@module-federation/bridge-vue3 0.18.3 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/index.cjs +4 -4
- package/dist/index.js +375 -370
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -57,8 +57,8 @@ const simpleJoinRemoteEntry = (o, 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
|
})(o);
|
|
@@ -69,34 +69,34 @@ function inferAutoPublicPath(o) {
|
|
|
69
69
|
}
|
|
70
70
|
function generateSnapshotFromManifest(o, t = {}) {
|
|
71
71
|
var n, r;
|
|
72
|
-
const { remotes: s = {}, overrides:
|
|
73
|
-
let
|
|
74
|
-
const c = () => "publicPath" in o.metaData ? o.metaData.publicPath === "auto" && l ? inferAutoPublicPath(l) : o.metaData.publicPath : o.metaData.getPublicPath, u = Object.keys(
|
|
72
|
+
const { remotes: s = {}, overrides: a = {}, version: l } = t;
|
|
73
|
+
let i;
|
|
74
|
+
const c = () => "publicPath" in o.metaData ? o.metaData.publicPath === "auto" && l ? inferAutoPublicPath(l) : o.metaData.publicPath : o.metaData.getPublicPath, u = Object.keys(a);
|
|
75
75
|
let p = {};
|
|
76
76
|
if (!Object.keys(s).length) {
|
|
77
77
|
var d;
|
|
78
78
|
p = ((d = o.remotes) == null ? void 0 : d.reduce((R, A) => {
|
|
79
79
|
let T;
|
|
80
80
|
const $ = A.federationContainerName;
|
|
81
|
-
return u.includes($) ? T =
|
|
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) => p[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 } = o.metaData, { exposes: I } = o;
|
|
91
91
|
let S = {
|
|
92
92
|
version: l || "",
|
|
93
93
|
buildVersion: _,
|
|
94
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: p,
|
|
101
101
|
shared: o == null ? void 0 : o.shared.map((R) => ({
|
|
102
102
|
assets: R.assets,
|
|
@@ -122,16 +122,16 @@ function generateSnapshotFromManifest(o, t = {}) {
|
|
|
122
122
|
prefetchEntryType: T
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
|
-
if ("publicPath" in o.metaData ?
|
|
125
|
+
if ("publicPath" in o.metaData ? i = _extends$2({}, S, {
|
|
126
126
|
publicPath: c(),
|
|
127
127
|
ssrPublicPath: o.metaData.ssrPublicPath
|
|
128
|
-
}) :
|
|
128
|
+
}) : i = _extends$2({}, S, {
|
|
129
129
|
getPublicPath: c()
|
|
130
130
|
}), v) {
|
|
131
131
|
const R = simpleJoinRemoteEntry(v.path, v.name);
|
|
132
|
-
|
|
132
|
+
i.ssrRemoteEntry = R, i.ssrRemoteEntryType = v.type || "commonjs-module";
|
|
133
133
|
}
|
|
134
|
-
return
|
|
134
|
+
return i;
|
|
135
135
|
}
|
|
136
136
|
function isManifestProvider(o) {
|
|
137
137
|
return !!("remoteEntry" in o && o.remoteEntry.includes(MANIFEST_EXT));
|
|
@@ -182,23 +182,23 @@ function isStaticResourcesEqual(o, t) {
|
|
|
182
182
|
}
|
|
183
183
|
function createScript(o) {
|
|
184
184
|
let t = null, n = !0, r = 2e4, s;
|
|
185
|
-
const
|
|
186
|
-
for (let
|
|
187
|
-
const c = i
|
|
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, o.url)) {
|
|
189
189
|
t = c, n = !1;
|
|
190
190
|
break;
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
if (!t) {
|
|
194
|
-
const
|
|
195
|
-
t = document.createElement("script"), t.type = (
|
|
194
|
+
const i = o.attrs;
|
|
195
|
+
t = document.createElement("script"), t.type = (i == null ? void 0 : i.type) === "module" ? "module" : "text/javascript";
|
|
196
196
|
let c;
|
|
197
|
-
o.createScriptHook && (c = o.createScriptHook(o.url, o.attrs), c instanceof HTMLScriptElement ? t = c : typeof c == "object" && ("script" in c && c.script && (t = c.script), "timeout" in c && c.timeout && (r = c.timeout))), t.src || (t.src = o.url),
|
|
198
|
-
t && (u === "async" || u === "defer" ? t[u] =
|
|
197
|
+
o.createScriptHook && (c = o.createScriptHook(o.url, o.attrs), c instanceof HTMLScriptElement ? t = c : typeof c == "object" && ("script" in c && c.script && (t = c.script), "timeout" in c && c.timeout && (r = c.timeout))), t.src || (t.src = o.url), i && !c && Object.keys(i).forEach((u) => {
|
|
198
|
+
t && (u === "async" || u === "defer" ? t[u] = i[u] : t.getAttribute(u) || t.setAttribute(u, i[u]));
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
|
-
const l = async (
|
|
201
|
+
const l = async (i, c) => {
|
|
202
202
|
clearTimeout(s);
|
|
203
203
|
const u = () => {
|
|
204
204
|
(c == null ? void 0 : c.type) === "error" ? o != null && o.onErrorCallback && (o == null || o.onErrorCallback(c)) : o != null && o.cb && (o == null || o.cb());
|
|
@@ -206,8 +206,8 @@ function createScript(o) {
|
|
|
206
206
|
if (t && (t.onerror = null, t.onload = null, safeWrapper(() => {
|
|
207
207
|
const { needDeleteScript: p = !0 } = o;
|
|
208
208
|
p && t != null && t.parentNode && t.parentNode.removeChild(t);
|
|
209
|
-
}),
|
|
210
|
-
const p =
|
|
209
|
+
}), i && typeof i == "function")) {
|
|
210
|
+
const p = i(c);
|
|
211
211
|
if (p instanceof Promise) {
|
|
212
212
|
const d = await p;
|
|
213
213
|
return u(), d;
|
|
@@ -226,33 +226,33 @@ function createScript(o) {
|
|
|
226
226
|
function createLink(o) {
|
|
227
227
|
let t = null, n = !0;
|
|
228
228
|
const r = document.getElementsByTagName("link");
|
|
229
|
-
for (let
|
|
230
|
-
const l = r[
|
|
231
|
-
if (
|
|
229
|
+
for (let a = 0; a < r.length; a++) {
|
|
230
|
+
const l = r[a], i = l.getAttribute("href"), c = l.getAttribute("rel");
|
|
231
|
+
if (i && isStaticResourcesEqual(i, o.url) && c === o.attrs.rel) {
|
|
232
232
|
t = l, n = !1;
|
|
233
233
|
break;
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
if (!t) {
|
|
237
237
|
t = document.createElement("link"), t.setAttribute("href", o.url);
|
|
238
|
-
let
|
|
238
|
+
let a;
|
|
239
239
|
const l = o.attrs;
|
|
240
|
-
o.createLinkHook && (
|
|
241
|
-
t && !t.getAttribute(
|
|
240
|
+
o.createLinkHook && (a = o.createLinkHook(o.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 = (
|
|
245
|
-
const
|
|
244
|
+
const s = (a, l) => {
|
|
245
|
+
const i = () => {
|
|
246
246
|
(l == null ? void 0 : l.type) === "error" ? o != null && o.onErrorCallback && (o == null || o.onErrorCallback(l)) : o != null && o.cb && (o == null || o.cb());
|
|
247
247
|
};
|
|
248
248
|
if (t && (t.onerror = null, t.onload = null, safeWrapper(() => {
|
|
249
249
|
const { needDeleteLink: c = !0 } = o;
|
|
250
250
|
c && t != null && t.parentNode && t.parentNode.removeChild(t);
|
|
251
|
-
}),
|
|
252
|
-
const c =
|
|
253
|
-
return
|
|
251
|
+
}), a)) {
|
|
252
|
+
const c = a(l);
|
|
253
|
+
return i(), c;
|
|
254
254
|
}
|
|
255
|
-
|
|
255
|
+
i();
|
|
256
256
|
};
|
|
257
257
|
return t.onerror = s.bind(null, t.onerror), t.onload = s.bind(null, t.onload), {
|
|
258
258
|
link: t,
|
|
@@ -261,18 +261,18 @@ function createLink(o) {
|
|
|
261
261
|
}
|
|
262
262
|
function loadScript(o, t) {
|
|
263
263
|
const { attrs: n = {}, createScriptHook: r } = t;
|
|
264
|
-
return new Promise((s,
|
|
265
|
-
const { script: l, needAttach:
|
|
264
|
+
return new Promise((s, a) => {
|
|
265
|
+
const { script: l, needAttach: i } = createScript({
|
|
266
266
|
url: o,
|
|
267
267
|
cb: s,
|
|
268
|
-
onErrorCallback:
|
|
268
|
+
onErrorCallback: a,
|
|
269
269
|
attrs: _extends$2({
|
|
270
270
|
fetchpriority: "high"
|
|
271
271
|
}, n),
|
|
272
272
|
createScriptHook: r,
|
|
273
273
|
needDeleteScript: !0
|
|
274
274
|
});
|
|
275
|
-
|
|
275
|
+
i && document.head.appendChild(l);
|
|
276
276
|
});
|
|
277
277
|
}
|
|
278
278
|
const sdkImportCache = /* @__PURE__ */ new Map();
|
|
@@ -290,7 +290,7 @@ const loadNodeFetch = async () => {
|
|
|
290
290
|
const o = await importNodeModule("node-fetch");
|
|
291
291
|
return o.default || o;
|
|
292
292
|
}, lazyLoaderHookFetch = async (o, t, n) => {
|
|
293
|
-
const s = await ((
|
|
293
|
+
const s = await ((a, l) => n.lifecycle.fetch.emit(a, l))(o, t || {});
|
|
294
294
|
return !s || !(s instanceof Response) ? (typeof fetch > "u" ? await loadNodeFetch() : fetch)(o, t || {}) : s;
|
|
295
295
|
}, createScriptNode = typeof ENV_TARGET > "u" || ENV_TARGET !== "web" ? (url, cb, attrs, loaderHook) => {
|
|
296
296
|
if (loaderHook != null && loaderHook.createScriptHook) {
|
|
@@ -351,12 +351,12 @@ const loadNodeFetch = async () => {
|
|
|
351
351
|
} : (o, t, n, r) => {
|
|
352
352
|
t(new Error("createScriptNode is disabled in non-Node.js environment"));
|
|
353
353
|
}, loadScriptNode = typeof ENV_TARGET > "u" || ENV_TARGET !== "web" ? (o, t) => new Promise((n, r) => {
|
|
354
|
-
createScriptNode(o, (s,
|
|
354
|
+
createScriptNode(o, (s, a) => {
|
|
355
355
|
if (s)
|
|
356
356
|
r(s);
|
|
357
357
|
else {
|
|
358
|
-
var l,
|
|
359
|
-
const c = (t == null || (l = t.attrs) == null ? void 0 : l.globalName) || `__FEDERATION_${t == null || (
|
|
358
|
+
var l, i;
|
|
359
|
+
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;
|
|
360
360
|
n(u);
|
|
361
361
|
}
|
|
362
362
|
}, t.attrs, t.loaderHook);
|
|
@@ -366,15 +366,15 @@ const loadNodeFetch = async () => {
|
|
|
366
366
|
async function loadModule(o, t) {
|
|
367
367
|
if (esmModuleCache.has(o))
|
|
368
368
|
return esmModuleCache.get(o);
|
|
369
|
-
const { fetch: n, vm: r } = t,
|
|
369
|
+
const { fetch: n, vm: r } = t, a = await (await n(o)).text(), l = new r.SourceTextModule(a, {
|
|
370
370
|
// @ts-ignore
|
|
371
|
-
importModuleDynamically: async (
|
|
372
|
-
const u = new URL(
|
|
371
|
+
importModuleDynamically: async (i, c) => {
|
|
372
|
+
const u = new URL(i, o).href;
|
|
373
373
|
return loadModule(u, t);
|
|
374
374
|
}
|
|
375
375
|
});
|
|
376
|
-
return esmModuleCache.set(o, l), await l.link(async (
|
|
377
|
-
const c = new URL(
|
|
376
|
+
return esmModuleCache.set(o, l), await l.link(async (i) => {
|
|
377
|
+
const c = new URL(i, o).href;
|
|
378
378
|
return await loadModule(c, t);
|
|
379
379
|
}), l;
|
|
380
380
|
}
|
|
@@ -390,9 +390,9 @@ function _extends$1() {
|
|
|
390
390
|
}
|
|
391
391
|
function _object_without_properties_loose(o, t) {
|
|
392
392
|
if (o == null) return {};
|
|
393
|
-
var n = {}, r = Object.keys(o), s,
|
|
394
|
-
for (
|
|
395
|
-
s = r[
|
|
393
|
+
var n = {}, r = Object.keys(o), s, a;
|
|
394
|
+
for (a = 0; a < r.length; a++)
|
|
395
|
+
s = r[a], !(t.indexOf(s) >= 0) && (n[s] = o[s]);
|
|
396
396
|
return n;
|
|
397
397
|
}
|
|
398
398
|
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", RUNTIME_009 = "RUNTIME-009", TYPE_001 = "TYPE-001", BUILD_001 = "BUILD-001", BUILD_002 = "BUILD-002", getDocsUrl = (o) => `View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${o.split("-")[0].toLowerCase()}/${o}`, getShortErrorMsg = (o, t, n, r) => {
|
|
@@ -504,7 +504,7 @@ function includeOwnProperty(o, t) {
|
|
|
504
504
|
includeOwnProperty(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__") || definePropertyGlobalVal(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});
|
|
505
505
|
const globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;
|
|
506
506
|
function setGlobalDefaultVal(o) {
|
|
507
|
-
var t, n, r, s,
|
|
507
|
+
var t, n, r, s, a, l;
|
|
508
508
|
includeOwnProperty(o, "__VMOK__") && !includeOwnProperty(o, "__FEDERATION__") && definePropertyGlobalVal(o, "__FEDERATION__", o.__VMOK__), includeOwnProperty(o, "__FEDERATION__") || (definePropertyGlobalVal(o, "__FEDERATION__", {
|
|
509
509
|
__GLOBAL_PLUGIN__: [],
|
|
510
510
|
__INSTANCES__: [],
|
|
@@ -513,8 +513,8 @@ function setGlobalDefaultVal(o) {
|
|
|
513
513
|
__MANIFEST_LOADING__: {},
|
|
514
514
|
__PRELOADED_MAP__: /* @__PURE__ */ new Map()
|
|
515
515
|
}), definePropertyGlobalVal(o, "__VMOK__", o.__FEDERATION__));
|
|
516
|
-
var
|
|
517
|
-
(
|
|
516
|
+
var i;
|
|
517
|
+
(i = (t = o.__FEDERATION__).__GLOBAL_PLUGIN__) != null || (t.__GLOBAL_PLUGIN__ = []);
|
|
518
518
|
var c;
|
|
519
519
|
(c = (n = o.__FEDERATION__).__INSTANCES__) != null || (n.__INSTANCES__ = []);
|
|
520
520
|
var u;
|
|
@@ -522,14 +522,14 @@ function setGlobalDefaultVal(o) {
|
|
|
522
522
|
var p;
|
|
523
523
|
(p = (s = o.__FEDERATION__).__SHARE__) != null || (s.__SHARE__ = {});
|
|
524
524
|
var d;
|
|
525
|
-
(d = (
|
|
525
|
+
(d = (a = o.__FEDERATION__).__MANIFEST_LOADING__) != null || (a.__MANIFEST_LOADING__ = {});
|
|
526
526
|
var m;
|
|
527
527
|
(m = (l = o.__FEDERATION__).__PRELOADED_MAP__) != null || (l.__PRELOADED_MAP__ = /* @__PURE__ */ new Map());
|
|
528
528
|
}
|
|
529
529
|
setGlobalDefaultVal(CurrentGlobal);
|
|
530
530
|
setGlobalDefaultVal(nativeGlobal);
|
|
531
531
|
function setGlobalFederationConstructor(o, t = isDebugMode()) {
|
|
532
|
-
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = o, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.
|
|
532
|
+
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = o, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.19.0");
|
|
533
533
|
}
|
|
534
534
|
function getInfoWithoutType(o, t) {
|
|
535
535
|
if (typeof t == "string") {
|
|
@@ -541,11 +541,11 @@ function getInfoWithoutType(o, t) {
|
|
|
541
541
|
{
|
|
542
542
|
const r = Object.keys(o);
|
|
543
543
|
for (const s of r) {
|
|
544
|
-
const [
|
|
544
|
+
const [a, l] = s.split(":"), i = `${a}:${t}`, c = o[i];
|
|
545
545
|
if (c)
|
|
546
546
|
return {
|
|
547
547
|
value: c,
|
|
548
|
-
key:
|
|
548
|
+
key: i
|
|
549
549
|
};
|
|
550
550
|
}
|
|
551
551
|
return {
|
|
@@ -561,11 +561,11 @@ const getGlobalSnapshot = () => nativeGlobal.__FEDERATION__.moduleInfo, getTarge
|
|
|
561
561
|
if (r && !r.version && "version" in o && o.version && (r.version = o.version), r)
|
|
562
562
|
return r;
|
|
563
563
|
if ("version" in o && o.version) {
|
|
564
|
-
const { version: s } = o,
|
|
564
|
+
const { version: s } = o, a = _object_without_properties_loose(o, [
|
|
565
565
|
"version"
|
|
566
|
-
]), l = getFMId(
|
|
567
|
-
if ((
|
|
568
|
-
return
|
|
566
|
+
]), l = getFMId(a), i = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, l).value;
|
|
567
|
+
if ((i == null ? void 0 : i.version) === s)
|
|
568
|
+
return i;
|
|
569
569
|
}
|
|
570
570
|
}, getGlobalSnapshotInfoByModuleInfo = (o) => getTargetSnapshotInfoByModuleInfo(o, nativeGlobal.__FEDERATION__.moduleInfo), setGlobalSnapshotInfoByModuleInfo = (o, t) => {
|
|
571
571
|
const n = getFMId(o);
|
|
@@ -598,7 +598,7 @@ function combineVersion(o, t, n, r) {
|
|
|
598
598
|
return r ? `${s}-${r}` : s;
|
|
599
599
|
}
|
|
600
600
|
function parseHyphen(o) {
|
|
601
|
-
return o.replace(parseRegex(hyphenRange), (t, n, r, s,
|
|
601
|
+
return o.replace(parseRegex(hyphenRange), (t, n, r, s, a, l, i, c, u, p, d, m) => (isXVersion(r) ? n = "" : isXVersion(s) ? n = `>=${r}.0.0` : isXVersion(a) ? n = `>=${r}.${s}.0` : n = `>=${n}`, isXVersion(u) ? c = "" : isXVersion(p) ? c = `<${Number(u) + 1}.0.0-0` : isXVersion(d) ? c = `<${u}.${Number(p) + 1}.0-0` : m ? c = `<=${u}.${p}.${d}-${m}` : c = `<=${c}`, `${n} ${c}`.trim()));
|
|
602
602
|
}
|
|
603
603
|
function parseComparatorTrim(o) {
|
|
604
604
|
return o.replace(parseRegex(comparatorTrim), "$1$2$3");
|
|
@@ -610,15 +610,15 @@ function parseCaretTrim(o) {
|
|
|
610
610
|
return o.replace(parseRegex(caretTrim), "$1^");
|
|
611
611
|
}
|
|
612
612
|
function parseCarets(o) {
|
|
613
|
-
return o.trim().split(/\s+/).map((t) => t.replace(parseRegex(caret), (n, r, s,
|
|
613
|
+
return o.trim().split(/\s+/).map((t) => t.replace(parseRegex(caret), (n, 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(" ");
|
|
614
614
|
}
|
|
615
615
|
function parseTildes(o) {
|
|
616
|
-
return o.trim().split(/\s+/).map((t) => t.replace(parseRegex(tilde), (n, r, s,
|
|
616
|
+
return o.trim().split(/\s+/).map((t) => t.replace(parseRegex(tilde), (n, 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(" ");
|
|
617
617
|
}
|
|
618
618
|
function parseXRanges(o) {
|
|
619
|
-
return o.split(/\s+/).map((t) => t.trim().replace(parseRegex(xRange), (n, r, s,
|
|
620
|
-
const c = isXVersion(s), u = c || isXVersion(
|
|
621
|
-
return r === "=" && p && (r = ""),
|
|
619
|
+
return o.split(/\s+/).map((t) => t.trim().replace(parseRegex(xRange), (n, r, s, a, l, i) => {
|
|
620
|
+
const c = isXVersion(s), u = c || isXVersion(a), p = u || isXVersion(l);
|
|
621
|
+
return r === "=" && p && (r = ""), i = "", c ? r === ">" || r === "<" ? "<0.0.0-0" : "*" : r && p ? (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` : p ? `>=${s}.${a}.0${i} <${s}.${Number(a) + 1}.0-0` : n;
|
|
622
622
|
})).join(" ");
|
|
623
623
|
}
|
|
624
624
|
function parseStar(o) {
|
|
@@ -638,10 +638,10 @@ function comparePreRelease(o, t) {
|
|
|
638
638
|
return -1;
|
|
639
639
|
if (n === void 0 && r === void 0)
|
|
640
640
|
return 0;
|
|
641
|
-
for (let s = 0,
|
|
642
|
-
const l = n[s],
|
|
643
|
-
if (l !==
|
|
644
|
-
return l === void 0 &&
|
|
641
|
+
for (let s = 0, a = n.length; s <= a; s++) {
|
|
642
|
+
const l = n[s], i = r[s];
|
|
643
|
+
if (l !== i)
|
|
644
|
+
return l === void 0 && i === void 0 ? 0 : l ? i ? compareAtom(l, i) : -1 : 1;
|
|
645
645
|
}
|
|
646
646
|
return 0;
|
|
647
647
|
}
|
|
@@ -714,13 +714,13 @@ function satisfy(o, t) {
|
|
|
714
714
|
const n = extractComparator(o);
|
|
715
715
|
if (!n)
|
|
716
716
|
return !1;
|
|
717
|
-
const [, r, , s,
|
|
717
|
+
const [, r, , s, a, l, i] = n, c = {
|
|
718
718
|
operator: r,
|
|
719
|
-
version: combineVersion(s,
|
|
719
|
+
version: combineVersion(s, a, l, i),
|
|
720
720
|
major: s,
|
|
721
|
-
minor:
|
|
721
|
+
minor: a,
|
|
722
722
|
patch: l,
|
|
723
|
-
preRelease:
|
|
723
|
+
preRelease: i == null ? void 0 : i.split(".")
|
|
724
724
|
}, u = t.split("||");
|
|
725
725
|
for (const p of u) {
|
|
726
726
|
const d = p.trim();
|
|
@@ -733,14 +733,14 @@ function satisfy(o, t) {
|
|
|
733
733
|
const y = m.split(" ").map((_) => parseComparatorString(_)).join(" ");
|
|
734
734
|
if (!y.trim())
|
|
735
735
|
return !0;
|
|
736
|
-
const
|
|
737
|
-
if (
|
|
736
|
+
const E = y.split(/\s+/).map((_) => parseGTE0(_)).filter(Boolean);
|
|
737
|
+
if (E.length === 0)
|
|
738
738
|
continue;
|
|
739
|
-
let
|
|
740
|
-
for (const _ of
|
|
739
|
+
let g = !0;
|
|
740
|
+
for (const _ of E) {
|
|
741
741
|
const b = extractComparator(_);
|
|
742
742
|
if (!b) {
|
|
743
|
-
|
|
743
|
+
g = !1;
|
|
744
744
|
break;
|
|
745
745
|
}
|
|
746
746
|
const [, v, , I, S, R, A] = b, T = {
|
|
@@ -752,11 +752,11 @@ function satisfy(o, t) {
|
|
|
752
752
|
preRelease: A == null ? void 0 : A.split(".")
|
|
753
753
|
};
|
|
754
754
|
if (!compare(T, c)) {
|
|
755
|
-
|
|
755
|
+
g = !1;
|
|
756
756
|
break;
|
|
757
757
|
}
|
|
758
758
|
}
|
|
759
|
-
if (
|
|
759
|
+
if (g)
|
|
760
760
|
return !0;
|
|
761
761
|
} catch (m) {
|
|
762
762
|
console.error(`[semver] Error processing range part "${d}":`, m);
|
|
@@ -770,7 +770,7 @@ function formatShare(o, t, n, r) {
|
|
|
770
770
|
"get" in o ? s = o.get : "lib" in o ? s = () => Promise.resolve(o.lib) : s = () => Promise.resolve(() => {
|
|
771
771
|
throw new Error(`Can not get shared '${n}'!`);
|
|
772
772
|
});
|
|
773
|
-
var
|
|
773
|
+
var a, l, i;
|
|
774
774
|
return _extends$1({
|
|
775
775
|
deps: [],
|
|
776
776
|
useIn: [],
|
|
@@ -785,35 +785,35 @@ function formatShare(o, t, n, r) {
|
|
|
785
785
|
}, o.shareConfig),
|
|
786
786
|
get: s,
|
|
787
787
|
loaded: o != null && o.loaded || "lib" in o ? !0 : void 0,
|
|
788
|
-
version: (
|
|
788
|
+
version: (a = o.version) != null ? a : "0",
|
|
789
789
|
scope: Array.isArray(o.scope) ? o.scope : [
|
|
790
790
|
(l = o.scope) != null ? l : "default"
|
|
791
791
|
],
|
|
792
|
-
strategy: ((
|
|
792
|
+
strategy: ((i = o.strategy) != null ? i : r) || "version-first"
|
|
793
793
|
});
|
|
794
794
|
}
|
|
795
795
|
function formatShareConfigs(o, t) {
|
|
796
|
-
const n = t.shared || {}, r = t.name, s = Object.keys(n).reduce((l,
|
|
797
|
-
const c = arrayOptions(n[
|
|
798
|
-
return l[
|
|
799
|
-
l[
|
|
796
|
+
const n = t.shared || {}, r = t.name, s = Object.keys(n).reduce((l, i) => {
|
|
797
|
+
const c = arrayOptions(n[i]);
|
|
798
|
+
return l[i] = l[i] || [], c.forEach((u) => {
|
|
799
|
+
l[i].push(formatShare(u, r, i, t.shareStrategy));
|
|
800
800
|
}), l;
|
|
801
|
-
}, {}),
|
|
801
|
+
}, {}), a = _extends$1({}, o.shared);
|
|
802
802
|
return Object.keys(s).forEach((l) => {
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
}) :
|
|
803
|
+
a[l] ? s[l].forEach((i) => {
|
|
804
|
+
a[l].find((u) => u.version === i.version) || a[l].push(i);
|
|
805
|
+
}) : a[l] = s[l];
|
|
806
806
|
}), {
|
|
807
|
-
shared:
|
|
807
|
+
shared: a,
|
|
808
808
|
shareInfos: s
|
|
809
809
|
};
|
|
810
810
|
}
|
|
811
811
|
function versionLt(o, t) {
|
|
812
812
|
const n = (r) => {
|
|
813
813
|
if (!Number.isNaN(Number(r))) {
|
|
814
|
-
const
|
|
814
|
+
const a = r.split(".");
|
|
815
815
|
let l = r;
|
|
816
|
-
for (let
|
|
816
|
+
for (let i = 0; i < 3 - a.length; i++)
|
|
817
817
|
l += ".0";
|
|
818
818
|
return l;
|
|
819
819
|
}
|
|
@@ -828,15 +828,15 @@ const findVersion = (o, t) => {
|
|
|
828
828
|
return Object.keys(o).reduce((r, s) => !r || n(r, s) || r === "0" ? s : r, 0);
|
|
829
829
|
}, isLoaded = (o) => !!o.loaded || typeof o.lib == "function", isLoading = (o) => !!o.loading;
|
|
830
830
|
function findSingletonVersionOrderByVersion(o, t, n) {
|
|
831
|
-
const r = o[t][n], s = function(
|
|
832
|
-
return !isLoaded(r[
|
|
831
|
+
const r = o[t][n], s = function(a, l) {
|
|
832
|
+
return !isLoaded(r[a]) && versionLt(a, l);
|
|
833
833
|
};
|
|
834
834
|
return findVersion(o[t][n], s);
|
|
835
835
|
}
|
|
836
836
|
function findSingletonVersionOrderByLoaded(o, t, n) {
|
|
837
|
-
const r = o[t][n], s = function(
|
|
838
|
-
const
|
|
839
|
-
return
|
|
837
|
+
const r = o[t][n], s = function(a, l) {
|
|
838
|
+
const i = (c) => isLoaded(c) || isLoading(c);
|
|
839
|
+
return i(r[l]) ? i(r[a]) ? !!versionLt(a, l) : !0 : i(r[a]) ? !1 : versionLt(a, l);
|
|
840
840
|
};
|
|
841
841
|
return findVersion(o[t][n], s);
|
|
842
842
|
}
|
|
@@ -846,23 +846,23 @@ function getFindShareFunction(o) {
|
|
|
846
846
|
function getRegisteredShare(o, t, n, r) {
|
|
847
847
|
if (!o)
|
|
848
848
|
return;
|
|
849
|
-
const { shareConfig: s, scope:
|
|
850
|
-
|
|
849
|
+
const { shareConfig: s, scope: a = DEFAULT_SCOPE, strategy: l } = n, i = Array.isArray(a) ? a : [
|
|
850
|
+
a
|
|
851
851
|
];
|
|
852
|
-
for (const c of
|
|
852
|
+
for (const c of i)
|
|
853
853
|
if (s && o[c] && o[c][t]) {
|
|
854
854
|
const { requiredVersion: u } = s, d = getFindShareFunction(l)(o, c, t), m = () => {
|
|
855
855
|
if (s.singleton) {
|
|
856
856
|
if (typeof u == "string" && !satisfy(d, u)) {
|
|
857
|
-
const
|
|
858
|
-
s.strictVersion ? error(
|
|
857
|
+
const g = `Version ${d} from ${d && o[c][t][d].from} of shared singleton module ${t} does not satisfy the requirement of ${n.from} which needs ${u})`;
|
|
858
|
+
s.strictVersion ? error(g) : warn(g);
|
|
859
859
|
}
|
|
860
860
|
return o[c][t][d];
|
|
861
861
|
} else {
|
|
862
862
|
if (u === !1 || u === "*" || satisfy(d, u))
|
|
863
863
|
return o[c][t][d];
|
|
864
|
-
for (const [
|
|
865
|
-
if (satisfy(
|
|
864
|
+
for (const [g, _] of Object.entries(o[c][t]))
|
|
865
|
+
if (satisfy(g, u))
|
|
866
866
|
return _;
|
|
867
867
|
}
|
|
868
868
|
}, y = {
|
|
@@ -880,11 +880,11 @@ function getGlobalShareScope() {
|
|
|
880
880
|
return Global.__FEDERATION__.__SHARE__;
|
|
881
881
|
}
|
|
882
882
|
function getTargetSharedOptions(o) {
|
|
883
|
-
const { pkgName: t, extraOptions: n, shareInfos: r } = o, s = (
|
|
884
|
-
if (!
|
|
883
|
+
const { pkgName: t, extraOptions: n, shareInfos: r } = o, s = (i) => {
|
|
884
|
+
if (!i)
|
|
885
885
|
return;
|
|
886
886
|
const c = {};
|
|
887
|
-
|
|
887
|
+
i.forEach((d) => {
|
|
888
888
|
c[d.version] = d;
|
|
889
889
|
});
|
|
890
890
|
const p = findVersion(c, function(d, m) {
|
|
@@ -892,8 +892,8 @@ function getTargetSharedOptions(o) {
|
|
|
892
892
|
});
|
|
893
893
|
return c[p];
|
|
894
894
|
};
|
|
895
|
-
var
|
|
896
|
-
const l = (
|
|
895
|
+
var a;
|
|
896
|
+
const l = (a = n == null ? void 0 : n.resolver) != null ? a : s;
|
|
897
897
|
return Object.assign({}, l(r[t]), n == null ? void 0 : n.customShareInfo);
|
|
898
898
|
}
|
|
899
899
|
function getBuilderId() {
|
|
@@ -905,9 +905,9 @@ function matchRemoteWithNameAndExpose(o, t) {
|
|
|
905
905
|
let s = t.replace(n.name, "");
|
|
906
906
|
if (r) {
|
|
907
907
|
if (s.startsWith("/")) {
|
|
908
|
-
const
|
|
908
|
+
const i = n.name;
|
|
909
909
|
return s = `.${s}`, {
|
|
910
|
-
pkgNameOrAlias:
|
|
910
|
+
pkgNameOrAlias: i,
|
|
911
911
|
expose: s,
|
|
912
912
|
remote: n
|
|
913
913
|
};
|
|
@@ -918,13 +918,13 @@ function matchRemoteWithNameAndExpose(o, t) {
|
|
|
918
918
|
remote: n
|
|
919
919
|
};
|
|
920
920
|
}
|
|
921
|
-
const
|
|
921
|
+
const a = n.alias && t.startsWith(n.alias);
|
|
922
922
|
let l = n.alias && t.replace(n.alias, "");
|
|
923
|
-
if (n.alias &&
|
|
923
|
+
if (n.alias && a) {
|
|
924
924
|
if (l && l.startsWith("/")) {
|
|
925
|
-
const
|
|
925
|
+
const i = n.alias;
|
|
926
926
|
return l = `.${l}`, {
|
|
927
|
-
pkgNameOrAlias:
|
|
927
|
+
pkgNameOrAlias: i,
|
|
928
928
|
expose: l,
|
|
929
929
|
remote: n
|
|
930
930
|
};
|
|
@@ -952,10 +952,10 @@ function registerPlugins(o, t) {
|
|
|
952
952
|
t.bridgeHook
|
|
953
953
|
];
|
|
954
954
|
return n.length > 0 && n.forEach((s) => {
|
|
955
|
-
o != null && o.find((
|
|
955
|
+
o != null && o.find((a) => a.name !== s.name) && o.push(s);
|
|
956
956
|
}), o && o.length > 0 && o.forEach((s) => {
|
|
957
|
-
r.forEach((
|
|
958
|
-
|
|
957
|
+
r.forEach((a) => {
|
|
958
|
+
a.applyPlugin(s, t);
|
|
959
959
|
});
|
|
960
960
|
}), o;
|
|
961
961
|
}
|
|
@@ -996,17 +996,20 @@ function handleRemoteEntryLoaded(o, t, n) {
|
|
|
996
996
|
remoteEntryKey: r
|
|
997
997
|
})), s;
|
|
998
998
|
}
|
|
999
|
-
async function loadEntryScript({ name: o, globalName: t, entry: n, loaderHook: r }) {
|
|
1000
|
-
const { entryExports:
|
|
1001
|
-
|
|
999
|
+
async function loadEntryScript({ name: o, globalName: t, entry: n, loaderHook: r, getEntryUrl: s }) {
|
|
1000
|
+
const { entryExports: a } = getRemoteEntryExports(o, t);
|
|
1001
|
+
if (a)
|
|
1002
|
+
return a;
|
|
1003
|
+
const l = s ? s(n) : n;
|
|
1004
|
+
return loadScript(l, {
|
|
1002
1005
|
attrs: {},
|
|
1003
|
-
createScriptHook: (i,
|
|
1004
|
-
const
|
|
1006
|
+
createScriptHook: (i, c) => {
|
|
1007
|
+
const u = r.lifecycle.createScript.emit({
|
|
1005
1008
|
url: i,
|
|
1006
|
-
attrs:
|
|
1009
|
+
attrs: c
|
|
1007
1010
|
});
|
|
1008
|
-
if (
|
|
1009
|
-
return
|
|
1011
|
+
if (u && (u instanceof HTMLScriptElement || "script" in u || "timeout" in u))
|
|
1012
|
+
return u;
|
|
1010
1013
|
}
|
|
1011
1014
|
}).then(() => handleRemoteEntryLoaded(o, t, n)).catch((i) => {
|
|
1012
1015
|
throw assert(void 0, getShortErrorMsg(RUNTIME_008, runtimeDescMap, {
|
|
@@ -1015,75 +1018,77 @@ async function loadEntryScript({ name: o, globalName: t, entry: n, loaderHook: r
|
|
|
1015
1018
|
})), i;
|
|
1016
1019
|
});
|
|
1017
1020
|
}
|
|
1018
|
-
async function loadEntryDom({ remoteInfo: o, remoteEntryExports: t, loaderHook: n }) {
|
|
1019
|
-
const { entry:
|
|
1020
|
-
switch (
|
|
1021
|
+
async function loadEntryDom({ remoteInfo: o, remoteEntryExports: t, loaderHook: n, getEntryUrl: r }) {
|
|
1022
|
+
const { entry: s, entryGlobalName: a, name: l, type: i } = o;
|
|
1023
|
+
switch (i) {
|
|
1021
1024
|
case "esm":
|
|
1022
1025
|
case "module":
|
|
1023
1026
|
return loadEsmEntry({
|
|
1024
|
-
entry:
|
|
1027
|
+
entry: s,
|
|
1025
1028
|
remoteEntryExports: t
|
|
1026
1029
|
});
|
|
1027
1030
|
case "system":
|
|
1028
1031
|
return loadSystemJsEntry({
|
|
1029
|
-
entry:
|
|
1032
|
+
entry: s,
|
|
1030
1033
|
remoteEntryExports: t
|
|
1031
1034
|
});
|
|
1032
1035
|
default:
|
|
1033
1036
|
return loadEntryScript({
|
|
1034
|
-
entry:
|
|
1035
|
-
globalName:
|
|
1036
|
-
name:
|
|
1037
|
-
loaderHook: n
|
|
1037
|
+
entry: s,
|
|
1038
|
+
globalName: a,
|
|
1039
|
+
name: l,
|
|
1040
|
+
loaderHook: n,
|
|
1041
|
+
getEntryUrl: r
|
|
1038
1042
|
});
|
|
1039
1043
|
}
|
|
1040
1044
|
}
|
|
1041
1045
|
async function loadEntryNode({ remoteInfo: o, loaderHook: t }) {
|
|
1042
|
-
const { entry: n, entryGlobalName: r, name: s, type:
|
|
1046
|
+
const { entry: n, entryGlobalName: r, name: s, type: a } = o, { entryExports: l } = getRemoteEntryExports(s, r);
|
|
1043
1047
|
return l || loadScriptNode(n, {
|
|
1044
1048
|
attrs: {
|
|
1045
1049
|
name: s,
|
|
1046
1050
|
globalName: r,
|
|
1047
|
-
type:
|
|
1051
|
+
type: a
|
|
1048
1052
|
},
|
|
1049
1053
|
loaderHook: {
|
|
1050
|
-
createScriptHook: (
|
|
1054
|
+
createScriptHook: (i, c = {}) => {
|
|
1051
1055
|
const u = t.lifecycle.createScript.emit({
|
|
1052
|
-
url:
|
|
1056
|
+
url: i,
|
|
1053
1057
|
attrs: c
|
|
1054
1058
|
});
|
|
1055
1059
|
if (u && "url" in u)
|
|
1056
1060
|
return u;
|
|
1057
1061
|
}
|
|
1058
1062
|
}
|
|
1059
|
-
}).then(() => handleRemoteEntryLoaded(s, r, n)).catch((
|
|
1060
|
-
throw
|
|
1063
|
+
}).then(() => handleRemoteEntryLoaded(s, r, n)).catch((i) => {
|
|
1064
|
+
throw i;
|
|
1061
1065
|
});
|
|
1062
1066
|
}
|
|
1063
1067
|
function getRemoteEntryUniqueKey(o) {
|
|
1064
1068
|
const { entry: t, name: n } = o;
|
|
1065
1069
|
return composeKeyWithSeparator(n, t);
|
|
1066
1070
|
}
|
|
1067
|
-
async function getRemoteEntry(
|
|
1068
|
-
const r = getRemoteEntryUniqueKey(
|
|
1069
|
-
if (
|
|
1070
|
-
return
|
|
1071
|
-
if (!globalLoading[
|
|
1072
|
-
const
|
|
1073
|
-
globalLoading[
|
|
1071
|
+
async function getRemoteEntry(o) {
|
|
1072
|
+
const { origin: t, remoteEntryExports: n, remoteInfo: r, getEntryUrl: s } = o, a = getRemoteEntryUniqueKey(r);
|
|
1073
|
+
if (n)
|
|
1074
|
+
return n;
|
|
1075
|
+
if (!globalLoading[a]) {
|
|
1076
|
+
const l = t.remoteHandler.hooks.lifecycle.loadEntry, i = t.loaderHook;
|
|
1077
|
+
globalLoading[a] = l.emit({
|
|
1074
1078
|
loaderHook: i,
|
|
1075
|
-
remoteInfo:
|
|
1076
|
-
remoteEntryExports:
|
|
1077
|
-
}).then((
|
|
1078
|
-
remoteInfo:
|
|
1079
|
-
remoteEntryExports:
|
|
1080
|
-
loaderHook: i
|
|
1079
|
+
remoteInfo: r,
|
|
1080
|
+
remoteEntryExports: n
|
|
1081
|
+
}).then((c) => c || ((typeof ENV_TARGET < "u" ? ENV_TARGET === "web" : isBrowserEnv()) ? loadEntryDom({
|
|
1082
|
+
remoteInfo: r,
|
|
1083
|
+
remoteEntryExports: n,
|
|
1084
|
+
loaderHook: i,
|
|
1085
|
+
getEntryUrl: s
|
|
1081
1086
|
}) : loadEntryNode({
|
|
1082
|
-
remoteInfo:
|
|
1087
|
+
remoteInfo: r,
|
|
1083
1088
|
loaderHook: i
|
|
1084
1089
|
})));
|
|
1085
1090
|
}
|
|
1086
|
-
return globalLoading[
|
|
1091
|
+
return globalLoading[a];
|
|
1087
1092
|
}
|
|
1088
1093
|
function getRemoteInfo(o) {
|
|
1089
1094
|
return _extends$1({}, o, {
|
|
@@ -1117,10 +1122,10 @@ function normalizePreloadExposes(o) {
|
|
|
1117
1122
|
return o ? o.map((t) => t === "." ? t : t.startsWith("./") ? t.replace("./", "") : t) : [];
|
|
1118
1123
|
}
|
|
1119
1124
|
function preloadAssets(o, t, n, r = !0) {
|
|
1120
|
-
const { cssAssets: s, jsAssetsWithoutEntry:
|
|
1125
|
+
const { cssAssets: s, jsAssetsWithoutEntry: a, entryAssets: l } = n;
|
|
1121
1126
|
if (t.options.inBrowser) {
|
|
1122
|
-
if (l.forEach((
|
|
1123
|
-
const { moduleInfo: c } =
|
|
1127
|
+
if (l.forEach((i) => {
|
|
1128
|
+
const { moduleInfo: c } = i, u = t.moduleCache.get(o.name);
|
|
1124
1129
|
getRemoteEntry(u ? {
|
|
1125
1130
|
origin: t,
|
|
1126
1131
|
remoteInfo: c,
|
|
@@ -1131,7 +1136,7 @@ function preloadAssets(o, t, n, r = !0) {
|
|
|
1131
1136
|
remoteEntryExports: void 0
|
|
1132
1137
|
});
|
|
1133
1138
|
}), r) {
|
|
1134
|
-
const
|
|
1139
|
+
const i = {
|
|
1135
1140
|
rel: "preload",
|
|
1136
1141
|
as: "style"
|
|
1137
1142
|
};
|
|
@@ -1140,7 +1145,7 @@ function preloadAssets(o, t, n, r = !0) {
|
|
|
1140
1145
|
url: c,
|
|
1141
1146
|
cb: () => {
|
|
1142
1147
|
},
|
|
1143
|
-
attrs:
|
|
1148
|
+
attrs: i,
|
|
1144
1149
|
createLinkHook: (d, m) => {
|
|
1145
1150
|
const y = t.loaderHook.lifecycle.createLink.emit({
|
|
1146
1151
|
url: d,
|
|
@@ -1153,7 +1158,7 @@ function preloadAssets(o, t, n, r = !0) {
|
|
|
1153
1158
|
p && document.head.appendChild(u);
|
|
1154
1159
|
});
|
|
1155
1160
|
} else {
|
|
1156
|
-
const
|
|
1161
|
+
const i = {
|
|
1157
1162
|
rel: "stylesheet",
|
|
1158
1163
|
type: "text/css"
|
|
1159
1164
|
};
|
|
@@ -1162,7 +1167,7 @@ function preloadAssets(o, t, n, r = !0) {
|
|
|
1162
1167
|
url: c,
|
|
1163
1168
|
cb: () => {
|
|
1164
1169
|
},
|
|
1165
|
-
attrs:
|
|
1170
|
+
attrs: i,
|
|
1166
1171
|
createLinkHook: (d, m) => {
|
|
1167
1172
|
const y = t.loaderHook.lifecycle.createLink.emit({
|
|
1168
1173
|
url: d,
|
|
@@ -1177,16 +1182,16 @@ function preloadAssets(o, t, n, r = !0) {
|
|
|
1177
1182
|
});
|
|
1178
1183
|
}
|
|
1179
1184
|
if (r) {
|
|
1180
|
-
const
|
|
1185
|
+
const i = {
|
|
1181
1186
|
rel: "preload",
|
|
1182
1187
|
as: "script"
|
|
1183
1188
|
};
|
|
1184
|
-
|
|
1189
|
+
a.forEach((c) => {
|
|
1185
1190
|
const { link: u, needAttach: p } = createLink({
|
|
1186
1191
|
url: c,
|
|
1187
1192
|
cb: () => {
|
|
1188
1193
|
},
|
|
1189
|
-
attrs:
|
|
1194
|
+
attrs: i,
|
|
1190
1195
|
createLinkHook: (d, m) => {
|
|
1191
1196
|
const y = t.loaderHook.lifecycle.createLink.emit({
|
|
1192
1197
|
url: d,
|
|
@@ -1199,16 +1204,16 @@ function preloadAssets(o, t, n, r = !0) {
|
|
|
1199
1204
|
p && document.head.appendChild(u);
|
|
1200
1205
|
});
|
|
1201
1206
|
} else {
|
|
1202
|
-
const
|
|
1207
|
+
const i = {
|
|
1203
1208
|
fetchpriority: "high",
|
|
1204
1209
|
type: (o == null ? void 0 : o.type) === "module" ? "module" : "text/javascript"
|
|
1205
1210
|
};
|
|
1206
|
-
|
|
1211
|
+
a.forEach((c) => {
|
|
1207
1212
|
const { script: u, needAttach: p } = createScript({
|
|
1208
1213
|
url: c,
|
|
1209
1214
|
cb: () => {
|
|
1210
1215
|
},
|
|
1211
|
-
attrs:
|
|
1216
|
+
attrs: i,
|
|
1212
1217
|
createScriptHook: (d, m) => {
|
|
1213
1218
|
const y = t.loaderHook.lifecycle.createScript.emit({
|
|
1214
1219
|
url: d,
|
|
@@ -1235,23 +1240,23 @@ let Module = class {
|
|
|
1235
1240
|
remoteInfo: this.remoteInfo,
|
|
1236
1241
|
remoteEntryExports: this.remoteEntryExports
|
|
1237
1242
|
});
|
|
1238
|
-
} catch {
|
|
1243
|
+
} catch (n) {
|
|
1239
1244
|
const r = getRemoteEntryUniqueKey(this.remoteInfo);
|
|
1240
|
-
t = await this.host.loaderHook.lifecycle.loadEntryError.emit({
|
|
1245
|
+
n instanceof Error && n.message.includes(RUNTIME_008) && (t = await this.host.loaderHook.lifecycle.loadEntryError.emit({
|
|
1241
1246
|
getRemoteEntry,
|
|
1242
1247
|
origin: this.host,
|
|
1243
1248
|
remoteInfo: this.remoteInfo,
|
|
1244
1249
|
remoteEntryExports: this.remoteEntryExports,
|
|
1245
1250
|
globalLoading,
|
|
1246
1251
|
uniqueKey: r
|
|
1247
|
-
});
|
|
1252
|
+
}));
|
|
1248
1253
|
}
|
|
1249
1254
|
return assert(t, `remoteEntryExports is undefined
|
|
1250
1255
|
${safeToString(this.remoteInfo)}`), this.remoteEntryExports = t, this.remoteEntryExports;
|
|
1251
1256
|
}
|
|
1252
1257
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1253
1258
|
async get(t, n, r, s) {
|
|
1254
|
-
const { loadFactory:
|
|
1259
|
+
const { loadFactory: a = !0 } = r || {
|
|
1255
1260
|
loadFactory: !0
|
|
1256
1261
|
}, l = await this.getEntry();
|
|
1257
1262
|
if (!this.inited) {
|
|
@@ -1261,11 +1266,11 @@ let Module = class {
|
|
|
1261
1266
|
m.length || m.push("default"), m.forEach((b) => {
|
|
1262
1267
|
d[b] || (d[b] = {});
|
|
1263
1268
|
});
|
|
1264
|
-
const y = d[m[0]],
|
|
1269
|
+
const y = d[m[0]], E = [], g = {
|
|
1265
1270
|
version: this.remoteInfo.version || "",
|
|
1266
1271
|
shareScopeKeys: Array.isArray(this.remoteInfo.shareScope) ? m : this.remoteInfo.shareScope || "default"
|
|
1267
1272
|
};
|
|
1268
|
-
Object.defineProperty(
|
|
1273
|
+
Object.defineProperty(g, "shareScopeMap", {
|
|
1269
1274
|
value: d,
|
|
1270
1275
|
// remoteEntryInitOptions will be traversed and assigned during container init, ,so this attribute is not allowed to be traversed
|
|
1271
1276
|
enumerable: !1
|
|
@@ -1273,8 +1278,8 @@ let Module = class {
|
|
|
1273
1278
|
const _ = await this.host.hooks.lifecycle.beforeInitContainer.emit({
|
|
1274
1279
|
shareScope: y,
|
|
1275
1280
|
// @ts-ignore shareScopeMap will be set by Object.defineProperty
|
|
1276
|
-
remoteEntryInitOptions:
|
|
1277
|
-
initScope:
|
|
1281
|
+
remoteEntryInitOptions: g,
|
|
1282
|
+
initScope: E,
|
|
1278
1283
|
remoteInfo: this.remoteInfo,
|
|
1279
1284
|
origin: this.host
|
|
1280
1285
|
});
|
|
@@ -1290,19 +1295,19 @@ let Module = class {
|
|
|
1290
1295
|
}));
|
|
1291
1296
|
}
|
|
1292
1297
|
this.lib = l, this.inited = !0;
|
|
1293
|
-
let
|
|
1294
|
-
|
|
1298
|
+
let i;
|
|
1299
|
+
i = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
|
|
1295
1300
|
remoteEntryExports: l,
|
|
1296
1301
|
expose: n,
|
|
1297
1302
|
moduleInfo: this.remoteInfo
|
|
1298
|
-
}),
|
|
1299
|
-
const c = processModuleAlias(this.remoteInfo.name, n), u = this.wraperFactory(
|
|
1300
|
-
return
|
|
1303
|
+
}), i || (i = await l.get(n)), assert(i, `${getFMId(this.remoteInfo)} remote don't export ${n}.`);
|
|
1304
|
+
const c = processModuleAlias(this.remoteInfo.name, n), u = this.wraperFactory(i, c);
|
|
1305
|
+
return a ? await u() : u;
|
|
1301
1306
|
}
|
|
1302
1307
|
wraperFactory(t, n) {
|
|
1303
|
-
function r(s,
|
|
1308
|
+
function r(s, a) {
|
|
1304
1309
|
s && typeof s == "object" && Object.isExtensible(s) && !Object.getOwnPropertyDescriptor(s, Symbol.for("mf_module_id")) && Object.defineProperty(s, Symbol.for("mf_module_id"), {
|
|
1305
|
-
value:
|
|
1310
|
+
value: a,
|
|
1306
1311
|
enumerable: !1
|
|
1307
1312
|
});
|
|
1308
1313
|
}
|
|
@@ -1350,8 +1355,8 @@ class AsyncHook extends SyncHook {
|
|
|
1350
1355
|
const r = Array.from(this.listeners);
|
|
1351
1356
|
if (r.length > 0) {
|
|
1352
1357
|
let s = 0;
|
|
1353
|
-
const
|
|
1354
|
-
n =
|
|
1358
|
+
const a = (l) => l === !1 ? !1 : s < r.length ? Promise.resolve(r[s++].apply(null, t)).then(a) : l;
|
|
1359
|
+
n = a();
|
|
1355
1360
|
}
|
|
1356
1361
|
return Promise.resolve(n);
|
|
1357
1362
|
}
|
|
@@ -1393,19 +1398,19 @@ class AsyncWaterfallHook extends SyncHook {
|
|
|
1393
1398
|
const n = Array.from(this.listeners);
|
|
1394
1399
|
if (n.length > 0) {
|
|
1395
1400
|
let r = 0;
|
|
1396
|
-
const s = (l) => (warn(l), this.onerror(l), t),
|
|
1401
|
+
const s = (l) => (warn(l), this.onerror(l), t), a = (l) => {
|
|
1397
1402
|
if (checkReturnData(t, l)) {
|
|
1398
1403
|
if (t = l, r < n.length)
|
|
1399
1404
|
try {
|
|
1400
|
-
return Promise.resolve(n[r++](t)).then(
|
|
1401
|
-
} catch (
|
|
1402
|
-
return s(
|
|
1405
|
+
return Promise.resolve(n[r++](t)).then(a, s);
|
|
1406
|
+
} catch (i) {
|
|
1407
|
+
return s(i);
|
|
1403
1408
|
}
|
|
1404
1409
|
} else
|
|
1405
1410
|
this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
|
|
1406
1411
|
return t;
|
|
1407
1412
|
};
|
|
1408
|
-
return Promise.resolve(
|
|
1413
|
+
return Promise.resolve(a(t));
|
|
1409
1414
|
}
|
|
1410
1415
|
return Promise.resolve(t);
|
|
1411
1416
|
}
|
|
@@ -1418,8 +1423,8 @@ class PluginSystem {
|
|
|
1418
1423
|
assert(isPlainObject(t), "Plugin configuration is invalid.");
|
|
1419
1424
|
const r = t.name;
|
|
1420
1425
|
assert(r, "A name must be provided by the plugin."), this.registerPlugins[r] || (this.registerPlugins[r] = t, t.apply == null || t.apply.call(t, n), Object.keys(this.lifecycle).forEach((s) => {
|
|
1421
|
-
const
|
|
1422
|
-
|
|
1426
|
+
const a = t[s];
|
|
1427
|
+
a && this.lifecycle[s].on(a);
|
|
1423
1428
|
}));
|
|
1424
1429
|
}
|
|
1425
1430
|
removePlugin(t) {
|
|
@@ -1443,13 +1448,13 @@ function snapshotPlugin() {
|
|
|
1443
1448
|
return {
|
|
1444
1449
|
name: "snapshot-plugin",
|
|
1445
1450
|
async afterResolve(o) {
|
|
1446
|
-
const { remote: t, pkgNameOrAlias: n, expose: r, origin: s, remoteInfo:
|
|
1451
|
+
const { remote: t, pkgNameOrAlias: n, expose: r, origin: s, remoteInfo: a, id: l } = o;
|
|
1447
1452
|
if (!isRemoteInfoWithEntry(t) || !isPureRemoteEntry(t)) {
|
|
1448
|
-
const { remoteSnapshot:
|
|
1453
|
+
const { remoteSnapshot: i, globalSnapshot: c } = await s.snapshotHandler.loadRemoteSnapshotInfo({
|
|
1449
1454
|
moduleInfo: t,
|
|
1450
1455
|
id: l
|
|
1451
1456
|
});
|
|
1452
|
-
assignRemoteInfo(
|
|
1457
|
+
assignRemoteInfo(a, i);
|
|
1453
1458
|
const u = {
|
|
1454
1459
|
remote: t,
|
|
1455
1460
|
preloadConfig: {
|
|
@@ -1464,13 +1469,13 @@ function snapshotPlugin() {
|
|
|
1464
1469
|
}, p = await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({
|
|
1465
1470
|
origin: s,
|
|
1466
1471
|
preloadOptions: u,
|
|
1467
|
-
remoteInfo:
|
|
1472
|
+
remoteInfo: a,
|
|
1468
1473
|
remote: t,
|
|
1469
|
-
remoteSnapshot:
|
|
1474
|
+
remoteSnapshot: i,
|
|
1470
1475
|
globalSnapshot: c
|
|
1471
1476
|
});
|
|
1472
|
-
return p && preloadAssets(
|
|
1473
|
-
remoteSnapshot:
|
|
1477
|
+
return p && preloadAssets(a, s, p, !1), _extends$1({}, o, {
|
|
1478
|
+
remoteSnapshot: i
|
|
1474
1479
|
});
|
|
1475
1480
|
}
|
|
1476
1481
|
return o;
|
|
@@ -1490,8 +1495,8 @@ function splitId(o) {
|
|
|
1490
1495
|
version: t[2]
|
|
1491
1496
|
};
|
|
1492
1497
|
}
|
|
1493
|
-
function traverseModuleInfo(o, t, n, r, s = {},
|
|
1494
|
-
const l = getFMId(t), { value:
|
|
1498
|
+
function traverseModuleInfo(o, t, n, r, s = {}, a) {
|
|
1499
|
+
const l = getFMId(t), { value: i } = getInfoWithoutType(o, l), c = a || i;
|
|
1495
1500
|
if (c && !isManifestProvider(c) && (n(c, t, r), c.remotesInfo)) {
|
|
1496
1501
|
const u = Object.keys(c.remotesInfo);
|
|
1497
1502
|
for (const p of u) {
|
|
@@ -1508,7 +1513,7 @@ function traverseModuleInfo(o, t, n, r, s = {}, i) {
|
|
|
1508
1513
|
}
|
|
1509
1514
|
const isExisted = (o, t) => document.querySelector(`${o}[${o === "link" ? "href" : "src"}="${t}"]`);
|
|
1510
1515
|
function generatePreloadAssets(o, t, n, r, s) {
|
|
1511
|
-
const
|
|
1516
|
+
const a = [], l = [], i = [], c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), { options: p } = o, { preloadConfig: d } = t, { depsRemote: m } = d;
|
|
1512
1517
|
if (traverseModuleInfo(r, n, (_, b, v) => {
|
|
1513
1518
|
let I;
|
|
1514
1519
|
if (v)
|
|
@@ -1523,7 +1528,7 @@ function generatePreloadAssets(o, t, n, r, s) {
|
|
|
1523
1528
|
else
|
|
1524
1529
|
return;
|
|
1525
1530
|
const S = getResourceUrl(_, getRemoteEntryInfoFromSnapshot(_).url);
|
|
1526
|
-
S &&
|
|
1531
|
+
S && i.push({
|
|
1527
1532
|
name: b.name,
|
|
1528
1533
|
moduleInfo: {
|
|
1529
1534
|
name: b.name,
|
|
@@ -1556,7 +1561,7 @@ function generatePreloadAssets(o, t, n, r, s) {
|
|
|
1556
1561
|
preloadConfig: I,
|
|
1557
1562
|
remote: b,
|
|
1558
1563
|
origin: o
|
|
1559
|
-
}), !getPreloaded(M) && (I.resourceCategory === "all" ? (
|
|
1564
|
+
}), !getPreloaded(M) && (I.resourceCategory === "all" ? (a.push(...$(w.assets.css.async)), a.push(...$(w.assets.css.sync)), l.push(...$(w.assets.js.async)), l.push(...$(w.assets.js.sync))) : (I.resourceCategory = "sync") && (a.push(...$(w.assets.css.sync)), l.push(...$(w.assets.js.sync))), setPreloaded(M));
|
|
1560
1565
|
}
|
|
1561
1566
|
}
|
|
1562
1567
|
}, !0, {}, s), s.shared && s.shared.length > 0) {
|
|
@@ -1581,18 +1586,18 @@ function generatePreloadAssets(o, t, n, r, s) {
|
|
|
1581
1586
|
});
|
|
1582
1587
|
});
|
|
1583
1588
|
}
|
|
1584
|
-
const
|
|
1589
|
+
const E = l.filter((_) => !c.has(_) && !isExisted("script", _));
|
|
1585
1590
|
return {
|
|
1586
|
-
cssAssets:
|
|
1587
|
-
jsAssetsWithoutEntry:
|
|
1588
|
-
entryAssets:
|
|
1591
|
+
cssAssets: a.filter((_) => !u.has(_) && !isExisted("link", _)),
|
|
1592
|
+
jsAssetsWithoutEntry: E,
|
|
1593
|
+
entryAssets: i.filter((_) => !isExisted("script", _.url))
|
|
1589
1594
|
};
|
|
1590
1595
|
}
|
|
1591
1596
|
const generatePreloadAssetsPlugin = function() {
|
|
1592
1597
|
return {
|
|
1593
1598
|
name: "generate-preload-assets-plugin",
|
|
1594
1599
|
async generatePreloadAssets(o) {
|
|
1595
|
-
const { origin: t, preloadOptions: n, remoteInfo: r, remote: s, globalSnapshot:
|
|
1600
|
+
const { origin: t, preloadOptions: n, remoteInfo: r, remote: s, globalSnapshot: a, remoteSnapshot: l } = o;
|
|
1596
1601
|
return isBrowserEnv() ? isRemoteInfoWithEntry(s) && isPureRemoteEntry(s) ? {
|
|
1597
1602
|
cssAssets: [],
|
|
1598
1603
|
jsAssetsWithoutEntry: [],
|
|
@@ -1609,7 +1614,7 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1609
1614
|
}
|
|
1610
1615
|
}
|
|
1611
1616
|
]
|
|
1612
|
-
} : (assignRemoteInfo(r, l), generatePreloadAssets(t, n, r,
|
|
1617
|
+
} : (assignRemoteInfo(r, l), generatePreloadAssets(t, n, r, a, l)) : {
|
|
1613
1618
|
cssAssets: [],
|
|
1614
1619
|
jsAssetsWithoutEntry: [],
|
|
1615
1620
|
entryAssets: []
|
|
@@ -1646,37 +1651,37 @@ class SnapshotHandler {
|
|
|
1646
1651
|
options: s,
|
|
1647
1652
|
moduleInfo: t
|
|
1648
1653
|
});
|
|
1649
|
-
let
|
|
1654
|
+
let a = getGlobalSnapshotInfoByModuleInfo({
|
|
1650
1655
|
name: this.HostInstance.options.name,
|
|
1651
1656
|
version: this.HostInstance.options.version
|
|
1652
1657
|
});
|
|
1653
|
-
|
|
1658
|
+
a || (a = {
|
|
1654
1659
|
version: this.HostInstance.options.version || "",
|
|
1655
1660
|
remoteEntry: "",
|
|
1656
1661
|
remotesInfo: {}
|
|
1657
1662
|
}, addGlobalSnapshot({
|
|
1658
|
-
[this.HostInstance.options.name]:
|
|
1659
|
-
})),
|
|
1663
|
+
[this.HostInstance.options.name]: a
|
|
1664
|
+
})), 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, {
|
|
1660
1665
|
[t.name]: {
|
|
1661
1666
|
matchedVersion: "version" in t ? t.version : t.entry
|
|
1662
1667
|
}
|
|
1663
1668
|
}));
|
|
1664
|
-
const { hostGlobalSnapshot: l, remoteSnapshot:
|
|
1669
|
+
const { hostGlobalSnapshot: l, remoteSnapshot: i, globalSnapshot: c } = this.getGlobalRemoteInfo(t), { remoteSnapshot: u, globalSnapshot: p } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1665
1670
|
options: s,
|
|
1666
1671
|
moduleInfo: t,
|
|
1667
1672
|
hostGlobalSnapshot: l,
|
|
1668
|
-
remoteSnapshot:
|
|
1673
|
+
remoteSnapshot: i,
|
|
1669
1674
|
globalSnapshot: c
|
|
1670
1675
|
});
|
|
1671
1676
|
let d, m;
|
|
1672
1677
|
if (u)
|
|
1673
1678
|
if (isManifestProvider(u)) {
|
|
1674
|
-
const y = isBrowserEnv() ? u.remoteEntry : u.ssrRemoteEntry || u.remoteEntry || "",
|
|
1679
|
+
const y = isBrowserEnv() ? u.remoteEntry : u.ssrRemoteEntry || u.remoteEntry || "", E = await this.getManifestJson(y, t, {}), g = setGlobalSnapshotInfoByModuleInfo(_extends$1({}, t, {
|
|
1675
1680
|
// The global remote may be overridden
|
|
1676
1681
|
// Therefore, set the snapshot key to the global address of the actual request
|
|
1677
1682
|
entry: y
|
|
1678
|
-
}),
|
|
1679
|
-
d =
|
|
1683
|
+
}), E);
|
|
1684
|
+
d = E, m = g;
|
|
1680
1685
|
} else {
|
|
1681
1686
|
const { remoteSnapshot: y } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1682
1687
|
options: this.HostInstance.options,
|
|
@@ -1687,13 +1692,13 @@ class SnapshotHandler {
|
|
|
1687
1692
|
d = y, m = p;
|
|
1688
1693
|
}
|
|
1689
1694
|
else if (isRemoteInfoWithEntry(t)) {
|
|
1690
|
-
const y = await this.getManifestJson(t.entry, t, {}),
|
|
1695
|
+
const y = await this.getManifestJson(t.entry, t, {}), E = setGlobalSnapshotInfoByModuleInfo(t, y), { remoteSnapshot: g } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1691
1696
|
options: this.HostInstance.options,
|
|
1692
1697
|
moduleInfo: t,
|
|
1693
1698
|
remoteSnapshot: y,
|
|
1694
1699
|
from: "global"
|
|
1695
1700
|
});
|
|
1696
|
-
d =
|
|
1701
|
+
d = g, m = E;
|
|
1697
1702
|
} else
|
|
1698
1703
|
error(getShortErrorMsg(RUNTIME_007, runtimeDescMap, {
|
|
1699
1704
|
hostName: t.name,
|
|
@@ -1720,12 +1725,12 @@ class SnapshotHandler {
|
|
|
1720
1725
|
if (l)
|
|
1721
1726
|
return l;
|
|
1722
1727
|
try {
|
|
1723
|
-
let
|
|
1724
|
-
(!
|
|
1725
|
-
} catch (
|
|
1728
|
+
let i = await this.loaderHook.lifecycle.fetch.emit(t, {});
|
|
1729
|
+
(!i || !(i instanceof Response)) && (i = await fetch(t, {})), l = await i.json();
|
|
1730
|
+
} catch (i) {
|
|
1726
1731
|
l = await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
1727
1732
|
id: t,
|
|
1728
|
-
error:
|
|
1733
|
+
error: i,
|
|
1729
1734
|
from: "runtime",
|
|
1730
1735
|
lifecycle: "afterResolve",
|
|
1731
1736
|
origin: this.HostInstance
|
|
@@ -1733,23 +1738,23 @@ class SnapshotHandler {
|
|
|
1733
1738
|
manifestUrl: t,
|
|
1734
1739
|
moduleName: n.name,
|
|
1735
1740
|
hostName: this.HostInstance.options.name
|
|
1736
|
-
}, `${
|
|
1741
|
+
}, `${i}`)));
|
|
1737
1742
|
}
|
|
1738
1743
|
return assert(l.metaData && l.exposes && l.shared, `${t} is not a federation manifest`), this.manifestCache.set(t, l), l;
|
|
1739
|
-
},
|
|
1740
|
-
const l = await s(),
|
|
1744
|
+
}, a = async () => {
|
|
1745
|
+
const l = await s(), i = generateSnapshotFromManifest(l, {
|
|
1741
1746
|
version: t
|
|
1742
1747
|
}), { remoteSnapshot: c } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1743
1748
|
options: this.HostInstance.options,
|
|
1744
1749
|
moduleInfo: n,
|
|
1745
1750
|
manifestJson: l,
|
|
1746
|
-
remoteSnapshot:
|
|
1751
|
+
remoteSnapshot: i,
|
|
1747
1752
|
manifestUrl: t,
|
|
1748
1753
|
from: "manifest"
|
|
1749
1754
|
});
|
|
1750
1755
|
return c;
|
|
1751
1756
|
};
|
|
1752
|
-
return this.manifestLoading[t] || (this.manifestLoading[t] =
|
|
1757
|
+
return this.manifestLoading[t] || (this.manifestLoading[t] = a().then((l) => l)), this.manifestLoading[t];
|
|
1753
1758
|
}
|
|
1754
1759
|
constructor(t) {
|
|
1755
1760
|
this.loadingHostSnapshot = null, this.manifestCache = /* @__PURE__ */ new Map(), this.hooks = new PluginSystem({
|
|
@@ -1791,30 +1796,30 @@ class SharedHandler {
|
|
|
1791
1796
|
strategy: s.strategy
|
|
1792
1797
|
}));
|
|
1793
1798
|
}));
|
|
1794
|
-
const
|
|
1799
|
+
const a = await this.hooks.lifecycle.beforeLoadShare.emit({
|
|
1795
1800
|
pkgName: t,
|
|
1796
1801
|
shareInfo: s,
|
|
1797
1802
|
shared: r.options.shared,
|
|
1798
1803
|
origin: r
|
|
1799
|
-
}), { shareInfo: l } =
|
|
1804
|
+
}), { shareInfo: l } = a;
|
|
1800
1805
|
assert(l, `Cannot find ${t} Share in the ${r.options.name}. Please ensure that the ${t} Share parameters have been injected`);
|
|
1801
|
-
const
|
|
1806
|
+
const i = getRegisteredShare(this.shareScopeMap, t, l, this.hooks.lifecycle.resolveShare), c = (u) => {
|
|
1802
1807
|
u.useIn || (u.useIn = []), addUniqueItem(u.useIn, r.options.name);
|
|
1803
1808
|
};
|
|
1804
|
-
if (
|
|
1805
|
-
return c(
|
|
1806
|
-
if (
|
|
1807
|
-
const u = await
|
|
1808
|
-
return
|
|
1809
|
-
} else if (
|
|
1809
|
+
if (i && i.lib)
|
|
1810
|
+
return c(i), i.lib;
|
|
1811
|
+
if (i && i.loading && !i.loaded) {
|
|
1812
|
+
const u = await i.loading;
|
|
1813
|
+
return i.loaded = !0, i.lib || (i.lib = u), c(i), u;
|
|
1814
|
+
} else if (i) {
|
|
1810
1815
|
const p = (async () => {
|
|
1811
|
-
const d = await
|
|
1812
|
-
return c(
|
|
1816
|
+
const d = await i.get();
|
|
1817
|
+
return c(i), i.loaded = !0, i.lib = d, d;
|
|
1813
1818
|
})();
|
|
1814
1819
|
return this.setShared({
|
|
1815
1820
|
pkgName: t,
|
|
1816
1821
|
loaded: !1,
|
|
1817
|
-
shared:
|
|
1822
|
+
shared: i,
|
|
1818
1823
|
from: r.options.name,
|
|
1819
1824
|
lib: null,
|
|
1820
1825
|
loading: p
|
|
@@ -1845,53 +1850,53 @@ class SharedHandler {
|
|
|
1845
1850
|
*/
|
|
1846
1851
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
1847
1852
|
initializeSharing(t = DEFAULT_SCOPE, n) {
|
|
1848
|
-
const { host: r } = this, s = n == null ? void 0 : n.from,
|
|
1853
|
+
const { host: r } = this, s = n == null ? void 0 : n.from, a = n == null ? void 0 : n.strategy;
|
|
1849
1854
|
let l = n == null ? void 0 : n.initScope;
|
|
1850
|
-
const
|
|
1855
|
+
const i = [];
|
|
1851
1856
|
if (s !== "build") {
|
|
1852
|
-
const { initTokens:
|
|
1857
|
+
const { initTokens: E } = this;
|
|
1853
1858
|
l || (l = []);
|
|
1854
|
-
let
|
|
1855
|
-
if (
|
|
1859
|
+
let g = E[t];
|
|
1860
|
+
if (g || (g = E[t] = {
|
|
1856
1861
|
from: this.host.name
|
|
1857
|
-
}), l.indexOf(
|
|
1858
|
-
l.push(
|
|
1862
|
+
}), l.indexOf(g) >= 0) return i;
|
|
1863
|
+
l.push(g);
|
|
1859
1864
|
}
|
|
1860
1865
|
const c = this.shareScopeMap, u = r.options.name;
|
|
1861
1866
|
c[t] || (c[t] = {});
|
|
1862
|
-
const p = c[t], d = (
|
|
1867
|
+
const p = c[t], d = (E, g) => {
|
|
1863
1868
|
var _;
|
|
1864
|
-
const { version: b, eager: v } =
|
|
1865
|
-
p[
|
|
1866
|
-
const I = p[
|
|
1867
|
-
(!S || S.strategy !== "loaded-first" && !S.loaded && (!v != !R ? v : u > S.from)) && (I[b] =
|
|
1868
|
-
}, m = (
|
|
1869
|
-
const { module:
|
|
1870
|
-
id:
|
|
1869
|
+
const { version: b, eager: v } = g;
|
|
1870
|
+
p[E] = p[E] || {};
|
|
1871
|
+
const I = p[E], S = I[b], R = !!(S && (S.eager || (_ = S.shareConfig) != null && _.eager));
|
|
1872
|
+
(!S || S.strategy !== "loaded-first" && !S.loaded && (!v != !R ? v : u > S.from)) && (I[b] = g);
|
|
1873
|
+
}, m = (E) => E && E.init && E.init(c[t], l), y = async (E) => {
|
|
1874
|
+
const { module: g } = await r.remoteHandler.getRemoteModuleAndOptions({
|
|
1875
|
+
id: E
|
|
1871
1876
|
});
|
|
1872
|
-
if (
|
|
1877
|
+
if (g.getEntry) {
|
|
1873
1878
|
let _;
|
|
1874
1879
|
try {
|
|
1875
|
-
_ = await
|
|
1880
|
+
_ = await g.getEntry();
|
|
1876
1881
|
} catch (b) {
|
|
1877
1882
|
_ = await r.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
1878
|
-
id:
|
|
1883
|
+
id: E,
|
|
1879
1884
|
error: b,
|
|
1880
1885
|
from: "runtime",
|
|
1881
1886
|
lifecycle: "beforeLoadShare",
|
|
1882
1887
|
origin: r
|
|
1883
1888
|
});
|
|
1884
1889
|
}
|
|
1885
|
-
|
|
1890
|
+
g.inited || (await m(_), g.inited = !0);
|
|
1886
1891
|
}
|
|
1887
1892
|
};
|
|
1888
|
-
return Object.keys(r.options.shared).forEach((
|
|
1889
|
-
r.options.shared[
|
|
1890
|
-
_.scope.includes(t) && d(
|
|
1893
|
+
return Object.keys(r.options.shared).forEach((E) => {
|
|
1894
|
+
r.options.shared[E].forEach((_) => {
|
|
1895
|
+
_.scope.includes(t) && d(E, _);
|
|
1891
1896
|
});
|
|
1892
|
-
}), (r.options.shareStrategy === "version-first" ||
|
|
1893
|
-
|
|
1894
|
-
}),
|
|
1897
|
+
}), (r.options.shareStrategy === "version-first" || a === "version-first") && r.options.remotes.forEach((E) => {
|
|
1898
|
+
E.shareScope === t && i.push(y(E.name));
|
|
1899
|
+
}), i;
|
|
1895
1900
|
}
|
|
1896
1901
|
// The lib function will only be available if the shared set by eager or runtime init is set or the shared is successfully loaded.
|
|
1897
1902
|
// 1. If the loaded shared already exists globally, then it will be reused
|
|
@@ -1903,41 +1908,41 @@ class SharedHandler {
|
|
|
1903
1908
|
extraOptions: n,
|
|
1904
1909
|
shareInfos: r.options.shared
|
|
1905
1910
|
});
|
|
1906
|
-
s != null && s.scope && s.scope.forEach((
|
|
1907
|
-
this.initializeSharing(
|
|
1911
|
+
s != null && s.scope && s.scope.forEach((i) => {
|
|
1912
|
+
this.initializeSharing(i, {
|
|
1908
1913
|
strategy: s.strategy
|
|
1909
1914
|
});
|
|
1910
1915
|
});
|
|
1911
|
-
const
|
|
1912
|
-
|
|
1916
|
+
const a = getRegisteredShare(this.shareScopeMap, t, s, this.hooks.lifecycle.resolveShare), l = (i) => {
|
|
1917
|
+
i.useIn || (i.useIn = []), addUniqueItem(i.useIn, r.options.name);
|
|
1913
1918
|
};
|
|
1914
|
-
if (
|
|
1915
|
-
if (typeof
|
|
1916
|
-
return l(
|
|
1917
|
-
if (typeof
|
|
1918
|
-
const
|
|
1919
|
-
if (!(
|
|
1920
|
-
return l(
|
|
1919
|
+
if (a) {
|
|
1920
|
+
if (typeof a.lib == "function")
|
|
1921
|
+
return l(a), a.loaded || (a.loaded = !0, a.from === r.options.name && (s.loaded = !0)), a.lib;
|
|
1922
|
+
if (typeof a.get == "function") {
|
|
1923
|
+
const i = a.get();
|
|
1924
|
+
if (!(i instanceof Promise))
|
|
1925
|
+
return l(a), this.setShared({
|
|
1921
1926
|
pkgName: t,
|
|
1922
1927
|
loaded: !0,
|
|
1923
1928
|
from: r.options.name,
|
|
1924
|
-
lib:
|
|
1925
|
-
shared:
|
|
1926
|
-
}),
|
|
1929
|
+
lib: i,
|
|
1930
|
+
shared: a
|
|
1931
|
+
}), i;
|
|
1927
1932
|
}
|
|
1928
1933
|
}
|
|
1929
1934
|
if (s.lib)
|
|
1930
1935
|
return s.loaded || (s.loaded = !0), s.lib;
|
|
1931
1936
|
if (s.get) {
|
|
1932
|
-
const
|
|
1933
|
-
if (
|
|
1937
|
+
const i = s.get();
|
|
1938
|
+
if (i instanceof Promise) {
|
|
1934
1939
|
const c = (n == null ? void 0 : n.from) === "build" ? RUNTIME_005 : RUNTIME_006;
|
|
1935
1940
|
throw new Error(getShortErrorMsg(c, runtimeDescMap, {
|
|
1936
1941
|
hostName: r.options.name,
|
|
1937
1942
|
sharedPkgName: t
|
|
1938
1943
|
}));
|
|
1939
1944
|
}
|
|
1940
|
-
return s.lib =
|
|
1945
|
+
return s.lib = i, this.setShared({
|
|
1941
1946
|
pkgName: t,
|
|
1942
1947
|
loaded: !0,
|
|
1943
1948
|
from: r.options.name,
|
|
@@ -1960,7 +1965,7 @@ class SharedHandler {
|
|
|
1960
1965
|
hostShareScopeMap: r.hostShareScopeMap
|
|
1961
1966
|
});
|
|
1962
1967
|
}
|
|
1963
|
-
setShared({ pkgName: t, shared: n, from: r, lib: s, loading:
|
|
1968
|
+
setShared({ pkgName: t, shared: n, from: r, lib: s, loading: a, loaded: l, get: i }) {
|
|
1964
1969
|
const { version: c, scope: u = "default" } = n, p = _object_without_properties_loose(n, [
|
|
1965
1970
|
"version",
|
|
1966
1971
|
"scope"
|
|
@@ -1977,12 +1982,12 @@ class SharedHandler {
|
|
|
1977
1982
|
}, p, {
|
|
1978
1983
|
lib: s,
|
|
1979
1984
|
loaded: l,
|
|
1980
|
-
loading:
|
|
1981
|
-
}),
|
|
1985
|
+
loading: a
|
|
1986
|
+
}), i && (this.shareScopeMap[m][t][c].get = i);
|
|
1982
1987
|
return;
|
|
1983
1988
|
}
|
|
1984
1989
|
const y = this.shareScopeMap[m][t][c];
|
|
1985
|
-
|
|
1990
|
+
a && !y.loading && (y.loading = a), l && !y.loaded && (y.loaded = l), r && y.from !== r && (y.from = r);
|
|
1986
1991
|
});
|
|
1987
1992
|
}
|
|
1988
1993
|
_setGlobalShareScopeMap(t) {
|
|
@@ -2003,26 +2008,26 @@ class SharedHandler {
|
|
|
2003
2008
|
}
|
|
2004
2009
|
class RemoteHandler {
|
|
2005
2010
|
formatAndRegisterRemote(t, n) {
|
|
2006
|
-
return (n.remotes || []).reduce((s,
|
|
2011
|
+
return (n.remotes || []).reduce((s, a) => (this.registerRemote(a, s, {
|
|
2007
2012
|
force: !1
|
|
2008
2013
|
}), s), t.remotes);
|
|
2009
2014
|
}
|
|
2010
2015
|
setIdToRemoteMap(t, n) {
|
|
2011
|
-
const { remote: r, expose: s } = n, { name:
|
|
2016
|
+
const { remote: r, expose: s } = n, { name: a, alias: l } = r;
|
|
2012
2017
|
if (this.idToRemoteMap[t] = {
|
|
2013
2018
|
name: r.name,
|
|
2014
2019
|
expose: s
|
|
2015
|
-
}, l && t.startsWith(
|
|
2016
|
-
const
|
|
2017
|
-
this.idToRemoteMap[
|
|
2020
|
+
}, l && t.startsWith(a)) {
|
|
2021
|
+
const i = t.replace(a, l);
|
|
2022
|
+
this.idToRemoteMap[i] = {
|
|
2018
2023
|
name: r.name,
|
|
2019
2024
|
expose: s
|
|
2020
2025
|
};
|
|
2021
2026
|
return;
|
|
2022
2027
|
}
|
|
2023
2028
|
if (l && t.startsWith(l)) {
|
|
2024
|
-
const
|
|
2025
|
-
this.idToRemoteMap[
|
|
2029
|
+
const i = t.replace(l, a);
|
|
2030
|
+
this.idToRemoteMap[i] = {
|
|
2026
2031
|
name: r.name,
|
|
2027
2032
|
expose: s
|
|
2028
2033
|
};
|
|
@@ -2035,9 +2040,9 @@ class RemoteHandler {
|
|
|
2035
2040
|
try {
|
|
2036
2041
|
const { loadFactory: s = !0 } = n || {
|
|
2037
2042
|
loadFactory: !0
|
|
2038
|
-
}, { module:
|
|
2043
|
+
}, { module: a, moduleOptions: l, remoteMatchInfo: i } = await this.getRemoteModuleAndOptions({
|
|
2039
2044
|
id: t
|
|
2040
|
-
}), { pkgNameOrAlias: c, remote: u, expose: p, id: d, remoteSnapshot: m } =
|
|
2045
|
+
}), { pkgNameOrAlias: c, remote: u, expose: p, id: d, remoteSnapshot: m } = i, y = await a.get(d, p, n, m), E = await this.hooks.lifecycle.onLoad.emit({
|
|
2041
2046
|
id: d,
|
|
2042
2047
|
pkgNameOrAlias: c,
|
|
2043
2048
|
expose: p,
|
|
@@ -2045,17 +2050,17 @@ class RemoteHandler {
|
|
|
2045
2050
|
exposeModuleFactory: s ? void 0 : y,
|
|
2046
2051
|
remote: u,
|
|
2047
2052
|
options: l,
|
|
2048
|
-
moduleInstance:
|
|
2053
|
+
moduleInstance: a,
|
|
2049
2054
|
origin: r
|
|
2050
2055
|
});
|
|
2051
|
-
return this.setIdToRemoteMap(t,
|
|
2056
|
+
return this.setIdToRemoteMap(t, i), typeof E == "function" ? E : y;
|
|
2052
2057
|
} catch (s) {
|
|
2053
|
-
const { from:
|
|
2058
|
+
const { from: a = "runtime" } = n || {
|
|
2054
2059
|
from: "runtime"
|
|
2055
2060
|
}, l = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2056
2061
|
id: t,
|
|
2057
2062
|
error: s,
|
|
2058
|
-
from:
|
|
2063
|
+
from: a,
|
|
2059
2064
|
lifecycle: "onLoad",
|
|
2060
2065
|
origin: r
|
|
2061
2066
|
});
|
|
@@ -2074,14 +2079,14 @@ class RemoteHandler {
|
|
|
2074
2079
|
});
|
|
2075
2080
|
const r = formatPreloadArgs(n.options.remotes, t);
|
|
2076
2081
|
await Promise.all(r.map(async (s) => {
|
|
2077
|
-
const { remote:
|
|
2078
|
-
moduleInfo:
|
|
2082
|
+
const { remote: a } = s, l = getRemoteInfo(a), { globalSnapshot: i, remoteSnapshot: c } = await n.snapshotHandler.loadRemoteSnapshotInfo({
|
|
2083
|
+
moduleInfo: a
|
|
2079
2084
|
}), u = await this.hooks.lifecycle.generatePreloadAssets.emit({
|
|
2080
2085
|
origin: n,
|
|
2081
2086
|
preloadOptions: s,
|
|
2082
|
-
remote:
|
|
2087
|
+
remote: a,
|
|
2083
2088
|
remoteInfo: l,
|
|
2084
|
-
globalSnapshot:
|
|
2089
|
+
globalSnapshot: i,
|
|
2085
2090
|
remoteSnapshot: c
|
|
2086
2091
|
});
|
|
2087
2092
|
u && preloadAssets(l, n, u);
|
|
@@ -2104,30 +2109,30 @@ class RemoteHandler {
|
|
|
2104
2109
|
options: n.options,
|
|
2105
2110
|
origin: n
|
|
2106
2111
|
});
|
|
2107
|
-
} catch (
|
|
2112
|
+
} catch (E) {
|
|
2108
2113
|
if (s = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2109
2114
|
id: r,
|
|
2110
2115
|
options: n.options,
|
|
2111
2116
|
origin: n,
|
|
2112
2117
|
from: "runtime",
|
|
2113
|
-
error:
|
|
2118
|
+
error: E,
|
|
2114
2119
|
lifecycle: "beforeRequest"
|
|
2115
2120
|
}), !s)
|
|
2116
|
-
throw
|
|
2121
|
+
throw E;
|
|
2117
2122
|
}
|
|
2118
|
-
const { id:
|
|
2123
|
+
const { id: a } = s, l = matchRemoteWithNameAndExpose(n.options.remotes, a);
|
|
2119
2124
|
assert(l, getShortErrorMsg(RUNTIME_004, runtimeDescMap, {
|
|
2120
2125
|
hostName: n.options.name,
|
|
2121
|
-
requestId:
|
|
2126
|
+
requestId: a
|
|
2122
2127
|
}));
|
|
2123
|
-
const { remote:
|
|
2124
|
-
id:
|
|
2128
|
+
const { remote: i } = l, c = getRemoteInfo(i), u = await n.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({
|
|
2129
|
+
id: a
|
|
2125
2130
|
}, l, {
|
|
2126
2131
|
options: n.options,
|
|
2127
2132
|
origin: n,
|
|
2128
2133
|
remoteInfo: c
|
|
2129
2134
|
})), { remote: p, expose: d } = u;
|
|
2130
|
-
assert(p && d, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${
|
|
2135
|
+
assert(p && d, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${a}.`);
|
|
2131
2136
|
let m = n.moduleCache.get(p.name);
|
|
2132
2137
|
const y = {
|
|
2133
2138
|
host: n,
|
|
@@ -2140,13 +2145,13 @@ class RemoteHandler {
|
|
|
2140
2145
|
};
|
|
2141
2146
|
}
|
|
2142
2147
|
registerRemote(t, n, r) {
|
|
2143
|
-
const { host: s } = this,
|
|
2148
|
+
const { host: s } = this, a = () => {
|
|
2144
2149
|
if (t.alias) {
|
|
2145
|
-
const
|
|
2150
|
+
const i = n.find((c) => {
|
|
2146
2151
|
var u;
|
|
2147
2152
|
return t.alias && (c.name.startsWith(t.alias) || ((u = c.alias) == null ? void 0 : u.startsWith(t.alias)));
|
|
2148
2153
|
});
|
|
2149
|
-
assert(!
|
|
2154
|
+
assert(!i, `The alias ${t.alias} of remote ${t.name} is not allowed to be the prefix of ${i && i.name} name or alias`);
|
|
2150
2155
|
}
|
|
2151
2156
|
"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);
|
|
2152
2157
|
};
|
|
@@ -2154,53 +2159,53 @@ class RemoteHandler {
|
|
|
2154
2159
|
remote: t,
|
|
2155
2160
|
origin: s
|
|
2156
2161
|
});
|
|
2157
|
-
const l = n.find((
|
|
2162
|
+
const l = n.find((i) => i.name === t.name);
|
|
2158
2163
|
if (!l)
|
|
2159
|
-
|
|
2164
|
+
a(), n.push(t), this.hooks.lifecycle.registerRemote.emit({
|
|
2160
2165
|
remote: t,
|
|
2161
2166
|
origin: s
|
|
2162
2167
|
});
|
|
2163
2168
|
else {
|
|
2164
|
-
const
|
|
2169
|
+
const i = [
|
|
2165
2170
|
`The remote "${t.name}" is already registered.`,
|
|
2166
2171
|
"Please note that overriding it may cause unexpected errors."
|
|
2167
2172
|
];
|
|
2168
|
-
r != null && r.force && (this.removeRemote(l),
|
|
2173
|
+
r != null && r.force && (this.removeRemote(l), a(), n.push(t), this.hooks.lifecycle.registerRemote.emit({
|
|
2169
2174
|
remote: t,
|
|
2170
2175
|
origin: s
|
|
2171
|
-
}), warn$1(
|
|
2176
|
+
}), warn$1(i.join(" ")));
|
|
2172
2177
|
}
|
|
2173
2178
|
}
|
|
2174
2179
|
removeRemote(t) {
|
|
2175
2180
|
try {
|
|
2176
|
-
const { host: r } = this, { name: s } = t,
|
|
2177
|
-
|
|
2181
|
+
const { host: r } = this, { name: s } = t, a = r.options.remotes.findIndex((i) => i.name === s);
|
|
2182
|
+
a !== -1 && r.options.remotes.splice(a, 1);
|
|
2178
2183
|
const l = r.moduleCache.get(t.name);
|
|
2179
2184
|
if (l) {
|
|
2180
|
-
const
|
|
2185
|
+
const i = l.remoteInfo, c = i.entryGlobalName;
|
|
2181
2186
|
if (CurrentGlobal[c]) {
|
|
2182
2187
|
var n;
|
|
2183
2188
|
(n = Object.getOwnPropertyDescriptor(CurrentGlobal, c)) != null && n.configurable ? delete CurrentGlobal[c] : CurrentGlobal[c] = void 0;
|
|
2184
2189
|
}
|
|
2185
2190
|
const u = getRemoteEntryUniqueKey(l.remoteInfo);
|
|
2186
|
-
globalLoading[u] && delete globalLoading[u], r.snapshotHandler.manifestCache.delete(
|
|
2187
|
-
let p =
|
|
2188
|
-
const d = CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex((y) =>
|
|
2191
|
+
globalLoading[u] && delete globalLoading[u], r.snapshotHandler.manifestCache.delete(i.entry);
|
|
2192
|
+
let p = i.buildVersion ? composeKeyWithSeparator(i.name, i.buildVersion) : i.name;
|
|
2193
|
+
const d = CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex((y) => i.buildVersion ? y.options.id === p : y.name === p);
|
|
2189
2194
|
if (d !== -1) {
|
|
2190
2195
|
const y = CurrentGlobal.__FEDERATION__.__INSTANCES__[d];
|
|
2191
2196
|
p = y.options.id || p;
|
|
2192
|
-
const
|
|
2193
|
-
let
|
|
2197
|
+
const E = getGlobalShareScope();
|
|
2198
|
+
let g = !0;
|
|
2194
2199
|
const _ = [];
|
|
2195
|
-
Object.keys(
|
|
2196
|
-
const v =
|
|
2200
|
+
Object.keys(E).forEach((b) => {
|
|
2201
|
+
const v = E[b];
|
|
2197
2202
|
v && Object.keys(v).forEach((I) => {
|
|
2198
2203
|
const S = v[I];
|
|
2199
2204
|
S && Object.keys(S).forEach((R) => {
|
|
2200
2205
|
const A = S[R];
|
|
2201
2206
|
A && Object.keys(A).forEach((T) => {
|
|
2202
2207
|
const $ = A[T];
|
|
2203
|
-
$ && typeof $ == "object" && $.from ===
|
|
2208
|
+
$ && typeof $ == "object" && $.from === i.name && ($.loaded || $.loading ? ($.useIn = $.useIn.filter((O) => O !== i.name), $.useIn.length ? g = !1 : _.push([
|
|
2204
2209
|
b,
|
|
2205
2210
|
I,
|
|
2206
2211
|
R,
|
|
@@ -2214,9 +2219,9 @@ class RemoteHandler {
|
|
|
2214
2219
|
});
|
|
2215
2220
|
});
|
|
2216
2221
|
});
|
|
2217
|
-
}),
|
|
2222
|
+
}), g && (y.shareScopeMap = {}, delete E[p]), _.forEach(([b, v, I, S]) => {
|
|
2218
2223
|
var R, A, T;
|
|
2219
|
-
(T =
|
|
2224
|
+
(T = E[b]) == null || (A = T[v]) == null || (R = A[I]) == null || delete R[S];
|
|
2220
2225
|
}), CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(d, 1);
|
|
2221
2226
|
}
|
|
2222
2227
|
const { hostGlobalSnapshot: m } = getGlobalRemoteInfo(t, r);
|
|
@@ -2270,11 +2275,11 @@ class ModuleFederation {
|
|
|
2270
2275
|
const s = getRemoteInfo({
|
|
2271
2276
|
name: t,
|
|
2272
2277
|
entry: n
|
|
2273
|
-
}),
|
|
2278
|
+
}), a = new Module({
|
|
2274
2279
|
host: this,
|
|
2275
2280
|
remoteInfo: s
|
|
2276
2281
|
});
|
|
2277
|
-
return
|
|
2282
|
+
return a.remoteEntryExports = r, this.moduleCache.set(t, a), a;
|
|
2278
2283
|
}
|
|
2279
2284
|
// eslint-disable-next-line max-lines-per-function
|
|
2280
2285
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
@@ -2289,13 +2294,13 @@ class ModuleFederation {
|
|
|
2289
2294
|
this.sharedHandler.initShareScopeMap(t, n, r);
|
|
2290
2295
|
}
|
|
2291
2296
|
formatOptions(t, n) {
|
|
2292
|
-
const { shared: r } = formatShareConfigs(t, n), { userOptions: s, options:
|
|
2297
|
+
const { shared: r } = formatShareConfigs(t, n), { userOptions: s, options: a } = this.hooks.lifecycle.beforeInit.emit({
|
|
2293
2298
|
origin: this,
|
|
2294
2299
|
userOptions: n,
|
|
2295
2300
|
options: t,
|
|
2296
2301
|
shareInfo: r
|
|
2297
|
-
}), l = this.remoteHandler.formatAndRegisterRemote(
|
|
2298
|
-
...
|
|
2302
|
+
}), l = this.remoteHandler.formatAndRegisterRemote(a, s), { shared: i } = this.sharedHandler.registerShared(a, s), c = [
|
|
2303
|
+
...a.plugins
|
|
2299
2304
|
];
|
|
2300
2305
|
s.plugins && s.plugins.forEach((p) => {
|
|
2301
2306
|
c.includes(p) || c.push(p);
|
|
@@ -2303,7 +2308,7 @@ class ModuleFederation {
|
|
|
2303
2308
|
const u = _extends$1({}, t, n, {
|
|
2304
2309
|
plugins: c,
|
|
2305
2310
|
remotes: l,
|
|
2306
|
-
shared:
|
|
2311
|
+
shared: i
|
|
2307
2312
|
});
|
|
2308
2313
|
return this.hooks.lifecycle.init.emit({
|
|
2309
2314
|
origin: this,
|
|
@@ -2312,7 +2317,7 @@ class ModuleFederation {
|
|
|
2312
2317
|
}
|
|
2313
2318
|
registerPlugins(t) {
|
|
2314
2319
|
const n = registerPlugins(t, this);
|
|
2315
|
-
this.options.plugins = this.options.plugins.reduce((r, s) => (s && r && !r.find((
|
|
2320
|
+
this.options.plugins = this.options.plugins.reduce((r, s) => (s && r && !r.find((a) => a.name === s.name) && r.push(s), r), n || []);
|
|
2316
2321
|
}
|
|
2317
2322
|
registerRemotes(t, n) {
|
|
2318
2323
|
return this.remoteHandler.registerRemotes(t, n);
|
|
@@ -2330,7 +2335,7 @@ class ModuleFederation {
|
|
|
2330
2335
|
beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
|
|
2331
2336
|
// maybe will change, temporarily for internal use only
|
|
2332
2337
|
initContainer: new AsyncWaterfallHook("initContainer")
|
|
2333
|
-
}), this.version = "0.
|
|
2338
|
+
}), this.version = "0.19.0", this.moduleCache = /* @__PURE__ */ new Map(), this.loaderHook = new PluginSystem({
|
|
2334
2339
|
// FIXME: may not be suitable , not open to the public yet
|
|
2335
2340
|
getModuleInfo: new SyncHook(),
|
|
2336
2341
|
createScript: new SyncHook(),
|
|
@@ -2369,23 +2374,23 @@ setGlobalFederationConstructor(ModuleFederation);
|
|
|
2369
2374
|
function createBridgeComponent(o) {
|
|
2370
2375
|
const t = /* @__PURE__ */ new Map(), n = getInstance();
|
|
2371
2376
|
return () => ({
|
|
2372
|
-
__APP_VERSION__: "0.
|
|
2377
|
+
__APP_VERSION__: "0.19.0",
|
|
2373
2378
|
async render(r) {
|
|
2374
|
-
var
|
|
2379
|
+
var E, g, _;
|
|
2375
2380
|
LoggerInstance.debug("createBridgeComponent render Info", r);
|
|
2376
2381
|
const {
|
|
2377
2382
|
moduleName: s,
|
|
2378
|
-
dom:
|
|
2383
|
+
dom: a,
|
|
2379
2384
|
basename: l,
|
|
2380
|
-
memoryRoute:
|
|
2385
|
+
memoryRoute: i,
|
|
2381
2386
|
hashRoute: c,
|
|
2382
2387
|
...u
|
|
2383
2388
|
} = r, p = Vue.createApp(o.rootComponent, u);
|
|
2384
|
-
t.set(
|
|
2385
|
-
const d = await ((_ = (
|
|
2389
|
+
t.set(a, p);
|
|
2390
|
+
const d = await ((_ = (g = (E = n == null ? void 0 : n.bridgeHook) == null ? void 0 : E.lifecycle) == null ? void 0 : g.beforeBridgeRender) == null ? void 0 : _.emit(r)), m = d && typeof d == "object" && (d != null && d.extraProps) ? d == null ? void 0 : d.extraProps : {}, y = o.appOptions({
|
|
2386
2391
|
app: p,
|
|
2387
2392
|
basename: l,
|
|
2388
|
-
memoryRoute:
|
|
2393
|
+
memoryRoute: i,
|
|
2389
2394
|
hashRoute: c,
|
|
2390
2395
|
...u,
|
|
2391
2396
|
...m
|
|
@@ -2404,9 +2409,9 @@ function createBridgeComponent(o) {
|
|
|
2404
2409
|
LoggerInstance.debug("createBridgeComponent render router info>>>", {
|
|
2405
2410
|
moduleName: s,
|
|
2406
2411
|
router: I
|
|
2407
|
-
}),
|
|
2412
|
+
}), i && await I.push(i.entryPath), p.use(I);
|
|
2408
2413
|
}
|
|
2409
|
-
p.mount(
|
|
2414
|
+
p.mount(a);
|
|
2410
2415
|
},
|
|
2411
2416
|
destroy(r) {
|
|
2412
2417
|
LoggerInstance.debug("createBridgeComponent destroy Info", r);
|
|
@@ -2431,8 +2436,8 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2431
2436
|
},
|
|
2432
2437
|
inheritAttrs: !1,
|
|
2433
2438
|
setup(o) {
|
|
2434
|
-
const t = ref(null), n = ref(null), r = ref(""), s = useRoute(),
|
|
2435
|
-
var m, y,
|
|
2439
|
+
const t = ref(null), n = ref(null), r = ref(""), s = useRoute(), a = getInstance(), l = useAttrs(), i = async () => {
|
|
2440
|
+
var m, y, E, g;
|
|
2436
2441
|
const u = (m = o.providerInfo) == null ? void 0 : m.call(o);
|
|
2437
2442
|
n.value = u;
|
|
2438
2443
|
let p = {
|
|
@@ -2444,19 +2449,19 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2444
2449
|
hashRoute: o.hashRoute
|
|
2445
2450
|
};
|
|
2446
2451
|
LoggerInstance.debug("createRemoteAppComponent LazyComponent render >>>", p);
|
|
2447
|
-
const d = await ((
|
|
2452
|
+
const d = 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(p)) || {};
|
|
2448
2453
|
p = {
|
|
2449
2454
|
...p,
|
|
2450
2455
|
...d.extraProps
|
|
2451
2456
|
}, u.render(p);
|
|
2452
2457
|
}, c = watch(() => s == null ? void 0 : s.path, (u) => {
|
|
2453
|
-
u !== s.path &&
|
|
2458
|
+
u !== s.path && i(), r.value !== "" && r.value !== u && (LoggerInstance.debug("createRemoteAppComponent dispatchPopstateEnv >>>", {
|
|
2454
2459
|
...o,
|
|
2455
2460
|
pathname: s.path
|
|
2456
2461
|
}), e()), r.value = u;
|
|
2457
2462
|
});
|
|
2458
2463
|
return onMounted(() => {
|
|
2459
|
-
|
|
2464
|
+
i();
|
|
2460
2465
|
}), onBeforeUnmount(() => {
|
|
2461
2466
|
var u;
|
|
2462
2467
|
LoggerInstance.debug("createRemoteAppComponent LazyComponent destroy >>>", {
|
|
@@ -2471,7 +2476,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2471
2476
|
});
|
|
2472
2477
|
function createRemoteAppComponent(o) {
|
|
2473
2478
|
return defineAsyncComponent({
|
|
2474
|
-
__APP_VERSION__: "0.
|
|
2479
|
+
__APP_VERSION__: "0.19.0",
|
|
2475
2480
|
...o.asyncComponentOptions,
|
|
2476
2481
|
//@ts-ignore
|
|
2477
2482
|
loader: async () => {
|
|
@@ -2488,16 +2493,16 @@ function createRemoteAppComponent(o) {
|
|
|
2488
2493
|
info: o
|
|
2489
2494
|
}
|
|
2490
2495
|
);
|
|
2491
|
-
const
|
|
2496
|
+
const a = await o.loader(), l = a && a[Symbol.for("mf_module_id")], i = a[s];
|
|
2492
2497
|
if (LoggerInstance.debug(
|
|
2493
2498
|
"createRemoteAppComponent LazyComponent loadRemote info >>>",
|
|
2494
|
-
{ moduleName: l, module:
|
|
2495
|
-
), s in
|
|
2499
|
+
{ moduleName: l, module: a, exportName: s, basename: n, route: t }
|
|
2500
|
+
), s in a && typeof i == "function")
|
|
2496
2501
|
return {
|
|
2497
2502
|
render() {
|
|
2498
2503
|
return h(RemoteApp, {
|
|
2499
2504
|
moduleName: l,
|
|
2500
|
-
providerInfo:
|
|
2505
|
+
providerInfo: i,
|
|
2501
2506
|
basename: n,
|
|
2502
2507
|
rootAttrs: o.rootAttrs
|
|
2503
2508
|
});
|