@module-federation/bridge-vue3 0.18.3 → 0.18.4
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 +9 -0
- package/dist/index.cjs +4 -4
- package/dist/index.js +384 -376
- package/package.json +4 -4
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.18.
|
|
532
|
+
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = o, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.18.4");
|
|
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,26 @@ 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
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1245
|
+
if (n instanceof Error && n.message.includes(RUNTIME_008))
|
|
1246
|
+
t = await this.host.loaderHook.lifecycle.loadEntryError.emit({
|
|
1247
|
+
getRemoteEntry,
|
|
1248
|
+
origin: this.host,
|
|
1249
|
+
remoteInfo: this.remoteInfo,
|
|
1250
|
+
remoteEntryExports: this.remoteEntryExports,
|
|
1251
|
+
globalLoading,
|
|
1252
|
+
uniqueKey: r
|
|
1253
|
+
});
|
|
1254
|
+
else
|
|
1255
|
+
throw n;
|
|
1248
1256
|
}
|
|
1249
1257
|
return assert(t, `remoteEntryExports is undefined
|
|
1250
1258
|
${safeToString(this.remoteInfo)}`), this.remoteEntryExports = t, this.remoteEntryExports;
|
|
1251
1259
|
}
|
|
1252
1260
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1253
1261
|
async get(t, n, r, s) {
|
|
1254
|
-
const { loadFactory:
|
|
1262
|
+
const { loadFactory: a = !0 } = r || {
|
|
1255
1263
|
loadFactory: !0
|
|
1256
1264
|
}, l = await this.getEntry();
|
|
1257
1265
|
if (!this.inited) {
|
|
@@ -1261,11 +1269,11 @@ let Module = class {
|
|
|
1261
1269
|
m.length || m.push("default"), m.forEach((b) => {
|
|
1262
1270
|
d[b] || (d[b] = {});
|
|
1263
1271
|
});
|
|
1264
|
-
const y = d[m[0]],
|
|
1272
|
+
const y = d[m[0]], E = [], g = {
|
|
1265
1273
|
version: this.remoteInfo.version || "",
|
|
1266
1274
|
shareScopeKeys: Array.isArray(this.remoteInfo.shareScope) ? m : this.remoteInfo.shareScope || "default"
|
|
1267
1275
|
};
|
|
1268
|
-
Object.defineProperty(
|
|
1276
|
+
Object.defineProperty(g, "shareScopeMap", {
|
|
1269
1277
|
value: d,
|
|
1270
1278
|
// remoteEntryInitOptions will be traversed and assigned during container init, ,so this attribute is not allowed to be traversed
|
|
1271
1279
|
enumerable: !1
|
|
@@ -1273,8 +1281,8 @@ let Module = class {
|
|
|
1273
1281
|
const _ = await this.host.hooks.lifecycle.beforeInitContainer.emit({
|
|
1274
1282
|
shareScope: y,
|
|
1275
1283
|
// @ts-ignore shareScopeMap will be set by Object.defineProperty
|
|
1276
|
-
remoteEntryInitOptions:
|
|
1277
|
-
initScope:
|
|
1284
|
+
remoteEntryInitOptions: g,
|
|
1285
|
+
initScope: E,
|
|
1278
1286
|
remoteInfo: this.remoteInfo,
|
|
1279
1287
|
origin: this.host
|
|
1280
1288
|
});
|
|
@@ -1290,19 +1298,19 @@ let Module = class {
|
|
|
1290
1298
|
}));
|
|
1291
1299
|
}
|
|
1292
1300
|
this.lib = l, this.inited = !0;
|
|
1293
|
-
let
|
|
1294
|
-
|
|
1301
|
+
let i;
|
|
1302
|
+
i = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
|
|
1295
1303
|
remoteEntryExports: l,
|
|
1296
1304
|
expose: n,
|
|
1297
1305
|
moduleInfo: this.remoteInfo
|
|
1298
|
-
}),
|
|
1299
|
-
const c = processModuleAlias(this.remoteInfo.name, n), u = this.wraperFactory(
|
|
1300
|
-
return
|
|
1306
|
+
}), i || (i = await l.get(n)), assert(i, `${getFMId(this.remoteInfo)} remote don't export ${n}.`);
|
|
1307
|
+
const c = processModuleAlias(this.remoteInfo.name, n), u = this.wraperFactory(i, c);
|
|
1308
|
+
return a ? await u() : u;
|
|
1301
1309
|
}
|
|
1302
1310
|
wraperFactory(t, n) {
|
|
1303
|
-
function r(s,
|
|
1311
|
+
function r(s, a) {
|
|
1304
1312
|
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:
|
|
1313
|
+
value: a,
|
|
1306
1314
|
enumerable: !1
|
|
1307
1315
|
});
|
|
1308
1316
|
}
|
|
@@ -1350,8 +1358,8 @@ class AsyncHook extends SyncHook {
|
|
|
1350
1358
|
const r = Array.from(this.listeners);
|
|
1351
1359
|
if (r.length > 0) {
|
|
1352
1360
|
let s = 0;
|
|
1353
|
-
const
|
|
1354
|
-
n =
|
|
1361
|
+
const a = (l) => l === !1 ? !1 : s < r.length ? Promise.resolve(r[s++].apply(null, t)).then(a) : l;
|
|
1362
|
+
n = a();
|
|
1355
1363
|
}
|
|
1356
1364
|
return Promise.resolve(n);
|
|
1357
1365
|
}
|
|
@@ -1393,19 +1401,19 @@ class AsyncWaterfallHook extends SyncHook {
|
|
|
1393
1401
|
const n = Array.from(this.listeners);
|
|
1394
1402
|
if (n.length > 0) {
|
|
1395
1403
|
let r = 0;
|
|
1396
|
-
const s = (l) => (warn(l), this.onerror(l), t),
|
|
1404
|
+
const s = (l) => (warn(l), this.onerror(l), t), a = (l) => {
|
|
1397
1405
|
if (checkReturnData(t, l)) {
|
|
1398
1406
|
if (t = l, r < n.length)
|
|
1399
1407
|
try {
|
|
1400
|
-
return Promise.resolve(n[r++](t)).then(
|
|
1401
|
-
} catch (
|
|
1402
|
-
return s(
|
|
1408
|
+
return Promise.resolve(n[r++](t)).then(a, s);
|
|
1409
|
+
} catch (i) {
|
|
1410
|
+
return s(i);
|
|
1403
1411
|
}
|
|
1404
1412
|
} else
|
|
1405
1413
|
this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
|
|
1406
1414
|
return t;
|
|
1407
1415
|
};
|
|
1408
|
-
return Promise.resolve(
|
|
1416
|
+
return Promise.resolve(a(t));
|
|
1409
1417
|
}
|
|
1410
1418
|
return Promise.resolve(t);
|
|
1411
1419
|
}
|
|
@@ -1418,8 +1426,8 @@ class PluginSystem {
|
|
|
1418
1426
|
assert(isPlainObject(t), "Plugin configuration is invalid.");
|
|
1419
1427
|
const r = t.name;
|
|
1420
1428
|
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
|
-
|
|
1429
|
+
const a = t[s];
|
|
1430
|
+
a && this.lifecycle[s].on(a);
|
|
1423
1431
|
}));
|
|
1424
1432
|
}
|
|
1425
1433
|
removePlugin(t) {
|
|
@@ -1443,13 +1451,13 @@ function snapshotPlugin() {
|
|
|
1443
1451
|
return {
|
|
1444
1452
|
name: "snapshot-plugin",
|
|
1445
1453
|
async afterResolve(o) {
|
|
1446
|
-
const { remote: t, pkgNameOrAlias: n, expose: r, origin: s, remoteInfo:
|
|
1454
|
+
const { remote: t, pkgNameOrAlias: n, expose: r, origin: s, remoteInfo: a, id: l } = o;
|
|
1447
1455
|
if (!isRemoteInfoWithEntry(t) || !isPureRemoteEntry(t)) {
|
|
1448
|
-
const { remoteSnapshot:
|
|
1456
|
+
const { remoteSnapshot: i, globalSnapshot: c } = await s.snapshotHandler.loadRemoteSnapshotInfo({
|
|
1449
1457
|
moduleInfo: t,
|
|
1450
1458
|
id: l
|
|
1451
1459
|
});
|
|
1452
|
-
assignRemoteInfo(
|
|
1460
|
+
assignRemoteInfo(a, i);
|
|
1453
1461
|
const u = {
|
|
1454
1462
|
remote: t,
|
|
1455
1463
|
preloadConfig: {
|
|
@@ -1464,13 +1472,13 @@ function snapshotPlugin() {
|
|
|
1464
1472
|
}, p = await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({
|
|
1465
1473
|
origin: s,
|
|
1466
1474
|
preloadOptions: u,
|
|
1467
|
-
remoteInfo:
|
|
1475
|
+
remoteInfo: a,
|
|
1468
1476
|
remote: t,
|
|
1469
|
-
remoteSnapshot:
|
|
1477
|
+
remoteSnapshot: i,
|
|
1470
1478
|
globalSnapshot: c
|
|
1471
1479
|
});
|
|
1472
|
-
return p && preloadAssets(
|
|
1473
|
-
remoteSnapshot:
|
|
1480
|
+
return p && preloadAssets(a, s, p, !1), _extends$1({}, o, {
|
|
1481
|
+
remoteSnapshot: i
|
|
1474
1482
|
});
|
|
1475
1483
|
}
|
|
1476
1484
|
return o;
|
|
@@ -1490,8 +1498,8 @@ function splitId(o) {
|
|
|
1490
1498
|
version: t[2]
|
|
1491
1499
|
};
|
|
1492
1500
|
}
|
|
1493
|
-
function traverseModuleInfo(o, t, n, r, s = {},
|
|
1494
|
-
const l = getFMId(t), { value:
|
|
1501
|
+
function traverseModuleInfo(o, t, n, r, s = {}, a) {
|
|
1502
|
+
const l = getFMId(t), { value: i } = getInfoWithoutType(o, l), c = a || i;
|
|
1495
1503
|
if (c && !isManifestProvider(c) && (n(c, t, r), c.remotesInfo)) {
|
|
1496
1504
|
const u = Object.keys(c.remotesInfo);
|
|
1497
1505
|
for (const p of u) {
|
|
@@ -1508,7 +1516,7 @@ function traverseModuleInfo(o, t, n, r, s = {}, i) {
|
|
|
1508
1516
|
}
|
|
1509
1517
|
const isExisted = (o, t) => document.querySelector(`${o}[${o === "link" ? "href" : "src"}="${t}"]`);
|
|
1510
1518
|
function generatePreloadAssets(o, t, n, r, s) {
|
|
1511
|
-
const
|
|
1519
|
+
const a = [], l = [], i = [], c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), { options: p } = o, { preloadConfig: d } = t, { depsRemote: m } = d;
|
|
1512
1520
|
if (traverseModuleInfo(r, n, (_, b, v) => {
|
|
1513
1521
|
let I;
|
|
1514
1522
|
if (v)
|
|
@@ -1523,7 +1531,7 @@ function generatePreloadAssets(o, t, n, r, s) {
|
|
|
1523
1531
|
else
|
|
1524
1532
|
return;
|
|
1525
1533
|
const S = getResourceUrl(_, getRemoteEntryInfoFromSnapshot(_).url);
|
|
1526
|
-
S &&
|
|
1534
|
+
S && i.push({
|
|
1527
1535
|
name: b.name,
|
|
1528
1536
|
moduleInfo: {
|
|
1529
1537
|
name: b.name,
|
|
@@ -1556,7 +1564,7 @@ function generatePreloadAssets(o, t, n, r, s) {
|
|
|
1556
1564
|
preloadConfig: I,
|
|
1557
1565
|
remote: b,
|
|
1558
1566
|
origin: o
|
|
1559
|
-
}), !getPreloaded(M) && (I.resourceCategory === "all" ? (
|
|
1567
|
+
}), !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
1568
|
}
|
|
1561
1569
|
}
|
|
1562
1570
|
}, !0, {}, s), s.shared && s.shared.length > 0) {
|
|
@@ -1581,18 +1589,18 @@ function generatePreloadAssets(o, t, n, r, s) {
|
|
|
1581
1589
|
});
|
|
1582
1590
|
});
|
|
1583
1591
|
}
|
|
1584
|
-
const
|
|
1592
|
+
const E = l.filter((_) => !c.has(_) && !isExisted("script", _));
|
|
1585
1593
|
return {
|
|
1586
|
-
cssAssets:
|
|
1587
|
-
jsAssetsWithoutEntry:
|
|
1588
|
-
entryAssets:
|
|
1594
|
+
cssAssets: a.filter((_) => !u.has(_) && !isExisted("link", _)),
|
|
1595
|
+
jsAssetsWithoutEntry: E,
|
|
1596
|
+
entryAssets: i.filter((_) => !isExisted("script", _.url))
|
|
1589
1597
|
};
|
|
1590
1598
|
}
|
|
1591
1599
|
const generatePreloadAssetsPlugin = function() {
|
|
1592
1600
|
return {
|
|
1593
1601
|
name: "generate-preload-assets-plugin",
|
|
1594
1602
|
async generatePreloadAssets(o) {
|
|
1595
|
-
const { origin: t, preloadOptions: n, remoteInfo: r, remote: s, globalSnapshot:
|
|
1603
|
+
const { origin: t, preloadOptions: n, remoteInfo: r, remote: s, globalSnapshot: a, remoteSnapshot: l } = o;
|
|
1596
1604
|
return isBrowserEnv() ? isRemoteInfoWithEntry(s) && isPureRemoteEntry(s) ? {
|
|
1597
1605
|
cssAssets: [],
|
|
1598
1606
|
jsAssetsWithoutEntry: [],
|
|
@@ -1609,7 +1617,7 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1609
1617
|
}
|
|
1610
1618
|
}
|
|
1611
1619
|
]
|
|
1612
|
-
} : (assignRemoteInfo(r, l), generatePreloadAssets(t, n, r,
|
|
1620
|
+
} : (assignRemoteInfo(r, l), generatePreloadAssets(t, n, r, a, l)) : {
|
|
1613
1621
|
cssAssets: [],
|
|
1614
1622
|
jsAssetsWithoutEntry: [],
|
|
1615
1623
|
entryAssets: []
|
|
@@ -1646,37 +1654,37 @@ class SnapshotHandler {
|
|
|
1646
1654
|
options: s,
|
|
1647
1655
|
moduleInfo: t
|
|
1648
1656
|
});
|
|
1649
|
-
let
|
|
1657
|
+
let a = getGlobalSnapshotInfoByModuleInfo({
|
|
1650
1658
|
name: this.HostInstance.options.name,
|
|
1651
1659
|
version: this.HostInstance.options.version
|
|
1652
1660
|
});
|
|
1653
|
-
|
|
1661
|
+
a || (a = {
|
|
1654
1662
|
version: this.HostInstance.options.version || "",
|
|
1655
1663
|
remoteEntry: "",
|
|
1656
1664
|
remotesInfo: {}
|
|
1657
1665
|
}, addGlobalSnapshot({
|
|
1658
|
-
[this.HostInstance.options.name]:
|
|
1659
|
-
})),
|
|
1666
|
+
[this.HostInstance.options.name]: a
|
|
1667
|
+
})), 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
1668
|
[t.name]: {
|
|
1661
1669
|
matchedVersion: "version" in t ? t.version : t.entry
|
|
1662
1670
|
}
|
|
1663
1671
|
}));
|
|
1664
|
-
const { hostGlobalSnapshot: l, remoteSnapshot:
|
|
1672
|
+
const { hostGlobalSnapshot: l, remoteSnapshot: i, globalSnapshot: c } = this.getGlobalRemoteInfo(t), { remoteSnapshot: u, globalSnapshot: p } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1665
1673
|
options: s,
|
|
1666
1674
|
moduleInfo: t,
|
|
1667
1675
|
hostGlobalSnapshot: l,
|
|
1668
|
-
remoteSnapshot:
|
|
1676
|
+
remoteSnapshot: i,
|
|
1669
1677
|
globalSnapshot: c
|
|
1670
1678
|
});
|
|
1671
1679
|
let d, m;
|
|
1672
1680
|
if (u)
|
|
1673
1681
|
if (isManifestProvider(u)) {
|
|
1674
|
-
const y = isBrowserEnv() ? u.remoteEntry : u.ssrRemoteEntry || u.remoteEntry || "",
|
|
1682
|
+
const y = isBrowserEnv() ? u.remoteEntry : u.ssrRemoteEntry || u.remoteEntry || "", E = await this.getManifestJson(y, t, {}), g = setGlobalSnapshotInfoByModuleInfo(_extends$1({}, t, {
|
|
1675
1683
|
// The global remote may be overridden
|
|
1676
1684
|
// Therefore, set the snapshot key to the global address of the actual request
|
|
1677
1685
|
entry: y
|
|
1678
|
-
}),
|
|
1679
|
-
d =
|
|
1686
|
+
}), E);
|
|
1687
|
+
d = E, m = g;
|
|
1680
1688
|
} else {
|
|
1681
1689
|
const { remoteSnapshot: y } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1682
1690
|
options: this.HostInstance.options,
|
|
@@ -1687,13 +1695,13 @@ class SnapshotHandler {
|
|
|
1687
1695
|
d = y, m = p;
|
|
1688
1696
|
}
|
|
1689
1697
|
else if (isRemoteInfoWithEntry(t)) {
|
|
1690
|
-
const y = await this.getManifestJson(t.entry, t, {}),
|
|
1698
|
+
const y = await this.getManifestJson(t.entry, t, {}), E = setGlobalSnapshotInfoByModuleInfo(t, y), { remoteSnapshot: g } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1691
1699
|
options: this.HostInstance.options,
|
|
1692
1700
|
moduleInfo: t,
|
|
1693
1701
|
remoteSnapshot: y,
|
|
1694
1702
|
from: "global"
|
|
1695
1703
|
});
|
|
1696
|
-
d =
|
|
1704
|
+
d = g, m = E;
|
|
1697
1705
|
} else
|
|
1698
1706
|
error(getShortErrorMsg(RUNTIME_007, runtimeDescMap, {
|
|
1699
1707
|
hostName: t.name,
|
|
@@ -1720,12 +1728,12 @@ class SnapshotHandler {
|
|
|
1720
1728
|
if (l)
|
|
1721
1729
|
return l;
|
|
1722
1730
|
try {
|
|
1723
|
-
let
|
|
1724
|
-
(!
|
|
1725
|
-
} catch (
|
|
1731
|
+
let i = await this.loaderHook.lifecycle.fetch.emit(t, {});
|
|
1732
|
+
(!i || !(i instanceof Response)) && (i = await fetch(t, {})), l = await i.json();
|
|
1733
|
+
} catch (i) {
|
|
1726
1734
|
l = await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
1727
1735
|
id: t,
|
|
1728
|
-
error:
|
|
1736
|
+
error: i,
|
|
1729
1737
|
from: "runtime",
|
|
1730
1738
|
lifecycle: "afterResolve",
|
|
1731
1739
|
origin: this.HostInstance
|
|
@@ -1733,23 +1741,23 @@ class SnapshotHandler {
|
|
|
1733
1741
|
manifestUrl: t,
|
|
1734
1742
|
moduleName: n.name,
|
|
1735
1743
|
hostName: this.HostInstance.options.name
|
|
1736
|
-
}, `${
|
|
1744
|
+
}, `${i}`)));
|
|
1737
1745
|
}
|
|
1738
1746
|
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(),
|
|
1747
|
+
}, a = async () => {
|
|
1748
|
+
const l = await s(), i = generateSnapshotFromManifest(l, {
|
|
1741
1749
|
version: t
|
|
1742
1750
|
}), { remoteSnapshot: c } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1743
1751
|
options: this.HostInstance.options,
|
|
1744
1752
|
moduleInfo: n,
|
|
1745
1753
|
manifestJson: l,
|
|
1746
|
-
remoteSnapshot:
|
|
1754
|
+
remoteSnapshot: i,
|
|
1747
1755
|
manifestUrl: t,
|
|
1748
1756
|
from: "manifest"
|
|
1749
1757
|
});
|
|
1750
1758
|
return c;
|
|
1751
1759
|
};
|
|
1752
|
-
return this.manifestLoading[t] || (this.manifestLoading[t] =
|
|
1760
|
+
return this.manifestLoading[t] || (this.manifestLoading[t] = a().then((l) => l)), this.manifestLoading[t];
|
|
1753
1761
|
}
|
|
1754
1762
|
constructor(t) {
|
|
1755
1763
|
this.loadingHostSnapshot = null, this.manifestCache = /* @__PURE__ */ new Map(), this.hooks = new PluginSystem({
|
|
@@ -1791,30 +1799,30 @@ class SharedHandler {
|
|
|
1791
1799
|
strategy: s.strategy
|
|
1792
1800
|
}));
|
|
1793
1801
|
}));
|
|
1794
|
-
const
|
|
1802
|
+
const a = await this.hooks.lifecycle.beforeLoadShare.emit({
|
|
1795
1803
|
pkgName: t,
|
|
1796
1804
|
shareInfo: s,
|
|
1797
1805
|
shared: r.options.shared,
|
|
1798
1806
|
origin: r
|
|
1799
|
-
}), { shareInfo: l } =
|
|
1807
|
+
}), { shareInfo: l } = a;
|
|
1800
1808
|
assert(l, `Cannot find ${t} Share in the ${r.options.name}. Please ensure that the ${t} Share parameters have been injected`);
|
|
1801
|
-
const
|
|
1809
|
+
const i = getRegisteredShare(this.shareScopeMap, t, l, this.hooks.lifecycle.resolveShare), c = (u) => {
|
|
1802
1810
|
u.useIn || (u.useIn = []), addUniqueItem(u.useIn, r.options.name);
|
|
1803
1811
|
};
|
|
1804
|
-
if (
|
|
1805
|
-
return c(
|
|
1806
|
-
if (
|
|
1807
|
-
const u = await
|
|
1808
|
-
return
|
|
1809
|
-
} else if (
|
|
1812
|
+
if (i && i.lib)
|
|
1813
|
+
return c(i), i.lib;
|
|
1814
|
+
if (i && i.loading && !i.loaded) {
|
|
1815
|
+
const u = await i.loading;
|
|
1816
|
+
return i.loaded = !0, i.lib || (i.lib = u), c(i), u;
|
|
1817
|
+
} else if (i) {
|
|
1810
1818
|
const p = (async () => {
|
|
1811
|
-
const d = await
|
|
1812
|
-
return c(
|
|
1819
|
+
const d = await i.get();
|
|
1820
|
+
return c(i), i.loaded = !0, i.lib = d, d;
|
|
1813
1821
|
})();
|
|
1814
1822
|
return this.setShared({
|
|
1815
1823
|
pkgName: t,
|
|
1816
1824
|
loaded: !1,
|
|
1817
|
-
shared:
|
|
1825
|
+
shared: i,
|
|
1818
1826
|
from: r.options.name,
|
|
1819
1827
|
lib: null,
|
|
1820
1828
|
loading: p
|
|
@@ -1845,53 +1853,53 @@ class SharedHandler {
|
|
|
1845
1853
|
*/
|
|
1846
1854
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
1847
1855
|
initializeSharing(t = DEFAULT_SCOPE, n) {
|
|
1848
|
-
const { host: r } = this, s = n == null ? void 0 : n.from,
|
|
1856
|
+
const { host: r } = this, s = n == null ? void 0 : n.from, a = n == null ? void 0 : n.strategy;
|
|
1849
1857
|
let l = n == null ? void 0 : n.initScope;
|
|
1850
|
-
const
|
|
1858
|
+
const i = [];
|
|
1851
1859
|
if (s !== "build") {
|
|
1852
|
-
const { initTokens:
|
|
1860
|
+
const { initTokens: E } = this;
|
|
1853
1861
|
l || (l = []);
|
|
1854
|
-
let
|
|
1855
|
-
if (
|
|
1862
|
+
let g = E[t];
|
|
1863
|
+
if (g || (g = E[t] = {
|
|
1856
1864
|
from: this.host.name
|
|
1857
|
-
}), l.indexOf(
|
|
1858
|
-
l.push(
|
|
1865
|
+
}), l.indexOf(g) >= 0) return i;
|
|
1866
|
+
l.push(g);
|
|
1859
1867
|
}
|
|
1860
1868
|
const c = this.shareScopeMap, u = r.options.name;
|
|
1861
1869
|
c[t] || (c[t] = {});
|
|
1862
|
-
const p = c[t], d = (
|
|
1870
|
+
const p = c[t], d = (E, g) => {
|
|
1863
1871
|
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:
|
|
1872
|
+
const { version: b, eager: v } = g;
|
|
1873
|
+
p[E] = p[E] || {};
|
|
1874
|
+
const I = p[E], S = I[b], R = !!(S && (S.eager || (_ = S.shareConfig) != null && _.eager));
|
|
1875
|
+
(!S || S.strategy !== "loaded-first" && !S.loaded && (!v != !R ? v : u > S.from)) && (I[b] = g);
|
|
1876
|
+
}, m = (E) => E && E.init && E.init(c[t], l), y = async (E) => {
|
|
1877
|
+
const { module: g } = await r.remoteHandler.getRemoteModuleAndOptions({
|
|
1878
|
+
id: E
|
|
1871
1879
|
});
|
|
1872
|
-
if (
|
|
1880
|
+
if (g.getEntry) {
|
|
1873
1881
|
let _;
|
|
1874
1882
|
try {
|
|
1875
|
-
_ = await
|
|
1883
|
+
_ = await g.getEntry();
|
|
1876
1884
|
} catch (b) {
|
|
1877
1885
|
_ = await r.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
1878
|
-
id:
|
|
1886
|
+
id: E,
|
|
1879
1887
|
error: b,
|
|
1880
1888
|
from: "runtime",
|
|
1881
1889
|
lifecycle: "beforeLoadShare",
|
|
1882
1890
|
origin: r
|
|
1883
1891
|
});
|
|
1884
1892
|
}
|
|
1885
|
-
|
|
1893
|
+
g.inited || (await m(_), g.inited = !0);
|
|
1886
1894
|
}
|
|
1887
1895
|
};
|
|
1888
|
-
return Object.keys(r.options.shared).forEach((
|
|
1889
|
-
r.options.shared[
|
|
1890
|
-
_.scope.includes(t) && d(
|
|
1896
|
+
return Object.keys(r.options.shared).forEach((E) => {
|
|
1897
|
+
r.options.shared[E].forEach((_) => {
|
|
1898
|
+
_.scope.includes(t) && d(E, _);
|
|
1891
1899
|
});
|
|
1892
|
-
}), (r.options.shareStrategy === "version-first" ||
|
|
1893
|
-
|
|
1894
|
-
}),
|
|
1900
|
+
}), (r.options.shareStrategy === "version-first" || a === "version-first") && r.options.remotes.forEach((E) => {
|
|
1901
|
+
E.shareScope === t && i.push(y(E.name));
|
|
1902
|
+
}), i;
|
|
1895
1903
|
}
|
|
1896
1904
|
// 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
1905
|
// 1. If the loaded shared already exists globally, then it will be reused
|
|
@@ -1903,41 +1911,41 @@ class SharedHandler {
|
|
|
1903
1911
|
extraOptions: n,
|
|
1904
1912
|
shareInfos: r.options.shared
|
|
1905
1913
|
});
|
|
1906
|
-
s != null && s.scope && s.scope.forEach((
|
|
1907
|
-
this.initializeSharing(
|
|
1914
|
+
s != null && s.scope && s.scope.forEach((i) => {
|
|
1915
|
+
this.initializeSharing(i, {
|
|
1908
1916
|
strategy: s.strategy
|
|
1909
1917
|
});
|
|
1910
1918
|
});
|
|
1911
|
-
const
|
|
1912
|
-
|
|
1919
|
+
const a = getRegisteredShare(this.shareScopeMap, t, s, this.hooks.lifecycle.resolveShare), l = (i) => {
|
|
1920
|
+
i.useIn || (i.useIn = []), addUniqueItem(i.useIn, r.options.name);
|
|
1913
1921
|
};
|
|
1914
|
-
if (
|
|
1915
|
-
if (typeof
|
|
1916
|
-
return l(
|
|
1917
|
-
if (typeof
|
|
1918
|
-
const
|
|
1919
|
-
if (!(
|
|
1920
|
-
return l(
|
|
1922
|
+
if (a) {
|
|
1923
|
+
if (typeof a.lib == "function")
|
|
1924
|
+
return l(a), a.loaded || (a.loaded = !0, a.from === r.options.name && (s.loaded = !0)), a.lib;
|
|
1925
|
+
if (typeof a.get == "function") {
|
|
1926
|
+
const i = a.get();
|
|
1927
|
+
if (!(i instanceof Promise))
|
|
1928
|
+
return l(a), this.setShared({
|
|
1921
1929
|
pkgName: t,
|
|
1922
1930
|
loaded: !0,
|
|
1923
1931
|
from: r.options.name,
|
|
1924
|
-
lib:
|
|
1925
|
-
shared:
|
|
1926
|
-
}),
|
|
1932
|
+
lib: i,
|
|
1933
|
+
shared: a
|
|
1934
|
+
}), i;
|
|
1927
1935
|
}
|
|
1928
1936
|
}
|
|
1929
1937
|
if (s.lib)
|
|
1930
1938
|
return s.loaded || (s.loaded = !0), s.lib;
|
|
1931
1939
|
if (s.get) {
|
|
1932
|
-
const
|
|
1933
|
-
if (
|
|
1940
|
+
const i = s.get();
|
|
1941
|
+
if (i instanceof Promise) {
|
|
1934
1942
|
const c = (n == null ? void 0 : n.from) === "build" ? RUNTIME_005 : RUNTIME_006;
|
|
1935
1943
|
throw new Error(getShortErrorMsg(c, runtimeDescMap, {
|
|
1936
1944
|
hostName: r.options.name,
|
|
1937
1945
|
sharedPkgName: t
|
|
1938
1946
|
}));
|
|
1939
1947
|
}
|
|
1940
|
-
return s.lib =
|
|
1948
|
+
return s.lib = i, this.setShared({
|
|
1941
1949
|
pkgName: t,
|
|
1942
1950
|
loaded: !0,
|
|
1943
1951
|
from: r.options.name,
|
|
@@ -1960,7 +1968,7 @@ class SharedHandler {
|
|
|
1960
1968
|
hostShareScopeMap: r.hostShareScopeMap
|
|
1961
1969
|
});
|
|
1962
1970
|
}
|
|
1963
|
-
setShared({ pkgName: t, shared: n, from: r, lib: s, loading:
|
|
1971
|
+
setShared({ pkgName: t, shared: n, from: r, lib: s, loading: a, loaded: l, get: i }) {
|
|
1964
1972
|
const { version: c, scope: u = "default" } = n, p = _object_without_properties_loose(n, [
|
|
1965
1973
|
"version",
|
|
1966
1974
|
"scope"
|
|
@@ -1977,12 +1985,12 @@ class SharedHandler {
|
|
|
1977
1985
|
}, p, {
|
|
1978
1986
|
lib: s,
|
|
1979
1987
|
loaded: l,
|
|
1980
|
-
loading:
|
|
1981
|
-
}),
|
|
1988
|
+
loading: a
|
|
1989
|
+
}), i && (this.shareScopeMap[m][t][c].get = i);
|
|
1982
1990
|
return;
|
|
1983
1991
|
}
|
|
1984
1992
|
const y = this.shareScopeMap[m][t][c];
|
|
1985
|
-
|
|
1993
|
+
a && !y.loading && (y.loading = a), l && !y.loaded && (y.loaded = l), r && y.from !== r && (y.from = r);
|
|
1986
1994
|
});
|
|
1987
1995
|
}
|
|
1988
1996
|
_setGlobalShareScopeMap(t) {
|
|
@@ -2003,26 +2011,26 @@ class SharedHandler {
|
|
|
2003
2011
|
}
|
|
2004
2012
|
class RemoteHandler {
|
|
2005
2013
|
formatAndRegisterRemote(t, n) {
|
|
2006
|
-
return (n.remotes || []).reduce((s,
|
|
2014
|
+
return (n.remotes || []).reduce((s, a) => (this.registerRemote(a, s, {
|
|
2007
2015
|
force: !1
|
|
2008
2016
|
}), s), t.remotes);
|
|
2009
2017
|
}
|
|
2010
2018
|
setIdToRemoteMap(t, n) {
|
|
2011
|
-
const { remote: r, expose: s } = n, { name:
|
|
2019
|
+
const { remote: r, expose: s } = n, { name: a, alias: l } = r;
|
|
2012
2020
|
if (this.idToRemoteMap[t] = {
|
|
2013
2021
|
name: r.name,
|
|
2014
2022
|
expose: s
|
|
2015
|
-
}, l && t.startsWith(
|
|
2016
|
-
const
|
|
2017
|
-
this.idToRemoteMap[
|
|
2023
|
+
}, l && t.startsWith(a)) {
|
|
2024
|
+
const i = t.replace(a, l);
|
|
2025
|
+
this.idToRemoteMap[i] = {
|
|
2018
2026
|
name: r.name,
|
|
2019
2027
|
expose: s
|
|
2020
2028
|
};
|
|
2021
2029
|
return;
|
|
2022
2030
|
}
|
|
2023
2031
|
if (l && t.startsWith(l)) {
|
|
2024
|
-
const
|
|
2025
|
-
this.idToRemoteMap[
|
|
2032
|
+
const i = t.replace(l, a);
|
|
2033
|
+
this.idToRemoteMap[i] = {
|
|
2026
2034
|
name: r.name,
|
|
2027
2035
|
expose: s
|
|
2028
2036
|
};
|
|
@@ -2035,9 +2043,9 @@ class RemoteHandler {
|
|
|
2035
2043
|
try {
|
|
2036
2044
|
const { loadFactory: s = !0 } = n || {
|
|
2037
2045
|
loadFactory: !0
|
|
2038
|
-
}, { module:
|
|
2046
|
+
}, { module: a, moduleOptions: l, remoteMatchInfo: i } = await this.getRemoteModuleAndOptions({
|
|
2039
2047
|
id: t
|
|
2040
|
-
}), { pkgNameOrAlias: c, remote: u, expose: p, id: d, remoteSnapshot: m } =
|
|
2048
|
+
}), { 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
2049
|
id: d,
|
|
2042
2050
|
pkgNameOrAlias: c,
|
|
2043
2051
|
expose: p,
|
|
@@ -2045,17 +2053,17 @@ class RemoteHandler {
|
|
|
2045
2053
|
exposeModuleFactory: s ? void 0 : y,
|
|
2046
2054
|
remote: u,
|
|
2047
2055
|
options: l,
|
|
2048
|
-
moduleInstance:
|
|
2056
|
+
moduleInstance: a,
|
|
2049
2057
|
origin: r
|
|
2050
2058
|
});
|
|
2051
|
-
return this.setIdToRemoteMap(t,
|
|
2059
|
+
return this.setIdToRemoteMap(t, i), typeof E == "function" ? E : y;
|
|
2052
2060
|
} catch (s) {
|
|
2053
|
-
const { from:
|
|
2061
|
+
const { from: a = "runtime" } = n || {
|
|
2054
2062
|
from: "runtime"
|
|
2055
2063
|
}, l = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2056
2064
|
id: t,
|
|
2057
2065
|
error: s,
|
|
2058
|
-
from:
|
|
2066
|
+
from: a,
|
|
2059
2067
|
lifecycle: "onLoad",
|
|
2060
2068
|
origin: r
|
|
2061
2069
|
});
|
|
@@ -2074,14 +2082,14 @@ class RemoteHandler {
|
|
|
2074
2082
|
});
|
|
2075
2083
|
const r = formatPreloadArgs(n.options.remotes, t);
|
|
2076
2084
|
await Promise.all(r.map(async (s) => {
|
|
2077
|
-
const { remote:
|
|
2078
|
-
moduleInfo:
|
|
2085
|
+
const { remote: a } = s, l = getRemoteInfo(a), { globalSnapshot: i, remoteSnapshot: c } = await n.snapshotHandler.loadRemoteSnapshotInfo({
|
|
2086
|
+
moduleInfo: a
|
|
2079
2087
|
}), u = await this.hooks.lifecycle.generatePreloadAssets.emit({
|
|
2080
2088
|
origin: n,
|
|
2081
2089
|
preloadOptions: s,
|
|
2082
|
-
remote:
|
|
2090
|
+
remote: a,
|
|
2083
2091
|
remoteInfo: l,
|
|
2084
|
-
globalSnapshot:
|
|
2092
|
+
globalSnapshot: i,
|
|
2085
2093
|
remoteSnapshot: c
|
|
2086
2094
|
});
|
|
2087
2095
|
u && preloadAssets(l, n, u);
|
|
@@ -2104,30 +2112,30 @@ class RemoteHandler {
|
|
|
2104
2112
|
options: n.options,
|
|
2105
2113
|
origin: n
|
|
2106
2114
|
});
|
|
2107
|
-
} catch (
|
|
2115
|
+
} catch (E) {
|
|
2108
2116
|
if (s = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2109
2117
|
id: r,
|
|
2110
2118
|
options: n.options,
|
|
2111
2119
|
origin: n,
|
|
2112
2120
|
from: "runtime",
|
|
2113
|
-
error:
|
|
2121
|
+
error: E,
|
|
2114
2122
|
lifecycle: "beforeRequest"
|
|
2115
2123
|
}), !s)
|
|
2116
|
-
throw
|
|
2124
|
+
throw E;
|
|
2117
2125
|
}
|
|
2118
|
-
const { id:
|
|
2126
|
+
const { id: a } = s, l = matchRemoteWithNameAndExpose(n.options.remotes, a);
|
|
2119
2127
|
assert(l, getShortErrorMsg(RUNTIME_004, runtimeDescMap, {
|
|
2120
2128
|
hostName: n.options.name,
|
|
2121
|
-
requestId:
|
|
2129
|
+
requestId: a
|
|
2122
2130
|
}));
|
|
2123
|
-
const { remote:
|
|
2124
|
-
id:
|
|
2131
|
+
const { remote: i } = l, c = getRemoteInfo(i), u = await n.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({
|
|
2132
|
+
id: a
|
|
2125
2133
|
}, l, {
|
|
2126
2134
|
options: n.options,
|
|
2127
2135
|
origin: n,
|
|
2128
2136
|
remoteInfo: c
|
|
2129
2137
|
})), { 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 ${
|
|
2138
|
+
assert(p && d, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${a}.`);
|
|
2131
2139
|
let m = n.moduleCache.get(p.name);
|
|
2132
2140
|
const y = {
|
|
2133
2141
|
host: n,
|
|
@@ -2140,13 +2148,13 @@ class RemoteHandler {
|
|
|
2140
2148
|
};
|
|
2141
2149
|
}
|
|
2142
2150
|
registerRemote(t, n, r) {
|
|
2143
|
-
const { host: s } = this,
|
|
2151
|
+
const { host: s } = this, a = () => {
|
|
2144
2152
|
if (t.alias) {
|
|
2145
|
-
const
|
|
2153
|
+
const i = n.find((c) => {
|
|
2146
2154
|
var u;
|
|
2147
2155
|
return t.alias && (c.name.startsWith(t.alias) || ((u = c.alias) == null ? void 0 : u.startsWith(t.alias)));
|
|
2148
2156
|
});
|
|
2149
|
-
assert(!
|
|
2157
|
+
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
2158
|
}
|
|
2151
2159
|
"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
2160
|
};
|
|
@@ -2154,53 +2162,53 @@ class RemoteHandler {
|
|
|
2154
2162
|
remote: t,
|
|
2155
2163
|
origin: s
|
|
2156
2164
|
});
|
|
2157
|
-
const l = n.find((
|
|
2165
|
+
const l = n.find((i) => i.name === t.name);
|
|
2158
2166
|
if (!l)
|
|
2159
|
-
|
|
2167
|
+
a(), n.push(t), this.hooks.lifecycle.registerRemote.emit({
|
|
2160
2168
|
remote: t,
|
|
2161
2169
|
origin: s
|
|
2162
2170
|
});
|
|
2163
2171
|
else {
|
|
2164
|
-
const
|
|
2172
|
+
const i = [
|
|
2165
2173
|
`The remote "${t.name}" is already registered.`,
|
|
2166
2174
|
"Please note that overriding it may cause unexpected errors."
|
|
2167
2175
|
];
|
|
2168
|
-
r != null && r.force && (this.removeRemote(l),
|
|
2176
|
+
r != null && r.force && (this.removeRemote(l), a(), n.push(t), this.hooks.lifecycle.registerRemote.emit({
|
|
2169
2177
|
remote: t,
|
|
2170
2178
|
origin: s
|
|
2171
|
-
}), warn$1(
|
|
2179
|
+
}), warn$1(i.join(" ")));
|
|
2172
2180
|
}
|
|
2173
2181
|
}
|
|
2174
2182
|
removeRemote(t) {
|
|
2175
2183
|
try {
|
|
2176
|
-
const { host: r } = this, { name: s } = t,
|
|
2177
|
-
|
|
2184
|
+
const { host: r } = this, { name: s } = t, a = r.options.remotes.findIndex((i) => i.name === s);
|
|
2185
|
+
a !== -1 && r.options.remotes.splice(a, 1);
|
|
2178
2186
|
const l = r.moduleCache.get(t.name);
|
|
2179
2187
|
if (l) {
|
|
2180
|
-
const
|
|
2188
|
+
const i = l.remoteInfo, c = i.entryGlobalName;
|
|
2181
2189
|
if (CurrentGlobal[c]) {
|
|
2182
2190
|
var n;
|
|
2183
2191
|
(n = Object.getOwnPropertyDescriptor(CurrentGlobal, c)) != null && n.configurable ? delete CurrentGlobal[c] : CurrentGlobal[c] = void 0;
|
|
2184
2192
|
}
|
|
2185
2193
|
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) =>
|
|
2194
|
+
globalLoading[u] && delete globalLoading[u], r.snapshotHandler.manifestCache.delete(i.entry);
|
|
2195
|
+
let p = i.buildVersion ? composeKeyWithSeparator(i.name, i.buildVersion) : i.name;
|
|
2196
|
+
const d = CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex((y) => i.buildVersion ? y.options.id === p : y.name === p);
|
|
2189
2197
|
if (d !== -1) {
|
|
2190
2198
|
const y = CurrentGlobal.__FEDERATION__.__INSTANCES__[d];
|
|
2191
2199
|
p = y.options.id || p;
|
|
2192
|
-
const
|
|
2193
|
-
let
|
|
2200
|
+
const E = getGlobalShareScope();
|
|
2201
|
+
let g = !0;
|
|
2194
2202
|
const _ = [];
|
|
2195
|
-
Object.keys(
|
|
2196
|
-
const v =
|
|
2203
|
+
Object.keys(E).forEach((b) => {
|
|
2204
|
+
const v = E[b];
|
|
2197
2205
|
v && Object.keys(v).forEach((I) => {
|
|
2198
2206
|
const S = v[I];
|
|
2199
2207
|
S && Object.keys(S).forEach((R) => {
|
|
2200
2208
|
const A = S[R];
|
|
2201
2209
|
A && Object.keys(A).forEach((T) => {
|
|
2202
2210
|
const $ = A[T];
|
|
2203
|
-
$ && typeof $ == "object" && $.from ===
|
|
2211
|
+
$ && typeof $ == "object" && $.from === i.name && ($.loaded || $.loading ? ($.useIn = $.useIn.filter((O) => O !== i.name), $.useIn.length ? g = !1 : _.push([
|
|
2204
2212
|
b,
|
|
2205
2213
|
I,
|
|
2206
2214
|
R,
|
|
@@ -2214,9 +2222,9 @@ class RemoteHandler {
|
|
|
2214
2222
|
});
|
|
2215
2223
|
});
|
|
2216
2224
|
});
|
|
2217
|
-
}),
|
|
2225
|
+
}), g && (y.shareScopeMap = {}, delete E[p]), _.forEach(([b, v, I, S]) => {
|
|
2218
2226
|
var R, A, T;
|
|
2219
|
-
(T =
|
|
2227
|
+
(T = E[b]) == null || (A = T[v]) == null || (R = A[I]) == null || delete R[S];
|
|
2220
2228
|
}), CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(d, 1);
|
|
2221
2229
|
}
|
|
2222
2230
|
const { hostGlobalSnapshot: m } = getGlobalRemoteInfo(t, r);
|
|
@@ -2270,11 +2278,11 @@ class ModuleFederation {
|
|
|
2270
2278
|
const s = getRemoteInfo({
|
|
2271
2279
|
name: t,
|
|
2272
2280
|
entry: n
|
|
2273
|
-
}),
|
|
2281
|
+
}), a = new Module({
|
|
2274
2282
|
host: this,
|
|
2275
2283
|
remoteInfo: s
|
|
2276
2284
|
});
|
|
2277
|
-
return
|
|
2285
|
+
return a.remoteEntryExports = r, this.moduleCache.set(t, a), a;
|
|
2278
2286
|
}
|
|
2279
2287
|
// eslint-disable-next-line max-lines-per-function
|
|
2280
2288
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
@@ -2289,13 +2297,13 @@ class ModuleFederation {
|
|
|
2289
2297
|
this.sharedHandler.initShareScopeMap(t, n, r);
|
|
2290
2298
|
}
|
|
2291
2299
|
formatOptions(t, n) {
|
|
2292
|
-
const { shared: r } = formatShareConfigs(t, n), { userOptions: s, options:
|
|
2300
|
+
const { shared: r } = formatShareConfigs(t, n), { userOptions: s, options: a } = this.hooks.lifecycle.beforeInit.emit({
|
|
2293
2301
|
origin: this,
|
|
2294
2302
|
userOptions: n,
|
|
2295
2303
|
options: t,
|
|
2296
2304
|
shareInfo: r
|
|
2297
|
-
}), l = this.remoteHandler.formatAndRegisterRemote(
|
|
2298
|
-
...
|
|
2305
|
+
}), l = this.remoteHandler.formatAndRegisterRemote(a, s), { shared: i } = this.sharedHandler.registerShared(a, s), c = [
|
|
2306
|
+
...a.plugins
|
|
2299
2307
|
];
|
|
2300
2308
|
s.plugins && s.plugins.forEach((p) => {
|
|
2301
2309
|
c.includes(p) || c.push(p);
|
|
@@ -2303,7 +2311,7 @@ class ModuleFederation {
|
|
|
2303
2311
|
const u = _extends$1({}, t, n, {
|
|
2304
2312
|
plugins: c,
|
|
2305
2313
|
remotes: l,
|
|
2306
|
-
shared:
|
|
2314
|
+
shared: i
|
|
2307
2315
|
});
|
|
2308
2316
|
return this.hooks.lifecycle.init.emit({
|
|
2309
2317
|
origin: this,
|
|
@@ -2312,7 +2320,7 @@ class ModuleFederation {
|
|
|
2312
2320
|
}
|
|
2313
2321
|
registerPlugins(t) {
|
|
2314
2322
|
const n = registerPlugins(t, this);
|
|
2315
|
-
this.options.plugins = this.options.plugins.reduce((r, s) => (s && r && !r.find((
|
|
2323
|
+
this.options.plugins = this.options.plugins.reduce((r, s) => (s && r && !r.find((a) => a.name === s.name) && r.push(s), r), n || []);
|
|
2316
2324
|
}
|
|
2317
2325
|
registerRemotes(t, n) {
|
|
2318
2326
|
return this.remoteHandler.registerRemotes(t, n);
|
|
@@ -2330,7 +2338,7 @@ class ModuleFederation {
|
|
|
2330
2338
|
beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
|
|
2331
2339
|
// maybe will change, temporarily for internal use only
|
|
2332
2340
|
initContainer: new AsyncWaterfallHook("initContainer")
|
|
2333
|
-
}), this.version = "0.18.
|
|
2341
|
+
}), this.version = "0.18.4", this.moduleCache = /* @__PURE__ */ new Map(), this.loaderHook = new PluginSystem({
|
|
2334
2342
|
// FIXME: may not be suitable , not open to the public yet
|
|
2335
2343
|
getModuleInfo: new SyncHook(),
|
|
2336
2344
|
createScript: new SyncHook(),
|
|
@@ -2369,23 +2377,23 @@ setGlobalFederationConstructor(ModuleFederation);
|
|
|
2369
2377
|
function createBridgeComponent(o) {
|
|
2370
2378
|
const t = /* @__PURE__ */ new Map(), n = getInstance();
|
|
2371
2379
|
return () => ({
|
|
2372
|
-
__APP_VERSION__: "0.18.
|
|
2380
|
+
__APP_VERSION__: "0.18.4",
|
|
2373
2381
|
async render(r) {
|
|
2374
|
-
var
|
|
2382
|
+
var E, g, _;
|
|
2375
2383
|
LoggerInstance.debug("createBridgeComponent render Info", r);
|
|
2376
2384
|
const {
|
|
2377
2385
|
moduleName: s,
|
|
2378
|
-
dom:
|
|
2386
|
+
dom: a,
|
|
2379
2387
|
basename: l,
|
|
2380
|
-
memoryRoute:
|
|
2388
|
+
memoryRoute: i,
|
|
2381
2389
|
hashRoute: c,
|
|
2382
2390
|
...u
|
|
2383
2391
|
} = r, p = Vue.createApp(o.rootComponent, u);
|
|
2384
|
-
t.set(
|
|
2385
|
-
const d = await ((_ = (
|
|
2392
|
+
t.set(a, p);
|
|
2393
|
+
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
2394
|
app: p,
|
|
2387
2395
|
basename: l,
|
|
2388
|
-
memoryRoute:
|
|
2396
|
+
memoryRoute: i,
|
|
2389
2397
|
hashRoute: c,
|
|
2390
2398
|
...u,
|
|
2391
2399
|
...m
|
|
@@ -2404,9 +2412,9 @@ function createBridgeComponent(o) {
|
|
|
2404
2412
|
LoggerInstance.debug("createBridgeComponent render router info>>>", {
|
|
2405
2413
|
moduleName: s,
|
|
2406
2414
|
router: I
|
|
2407
|
-
}),
|
|
2415
|
+
}), i && await I.push(i.entryPath), p.use(I);
|
|
2408
2416
|
}
|
|
2409
|
-
p.mount(
|
|
2417
|
+
p.mount(a);
|
|
2410
2418
|
},
|
|
2411
2419
|
destroy(r) {
|
|
2412
2420
|
LoggerInstance.debug("createBridgeComponent destroy Info", r);
|
|
@@ -2431,8 +2439,8 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2431
2439
|
},
|
|
2432
2440
|
inheritAttrs: !1,
|
|
2433
2441
|
setup(o) {
|
|
2434
|
-
const t = ref(null), n = ref(null), r = ref(""), s = useRoute(),
|
|
2435
|
-
var m, y,
|
|
2442
|
+
const t = ref(null), n = ref(null), r = ref(""), s = useRoute(), a = getInstance(), l = useAttrs(), i = async () => {
|
|
2443
|
+
var m, y, E, g;
|
|
2436
2444
|
const u = (m = o.providerInfo) == null ? void 0 : m.call(o);
|
|
2437
2445
|
n.value = u;
|
|
2438
2446
|
let p = {
|
|
@@ -2444,19 +2452,19 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2444
2452
|
hashRoute: o.hashRoute
|
|
2445
2453
|
};
|
|
2446
2454
|
LoggerInstance.debug("createRemoteAppComponent LazyComponent render >>>", p);
|
|
2447
|
-
const d = await ((
|
|
2455
|
+
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
2456
|
p = {
|
|
2449
2457
|
...p,
|
|
2450
2458
|
...d.extraProps
|
|
2451
2459
|
}, u.render(p);
|
|
2452
2460
|
}, c = watch(() => s == null ? void 0 : s.path, (u) => {
|
|
2453
|
-
u !== s.path &&
|
|
2461
|
+
u !== s.path && i(), r.value !== "" && r.value !== u && (LoggerInstance.debug("createRemoteAppComponent dispatchPopstateEnv >>>", {
|
|
2454
2462
|
...o,
|
|
2455
2463
|
pathname: s.path
|
|
2456
2464
|
}), e()), r.value = u;
|
|
2457
2465
|
});
|
|
2458
2466
|
return onMounted(() => {
|
|
2459
|
-
|
|
2467
|
+
i();
|
|
2460
2468
|
}), onBeforeUnmount(() => {
|
|
2461
2469
|
var u;
|
|
2462
2470
|
LoggerInstance.debug("createRemoteAppComponent LazyComponent destroy >>>", {
|
|
@@ -2471,7 +2479,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2471
2479
|
});
|
|
2472
2480
|
function createRemoteAppComponent(o) {
|
|
2473
2481
|
return defineAsyncComponent({
|
|
2474
|
-
__APP_VERSION__: "0.18.
|
|
2482
|
+
__APP_VERSION__: "0.18.4",
|
|
2475
2483
|
...o.asyncComponentOptions,
|
|
2476
2484
|
//@ts-ignore
|
|
2477
2485
|
loader: async () => {
|
|
@@ -2488,16 +2496,16 @@ function createRemoteAppComponent(o) {
|
|
|
2488
2496
|
info: o
|
|
2489
2497
|
}
|
|
2490
2498
|
);
|
|
2491
|
-
const
|
|
2499
|
+
const a = await o.loader(), l = a && a[Symbol.for("mf_module_id")], i = a[s];
|
|
2492
2500
|
if (LoggerInstance.debug(
|
|
2493
2501
|
"createRemoteAppComponent LazyComponent loadRemote info >>>",
|
|
2494
|
-
{ moduleName: l, module:
|
|
2495
|
-
), s in
|
|
2502
|
+
{ moduleName: l, module: a, exportName: s, basename: n, route: t }
|
|
2503
|
+
), s in a && typeof i == "function")
|
|
2496
2504
|
return {
|
|
2497
2505
|
render() {
|
|
2498
2506
|
return h(RemoteApp, {
|
|
2499
2507
|
moduleName: l,
|
|
2500
|
-
providerInfo:
|
|
2508
|
+
providerInfo: i,
|
|
2501
2509
|
basename: n,
|
|
2502
2510
|
rootAttrs: o.rootAttrs
|
|
2503
2511
|
});
|