@module-federation/bridge-vue3 0.24.1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/index.cjs +5 -5
- package/dist/index.js +331 -323
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -61,17 +61,17 @@ function generateSnapshotFromManifest(r, t = {}) {
|
|
|
61
61
|
var S, _, T;
|
|
62
62
|
const { remotes: n = {}, overrides: o = {}, version: s } = t;
|
|
63
63
|
let i;
|
|
64
|
-
const
|
|
64
|
+
const a = () => "publicPath" in r.metaData ? r.metaData.publicPath === "auto" && s ? inferAutoPublicPath(s) : r.metaData.publicPath : r.metaData.getPublicPath, c = Object.keys(o);
|
|
65
65
|
let u = {};
|
|
66
|
-
Object.keys(n).length || (u = ((S = r.remotes) == null ? void 0 : S.reduce((I,
|
|
67
|
-
let
|
|
68
|
-
const k =
|
|
69
|
-
return
|
|
70
|
-
matchedVersion:
|
|
66
|
+
Object.keys(n).length || (u = ((S = r.remotes) == null ? void 0 : S.reduce((I, w) => {
|
|
67
|
+
let A;
|
|
68
|
+
const k = w.federationContainerName;
|
|
69
|
+
return c.includes(k) ? A = o[k] : "version" in w ? A = w.version : A = w.entry, I[k] = {
|
|
70
|
+
matchedVersion: A
|
|
71
71
|
}, I;
|
|
72
72
|
}, {})) || {}), Object.keys(n).forEach((I) => u[I] = {
|
|
73
73
|
// overrides will override dependencies
|
|
74
|
-
matchedVersion:
|
|
74
|
+
matchedVersion: c.includes(I) ? o[I] : n[I]
|
|
75
75
|
});
|
|
76
76
|
const { remoteEntry: { path: l, name: d, type: y }, types: p = { path: "", name: "", zip: "", api: "" }, buildInfo: { buildVersion: m }, globalName: g, ssrRemoteEntry: b } = r.metaData, { exposes: E } = r;
|
|
77
77
|
let R = {
|
|
@@ -105,20 +105,20 @@ function generateSnapshotFromManifest(r, t = {}) {
|
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
107
|
if ((T = r.metaData) != null && T.prefetchEntry) {
|
|
108
|
-
const { path: I, name:
|
|
108
|
+
const { path: I, name: w, type: A } = r.metaData.prefetchEntry;
|
|
109
109
|
R = {
|
|
110
110
|
...R,
|
|
111
|
-
prefetchEntry: simpleJoinRemoteEntry(I,
|
|
112
|
-
prefetchEntryType:
|
|
111
|
+
prefetchEntry: simpleJoinRemoteEntry(I, w),
|
|
112
|
+
prefetchEntryType: A
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
if ("publicPath" in r.metaData ? i = {
|
|
116
116
|
...R,
|
|
117
|
-
publicPath:
|
|
117
|
+
publicPath: a(),
|
|
118
118
|
ssrPublicPath: r.metaData.ssrPublicPath
|
|
119
119
|
} : i = {
|
|
120
120
|
...R,
|
|
121
|
-
getPublicPath:
|
|
121
|
+
getPublicPath: a()
|
|
122
122
|
}, b) {
|
|
123
123
|
const I = simpleJoinRemoteEntry(b.path, b.name);
|
|
124
124
|
i.ssrRemoteEntry = I, i.ssrRemoteEntryType = b.type || "commonjs-module";
|
|
@@ -164,7 +164,7 @@ class Logger {
|
|
|
164
164
|
this.delegate = t ?? DEFAULT_DELEGATE;
|
|
165
165
|
}
|
|
166
166
|
emit(t, n) {
|
|
167
|
-
const o = this.delegate, i = isDebugMode() ? captureStackTrace() : void 0,
|
|
167
|
+
const o = this.delegate, i = isDebugMode() ? captureStackTrace() : void 0, a = i ? [...n, i] : n, c = (() => {
|
|
168
168
|
switch (t) {
|
|
169
169
|
case "log":
|
|
170
170
|
return ["log", "info"];
|
|
@@ -179,17 +179,17 @@ class Logger {
|
|
|
179
179
|
return ["debug", "log"];
|
|
180
180
|
}
|
|
181
181
|
})();
|
|
182
|
-
for (const u of
|
|
182
|
+
for (const u of c) {
|
|
183
183
|
const l = o[u];
|
|
184
184
|
if (typeof l == "function") {
|
|
185
|
-
l.call(o, this.prefix, ...
|
|
185
|
+
l.call(o, this.prefix, ...a);
|
|
186
186
|
return;
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
for (const u of
|
|
189
|
+
for (const u of c) {
|
|
190
190
|
const l = DEFAULT_DELEGATE[u];
|
|
191
191
|
if (typeof l == "function") {
|
|
192
|
-
l.call(DEFAULT_DELEGATE, this.prefix, ...
|
|
192
|
+
l.call(DEFAULT_DELEGATE, this.prefix, ...a);
|
|
193
193
|
return;
|
|
194
194
|
}
|
|
195
195
|
}
|
|
@@ -243,22 +243,22 @@ function isStaticResourcesEqual(r, t) {
|
|
|
243
243
|
function createScript(r) {
|
|
244
244
|
let t = null, n = !0, o = 2e4, s;
|
|
245
245
|
const i = document.getElementsByTagName("script");
|
|
246
|
-
for (let
|
|
247
|
-
const u = i[
|
|
246
|
+
for (let c = 0; c < i.length; c++) {
|
|
247
|
+
const u = i[c], l = u.getAttribute("src");
|
|
248
248
|
if (l && isStaticResourcesEqual(l, r.url)) {
|
|
249
249
|
t = u, n = !1;
|
|
250
250
|
break;
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
253
|
if (!t) {
|
|
254
|
-
const
|
|
255
|
-
t = document.createElement("script"), t.type = (
|
|
254
|
+
const c = r.attrs;
|
|
255
|
+
t = document.createElement("script"), t.type = (c == null ? void 0 : c.type) === "module" ? "module" : "text/javascript";
|
|
256
256
|
let u;
|
|
257
|
-
r.createScriptHook && (u = r.createScriptHook(r.url, r.attrs), u instanceof HTMLScriptElement ? t = u : typeof u == "object" && ("script" in u && u.script && (t = u.script), "timeout" in u && u.timeout && (o = u.timeout))), t.src || (t.src = r.url),
|
|
258
|
-
t && (l === "async" || l === "defer" ? t[l] =
|
|
257
|
+
r.createScriptHook && (u = r.createScriptHook(r.url, r.attrs), u instanceof HTMLScriptElement ? t = u : typeof u == "object" && ("script" in u && u.script && (t = u.script), "timeout" in u && u.timeout && (o = u.timeout))), t.src || (t.src = r.url), c && !u && Object.keys(c).forEach((l) => {
|
|
258
|
+
t && (l === "async" || l === "defer" ? t[l] = c[l] : t.getAttribute(l) || t.setAttribute(l, c[l]));
|
|
259
259
|
});
|
|
260
260
|
}
|
|
261
|
-
const
|
|
261
|
+
const a = async (c, u) => {
|
|
262
262
|
clearTimeout(s);
|
|
263
263
|
const l = () => {
|
|
264
264
|
(u == null ? void 0 : u.type) === "error" ? r != null && r.onErrorCallback && (r == null || r.onErrorCallback(u)) : r != null && r.cb && (r == null || r.cb());
|
|
@@ -266,8 +266,8 @@ function createScript(r) {
|
|
|
266
266
|
if (t && (t.onerror = null, t.onload = null, safeWrapper(() => {
|
|
267
267
|
const { needDeleteScript: d = !0 } = r;
|
|
268
268
|
d && t != null && t.parentNode && t.parentNode.removeChild(t);
|
|
269
|
-
}),
|
|
270
|
-
const d =
|
|
269
|
+
}), c && typeof c == "function")) {
|
|
270
|
+
const d = c(u);
|
|
271
271
|
if (d instanceof Promise) {
|
|
272
272
|
const y = await d;
|
|
273
273
|
return l(), y;
|
|
@@ -276,47 +276,47 @@ function createScript(r) {
|
|
|
276
276
|
}
|
|
277
277
|
l();
|
|
278
278
|
};
|
|
279
|
-
return t.onerror =
|
|
280
|
-
|
|
279
|
+
return t.onerror = a.bind(null, t.onerror), t.onload = a.bind(null, t.onload), s = setTimeout(() => {
|
|
280
|
+
a(null, new Error(`Remote script "${r.url}" time-outed.`));
|
|
281
281
|
}, o), { script: t, needAttach: n };
|
|
282
282
|
}
|
|
283
283
|
function createLink(r) {
|
|
284
284
|
let t = null, n = !0;
|
|
285
285
|
const o = document.getElementsByTagName("link");
|
|
286
286
|
for (let i = 0; i < o.length; i++) {
|
|
287
|
-
const
|
|
288
|
-
if (
|
|
289
|
-
t =
|
|
287
|
+
const a = o[i], c = a.getAttribute("href"), u = a.getAttribute("rel");
|
|
288
|
+
if (c && isStaticResourcesEqual(c, r.url) && u === r.attrs.rel) {
|
|
289
|
+
t = a, n = !1;
|
|
290
290
|
break;
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
if (!t) {
|
|
294
294
|
t = document.createElement("link"), t.setAttribute("href", r.url);
|
|
295
295
|
let i;
|
|
296
|
-
const
|
|
297
|
-
r.createLinkHook && (i = r.createLinkHook(r.url,
|
|
298
|
-
t && !t.getAttribute(
|
|
296
|
+
const a = r.attrs;
|
|
297
|
+
r.createLinkHook && (i = r.createLinkHook(r.url, a), i instanceof HTMLLinkElement && (t = i)), a && !i && Object.keys(a).forEach((c) => {
|
|
298
|
+
t && !t.getAttribute(c) && t.setAttribute(c, a[c]);
|
|
299
299
|
});
|
|
300
300
|
}
|
|
301
|
-
const s = (i,
|
|
302
|
-
const
|
|
303
|
-
(
|
|
301
|
+
const s = (i, a) => {
|
|
302
|
+
const c = () => {
|
|
303
|
+
(a == null ? void 0 : a.type) === "error" ? r != null && r.onErrorCallback && (r == null || r.onErrorCallback(a)) : r != null && r.cb && (r == null || r.cb());
|
|
304
304
|
};
|
|
305
305
|
if (t && (t.onerror = null, t.onload = null, safeWrapper(() => {
|
|
306
306
|
const { needDeleteLink: u = !0 } = r;
|
|
307
307
|
u && t != null && t.parentNode && t.parentNode.removeChild(t);
|
|
308
308
|
}), i)) {
|
|
309
|
-
const u = i(
|
|
310
|
-
return
|
|
309
|
+
const u = i(a);
|
|
310
|
+
return c(), u;
|
|
311
311
|
}
|
|
312
|
-
|
|
312
|
+
c();
|
|
313
313
|
};
|
|
314
314
|
return t.onerror = s.bind(null, t.onerror), t.onload = s.bind(null, t.onload), { link: t, needAttach: n };
|
|
315
315
|
}
|
|
316
316
|
function loadScript(r, t) {
|
|
317
317
|
const { attrs: n = {}, createScriptHook: o } = t;
|
|
318
318
|
return new Promise((s, i) => {
|
|
319
|
-
const { script:
|
|
319
|
+
const { script: a, needAttach: c } = createScript({
|
|
320
320
|
url: r,
|
|
321
321
|
cb: s,
|
|
322
322
|
onErrorCallback: i,
|
|
@@ -327,7 +327,7 @@ function loadScript(r, t) {
|
|
|
327
327
|
createScriptHook: o,
|
|
328
328
|
needDeleteScript: !0
|
|
329
329
|
});
|
|
330
|
-
|
|
330
|
+
c && document.head.appendChild(a);
|
|
331
331
|
});
|
|
332
332
|
}
|
|
333
333
|
const sdkImportCache = /* @__PURE__ */ new Map();
|
|
@@ -345,7 +345,7 @@ const loadNodeFetch = async () => {
|
|
|
345
345
|
const r = await importNodeModule("node-fetch");
|
|
346
346
|
return r.default || r;
|
|
347
347
|
}, lazyLoaderHookFetch = async (r, t, n) => {
|
|
348
|
-
const s = await ((i,
|
|
348
|
+
const s = await ((i, a) => n.lifecycle.fetch.emit(i, a))(r, t || {});
|
|
349
349
|
return !s || !(s instanceof Response) ? (typeof fetch > "u" ? await loadNodeFetch() : fetch)(r, t || {}) : s;
|
|
350
350
|
}, createScriptNode = typeof ENV_TARGET > "u" || ENV_TARGET !== "web" ? (url, cb, attrs, loaderHook) => {
|
|
351
351
|
if (loaderHook != null && loaderHook.createScriptHook) {
|
|
@@ -403,11 +403,11 @@ const loadNodeFetch = async () => {
|
|
|
403
403
|
t(new Error("createScriptNode is disabled in non-Node.js environment"));
|
|
404
404
|
}, loadScriptNode = typeof ENV_TARGET > "u" || ENV_TARGET !== "web" ? (r, t) => new Promise((n, o) => {
|
|
405
405
|
createScriptNode(r, (s, i) => {
|
|
406
|
-
var
|
|
406
|
+
var a, c;
|
|
407
407
|
if (s)
|
|
408
408
|
o(s);
|
|
409
409
|
else {
|
|
410
|
-
const u = ((
|
|
410
|
+
const u = ((a = t == null ? void 0 : t.attrs) == null ? void 0 : a.globalName) || `__FEDERATION_${(c = t == null ? void 0 : t.attrs) == null ? void 0 : c.name}:custom__`, l = globalThis[u] = i;
|
|
411
411
|
n(l);
|
|
412
412
|
}
|
|
413
413
|
}, t.attrs, t.loaderHook);
|
|
@@ -417,17 +417,17 @@ const loadNodeFetch = async () => {
|
|
|
417
417
|
async function loadModule(r, t) {
|
|
418
418
|
if (esmModuleCache.has(r))
|
|
419
419
|
return esmModuleCache.get(r);
|
|
420
|
-
const { fetch: n, vm: o } = t, i = await (await n(r)).text(),
|
|
420
|
+
const { fetch: n, vm: o } = t, i = await (await n(r)).text(), a = new o.SourceTextModule(i, {
|
|
421
421
|
// @ts-ignore
|
|
422
|
-
importModuleDynamically: async (
|
|
423
|
-
const l = new URL(
|
|
422
|
+
importModuleDynamically: async (c, u) => {
|
|
423
|
+
const l = new URL(c, r).href;
|
|
424
424
|
return loadModule(l, t);
|
|
425
425
|
}
|
|
426
426
|
});
|
|
427
|
-
return esmModuleCache.set(r,
|
|
428
|
-
const u = new URL(
|
|
427
|
+
return esmModuleCache.set(r, a), await a.link(async (c) => {
|
|
428
|
+
const u = new URL(c, r).href;
|
|
429
429
|
return await loadModule(u, t);
|
|
430
|
-
}),
|
|
430
|
+
}), a;
|
|
431
431
|
}
|
|
432
432
|
const LoggerInstance = createLogger("[ Module Federation Bridge Vue3 ]"), 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", RUNTIME_009 = "RUNTIME-009", getDocsUrl = (r) => `View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${r.split("-")[0].toLowerCase()}#${r.toLowerCase()}`, getShortErrorMsg = (r, t, n, o) => {
|
|
433
433
|
const s = [`${[t[r]]} #${r}`];
|
|
@@ -515,7 +515,7 @@ function includeOwnProperty(r, t) {
|
|
|
515
515
|
includeOwnProperty(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__") || definePropertyGlobalVal(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});
|
|
516
516
|
const globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;
|
|
517
517
|
function setGlobalDefaultVal(r) {
|
|
518
|
-
var t, n, o, s, i,
|
|
518
|
+
var t, n, o, s, i, a;
|
|
519
519
|
includeOwnProperty(r, "__VMOK__") && !includeOwnProperty(r, "__FEDERATION__") && definePropertyGlobalVal(r, "__FEDERATION__", r.__VMOK__), includeOwnProperty(r, "__FEDERATION__") || (definePropertyGlobalVal(r, "__FEDERATION__", {
|
|
520
520
|
__GLOBAL_PLUGIN__: [],
|
|
521
521
|
__INSTANCES__: [],
|
|
@@ -523,12 +523,12 @@ function setGlobalDefaultVal(r) {
|
|
|
523
523
|
__SHARE__: {},
|
|
524
524
|
__MANIFEST_LOADING__: {},
|
|
525
525
|
__PRELOADED_MAP__: /* @__PURE__ */ new Map()
|
|
526
|
-
}), definePropertyGlobalVal(r, "__VMOK__", r.__FEDERATION__)), (t = r.__FEDERATION__).__GLOBAL_PLUGIN__ ?? (t.__GLOBAL_PLUGIN__ = []), (n = r.__FEDERATION__).__INSTANCES__ ?? (n.__INSTANCES__ = []), (o = r.__FEDERATION__).moduleInfo ?? (o.moduleInfo = {}), (s = r.__FEDERATION__).__SHARE__ ?? (s.__SHARE__ = {}), (i = r.__FEDERATION__).__MANIFEST_LOADING__ ?? (i.__MANIFEST_LOADING__ = {}), (
|
|
526
|
+
}), definePropertyGlobalVal(r, "__VMOK__", r.__FEDERATION__)), (t = r.__FEDERATION__).__GLOBAL_PLUGIN__ ?? (t.__GLOBAL_PLUGIN__ = []), (n = r.__FEDERATION__).__INSTANCES__ ?? (n.__INSTANCES__ = []), (o = r.__FEDERATION__).moduleInfo ?? (o.moduleInfo = {}), (s = r.__FEDERATION__).__SHARE__ ?? (s.__SHARE__ = {}), (i = r.__FEDERATION__).__MANIFEST_LOADING__ ?? (i.__MANIFEST_LOADING__ = {}), (a = r.__FEDERATION__).__PRELOADED_MAP__ ?? (a.__PRELOADED_MAP__ = /* @__PURE__ */ new Map());
|
|
527
527
|
}
|
|
528
528
|
setGlobalDefaultVal(CurrentGlobal);
|
|
529
529
|
setGlobalDefaultVal(nativeGlobal);
|
|
530
530
|
function setGlobalFederationConstructor(r, t = isDebugMode()) {
|
|
531
|
-
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = r, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.
|
|
531
|
+
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = r, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "2.0.1");
|
|
532
532
|
}
|
|
533
533
|
function getInfoWithoutType(r, t) {
|
|
534
534
|
if (typeof t == "string") {
|
|
@@ -540,11 +540,11 @@ function getInfoWithoutType(r, t) {
|
|
|
540
540
|
{
|
|
541
541
|
const o = Object.keys(r);
|
|
542
542
|
for (const s of o) {
|
|
543
|
-
const [i,
|
|
543
|
+
const [i, a] = s.split(":"), c = `${i}:${t}`, u = r[c];
|
|
544
544
|
if (u)
|
|
545
545
|
return {
|
|
546
546
|
value: u,
|
|
547
|
-
key:
|
|
547
|
+
key: c
|
|
548
548
|
};
|
|
549
549
|
}
|
|
550
550
|
return {
|
|
@@ -560,9 +560,9 @@ const getGlobalSnapshot = () => nativeGlobal.__FEDERATION__.moduleInfo, getTarge
|
|
|
560
560
|
if (o && !o.version && "version" in r && r.version && (o.version = r.version), o)
|
|
561
561
|
return o;
|
|
562
562
|
if ("version" in r && r.version) {
|
|
563
|
-
const { version: s, ...i } = r,
|
|
564
|
-
if ((
|
|
565
|
-
return
|
|
563
|
+
const { version: s, ...i } = r, a = getFMId(i), c = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, a).value;
|
|
564
|
+
if ((c == null ? void 0 : c.version) === s)
|
|
565
|
+
return c;
|
|
566
566
|
}
|
|
567
567
|
}, getGlobalSnapshotInfoByModuleInfo = (r) => getTargetSnapshotInfoByModuleInfo(r, nativeGlobal.__FEDERATION__.moduleInfo), setGlobalSnapshotInfoByModuleInfo = (r, t) => {
|
|
568
568
|
const n = getFMId(r);
|
|
@@ -598,7 +598,7 @@ function combineVersion(r, t, n, o) {
|
|
|
598
598
|
return o ? `${s}-${o}` : s;
|
|
599
599
|
}
|
|
600
600
|
function parseHyphen(r) {
|
|
601
|
-
return r.replace(parseRegex(hyphenRange), (t, n, o, s, i,
|
|
601
|
+
return r.replace(parseRegex(hyphenRange), (t, n, o, s, i, a, c, u, l, d, y, p) => (isXVersion(o) ? n = "" : isXVersion(s) ? n = `>=${o}.0.0` : isXVersion(i) ? n = `>=${o}.${s}.0` : n = `>=${n}`, isXVersion(l) ? u = "" : isXVersion(d) ? u = `<${Number(l) + 1}.0.0-0` : isXVersion(y) ? u = `<${l}.${Number(d) + 1}.0-0` : p ? u = `<=${l}.${d}.${y}-${p}` : u = `<=${u}`, `${n} ${u}`.trim()));
|
|
602
602
|
}
|
|
603
603
|
function parseComparatorTrim(r) {
|
|
604
604
|
return r.replace(parseRegex(comparatorTrim), "$1$2$3");
|
|
@@ -610,15 +610,15 @@ function parseCaretTrim(r) {
|
|
|
610
610
|
return r.replace(parseRegex(caretTrim), "$1^");
|
|
611
611
|
}
|
|
612
612
|
function parseCarets(r) {
|
|
613
|
-
return r.trim().split(/\s+/).map((t) => t.replace(parseRegex(caret), (n, o, s, i,
|
|
613
|
+
return r.trim().split(/\s+/).map((t) => t.replace(parseRegex(caret), (n, o, s, i, a) => isXVersion(o) ? "" : isXVersion(s) ? `>=${o}.0.0 <${Number(o) + 1}.0.0-0` : isXVersion(i) ? 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}.${i}-${a} <${o}.${s}.${Number(i) + 1}-0` : `>=${o}.${s}.${i}-${a} <${o}.${Number(s) + 1}.0-0` : `>=${o}.${s}.${i}-${a} <${Number(o) + 1}.0.0-0` : o === "0" ? s === "0" ? `>=${o}.${s}.${i} <${o}.${s}.${Number(i) + 1}-0` : `>=${o}.${s}.${i} <${o}.${Number(s) + 1}.0-0` : `>=${o}.${s}.${i} <${Number(o) + 1}.0.0-0`)).join(" ");
|
|
614
614
|
}
|
|
615
615
|
function parseTildes(r) {
|
|
616
|
-
return r.trim().split(/\s+/).map((t) => t.replace(parseRegex(tilde), (n, o, s, i,
|
|
616
|
+
return r.trim().split(/\s+/).map((t) => t.replace(parseRegex(tilde), (n, o, s, i, a) => isXVersion(o) ? "" : isXVersion(s) ? `>=${o}.0.0 <${Number(o) + 1}.0.0-0` : isXVersion(i) ? `>=${o}.${s}.0 <${o}.${Number(s) + 1}.0-0` : a ? `>=${o}.${s}.${i}-${a} <${o}.${Number(s) + 1}.0-0` : `>=${o}.${s}.${i} <${o}.${Number(s) + 1}.0-0`)).join(" ");
|
|
617
617
|
}
|
|
618
618
|
function parseXRanges(r) {
|
|
619
|
-
return r.split(/\s+/).map((t) => t.trim().replace(parseRegex(xRange), (n, o, s, i,
|
|
620
|
-
const u = isXVersion(s), l = u || isXVersion(i), d = l || isXVersion(
|
|
621
|
-
return o === "=" && d && (o = ""),
|
|
619
|
+
return r.split(/\s+/).map((t) => t.trim().replace(parseRegex(xRange), (n, o, s, i, a, c) => {
|
|
620
|
+
const u = isXVersion(s), l = u || isXVersion(i), d = l || isXVersion(a);
|
|
621
|
+
return o === "=" && d && (o = ""), c = "", u ? o === ">" || o === "<" ? "<0.0.0-0" : "*" : o && d ? (l && (i = 0), a = 0, o === ">" ? (o = ">=", l ? (s = Number(s) + 1, i = 0, a = 0) : (i = Number(i) + 1, a = 0)) : o === "<=" && (o = "<", l ? s = Number(s) + 1 : i = Number(i) + 1), o === "<" && (c = "-0"), `${o + s}.${i}.${a}${c}`) : l ? `>=${s}.0.0${c} <${Number(s) + 1}.0.0-0` : d ? `>=${s}.${i}.0${c} <${s}.${Number(i) + 1}.0-0` : n;
|
|
622
622
|
})).join(" ");
|
|
623
623
|
}
|
|
624
624
|
function parseStar(r) {
|
|
@@ -639,9 +639,9 @@ function comparePreRelease(r, t) {
|
|
|
639
639
|
if (n === void 0 && o === void 0)
|
|
640
640
|
return 0;
|
|
641
641
|
for (let s = 0, i = n.length; s <= i; s++) {
|
|
642
|
-
const
|
|
643
|
-
if (
|
|
644
|
-
return
|
|
642
|
+
const a = n[s], c = o[s];
|
|
643
|
+
if (a !== c)
|
|
644
|
+
return a === void 0 && c === void 0 ? 0 : a ? c ? compareAtom(a, c) : -1 : 1;
|
|
645
645
|
}
|
|
646
646
|
return 0;
|
|
647
647
|
}
|
|
@@ -714,14 +714,14 @@ function satisfy(r, t) {
|
|
|
714
714
|
const n = extractComparator(r);
|
|
715
715
|
if (!n)
|
|
716
716
|
return !1;
|
|
717
|
-
const [, o, , s, i,
|
|
717
|
+
const [, o, , s, i, a, c] = n, u = {
|
|
718
718
|
operator: o,
|
|
719
|
-
version: combineVersion(s, i,
|
|
719
|
+
version: combineVersion(s, i, a, c),
|
|
720
720
|
// exclude build atom
|
|
721
721
|
major: s,
|
|
722
722
|
minor: i,
|
|
723
|
-
patch:
|
|
724
|
-
preRelease:
|
|
723
|
+
patch: a,
|
|
724
|
+
preRelease: c == null ? void 0 : c.split(".")
|
|
725
725
|
}, l = t.split("||");
|
|
726
726
|
for (const d of l) {
|
|
727
727
|
const y = d.trim();
|
|
@@ -744,15 +744,15 @@ function satisfy(r, t) {
|
|
|
744
744
|
b = !1;
|
|
745
745
|
break;
|
|
746
746
|
}
|
|
747
|
-
const [, S, , _, T, I,
|
|
747
|
+
const [, S, , _, T, I, w] = R, A = {
|
|
748
748
|
operator: S,
|
|
749
|
-
version: combineVersion(_, T, I,
|
|
749
|
+
version: combineVersion(_, T, I, w),
|
|
750
750
|
major: _,
|
|
751
751
|
minor: T,
|
|
752
752
|
patch: I,
|
|
753
|
-
preRelease:
|
|
753
|
+
preRelease: w == null ? void 0 : w.split(".")
|
|
754
754
|
};
|
|
755
|
-
if (!compare(
|
|
755
|
+
if (!compare(A, u)) {
|
|
756
756
|
b = !1;
|
|
757
757
|
break;
|
|
758
758
|
}
|
|
@@ -767,11 +767,11 @@ function satisfy(r, t) {
|
|
|
767
767
|
return !1;
|
|
768
768
|
}
|
|
769
769
|
function formatShare(r, t, n, o) {
|
|
770
|
-
var i;
|
|
770
|
+
var i, a;
|
|
771
771
|
let s;
|
|
772
772
|
if ("get" in r ? s = r.get : "lib" in r ? s = () => Promise.resolve(r.lib) : s = () => Promise.resolve(() => {
|
|
773
773
|
throw new Error(`Can not get shared '${n}'!`);
|
|
774
|
-
}), (i = r.shareConfig) != null && i.eager && r.treeShaking)
|
|
774
|
+
}), (i = r.shareConfig) != null && i.eager && ((a = r.treeShaking) != null && a.mode))
|
|
775
775
|
throw new Error('Can not set "eager:true" and "treeShaking" at the same time!');
|
|
776
776
|
return {
|
|
777
777
|
deps: [],
|
|
@@ -800,18 +800,18 @@ function formatShare(r, t, n, o) {
|
|
|
800
800
|
};
|
|
801
801
|
}
|
|
802
802
|
function formatShareConfigs(r, t) {
|
|
803
|
-
const n = t.shared || {}, o = t.name, s = Object.keys(n).reduce((
|
|
804
|
-
const u = arrayOptions(n[
|
|
805
|
-
return c
|
|
806
|
-
c
|
|
807
|
-
}),
|
|
803
|
+
const n = t.shared || {}, o = t.name, s = Object.keys(n).reduce((a, c) => {
|
|
804
|
+
const u = arrayOptions(n[c]);
|
|
805
|
+
return a[c] = a[c] || [], u.forEach((l) => {
|
|
806
|
+
a[c].push(formatShare(l, o, c, t.shareStrategy));
|
|
807
|
+
}), a;
|
|
808
808
|
}, {}), i = {
|
|
809
809
|
...r.shared
|
|
810
810
|
};
|
|
811
|
-
return Object.keys(s).forEach((
|
|
812
|
-
i[
|
|
813
|
-
i[
|
|
814
|
-
}) : i[
|
|
811
|
+
return Object.keys(s).forEach((a) => {
|
|
812
|
+
i[a] ? s[a].forEach((c) => {
|
|
813
|
+
i[a].find((l) => l.version === c.version) || i[a].push(c);
|
|
814
|
+
}) : i[a] = s[a];
|
|
815
815
|
}), { allShareInfos: i, newShareInfos: s };
|
|
816
816
|
}
|
|
817
817
|
function shouldUseTreeShaking(r, t) {
|
|
@@ -824,10 +824,10 @@ function versionLt(r, t) {
|
|
|
824
824
|
const n = (o) => {
|
|
825
825
|
if (!Number.isNaN(Number(o))) {
|
|
826
826
|
const i = o.split(".");
|
|
827
|
-
let
|
|
828
|
-
for (let
|
|
829
|
-
|
|
830
|
-
return
|
|
827
|
+
let a = o;
|
|
828
|
+
for (let c = 0; c < 3 - i.length; c++)
|
|
829
|
+
a += ".0";
|
|
830
|
+
return a;
|
|
831
831
|
}
|
|
832
832
|
return o;
|
|
833
833
|
};
|
|
@@ -846,29 +846,29 @@ const findVersion = (r, t) => {
|
|
|
846
846
|
};
|
|
847
847
|
function findSingletonVersionOrderByVersion(r, t, n, o) {
|
|
848
848
|
const s = r[t][n];
|
|
849
|
-
let i = "",
|
|
850
|
-
const
|
|
851
|
-
return
|
|
849
|
+
let i = "", a = shouldUseTreeShaking(o);
|
|
850
|
+
const c = function(u, l) {
|
|
851
|
+
return a ? s[u].treeShaking ? s[l].treeShaking ? !isLoaded(s[u].treeShaking) && versionLt(u, l) : !1 : !0 : !isLoaded(s[u]) && versionLt(u, l);
|
|
852
852
|
};
|
|
853
|
-
if (
|
|
854
|
-
if (i = findVersion(r[t][n],
|
|
853
|
+
if (a) {
|
|
854
|
+
if (i = findVersion(r[t][n], c), i)
|
|
855
855
|
return {
|
|
856
856
|
version: i,
|
|
857
|
-
useTreesShaking:
|
|
857
|
+
useTreesShaking: a
|
|
858
858
|
};
|
|
859
|
-
|
|
859
|
+
a = !1;
|
|
860
860
|
}
|
|
861
861
|
return {
|
|
862
|
-
version: findVersion(r[t][n],
|
|
863
|
-
useTreesShaking:
|
|
862
|
+
version: findVersion(r[t][n], c),
|
|
863
|
+
useTreesShaking: a
|
|
864
864
|
};
|
|
865
865
|
}
|
|
866
866
|
const isLoadingOrLoaded = (r) => isLoaded(r) || isLoading(r);
|
|
867
867
|
function findSingletonVersionOrderByLoaded(r, t, n, o) {
|
|
868
868
|
const s = r[t][n];
|
|
869
|
-
let i = "",
|
|
870
|
-
const
|
|
871
|
-
if (
|
|
869
|
+
let i = "", a = shouldUseTreeShaking(o);
|
|
870
|
+
const c = function(u, l) {
|
|
871
|
+
if (a) {
|
|
872
872
|
if (!s[u].treeShaking)
|
|
873
873
|
return !0;
|
|
874
874
|
if (!s[l].treeShaking)
|
|
@@ -880,17 +880,17 @@ function findSingletonVersionOrderByLoaded(r, t, n, o) {
|
|
|
880
880
|
}
|
|
881
881
|
return isLoadingOrLoaded(s[l]) ? isLoadingOrLoaded(s[u]) ? !!versionLt(u, l) : !0 : isLoadingOrLoaded(s[u]) ? !1 : versionLt(u, l);
|
|
882
882
|
};
|
|
883
|
-
if (
|
|
884
|
-
if (i = findVersion(r[t][n],
|
|
883
|
+
if (a) {
|
|
884
|
+
if (i = findVersion(r[t][n], c), i)
|
|
885
885
|
return {
|
|
886
886
|
version: i,
|
|
887
|
-
useTreesShaking:
|
|
887
|
+
useTreesShaking: a
|
|
888
888
|
};
|
|
889
|
-
|
|
889
|
+
a = !1;
|
|
890
890
|
}
|
|
891
891
|
return {
|
|
892
|
-
version: findVersion(r[t][n],
|
|
893
|
-
useTreesShaking:
|
|
892
|
+
version: findVersion(r[t][n], c),
|
|
893
|
+
useTreesShaking: a
|
|
894
894
|
};
|
|
895
895
|
}
|
|
896
896
|
function getFindShareFunction(r) {
|
|
@@ -899,10 +899,10 @@ function getFindShareFunction(r) {
|
|
|
899
899
|
function getRegisteredShare(r, t, n, o) {
|
|
900
900
|
if (!r)
|
|
901
901
|
return;
|
|
902
|
-
const { shareConfig: s, scope: i = DEFAULT_SCOPE, strategy:
|
|
902
|
+
const { shareConfig: s, scope: i = DEFAULT_SCOPE, strategy: a, treeShaking: c } = n, u = Array.isArray(i) ? i : [i];
|
|
903
903
|
for (const l of u)
|
|
904
904
|
if (s && r[l] && r[l][t]) {
|
|
905
|
-
const { requiredVersion: d } = s, y = getFindShareFunction(
|
|
905
|
+
const { requiredVersion: d } = s, y = getFindShareFunction(a), { version: p, useTreesShaking: m } = y(r, l, t, c), g = () => {
|
|
906
906
|
const R = r[l][t][p];
|
|
907
907
|
if (s.singleton) {
|
|
908
908
|
if (typeof d == "string" && !satisfy(p, d)) {
|
|
@@ -924,10 +924,10 @@ function getRegisteredShare(r, t, n, o) {
|
|
|
924
924
|
shared: R,
|
|
925
925
|
useTreesShaking: m
|
|
926
926
|
};
|
|
927
|
-
const S = shouldUseTreeShaking(
|
|
927
|
+
const S = shouldUseTreeShaking(c);
|
|
928
928
|
if (S) {
|
|
929
929
|
for (const [_, T] of Object.entries(r[l][t]))
|
|
930
|
-
if (shouldUseTreeShaking(T.treeShaking,
|
|
930
|
+
if (shouldUseTreeShaking(T.treeShaking, c == null ? void 0 : c.usedExports) && satisfy(_, d))
|
|
931
931
|
return {
|
|
932
932
|
shared: T,
|
|
933
933
|
useTreesShaking: S
|
|
@@ -970,17 +970,17 @@ function getTargetSharedOptions(r) {
|
|
|
970
970
|
);
|
|
971
971
|
});
|
|
972
972
|
return l[y];
|
|
973
|
-
}, i = (n == null ? void 0 : n.resolver) ?? s,
|
|
973
|
+
}, i = (n == null ? void 0 : n.resolver) ?? s, a = (u) => u !== null && typeof u == "object" && !Array.isArray(u), c = (...u) => {
|
|
974
974
|
const l = {};
|
|
975
975
|
for (const d of u)
|
|
976
976
|
if (d)
|
|
977
977
|
for (const [y, p] of Object.entries(d)) {
|
|
978
978
|
const m = l[y];
|
|
979
|
-
|
|
979
|
+
a(m) && a(p) ? l[y] = c(m, p) : p !== void 0 && (l[y] = p);
|
|
980
980
|
}
|
|
981
981
|
return l;
|
|
982
982
|
};
|
|
983
|
-
return
|
|
983
|
+
return c(i(o[t]), n == null ? void 0 : n.customShareInfo);
|
|
984
984
|
}
|
|
985
985
|
const addUseIn = (r, t) => {
|
|
986
986
|
r.useIn || (r.useIn = []), addUniqueItem(r.useIn, t);
|
|
@@ -1000,9 +1000,9 @@ function matchRemoteWithNameAndExpose(r, t) {
|
|
|
1000
1000
|
let s = t.replace(n.name, "");
|
|
1001
1001
|
if (o) {
|
|
1002
1002
|
if (s.startsWith("/")) {
|
|
1003
|
-
const
|
|
1003
|
+
const c = n.name;
|
|
1004
1004
|
return s = `.${s}`, {
|
|
1005
|
-
pkgNameOrAlias:
|
|
1005
|
+
pkgNameOrAlias: c,
|
|
1006
1006
|
expose: s,
|
|
1007
1007
|
remote: n
|
|
1008
1008
|
};
|
|
@@ -1014,16 +1014,16 @@ function matchRemoteWithNameAndExpose(r, t) {
|
|
|
1014
1014
|
};
|
|
1015
1015
|
}
|
|
1016
1016
|
const i = n.alias && t.startsWith(n.alias);
|
|
1017
|
-
let
|
|
1017
|
+
let a = n.alias && t.replace(n.alias, "");
|
|
1018
1018
|
if (n.alias && i) {
|
|
1019
|
-
if (
|
|
1020
|
-
const
|
|
1021
|
-
return
|
|
1022
|
-
pkgNameOrAlias:
|
|
1023
|
-
expose:
|
|
1019
|
+
if (a && a.startsWith("/")) {
|
|
1020
|
+
const c = n.alias;
|
|
1021
|
+
return a = `.${a}`, {
|
|
1022
|
+
pkgNameOrAlias: c,
|
|
1023
|
+
expose: a,
|
|
1024
1024
|
remote: n
|
|
1025
1025
|
};
|
|
1026
|
-
} else if (
|
|
1026
|
+
} else if (a === "")
|
|
1027
1027
|
return {
|
|
1028
1028
|
pkgNameOrAlias: n.alias,
|
|
1029
1029
|
expose: ".",
|
|
@@ -1092,24 +1092,24 @@ async function loadEntryScript({ name: r, globalName: t, entry: n, loaderHook: o
|
|
|
1092
1092
|
const { entryExports: i } = getRemoteEntryExports(r, t);
|
|
1093
1093
|
if (i)
|
|
1094
1094
|
return i;
|
|
1095
|
-
const
|
|
1096
|
-
return loadScript(
|
|
1095
|
+
const a = s ? s(n) : n;
|
|
1096
|
+
return loadScript(a, {
|
|
1097
1097
|
attrs: {},
|
|
1098
|
-
createScriptHook: (
|
|
1099
|
-
const l = o.lifecycle.createScript.emit({ url:
|
|
1098
|
+
createScriptHook: (c, u) => {
|
|
1099
|
+
const l = o.lifecycle.createScript.emit({ url: c, attrs: u });
|
|
1100
1100
|
if (l && (l instanceof HTMLScriptElement || "script" in l || "timeout" in l))
|
|
1101
1101
|
return l;
|
|
1102
1102
|
}
|
|
1103
|
-
}).then(() => handleRemoteEntryLoaded(r, t, n)).catch((
|
|
1103
|
+
}).then(() => handleRemoteEntryLoaded(r, t, n)).catch((c) => {
|
|
1104
1104
|
throw assert(void 0, getShortErrorMsg(RUNTIME_008, runtimeDescMap, {
|
|
1105
1105
|
remoteName: r,
|
|
1106
1106
|
resourceUrl: n
|
|
1107
|
-
})),
|
|
1107
|
+
})), c;
|
|
1108
1108
|
});
|
|
1109
1109
|
}
|
|
1110
1110
|
async function loadEntryDom({ remoteInfo: r, remoteEntryExports: t, loaderHook: n, getEntryUrl: o }) {
|
|
1111
|
-
const { entry: s, entryGlobalName: i, name:
|
|
1112
|
-
switch (
|
|
1111
|
+
const { entry: s, entryGlobalName: i, name: a, type: c } = r;
|
|
1112
|
+
switch (c) {
|
|
1113
1113
|
case "esm":
|
|
1114
1114
|
case "module":
|
|
1115
1115
|
return loadEsmEntry({ entry: s, remoteEntryExports: t });
|
|
@@ -1119,25 +1119,25 @@ async function loadEntryDom({ remoteInfo: r, remoteEntryExports: t, loaderHook:
|
|
|
1119
1119
|
return loadEntryScript({
|
|
1120
1120
|
entry: s,
|
|
1121
1121
|
globalName: i,
|
|
1122
|
-
name:
|
|
1122
|
+
name: a,
|
|
1123
1123
|
loaderHook: n,
|
|
1124
1124
|
getEntryUrl: o
|
|
1125
1125
|
});
|
|
1126
1126
|
}
|
|
1127
1127
|
}
|
|
1128
1128
|
async function loadEntryNode({ remoteInfo: r, loaderHook: t }) {
|
|
1129
|
-
const { entry: n, entryGlobalName: o, name: s, type: i } = r, { entryExports:
|
|
1130
|
-
return
|
|
1129
|
+
const { entry: n, entryGlobalName: o, name: s, type: i } = r, { entryExports: a } = getRemoteEntryExports(s, o);
|
|
1130
|
+
return a || loadScriptNode(n, {
|
|
1131
1131
|
attrs: { name: s, globalName: o, type: i },
|
|
1132
1132
|
loaderHook: {
|
|
1133
|
-
createScriptHook: (
|
|
1134
|
-
const l = t.lifecycle.createScript.emit({ url:
|
|
1133
|
+
createScriptHook: (c, u = {}) => {
|
|
1134
|
+
const l = t.lifecycle.createScript.emit({ url: c, attrs: u });
|
|
1135
1135
|
if (l && "url" in l)
|
|
1136
1136
|
return l;
|
|
1137
1137
|
}
|
|
1138
1138
|
}
|
|
1139
|
-
}).then(() => handleRemoteEntryLoaded(s, o, n)).catch((
|
|
1140
|
-
throw
|
|
1139
|
+
}).then(() => handleRemoteEntryLoaded(s, o, n)).catch((c) => {
|
|
1140
|
+
throw c;
|
|
1141
1141
|
});
|
|
1142
1142
|
}
|
|
1143
1143
|
function getRemoteEntryUniqueKey(r) {
|
|
@@ -1145,12 +1145,12 @@ function getRemoteEntryUniqueKey(r) {
|
|
|
1145
1145
|
return composeKeyWithSeparator(n, t);
|
|
1146
1146
|
}
|
|
1147
1147
|
async function getRemoteEntry(r) {
|
|
1148
|
-
const { origin: t, remoteEntryExports: n, remoteInfo: o, getEntryUrl: s, _inErrorHandling: i = !1 } = r,
|
|
1148
|
+
const { origin: t, remoteEntryExports: n, remoteInfo: o, getEntryUrl: s, _inErrorHandling: i = !1 } = r, a = getRemoteEntryUniqueKey(o);
|
|
1149
1149
|
if (n)
|
|
1150
1150
|
return n;
|
|
1151
|
-
if (!globalLoading[
|
|
1152
|
-
const
|
|
1153
|
-
globalLoading[
|
|
1151
|
+
if (!globalLoading[a]) {
|
|
1152
|
+
const c = t.remoteHandler.hooks.lifecycle.loadEntry, u = t.loaderHook;
|
|
1153
|
+
globalLoading[a] = c.emit({
|
|
1154
1154
|
loaderHook: u,
|
|
1155
1155
|
remoteInfo: o,
|
|
1156
1156
|
remoteEntryExports: n
|
|
@@ -1176,7 +1176,7 @@ async function getRemoteEntry(r) {
|
|
|
1176
1176
|
throw l;
|
|
1177
1177
|
});
|
|
1178
1178
|
}
|
|
1179
|
-
return globalLoading[
|
|
1179
|
+
return globalLoading[a];
|
|
1180
1180
|
}
|
|
1181
1181
|
function getRemoteInfo(r) {
|
|
1182
1182
|
return {
|
|
@@ -1212,10 +1212,10 @@ function normalizePreloadExposes(r) {
|
|
|
1212
1212
|
return r ? r.map((t) => t === "." ? t : t.startsWith("./") ? t.replace("./", "") : t) : [];
|
|
1213
1213
|
}
|
|
1214
1214
|
function preloadAssets(r, t, n, o = !0) {
|
|
1215
|
-
const { cssAssets: s, jsAssetsWithoutEntry: i, entryAssets:
|
|
1215
|
+
const { cssAssets: s, jsAssetsWithoutEntry: i, entryAssets: a } = n;
|
|
1216
1216
|
if (t.options.inBrowser) {
|
|
1217
|
-
if (
|
|
1218
|
-
const { moduleInfo: u } =
|
|
1217
|
+
if (a.forEach((c) => {
|
|
1218
|
+
const { moduleInfo: u } = c, l = t.moduleCache.get(r.name);
|
|
1219
1219
|
getRemoteEntry(l ? {
|
|
1220
1220
|
origin: t,
|
|
1221
1221
|
remoteInfo: u,
|
|
@@ -1226,7 +1226,7 @@ function preloadAssets(r, t, n, o = !0) {
|
|
|
1226
1226
|
remoteEntryExports: void 0
|
|
1227
1227
|
});
|
|
1228
1228
|
}), o) {
|
|
1229
|
-
const
|
|
1229
|
+
const c = {
|
|
1230
1230
|
rel: "preload",
|
|
1231
1231
|
as: "style"
|
|
1232
1232
|
};
|
|
@@ -1235,7 +1235,7 @@ function preloadAssets(r, t, n, o = !0) {
|
|
|
1235
1235
|
url: u,
|
|
1236
1236
|
cb: () => {
|
|
1237
1237
|
},
|
|
1238
|
-
attrs:
|
|
1238
|
+
attrs: c,
|
|
1239
1239
|
createLinkHook: (y, p) => {
|
|
1240
1240
|
const m = t.loaderHook.lifecycle.createLink.emit({
|
|
1241
1241
|
url: y,
|
|
@@ -1248,7 +1248,7 @@ function preloadAssets(r, t, n, o = !0) {
|
|
|
1248
1248
|
d && document.head.appendChild(l);
|
|
1249
1249
|
});
|
|
1250
1250
|
} else {
|
|
1251
|
-
const
|
|
1251
|
+
const c = {
|
|
1252
1252
|
rel: "stylesheet",
|
|
1253
1253
|
type: "text/css"
|
|
1254
1254
|
};
|
|
@@ -1257,7 +1257,7 @@ function preloadAssets(r, t, n, o = !0) {
|
|
|
1257
1257
|
url: u,
|
|
1258
1258
|
cb: () => {
|
|
1259
1259
|
},
|
|
1260
|
-
attrs:
|
|
1260
|
+
attrs: c,
|
|
1261
1261
|
createLinkHook: (y, p) => {
|
|
1262
1262
|
const m = t.loaderHook.lifecycle.createLink.emit({
|
|
1263
1263
|
url: y,
|
|
@@ -1272,7 +1272,7 @@ function preloadAssets(r, t, n, o = !0) {
|
|
|
1272
1272
|
});
|
|
1273
1273
|
}
|
|
1274
1274
|
if (o) {
|
|
1275
|
-
const
|
|
1275
|
+
const c = {
|
|
1276
1276
|
rel: "preload",
|
|
1277
1277
|
as: "script"
|
|
1278
1278
|
};
|
|
@@ -1281,7 +1281,7 @@ function preloadAssets(r, t, n, o = !0) {
|
|
|
1281
1281
|
url: u,
|
|
1282
1282
|
cb: () => {
|
|
1283
1283
|
},
|
|
1284
|
-
attrs:
|
|
1284
|
+
attrs: c,
|
|
1285
1285
|
createLinkHook: (y, p) => {
|
|
1286
1286
|
const m = t.loaderHook.lifecycle.createLink.emit({
|
|
1287
1287
|
url: y,
|
|
@@ -1294,7 +1294,7 @@ function preloadAssets(r, t, n, o = !0) {
|
|
|
1294
1294
|
d && document.head.appendChild(l);
|
|
1295
1295
|
});
|
|
1296
1296
|
} else {
|
|
1297
|
-
const
|
|
1297
|
+
const c = {
|
|
1298
1298
|
fetchpriority: "high",
|
|
1299
1299
|
type: (r == null ? void 0 : r.type) === "module" ? "module" : "text/javascript"
|
|
1300
1300
|
};
|
|
@@ -1303,7 +1303,7 @@ function preloadAssets(r, t, n, o = !0) {
|
|
|
1303
1303
|
url: u,
|
|
1304
1304
|
cb: () => {
|
|
1305
1305
|
},
|
|
1306
|
-
attrs:
|
|
1306
|
+
attrs: c,
|
|
1307
1307
|
createScriptHook: (y, p) => {
|
|
1308
1308
|
const m = t.loaderHook.lifecycle.createScript.emit({
|
|
1309
1309
|
url: y,
|
|
@@ -1321,8 +1321,8 @@ function preloadAssets(r, t, n, o = !0) {
|
|
|
1321
1321
|
}
|
|
1322
1322
|
function createRemoteEntryInitOptions(r, t) {
|
|
1323
1323
|
const n = t, o = Array.isArray(r.shareScope) ? r.shareScope : [r.shareScope];
|
|
1324
|
-
o.length || o.push("default"), o.forEach((
|
|
1325
|
-
n[
|
|
1324
|
+
o.length || o.push("default"), o.forEach((c) => {
|
|
1325
|
+
n[c] || (n[c] = {});
|
|
1326
1326
|
});
|
|
1327
1327
|
const s = {
|
|
1328
1328
|
version: r.version || "",
|
|
@@ -1358,13 +1358,16 @@ class Module {
|
|
|
1358
1358
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1359
1359
|
async init(t, n) {
|
|
1360
1360
|
const o = await this.getEntry();
|
|
1361
|
-
if (
|
|
1362
|
-
|
|
1363
|
-
|
|
1361
|
+
if (this.inited)
|
|
1362
|
+
return o;
|
|
1363
|
+
if (this.initPromise)
|
|
1364
|
+
return await this.initPromise, o;
|
|
1365
|
+
this.initing = !0, this.initPromise = (async () => {
|
|
1366
|
+
const { remoteEntryInitOptions: s, shareScope: i, initScope: a } = createRemoteEntryInitOptions(this.remoteInfo, this.host.shareScopeMap), c = await this.host.hooks.lifecycle.beforeInitContainer.emit({
|
|
1364
1367
|
shareScope: i,
|
|
1365
1368
|
// @ts-ignore shareScopeMap will be set by Object.defineProperty
|
|
1366
1369
|
remoteEntryInitOptions: s,
|
|
1367
|
-
initScope:
|
|
1370
|
+
initScope: a,
|
|
1368
1371
|
remoteInfo: this.remoteInfo,
|
|
1369
1372
|
origin: this.host
|
|
1370
1373
|
});
|
|
@@ -1373,26 +1376,31 @@ class Module {
|
|
|
1373
1376
|
remoteName: this.remoteInfo.name,
|
|
1374
1377
|
remoteEntryUrl: this.remoteInfo.entry,
|
|
1375
1378
|
remoteEntryKey: this.remoteInfo.entryGlobalName
|
|
1376
|
-
})), await o.init(
|
|
1377
|
-
...
|
|
1379
|
+
})), await o.init(c.shareScope, c.initScope, c.remoteEntryInitOptions), await this.host.hooks.lifecycle.initContainer.emit({
|
|
1380
|
+
...c,
|
|
1378
1381
|
id: t,
|
|
1379
1382
|
remoteSnapshot: n,
|
|
1380
1383
|
remoteEntryExports: o
|
|
1381
1384
|
}), this.inited = !0;
|
|
1385
|
+
})();
|
|
1386
|
+
try {
|
|
1387
|
+
await this.initPromise;
|
|
1388
|
+
} finally {
|
|
1389
|
+
this.initing = !1, this.initPromise = void 0;
|
|
1382
1390
|
}
|
|
1383
1391
|
return o;
|
|
1384
1392
|
}
|
|
1385
1393
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1386
1394
|
async get(t, n, o, s) {
|
|
1387
|
-
const { loadFactory: i = !0 } = o || { loadFactory: !0 },
|
|
1388
|
-
this.lib =
|
|
1389
|
-
let
|
|
1390
|
-
|
|
1391
|
-
remoteEntryExports:
|
|
1395
|
+
const { loadFactory: i = !0 } = o || { loadFactory: !0 }, a = await this.init(t, s);
|
|
1396
|
+
this.lib = a;
|
|
1397
|
+
let c;
|
|
1398
|
+
c = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
|
|
1399
|
+
remoteEntryExports: a,
|
|
1392
1400
|
expose: n,
|
|
1393
1401
|
moduleInfo: this.remoteInfo
|
|
1394
|
-
}),
|
|
1395
|
-
const u = processModuleAlias(this.remoteInfo.name, n), l = this.wraperFactory(
|
|
1402
|
+
}), c || (c = await a.get(n)), assert(c, `${getFMId(this.remoteInfo)} remote don't export ${n}.`);
|
|
1403
|
+
const u = processModuleAlias(this.remoteInfo.name, n), l = this.wraperFactory(c, u);
|
|
1396
1404
|
return i ? await l() : l;
|
|
1397
1405
|
}
|
|
1398
1406
|
wraperFactory(t, n) {
|
|
@@ -1443,7 +1451,7 @@ class AsyncHook extends SyncHook {
|
|
|
1443
1451
|
const o = Array.from(this.listeners);
|
|
1444
1452
|
if (o.length > 0) {
|
|
1445
1453
|
let s = 0;
|
|
1446
|
-
const i = (
|
|
1454
|
+
const i = (a) => a === !1 ? !1 : s < o.length ? Promise.resolve(o[s++].apply(null, t)).then(i) : a;
|
|
1447
1455
|
n = i();
|
|
1448
1456
|
}
|
|
1449
1457
|
return Promise.resolve(n);
|
|
@@ -1489,13 +1497,13 @@ class AsyncWaterfallHook extends SyncHook {
|
|
|
1489
1497
|
const n = Array.from(this.listeners);
|
|
1490
1498
|
if (n.length > 0) {
|
|
1491
1499
|
let o = 0;
|
|
1492
|
-
const s = (
|
|
1493
|
-
if (checkReturnData(t,
|
|
1494
|
-
if (t =
|
|
1500
|
+
const s = (a) => (warn(a), this.onerror(a), t), i = (a) => {
|
|
1501
|
+
if (checkReturnData(t, a)) {
|
|
1502
|
+
if (t = a, o < n.length)
|
|
1495
1503
|
try {
|
|
1496
1504
|
return Promise.resolve(n[o++](t)).then(i, s);
|
|
1497
|
-
} catch (
|
|
1498
|
-
return s(
|
|
1505
|
+
} catch (c) {
|
|
1506
|
+
return s(c);
|
|
1499
1507
|
}
|
|
1500
1508
|
} else
|
|
1501
1509
|
this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
|
|
@@ -1515,8 +1523,8 @@ class PluginSystem {
|
|
|
1515
1523
|
assert(isPlainObject(t), "Plugin configuration is invalid.");
|
|
1516
1524
|
const o = t.name;
|
|
1517
1525
|
assert(o, "A name must be provided by the plugin."), this.registerPlugins[o] || (this.registerPlugins[o] = t, (s = t.apply) == null || s.call(t, n), Object.keys(this.lifecycle).forEach((i) => {
|
|
1518
|
-
const
|
|
1519
|
-
|
|
1526
|
+
const a = t[i];
|
|
1527
|
+
a && this.lifecycle[i].on(a);
|
|
1520
1528
|
}));
|
|
1521
1529
|
}
|
|
1522
1530
|
removePlugin(t) {
|
|
@@ -1537,13 +1545,13 @@ function snapshotPlugin() {
|
|
|
1537
1545
|
return {
|
|
1538
1546
|
name: "snapshot-plugin",
|
|
1539
1547
|
async afterResolve(r) {
|
|
1540
|
-
const { remote: t, pkgNameOrAlias: n, expose: o, origin: s, remoteInfo: i, id:
|
|
1548
|
+
const { remote: t, pkgNameOrAlias: n, expose: o, origin: s, remoteInfo: i, id: a } = r;
|
|
1541
1549
|
if (!isRemoteInfoWithEntry(t) || !isPureRemoteEntry(t)) {
|
|
1542
|
-
const { remoteSnapshot:
|
|
1550
|
+
const { remoteSnapshot: c, globalSnapshot: u } = await s.snapshotHandler.loadRemoteSnapshotInfo({
|
|
1543
1551
|
moduleInfo: t,
|
|
1544
|
-
id:
|
|
1552
|
+
id: a
|
|
1545
1553
|
});
|
|
1546
|
-
assignRemoteInfo(i,
|
|
1554
|
+
assignRemoteInfo(i, c);
|
|
1547
1555
|
const l = {
|
|
1548
1556
|
remote: t,
|
|
1549
1557
|
preloadConfig: {
|
|
@@ -1558,12 +1566,12 @@ function snapshotPlugin() {
|
|
|
1558
1566
|
preloadOptions: l,
|
|
1559
1567
|
remoteInfo: i,
|
|
1560
1568
|
remote: t,
|
|
1561
|
-
remoteSnapshot:
|
|
1569
|
+
remoteSnapshot: c,
|
|
1562
1570
|
globalSnapshot: u
|
|
1563
1571
|
});
|
|
1564
1572
|
return d && preloadAssets(i, s, d, !1), {
|
|
1565
1573
|
...r,
|
|
1566
|
-
remoteSnapshot:
|
|
1574
|
+
remoteSnapshot: c
|
|
1567
1575
|
};
|
|
1568
1576
|
}
|
|
1569
1577
|
return r;
|
|
@@ -1584,7 +1592,7 @@ function splitId(r) {
|
|
|
1584
1592
|
};
|
|
1585
1593
|
}
|
|
1586
1594
|
function traverseModuleInfo(r, t, n, o, s = {}, i) {
|
|
1587
|
-
const
|
|
1595
|
+
const a = getFMId(t), { value: c } = getInfoWithoutType(r, a), u = i || c;
|
|
1588
1596
|
if (u && !isManifestProvider(u) && (n(u, t, o), u.remotesInfo)) {
|
|
1589
1597
|
const l = Object.keys(u.remotesInfo);
|
|
1590
1598
|
for (const d of l) {
|
|
@@ -1601,7 +1609,7 @@ function traverseModuleInfo(r, t, n, o, s = {}, i) {
|
|
|
1601
1609
|
}
|
|
1602
1610
|
const isExisted = (r, t) => document.querySelector(`${r}[${r === "link" ? "href" : "src"}="${t}"]`);
|
|
1603
1611
|
function generatePreloadAssets(r, t, n, o, s) {
|
|
1604
|
-
const i = [],
|
|
1612
|
+
const i = [], a = [], c = [], u = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), { options: d } = r, { preloadConfig: y } = t, { depsRemote: p } = y;
|
|
1605
1613
|
if (traverseModuleInfo(o, n, (E, R, S) => {
|
|
1606
1614
|
var k;
|
|
1607
1615
|
let _;
|
|
@@ -1617,7 +1625,7 @@ function generatePreloadAssets(r, t, n, o, s) {
|
|
|
1617
1625
|
else
|
|
1618
1626
|
return;
|
|
1619
1627
|
const T = getResourceUrl(E, getRemoteEntryInfoFromSnapshot(E).url);
|
|
1620
|
-
T &&
|
|
1628
|
+
T && c.push({
|
|
1621
1629
|
name: R.name,
|
|
1622
1630
|
moduleInfo: {
|
|
1623
1631
|
name: R.name,
|
|
@@ -1630,9 +1638,9 @@ function generatePreloadAssets(r, t, n, o, s) {
|
|
|
1630
1638
|
url: T
|
|
1631
1639
|
});
|
|
1632
1640
|
let I = "modules" in E ? E.modules : [];
|
|
1633
|
-
const
|
|
1634
|
-
|
|
1635
|
-
function
|
|
1641
|
+
const w = normalizePreloadExposes(_.exposes);
|
|
1642
|
+
w.length && "modules" in E && (I = (k = E == null ? void 0 : E.modules) == null ? void 0 : k.reduce((N, $) => ((w == null ? void 0 : w.indexOf($.moduleName)) !== -1 && N.push($), N), []));
|
|
1643
|
+
function A(N) {
|
|
1636
1644
|
const $ = N.map((L) => getResourceUrl(E, L));
|
|
1637
1645
|
return _.filter ? $.filter(_.filter) : $;
|
|
1638
1646
|
}
|
|
@@ -1647,7 +1655,7 @@ function generatePreloadAssets(r, t, n, o, s) {
|
|
|
1647
1655
|
preloadConfig: _,
|
|
1648
1656
|
remote: R,
|
|
1649
1657
|
origin: r
|
|
1650
|
-
}), !getPreloaded(P) && (_.resourceCategory === "all" ? (i.push(...
|
|
1658
|
+
}), !getPreloaded(P) && (_.resourceCategory === "all" ? (i.push(...A(L.assets.css.async)), i.push(...A(L.assets.css.sync)), a.push(...A(L.assets.js.async)), a.push(...A(L.assets.js.sync))) : (_.resourceCategory = "sync") && (i.push(...A(L.assets.css.sync)), a.push(...A(L.assets.js.sync))), setPreloaded(P));
|
|
1651
1659
|
}
|
|
1652
1660
|
}
|
|
1653
1661
|
}, !0, {}, s), s.shared && s.shared.length > 0) {
|
|
@@ -1664,26 +1672,26 @@ function generatePreloadAssets(r, t, n, o, s) {
|
|
|
1664
1672
|
const S = (I = d.shared) == null ? void 0 : I[R.sharedName];
|
|
1665
1673
|
if (!S)
|
|
1666
1674
|
return;
|
|
1667
|
-
const _ = R.version ? S.find((
|
|
1675
|
+
const _ = R.version ? S.find((w) => w.version === R.version) : S;
|
|
1668
1676
|
if (!_)
|
|
1669
1677
|
return;
|
|
1670
|
-
arrayOptions(_).forEach((
|
|
1671
|
-
E(
|
|
1678
|
+
arrayOptions(_).forEach((w) => {
|
|
1679
|
+
E(w, R);
|
|
1672
1680
|
});
|
|
1673
1681
|
});
|
|
1674
1682
|
}
|
|
1675
|
-
const g =
|
|
1683
|
+
const g = a.filter((E) => !u.has(E) && !isExisted("script", E));
|
|
1676
1684
|
return {
|
|
1677
1685
|
cssAssets: i.filter((E) => !l.has(E) && !isExisted("link", E)),
|
|
1678
1686
|
jsAssetsWithoutEntry: g,
|
|
1679
|
-
entryAssets:
|
|
1687
|
+
entryAssets: c.filter((E) => !isExisted("script", E.url))
|
|
1680
1688
|
};
|
|
1681
1689
|
}
|
|
1682
1690
|
const generatePreloadAssetsPlugin = function() {
|
|
1683
1691
|
return {
|
|
1684
1692
|
name: "generate-preload-assets-plugin",
|
|
1685
1693
|
async generatePreloadAssets(r) {
|
|
1686
|
-
const { origin: t, preloadOptions: n, remoteInfo: o, remote: s, globalSnapshot: i, remoteSnapshot:
|
|
1694
|
+
const { origin: t, preloadOptions: n, remoteInfo: o, remote: s, globalSnapshot: i, remoteSnapshot: a } = r;
|
|
1687
1695
|
return isBrowserEnv() ? isRemoteInfoWithEntry(s) && isPureRemoteEntry(s) ? {
|
|
1688
1696
|
cssAssets: [],
|
|
1689
1697
|
jsAssetsWithoutEntry: [],
|
|
@@ -1700,7 +1708,7 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1700
1708
|
}
|
|
1701
1709
|
}
|
|
1702
1710
|
]
|
|
1703
|
-
} : (assignRemoteInfo(o,
|
|
1711
|
+
} : (assignRemoteInfo(o, a), generatePreloadAssets(t, n, o, i, a)) : {
|
|
1704
1712
|
cssAssets: [],
|
|
1705
1713
|
jsAssetsWithoutEntry: [],
|
|
1706
1714
|
entryAssets: []
|
|
@@ -1761,11 +1769,11 @@ class SnapshotHandler {
|
|
|
1761
1769
|
matchedVersion: "version" in t ? t.version : t.entry
|
|
1762
1770
|
}
|
|
1763
1771
|
});
|
|
1764
|
-
const { hostGlobalSnapshot:
|
|
1772
|
+
const { hostGlobalSnapshot: a, remoteSnapshot: c, globalSnapshot: u } = this.getGlobalRemoteInfo(t), { remoteSnapshot: l, globalSnapshot: d } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1765
1773
|
options: s,
|
|
1766
1774
|
moduleInfo: t,
|
|
1767
|
-
hostGlobalSnapshot:
|
|
1768
|
-
remoteSnapshot:
|
|
1775
|
+
hostGlobalSnapshot: a,
|
|
1776
|
+
remoteSnapshot: c,
|
|
1769
1777
|
globalSnapshot: u
|
|
1770
1778
|
});
|
|
1771
1779
|
let y, p;
|
|
@@ -1817,40 +1825,40 @@ class SnapshotHandler {
|
|
|
1817
1825
|
}
|
|
1818
1826
|
async getManifestJson(t, n, o) {
|
|
1819
1827
|
const s = async () => {
|
|
1820
|
-
let
|
|
1821
|
-
if (
|
|
1822
|
-
return
|
|
1828
|
+
let a = this.manifestCache.get(t);
|
|
1829
|
+
if (a)
|
|
1830
|
+
return a;
|
|
1823
1831
|
try {
|
|
1824
|
-
let
|
|
1825
|
-
(!
|
|
1826
|
-
} catch (
|
|
1827
|
-
|
|
1832
|
+
let c = await this.loaderHook.lifecycle.fetch.emit(t, {});
|
|
1833
|
+
(!c || !(c instanceof Response)) && (c = await fetch(t, {})), a = await c.json();
|
|
1834
|
+
} catch (c) {
|
|
1835
|
+
a = await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
1828
1836
|
id: t,
|
|
1829
|
-
error:
|
|
1837
|
+
error: c,
|
|
1830
1838
|
from: "runtime",
|
|
1831
1839
|
lifecycle: "afterResolve",
|
|
1832
1840
|
origin: this.HostInstance
|
|
1833
|
-
}),
|
|
1841
|
+
}), a || (delete this.manifestLoading[t], error(getShortErrorMsg(RUNTIME_003, runtimeDescMap, {
|
|
1834
1842
|
manifestUrl: t,
|
|
1835
1843
|
moduleName: n.name,
|
|
1836
1844
|
hostName: this.HostInstance.options.name
|
|
1837
|
-
}, `${
|
|
1845
|
+
}, `${c}`)));
|
|
1838
1846
|
}
|
|
1839
|
-
return assert(
|
|
1847
|
+
return assert(a.metaData && a.exposes && a.shared, `${t} is not a federation manifest`), this.manifestCache.set(t, a), a;
|
|
1840
1848
|
}, i = async () => {
|
|
1841
|
-
const
|
|
1849
|
+
const a = await s(), c = generateSnapshotFromManifest(a, {
|
|
1842
1850
|
version: t
|
|
1843
1851
|
}), { remoteSnapshot: u } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1844
1852
|
options: this.HostInstance.options,
|
|
1845
1853
|
moduleInfo: n,
|
|
1846
|
-
manifestJson:
|
|
1847
|
-
remoteSnapshot:
|
|
1854
|
+
manifestJson: a,
|
|
1855
|
+
remoteSnapshot: c,
|
|
1848
1856
|
manifestUrl: t,
|
|
1849
1857
|
from: "manifest"
|
|
1850
1858
|
});
|
|
1851
1859
|
return u;
|
|
1852
1860
|
};
|
|
1853
|
-
return this.manifestLoading[t] || (this.manifestLoading[t] = i().then((
|
|
1861
|
+
return this.manifestLoading[t] || (this.manifestLoading[t] = i().then((a) => a)), this.manifestLoading[t];
|
|
1854
1862
|
}
|
|
1855
1863
|
}
|
|
1856
1864
|
class SharedHandler {
|
|
@@ -1869,16 +1877,16 @@ class SharedHandler {
|
|
|
1869
1877
|
// register shared in shareScopeMap
|
|
1870
1878
|
registerShared(t, n) {
|
|
1871
1879
|
const { newShareInfos: o, allShareInfos: s } = formatShareConfigs(t, n);
|
|
1872
|
-
return Object.keys(o).forEach((
|
|
1873
|
-
o[
|
|
1880
|
+
return Object.keys(o).forEach((a) => {
|
|
1881
|
+
o[a].forEach((u) => {
|
|
1874
1882
|
u.scope.forEach((l) => {
|
|
1875
1883
|
var y;
|
|
1876
1884
|
this.hooks.lifecycle.beforeRegisterShare.emit({
|
|
1877
1885
|
origin: this.host,
|
|
1878
|
-
pkgName:
|
|
1886
|
+
pkgName: a,
|
|
1879
1887
|
shared: u
|
|
1880
|
-
}), ((y = this.shareScopeMap[l]) == null ? void 0 : y[
|
|
1881
|
-
pkgName:
|
|
1888
|
+
}), ((y = this.shareScopeMap[l]) == null ? void 0 : y[a]) || this.setShared({
|
|
1889
|
+
pkgName: a,
|
|
1882
1890
|
lib: u.lib,
|
|
1883
1891
|
get: u.get,
|
|
1884
1892
|
loaded: u.loaded || !!u.lib,
|
|
@@ -1908,11 +1916,11 @@ class SharedHandler {
|
|
|
1908
1916
|
shareInfo: s,
|
|
1909
1917
|
shared: o.options.shared,
|
|
1910
1918
|
origin: o
|
|
1911
|
-
}), { shareInfo:
|
|
1912
|
-
assert(
|
|
1913
|
-
const { shared:
|
|
1914
|
-
if (
|
|
1915
|
-
const l = directShare(
|
|
1919
|
+
}), { shareInfo: a } = i;
|
|
1920
|
+
assert(a, `Cannot find ${t} Share in the ${o.options.name}. Please ensure that the ${t} Share parameters have been injected`);
|
|
1921
|
+
const { shared: c, useTreesShaking: u } = getRegisteredShare(this.shareScopeMap, t, a, this.hooks.lifecycle.resolveShare) || {};
|
|
1922
|
+
if (c) {
|
|
1923
|
+
const l = directShare(c, u);
|
|
1916
1924
|
if (l.lib)
|
|
1917
1925
|
return addUseIn(l, o.options.name), l.lib;
|
|
1918
1926
|
if (l.loading && !l.loaded) {
|
|
@@ -1926,7 +1934,7 @@ class SharedHandler {
|
|
|
1926
1934
|
return this.setShared({
|
|
1927
1935
|
pkgName: t,
|
|
1928
1936
|
loaded: !1,
|
|
1929
|
-
shared:
|
|
1937
|
+
shared: c,
|
|
1930
1938
|
from: o.options.name,
|
|
1931
1939
|
lib: null,
|
|
1932
1940
|
loading: y,
|
|
@@ -1936,20 +1944,20 @@ class SharedHandler {
|
|
|
1936
1944
|
} else {
|
|
1937
1945
|
if (n != null && n.customShareInfo)
|
|
1938
1946
|
return !1;
|
|
1939
|
-
const l = shouldUseTreeShaking(
|
|
1947
|
+
const l = shouldUseTreeShaking(a.treeShaking), d = directShare(a, l), p = (async () => {
|
|
1940
1948
|
const m = await d.get();
|
|
1941
1949
|
d.lib = m, d.loaded = !0, addUseIn(d, o.options.name);
|
|
1942
|
-
const { shared: g, useTreesShaking: b } = getRegisteredShare(this.shareScopeMap, t,
|
|
1950
|
+
const { shared: g, useTreesShaking: b } = getRegisteredShare(this.shareScopeMap, t, a, this.hooks.lifecycle.resolveShare) || {};
|
|
1943
1951
|
if (g) {
|
|
1944
1952
|
const E = directShare(g, b);
|
|
1945
|
-
E.lib = m, E.loaded = !0, g.from =
|
|
1953
|
+
E.lib = m, E.loaded = !0, g.from = a.from;
|
|
1946
1954
|
}
|
|
1947
1955
|
return m;
|
|
1948
1956
|
})();
|
|
1949
1957
|
return this.setShared({
|
|
1950
1958
|
pkgName: t,
|
|
1951
1959
|
loaded: !1,
|
|
1952
|
-
shared:
|
|
1960
|
+
shared: a,
|
|
1953
1961
|
from: o.options.name,
|
|
1954
1962
|
lib: null,
|
|
1955
1963
|
loading: p,
|
|
@@ -1965,15 +1973,15 @@ class SharedHandler {
|
|
|
1965
1973
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
1966
1974
|
initializeSharing(t = DEFAULT_SCOPE, n) {
|
|
1967
1975
|
const { host: o } = this, s = n == null ? void 0 : n.from, i = n == null ? void 0 : n.strategy;
|
|
1968
|
-
let
|
|
1969
|
-
const
|
|
1976
|
+
let a = n == null ? void 0 : n.initScope;
|
|
1977
|
+
const c = [];
|
|
1970
1978
|
if (s !== "build") {
|
|
1971
1979
|
const { initTokens: m } = this;
|
|
1972
|
-
|
|
1980
|
+
a || (a = []);
|
|
1973
1981
|
let g = m[t];
|
|
1974
|
-
if (g || (g = m[t] = { from: this.host.name }),
|
|
1975
|
-
return
|
|
1976
|
-
|
|
1982
|
+
if (g || (g = m[t] = { from: this.host.name }), a.indexOf(g) >= 0)
|
|
1983
|
+
return c;
|
|
1984
|
+
a.push(g);
|
|
1977
1985
|
}
|
|
1978
1986
|
const u = this.shareScopeMap, l = o.options.name;
|
|
1979
1987
|
u[t] || (u[t] = {});
|
|
@@ -2007,8 +2015,8 @@ class SharedHandler {
|
|
|
2007
2015
|
b.scope.includes(t) && y(m, b);
|
|
2008
2016
|
});
|
|
2009
2017
|
}), (o.options.shareStrategy === "version-first" || i === "version-first") && o.options.remotes.forEach((m) => {
|
|
2010
|
-
m.shareScope === t &&
|
|
2011
|
-
}),
|
|
2018
|
+
m.shareScope === t && c.push(p(m.name));
|
|
2019
|
+
}), c;
|
|
2012
2020
|
}
|
|
2013
2021
|
// The lib function will only be available if the shared set by eager or runtime init is set or the shared is successfully loaded.
|
|
2014
2022
|
// 1. If the loaded shared already exists globally, then it will be reused
|
|
@@ -2020,37 +2028,37 @@ class SharedHandler {
|
|
|
2020
2028
|
extraOptions: n,
|
|
2021
2029
|
shareInfos: o.options.shared
|
|
2022
2030
|
});
|
|
2023
|
-
s != null && s.scope && s.scope.forEach((
|
|
2024
|
-
this.initializeSharing(
|
|
2031
|
+
s != null && s.scope && s.scope.forEach((c) => {
|
|
2032
|
+
this.initializeSharing(c, { strategy: s.strategy });
|
|
2025
2033
|
});
|
|
2026
|
-
const { shared: i, useTreesShaking:
|
|
2034
|
+
const { shared: i, useTreesShaking: a } = getRegisteredShare(this.shareScopeMap, t, s, this.hooks.lifecycle.resolveShare) || {};
|
|
2027
2035
|
if (i) {
|
|
2028
2036
|
if (typeof i.lib == "function")
|
|
2029
2037
|
return addUseIn(i, o.options.name), i.loaded || (i.loaded = !0, i.from === o.options.name && (s.loaded = !0)), i.lib;
|
|
2030
2038
|
if (typeof i.get == "function") {
|
|
2031
|
-
const
|
|
2032
|
-
if (!(
|
|
2039
|
+
const c = i.get();
|
|
2040
|
+
if (!(c instanceof Promise))
|
|
2033
2041
|
return addUseIn(i, o.options.name), this.setShared({
|
|
2034
2042
|
pkgName: t,
|
|
2035
2043
|
loaded: !0,
|
|
2036
2044
|
from: o.options.name,
|
|
2037
|
-
lib:
|
|
2045
|
+
lib: c,
|
|
2038
2046
|
shared: i
|
|
2039
|
-
}),
|
|
2047
|
+
}), c;
|
|
2040
2048
|
}
|
|
2041
2049
|
}
|
|
2042
2050
|
if (s.lib)
|
|
2043
2051
|
return s.loaded || (s.loaded = !0), s.lib;
|
|
2044
2052
|
if (s.get) {
|
|
2045
|
-
const
|
|
2046
|
-
if (
|
|
2053
|
+
const c = s.get();
|
|
2054
|
+
if (c instanceof Promise) {
|
|
2047
2055
|
const u = (n == null ? void 0 : n.from) === "build" ? RUNTIME_005 : RUNTIME_006;
|
|
2048
2056
|
throw new Error(getShortErrorMsg(u, runtimeDescMap, {
|
|
2049
2057
|
hostName: o.options.name,
|
|
2050
2058
|
sharedPkgName: t
|
|
2051
2059
|
}));
|
|
2052
2060
|
}
|
|
2053
|
-
return s.lib =
|
|
2061
|
+
return s.lib = c, this.setShared({
|
|
2054
2062
|
pkgName: t,
|
|
2055
2063
|
loaded: !0,
|
|
2056
2064
|
from: o.options.name,
|
|
@@ -2073,12 +2081,12 @@ class SharedHandler {
|
|
|
2073
2081
|
hostShareScopeMap: o.hostShareScopeMap
|
|
2074
2082
|
});
|
|
2075
2083
|
}
|
|
2076
|
-
setShared({ pkgName: t, shared: n, from: o, lib: s, loading: i, loaded:
|
|
2084
|
+
setShared({ pkgName: t, shared: n, from: o, lib: s, loading: i, loaded: a, get: c, treeShaking: u }) {
|
|
2077
2085
|
const { version: l, scope: d = "default", ...y } = n, p = Array.isArray(d) ? d : [d], m = (g) => {
|
|
2078
2086
|
const b = (R, S, _) => {
|
|
2079
2087
|
_ && !R[S] && (R[S] = _);
|
|
2080
2088
|
}, E = u ? g.treeShaking : g;
|
|
2081
|
-
b(E, "loaded",
|
|
2089
|
+
b(E, "loaded", a), b(E, "loading", i), b(E, "get", c);
|
|
2082
2090
|
};
|
|
2083
2091
|
p.forEach((g) => {
|
|
2084
2092
|
this.shareScopeMap[g] || (this.shareScopeMap[g] = {}), this.shareScopeMap[g][t] || (this.shareScopeMap[g][t] = {}), this.shareScopeMap[g][t][l] || (this.shareScopeMap[g][t][l] = {
|
|
@@ -2117,15 +2125,15 @@ class RemoteHandler {
|
|
|
2117
2125
|
return (n.remotes || []).reduce((s, i) => (this.registerRemote(i, s, { force: !1 }), s), t.remotes);
|
|
2118
2126
|
}
|
|
2119
2127
|
setIdToRemoteMap(t, n) {
|
|
2120
|
-
const { remote: o, expose: s } = n, { name: i, alias:
|
|
2121
|
-
if (this.idToRemoteMap[t] = { name: o.name, expose: s },
|
|
2122
|
-
const
|
|
2123
|
-
this.idToRemoteMap[
|
|
2128
|
+
const { remote: o, expose: s } = n, { name: i, alias: a } = o;
|
|
2129
|
+
if (this.idToRemoteMap[t] = { name: o.name, expose: s }, a && t.startsWith(i)) {
|
|
2130
|
+
const c = t.replace(i, a);
|
|
2131
|
+
this.idToRemoteMap[c] = { name: o.name, expose: s };
|
|
2124
2132
|
return;
|
|
2125
2133
|
}
|
|
2126
|
-
if (
|
|
2127
|
-
const
|
|
2128
|
-
this.idToRemoteMap[
|
|
2134
|
+
if (a && t.startsWith(a)) {
|
|
2135
|
+
const c = t.replace(a, i);
|
|
2136
|
+
this.idToRemoteMap[c] = { name: o.name, expose: s };
|
|
2129
2137
|
}
|
|
2130
2138
|
}
|
|
2131
2139
|
// eslint-disable-next-line max-lines-per-function
|
|
@@ -2135,31 +2143,31 @@ class RemoteHandler {
|
|
|
2135
2143
|
try {
|
|
2136
2144
|
const { loadFactory: s = !0 } = n || {
|
|
2137
2145
|
loadFactory: !0
|
|
2138
|
-
}, { module: i, moduleOptions:
|
|
2146
|
+
}, { module: i, moduleOptions: a, remoteMatchInfo: c } = await this.getRemoteModuleAndOptions({
|
|
2139
2147
|
id: t
|
|
2140
|
-
}), { pkgNameOrAlias: u, remote: l, expose: d, id: y, remoteSnapshot: p } =
|
|
2148
|
+
}), { pkgNameOrAlias: u, remote: l, expose: d, id: y, remoteSnapshot: p } = c, m = await i.get(y, d, n, p), g = await this.hooks.lifecycle.onLoad.emit({
|
|
2141
2149
|
id: y,
|
|
2142
2150
|
pkgNameOrAlias: u,
|
|
2143
2151
|
expose: d,
|
|
2144
2152
|
exposeModule: s ? m : void 0,
|
|
2145
2153
|
exposeModuleFactory: s ? void 0 : m,
|
|
2146
2154
|
remote: l,
|
|
2147
|
-
options:
|
|
2155
|
+
options: a,
|
|
2148
2156
|
moduleInstance: i,
|
|
2149
2157
|
origin: o
|
|
2150
2158
|
});
|
|
2151
|
-
return this.setIdToRemoteMap(t,
|
|
2159
|
+
return this.setIdToRemoteMap(t, c), typeof g == "function" ? g : m;
|
|
2152
2160
|
} catch (s) {
|
|
2153
|
-
const { from: i = "runtime" } = n || { from: "runtime" },
|
|
2161
|
+
const { from: i = "runtime" } = n || { from: "runtime" }, a = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2154
2162
|
id: t,
|
|
2155
2163
|
error: s,
|
|
2156
2164
|
from: i,
|
|
2157
2165
|
lifecycle: "onLoad",
|
|
2158
2166
|
origin: o
|
|
2159
2167
|
});
|
|
2160
|
-
if (!
|
|
2168
|
+
if (!a)
|
|
2161
2169
|
throw s;
|
|
2162
|
-
return
|
|
2170
|
+
return a;
|
|
2163
2171
|
}
|
|
2164
2172
|
}
|
|
2165
2173
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
@@ -2172,17 +2180,17 @@ class RemoteHandler {
|
|
|
2172
2180
|
});
|
|
2173
2181
|
const o = formatPreloadArgs(n.options.remotes, t);
|
|
2174
2182
|
await Promise.all(o.map(async (s) => {
|
|
2175
|
-
const { remote: i } = s,
|
|
2183
|
+
const { remote: i } = s, a = getRemoteInfo(i), { globalSnapshot: c, remoteSnapshot: u } = await n.snapshotHandler.loadRemoteSnapshotInfo({
|
|
2176
2184
|
moduleInfo: i
|
|
2177
2185
|
}), l = await this.hooks.lifecycle.generatePreloadAssets.emit({
|
|
2178
2186
|
origin: n,
|
|
2179
2187
|
preloadOptions: s,
|
|
2180
2188
|
remote: i,
|
|
2181
|
-
remoteInfo:
|
|
2182
|
-
globalSnapshot:
|
|
2189
|
+
remoteInfo: a,
|
|
2190
|
+
globalSnapshot: c,
|
|
2183
2191
|
remoteSnapshot: u
|
|
2184
2192
|
});
|
|
2185
|
-
l && preloadAssets(
|
|
2193
|
+
l && preloadAssets(a, n, l);
|
|
2186
2194
|
}));
|
|
2187
2195
|
}
|
|
2188
2196
|
registerRemotes(t, n) {
|
|
@@ -2213,14 +2221,14 @@ class RemoteHandler {
|
|
|
2213
2221
|
}), !s)
|
|
2214
2222
|
throw g;
|
|
2215
2223
|
}
|
|
2216
|
-
const { id: i } = s,
|
|
2217
|
-
assert(
|
|
2224
|
+
const { id: i } = s, a = matchRemoteWithNameAndExpose(n.options.remotes, i);
|
|
2225
|
+
assert(a, getShortErrorMsg(RUNTIME_004, runtimeDescMap, {
|
|
2218
2226
|
hostName: n.options.name,
|
|
2219
2227
|
requestId: i
|
|
2220
2228
|
}));
|
|
2221
|
-
const { remote:
|
|
2229
|
+
const { remote: c } = a, u = getRemoteInfo(c), l = await n.sharedHandler.hooks.lifecycle.afterResolve.emit({
|
|
2222
2230
|
id: i,
|
|
2223
|
-
...
|
|
2231
|
+
...a,
|
|
2224
2232
|
options: n.options,
|
|
2225
2233
|
origin: n,
|
|
2226
2234
|
remoteInfo: u
|
|
@@ -2240,39 +2248,39 @@ class RemoteHandler {
|
|
|
2240
2248
|
registerRemote(t, n, o) {
|
|
2241
2249
|
const { host: s } = this, i = () => {
|
|
2242
2250
|
if (t.alias) {
|
|
2243
|
-
const
|
|
2251
|
+
const c = n.find((u) => {
|
|
2244
2252
|
var l;
|
|
2245
2253
|
return t.alias && (u.name.startsWith(t.alias) || ((l = u.alias) == null ? void 0 : l.startsWith(t.alias)));
|
|
2246
2254
|
});
|
|
2247
|
-
assert(!
|
|
2255
|
+
assert(!c, `The alias ${t.alias} of remote ${t.name} is not allowed to be the prefix of ${c && c.name} name or alias`);
|
|
2248
2256
|
}
|
|
2249
2257
|
"entry" in t && isBrowserEnv() && !t.entry.startsWith("http") && (t.entry = new URL(t.entry, window.location.origin).href), t.shareScope || (t.shareScope = DEFAULT_SCOPE), t.type || (t.type = DEFAULT_REMOTE_TYPE);
|
|
2250
2258
|
};
|
|
2251
2259
|
this.hooks.lifecycle.beforeRegisterRemote.emit({ remote: t, origin: s });
|
|
2252
|
-
const
|
|
2253
|
-
if (!
|
|
2260
|
+
const a = n.find((c) => c.name === t.name);
|
|
2261
|
+
if (!a)
|
|
2254
2262
|
i(), n.push(t), this.hooks.lifecycle.registerRemote.emit({ remote: t, origin: s });
|
|
2255
2263
|
else {
|
|
2256
|
-
const
|
|
2264
|
+
const c = [
|
|
2257
2265
|
`The remote "${t.name}" is already registered.`,
|
|
2258
2266
|
"Please note that overriding it may cause unexpected errors."
|
|
2259
2267
|
];
|
|
2260
|
-
o != null && o.force && (this.removeRemote(
|
|
2268
|
+
o != null && o.force && (this.removeRemote(a), i(), n.push(t), this.hooks.lifecycle.registerRemote.emit({ remote: t, origin: s }), warn$1(c.join(" ")));
|
|
2261
2269
|
}
|
|
2262
2270
|
}
|
|
2263
2271
|
removeRemote(t) {
|
|
2264
2272
|
var n;
|
|
2265
2273
|
try {
|
|
2266
|
-
const { host: o } = this, { name: s } = t, i = o.options.remotes.findIndex((
|
|
2274
|
+
const { host: o } = this, { name: s } = t, i = o.options.remotes.findIndex((c) => c.name === s);
|
|
2267
2275
|
i !== -1 && o.options.remotes.splice(i, 1);
|
|
2268
|
-
const
|
|
2269
|
-
if (
|
|
2270
|
-
const
|
|
2276
|
+
const a = o.moduleCache.get(t.name);
|
|
2277
|
+
if (a) {
|
|
2278
|
+
const c = a.remoteInfo, u = c.entryGlobalName;
|
|
2271
2279
|
CurrentGlobal[u] && ((n = Object.getOwnPropertyDescriptor(CurrentGlobal, u)) != null && n.configurable ? delete CurrentGlobal[u] : CurrentGlobal[u] = void 0);
|
|
2272
|
-
const l = getRemoteEntryUniqueKey(
|
|
2273
|
-
globalLoading[l] && delete globalLoading[l], o.snapshotHandler.manifestCache.delete(
|
|
2274
|
-
let d =
|
|
2275
|
-
const y = CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex((m) =>
|
|
2280
|
+
const l = getRemoteEntryUniqueKey(a.remoteInfo);
|
|
2281
|
+
globalLoading[l] && delete globalLoading[l], o.snapshotHandler.manifestCache.delete(c.entry);
|
|
2282
|
+
let d = c.buildVersion ? composeKeyWithSeparator(c.name, c.buildVersion) : c.name;
|
|
2283
|
+
const y = CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex((m) => c.buildVersion ? m.options.id === d : m.name === d);
|
|
2276
2284
|
if (y !== -1) {
|
|
2277
2285
|
const m = CurrentGlobal.__FEDERATION__.__INSTANCES__[y];
|
|
2278
2286
|
d = m.options.id || d;
|
|
@@ -2284,26 +2292,26 @@ class RemoteHandler {
|
|
|
2284
2292
|
S && Object.keys(S).forEach((_) => {
|
|
2285
2293
|
const T = S[_];
|
|
2286
2294
|
T && Object.keys(T).forEach((I) => {
|
|
2287
|
-
const
|
|
2288
|
-
|
|
2289
|
-
const k = A
|
|
2290
|
-
k && typeof k == "object" && k.from ===
|
|
2295
|
+
const w = T[I];
|
|
2296
|
+
w && Object.keys(w).forEach((A) => {
|
|
2297
|
+
const k = w[A];
|
|
2298
|
+
k && typeof k == "object" && k.from === c.name && (k.loaded || k.loading ? (k.useIn = k.useIn.filter((N) => N !== c.name), k.useIn.length ? b = !1 : E.push([
|
|
2291
2299
|
R,
|
|
2292
2300
|
_,
|
|
2293
2301
|
I,
|
|
2294
|
-
|
|
2302
|
+
A
|
|
2295
2303
|
])) : E.push([
|
|
2296
2304
|
R,
|
|
2297
2305
|
_,
|
|
2298
2306
|
I,
|
|
2299
|
-
|
|
2307
|
+
A
|
|
2300
2308
|
]));
|
|
2301
2309
|
});
|
|
2302
2310
|
});
|
|
2303
2311
|
});
|
|
2304
2312
|
}), b && (m.shareScopeMap = {}, delete g[d]), E.forEach(([R, S, _, T]) => {
|
|
2305
|
-
var I,
|
|
2306
|
-
(
|
|
2313
|
+
var I, w, A;
|
|
2314
|
+
(A = (w = (I = g[R]) == null ? void 0 : I[S]) == null ? void 0 : w[_]) == null || delete A[T];
|
|
2307
2315
|
}), CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(y, 1);
|
|
2308
2316
|
}
|
|
2309
2317
|
const { hostGlobalSnapshot: p } = getGlobalRemoteInfo(t, o);
|
|
@@ -2328,7 +2336,7 @@ class ModuleFederation {
|
|
|
2328
2336
|
beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
|
|
2329
2337
|
// maybe will change, temporarily for internal use only
|
|
2330
2338
|
initContainer: new AsyncWaterfallHook("initContainer")
|
|
2331
|
-
}), this.version = "0.
|
|
2339
|
+
}), this.version = "2.0.1", this.moduleCache = /* @__PURE__ */ new Map(), this.loaderHook = new PluginSystem({
|
|
2332
2340
|
// FIXME: may not be suitable , not open to the public yet
|
|
2333
2341
|
getModuleInfo: new SyncHook(),
|
|
2334
2342
|
createScript: new SyncHook(),
|
|
@@ -2395,7 +2403,7 @@ class ModuleFederation {
|
|
|
2395
2403
|
userOptions: n,
|
|
2396
2404
|
options: t,
|
|
2397
2405
|
shareInfo: o
|
|
2398
|
-
}),
|
|
2406
|
+
}), a = this.remoteHandler.formatAndRegisterRemote(i, s), { allShareInfos: c } = this.sharedHandler.registerShared(i, s), u = [...i.plugins];
|
|
2399
2407
|
s.plugins && s.plugins.forEach((d) => {
|
|
2400
2408
|
u.includes(d) || u.push(d);
|
|
2401
2409
|
});
|
|
@@ -2403,8 +2411,8 @@ class ModuleFederation {
|
|
|
2403
2411
|
...t,
|
|
2404
2412
|
...n,
|
|
2405
2413
|
plugins: u,
|
|
2406
|
-
remotes:
|
|
2407
|
-
shared:
|
|
2414
|
+
remotes: a,
|
|
2415
|
+
shared: c
|
|
2408
2416
|
};
|
|
2409
2417
|
return this.hooks.lifecycle.init.emit({
|
|
2410
2418
|
origin: this,
|
|
@@ -2445,31 +2453,31 @@ function addBasenameToNestedRoutes(r, t) {
|
|
|
2445
2453
|
function processRoutes(r) {
|
|
2446
2454
|
const { router: t, basename: n, memoryRoute: o, hashRoute: s } = r, i = t.getRoutes().sort(
|
|
2447
2455
|
(p, m) => p.path.split("/").filter((g) => g).length - m.path.split("/").filter((g) => g).length
|
|
2448
|
-
),
|
|
2456
|
+
), a = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set();
|
|
2449
2457
|
i.forEach((p) => {
|
|
2450
|
-
|
|
2458
|
+
a.set(p.path, p);
|
|
2451
2459
|
});
|
|
2452
2460
|
const u = (p, m) => `${p}/${m}`.replace(/\/+/g, "/").replace(/\/$/, "") || "/", l = (p, m = "") => {
|
|
2453
2461
|
if (!p.children || p.children.length === 0)
|
|
2454
2462
|
return p;
|
|
2455
2463
|
for (let g = 0; g < p.children.length; g++) {
|
|
2456
|
-
const b = p.children[g], E = u(m, b.path), R =
|
|
2457
|
-
if (R && !
|
|
2464
|
+
const b = p.children[g], E = u(m, b.path), R = a.get(E);
|
|
2465
|
+
if (R && !c.has(R)) {
|
|
2458
2466
|
const S = {
|
|
2459
2467
|
...R,
|
|
2460
2468
|
path: b.path
|
|
2461
2469
|
// Keep the original relative path from static route
|
|
2462
2470
|
};
|
|
2463
|
-
p.children[g] = S,
|
|
2471
|
+
p.children[g] = S, c.add(R), l(S, E);
|
|
2464
2472
|
}
|
|
2465
2473
|
}
|
|
2466
2474
|
return p;
|
|
2467
2475
|
};
|
|
2468
2476
|
let d = [];
|
|
2469
2477
|
for (const p of i)
|
|
2470
|
-
if (!
|
|
2478
|
+
if (!c.has(p)) {
|
|
2471
2479
|
const m = l(p, p.path);
|
|
2472
|
-
|
|
2480
|
+
c.add(p), d.push(m);
|
|
2473
2481
|
}
|
|
2474
2482
|
let y;
|
|
2475
2483
|
return o ? y = VueRouter.createMemoryHistory(n) : s ? (y = VueRouter.createWebHashHistory(), n && (d = addBasenameToNestedRoutes(d, n))) : y = VueRouter.createWebHistory(n), {
|
|
@@ -2480,23 +2488,23 @@ function processRoutes(r) {
|
|
|
2480
2488
|
function createBridgeComponent(r) {
|
|
2481
2489
|
const t = /* @__PURE__ */ new Map(), n = getInstance();
|
|
2482
2490
|
return () => ({
|
|
2483
|
-
__APP_VERSION__: "0.
|
|
2491
|
+
__APP_VERSION__: "2.0.1",
|
|
2484
2492
|
async render(o) {
|
|
2485
2493
|
var g, b, E;
|
|
2486
2494
|
LoggerInstance.debug("createBridgeComponent render Info", o);
|
|
2487
2495
|
const {
|
|
2488
2496
|
moduleName: s,
|
|
2489
2497
|
dom: i,
|
|
2490
|
-
basename:
|
|
2491
|
-
memoryRoute:
|
|
2498
|
+
basename: a,
|
|
2499
|
+
memoryRoute: c,
|
|
2492
2500
|
hashRoute: u,
|
|
2493
2501
|
...l
|
|
2494
2502
|
} = o, d = Vue.createApp(r.rootComponent, l);
|
|
2495
2503
|
t.set(i, d);
|
|
2496
2504
|
const y = await ((E = (b = (g = n == null ? void 0 : n.bridgeHook) == null ? void 0 : g.lifecycle) == null ? void 0 : b.beforeBridgeRender) == null ? void 0 : E.emit(o)), p = y && typeof y == "object" && (y != null && y.extraProps) ? y == null ? void 0 : y.extraProps : {}, m = r.appOptions({
|
|
2497
2505
|
app: d,
|
|
2498
|
-
basename:
|
|
2499
|
-
memoryRoute:
|
|
2506
|
+
basename: a,
|
|
2507
|
+
memoryRoute: c,
|
|
2500
2508
|
hashRoute: u,
|
|
2501
2509
|
...l,
|
|
2502
2510
|
...p
|
|
@@ -2515,7 +2523,7 @@ function createBridgeComponent(r) {
|
|
|
2515
2523
|
LoggerInstance.debug("createBridgeComponent render router info>>>", {
|
|
2516
2524
|
moduleName: s,
|
|
2517
2525
|
router: _
|
|
2518
|
-
}),
|
|
2526
|
+
}), c && await _.push(c.entryPath), d.use(_);
|
|
2519
2527
|
}
|
|
2520
2528
|
d.mount(i);
|
|
2521
2529
|
},
|
|
@@ -2542,12 +2550,12 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2542
2550
|
},
|
|
2543
2551
|
inheritAttrs: !1,
|
|
2544
2552
|
setup(r) {
|
|
2545
|
-
const t = ref(null), n = ref(null), o = ref(""), s = useRoute(), i = getInstance(),
|
|
2553
|
+
const t = ref(null), n = ref(null), o = ref(""), s = useRoute(), i = getInstance(), a = useAttrs(), c = async () => {
|
|
2546
2554
|
var p, m, g, b;
|
|
2547
2555
|
const l = (p = r.providerInfo) == null ? void 0 : p.call(r);
|
|
2548
2556
|
n.value = l;
|
|
2549
2557
|
let d = {
|
|
2550
|
-
...
|
|
2558
|
+
...a,
|
|
2551
2559
|
moduleName: r.moduleName,
|
|
2552
2560
|
dom: t.value,
|
|
2553
2561
|
basename: r.basename,
|
|
@@ -2561,13 +2569,13 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2561
2569
|
...y.extraProps
|
|
2562
2570
|
}, l.render(d);
|
|
2563
2571
|
}, u = watch(() => s == null ? void 0 : s.path, (l) => {
|
|
2564
|
-
l !== s.path &&
|
|
2572
|
+
l !== s.path && c(), o.value !== "" && o.value !== l && (LoggerInstance.debug("createRemoteAppComponent dispatchPopstateEnv >>>", {
|
|
2565
2573
|
...r,
|
|
2566
2574
|
pathname: s.path
|
|
2567
2575
|
}), e()), o.value = l;
|
|
2568
2576
|
});
|
|
2569
2577
|
return onMounted(() => {
|
|
2570
|
-
|
|
2578
|
+
c();
|
|
2571
2579
|
}), onBeforeUnmount(() => {
|
|
2572
2580
|
var l;
|
|
2573
2581
|
LoggerInstance.debug("createRemoteAppComponent LazyComponent destroy >>>", {
|
|
@@ -2582,7 +2590,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2582
2590
|
});
|
|
2583
2591
|
function createRemoteAppComponent(r) {
|
|
2584
2592
|
return defineAsyncComponent({
|
|
2585
|
-
__APP_VERSION__: "0.
|
|
2593
|
+
__APP_VERSION__: "2.0.1",
|
|
2586
2594
|
...r.asyncComponentOptions,
|
|
2587
2595
|
//@ts-ignore
|
|
2588
2596
|
loader: async () => {
|
|
@@ -2599,16 +2607,16 @@ function createRemoteAppComponent(r) {
|
|
|
2599
2607
|
info: r
|
|
2600
2608
|
}
|
|
2601
2609
|
);
|
|
2602
|
-
const i = await r.loader(),
|
|
2610
|
+
const i = await r.loader(), a = i && i[Symbol.for("mf_module_id")], c = i[s];
|
|
2603
2611
|
if (LoggerInstance.debug(
|
|
2604
2612
|
"createRemoteAppComponent LazyComponent loadRemote info >>>",
|
|
2605
|
-
{ moduleName:
|
|
2606
|
-
), s in i && typeof
|
|
2613
|
+
{ moduleName: a, module: i, exportName: s, basename: n, route: t }
|
|
2614
|
+
), s in i && typeof c == "function")
|
|
2607
2615
|
return {
|
|
2608
2616
|
render() {
|
|
2609
2617
|
return h(RemoteApp, {
|
|
2610
|
-
moduleName:
|
|
2611
|
-
providerInfo:
|
|
2618
|
+
moduleName: a,
|
|
2619
|
+
providerInfo: c,
|
|
2612
2620
|
basename: n,
|
|
2613
2621
|
rootAttrs: r.rootAttrs
|
|
2614
2622
|
});
|