@module-federation/bridge-vue3 0.8.4 → 0.8.5
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.js +8 -8
- package/dist/index.d.ts +18 -2
- package/dist/index.es.js +700 -692
- package/package.json +4 -4
- package/src/provider.ts +38 -24
package/dist/index.es.js
CHANGED
|
@@ -3,12 +3,12 @@ import { defineComponent, ref, watch, onMounted, onBeforeUnmount, createVNode, d
|
|
|
3
3
|
import * as VueRouter from "vue-router";
|
|
4
4
|
import { useRoute } from "vue-router";
|
|
5
5
|
var __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __hasOwnProp = Object.prototype.hasOwnProperty, __export = (r, t) => {
|
|
6
|
-
for (var
|
|
7
|
-
__defProp(r,
|
|
8
|
-
}, __copyProps = (r, t,
|
|
6
|
+
for (var n in t)
|
|
7
|
+
__defProp(r, n, { get: t[n], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (r, t, n, o) => {
|
|
9
9
|
if (t && typeof t == "object" || typeof t == "function")
|
|
10
10
|
for (let s of __getOwnPropNames(t))
|
|
11
|
-
!__hasOwnProp.call(r, s) && s !==
|
|
11
|
+
!__hasOwnProp.call(r, s) && s !== n && __defProp(r, s, { get: () => t[s], enumerable: !(o = __getOwnPropDesc(t, s)) || o.enumerable });
|
|
12
12
|
return r;
|
|
13
13
|
}, __toCommonJS = (r) => __copyProps(__defProp({}, "__esModule", { value: !0 }), r), browser_exports = {};
|
|
14
14
|
__export(browser_exports, {
|
|
@@ -19,10 +19,10 @@ var browser = __toCommonJS(browser_exports), supportsSubstitutions = void 0, sup
|
|
|
19
19
|
if (typeof supportsSubstitutions < "u")
|
|
20
20
|
return supportsSubstitutions;
|
|
21
21
|
try {
|
|
22
|
-
const r = "color test", t = "color: red;",
|
|
23
|
-
console.log = (...
|
|
24
|
-
|
|
25
|
-
}, console.log(`%c${r}`, t), console.log =
|
|
22
|
+
const r = "color test", t = "color: red;", n = console.log;
|
|
23
|
+
console.log = (...o) => {
|
|
24
|
+
o[0] === `%c${r}` && o[1] === t && (supportsSubstitutions = !0);
|
|
25
|
+
}, console.log(`%c${r}`, t), console.log = n;
|
|
26
26
|
} catch {
|
|
27
27
|
supportsSubstitutions = !1;
|
|
28
28
|
}
|
|
@@ -37,18 +37,18 @@ var browser = __toCommonJS(browser_exports), supportsSubstitutions = void 0, sup
|
|
|
37
37
|
gray: "color: gray;"
|
|
38
38
|
}, formatter = (r) => supportColor() ? (t) => {
|
|
39
39
|
if (Array.isArray(t)) {
|
|
40
|
-
const [
|
|
41
|
-
return [`%c${
|
|
40
|
+
const [n, o] = t;
|
|
41
|
+
return [`%c${n.replace("%c", "")}`, o ? `${ansiToCss[r]}${o}` : `${ansiToCss[r] || ""}`];
|
|
42
42
|
}
|
|
43
43
|
return [`%c${String(t).replace("%c", "")}`, ansiToCss[r] || ""];
|
|
44
44
|
} : (t) => [String(t)], bold = formatter("bold"), red = formatter("red"), green = formatter("green"), orange = formatter("orange"), dodgerblue = formatter("dodgerblue"), magenta = formatter("magenta");
|
|
45
45
|
formatter("gray");
|
|
46
|
-
function getLabel(r, t,
|
|
47
|
-
let
|
|
48
|
-
return "label" in t && (
|
|
46
|
+
function getLabel(r, t, n) {
|
|
47
|
+
let o = [""];
|
|
48
|
+
return "label" in t && (o = [n[r] || t.label || ""], o = bold(t.color ? t.color(o) : o[0])), o = o.filter(Boolean), o;
|
|
49
49
|
}
|
|
50
|
-
function finalLog(r, t,
|
|
51
|
-
r.length ? Array.isArray(
|
|
50
|
+
function finalLog(r, t, n, o) {
|
|
51
|
+
r.length ? Array.isArray(o) ? console.log(...r, ...o) : console.log(...r, t) : Array.isArray(o) ? console.log(...o) : console.log(t, ...n);
|
|
52
52
|
}
|
|
53
53
|
var LOG_LEVEL = {
|
|
54
54
|
error: 0,
|
|
@@ -56,38 +56,38 @@ var LOG_LEVEL = {
|
|
|
56
56
|
info: 2,
|
|
57
57
|
log: 3,
|
|
58
58
|
verbose: 4
|
|
59
|
-
}, errorStackRegExp = /at\s.*:\d+:\d+[\s\)]*$/, anonymousErrorStackRegExp = /at\s.*\(<anonymous>\)$/, isErrorStackMessage = (r) => errorStackRegExp.test(r) || anonymousErrorStackRegExp.test(r), createLogger$1 = (r = {}, { getLabel: t, handleError:
|
|
60
|
-
let
|
|
61
|
-
if (LOG_LEVEL[
|
|
59
|
+
}, errorStackRegExp = /at\s.*:\d+:\d+[\s\)]*$/, anonymousErrorStackRegExp = /at\s.*\(<anonymous>\)$/, isErrorStackMessage = (r) => errorStackRegExp.test(r) || anonymousErrorStackRegExp.test(r), createLogger$1 = (r = {}, { getLabel: t, handleError: n, finalLog: o, greet: s, LOG_TYPES: a }) => {
|
|
60
|
+
let l = r.level || "log", i = r.labels || {}, c = (d, p, ...m) => {
|
|
61
|
+
if (LOG_LEVEL[a[d].level] > LOG_LEVEL[l])
|
|
62
62
|
return;
|
|
63
63
|
if (p == null)
|
|
64
64
|
return console.log();
|
|
65
|
-
let y =
|
|
65
|
+
let y = a[d], _ = "";
|
|
66
66
|
const R = t(d, y, i);
|
|
67
67
|
if (p instanceof Error)
|
|
68
68
|
if (p.stack) {
|
|
69
69
|
let [g, ...E] = p.stack.split(`
|
|
70
70
|
`);
|
|
71
71
|
g.startsWith("Error: ") && (g = g.slice(7)), _ = `${g}
|
|
72
|
-
${
|
|
72
|
+
${n(E.join(`
|
|
73
73
|
`))}`;
|
|
74
74
|
} else
|
|
75
75
|
_ = p.message;
|
|
76
76
|
else
|
|
77
77
|
y.level === "error" && typeof p == "string" ? _ = p.split(`
|
|
78
|
-
`).map((E) => isErrorStackMessage(E) ?
|
|
78
|
+
`).map((E) => isErrorStackMessage(E) ? n(E) : E).join(`
|
|
79
79
|
`) : _ = `${p}`;
|
|
80
|
-
|
|
80
|
+
o(R, _, m, p);
|
|
81
81
|
}, u = {
|
|
82
82
|
// greet
|
|
83
83
|
greet: (d) => c("log", s(d))
|
|
84
84
|
};
|
|
85
|
-
return Object.keys(
|
|
85
|
+
return Object.keys(a).forEach((d) => {
|
|
86
86
|
u[d] = (...p) => c(d, ...p);
|
|
87
87
|
}), Object.defineProperty(u, "level", {
|
|
88
|
-
get: () =>
|
|
88
|
+
get: () => l,
|
|
89
89
|
set(d) {
|
|
90
|
-
|
|
90
|
+
l = d;
|
|
91
91
|
}
|
|
92
92
|
}), Object.defineProperty(u, "labels", {
|
|
93
93
|
get: () => i,
|
|
@@ -101,17 +101,17 @@ ${o(E.join(`
|
|
|
101
101
|
function gradient(r) {
|
|
102
102
|
if (!supportColor())
|
|
103
103
|
return [r];
|
|
104
|
-
const t = [...r],
|
|
105
|
-
if (
|
|
104
|
+
const t = [...r], n = t.filter(isWord), o = n.length - 1;
|
|
105
|
+
if (o === 0)
|
|
106
106
|
return console.log(`%c${r}`, `color: rgb(${startColor.join(",")}); font-weight: bold;`), [r];
|
|
107
|
-
let s = "",
|
|
108
|
-
return t.forEach((
|
|
109
|
-
if (isWord(
|
|
110
|
-
const i =
|
|
111
|
-
s += `%c${
|
|
107
|
+
let s = "", a = [];
|
|
108
|
+
return t.forEach((l) => {
|
|
109
|
+
if (isWord(l)) {
|
|
110
|
+
const i = n.indexOf(l) / o, c = Math.round(startColor[0] + (endColor[0] - startColor[0]) * i), u = Math.round(startColor[1] + (endColor[1] - startColor[1]) * i), d = Math.round(startColor[2] + (endColor[2] - startColor[2]) * i);
|
|
111
|
+
s += `%c${l}`, a.push(`color: rgb(${c},${u},${d}); font-weight: bold;`);
|
|
112
112
|
} else
|
|
113
|
-
s +=
|
|
114
|
-
}), [s, ...
|
|
113
|
+
s += l;
|
|
114
|
+
}), [s, ...a];
|
|
115
115
|
}
|
|
116
116
|
var LOG_TYPES = {
|
|
117
117
|
// Level error
|
|
@@ -171,10 +171,10 @@ function createLogger2(r = {}) {
|
|
|
171
171
|
var logger$1 = createLogger2();
|
|
172
172
|
function _extends$2() {
|
|
173
173
|
return _extends$2 = Object.assign || function(t) {
|
|
174
|
-
for (var
|
|
175
|
-
var
|
|
176
|
-
for (var s in
|
|
177
|
-
Object.prototype.hasOwnProperty.call(
|
|
174
|
+
for (var n = 1; n < arguments.length; n++) {
|
|
175
|
+
var o = arguments[n];
|
|
176
|
+
for (var s in o)
|
|
177
|
+
Object.prototype.hasOwnProperty.call(o, s) && (t[s] = o[s]);
|
|
178
178
|
}
|
|
179
179
|
return t;
|
|
180
180
|
}, _extends$2.apply(this, arguments);
|
|
@@ -224,11 +224,11 @@ function createLogger(r) {
|
|
|
224
224
|
}
|
|
225
225
|
createLogger(PREFIX);
|
|
226
226
|
const LOG_CATEGORY$1 = "[ Federation Runtime ]", composeKeyWithSeparator = function(...r) {
|
|
227
|
-
return r.length ? r.reduce((t,
|
|
227
|
+
return r.length ? r.reduce((t, n) => n ? t ? `${t}${SEPARATOR}${n}` : n : t, "") : "";
|
|
228
228
|
}, getResourceUrl = (r, t) => {
|
|
229
229
|
if ("getPublicPath" in r) {
|
|
230
|
-
let
|
|
231
|
-
return r.getPublicPath.startsWith("function") ?
|
|
230
|
+
let n;
|
|
231
|
+
return r.getPublicPath.startsWith("function") ? n = new Function("return " + r.getPublicPath)()() : n = new Function(r.getPublicPath)(), `${n}${t}`;
|
|
232
232
|
} else
|
|
233
233
|
return "publicPath" in r ? `${r.publicPath}${t}` : (console.warn("Cannot get resource URL. If in debug mode, please ignore.", r, t), "");
|
|
234
234
|
}, warn$1 = (r) => {
|
|
@@ -244,45 +244,45 @@ function safeToString(r) {
|
|
|
244
244
|
const simpleJoinRemoteEntry = (r, t) => {
|
|
245
245
|
if (!r)
|
|
246
246
|
return t;
|
|
247
|
-
const
|
|
247
|
+
const o = ((s) => {
|
|
248
248
|
if (s === ".")
|
|
249
249
|
return "";
|
|
250
250
|
if (s.startsWith("./"))
|
|
251
251
|
return s.replace("./", "");
|
|
252
252
|
if (s.startsWith("/")) {
|
|
253
|
-
const
|
|
254
|
-
return
|
|
253
|
+
const a = s.slice(1);
|
|
254
|
+
return a.endsWith("/") ? a.slice(0, -1) : a;
|
|
255
255
|
}
|
|
256
256
|
return s;
|
|
257
257
|
})(r);
|
|
258
|
-
return
|
|
258
|
+
return o ? o.endsWith("/") ? `${o}${t}` : `${o}/${t}` : t;
|
|
259
259
|
};
|
|
260
260
|
function inferAutoPublicPath(r) {
|
|
261
261
|
return r.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
|
|
262
262
|
}
|
|
263
263
|
function generateSnapshotFromManifest(r, t = {}) {
|
|
264
|
-
var
|
|
265
|
-
const { remotes: s = {}, overrides:
|
|
264
|
+
var n, o;
|
|
265
|
+
const { remotes: s = {}, overrides: a = {}, version: l } = t;
|
|
266
266
|
let i;
|
|
267
|
-
const c = () => "publicPath" in r.metaData ? r.metaData.publicPath === "auto" &&
|
|
267
|
+
const c = () => "publicPath" in r.metaData ? r.metaData.publicPath === "auto" && l ? inferAutoPublicPath(l) : r.metaData.publicPath : r.metaData.getPublicPath, u = Object.keys(a);
|
|
268
268
|
let d = {};
|
|
269
269
|
if (!Object.keys(s).length) {
|
|
270
270
|
var p;
|
|
271
271
|
d = ((p = r.remotes) == null ? void 0 : p.reduce((b, $) => {
|
|
272
|
-
let
|
|
272
|
+
let w;
|
|
273
273
|
const O = $.federationContainerName;
|
|
274
|
-
return u.includes(O) ?
|
|
275
|
-
matchedVersion:
|
|
274
|
+
return u.includes(O) ? w = a[O] : "version" in $ ? w = $.version : w = $.entry, b[O] = {
|
|
275
|
+
matchedVersion: w
|
|
276
276
|
}, b;
|
|
277
277
|
}, {})) || {};
|
|
278
278
|
}
|
|
279
279
|
Object.keys(s).forEach((b) => d[b] = {
|
|
280
280
|
// overrides will override dependencies
|
|
281
|
-
matchedVersion: u.includes(b) ?
|
|
281
|
+
matchedVersion: u.includes(b) ? a[b] : s[b]
|
|
282
282
|
});
|
|
283
|
-
const { remoteEntry: { path: m, name: y, type: _ }, types: R, buildInfo: { buildVersion: g }, globalName: E, ssrRemoteEntry:
|
|
283
|
+
const { remoteEntry: { path: m, name: y, type: _ }, types: R, buildInfo: { buildVersion: g }, globalName: E, ssrRemoteEntry: v } = r.metaData, { exposes: I } = r;
|
|
284
284
|
let S = {
|
|
285
|
-
version:
|
|
285
|
+
version: l || "",
|
|
286
286
|
buildVersion: g,
|
|
287
287
|
globalName: E,
|
|
288
288
|
remoteEntry: simpleJoinRemoteEntry(m, y),
|
|
@@ -296,32 +296,32 @@ function generateSnapshotFromManifest(r, t = {}) {
|
|
|
296
296
|
sharedName: b.name,
|
|
297
297
|
version: b.version
|
|
298
298
|
})),
|
|
299
|
-
modules:
|
|
299
|
+
modules: I == null ? void 0 : I.map((b) => ({
|
|
300
300
|
moduleName: b.name,
|
|
301
301
|
modulePath: b.path,
|
|
302
302
|
assets: b.assets
|
|
303
303
|
}))
|
|
304
304
|
};
|
|
305
|
-
if ((
|
|
305
|
+
if ((n = r.metaData) != null && n.prefetchInterface) {
|
|
306
306
|
const b = r.metaData.prefetchInterface;
|
|
307
307
|
S = _extends$2({}, S, {
|
|
308
308
|
prefetchInterface: b
|
|
309
309
|
});
|
|
310
310
|
}
|
|
311
|
-
if ((
|
|
312
|
-
const { path: b, name: $, type:
|
|
311
|
+
if ((o = r.metaData) != null && o.prefetchEntry) {
|
|
312
|
+
const { path: b, name: $, type: w } = r.metaData.prefetchEntry;
|
|
313
313
|
S = _extends$2({}, S, {
|
|
314
314
|
prefetchEntry: simpleJoinRemoteEntry(b, $),
|
|
315
|
-
prefetchEntryType:
|
|
315
|
+
prefetchEntryType: w
|
|
316
316
|
});
|
|
317
317
|
}
|
|
318
318
|
if ("publicPath" in r.metaData ? i = _extends$2({}, S, {
|
|
319
319
|
publicPath: c()
|
|
320
320
|
}) : i = _extends$2({}, S, {
|
|
321
321
|
getPublicPath: c()
|
|
322
|
-
}),
|
|
323
|
-
const b = simpleJoinRemoteEntry(
|
|
324
|
-
i.ssrRemoteEntry = b, i.ssrRemoteEntryType =
|
|
322
|
+
}), v) {
|
|
323
|
+
const b = simpleJoinRemoteEntry(v.path, v.name);
|
|
324
|
+
i.ssrRemoteEntry = b, i.ssrRemoteEntryType = v.type || "commonjs-module";
|
|
325
325
|
}
|
|
326
326
|
return i;
|
|
327
327
|
}
|
|
@@ -331,22 +331,22 @@ function isManifestProvider(r) {
|
|
|
331
331
|
async function safeWrapper(r, t) {
|
|
332
332
|
try {
|
|
333
333
|
return await r();
|
|
334
|
-
} catch (
|
|
335
|
-
warn$1(
|
|
334
|
+
} catch (n) {
|
|
335
|
+
warn$1(n);
|
|
336
336
|
return;
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
339
|
function isStaticResourcesEqual(r, t) {
|
|
340
|
-
const
|
|
341
|
-
return
|
|
340
|
+
const n = /^(https?:)?\/\//i, o = r.replace(n, "").replace(/\/$/, ""), s = t.replace(n, "").replace(/\/$/, "");
|
|
341
|
+
return o === s;
|
|
342
342
|
}
|
|
343
343
|
function createScript(r) {
|
|
344
|
-
let t = null,
|
|
345
|
-
const
|
|
346
|
-
for (let i = 0; i <
|
|
347
|
-
const c =
|
|
344
|
+
let t = null, n = !0, o = 2e4, s;
|
|
345
|
+
const a = document.getElementsByTagName("script");
|
|
346
|
+
for (let i = 0; i < a.length; i++) {
|
|
347
|
+
const c = a[i], u = c.getAttribute("src");
|
|
348
348
|
if (u && isStaticResourcesEqual(u, r.url)) {
|
|
349
|
-
t = c,
|
|
349
|
+
t = c, n = !1;
|
|
350
350
|
break;
|
|
351
351
|
}
|
|
352
352
|
}
|
|
@@ -354,11 +354,11 @@ function createScript(r) {
|
|
|
354
354
|
const i = r.attrs;
|
|
355
355
|
t = document.createElement("script"), t.type = (i == null ? void 0 : i.type) === "module" ? "module" : "text/javascript";
|
|
356
356
|
let c;
|
|
357
|
-
r.createScriptHook && (c = r.createScriptHook(r.url, r.attrs), c instanceof HTMLScriptElement ? t = c : typeof c == "object" && ("script" in c && c.script && (t = c.script), "timeout" in c && c.timeout && (
|
|
357
|
+
r.createScriptHook && (c = r.createScriptHook(r.url, r.attrs), c instanceof HTMLScriptElement ? t = c : typeof c == "object" && ("script" in c && c.script && (t = c.script), "timeout" in c && c.timeout && (o = c.timeout))), t.src || (t.src = r.url), i && !c && Object.keys(i).forEach((u) => {
|
|
358
358
|
t && (u === "async" || u === "defer" ? t[u] = i[u] : t.getAttribute(u) || t.setAttribute(u, i[u]));
|
|
359
359
|
});
|
|
360
360
|
}
|
|
361
|
-
const
|
|
361
|
+
const l = async (i, c) => {
|
|
362
362
|
var u;
|
|
363
363
|
if (clearTimeout(s), t && (t.onerror = null, t.onload = null, safeWrapper(() => {
|
|
364
364
|
const { needDeleteScript: m = !0 } = r;
|
|
@@ -375,73 +375,73 @@ function createScript(r) {
|
|
|
375
375
|
}
|
|
376
376
|
r == null || (u = r.cb) == null || u.call(r);
|
|
377
377
|
};
|
|
378
|
-
return t.onerror =
|
|
379
|
-
|
|
380
|
-
},
|
|
378
|
+
return t.onerror = l.bind(null, t.onerror), t.onload = l.bind(null, t.onload), s = setTimeout(() => {
|
|
379
|
+
l(null, new Error(`Remote script "${r.url}" time-outed.`));
|
|
380
|
+
}, o), {
|
|
381
381
|
script: t,
|
|
382
|
-
needAttach:
|
|
382
|
+
needAttach: n
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
385
|
function createLink(r) {
|
|
386
|
-
let t = null,
|
|
387
|
-
const
|
|
388
|
-
for (let
|
|
389
|
-
const
|
|
386
|
+
let t = null, n = !0;
|
|
387
|
+
const o = document.getElementsByTagName("link");
|
|
388
|
+
for (let a = 0; a < o.length; a++) {
|
|
389
|
+
const l = o[a], i = l.getAttribute("href"), c = l.getAttribute("ref");
|
|
390
390
|
if (i && isStaticResourcesEqual(i, r.url) && c === r.attrs.ref) {
|
|
391
|
-
t =
|
|
391
|
+
t = l, n = !1;
|
|
392
392
|
break;
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
395
|
if (!t) {
|
|
396
396
|
t = document.createElement("link"), t.setAttribute("href", r.url);
|
|
397
|
-
let
|
|
398
|
-
const
|
|
399
|
-
r.createLinkHook && (
|
|
400
|
-
t && !t.getAttribute(i) && t.setAttribute(i,
|
|
397
|
+
let a;
|
|
398
|
+
const l = r.attrs;
|
|
399
|
+
r.createLinkHook && (a = r.createLinkHook(r.url, l), a instanceof HTMLLinkElement && (t = a)), l && !a && Object.keys(l).forEach((i) => {
|
|
400
|
+
t && !t.getAttribute(i) && t.setAttribute(i, l[i]);
|
|
401
401
|
});
|
|
402
402
|
}
|
|
403
|
-
const s = (
|
|
403
|
+
const s = (a, l) => {
|
|
404
404
|
if (t && (t.onerror = null, t.onload = null, safeWrapper(() => {
|
|
405
405
|
const { needDeleteLink: i = !0 } = r;
|
|
406
406
|
i && t != null && t.parentNode && t.parentNode.removeChild(t);
|
|
407
|
-
}),
|
|
408
|
-
const i = l
|
|
407
|
+
}), a)) {
|
|
408
|
+
const i = a(l);
|
|
409
409
|
return r.cb(), i;
|
|
410
410
|
}
|
|
411
411
|
r.cb();
|
|
412
412
|
};
|
|
413
413
|
return t.onerror = s.bind(null, t.onerror), t.onload = s.bind(null, t.onload), {
|
|
414
414
|
link: t,
|
|
415
|
-
needAttach:
|
|
415
|
+
needAttach: n
|
|
416
416
|
};
|
|
417
417
|
}
|
|
418
418
|
function loadScript(r, t) {
|
|
419
|
-
const { attrs:
|
|
420
|
-
return new Promise((s,
|
|
421
|
-
const { script:
|
|
419
|
+
const { attrs: n = {}, createScriptHook: o } = t;
|
|
420
|
+
return new Promise((s, a) => {
|
|
421
|
+
const { script: l, needAttach: i } = createScript({
|
|
422
422
|
url: r,
|
|
423
423
|
cb: s,
|
|
424
424
|
attrs: _extends$2({
|
|
425
425
|
fetchpriority: "high"
|
|
426
|
-
},
|
|
427
|
-
createScriptHook:
|
|
426
|
+
}, n),
|
|
427
|
+
createScriptHook: o,
|
|
428
428
|
needDeleteScript: !0
|
|
429
429
|
});
|
|
430
|
-
i && document.head.appendChild(
|
|
430
|
+
i && document.head.appendChild(l);
|
|
431
431
|
});
|
|
432
432
|
}
|
|
433
433
|
function importNodeModule(r) {
|
|
434
434
|
if (!r)
|
|
435
435
|
throw new Error("import specifier is required");
|
|
436
|
-
return new Function("name", "return import(name)")(r).then((
|
|
437
|
-
throw console.error(`Error importing module ${r}:`,
|
|
436
|
+
return new Function("name", "return import(name)")(r).then((n) => n).catch((n) => {
|
|
437
|
+
throw console.error(`Error importing module ${r}:`, n), n;
|
|
438
438
|
});
|
|
439
439
|
}
|
|
440
440
|
const loadNodeFetch = async () => {
|
|
441
441
|
const r = await importNodeModule("node-fetch");
|
|
442
442
|
return r.default || r;
|
|
443
|
-
}, lazyLoaderHookFetch = async (r, t,
|
|
444
|
-
const s = await ((
|
|
443
|
+
}, lazyLoaderHookFetch = async (r, t, n) => {
|
|
444
|
+
const s = await ((a, l) => n.lifecycle.fetch.emit(a, l))(r, t || {});
|
|
445
445
|
return !s || !(s instanceof Response) ? (typeof fetch > "u" ? await loadNodeFetch() : fetch)(r, t || {}) : s;
|
|
446
446
|
};
|
|
447
447
|
function createScriptNode(url, cb, attrs, loaderHook) {
|
|
@@ -502,38 +502,38 @@ function createScriptNode(url, cb, attrs, loaderHook) {
|
|
|
502
502
|
});
|
|
503
503
|
}
|
|
504
504
|
function loadScriptNode(r, t) {
|
|
505
|
-
return new Promise((
|
|
506
|
-
createScriptNode(r, (s,
|
|
505
|
+
return new Promise((n, o) => {
|
|
506
|
+
createScriptNode(r, (s, a) => {
|
|
507
507
|
if (s)
|
|
508
|
-
|
|
508
|
+
o(s);
|
|
509
509
|
else {
|
|
510
|
-
var
|
|
511
|
-
const c = (t == null || (
|
|
512
|
-
|
|
510
|
+
var l, i;
|
|
511
|
+
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;
|
|
512
|
+
n(u);
|
|
513
513
|
}
|
|
514
514
|
}, t.attrs, t.loaderHook);
|
|
515
515
|
});
|
|
516
516
|
}
|
|
517
517
|
async function loadModule(r, t) {
|
|
518
|
-
const { fetch:
|
|
518
|
+
const { fetch: n, vm: o } = t, a = await (await n(r)).text(), l = new o.SourceTextModule(a, {
|
|
519
519
|
// @ts-ignore
|
|
520
520
|
importModuleDynamically: async (i, c) => {
|
|
521
521
|
const u = new URL(i, r).href;
|
|
522
522
|
return loadModule(u, t);
|
|
523
523
|
}
|
|
524
524
|
});
|
|
525
|
-
return await
|
|
525
|
+
return await l.link(async (i) => {
|
|
526
526
|
const c = new URL(i, r).href;
|
|
527
527
|
return await loadModule(c, t);
|
|
528
|
-
}),
|
|
528
|
+
}), l;
|
|
529
529
|
}
|
|
530
530
|
const LoggerInstance = createLogger("[ Module Federation Bridge Vue3 ]");
|
|
531
531
|
function _extends$1() {
|
|
532
532
|
return _extends$1 = Object.assign || function(t) {
|
|
533
|
-
for (var
|
|
534
|
-
var
|
|
535
|
-
for (var s in
|
|
536
|
-
Object.prototype.hasOwnProperty.call(
|
|
533
|
+
for (var n = 1; n < arguments.length; n++) {
|
|
534
|
+
var o = arguments[n];
|
|
535
|
+
for (var s in o)
|
|
536
|
+
Object.prototype.hasOwnProperty.call(o, s) && (t[s] = o[s]);
|
|
537
537
|
}
|
|
538
538
|
return t;
|
|
539
539
|
}, _extends$1.apply(this, arguments);
|
|
@@ -541,10 +541,10 @@ function _extends$1() {
|
|
|
541
541
|
function _object_without_properties_loose(r, t) {
|
|
542
542
|
if (r == null)
|
|
543
543
|
return {};
|
|
544
|
-
var
|
|
545
|
-
for (
|
|
546
|
-
s =
|
|
547
|
-
return
|
|
544
|
+
var n = {}, o = Object.keys(r), s, a;
|
|
545
|
+
for (a = 0; a < o.length; a++)
|
|
546
|
+
s = o[a], !(t.indexOf(s) >= 0) && (n[s] = r[s]);
|
|
547
|
+
return n;
|
|
548
548
|
}
|
|
549
549
|
function getBuilderId() {
|
|
550
550
|
return typeof FEDERATION_BUILD_IDENTIFIER < "u" ? FEDERATION_BUILD_IDENTIFIER : "";
|
|
@@ -560,7 +560,7 @@ function warn(r) {
|
|
|
560
560
|
r instanceof Error && (r.message = `${LOG_CATEGORY}: ${r.message}`), logger.warn(r);
|
|
561
561
|
}
|
|
562
562
|
function addUniqueItem(r, t) {
|
|
563
|
-
return r.findIndex((
|
|
563
|
+
return r.findIndex((n) => n === t) === -1 && r.push(t), r;
|
|
564
564
|
}
|
|
565
565
|
function getFMId(r) {
|
|
566
566
|
return "version" in r && r.version ? `${r.name}:${r.version}` : "entry" in r && r.entry ? `${r.name}:${r.entry}` : `${r.name}`;
|
|
@@ -600,8 +600,8 @@ function getRemoteEntryInfoFromSnapshot(r) {
|
|
|
600
600
|
} : t;
|
|
601
601
|
}
|
|
602
602
|
const processModuleAlias = (r, t) => {
|
|
603
|
-
let
|
|
604
|
-
return r.endsWith("/") ?
|
|
603
|
+
let n;
|
|
604
|
+
return r.endsWith("/") ? n = r.slice(0, -1) : n = r, t.startsWith(".") && (t = t.slice(1)), n = n + t, n;
|
|
605
605
|
}, CurrentGlobal = typeof globalThis == "object" ? globalThis : window, nativeGlobal = (() => {
|
|
606
606
|
try {
|
|
607
607
|
return document.defaultView;
|
|
@@ -609,9 +609,9 @@ const processModuleAlias = (r, t) => {
|
|
|
609
609
|
return CurrentGlobal;
|
|
610
610
|
}
|
|
611
611
|
})(), Global = nativeGlobal;
|
|
612
|
-
function definePropertyGlobalVal(r, t,
|
|
612
|
+
function definePropertyGlobalVal(r, t, n) {
|
|
613
613
|
Object.defineProperty(r, t, {
|
|
614
|
-
value:
|
|
614
|
+
value: n,
|
|
615
615
|
configurable: !1,
|
|
616
616
|
writable: !0
|
|
617
617
|
});
|
|
@@ -622,7 +622,7 @@ function includeOwnProperty(r, t) {
|
|
|
622
622
|
includeOwnProperty(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__") || definePropertyGlobalVal(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});
|
|
623
623
|
const globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;
|
|
624
624
|
function setGlobalDefaultVal(r) {
|
|
625
|
-
var t,
|
|
625
|
+
var t, n, o, s, a, l;
|
|
626
626
|
includeOwnProperty(r, "__VMOK__") && !includeOwnProperty(r, "__FEDERATION__") && definePropertyGlobalVal(r, "__FEDERATION__", r.__VMOK__), includeOwnProperty(r, "__FEDERATION__") || (definePropertyGlobalVal(r, "__FEDERATION__", {
|
|
627
627
|
__GLOBAL_PLUGIN__: [],
|
|
628
628
|
__INSTANCES__: [],
|
|
@@ -634,20 +634,20 @@ function setGlobalDefaultVal(r) {
|
|
|
634
634
|
var i;
|
|
635
635
|
(i = (t = r.__FEDERATION__).__GLOBAL_PLUGIN__) != null || (t.__GLOBAL_PLUGIN__ = []);
|
|
636
636
|
var c;
|
|
637
|
-
(c = (
|
|
637
|
+
(c = (n = r.__FEDERATION__).__INSTANCES__) != null || (n.__INSTANCES__ = []);
|
|
638
638
|
var u;
|
|
639
|
-
(u = (
|
|
639
|
+
(u = (o = r.__FEDERATION__).moduleInfo) != null || (o.moduleInfo = {});
|
|
640
640
|
var d;
|
|
641
641
|
(d = (s = r.__FEDERATION__).__SHARE__) != null || (s.__SHARE__ = {});
|
|
642
642
|
var p;
|
|
643
|
-
(p = (
|
|
643
|
+
(p = (a = r.__FEDERATION__).__MANIFEST_LOADING__) != null || (a.__MANIFEST_LOADING__ = {});
|
|
644
644
|
var m;
|
|
645
|
-
(m = (
|
|
645
|
+
(m = (l = r.__FEDERATION__).__PRELOADED_MAP__) != null || (l.__PRELOADED_MAP__ = /* @__PURE__ */ new Map());
|
|
646
646
|
}
|
|
647
647
|
setGlobalDefaultVal(CurrentGlobal);
|
|
648
648
|
setGlobalDefaultVal(nativeGlobal);
|
|
649
649
|
function setGlobalFederationConstructor(r, t = isDebugMode()) {
|
|
650
|
-
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = r, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.8.
|
|
650
|
+
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = r, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.8.5");
|
|
651
651
|
}
|
|
652
652
|
function getInfoWithoutType(r, t) {
|
|
653
653
|
if (typeof t == "string") {
|
|
@@ -657,9 +657,9 @@ function getInfoWithoutType(r, t) {
|
|
|
657
657
|
key: t
|
|
658
658
|
};
|
|
659
659
|
{
|
|
660
|
-
const
|
|
661
|
-
for (const s of
|
|
662
|
-
const [
|
|
660
|
+
const o = Object.keys(r);
|
|
661
|
+
for (const s of o) {
|
|
662
|
+
const [a, l] = s.split(":"), i = `${a}:${t}`, c = r[i];
|
|
663
663
|
if (c)
|
|
664
664
|
return {
|
|
665
665
|
value: c,
|
|
@@ -675,28 +675,28 @@ function getInfoWithoutType(r, t) {
|
|
|
675
675
|
throw new Error("key must be string");
|
|
676
676
|
}
|
|
677
677
|
const getGlobalSnapshot = () => nativeGlobal.__FEDERATION__.moduleInfo, getTargetSnapshotInfoByModuleInfo = (r, t) => {
|
|
678
|
-
const
|
|
679
|
-
if (
|
|
680
|
-
return
|
|
678
|
+
const n = getFMId(r), o = getInfoWithoutType(t, n).value;
|
|
679
|
+
if (o && !o.version && "version" in r && r.version && (o.version = r.version), o)
|
|
680
|
+
return o;
|
|
681
681
|
if ("version" in r && r.version) {
|
|
682
|
-
const { version: s } = r,
|
|
682
|
+
const { version: s } = r, a = _object_without_properties_loose(r, [
|
|
683
683
|
"version"
|
|
684
|
-
]),
|
|
684
|
+
]), l = getFMId(a), i = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, l).value;
|
|
685
685
|
if ((i == null ? void 0 : i.version) === s)
|
|
686
686
|
return i;
|
|
687
687
|
}
|
|
688
688
|
}, getGlobalSnapshotInfoByModuleInfo = (r) => getTargetSnapshotInfoByModuleInfo(r, nativeGlobal.__FEDERATION__.moduleInfo), setGlobalSnapshotInfoByModuleInfo = (r, t) => {
|
|
689
|
-
const
|
|
690
|
-
return nativeGlobal.__FEDERATION__.moduleInfo[
|
|
689
|
+
const n = getFMId(r);
|
|
690
|
+
return nativeGlobal.__FEDERATION__.moduleInfo[n] = t, nativeGlobal.__FEDERATION__.moduleInfo;
|
|
691
691
|
}, addGlobalSnapshot = (r) => (nativeGlobal.__FEDERATION__.moduleInfo = _extends$1({}, nativeGlobal.__FEDERATION__.moduleInfo, r), () => {
|
|
692
692
|
const t = Object.keys(r);
|
|
693
|
-
for (const
|
|
694
|
-
delete nativeGlobal.__FEDERATION__.moduleInfo[
|
|
693
|
+
for (const n of t)
|
|
694
|
+
delete nativeGlobal.__FEDERATION__.moduleInfo[n];
|
|
695
695
|
}), getRemoteEntryExports = (r, t) => {
|
|
696
|
-
const
|
|
696
|
+
const n = t || `__FEDERATION_${r}:custom__`, o = CurrentGlobal[n];
|
|
697
697
|
return {
|
|
698
|
-
remoteEntryKey:
|
|
699
|
-
entryExports:
|
|
698
|
+
remoteEntryKey: n,
|
|
699
|
+
entryExports: o
|
|
700
700
|
};
|
|
701
701
|
}, getGlobalHostPlugins = () => nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__, getPreloaded = (r) => CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.get(r), setPreloaded = (r) => CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.set(r, !0), DEFAULT_SCOPE = "default", DEFAULT_REMOTE_TYPE = "global", buildIdentifier = "[0-9A-Za-z-]+", build = `(?:\\+(${buildIdentifier}(?:\\.${buildIdentifier})*))`, numericIdentifier = "0|[1-9]\\d*", numericIdentifierLoose = "[0-9]+", nonNumericIdentifier = "\\d*[a-zA-Z-][a-zA-Z0-9-]*", preReleaseIdentifierLoose = `(?:${numericIdentifierLoose}|${nonNumericIdentifier})`, preReleaseLoose = `(?:-?(${preReleaseIdentifierLoose}(?:\\.${preReleaseIdentifierLoose})*))`, preReleaseIdentifier = `(?:${numericIdentifier}|${nonNumericIdentifier})`, preRelease = `(?:-(${preReleaseIdentifier}(?:\\.${preReleaseIdentifier})*))`, xRangeIdentifier = `${numericIdentifier}|x|X|\\*`, xRangePlain = `[v=\\s]*(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:${preRelease})?${build}?)?)?`, hyphenRange = `^\\s*(${xRangePlain})\\s+-\\s+(${xRangePlain})\\s*$`, mainVersionLoose = `(${numericIdentifierLoose})\\.(${numericIdentifierLoose})\\.(${numericIdentifierLoose})`, loosePlain = `[v=\\s]*${mainVersionLoose}${preReleaseLoose}?${build}?`, gtlt = "((?:<|>)?=?)", comparatorTrim = `(\\s*)${gtlt}\\s*(${loosePlain}|${xRangePlain})`, loneTilde = "(?:~>?)", tildeTrim = `(\\s*)${loneTilde}\\s+`, loneCaret = "(?:\\^)", caretTrim = `(\\s*)${loneCaret}\\s+`, star = "(<|>)?=?\\s*\\*", caret = `^${loneCaret}${xRangePlain}$`, mainVersion = `(${numericIdentifier})\\.(${numericIdentifier})\\.(${numericIdentifier})`, fullPlain = `v?${mainVersion}${preRelease}?${build}?`, tilde = `^${loneTilde}${xRangePlain}$`, xRange = `^${gtlt}\\s*${xRangePlain}$`, comparator = `^${gtlt}\\s*(${fullPlain})$|^$`, gte0 = "^\\s*>=\\s*0.0.0\\s*$";
|
|
702
702
|
function parseRegex(r) {
|
|
@@ -706,17 +706,17 @@ function isXVersion(r) {
|
|
|
706
706
|
return !r || r.toLowerCase() === "x" || r === "*";
|
|
707
707
|
}
|
|
708
708
|
function pipe(...r) {
|
|
709
|
-
return (t) => r.reduce((
|
|
709
|
+
return (t) => r.reduce((n, o) => o(n), t);
|
|
710
710
|
}
|
|
711
711
|
function extractComparator(r) {
|
|
712
712
|
return r.match(parseRegex(comparator));
|
|
713
713
|
}
|
|
714
|
-
function combineVersion(r, t,
|
|
715
|
-
const s = `${r}.${t}.${
|
|
716
|
-
return
|
|
714
|
+
function combineVersion(r, t, n, o) {
|
|
715
|
+
const s = `${r}.${t}.${n}`;
|
|
716
|
+
return o ? `${s}-${o}` : s;
|
|
717
717
|
}
|
|
718
718
|
function parseHyphen(r) {
|
|
719
|
-
return r.replace(parseRegex(hyphenRange), (t,
|
|
719
|
+
return r.replace(parseRegex(hyphenRange), (t, n, o, s, a, l, i, c, u, d, p, m) => (isXVersion(o) ? n = "" : isXVersion(s) ? n = `>=${o}.0.0` : isXVersion(a) ? n = `>=${o}.${s}.0` : n = `>=${n}`, isXVersion(u) ? c = "" : isXVersion(d) ? c = `<${Number(u) + 1}.0.0-0` : isXVersion(p) ? c = `<${u}.${Number(d) + 1}.0-0` : m ? c = `<=${u}.${d}.${p}-${m}` : c = `<=${c}`, `${n} ${c}`.trim()));
|
|
720
720
|
}
|
|
721
721
|
function parseComparatorTrim(r) {
|
|
722
722
|
return r.replace(parseRegex(comparatorTrim), "$1$2$3");
|
|
@@ -728,15 +728,15 @@ function parseCaretTrim(r) {
|
|
|
728
728
|
return r.replace(parseRegex(caretTrim), "$1^");
|
|
729
729
|
}
|
|
730
730
|
function parseCarets(r) {
|
|
731
|
-
return r.trim().split(/\s+/).map((t) => t.replace(parseRegex(caret), (
|
|
731
|
+
return r.trim().split(/\s+/).map((t) => t.replace(parseRegex(caret), (n, o, s, a, l) => isXVersion(o) ? "" : isXVersion(s) ? `>=${o}.0.0 <${Number(o) + 1}.0.0-0` : isXVersion(a) ? o === "0" ? `>=${o}.${s}.0 <${o}.${Number(s) + 1}.0-0` : `>=${o}.${s}.0 <${Number(o) + 1}.0.0-0` : l ? o === "0" ? s === "0" ? `>=${o}.${s}.${a}-${l} <${o}.${s}.${Number(a) + 1}-0` : `>=${o}.${s}.${a}-${l} <${o}.${Number(s) + 1}.0-0` : `>=${o}.${s}.${a}-${l} <${Number(o) + 1}.0.0-0` : o === "0" ? s === "0" ? `>=${o}.${s}.${a} <${o}.${s}.${Number(a) + 1}-0` : `>=${o}.${s}.${a} <${o}.${Number(s) + 1}.0-0` : `>=${o}.${s}.${a} <${Number(o) + 1}.0.0-0`)).join(" ");
|
|
732
732
|
}
|
|
733
733
|
function parseTildes(r) {
|
|
734
|
-
return r.trim().split(/\s+/).map((t) => t.replace(parseRegex(tilde), (
|
|
734
|
+
return r.trim().split(/\s+/).map((t) => t.replace(parseRegex(tilde), (n, o, s, a, l) => isXVersion(o) ? "" : isXVersion(s) ? `>=${o}.0.0 <${Number(o) + 1}.0.0-0` : isXVersion(a) ? `>=${o}.${s}.0 <${o}.${Number(s) + 1}.0-0` : l ? `>=${o}.${s}.${a}-${l} <${o}.${Number(s) + 1}.0-0` : `>=${o}.${s}.${a} <${o}.${Number(s) + 1}.0-0`)).join(" ");
|
|
735
735
|
}
|
|
736
736
|
function parseXRanges(r) {
|
|
737
|
-
return r.split(/\s+/).map((t) => t.trim().replace(parseRegex(xRange), (
|
|
738
|
-
const c = isXVersion(s), u = c || isXVersion(
|
|
739
|
-
return
|
|
737
|
+
return r.split(/\s+/).map((t) => t.trim().replace(parseRegex(xRange), (n, o, s, a, l, i) => {
|
|
738
|
+
const c = isXVersion(s), u = c || isXVersion(a), d = u || isXVersion(l);
|
|
739
|
+
return o === "=" && d && (o = ""), i = "", c ? o === ">" || o === "<" ? "<0.0.0-0" : "*" : o && d ? (u && (a = 0), l = 0, o === ">" ? (o = ">=", u ? (s = Number(s) + 1, a = 0, l = 0) : (a = Number(a) + 1, l = 0)) : o === "<=" && (o = "<", u ? s = Number(s) + 1 : a = Number(a) + 1), o === "<" && (i = "-0"), `${o + s}.${a}.${l}${i}`) : u ? `>=${s}.0.0${i} <${Number(s) + 1}.0.0-0` : d ? `>=${s}.${a}.0${i} <${s}.${Number(a) + 1}.0-0` : n;
|
|
740
740
|
})).join(" ");
|
|
741
741
|
}
|
|
742
742
|
function parseStar(r) {
|
|
@@ -749,17 +749,17 @@ function compareAtom(r, t) {
|
|
|
749
749
|
return r = Number(r) || r, t = Number(t) || t, r > t ? 1 : r === t ? 0 : -1;
|
|
750
750
|
}
|
|
751
751
|
function comparePreRelease(r, t) {
|
|
752
|
-
const { preRelease:
|
|
753
|
-
if (
|
|
752
|
+
const { preRelease: n } = r, { preRelease: o } = t;
|
|
753
|
+
if (n === void 0 && o)
|
|
754
754
|
return 1;
|
|
755
|
-
if (
|
|
755
|
+
if (n && o === void 0)
|
|
756
756
|
return -1;
|
|
757
|
-
if (
|
|
757
|
+
if (n === void 0 && o === void 0)
|
|
758
758
|
return 0;
|
|
759
|
-
for (let s = 0,
|
|
760
|
-
const
|
|
761
|
-
if (
|
|
762
|
-
return
|
|
759
|
+
for (let s = 0, a = n.length; s <= a; s++) {
|
|
760
|
+
const l = n[s], i = o[s];
|
|
761
|
+
if (l !== i)
|
|
762
|
+
return l === void 0 && i === void 0 ? 0 : l ? i ? compareAtom(l, i) : -1 : 1;
|
|
763
763
|
}
|
|
764
764
|
return 0;
|
|
765
765
|
}
|
|
@@ -829,11 +829,11 @@ function parseRange(r) {
|
|
|
829
829
|
function satisfy(r, t) {
|
|
830
830
|
if (!r)
|
|
831
831
|
return !1;
|
|
832
|
-
const s = parseRange(t).split(" ").map((m) => parseComparatorString(m)).join(" ").split(/\s+/).map((m) => parseGTE0(m)),
|
|
833
|
-
if (!
|
|
832
|
+
const s = parseRange(t).split(" ").map((m) => parseComparatorString(m)).join(" ").split(/\s+/).map((m) => parseGTE0(m)), a = extractComparator(r);
|
|
833
|
+
if (!a)
|
|
834
834
|
return !1;
|
|
835
|
-
const [,
|
|
836
|
-
operator:
|
|
835
|
+
const [, l, , i, c, u, d] = a, p = {
|
|
836
|
+
operator: l,
|
|
837
837
|
version: combineVersion(i, c, u, d),
|
|
838
838
|
major: i,
|
|
839
839
|
minor: c,
|
|
@@ -844,25 +844,25 @@ function satisfy(r, t) {
|
|
|
844
844
|
const y = extractComparator(m);
|
|
845
845
|
if (!y)
|
|
846
846
|
return !1;
|
|
847
|
-
const [, _, , R, g, E,
|
|
847
|
+
const [, _, , R, g, E, v] = y, I = {
|
|
848
848
|
operator: _,
|
|
849
|
-
version: combineVersion(R, g, E,
|
|
849
|
+
version: combineVersion(R, g, E, v),
|
|
850
850
|
major: R,
|
|
851
851
|
minor: g,
|
|
852
852
|
patch: E,
|
|
853
|
-
preRelease:
|
|
853
|
+
preRelease: v == null ? void 0 : v.split(".")
|
|
854
854
|
};
|
|
855
|
-
if (!compare(
|
|
855
|
+
if (!compare(I, p))
|
|
856
856
|
return !1;
|
|
857
857
|
}
|
|
858
858
|
return !0;
|
|
859
859
|
}
|
|
860
|
-
function formatShare(r, t,
|
|
860
|
+
function formatShare(r, t, n, o) {
|
|
861
861
|
let s;
|
|
862
862
|
"get" in r ? s = r.get : "lib" in r ? s = () => Promise.resolve(r.lib) : s = () => Promise.resolve(() => {
|
|
863
|
-
throw new Error(`Can not get shared '${
|
|
863
|
+
throw new Error(`Can not get shared '${n}'!`);
|
|
864
864
|
}), r.strategy && warn('"shared.strategy is deprecated, please set in initOptions.shareStrategy instead!"');
|
|
865
|
-
var
|
|
865
|
+
var a, l, i;
|
|
866
866
|
return _extends$1({
|
|
867
867
|
deps: [],
|
|
868
868
|
useIn: [],
|
|
@@ -877,76 +877,76 @@ function formatShare(r, t, o, n) {
|
|
|
877
877
|
}, r.shareConfig),
|
|
878
878
|
get: s,
|
|
879
879
|
loaded: r != null && r.loaded || "lib" in r ? !0 : void 0,
|
|
880
|
-
version: (
|
|
880
|
+
version: (a = r.version) != null ? a : "0",
|
|
881
881
|
scope: Array.isArray(r.scope) ? r.scope : [
|
|
882
|
-
(
|
|
882
|
+
(l = r.scope) != null ? l : "default"
|
|
883
883
|
],
|
|
884
|
-
strategy: ((i = r.strategy) != null ? i :
|
|
884
|
+
strategy: ((i = r.strategy) != null ? i : o) || "version-first"
|
|
885
885
|
});
|
|
886
886
|
}
|
|
887
887
|
function formatShareConfigs(r, t) {
|
|
888
|
-
const
|
|
889
|
-
const c = arrayOptions(
|
|
890
|
-
return
|
|
891
|
-
|
|
892
|
-
}),
|
|
893
|
-
}, {}),
|
|
894
|
-
return Object.keys(s).forEach((
|
|
895
|
-
l
|
|
896
|
-
l
|
|
897
|
-
}) : l
|
|
888
|
+
const n = t.shared || {}, o = t.name, s = Object.keys(n).reduce((l, i) => {
|
|
889
|
+
const c = arrayOptions(n[i]);
|
|
890
|
+
return l[i] = l[i] || [], c.forEach((u) => {
|
|
891
|
+
l[i].push(formatShare(u, o, i, t.shareStrategy));
|
|
892
|
+
}), l;
|
|
893
|
+
}, {}), a = _extends$1({}, r.shared);
|
|
894
|
+
return Object.keys(s).forEach((l) => {
|
|
895
|
+
a[l] ? s[l].forEach((i) => {
|
|
896
|
+
a[l].find((u) => u.version === i.version) || a[l].push(i);
|
|
897
|
+
}) : a[l] = s[l];
|
|
898
898
|
}), {
|
|
899
|
-
shared:
|
|
899
|
+
shared: a,
|
|
900
900
|
shareInfos: s
|
|
901
901
|
};
|
|
902
902
|
}
|
|
903
903
|
function versionLt(r, t) {
|
|
904
|
-
const
|
|
905
|
-
if (!Number.isNaN(Number(
|
|
906
|
-
const
|
|
907
|
-
let
|
|
908
|
-
for (let i = 0; i < 3 -
|
|
909
|
-
|
|
910
|
-
return
|
|
904
|
+
const n = (o) => {
|
|
905
|
+
if (!Number.isNaN(Number(o))) {
|
|
906
|
+
const a = o.split(".");
|
|
907
|
+
let l = o;
|
|
908
|
+
for (let i = 0; i < 3 - a.length; i++)
|
|
909
|
+
l += ".0";
|
|
910
|
+
return l;
|
|
911
911
|
}
|
|
912
|
-
return
|
|
912
|
+
return o;
|
|
913
913
|
};
|
|
914
|
-
return !!satisfy(
|
|
914
|
+
return !!satisfy(n(r), `<=${n(t)}`);
|
|
915
915
|
}
|
|
916
916
|
const findVersion = (r, t) => {
|
|
917
|
-
const
|
|
918
|
-
return versionLt(
|
|
917
|
+
const n = t || function(o, s) {
|
|
918
|
+
return versionLt(o, s);
|
|
919
919
|
};
|
|
920
|
-
return Object.keys(r).reduce((
|
|
920
|
+
return Object.keys(r).reduce((o, s) => !o || n(o, s) || o === "0" ? s : o, 0);
|
|
921
921
|
}, isLoaded = (r) => !!r.loaded || typeof r.lib == "function", isLoading = (r) => !!r.loading;
|
|
922
|
-
function findSingletonVersionOrderByVersion(r, t,
|
|
923
|
-
const
|
|
924
|
-
return !isLoaded(
|
|
922
|
+
function findSingletonVersionOrderByVersion(r, t, n) {
|
|
923
|
+
const o = r[t][n], s = function(a, l) {
|
|
924
|
+
return !isLoaded(o[a]) && versionLt(a, l);
|
|
925
925
|
};
|
|
926
|
-
return findVersion(r[t][
|
|
926
|
+
return findVersion(r[t][n], s);
|
|
927
927
|
}
|
|
928
|
-
function findSingletonVersionOrderByLoaded(r, t,
|
|
929
|
-
const
|
|
928
|
+
function findSingletonVersionOrderByLoaded(r, t, n) {
|
|
929
|
+
const o = r[t][n], s = function(a, l) {
|
|
930
930
|
const i = (c) => isLoaded(c) || isLoading(c);
|
|
931
|
-
return i(
|
|
931
|
+
return i(o[l]) ? i(o[a]) ? !!versionLt(a, l) : !0 : i(o[a]) ? !1 : versionLt(a, l);
|
|
932
932
|
};
|
|
933
|
-
return findVersion(r[t][
|
|
933
|
+
return findVersion(r[t][n], s);
|
|
934
934
|
}
|
|
935
935
|
function getFindShareFunction(r) {
|
|
936
936
|
return r === "loaded-first" ? findSingletonVersionOrderByLoaded : findSingletonVersionOrderByVersion;
|
|
937
937
|
}
|
|
938
|
-
function getRegisteredShare(r, t,
|
|
938
|
+
function getRegisteredShare(r, t, n, o) {
|
|
939
939
|
if (!r)
|
|
940
940
|
return;
|
|
941
|
-
const { shareConfig: s, scope:
|
|
942
|
-
|
|
941
|
+
const { shareConfig: s, scope: a = DEFAULT_SCOPE, strategy: l } = n, i = Array.isArray(a) ? a : [
|
|
942
|
+
a
|
|
943
943
|
];
|
|
944
944
|
for (const c of i)
|
|
945
945
|
if (s && r[c] && r[c][t]) {
|
|
946
|
-
const { requiredVersion: u } = s, p = getFindShareFunction(
|
|
946
|
+
const { requiredVersion: u } = s, p = getFindShareFunction(l)(r, c, t), m = () => {
|
|
947
947
|
if (s.singleton) {
|
|
948
948
|
if (typeof u == "string" && !satisfy(p, u)) {
|
|
949
|
-
const R = `Version ${p} from ${p && r[c][t][p].from} of shared singleton module ${t} does not satisfy the requirement of ${
|
|
949
|
+
const R = `Version ${p} from ${p && r[c][t][p].from} of shared singleton module ${t} does not satisfy the requirement of ${n.from} which needs ${u})`;
|
|
950
950
|
s.strictVersion ? error(R) : warn(R);
|
|
951
951
|
}
|
|
952
952
|
return r[c][t][p];
|
|
@@ -965,14 +965,14 @@ function getRegisteredShare(r, t, o, n) {
|
|
|
965
965
|
GlobalFederation: Global.__FEDERATION__,
|
|
966
966
|
resolver: m
|
|
967
967
|
};
|
|
968
|
-
return (
|
|
968
|
+
return (o.emit(y) || y).resolver();
|
|
969
969
|
}
|
|
970
970
|
}
|
|
971
971
|
function getGlobalShareScope() {
|
|
972
972
|
return Global.__FEDERATION__.__SHARE__;
|
|
973
973
|
}
|
|
974
974
|
function getTargetSharedOptions(r) {
|
|
975
|
-
const { pkgName: t, extraOptions:
|
|
975
|
+
const { pkgName: t, extraOptions: n, shareInfos: o } = r, s = (i) => {
|
|
976
976
|
if (!i)
|
|
977
977
|
return;
|
|
978
978
|
const c = {};
|
|
@@ -984,26 +984,26 @@ function getTargetSharedOptions(r) {
|
|
|
984
984
|
});
|
|
985
985
|
return c[d];
|
|
986
986
|
};
|
|
987
|
-
var
|
|
988
|
-
const
|
|
989
|
-
return Object.assign({},
|
|
987
|
+
var a;
|
|
988
|
+
const l = (a = n == null ? void 0 : n.resolver) != null ? a : s;
|
|
989
|
+
return Object.assign({}, l(o[t]), n == null ? void 0 : n.customShareInfo);
|
|
990
990
|
}
|
|
991
|
-
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", TYPE_001 = "TYPE-001", getDocsUrl = (r) => `https://module-federation.io/guide/troubleshooting/${r.split("-")[0].toLowerCase()}/${r}`, getShortErrorMsg = (r, t,
|
|
991
|
+
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", TYPE_001 = "TYPE-001", getDocsUrl = (r) => `https://module-federation.io/guide/troubleshooting/${r.split("-")[0].toLowerCase()}/${r}`, getShortErrorMsg = (r, t, n, o) => {
|
|
992
992
|
const s = [
|
|
993
993
|
`${[
|
|
994
994
|
t[r]
|
|
995
995
|
]} #${r}`
|
|
996
996
|
];
|
|
997
|
-
return
|
|
998
|
-
${
|
|
997
|
+
return n && s.push(`args: ${JSON.stringify(n)}`), s.push(getDocsUrl(r)), o && s.push(`Original Error Message:
|
|
998
|
+
${o}`), s.join(`
|
|
999
999
|
`);
|
|
1000
1000
|
};
|
|
1001
1001
|
function _extends() {
|
|
1002
1002
|
return _extends = Object.assign || function(t) {
|
|
1003
|
-
for (var
|
|
1004
|
-
var
|
|
1005
|
-
for (var s in
|
|
1006
|
-
Object.prototype.hasOwnProperty.call(
|
|
1003
|
+
for (var n = 1; n < arguments.length; n++) {
|
|
1004
|
+
var o = arguments[n];
|
|
1005
|
+
for (var s in o)
|
|
1006
|
+
Object.prototype.hasOwnProperty.call(o, s) && (t[s] = o[s]);
|
|
1007
1007
|
}
|
|
1008
1008
|
return t;
|
|
1009
1009
|
}, _extends.apply(this, arguments);
|
|
@@ -1021,139 +1021,139 @@ const runtimeDescMap = {
|
|
|
1021
1021
|
};
|
|
1022
1022
|
_extends({}, runtimeDescMap, typeDescMap);
|
|
1023
1023
|
function matchRemoteWithNameAndExpose(r, t) {
|
|
1024
|
-
for (const
|
|
1025
|
-
const
|
|
1026
|
-
let s = t.replace(
|
|
1027
|
-
if (
|
|
1024
|
+
for (const n of r) {
|
|
1025
|
+
const o = t.startsWith(n.name);
|
|
1026
|
+
let s = t.replace(n.name, "");
|
|
1027
|
+
if (o) {
|
|
1028
1028
|
if (s.startsWith("/")) {
|
|
1029
|
-
const i =
|
|
1029
|
+
const i = n.name;
|
|
1030
1030
|
return s = `.${s}`, {
|
|
1031
1031
|
pkgNameOrAlias: i,
|
|
1032
1032
|
expose: s,
|
|
1033
|
-
remote:
|
|
1033
|
+
remote: n
|
|
1034
1034
|
};
|
|
1035
1035
|
} else if (s === "")
|
|
1036
1036
|
return {
|
|
1037
|
-
pkgNameOrAlias:
|
|
1037
|
+
pkgNameOrAlias: n.name,
|
|
1038
1038
|
expose: ".",
|
|
1039
|
-
remote:
|
|
1039
|
+
remote: n
|
|
1040
1040
|
};
|
|
1041
1041
|
}
|
|
1042
|
-
const
|
|
1043
|
-
let
|
|
1044
|
-
if (
|
|
1045
|
-
if (
|
|
1046
|
-
const i =
|
|
1047
|
-
return
|
|
1042
|
+
const a = n.alias && t.startsWith(n.alias);
|
|
1043
|
+
let l = n.alias && t.replace(n.alias, "");
|
|
1044
|
+
if (n.alias && a) {
|
|
1045
|
+
if (l && l.startsWith("/")) {
|
|
1046
|
+
const i = n.alias;
|
|
1047
|
+
return l = `.${l}`, {
|
|
1048
1048
|
pkgNameOrAlias: i,
|
|
1049
|
-
expose:
|
|
1050
|
-
remote:
|
|
1049
|
+
expose: l,
|
|
1050
|
+
remote: n
|
|
1051
1051
|
};
|
|
1052
|
-
} else if (
|
|
1052
|
+
} else if (l === "")
|
|
1053
1053
|
return {
|
|
1054
|
-
pkgNameOrAlias:
|
|
1054
|
+
pkgNameOrAlias: n.alias,
|
|
1055
1055
|
expose: ".",
|
|
1056
|
-
remote:
|
|
1056
|
+
remote: n
|
|
1057
1057
|
};
|
|
1058
1058
|
}
|
|
1059
1059
|
}
|
|
1060
1060
|
}
|
|
1061
1061
|
function matchRemote(r, t) {
|
|
1062
|
-
for (const
|
|
1063
|
-
if (t ===
|
|
1064
|
-
return
|
|
1062
|
+
for (const n of r)
|
|
1063
|
+
if (t === n.name || n.alias && t === n.alias)
|
|
1064
|
+
return n;
|
|
1065
1065
|
}
|
|
1066
1066
|
function registerPlugins$1(r, t) {
|
|
1067
|
-
const
|
|
1068
|
-
return
|
|
1069
|
-
r != null && r.find((s) => s.name !==
|
|
1070
|
-
}), r && r.length > 0 && r.forEach((
|
|
1067
|
+
const n = getGlobalHostPlugins();
|
|
1068
|
+
return n.length > 0 && n.forEach((o) => {
|
|
1069
|
+
r != null && r.find((s) => s.name !== o.name) && r.push(o);
|
|
1070
|
+
}), r && r.length > 0 && r.forEach((o) => {
|
|
1071
1071
|
t.forEach((s) => {
|
|
1072
|
-
s.applyPlugin(
|
|
1072
|
+
s.applyPlugin(o);
|
|
1073
1073
|
});
|
|
1074
1074
|
}), r;
|
|
1075
1075
|
}
|
|
1076
1076
|
async function loadEsmEntry({ entry: r, remoteEntryExports: t }) {
|
|
1077
|
-
return new Promise((
|
|
1077
|
+
return new Promise((n, o) => {
|
|
1078
1078
|
try {
|
|
1079
|
-
t ?
|
|
1080
|
-
|
|
1081
|
-
|
|
1079
|
+
t ? n(t) : typeof FEDERATION_ALLOW_NEW_FUNCTION < "u" ? new Function("callbacks", `import("${r}").then(callbacks[0]).catch(callbacks[1])`)([
|
|
1080
|
+
n,
|
|
1081
|
+
o
|
|
1082
1082
|
]) : import(
|
|
1083
1083
|
/* webpackIgnore: true */
|
|
1084
1084
|
/* @vite-ignore */
|
|
1085
1085
|
r
|
|
1086
|
-
).then(
|
|
1086
|
+
).then(n).catch(o);
|
|
1087
1087
|
} catch (s) {
|
|
1088
|
-
|
|
1088
|
+
o(s);
|
|
1089
1089
|
}
|
|
1090
1090
|
});
|
|
1091
1091
|
}
|
|
1092
1092
|
async function loadSystemJsEntry({ entry: r, remoteEntryExports: t }) {
|
|
1093
|
-
return new Promise((
|
|
1093
|
+
return new Promise((n, o) => {
|
|
1094
1094
|
try {
|
|
1095
|
-
t ?
|
|
1096
|
-
|
|
1097
|
-
|
|
1095
|
+
t ? n(t) : typeof __system_context__ > "u" ? System.import(r).then(n).catch(o) : new Function("callbacks", `System.import("${r}").then(callbacks[0]).catch(callbacks[1])`)([
|
|
1096
|
+
n,
|
|
1097
|
+
o
|
|
1098
1098
|
]);
|
|
1099
1099
|
} catch (s) {
|
|
1100
|
-
|
|
1100
|
+
o(s);
|
|
1101
1101
|
}
|
|
1102
1102
|
});
|
|
1103
1103
|
}
|
|
1104
|
-
async function loadEntryScript({ name: r, globalName: t, entry:
|
|
1104
|
+
async function loadEntryScript({ name: r, globalName: t, entry: n, loaderHook: o }) {
|
|
1105
1105
|
const { entryExports: s } = getRemoteEntryExports(r, t);
|
|
1106
|
-
return s || loadScript(
|
|
1106
|
+
return s || loadScript(n, {
|
|
1107
1107
|
attrs: {},
|
|
1108
|
-
createScriptHook: (
|
|
1109
|
-
const i =
|
|
1110
|
-
url:
|
|
1111
|
-
attrs:
|
|
1108
|
+
createScriptHook: (a, l) => {
|
|
1109
|
+
const i = o.lifecycle.createScript.emit({
|
|
1110
|
+
url: a,
|
|
1111
|
+
attrs: l
|
|
1112
1112
|
});
|
|
1113
1113
|
if (i && (i instanceof HTMLScriptElement || "script" in i || "timeout" in i))
|
|
1114
1114
|
return i;
|
|
1115
1115
|
}
|
|
1116
1116
|
}).then(() => {
|
|
1117
|
-
const { remoteEntryKey:
|
|
1118
|
-
return assert(
|
|
1117
|
+
const { remoteEntryKey: a, entryExports: l } = getRemoteEntryExports(r, t);
|
|
1118
|
+
return assert(l, getShortErrorMsg(RUNTIME_001, runtimeDescMap, {
|
|
1119
1119
|
remoteName: r,
|
|
1120
|
-
remoteEntryUrl:
|
|
1121
|
-
remoteEntryKey:
|
|
1122
|
-
})),
|
|
1123
|
-
}).catch((
|
|
1124
|
-
throw
|
|
1120
|
+
remoteEntryUrl: n,
|
|
1121
|
+
remoteEntryKey: a
|
|
1122
|
+
})), l;
|
|
1123
|
+
}).catch((a) => {
|
|
1124
|
+
throw a;
|
|
1125
1125
|
});
|
|
1126
1126
|
}
|
|
1127
|
-
async function loadEntryDom({ remoteInfo: r, remoteEntryExports: t, loaderHook:
|
|
1128
|
-
const { entry:
|
|
1129
|
-
switch (
|
|
1127
|
+
async function loadEntryDom({ remoteInfo: r, remoteEntryExports: t, loaderHook: n }) {
|
|
1128
|
+
const { entry: o, entryGlobalName: s, name: a, type: l } = r;
|
|
1129
|
+
switch (l) {
|
|
1130
1130
|
case "esm":
|
|
1131
1131
|
case "module":
|
|
1132
1132
|
return loadEsmEntry({
|
|
1133
|
-
entry:
|
|
1133
|
+
entry: o,
|
|
1134
1134
|
remoteEntryExports: t
|
|
1135
1135
|
});
|
|
1136
1136
|
case "system":
|
|
1137
1137
|
return loadSystemJsEntry({
|
|
1138
|
-
entry:
|
|
1138
|
+
entry: o,
|
|
1139
1139
|
remoteEntryExports: t
|
|
1140
1140
|
});
|
|
1141
1141
|
default:
|
|
1142
1142
|
return loadEntryScript({
|
|
1143
|
-
entry:
|
|
1143
|
+
entry: o,
|
|
1144
1144
|
globalName: s,
|
|
1145
|
-
name:
|
|
1146
|
-
loaderHook:
|
|
1145
|
+
name: a,
|
|
1146
|
+
loaderHook: n
|
|
1147
1147
|
});
|
|
1148
1148
|
}
|
|
1149
1149
|
}
|
|
1150
1150
|
async function loadEntryNode({ remoteInfo: r, loaderHook: t }) {
|
|
1151
|
-
const { entry:
|
|
1152
|
-
return
|
|
1151
|
+
const { entry: n, entryGlobalName: o, name: s, type: a } = r, { entryExports: l } = getRemoteEntryExports(s, o);
|
|
1152
|
+
return l || loadScriptNode(n, {
|
|
1153
1153
|
attrs: {
|
|
1154
1154
|
name: s,
|
|
1155
|
-
globalName:
|
|
1156
|
-
type:
|
|
1155
|
+
globalName: o,
|
|
1156
|
+
type: a
|
|
1157
1157
|
},
|
|
1158
1158
|
loaderHook: {
|
|
1159
1159
|
createScriptHook: (i, c = {}) => {
|
|
@@ -1166,10 +1166,10 @@ async function loadEntryNode({ remoteInfo: r, loaderHook: t }) {
|
|
|
1166
1166
|
}
|
|
1167
1167
|
}
|
|
1168
1168
|
}).then(() => {
|
|
1169
|
-
const { remoteEntryKey: i, entryExports: c } = getRemoteEntryExports(s,
|
|
1169
|
+
const { remoteEntryKey: i, entryExports: c } = getRemoteEntryExports(s, o);
|
|
1170
1170
|
return assert(c, getShortErrorMsg(RUNTIME_001, runtimeDescMap, {
|
|
1171
1171
|
remoteName: s,
|
|
1172
|
-
remoteEntryUrl:
|
|
1172
|
+
remoteEntryUrl: n,
|
|
1173
1173
|
remoteEntryKey: i
|
|
1174
1174
|
})), c;
|
|
1175
1175
|
}).catch((i) => {
|
|
@@ -1177,29 +1177,29 @@ async function loadEntryNode({ remoteInfo: r, loaderHook: t }) {
|
|
|
1177
1177
|
});
|
|
1178
1178
|
}
|
|
1179
1179
|
function getRemoteEntryUniqueKey(r) {
|
|
1180
|
-
const { entry: t, name:
|
|
1181
|
-
return composeKeyWithSeparator(
|
|
1180
|
+
const { entry: t, name: n } = r;
|
|
1181
|
+
return composeKeyWithSeparator(n, t);
|
|
1182
1182
|
}
|
|
1183
|
-
async function getRemoteEntry({ origin: r, remoteEntryExports: t, remoteInfo:
|
|
1184
|
-
const
|
|
1183
|
+
async function getRemoteEntry({ origin: r, remoteEntryExports: t, remoteInfo: n }) {
|
|
1184
|
+
const o = getRemoteEntryUniqueKey(n);
|
|
1185
1185
|
if (t)
|
|
1186
1186
|
return t;
|
|
1187
|
-
if (!globalLoading[
|
|
1188
|
-
const s = r.remoteHandler.hooks.lifecycle.loadEntry,
|
|
1189
|
-
globalLoading[
|
|
1190
|
-
loaderHook:
|
|
1191
|
-
remoteInfo:
|
|
1187
|
+
if (!globalLoading[o]) {
|
|
1188
|
+
const s = r.remoteHandler.hooks.lifecycle.loadEntry, a = r.loaderHook;
|
|
1189
|
+
globalLoading[o] = s.emit({
|
|
1190
|
+
loaderHook: a,
|
|
1191
|
+
remoteInfo: n,
|
|
1192
1192
|
remoteEntryExports: t
|
|
1193
|
-
}).then((
|
|
1194
|
-
remoteInfo:
|
|
1193
|
+
}).then((l) => l || (isBrowserEnv() ? loadEntryDom({
|
|
1194
|
+
remoteInfo: n,
|
|
1195
1195
|
remoteEntryExports: t,
|
|
1196
|
-
loaderHook:
|
|
1196
|
+
loaderHook: a
|
|
1197
1197
|
}) : loadEntryNode({
|
|
1198
|
-
remoteInfo:
|
|
1199
|
-
loaderHook:
|
|
1198
|
+
remoteInfo: n,
|
|
1199
|
+
loaderHook: a
|
|
1200
1200
|
})));
|
|
1201
1201
|
}
|
|
1202
|
-
return globalLoading[
|
|
1202
|
+
return globalLoading[o];
|
|
1203
1203
|
}
|
|
1204
1204
|
function getRemoteInfo(r) {
|
|
1205
1205
|
return _extends$1({}, r, {
|
|
@@ -1221,24 +1221,24 @@ let Module = class {
|
|
|
1221
1221
|
remoteEntryExports: this.remoteEntryExports
|
|
1222
1222
|
});
|
|
1223
1223
|
} catch {
|
|
1224
|
-
const
|
|
1224
|
+
const o = getRemoteEntryUniqueKey(this.remoteInfo);
|
|
1225
1225
|
t = await this.host.loaderHook.lifecycle.loadEntryError.emit({
|
|
1226
1226
|
getRemoteEntry,
|
|
1227
1227
|
origin: this.host,
|
|
1228
1228
|
remoteInfo: this.remoteInfo,
|
|
1229
1229
|
remoteEntryExports: this.remoteEntryExports,
|
|
1230
1230
|
globalLoading,
|
|
1231
|
-
uniqueKey:
|
|
1231
|
+
uniqueKey: o
|
|
1232
1232
|
});
|
|
1233
1233
|
}
|
|
1234
1234
|
return assert(t, `remoteEntryExports is undefined
|
|
1235
1235
|
${safeToString(this.remoteInfo)}`), this.remoteEntryExports = t, this.remoteEntryExports;
|
|
1236
1236
|
}
|
|
1237
1237
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1238
|
-
async get(t,
|
|
1239
|
-
const { loadFactory:
|
|
1238
|
+
async get(t, n, o, s) {
|
|
1239
|
+
const { loadFactory: a = !0 } = o || {
|
|
1240
1240
|
loadFactory: !0
|
|
1241
|
-
},
|
|
1241
|
+
}, l = await this.getEntry();
|
|
1242
1242
|
if (!this.inited) {
|
|
1243
1243
|
const p = this.host.shareScopeMap, m = this.remoteInfo.shareScope || "default";
|
|
1244
1244
|
p[m] || (p[m] = {});
|
|
@@ -1258,43 +1258,43 @@ let Module = class {
|
|
|
1258
1258
|
remoteInfo: this.remoteInfo,
|
|
1259
1259
|
origin: this.host
|
|
1260
1260
|
});
|
|
1261
|
-
typeof (
|
|
1261
|
+
typeof (l == null ? void 0 : l.init) > "u" && error(getShortErrorMsg(RUNTIME_002, runtimeDescMap, {
|
|
1262
1262
|
remoteName: name,
|
|
1263
1263
|
remoteEntryUrl: this.remoteInfo.entry,
|
|
1264
1264
|
remoteEntryKey: this.remoteInfo.entryGlobalName
|
|
1265
|
-
})), await
|
|
1265
|
+
})), await l.init(g.shareScope, g.initScope, g.remoteEntryInitOptions), await this.host.hooks.lifecycle.initContainer.emit(_extends$1({}, g, {
|
|
1266
1266
|
id: t,
|
|
1267
1267
|
remoteSnapshot: s,
|
|
1268
|
-
remoteEntryExports:
|
|
1268
|
+
remoteEntryExports: l
|
|
1269
1269
|
}));
|
|
1270
1270
|
}
|
|
1271
|
-
this.lib =
|
|
1271
|
+
this.lib = l, this.inited = !0;
|
|
1272
1272
|
let i;
|
|
1273
1273
|
i = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
|
|
1274
|
-
remoteEntryExports:
|
|
1275
|
-
expose:
|
|
1274
|
+
remoteEntryExports: l,
|
|
1275
|
+
expose: n,
|
|
1276
1276
|
moduleInfo: this.remoteInfo
|
|
1277
|
-
}), i || (i = await
|
|
1278
|
-
const c = processModuleAlias(this.remoteInfo.name,
|
|
1279
|
-
return
|
|
1277
|
+
}), i || (i = await l.get(n)), assert(i, `${getFMId(this.remoteInfo)} remote don't export ${n}.`);
|
|
1278
|
+
const c = processModuleAlias(this.remoteInfo.name, n), u = this.wraperFactory(i, c);
|
|
1279
|
+
return a ? await u() : u;
|
|
1280
1280
|
}
|
|
1281
|
-
wraperFactory(t,
|
|
1282
|
-
function
|
|
1281
|
+
wraperFactory(t, n) {
|
|
1282
|
+
function o(s, a) {
|
|
1283
1283
|
s && typeof s == "object" && Object.isExtensible(s) && !Object.getOwnPropertyDescriptor(s, Symbol.for("mf_module_id")) && Object.defineProperty(s, Symbol.for("mf_module_id"), {
|
|
1284
|
-
value:
|
|
1284
|
+
value: a,
|
|
1285
1285
|
enumerable: !1
|
|
1286
1286
|
});
|
|
1287
1287
|
}
|
|
1288
1288
|
return t instanceof Promise ? async () => {
|
|
1289
1289
|
const s = await t();
|
|
1290
|
-
return
|
|
1290
|
+
return o(s, n), s;
|
|
1291
1291
|
} : () => {
|
|
1292
1292
|
const s = t();
|
|
1293
|
-
return
|
|
1293
|
+
return o(s, n), s;
|
|
1294
1294
|
};
|
|
1295
1295
|
}
|
|
1296
|
-
constructor({ remoteInfo: t, host:
|
|
1297
|
-
this.inited = !1, this.lib = void 0, this.remoteInfo = t, this.host =
|
|
1296
|
+
constructor({ remoteInfo: t, host: n }) {
|
|
1297
|
+
this.inited = !1, this.lib = void 0, this.remoteInfo = t, this.host = n;
|
|
1298
1298
|
}
|
|
1299
1299
|
};
|
|
1300
1300
|
class SyncHook {
|
|
@@ -1302,16 +1302,16 @@ class SyncHook {
|
|
|
1302
1302
|
typeof t == "function" && this.listeners.add(t);
|
|
1303
1303
|
}
|
|
1304
1304
|
once(t) {
|
|
1305
|
-
const
|
|
1306
|
-
this.on(function
|
|
1307
|
-
return
|
|
1305
|
+
const n = this;
|
|
1306
|
+
this.on(function o(...s) {
|
|
1307
|
+
return n.remove(o), t.apply(null, s);
|
|
1308
1308
|
});
|
|
1309
1309
|
}
|
|
1310
1310
|
emit(...t) {
|
|
1311
|
-
let
|
|
1312
|
-
return this.listeners.size > 0 && this.listeners.forEach((
|
|
1313
|
-
|
|
1314
|
-
}),
|
|
1311
|
+
let n;
|
|
1312
|
+
return this.listeners.size > 0 && this.listeners.forEach((o) => {
|
|
1313
|
+
n = o(...t);
|
|
1314
|
+
}), n;
|
|
1315
1315
|
}
|
|
1316
1316
|
remove(t) {
|
|
1317
1317
|
this.listeners.delete(t);
|
|
@@ -1325,22 +1325,22 @@ class SyncHook {
|
|
|
1325
1325
|
}
|
|
1326
1326
|
class AsyncHook extends SyncHook {
|
|
1327
1327
|
emit(...t) {
|
|
1328
|
-
let
|
|
1329
|
-
const
|
|
1330
|
-
if (
|
|
1328
|
+
let n;
|
|
1329
|
+
const o = Array.from(this.listeners);
|
|
1330
|
+
if (o.length > 0) {
|
|
1331
1331
|
let s = 0;
|
|
1332
|
-
const
|
|
1333
|
-
|
|
1332
|
+
const a = (l) => l === !1 ? !1 : s < o.length ? Promise.resolve(o[s++].apply(null, t)).then(a) : l;
|
|
1333
|
+
n = a();
|
|
1334
1334
|
}
|
|
1335
|
-
return Promise.resolve(
|
|
1335
|
+
return Promise.resolve(n);
|
|
1336
1336
|
}
|
|
1337
1337
|
}
|
|
1338
1338
|
function checkReturnData(r, t) {
|
|
1339
1339
|
if (!isObject(t))
|
|
1340
1340
|
return !1;
|
|
1341
1341
|
if (r !== t) {
|
|
1342
|
-
for (const
|
|
1343
|
-
if (!(
|
|
1342
|
+
for (const n in r)
|
|
1343
|
+
if (!(n in t))
|
|
1344
1344
|
return !1;
|
|
1345
1345
|
}
|
|
1346
1346
|
return !0;
|
|
@@ -1348,17 +1348,17 @@ function checkReturnData(r, t) {
|
|
|
1348
1348
|
class SyncWaterfallHook extends SyncHook {
|
|
1349
1349
|
emit(t) {
|
|
1350
1350
|
isObject(t) || error(`The data for the "${this.type}" hook should be an object.`);
|
|
1351
|
-
for (const
|
|
1351
|
+
for (const n of this.listeners)
|
|
1352
1352
|
try {
|
|
1353
|
-
const
|
|
1354
|
-
if (checkReturnData(t,
|
|
1355
|
-
t =
|
|
1353
|
+
const o = n(t);
|
|
1354
|
+
if (checkReturnData(t, o))
|
|
1355
|
+
t = o;
|
|
1356
1356
|
else {
|
|
1357
1357
|
this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);
|
|
1358
1358
|
break;
|
|
1359
1359
|
}
|
|
1360
|
-
} catch (
|
|
1361
|
-
warn(
|
|
1360
|
+
} catch (o) {
|
|
1361
|
+
warn(o), this.onerror(o);
|
|
1362
1362
|
}
|
|
1363
1363
|
return t;
|
|
1364
1364
|
}
|
|
@@ -1369,14 +1369,14 @@ class SyncWaterfallHook extends SyncHook {
|
|
|
1369
1369
|
class AsyncWaterfallHook extends SyncHook {
|
|
1370
1370
|
emit(t) {
|
|
1371
1371
|
isObject(t) || error(`The response data for the "${this.type}" hook must be an object.`);
|
|
1372
|
-
const
|
|
1373
|
-
if (
|
|
1374
|
-
let
|
|
1375
|
-
const s = (
|
|
1376
|
-
if (checkReturnData(t,
|
|
1377
|
-
if (t =
|
|
1372
|
+
const n = Array.from(this.listeners);
|
|
1373
|
+
if (n.length > 0) {
|
|
1374
|
+
let o = 0;
|
|
1375
|
+
const s = (l) => (warn(l), this.onerror(l), t), a = (l) => {
|
|
1376
|
+
if (checkReturnData(t, l)) {
|
|
1377
|
+
if (t = l, o < n.length)
|
|
1378
1378
|
try {
|
|
1379
|
-
return Promise.resolve(o
|
|
1379
|
+
return Promise.resolve(n[o++](t)).then(a, s);
|
|
1380
1380
|
} catch (i) {
|
|
1381
1381
|
return s(i);
|
|
1382
1382
|
}
|
|
@@ -1384,7 +1384,7 @@ class AsyncWaterfallHook extends SyncHook {
|
|
|
1384
1384
|
this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
|
|
1385
1385
|
return t;
|
|
1386
1386
|
};
|
|
1387
|
-
return Promise.resolve(
|
|
1387
|
+
return Promise.resolve(a(t));
|
|
1388
1388
|
}
|
|
1389
1389
|
return Promise.resolve(t);
|
|
1390
1390
|
}
|
|
@@ -1395,25 +1395,25 @@ class AsyncWaterfallHook extends SyncHook {
|
|
|
1395
1395
|
class PluginSystem {
|
|
1396
1396
|
applyPlugin(t) {
|
|
1397
1397
|
assert(isPlainObject(t), "Plugin configuration is invalid.");
|
|
1398
|
-
const
|
|
1399
|
-
assert(
|
|
1400
|
-
const s = t[
|
|
1401
|
-
s && this.lifecycle[
|
|
1398
|
+
const n = t.name;
|
|
1399
|
+
assert(n, "A name must be provided by the plugin."), this.registerPlugins[n] || (this.registerPlugins[n] = t, Object.keys(this.lifecycle).forEach((o) => {
|
|
1400
|
+
const s = t[o];
|
|
1401
|
+
s && this.lifecycle[o].on(s);
|
|
1402
1402
|
}));
|
|
1403
1403
|
}
|
|
1404
1404
|
removePlugin(t) {
|
|
1405
1405
|
assert(t, "A name is required.");
|
|
1406
|
-
const
|
|
1407
|
-
assert(
|
|
1408
|
-
|
|
1406
|
+
const n = this.registerPlugins[t];
|
|
1407
|
+
assert(n, `The plugin "${t}" is not registered.`), Object.keys(n).forEach((o) => {
|
|
1408
|
+
o !== "name" && this.lifecycle[o].remove(n[o]);
|
|
1409
1409
|
});
|
|
1410
1410
|
}
|
|
1411
1411
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
1412
|
-
inherit({ lifecycle: t, registerPlugins:
|
|
1413
|
-
Object.keys(t).forEach((
|
|
1414
|
-
assert(!this.lifecycle[
|
|
1415
|
-
}), Object.keys(
|
|
1416
|
-
assert(!this.registerPlugins[
|
|
1412
|
+
inherit({ lifecycle: t, registerPlugins: n }) {
|
|
1413
|
+
Object.keys(t).forEach((o) => {
|
|
1414
|
+
assert(!this.lifecycle[o], `The hook "${o}" has a conflict and cannot be inherited.`), this.lifecycle[o] = t[o];
|
|
1415
|
+
}), Object.keys(n).forEach((o) => {
|
|
1416
|
+
assert(!this.registerPlugins[o], `The plugin "${o}" has a conflict and cannot be inherited.`), this.applyPlugin(n[o]);
|
|
1417
1417
|
});
|
|
1418
1418
|
}
|
|
1419
1419
|
constructor(t) {
|
|
@@ -1429,24 +1429,24 @@ function defaultPreloadArgs(r) {
|
|
|
1429
1429
|
}, r);
|
|
1430
1430
|
}
|
|
1431
1431
|
function formatPreloadArgs(r, t) {
|
|
1432
|
-
return t.map((
|
|
1433
|
-
const
|
|
1434
|
-
return assert(
|
|
1435
|
-
remoteInfo:
|
|
1432
|
+
return t.map((n) => {
|
|
1433
|
+
const o = matchRemote(r, n.nameOrAlias);
|
|
1434
|
+
return assert(o, `Unable to preload ${n.nameOrAlias} as it is not included in ${!o && safeToString({
|
|
1435
|
+
remoteInfo: o,
|
|
1436
1436
|
remotes: r
|
|
1437
1437
|
})}`), {
|
|
1438
|
-
remote:
|
|
1439
|
-
preloadConfig: defaultPreloadArgs(
|
|
1438
|
+
remote: o,
|
|
1439
|
+
preloadConfig: defaultPreloadArgs(n)
|
|
1440
1440
|
};
|
|
1441
1441
|
});
|
|
1442
1442
|
}
|
|
1443
1443
|
function normalizePreloadExposes(r) {
|
|
1444
1444
|
return r ? r.map((t) => t === "." ? t : t.startsWith("./") ? t.replace("./", "") : t) : [];
|
|
1445
1445
|
}
|
|
1446
|
-
function preloadAssets(r, t,
|
|
1447
|
-
const { cssAssets: s, jsAssetsWithoutEntry:
|
|
1446
|
+
function preloadAssets(r, t, n, o = !0) {
|
|
1447
|
+
const { cssAssets: s, jsAssetsWithoutEntry: a, entryAssets: l } = n;
|
|
1448
1448
|
if (t.options.inBrowser) {
|
|
1449
|
-
if (
|
|
1449
|
+
if (l.forEach((i) => {
|
|
1450
1450
|
const { moduleInfo: c } = i, u = t.moduleCache.get(r.name);
|
|
1451
1451
|
getRemoteEntry(u ? {
|
|
1452
1452
|
origin: t,
|
|
@@ -1457,7 +1457,7 @@ function preloadAssets(r, t, o, n = !0) {
|
|
|
1457
1457
|
remoteInfo: c,
|
|
1458
1458
|
remoteEntryExports: void 0
|
|
1459
1459
|
});
|
|
1460
|
-
}),
|
|
1460
|
+
}), o) {
|
|
1461
1461
|
const i = {
|
|
1462
1462
|
rel: "preload",
|
|
1463
1463
|
as: "style"
|
|
@@ -1503,12 +1503,12 @@ function preloadAssets(r, t, o, n = !0) {
|
|
|
1503
1503
|
d && document.head.appendChild(u);
|
|
1504
1504
|
});
|
|
1505
1505
|
}
|
|
1506
|
-
if (
|
|
1506
|
+
if (o) {
|
|
1507
1507
|
const i = {
|
|
1508
1508
|
rel: "preload",
|
|
1509
1509
|
as: "script"
|
|
1510
1510
|
};
|
|
1511
|
-
|
|
1511
|
+
a.forEach((c) => {
|
|
1512
1512
|
const { link: u, needAttach: d } = createLink({
|
|
1513
1513
|
url: c,
|
|
1514
1514
|
cb: () => {
|
|
@@ -1530,7 +1530,7 @@ function preloadAssets(r, t, o, n = !0) {
|
|
|
1530
1530
|
fetchpriority: "high",
|
|
1531
1531
|
type: (r == null ? void 0 : r.type) === "module" ? "module" : "text/javascript"
|
|
1532
1532
|
};
|
|
1533
|
-
|
|
1533
|
+
a.forEach((c) => {
|
|
1534
1534
|
const { script: u, needAttach: d } = createScript({
|
|
1535
1535
|
url: c,
|
|
1536
1536
|
cb: () => {
|
|
@@ -1552,25 +1552,25 @@ function preloadAssets(r, t, o, n = !0) {
|
|
|
1552
1552
|
}
|
|
1553
1553
|
}
|
|
1554
1554
|
function assignRemoteInfo(r, t) {
|
|
1555
|
-
const
|
|
1556
|
-
|
|
1557
|
-
let
|
|
1558
|
-
!isBrowserEnv() && !
|
|
1555
|
+
const n = getRemoteEntryInfoFromSnapshot(t);
|
|
1556
|
+
n.url || error(`The attribute remoteEntry of ${r.name} must not be undefined.`);
|
|
1557
|
+
let o = getResourceUrl(t, n.url);
|
|
1558
|
+
!isBrowserEnv() && !o.startsWith("http") && (o = `https:${o}`), r.type = n.type, r.entryGlobalName = n.globalName, r.entry = o, r.version = t.version, r.buildVersion = t.buildVersion;
|
|
1559
1559
|
}
|
|
1560
1560
|
function snapshotPlugin() {
|
|
1561
1561
|
return {
|
|
1562
1562
|
name: "snapshot-plugin",
|
|
1563
1563
|
async afterResolve(r) {
|
|
1564
|
-
const { remote: t, pkgNameOrAlias:
|
|
1564
|
+
const { remote: t, pkgNameOrAlias: n, expose: o, origin: s, remoteInfo: a } = r;
|
|
1565
1565
|
if (!isRemoteInfoWithEntry(t) || !isPureRemoteEntry(t)) {
|
|
1566
|
-
const { remoteSnapshot:
|
|
1567
|
-
assignRemoteInfo(
|
|
1566
|
+
const { remoteSnapshot: l, globalSnapshot: i } = await s.snapshotHandler.loadRemoteSnapshotInfo(t);
|
|
1567
|
+
assignRemoteInfo(a, l);
|
|
1568
1568
|
const c = {
|
|
1569
1569
|
remote: t,
|
|
1570
1570
|
preloadConfig: {
|
|
1571
|
-
nameOrAlias:
|
|
1571
|
+
nameOrAlias: n,
|
|
1572
1572
|
exposes: [
|
|
1573
|
-
|
|
1573
|
+
o
|
|
1574
1574
|
],
|
|
1575
1575
|
resourceCategory: "sync",
|
|
1576
1576
|
share: !1,
|
|
@@ -1579,13 +1579,13 @@ function snapshotPlugin() {
|
|
|
1579
1579
|
}, u = await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({
|
|
1580
1580
|
origin: s,
|
|
1581
1581
|
preloadOptions: c,
|
|
1582
|
-
remoteInfo:
|
|
1582
|
+
remoteInfo: a,
|
|
1583
1583
|
remote: t,
|
|
1584
|
-
remoteSnapshot:
|
|
1584
|
+
remoteSnapshot: l,
|
|
1585
1585
|
globalSnapshot: i
|
|
1586
1586
|
});
|
|
1587
|
-
return u && preloadAssets(
|
|
1588
|
-
remoteSnapshot:
|
|
1587
|
+
return u && preloadAssets(a, s, u, !1), _extends$1({}, r, {
|
|
1588
|
+
remoteSnapshot: l
|
|
1589
1589
|
});
|
|
1590
1590
|
}
|
|
1591
1591
|
return r;
|
|
@@ -1605,9 +1605,9 @@ function splitId(r) {
|
|
|
1605
1605
|
version: t[2]
|
|
1606
1606
|
};
|
|
1607
1607
|
}
|
|
1608
|
-
function traverseModuleInfo(r, t,
|
|
1609
|
-
const
|
|
1610
|
-
if (c && !isManifestProvider(c) && (
|
|
1608
|
+
function traverseModuleInfo(r, t, n, o, s = {}, a) {
|
|
1609
|
+
const l = getFMId(t), { value: i } = getInfoWithoutType(r, l), c = a || i;
|
|
1610
|
+
if (c && !isManifestProvider(c) && (n(c, t, o), c.remotesInfo)) {
|
|
1611
1611
|
const u = Object.keys(c.remotesInfo);
|
|
1612
1612
|
for (const d of u) {
|
|
1613
1613
|
if (s[d])
|
|
@@ -1617,23 +1617,23 @@ function traverseModuleInfo(r, t, o, n, s = {}, l) {
|
|
|
1617
1617
|
traverseModuleInfo(r, {
|
|
1618
1618
|
name: p.name,
|
|
1619
1619
|
version: m.matchedVersion
|
|
1620
|
-
},
|
|
1620
|
+
}, n, !1, s, void 0);
|
|
1621
1621
|
}
|
|
1622
1622
|
}
|
|
1623
1623
|
}
|
|
1624
|
-
function generatePreloadAssets(r, t,
|
|
1625
|
-
const
|
|
1626
|
-
if (traverseModuleInfo(
|
|
1627
|
-
let
|
|
1628
|
-
if (
|
|
1629
|
-
|
|
1624
|
+
function generatePreloadAssets(r, t, n, o, s) {
|
|
1625
|
+
const a = [], l = [], i = [], c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), { options: d } = r, { preloadConfig: p } = t, { depsRemote: m } = p;
|
|
1626
|
+
if (traverseModuleInfo(o, n, (g, E, v) => {
|
|
1627
|
+
let I;
|
|
1628
|
+
if (v)
|
|
1629
|
+
I = p;
|
|
1630
1630
|
else if (Array.isArray(m)) {
|
|
1631
|
-
const T = m.find((
|
|
1631
|
+
const T = m.find((A) => A.nameOrAlias === E.name || A.nameOrAlias === E.alias);
|
|
1632
1632
|
if (!T)
|
|
1633
1633
|
return;
|
|
1634
|
-
|
|
1634
|
+
I = defaultPreloadArgs(T);
|
|
1635
1635
|
} else if (m === !0)
|
|
1636
|
-
|
|
1636
|
+
I = p;
|
|
1637
1637
|
else
|
|
1638
1638
|
return;
|
|
1639
1639
|
const S = getResourceUrl(g, getRemoteEntryInfoFromSnapshot(g).url);
|
|
@@ -1650,44 +1650,44 @@ function generatePreloadAssets(r, t, o, n, s) {
|
|
|
1650
1650
|
url: S
|
|
1651
1651
|
});
|
|
1652
1652
|
let b = "modules" in g ? g.modules : [];
|
|
1653
|
-
const $ = normalizePreloadExposes(
|
|
1653
|
+
const $ = normalizePreloadExposes(I.exposes);
|
|
1654
1654
|
if ($.length && "modules" in g) {
|
|
1655
|
-
var
|
|
1656
|
-
b = g == null || (
|
|
1655
|
+
var w;
|
|
1656
|
+
b = g == null || (w = g.modules) == null ? void 0 : w.reduce((T, A) => (($ == null ? void 0 : $.indexOf(A.moduleName)) !== -1 && T.push(A), T), []);
|
|
1657
1657
|
}
|
|
1658
1658
|
function O(T) {
|
|
1659
|
-
const
|
|
1660
|
-
return
|
|
1659
|
+
const A = T.map((P) => getResourceUrl(g, P));
|
|
1660
|
+
return I.filter ? A.filter(I.filter) : A;
|
|
1661
1661
|
}
|
|
1662
1662
|
if (b) {
|
|
1663
1663
|
const T = b.length;
|
|
1664
|
-
for (let
|
|
1665
|
-
const P = b[
|
|
1664
|
+
for (let A = 0; A < T; A++) {
|
|
1665
|
+
const P = b[A], M = `${E.name}/${P.moduleName}`;
|
|
1666
1666
|
r.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({
|
|
1667
1667
|
id: P.moduleName === "." ? E.name : M,
|
|
1668
1668
|
name: E.name,
|
|
1669
1669
|
remoteSnapshot: g,
|
|
1670
|
-
preloadConfig:
|
|
1670
|
+
preloadConfig: I,
|
|
1671
1671
|
remote: E,
|
|
1672
1672
|
origin: r
|
|
1673
|
-
}), !getPreloaded(M) && (
|
|
1673
|
+
}), !getPreloaded(M) && (I.resourceCategory === "all" ? (a.push(...O(P.assets.css.async)), a.push(...O(P.assets.css.sync)), l.push(...O(P.assets.js.async)), l.push(...O(P.assets.js.sync))) : (I.resourceCategory = "sync") && (a.push(...O(P.assets.css.sync)), l.push(...O(P.assets.js.sync))), setPreloaded(M));
|
|
1674
1674
|
}
|
|
1675
1675
|
}
|
|
1676
1676
|
}, !0, {}, s), s.shared) {
|
|
1677
|
-
const g = (E,
|
|
1678
|
-
const
|
|
1679
|
-
|
|
1677
|
+
const g = (E, v) => {
|
|
1678
|
+
const I = getRegisteredShare(r.shareScopeMap, v.sharedName, E, r.sharedHandler.hooks.lifecycle.resolveShare);
|
|
1679
|
+
I && typeof I.lib == "function" && (v.assets.js.sync.forEach((S) => {
|
|
1680
1680
|
c.add(S);
|
|
1681
|
-
}),
|
|
1681
|
+
}), v.assets.css.sync.forEach((S) => {
|
|
1682
1682
|
u.add(S);
|
|
1683
1683
|
}));
|
|
1684
1684
|
};
|
|
1685
1685
|
s.shared.forEach((E) => {
|
|
1686
|
-
var
|
|
1687
|
-
const
|
|
1688
|
-
if (!
|
|
1686
|
+
var v;
|
|
1687
|
+
const I = (v = d.shared) == null ? void 0 : v[E.sharedName];
|
|
1688
|
+
if (!I)
|
|
1689
1689
|
return;
|
|
1690
|
-
const S = E.version ?
|
|
1690
|
+
const S = E.version ? I.find(($) => $.version === E.version) : I;
|
|
1691
1691
|
if (!S)
|
|
1692
1692
|
return;
|
|
1693
1693
|
arrayOptions(S).forEach(($) => {
|
|
@@ -1695,9 +1695,9 @@ function generatePreloadAssets(r, t, o, n, s) {
|
|
|
1695
1695
|
});
|
|
1696
1696
|
});
|
|
1697
1697
|
}
|
|
1698
|
-
const _ =
|
|
1698
|
+
const _ = l.filter((g) => !c.has(g));
|
|
1699
1699
|
return {
|
|
1700
|
-
cssAssets:
|
|
1700
|
+
cssAssets: a.filter((g) => !u.has(g)),
|
|
1701
1701
|
jsAssetsWithoutEntry: _,
|
|
1702
1702
|
entryAssets: i
|
|
1703
1703
|
};
|
|
@@ -1706,7 +1706,7 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1706
1706
|
return {
|
|
1707
1707
|
name: "generate-preload-assets-plugin",
|
|
1708
1708
|
async generatePreloadAssets(r) {
|
|
1709
|
-
const { origin: t, preloadOptions:
|
|
1709
|
+
const { origin: t, preloadOptions: n, remoteInfo: o, remote: s, globalSnapshot: a, remoteSnapshot: l } = r;
|
|
1710
1710
|
return isRemoteInfoWithEntry(s) && isPureRemoteEntry(s) ? {
|
|
1711
1711
|
cssAssets: [],
|
|
1712
1712
|
jsAssetsWithoutEntry: [],
|
|
@@ -1715,29 +1715,29 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1715
1715
|
name: s.name,
|
|
1716
1716
|
url: s.entry,
|
|
1717
1717
|
moduleInfo: {
|
|
1718
|
-
name:
|
|
1718
|
+
name: o.name,
|
|
1719
1719
|
entry: s.entry,
|
|
1720
|
-
type:
|
|
1720
|
+
type: o.type || "global",
|
|
1721
1721
|
entryGlobalName: "",
|
|
1722
1722
|
shareScope: ""
|
|
1723
1723
|
}
|
|
1724
1724
|
}
|
|
1725
1725
|
]
|
|
1726
|
-
} : (assignRemoteInfo(
|
|
1726
|
+
} : (assignRemoteInfo(o, l), generatePreloadAssets(t, n, o, a, l));
|
|
1727
1727
|
}
|
|
1728
1728
|
};
|
|
1729
1729
|
};
|
|
1730
1730
|
function getGlobalRemoteInfo(r, t) {
|
|
1731
|
-
const
|
|
1731
|
+
const n = getGlobalSnapshotInfoByModuleInfo({
|
|
1732
1732
|
name: t.options.name,
|
|
1733
1733
|
version: t.options.version
|
|
1734
|
-
}),
|
|
1735
|
-
return
|
|
1736
|
-
hostGlobalSnapshot:
|
|
1734
|
+
}), o = n && "remotesInfo" in n && n.remotesInfo && getInfoWithoutType(n.remotesInfo, r.name).value;
|
|
1735
|
+
return o && o.matchedVersion ? {
|
|
1736
|
+
hostGlobalSnapshot: n,
|
|
1737
1737
|
globalSnapshot: getGlobalSnapshot(),
|
|
1738
1738
|
remoteSnapshot: getGlobalSnapshotInfoByModuleInfo({
|
|
1739
1739
|
name: r.name,
|
|
1740
|
-
version:
|
|
1740
|
+
version: o.matchedVersion
|
|
1741
1741
|
})
|
|
1742
1742
|
} : {
|
|
1743
1743
|
hostGlobalSnapshot: void 0,
|
|
@@ -1750,46 +1750,46 @@ function getGlobalRemoteInfo(r, t) {
|
|
|
1750
1750
|
}
|
|
1751
1751
|
class SnapshotHandler {
|
|
1752
1752
|
async loadSnapshot(t) {
|
|
1753
|
-
const { options:
|
|
1754
|
-
options:
|
|
1753
|
+
const { options: n } = this.HostInstance, { hostGlobalSnapshot: o, remoteSnapshot: s, globalSnapshot: a } = this.getGlobalRemoteInfo(t), { remoteSnapshot: l, globalSnapshot: i } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1754
|
+
options: n,
|
|
1755
1755
|
moduleInfo: t,
|
|
1756
|
-
hostGlobalSnapshot:
|
|
1756
|
+
hostGlobalSnapshot: o,
|
|
1757
1757
|
remoteSnapshot: s,
|
|
1758
|
-
globalSnapshot:
|
|
1758
|
+
globalSnapshot: a
|
|
1759
1759
|
});
|
|
1760
1760
|
return {
|
|
1761
|
-
remoteSnapshot:
|
|
1761
|
+
remoteSnapshot: l,
|
|
1762
1762
|
globalSnapshot: i
|
|
1763
1763
|
};
|
|
1764
1764
|
}
|
|
1765
1765
|
// eslint-disable-next-line max-lines-per-function
|
|
1766
1766
|
async loadRemoteSnapshotInfo(t) {
|
|
1767
|
-
const { options:
|
|
1767
|
+
const { options: n } = this.HostInstance;
|
|
1768
1768
|
await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({
|
|
1769
|
-
options:
|
|
1769
|
+
options: n,
|
|
1770
1770
|
moduleInfo: t
|
|
1771
1771
|
});
|
|
1772
|
-
let
|
|
1772
|
+
let o = getGlobalSnapshotInfoByModuleInfo({
|
|
1773
1773
|
name: this.HostInstance.options.name,
|
|
1774
1774
|
version: this.HostInstance.options.version
|
|
1775
1775
|
});
|
|
1776
|
-
|
|
1776
|
+
o || (o = {
|
|
1777
1777
|
version: this.HostInstance.options.version || "",
|
|
1778
1778
|
remoteEntry: "",
|
|
1779
1779
|
remotesInfo: {}
|
|
1780
1780
|
}, addGlobalSnapshot({
|
|
1781
|
-
[this.HostInstance.options.name]:
|
|
1782
|
-
})),
|
|
1781
|
+
[this.HostInstance.options.name]: o
|
|
1782
|
+
})), o && "remotesInfo" in o && !getInfoWithoutType(o.remotesInfo, t.name).value && ("version" in t || "entry" in t) && (o.remotesInfo = _extends$1({}, o == null ? void 0 : o.remotesInfo, {
|
|
1783
1783
|
[t.name]: {
|
|
1784
1784
|
matchedVersion: "version" in t ? t.version : t.entry
|
|
1785
1785
|
}
|
|
1786
1786
|
}));
|
|
1787
|
-
const { hostGlobalSnapshot: s, remoteSnapshot:
|
|
1788
|
-
options:
|
|
1787
|
+
const { hostGlobalSnapshot: s, remoteSnapshot: a, globalSnapshot: l } = this.getGlobalRemoteInfo(t), { remoteSnapshot: i, globalSnapshot: c } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1788
|
+
options: n,
|
|
1789
1789
|
moduleInfo: t,
|
|
1790
1790
|
hostGlobalSnapshot: s,
|
|
1791
|
-
remoteSnapshot:
|
|
1792
|
-
globalSnapshot:
|
|
1791
|
+
remoteSnapshot: a,
|
|
1792
|
+
globalSnapshot: l
|
|
1793
1793
|
});
|
|
1794
1794
|
let u, d;
|
|
1795
1795
|
if (i)
|
|
@@ -1824,7 +1824,7 @@ class SnapshotHandler {
|
|
|
1824
1824
|
globalSnapshot: JSON.stringify(c)
|
|
1825
1825
|
}));
|
|
1826
1826
|
return await this.hooks.lifecycle.afterLoadSnapshot.emit({
|
|
1827
|
-
options:
|
|
1827
|
+
options: n,
|
|
1828
1828
|
moduleInfo: t,
|
|
1829
1829
|
remoteSnapshot: u
|
|
1830
1830
|
}), {
|
|
@@ -1835,34 +1835,34 @@ class SnapshotHandler {
|
|
|
1835
1835
|
getGlobalRemoteInfo(t) {
|
|
1836
1836
|
return getGlobalRemoteInfo(t, this.HostInstance);
|
|
1837
1837
|
}
|
|
1838
|
-
async getManifestJson(t,
|
|
1838
|
+
async getManifestJson(t, n, o) {
|
|
1839
1839
|
const s = async () => {
|
|
1840
|
-
let
|
|
1841
|
-
if (
|
|
1842
|
-
return
|
|
1840
|
+
let l = this.manifestCache.get(t);
|
|
1841
|
+
if (l)
|
|
1842
|
+
return l;
|
|
1843
1843
|
try {
|
|
1844
1844
|
let i = await this.loaderHook.lifecycle.fetch.emit(t, {});
|
|
1845
|
-
return (!i || !(i instanceof Response)) && (i = await fetch(t, {})),
|
|
1845
|
+
return (!i || !(i instanceof Response)) && (i = await fetch(t, {})), l = await i.json(), assert(l.metaData && l.exposes && l.shared, `${t} is not a federation manifest`), this.manifestCache.set(t, l), l;
|
|
1846
1846
|
} catch (i) {
|
|
1847
1847
|
delete this.manifestLoading[t], error(getShortErrorMsg(RUNTIME_003, runtimeDescMap, {
|
|
1848
1848
|
manifestUrl: t,
|
|
1849
|
-
moduleName:
|
|
1849
|
+
moduleName: n.name
|
|
1850
1850
|
}, `${i}`));
|
|
1851
1851
|
}
|
|
1852
|
-
},
|
|
1853
|
-
const
|
|
1852
|
+
}, a = async () => {
|
|
1853
|
+
const l = await s(), i = generateSnapshotFromManifest(l, {
|
|
1854
1854
|
version: t
|
|
1855
1855
|
}), { remoteSnapshot: c } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1856
1856
|
options: this.HostInstance.options,
|
|
1857
|
-
moduleInfo:
|
|
1858
|
-
manifestJson:
|
|
1857
|
+
moduleInfo: n,
|
|
1858
|
+
manifestJson: l,
|
|
1859
1859
|
remoteSnapshot: i,
|
|
1860
1860
|
manifestUrl: t,
|
|
1861
1861
|
from: "manifest"
|
|
1862
1862
|
});
|
|
1863
1863
|
return c;
|
|
1864
1864
|
};
|
|
1865
|
-
return this.manifestLoading[t] || (this.manifestLoading[t] =
|
|
1865
|
+
return this.manifestLoading[t] || (this.manifestLoading[t] = a().then((l) => l)), this.manifestLoading[t];
|
|
1866
1866
|
}
|
|
1867
1867
|
constructor(t) {
|
|
1868
1868
|
this.loadingHostSnapshot = null, this.manifestCache = /* @__PURE__ */ new Map(), this.hooks = new PluginSystem({
|
|
@@ -1875,44 +1875,44 @@ class SnapshotHandler {
|
|
|
1875
1875
|
}
|
|
1876
1876
|
class SharedHandler {
|
|
1877
1877
|
// register shared in shareScopeMap
|
|
1878
|
-
registerShared(t,
|
|
1879
|
-
const { shareInfos:
|
|
1880
|
-
return Object.keys(
|
|
1881
|
-
|
|
1882
|
-
!getRegisteredShare(this.shareScopeMap,
|
|
1883
|
-
pkgName:
|
|
1878
|
+
registerShared(t, n) {
|
|
1879
|
+
const { shareInfos: o, shared: s } = formatShareConfigs(t, n);
|
|
1880
|
+
return Object.keys(o).forEach((l) => {
|
|
1881
|
+
o[l].forEach((c) => {
|
|
1882
|
+
!getRegisteredShare(this.shareScopeMap, l, c, this.hooks.lifecycle.resolveShare) && c && c.lib && this.setShared({
|
|
1883
|
+
pkgName: l,
|
|
1884
1884
|
lib: c.lib,
|
|
1885
1885
|
get: c.get,
|
|
1886
1886
|
loaded: !0,
|
|
1887
1887
|
shared: c,
|
|
1888
|
-
from:
|
|
1888
|
+
from: n.name
|
|
1889
1889
|
});
|
|
1890
1890
|
});
|
|
1891
1891
|
}), {
|
|
1892
|
-
shareInfos:
|
|
1892
|
+
shareInfos: o,
|
|
1893
1893
|
shared: s
|
|
1894
1894
|
};
|
|
1895
1895
|
}
|
|
1896
|
-
async loadShare(t,
|
|
1897
|
-
const { host:
|
|
1896
|
+
async loadShare(t, n) {
|
|
1897
|
+
const { host: o } = this, s = getTargetSharedOptions({
|
|
1898
1898
|
pkgName: t,
|
|
1899
|
-
extraOptions:
|
|
1900
|
-
shareInfos:
|
|
1899
|
+
extraOptions: n,
|
|
1900
|
+
shareInfos: o.options.shared
|
|
1901
1901
|
});
|
|
1902
1902
|
s != null && s.scope && await Promise.all(s.scope.map(async (u) => {
|
|
1903
1903
|
await Promise.all(this.initializeSharing(u, {
|
|
1904
1904
|
strategy: s.strategy
|
|
1905
1905
|
}));
|
|
1906
1906
|
}));
|
|
1907
|
-
const
|
|
1907
|
+
const a = await this.hooks.lifecycle.beforeLoadShare.emit({
|
|
1908
1908
|
pkgName: t,
|
|
1909
1909
|
shareInfo: s,
|
|
1910
|
-
shared:
|
|
1911
|
-
origin:
|
|
1912
|
-
}), { shareInfo:
|
|
1913
|
-
assert(
|
|
1914
|
-
const i = getRegisteredShare(this.shareScopeMap, t,
|
|
1915
|
-
u.useIn || (u.useIn = []), addUniqueItem(u.useIn,
|
|
1910
|
+
shared: o.options.shared,
|
|
1911
|
+
origin: o
|
|
1912
|
+
}), { shareInfo: l } = a;
|
|
1913
|
+
assert(l, `Cannot find ${t} Share in the ${o.options.name}. Please ensure that the ${t} Share parameters have been injected`);
|
|
1914
|
+
const i = getRegisteredShare(this.shareScopeMap, t, l, this.hooks.lifecycle.resolveShare), c = (u) => {
|
|
1915
|
+
u.useIn || (u.useIn = []), addUniqueItem(u.useIn, o.options.name);
|
|
1916
1916
|
};
|
|
1917
1917
|
if (i && i.lib)
|
|
1918
1918
|
return c(i), i.lib;
|
|
@@ -1922,32 +1922,32 @@ class SharedHandler {
|
|
|
1922
1922
|
} else if (i) {
|
|
1923
1923
|
const d = (async () => {
|
|
1924
1924
|
const p = await i.get();
|
|
1925
|
-
|
|
1926
|
-
const m = getRegisteredShare(this.shareScopeMap, t,
|
|
1925
|
+
l.lib = p, l.loaded = !0, c(l);
|
|
1926
|
+
const m = getRegisteredShare(this.shareScopeMap, t, l, this.hooks.lifecycle.resolveShare);
|
|
1927
1927
|
return m && (m.lib = p, m.loaded = !0), p;
|
|
1928
1928
|
})();
|
|
1929
1929
|
return this.setShared({
|
|
1930
1930
|
pkgName: t,
|
|
1931
1931
|
loaded: !1,
|
|
1932
1932
|
shared: i,
|
|
1933
|
-
from:
|
|
1933
|
+
from: o.options.name,
|
|
1934
1934
|
lib: null,
|
|
1935
1935
|
loading: d
|
|
1936
1936
|
}), d;
|
|
1937
1937
|
} else {
|
|
1938
|
-
if (
|
|
1938
|
+
if (n != null && n.customShareInfo)
|
|
1939
1939
|
return !1;
|
|
1940
1940
|
const d = (async () => {
|
|
1941
|
-
const p = await
|
|
1942
|
-
|
|
1943
|
-
const m = getRegisteredShare(this.shareScopeMap, t,
|
|
1941
|
+
const p = await l.get();
|
|
1942
|
+
l.lib = p, l.loaded = !0, c(l);
|
|
1943
|
+
const m = getRegisteredShare(this.shareScopeMap, t, l, this.hooks.lifecycle.resolveShare);
|
|
1944
1944
|
return m && (m.lib = p, m.loaded = !0), p;
|
|
1945
1945
|
})();
|
|
1946
1946
|
return this.setShared({
|
|
1947
1947
|
pkgName: t,
|
|
1948
1948
|
loaded: !1,
|
|
1949
|
-
shared:
|
|
1950
|
-
from:
|
|
1949
|
+
shared: l,
|
|
1950
|
+
from: o.options.name,
|
|
1951
1951
|
lib: null,
|
|
1952
1952
|
loading: d
|
|
1953
1953
|
}), d;
|
|
@@ -1959,30 +1959,30 @@ class SharedHandler {
|
|
|
1959
1959
|
* If the share scope does not exist, it creates one.
|
|
1960
1960
|
*/
|
|
1961
1961
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
1962
|
-
initializeSharing(t = DEFAULT_SCOPE,
|
|
1963
|
-
const { host:
|
|
1964
|
-
let
|
|
1962
|
+
initializeSharing(t = DEFAULT_SCOPE, n) {
|
|
1963
|
+
const { host: o } = this, s = n == null ? void 0 : n.from, a = n == null ? void 0 : n.strategy;
|
|
1964
|
+
let l = n == null ? void 0 : n.initScope;
|
|
1965
1965
|
const i = [];
|
|
1966
1966
|
if (s !== "build") {
|
|
1967
1967
|
const { initTokens: _ } = this;
|
|
1968
|
-
|
|
1968
|
+
l || (l = []);
|
|
1969
1969
|
let R = _[t];
|
|
1970
1970
|
if (R || (R = _[t] = {
|
|
1971
1971
|
from: this.host.name
|
|
1972
|
-
}),
|
|
1972
|
+
}), l.indexOf(R) >= 0)
|
|
1973
1973
|
return i;
|
|
1974
|
-
|
|
1974
|
+
l.push(R);
|
|
1975
1975
|
}
|
|
1976
|
-
const c = this.shareScopeMap, u =
|
|
1976
|
+
const c = this.shareScopeMap, u = o.options.name;
|
|
1977
1977
|
c[t] || (c[t] = {});
|
|
1978
1978
|
const d = c[t], p = (_, R) => {
|
|
1979
1979
|
var g;
|
|
1980
|
-
const { version: E, eager:
|
|
1980
|
+
const { version: E, eager: v } = R;
|
|
1981
1981
|
d[_] = d[_] || {};
|
|
1982
|
-
const
|
|
1983
|
-
(!S || S.strategy !== "loaded-first" && !S.loaded && (!
|
|
1984
|
-
}, m = (_) => _ && _.init && _.init(c[t],
|
|
1985
|
-
const { module: R } = await
|
|
1982
|
+
const I = d[_], S = I[E], b = !!(S && (S.eager || (g = S.shareConfig) != null && g.eager));
|
|
1983
|
+
(!S || S.strategy !== "loaded-first" && !S.loaded && (!v != !b ? v : u > S.from)) && (I[E] = R);
|
|
1984
|
+
}, m = (_) => _ && _.init && _.init(c[t], l), y = async (_) => {
|
|
1985
|
+
const { module: R } = await o.remoteHandler.getRemoteModuleAndOptions({
|
|
1986
1986
|
id: _
|
|
1987
1987
|
});
|
|
1988
1988
|
if (R.getEntry) {
|
|
@@ -1990,22 +1990,22 @@ class SharedHandler {
|
|
|
1990
1990
|
try {
|
|
1991
1991
|
g = await R.getEntry();
|
|
1992
1992
|
} catch (E) {
|
|
1993
|
-
g = await
|
|
1993
|
+
g = await o.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
1994
1994
|
id: _,
|
|
1995
1995
|
error: E,
|
|
1996
1996
|
from: "runtime",
|
|
1997
1997
|
lifecycle: "beforeLoadShare",
|
|
1998
|
-
origin:
|
|
1998
|
+
origin: o
|
|
1999
1999
|
});
|
|
2000
2000
|
}
|
|
2001
2001
|
R.inited || (await m(g), R.inited = !0);
|
|
2002
2002
|
}
|
|
2003
2003
|
};
|
|
2004
|
-
return Object.keys(
|
|
2005
|
-
|
|
2004
|
+
return Object.keys(o.options.shared).forEach((_) => {
|
|
2005
|
+
o.options.shared[_].forEach((g) => {
|
|
2006
2006
|
g.scope.includes(t) && p(_, g);
|
|
2007
2007
|
});
|
|
2008
|
-
}), (
|
|
2008
|
+
}), (o.options.shareStrategy === "version-first" || a === "version-first") && o.options.remotes.forEach((_) => {
|
|
2009
2009
|
_.shareScope === t && i.push(y(_.name));
|
|
2010
2010
|
}), i;
|
|
2011
2011
|
}
|
|
@@ -2013,32 +2013,32 @@ class SharedHandler {
|
|
|
2013
2013
|
// 1. If the loaded shared already exists globally, then it will be reused
|
|
2014
2014
|
// 2. If lib exists in local shared, it will be used directly
|
|
2015
2015
|
// 3. If the local get returns something other than Promise, then it will be used directly
|
|
2016
|
-
loadShareSync(t,
|
|
2017
|
-
const { host:
|
|
2016
|
+
loadShareSync(t, n) {
|
|
2017
|
+
const { host: o } = this, s = getTargetSharedOptions({
|
|
2018
2018
|
pkgName: t,
|
|
2019
|
-
extraOptions:
|
|
2020
|
-
shareInfos:
|
|
2019
|
+
extraOptions: n,
|
|
2020
|
+
shareInfos: o.options.shared
|
|
2021
2021
|
});
|
|
2022
2022
|
s != null && s.scope && s.scope.forEach((i) => {
|
|
2023
2023
|
this.initializeSharing(i, {
|
|
2024
2024
|
strategy: s.strategy
|
|
2025
2025
|
});
|
|
2026
2026
|
});
|
|
2027
|
-
const
|
|
2028
|
-
i.useIn || (i.useIn = []), addUniqueItem(i.useIn,
|
|
2027
|
+
const a = getRegisteredShare(this.shareScopeMap, t, s, this.hooks.lifecycle.resolveShare), l = (i) => {
|
|
2028
|
+
i.useIn || (i.useIn = []), addUniqueItem(i.useIn, o.options.name);
|
|
2029
2029
|
};
|
|
2030
|
-
if (
|
|
2031
|
-
if (typeof
|
|
2032
|
-
return a
|
|
2033
|
-
if (typeof
|
|
2034
|
-
const i =
|
|
2030
|
+
if (a) {
|
|
2031
|
+
if (typeof a.lib == "function")
|
|
2032
|
+
return l(a), a.loaded || (a.loaded = !0, a.from === o.options.name && (s.loaded = !0)), a.lib;
|
|
2033
|
+
if (typeof a.get == "function") {
|
|
2034
|
+
const i = a.get();
|
|
2035
2035
|
if (!(i instanceof Promise))
|
|
2036
|
-
return a
|
|
2036
|
+
return l(a), this.setShared({
|
|
2037
2037
|
pkgName: t,
|
|
2038
2038
|
loaded: !0,
|
|
2039
|
-
from:
|
|
2039
|
+
from: o.options.name,
|
|
2040
2040
|
lib: i,
|
|
2041
|
-
shared:
|
|
2041
|
+
shared: a
|
|
2042
2042
|
}), i;
|
|
2043
2043
|
}
|
|
2044
2044
|
}
|
|
@@ -2047,37 +2047,37 @@ class SharedHandler {
|
|
|
2047
2047
|
if (s.get) {
|
|
2048
2048
|
const i = s.get();
|
|
2049
2049
|
if (i instanceof Promise) {
|
|
2050
|
-
const c = (
|
|
2050
|
+
const c = (n == null ? void 0 : n.from) === "build" ? RUNTIME_005 : RUNTIME_006;
|
|
2051
2051
|
throw new Error(getShortErrorMsg(c, runtimeDescMap, {
|
|
2052
|
-
hostName:
|
|
2052
|
+
hostName: o.options.name,
|
|
2053
2053
|
sharedPkgName: t
|
|
2054
2054
|
}));
|
|
2055
2055
|
}
|
|
2056
2056
|
return s.lib = i, this.setShared({
|
|
2057
2057
|
pkgName: t,
|
|
2058
2058
|
loaded: !0,
|
|
2059
|
-
from:
|
|
2059
|
+
from: o.options.name,
|
|
2060
2060
|
lib: s.lib,
|
|
2061
2061
|
shared: s
|
|
2062
2062
|
}), s.lib;
|
|
2063
2063
|
}
|
|
2064
2064
|
throw new Error(getShortErrorMsg(RUNTIME_006, runtimeDescMap, {
|
|
2065
|
-
hostName:
|
|
2065
|
+
hostName: o.options.name,
|
|
2066
2066
|
sharedPkgName: t
|
|
2067
2067
|
}));
|
|
2068
2068
|
}
|
|
2069
|
-
initShareScopeMap(t,
|
|
2069
|
+
initShareScopeMap(t, n, o = {}) {
|
|
2070
2070
|
const { host: s } = this;
|
|
2071
|
-
this.shareScopeMap[t] =
|
|
2072
|
-
shareScope:
|
|
2071
|
+
this.shareScopeMap[t] = n, this.hooks.lifecycle.initContainerShareScopeMap.emit({
|
|
2072
|
+
shareScope: n,
|
|
2073
2073
|
options: s.options,
|
|
2074
2074
|
origin: s,
|
|
2075
2075
|
scopeName: t,
|
|
2076
|
-
hostShareScopeMap:
|
|
2076
|
+
hostShareScopeMap: o.hostShareScopeMap
|
|
2077
2077
|
});
|
|
2078
2078
|
}
|
|
2079
|
-
setShared({ pkgName: t, shared:
|
|
2080
|
-
const { version: c, scope: u = "default" } =
|
|
2079
|
+
setShared({ pkgName: t, shared: n, from: o, lib: s, loading: a, loaded: l, get: i }) {
|
|
2080
|
+
const { version: c, scope: u = "default" } = n, d = _object_without_properties_loose(n, [
|
|
2081
2081
|
"version",
|
|
2082
2082
|
"scope"
|
|
2083
2083
|
]);
|
|
@@ -2092,18 +2092,18 @@ class SharedHandler {
|
|
|
2092
2092
|
]
|
|
2093
2093
|
}, d, {
|
|
2094
2094
|
lib: s,
|
|
2095
|
-
loaded:
|
|
2096
|
-
loading:
|
|
2095
|
+
loaded: l,
|
|
2096
|
+
loading: a
|
|
2097
2097
|
}), i && (this.shareScopeMap[m][t][c].get = i);
|
|
2098
2098
|
return;
|
|
2099
2099
|
}
|
|
2100
2100
|
const y = this.shareScopeMap[m][t][c];
|
|
2101
|
-
|
|
2101
|
+
a && !y.loading && (y.loading = a);
|
|
2102
2102
|
});
|
|
2103
2103
|
}
|
|
2104
2104
|
_setGlobalShareScopeMap(t) {
|
|
2105
|
-
const
|
|
2106
|
-
|
|
2105
|
+
const n = getGlobalShareScope(), o = t.id || t.name;
|
|
2106
|
+
o && !n[o] && (n[o] = this.shareScopeMap);
|
|
2107
2107
|
}
|
|
2108
2108
|
constructor(t) {
|
|
2109
2109
|
this.hooks = new PluginSystem({
|
|
@@ -2118,145 +2118,145 @@ class SharedHandler {
|
|
|
2118
2118
|
}
|
|
2119
2119
|
}
|
|
2120
2120
|
class RemoteHandler {
|
|
2121
|
-
formatAndRegisterRemote(t,
|
|
2122
|
-
return (
|
|
2121
|
+
formatAndRegisterRemote(t, n) {
|
|
2122
|
+
return (n.remotes || []).reduce((s, a) => (this.registerRemote(a, s, {
|
|
2123
2123
|
force: !1
|
|
2124
2124
|
}), s), t.remotes);
|
|
2125
2125
|
}
|
|
2126
|
-
setIdToRemoteMap(t,
|
|
2127
|
-
const { remote:
|
|
2126
|
+
setIdToRemoteMap(t, n) {
|
|
2127
|
+
const { remote: o, expose: s } = n, { name: a, alias: l } = o;
|
|
2128
2128
|
if (this.idToRemoteMap[t] = {
|
|
2129
|
-
name:
|
|
2129
|
+
name: o.name,
|
|
2130
2130
|
expose: s
|
|
2131
|
-
},
|
|
2132
|
-
const i = t.replace(
|
|
2131
|
+
}, l && t.startsWith(a)) {
|
|
2132
|
+
const i = t.replace(a, l);
|
|
2133
2133
|
this.idToRemoteMap[i] = {
|
|
2134
|
-
name:
|
|
2134
|
+
name: o.name,
|
|
2135
2135
|
expose: s
|
|
2136
2136
|
};
|
|
2137
2137
|
return;
|
|
2138
2138
|
}
|
|
2139
|
-
if (
|
|
2140
|
-
const i = t.replace(
|
|
2139
|
+
if (l && t.startsWith(l)) {
|
|
2140
|
+
const i = t.replace(l, a);
|
|
2141
2141
|
this.idToRemoteMap[i] = {
|
|
2142
|
-
name:
|
|
2142
|
+
name: o.name,
|
|
2143
2143
|
expose: s
|
|
2144
2144
|
};
|
|
2145
2145
|
}
|
|
2146
2146
|
}
|
|
2147
2147
|
// eslint-disable-next-line max-lines-per-function
|
|
2148
2148
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
2149
|
-
async loadRemote(t,
|
|
2150
|
-
const { host:
|
|
2149
|
+
async loadRemote(t, n) {
|
|
2150
|
+
const { host: o } = this;
|
|
2151
2151
|
try {
|
|
2152
|
-
const { loadFactory: s = !0 } =
|
|
2152
|
+
const { loadFactory: s = !0 } = n || {
|
|
2153
2153
|
loadFactory: !0
|
|
2154
|
-
}, { module:
|
|
2154
|
+
}, { module: a, moduleOptions: l, remoteMatchInfo: i } = await this.getRemoteModuleAndOptions({
|
|
2155
2155
|
id: t
|
|
2156
|
-
}), { pkgNameOrAlias: c, remote: u, expose: d, id: p, remoteSnapshot: m } = i, y = await
|
|
2156
|
+
}), { pkgNameOrAlias: c, remote: u, expose: d, id: p, remoteSnapshot: m } = i, y = await a.get(p, d, n, m), _ = await this.hooks.lifecycle.onLoad.emit({
|
|
2157
2157
|
id: p,
|
|
2158
2158
|
pkgNameOrAlias: c,
|
|
2159
2159
|
expose: d,
|
|
2160
2160
|
exposeModule: s ? y : void 0,
|
|
2161
2161
|
exposeModuleFactory: s ? void 0 : y,
|
|
2162
2162
|
remote: u,
|
|
2163
|
-
options:
|
|
2164
|
-
moduleInstance:
|
|
2165
|
-
origin:
|
|
2163
|
+
options: l,
|
|
2164
|
+
moduleInstance: a,
|
|
2165
|
+
origin: o
|
|
2166
2166
|
});
|
|
2167
2167
|
return this.setIdToRemoteMap(t, i), typeof _ == "function" ? _ : y;
|
|
2168
2168
|
} catch (s) {
|
|
2169
|
-
const { from:
|
|
2169
|
+
const { from: a = "runtime" } = n || {
|
|
2170
2170
|
from: "runtime"
|
|
2171
|
-
},
|
|
2171
|
+
}, l = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2172
2172
|
id: t,
|
|
2173
2173
|
error: s,
|
|
2174
|
-
from:
|
|
2174
|
+
from: a,
|
|
2175
2175
|
lifecycle: "onLoad",
|
|
2176
|
-
origin:
|
|
2176
|
+
origin: o
|
|
2177
2177
|
});
|
|
2178
|
-
if (!
|
|
2178
|
+
if (!l)
|
|
2179
2179
|
throw s;
|
|
2180
|
-
return
|
|
2180
|
+
return l;
|
|
2181
2181
|
}
|
|
2182
2182
|
}
|
|
2183
2183
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
2184
2184
|
async preloadRemote(t) {
|
|
2185
|
-
const { host:
|
|
2185
|
+
const { host: n } = this;
|
|
2186
2186
|
await this.hooks.lifecycle.beforePreloadRemote.emit({
|
|
2187
2187
|
preloadOps: t,
|
|
2188
|
-
options:
|
|
2189
|
-
origin:
|
|
2188
|
+
options: n.options,
|
|
2189
|
+
origin: n
|
|
2190
2190
|
});
|
|
2191
|
-
const
|
|
2192
|
-
await Promise.all(
|
|
2193
|
-
const { remote:
|
|
2194
|
-
origin:
|
|
2191
|
+
const o = formatPreloadArgs(n.options.remotes, t);
|
|
2192
|
+
await Promise.all(o.map(async (s) => {
|
|
2193
|
+
const { remote: a } = s, l = getRemoteInfo(a), { globalSnapshot: i, remoteSnapshot: c } = await n.snapshotHandler.loadRemoteSnapshotInfo(a), u = await this.hooks.lifecycle.generatePreloadAssets.emit({
|
|
2194
|
+
origin: n,
|
|
2195
2195
|
preloadOptions: s,
|
|
2196
|
-
remote:
|
|
2197
|
-
remoteInfo:
|
|
2196
|
+
remote: a,
|
|
2197
|
+
remoteInfo: l,
|
|
2198
2198
|
globalSnapshot: i,
|
|
2199
2199
|
remoteSnapshot: c
|
|
2200
2200
|
});
|
|
2201
|
-
u && preloadAssets(
|
|
2201
|
+
u && preloadAssets(l, n, u);
|
|
2202
2202
|
}));
|
|
2203
2203
|
}
|
|
2204
|
-
registerRemotes(t,
|
|
2205
|
-
const { host:
|
|
2204
|
+
registerRemotes(t, n) {
|
|
2205
|
+
const { host: o } = this;
|
|
2206
2206
|
t.forEach((s) => {
|
|
2207
|
-
this.registerRemote(s,
|
|
2208
|
-
force:
|
|
2207
|
+
this.registerRemote(s, o.options.remotes, {
|
|
2208
|
+
force: n == null ? void 0 : n.force
|
|
2209
2209
|
});
|
|
2210
2210
|
});
|
|
2211
2211
|
}
|
|
2212
2212
|
async getRemoteModuleAndOptions(t) {
|
|
2213
|
-
const { host:
|
|
2213
|
+
const { host: n } = this, { id: o } = t;
|
|
2214
2214
|
let s;
|
|
2215
2215
|
try {
|
|
2216
2216
|
s = await this.hooks.lifecycle.beforeRequest.emit({
|
|
2217
|
-
id:
|
|
2218
|
-
options:
|
|
2219
|
-
origin:
|
|
2217
|
+
id: o,
|
|
2218
|
+
options: n.options,
|
|
2219
|
+
origin: n
|
|
2220
2220
|
});
|
|
2221
2221
|
} catch (_) {
|
|
2222
2222
|
if (s = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2223
|
-
id:
|
|
2224
|
-
options:
|
|
2225
|
-
origin:
|
|
2223
|
+
id: o,
|
|
2224
|
+
options: n.options,
|
|
2225
|
+
origin: n,
|
|
2226
2226
|
from: "runtime",
|
|
2227
2227
|
error: _,
|
|
2228
2228
|
lifecycle: "beforeRequest"
|
|
2229
2229
|
}), !s)
|
|
2230
2230
|
throw _;
|
|
2231
2231
|
}
|
|
2232
|
-
const { id:
|
|
2233
|
-
assert(
|
|
2234
|
-
hostName:
|
|
2235
|
-
requestId:
|
|
2232
|
+
const { id: a } = s, l = matchRemoteWithNameAndExpose(n.options.remotes, a);
|
|
2233
|
+
assert(l, getShortErrorMsg(RUNTIME_004, runtimeDescMap, {
|
|
2234
|
+
hostName: n.options.name,
|
|
2235
|
+
requestId: a
|
|
2236
2236
|
}));
|
|
2237
|
-
const { remote: i } =
|
|
2238
|
-
id:
|
|
2239
|
-
},
|
|
2240
|
-
options:
|
|
2241
|
-
origin:
|
|
2237
|
+
const { remote: i } = l, c = getRemoteInfo(i), u = await n.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({
|
|
2238
|
+
id: a
|
|
2239
|
+
}, l, {
|
|
2240
|
+
options: n.options,
|
|
2241
|
+
origin: n,
|
|
2242
2242
|
remoteInfo: c
|
|
2243
2243
|
})), { remote: d, expose: p } = u;
|
|
2244
|
-
assert(d && p, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${
|
|
2245
|
-
let m =
|
|
2244
|
+
assert(d && p, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${a}.`);
|
|
2245
|
+
let m = n.moduleCache.get(d.name);
|
|
2246
2246
|
const y = {
|
|
2247
|
-
host:
|
|
2247
|
+
host: n,
|
|
2248
2248
|
remoteInfo: c
|
|
2249
2249
|
};
|
|
2250
|
-
return m || (m = new Module(y),
|
|
2250
|
+
return m || (m = new Module(y), n.moduleCache.set(d.name, m)), {
|
|
2251
2251
|
module: m,
|
|
2252
2252
|
moduleOptions: y,
|
|
2253
2253
|
remoteMatchInfo: u
|
|
2254
2254
|
};
|
|
2255
2255
|
}
|
|
2256
|
-
registerRemote(t,
|
|
2257
|
-
const { host: s } = this,
|
|
2256
|
+
registerRemote(t, n, o) {
|
|
2257
|
+
const { host: s } = this, a = () => {
|
|
2258
2258
|
if (t.alias) {
|
|
2259
|
-
const i =
|
|
2259
|
+
const i = n.find((c) => {
|
|
2260
2260
|
var u;
|
|
2261
2261
|
return t.alias && (c.name.startsWith(t.alias) || ((u = c.alias) == null ? void 0 : u.startsWith(t.alias)));
|
|
2262
2262
|
});
|
|
@@ -2268,9 +2268,9 @@ class RemoteHandler {
|
|
|
2268
2268
|
remote: t,
|
|
2269
2269
|
origin: s
|
|
2270
2270
|
});
|
|
2271
|
-
const
|
|
2272
|
-
if (!
|
|
2273
|
-
|
|
2271
|
+
const l = n.find((i) => i.name === t.name);
|
|
2272
|
+
if (!l)
|
|
2273
|
+
a(), n.push(t), this.hooks.lifecycle.registerRemote.emit({
|
|
2274
2274
|
remote: t,
|
|
2275
2275
|
origin: s
|
|
2276
2276
|
});
|
|
@@ -2279,7 +2279,7 @@ class RemoteHandler {
|
|
|
2279
2279
|
`The remote "${t.name}" is already registered.`,
|
|
2280
2280
|
"Please note that overriding it may cause unexpected errors."
|
|
2281
2281
|
];
|
|
2282
|
-
|
|
2282
|
+
o != null && o.force && (this.removeRemote(l), a(), n.push(t), this.hooks.lifecycle.registerRemote.emit({
|
|
2283
2283
|
remote: t,
|
|
2284
2284
|
origin: s
|
|
2285
2285
|
}), warn$1(i.join(" ")));
|
|
@@ -2287,17 +2287,17 @@ class RemoteHandler {
|
|
|
2287
2287
|
}
|
|
2288
2288
|
removeRemote(t) {
|
|
2289
2289
|
try {
|
|
2290
|
-
const { host:
|
|
2291
|
-
|
|
2292
|
-
const
|
|
2293
|
-
if (
|
|
2294
|
-
const i =
|
|
2290
|
+
const { host: o } = this, { name: s } = t, a = o.options.remotes.findIndex((i) => i.name === s);
|
|
2291
|
+
a !== -1 && o.options.remotes.splice(a, 1);
|
|
2292
|
+
const l = o.moduleCache.get(t.name);
|
|
2293
|
+
if (l) {
|
|
2294
|
+
const i = l.remoteInfo, c = i.entryGlobalName;
|
|
2295
2295
|
if (CurrentGlobal[c]) {
|
|
2296
|
-
var
|
|
2297
|
-
(
|
|
2296
|
+
var n;
|
|
2297
|
+
(n = Object.getOwnPropertyDescriptor(CurrentGlobal, c)) != null && n.configurable ? delete CurrentGlobal[c] : CurrentGlobal[c] = void 0;
|
|
2298
2298
|
}
|
|
2299
|
-
const u = getRemoteEntryUniqueKey(
|
|
2300
|
-
globalLoading[u] && delete globalLoading[u],
|
|
2299
|
+
const u = getRemoteEntryUniqueKey(l.remoteInfo);
|
|
2300
|
+
globalLoading[u] && delete globalLoading[u], o.snapshotHandler.manifestCache.delete(i.entry);
|
|
2301
2301
|
let d = i.buildVersion ? composeKeyWithSeparator(i.name, i.buildVersion) : i.name;
|
|
2302
2302
|
const p = CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex((y) => i.buildVersion ? y.options.id === d : y.name === d);
|
|
2303
2303
|
if (p !== -1) {
|
|
@@ -2307,41 +2307,41 @@ class RemoteHandler {
|
|
|
2307
2307
|
let R = !0;
|
|
2308
2308
|
const g = [];
|
|
2309
2309
|
Object.keys(_).forEach((E) => {
|
|
2310
|
-
const
|
|
2311
|
-
|
|
2312
|
-
const S = I
|
|
2310
|
+
const v = _[E];
|
|
2311
|
+
v && Object.keys(v).forEach((I) => {
|
|
2312
|
+
const S = v[I];
|
|
2313
2313
|
S && Object.keys(S).forEach((b) => {
|
|
2314
2314
|
const $ = S[b];
|
|
2315
|
-
$ && Object.keys($).forEach((
|
|
2316
|
-
const O = $[
|
|
2315
|
+
$ && Object.keys($).forEach((w) => {
|
|
2316
|
+
const O = $[w];
|
|
2317
2317
|
O && typeof O == "object" && O.from === i.name && (O.loaded || O.loading ? (O.useIn = O.useIn.filter((T) => T !== i.name), O.useIn.length ? R = !1 : g.push([
|
|
2318
2318
|
E,
|
|
2319
|
-
|
|
2319
|
+
I,
|
|
2320
2320
|
b,
|
|
2321
|
-
|
|
2321
|
+
w
|
|
2322
2322
|
])) : g.push([
|
|
2323
2323
|
E,
|
|
2324
|
-
|
|
2324
|
+
I,
|
|
2325
2325
|
b,
|
|
2326
|
-
|
|
2326
|
+
w
|
|
2327
2327
|
]));
|
|
2328
2328
|
});
|
|
2329
2329
|
});
|
|
2330
2330
|
});
|
|
2331
|
-
}), R && (y.shareScopeMap = {}, delete _[d]), g.forEach(([E,
|
|
2332
|
-
var b, $,
|
|
2333
|
-
(
|
|
2331
|
+
}), R && (y.shareScopeMap = {}, delete _[d]), g.forEach(([E, v, I, S]) => {
|
|
2332
|
+
var b, $, w;
|
|
2333
|
+
(w = _[E]) == null || ($ = w[v]) == null || (b = $[I]) == null || delete b[S];
|
|
2334
2334
|
}), CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(p, 1);
|
|
2335
2335
|
}
|
|
2336
|
-
const { hostGlobalSnapshot: m } = getGlobalRemoteInfo(t,
|
|
2336
|
+
const { hostGlobalSnapshot: m } = getGlobalRemoteInfo(t, o);
|
|
2337
2337
|
if (m) {
|
|
2338
2338
|
const y = m && "remotesInfo" in m && m.remotesInfo && getInfoWithoutType(m.remotesInfo, t.name).key;
|
|
2339
2339
|
y && (delete m.remotesInfo[y], Global.__FEDERATION__.__MANIFEST_LOADING__[y] && delete Global.__FEDERATION__.__MANIFEST_LOADING__[y]);
|
|
2340
2340
|
}
|
|
2341
|
-
|
|
2341
|
+
o.moduleCache.delete(t.name);
|
|
2342
2342
|
}
|
|
2343
|
-
} catch (
|
|
2344
|
-
logger.log("removeRemote fail: ",
|
|
2343
|
+
} catch (o) {
|
|
2344
|
+
logger.log("removeRemote fail: ", o);
|
|
2345
2345
|
}
|
|
2346
2346
|
}
|
|
2347
2347
|
constructor(t) {
|
|
@@ -2363,59 +2363,59 @@ class RemoteHandler {
|
|
|
2363
2363
|
class FederationHost {
|
|
2364
2364
|
initOptions(t) {
|
|
2365
2365
|
this.registerPlugins(t.plugins);
|
|
2366
|
-
const
|
|
2367
|
-
return this.options =
|
|
2366
|
+
const n = this.formatOptions(this.options, t);
|
|
2367
|
+
return this.options = n, n;
|
|
2368
2368
|
}
|
|
2369
|
-
async loadShare(t,
|
|
2370
|
-
return this.sharedHandler.loadShare(t,
|
|
2369
|
+
async loadShare(t, n) {
|
|
2370
|
+
return this.sharedHandler.loadShare(t, n);
|
|
2371
2371
|
}
|
|
2372
2372
|
// The lib function will only be available if the shared set by eager or runtime init is set or the shared is successfully loaded.
|
|
2373
2373
|
// 1. If the loaded shared already exists globally, then it will be reused
|
|
2374
2374
|
// 2. If lib exists in local shared, it will be used directly
|
|
2375
2375
|
// 3. If the local get returns something other than Promise, then it will be used directly
|
|
2376
|
-
loadShareSync(t,
|
|
2377
|
-
return this.sharedHandler.loadShareSync(t,
|
|
2376
|
+
loadShareSync(t, n) {
|
|
2377
|
+
return this.sharedHandler.loadShareSync(t, n);
|
|
2378
2378
|
}
|
|
2379
|
-
initializeSharing(t = DEFAULT_SCOPE,
|
|
2380
|
-
return this.sharedHandler.initializeSharing(t,
|
|
2379
|
+
initializeSharing(t = DEFAULT_SCOPE, n) {
|
|
2380
|
+
return this.sharedHandler.initializeSharing(t, n);
|
|
2381
2381
|
}
|
|
2382
|
-
initRawContainer(t,
|
|
2382
|
+
initRawContainer(t, n, o) {
|
|
2383
2383
|
const s = getRemoteInfo({
|
|
2384
2384
|
name: t,
|
|
2385
|
-
entry:
|
|
2386
|
-
}),
|
|
2385
|
+
entry: n
|
|
2386
|
+
}), a = new Module({
|
|
2387
2387
|
host: this,
|
|
2388
2388
|
remoteInfo: s
|
|
2389
2389
|
});
|
|
2390
|
-
return
|
|
2390
|
+
return a.remoteEntryExports = o, this.moduleCache.set(t, a), a;
|
|
2391
2391
|
}
|
|
2392
2392
|
// eslint-disable-next-line max-lines-per-function
|
|
2393
2393
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
2394
|
-
async loadRemote(t,
|
|
2395
|
-
return this.remoteHandler.loadRemote(t,
|
|
2394
|
+
async loadRemote(t, n) {
|
|
2395
|
+
return this.remoteHandler.loadRemote(t, n);
|
|
2396
2396
|
}
|
|
2397
2397
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
2398
2398
|
async preloadRemote(t) {
|
|
2399
2399
|
return this.remoteHandler.preloadRemote(t);
|
|
2400
2400
|
}
|
|
2401
|
-
initShareScopeMap(t,
|
|
2402
|
-
this.sharedHandler.initShareScopeMap(t,
|
|
2401
|
+
initShareScopeMap(t, n, o = {}) {
|
|
2402
|
+
this.sharedHandler.initShareScopeMap(t, n, o);
|
|
2403
2403
|
}
|
|
2404
|
-
formatOptions(t,
|
|
2405
|
-
const { shared:
|
|
2404
|
+
formatOptions(t, n) {
|
|
2405
|
+
const { shared: o } = formatShareConfigs(t, n), { userOptions: s, options: a } = this.hooks.lifecycle.beforeInit.emit({
|
|
2406
2406
|
origin: this,
|
|
2407
|
-
userOptions:
|
|
2407
|
+
userOptions: n,
|
|
2408
2408
|
options: t,
|
|
2409
|
-
shareInfo:
|
|
2410
|
-
}),
|
|
2411
|
-
...
|
|
2409
|
+
shareInfo: o
|
|
2410
|
+
}), l = this.remoteHandler.formatAndRegisterRemote(a, s), { shared: i } = this.sharedHandler.registerShared(a, s), c = [
|
|
2411
|
+
...a.plugins
|
|
2412
2412
|
];
|
|
2413
2413
|
s.plugins && s.plugins.forEach((d) => {
|
|
2414
2414
|
c.includes(d) || c.push(d);
|
|
2415
2415
|
});
|
|
2416
|
-
const u = _extends$1({}, t,
|
|
2416
|
+
const u = _extends$1({}, t, n, {
|
|
2417
2417
|
plugins: c,
|
|
2418
|
-
remotes:
|
|
2418
|
+
remotes: l,
|
|
2419
2419
|
shared: i
|
|
2420
2420
|
});
|
|
2421
2421
|
return this.hooks.lifecycle.init.emit({
|
|
@@ -2424,7 +2424,7 @@ class FederationHost {
|
|
|
2424
2424
|
}), u;
|
|
2425
2425
|
}
|
|
2426
2426
|
registerPlugins(t) {
|
|
2427
|
-
const
|
|
2427
|
+
const n = registerPlugins$1(t, [
|
|
2428
2428
|
this.hooks,
|
|
2429
2429
|
this.remoteHandler.hooks,
|
|
2430
2430
|
this.sharedHandler.hooks,
|
|
@@ -2432,10 +2432,10 @@ class FederationHost {
|
|
|
2432
2432
|
this.loaderHook,
|
|
2433
2433
|
this.bridgeHook
|
|
2434
2434
|
]);
|
|
2435
|
-
this.options.plugins = this.options.plugins.reduce((
|
|
2435
|
+
this.options.plugins = this.options.plugins.reduce((o, s) => (s && o && !o.find((a) => a.name === s.name) && o.push(s), o), n || []);
|
|
2436
2436
|
}
|
|
2437
|
-
registerRemotes(t,
|
|
2438
|
-
return this.remoteHandler.registerRemotes(t,
|
|
2437
|
+
registerRemotes(t, n) {
|
|
2438
|
+
return this.remoteHandler.registerRemotes(t, n);
|
|
2439
2439
|
}
|
|
2440
2440
|
constructor(t) {
|
|
2441
2441
|
this.hooks = new PluginSystem({
|
|
@@ -2445,7 +2445,7 @@ class FederationHost {
|
|
|
2445
2445
|
beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
|
|
2446
2446
|
// maybe will change, temporarily for internal use only
|
|
2447
2447
|
initContainer: new AsyncWaterfallHook("initContainer")
|
|
2448
|
-
}), this.version = "0.8.
|
|
2448
|
+
}), this.version = "0.8.5", this.moduleCache = /* @__PURE__ */ new Map(), this.loaderHook = new PluginSystem({
|
|
2449
2449
|
// FIXME: may not be suitable , not open to the public yet
|
|
2450
2450
|
getModuleInfo: new SyncHook(),
|
|
2451
2451
|
createScript: new SyncHook(),
|
|
@@ -2459,7 +2459,7 @@ class FederationHost {
|
|
|
2459
2459
|
beforeBridgeDestroy: new SyncHook(),
|
|
2460
2460
|
afterBridgeDestroy: new SyncHook()
|
|
2461
2461
|
});
|
|
2462
|
-
const
|
|
2462
|
+
const n = {
|
|
2463
2463
|
id: getBuilderId(),
|
|
2464
2464
|
name: t.name,
|
|
2465
2465
|
plugins: [
|
|
@@ -2470,41 +2470,49 @@ class FederationHost {
|
|
|
2470
2470
|
shared: {},
|
|
2471
2471
|
inBrowser: isBrowserEnv()
|
|
2472
2472
|
};
|
|
2473
|
-
this.name = t.name, this.options =
|
|
2474
|
-
...
|
|
2473
|
+
this.name = t.name, this.options = n, this.snapshotHandler = new SnapshotHandler(this), this.sharedHandler = new SharedHandler(this), this.remoteHandler = new RemoteHandler(this), this.shareScopeMap = this.sharedHandler.shareScopeMap, this.registerPlugins([
|
|
2474
|
+
...n.plugins,
|
|
2475
2475
|
...t.plugins || []
|
|
2476
|
-
]), this.options = this.formatOptions(
|
|
2476
|
+
]), this.options = this.formatOptions(n, t);
|
|
2477
2477
|
}
|
|
2478
2478
|
}
|
|
2479
|
+
let FederationInstance = null;
|
|
2480
|
+
function getInstance() {
|
|
2481
|
+
return FederationInstance;
|
|
2482
|
+
}
|
|
2479
2483
|
setGlobalFederationConstructor(FederationHost);
|
|
2480
2484
|
function createBridgeComponent(r) {
|
|
2481
|
-
const t = /* @__PURE__ */ new Map();
|
|
2485
|
+
const t = /* @__PURE__ */ new Map(), n = getInstance();
|
|
2482
2486
|
return () => ({
|
|
2483
|
-
__APP_VERSION__: "0.8.
|
|
2484
|
-
render(o) {
|
|
2487
|
+
__APP_VERSION__: "0.8.5",
|
|
2488
|
+
async render(o) {
|
|
2489
|
+
var c, u, d;
|
|
2485
2490
|
LoggerInstance.log("createBridgeComponent render Info", o);
|
|
2486
|
-
const
|
|
2487
|
-
t.set(o.dom,
|
|
2488
|
-
const
|
|
2491
|
+
const s = Vue.createApp(r.rootComponent);
|
|
2492
|
+
t.set(o.dom, s);
|
|
2493
|
+
const a = await ((d = (u = (c = n == null ? void 0 : n.bridgeHook) == null ? void 0 : c.lifecycle) == null ? void 0 : u.beforeBridgeRender) == null ? void 0 : d.emit(o)), l = a && typeof a == "object" && (a != null && a.extraProps) ? a == null ? void 0 : a.extraProps : {}, i = r.appOptions({
|
|
2494
|
+
app: s,
|
|
2489
2495
|
basename: o.basename,
|
|
2490
2496
|
memoryRoute: o.memoryRoute,
|
|
2491
2497
|
...l
|
|
2492
|
-
}), i = o.memoryRoute ? VueRouter.createMemoryHistory(o.basename) : VueRouter.createWebHistory(o.basename), c = VueRouter.createRouter({
|
|
2493
|
-
...a.router.options,
|
|
2494
|
-
history: i,
|
|
2495
|
-
routes: a.router.getRoutes()
|
|
2496
2498
|
});
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2499
|
+
if (i != null && i.router) {
|
|
2500
|
+
const p = o.memoryRoute ? VueRouter.createMemoryHistory(o.basename) : VueRouter.createWebHistory(o.basename), m = VueRouter.createRouter({
|
|
2501
|
+
...i.router.options,
|
|
2502
|
+
history: p,
|
|
2503
|
+
routes: i.router.getRoutes()
|
|
2504
|
+
});
|
|
2505
|
+
LoggerInstance.log("createBridgeComponent render router info>>>", {
|
|
2506
|
+
name: o.moduleName,
|
|
2507
|
+
router: m
|
|
2508
|
+
}), o.memoryRoute && await m.push(o.memoryRoute.entryPath), s.use(m);
|
|
2509
|
+
}
|
|
2510
|
+
s.mount(o.dom);
|
|
2503
2511
|
},
|
|
2504
2512
|
destroy(o) {
|
|
2505
2513
|
LoggerInstance.log("createBridgeComponent destroy Info", o);
|
|
2506
|
-
const
|
|
2507
|
-
|
|
2514
|
+
const s = t.get(o == null ? void 0 : o.dom);
|
|
2515
|
+
s == null || s.unmount();
|
|
2508
2516
|
}
|
|
2509
2517
|
});
|
|
2510
2518
|
}
|
|
@@ -2521,10 +2529,10 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2521
2529
|
providerInfo: Function
|
|
2522
2530
|
},
|
|
2523
2531
|
setup(r) {
|
|
2524
|
-
const t = ref(null),
|
|
2532
|
+
const t = ref(null), n = ref(null), o = ref(""), s = useRoute(), a = () => {
|
|
2525
2533
|
var d;
|
|
2526
2534
|
const i = (d = r.providerInfo) == null ? void 0 : d.call(r);
|
|
2527
|
-
|
|
2535
|
+
n.value = i;
|
|
2528
2536
|
let c = {
|
|
2529
2537
|
name: r.moduleName,
|
|
2530
2538
|
dom: t.value,
|
|
@@ -2535,19 +2543,19 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2535
2543
|
...c,
|
|
2536
2544
|
...{}.extraProps
|
|
2537
2545
|
}, i.render(c);
|
|
2538
|
-
},
|
|
2539
|
-
i !== s.path &&
|
|
2546
|
+
}, l = watch(() => s.path, (i) => {
|
|
2547
|
+
i !== s.path && a(), o.value !== "" && o.value !== i && (LoggerInstance.log("createRemoteComponent dispatchPopstateEnv >>>", {
|
|
2540
2548
|
...r,
|
|
2541
2549
|
pathname: s.path
|
|
2542
|
-
}), e()),
|
|
2550
|
+
}), e()), o.value = i;
|
|
2543
2551
|
});
|
|
2544
2552
|
return onMounted(() => {
|
|
2545
|
-
|
|
2553
|
+
a();
|
|
2546
2554
|
}), onBeforeUnmount(() => {
|
|
2547
2555
|
var i;
|
|
2548
2556
|
LoggerInstance.log("createRemoteComponent LazyComponent destroy >>>", {
|
|
2549
2557
|
...r
|
|
2550
|
-
}),
|
|
2558
|
+
}), l(), (i = n.value) == null || i.destroy({
|
|
2551
2559
|
dom: t.value
|
|
2552
2560
|
});
|
|
2553
2561
|
}), () => createVNode("div", {
|
|
@@ -2557,31 +2565,31 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2557
2565
|
});
|
|
2558
2566
|
function createRemoteComponent(r) {
|
|
2559
2567
|
return defineAsyncComponent({
|
|
2560
|
-
__APP_VERSION__: "0.8.
|
|
2568
|
+
__APP_VERSION__: "0.8.5",
|
|
2561
2569
|
...r.asyncComponentOptions,
|
|
2562
2570
|
//@ts-ignore
|
|
2563
2571
|
loader: async () => {
|
|
2564
2572
|
var c;
|
|
2565
2573
|
const t = useRoute();
|
|
2566
|
-
let
|
|
2567
|
-
const
|
|
2568
|
-
|
|
2574
|
+
let n = "/";
|
|
2575
|
+
const o = (c = t.matched[0]) == null ? void 0 : c.path;
|
|
2576
|
+
o && (o.endsWith("/:pathMatch(.*)*") ? n = o.replace("/:pathMatch(.*)*", "") : n = t.matched[0].path);
|
|
2569
2577
|
const s = (r == null ? void 0 : r.export) || "default";
|
|
2570
2578
|
LoggerInstance.log("createRemoteComponent LazyComponent create >>>", {
|
|
2571
|
-
basename:
|
|
2579
|
+
basename: n,
|
|
2572
2580
|
info: r
|
|
2573
2581
|
});
|
|
2574
|
-
const
|
|
2582
|
+
const a = await r.loader(), l = a && a[Symbol.for("mf_module_id")], i = a[s];
|
|
2575
2583
|
if (LoggerInstance.log(
|
|
2576
2584
|
"createRemoteComponent LazyComponent loadRemote info >>>",
|
|
2577
|
-
{ name:
|
|
2578
|
-
), s in
|
|
2585
|
+
{ name: l, module: a, exportName: s, basename: n, route: t }
|
|
2586
|
+
), s in a && typeof i == "function")
|
|
2579
2587
|
return {
|
|
2580
2588
|
render() {
|
|
2581
2589
|
return h(RemoteApp, {
|
|
2582
|
-
moduleName:
|
|
2590
|
+
moduleName: l,
|
|
2583
2591
|
providerInfo: i,
|
|
2584
|
-
basename:
|
|
2592
|
+
basename: n
|
|
2585
2593
|
});
|
|
2586
2594
|
}
|
|
2587
2595
|
};
|