@module-federation/bridge-vue3 0.0.0-next-20241216131539 → 0.0.0-next-20241218082038
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 +14 -4
- package/dist/index.cjs.js +8 -8
- package/dist/index.d.ts +18 -2
- package/dist/index.es.js +704 -694
- 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", BUILD_001 = "BUILD-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);
|
|
@@ -1018,142 +1018,144 @@ const runtimeDescMap = {
|
|
|
1018
1018
|
[RUNTIME_007]: "Failed to get remote snapshot."
|
|
1019
1019
|
}, typeDescMap = {
|
|
1020
1020
|
[TYPE_001]: "Failed to generate type declaration."
|
|
1021
|
+
}, buildDescMap = {
|
|
1022
|
+
[BUILD_001]: "Failed to find expose module."
|
|
1021
1023
|
};
|
|
1022
|
-
_extends({}, runtimeDescMap, typeDescMap);
|
|
1024
|
+
_extends({}, runtimeDescMap, typeDescMap, buildDescMap);
|
|
1023
1025
|
function matchRemoteWithNameAndExpose(r, t) {
|
|
1024
|
-
for (const
|
|
1025
|
-
const
|
|
1026
|
-
let s = t.replace(
|
|
1027
|
-
if (
|
|
1026
|
+
for (const n of r) {
|
|
1027
|
+
const o = t.startsWith(n.name);
|
|
1028
|
+
let s = t.replace(n.name, "");
|
|
1029
|
+
if (o) {
|
|
1028
1030
|
if (s.startsWith("/")) {
|
|
1029
|
-
const i =
|
|
1031
|
+
const i = n.name;
|
|
1030
1032
|
return s = `.${s}`, {
|
|
1031
1033
|
pkgNameOrAlias: i,
|
|
1032
1034
|
expose: s,
|
|
1033
|
-
remote:
|
|
1035
|
+
remote: n
|
|
1034
1036
|
};
|
|
1035
1037
|
} else if (s === "")
|
|
1036
1038
|
return {
|
|
1037
|
-
pkgNameOrAlias:
|
|
1039
|
+
pkgNameOrAlias: n.name,
|
|
1038
1040
|
expose: ".",
|
|
1039
|
-
remote:
|
|
1041
|
+
remote: n
|
|
1040
1042
|
};
|
|
1041
1043
|
}
|
|
1042
|
-
const
|
|
1043
|
-
let
|
|
1044
|
-
if (
|
|
1045
|
-
if (
|
|
1046
|
-
const i =
|
|
1047
|
-
return
|
|
1044
|
+
const a = n.alias && t.startsWith(n.alias);
|
|
1045
|
+
let l = n.alias && t.replace(n.alias, "");
|
|
1046
|
+
if (n.alias && a) {
|
|
1047
|
+
if (l && l.startsWith("/")) {
|
|
1048
|
+
const i = n.alias;
|
|
1049
|
+
return l = `.${l}`, {
|
|
1048
1050
|
pkgNameOrAlias: i,
|
|
1049
|
-
expose:
|
|
1050
|
-
remote:
|
|
1051
|
+
expose: l,
|
|
1052
|
+
remote: n
|
|
1051
1053
|
};
|
|
1052
|
-
} else if (
|
|
1054
|
+
} else if (l === "")
|
|
1053
1055
|
return {
|
|
1054
|
-
pkgNameOrAlias:
|
|
1056
|
+
pkgNameOrAlias: n.alias,
|
|
1055
1057
|
expose: ".",
|
|
1056
|
-
remote:
|
|
1058
|
+
remote: n
|
|
1057
1059
|
};
|
|
1058
1060
|
}
|
|
1059
1061
|
}
|
|
1060
1062
|
}
|
|
1061
1063
|
function matchRemote(r, t) {
|
|
1062
|
-
for (const
|
|
1063
|
-
if (t ===
|
|
1064
|
-
return
|
|
1064
|
+
for (const n of r)
|
|
1065
|
+
if (t === n.name || n.alias && t === n.alias)
|
|
1066
|
+
return n;
|
|
1065
1067
|
}
|
|
1066
1068
|
function registerPlugins$1(r, t) {
|
|
1067
|
-
const
|
|
1068
|
-
return
|
|
1069
|
-
r != null && r.find((s) => s.name !==
|
|
1070
|
-
}), r && r.length > 0 && r.forEach((
|
|
1069
|
+
const n = getGlobalHostPlugins();
|
|
1070
|
+
return n.length > 0 && n.forEach((o) => {
|
|
1071
|
+
r != null && r.find((s) => s.name !== o.name) && r.push(o);
|
|
1072
|
+
}), r && r.length > 0 && r.forEach((o) => {
|
|
1071
1073
|
t.forEach((s) => {
|
|
1072
|
-
s.applyPlugin(
|
|
1074
|
+
s.applyPlugin(o);
|
|
1073
1075
|
});
|
|
1074
1076
|
}), r;
|
|
1075
1077
|
}
|
|
1076
1078
|
async function loadEsmEntry({ entry: r, remoteEntryExports: t }) {
|
|
1077
|
-
return new Promise((
|
|
1079
|
+
return new Promise((n, o) => {
|
|
1078
1080
|
try {
|
|
1079
|
-
t ?
|
|
1080
|
-
|
|
1081
|
-
|
|
1081
|
+
t ? n(t) : typeof FEDERATION_ALLOW_NEW_FUNCTION < "u" ? new Function("callbacks", `import("${r}").then(callbacks[0]).catch(callbacks[1])`)([
|
|
1082
|
+
n,
|
|
1083
|
+
o
|
|
1082
1084
|
]) : import(
|
|
1083
1085
|
/* webpackIgnore: true */
|
|
1084
1086
|
/* @vite-ignore */
|
|
1085
1087
|
r
|
|
1086
|
-
).then(
|
|
1088
|
+
).then(n).catch(o);
|
|
1087
1089
|
} catch (s) {
|
|
1088
|
-
|
|
1090
|
+
o(s);
|
|
1089
1091
|
}
|
|
1090
1092
|
});
|
|
1091
1093
|
}
|
|
1092
1094
|
async function loadSystemJsEntry({ entry: r, remoteEntryExports: t }) {
|
|
1093
|
-
return new Promise((
|
|
1095
|
+
return new Promise((n, o) => {
|
|
1094
1096
|
try {
|
|
1095
|
-
t ?
|
|
1096
|
-
|
|
1097
|
-
|
|
1097
|
+
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])`)([
|
|
1098
|
+
n,
|
|
1099
|
+
o
|
|
1098
1100
|
]);
|
|
1099
1101
|
} catch (s) {
|
|
1100
|
-
|
|
1102
|
+
o(s);
|
|
1101
1103
|
}
|
|
1102
1104
|
});
|
|
1103
1105
|
}
|
|
1104
|
-
async function loadEntryScript({ name: r, globalName: t, entry:
|
|
1106
|
+
async function loadEntryScript({ name: r, globalName: t, entry: n, loaderHook: o }) {
|
|
1105
1107
|
const { entryExports: s } = getRemoteEntryExports(r, t);
|
|
1106
|
-
return s || loadScript(
|
|
1108
|
+
return s || loadScript(n, {
|
|
1107
1109
|
attrs: {},
|
|
1108
|
-
createScriptHook: (
|
|
1109
|
-
const i =
|
|
1110
|
-
url:
|
|
1111
|
-
attrs:
|
|
1110
|
+
createScriptHook: (a, l) => {
|
|
1111
|
+
const i = o.lifecycle.createScript.emit({
|
|
1112
|
+
url: a,
|
|
1113
|
+
attrs: l
|
|
1112
1114
|
});
|
|
1113
1115
|
if (i && (i instanceof HTMLScriptElement || "script" in i || "timeout" in i))
|
|
1114
1116
|
return i;
|
|
1115
1117
|
}
|
|
1116
1118
|
}).then(() => {
|
|
1117
|
-
const { remoteEntryKey:
|
|
1118
|
-
return assert(
|
|
1119
|
+
const { remoteEntryKey: a, entryExports: l } = getRemoteEntryExports(r, t);
|
|
1120
|
+
return assert(l, getShortErrorMsg(RUNTIME_001, runtimeDescMap, {
|
|
1119
1121
|
remoteName: r,
|
|
1120
|
-
remoteEntryUrl:
|
|
1121
|
-
remoteEntryKey:
|
|
1122
|
-
})),
|
|
1123
|
-
}).catch((
|
|
1124
|
-
throw
|
|
1122
|
+
remoteEntryUrl: n,
|
|
1123
|
+
remoteEntryKey: a
|
|
1124
|
+
})), l;
|
|
1125
|
+
}).catch((a) => {
|
|
1126
|
+
throw a;
|
|
1125
1127
|
});
|
|
1126
1128
|
}
|
|
1127
|
-
async function loadEntryDom({ remoteInfo: r, remoteEntryExports: t, loaderHook:
|
|
1128
|
-
const { entry:
|
|
1129
|
-
switch (
|
|
1129
|
+
async function loadEntryDom({ remoteInfo: r, remoteEntryExports: t, loaderHook: n }) {
|
|
1130
|
+
const { entry: o, entryGlobalName: s, name: a, type: l } = r;
|
|
1131
|
+
switch (l) {
|
|
1130
1132
|
case "esm":
|
|
1131
1133
|
case "module":
|
|
1132
1134
|
return loadEsmEntry({
|
|
1133
|
-
entry:
|
|
1135
|
+
entry: o,
|
|
1134
1136
|
remoteEntryExports: t
|
|
1135
1137
|
});
|
|
1136
1138
|
case "system":
|
|
1137
1139
|
return loadSystemJsEntry({
|
|
1138
|
-
entry:
|
|
1140
|
+
entry: o,
|
|
1139
1141
|
remoteEntryExports: t
|
|
1140
1142
|
});
|
|
1141
1143
|
default:
|
|
1142
1144
|
return loadEntryScript({
|
|
1143
|
-
entry:
|
|
1145
|
+
entry: o,
|
|
1144
1146
|
globalName: s,
|
|
1145
|
-
name:
|
|
1146
|
-
loaderHook:
|
|
1147
|
+
name: a,
|
|
1148
|
+
loaderHook: n
|
|
1147
1149
|
});
|
|
1148
1150
|
}
|
|
1149
1151
|
}
|
|
1150
1152
|
async function loadEntryNode({ remoteInfo: r, loaderHook: t }) {
|
|
1151
|
-
const { entry:
|
|
1152
|
-
return
|
|
1153
|
+
const { entry: n, entryGlobalName: o, name: s, type: a } = r, { entryExports: l } = getRemoteEntryExports(s, o);
|
|
1154
|
+
return l || loadScriptNode(n, {
|
|
1153
1155
|
attrs: {
|
|
1154
1156
|
name: s,
|
|
1155
|
-
globalName:
|
|
1156
|
-
type:
|
|
1157
|
+
globalName: o,
|
|
1158
|
+
type: a
|
|
1157
1159
|
},
|
|
1158
1160
|
loaderHook: {
|
|
1159
1161
|
createScriptHook: (i, c = {}) => {
|
|
@@ -1166,10 +1168,10 @@ async function loadEntryNode({ remoteInfo: r, loaderHook: t }) {
|
|
|
1166
1168
|
}
|
|
1167
1169
|
}
|
|
1168
1170
|
}).then(() => {
|
|
1169
|
-
const { remoteEntryKey: i, entryExports: c } = getRemoteEntryExports(s,
|
|
1171
|
+
const { remoteEntryKey: i, entryExports: c } = getRemoteEntryExports(s, o);
|
|
1170
1172
|
return assert(c, getShortErrorMsg(RUNTIME_001, runtimeDescMap, {
|
|
1171
1173
|
remoteName: s,
|
|
1172
|
-
remoteEntryUrl:
|
|
1174
|
+
remoteEntryUrl: n,
|
|
1173
1175
|
remoteEntryKey: i
|
|
1174
1176
|
})), c;
|
|
1175
1177
|
}).catch((i) => {
|
|
@@ -1177,29 +1179,29 @@ async function loadEntryNode({ remoteInfo: r, loaderHook: t }) {
|
|
|
1177
1179
|
});
|
|
1178
1180
|
}
|
|
1179
1181
|
function getRemoteEntryUniqueKey(r) {
|
|
1180
|
-
const { entry: t, name:
|
|
1181
|
-
return composeKeyWithSeparator(
|
|
1182
|
+
const { entry: t, name: n } = r;
|
|
1183
|
+
return composeKeyWithSeparator(n, t);
|
|
1182
1184
|
}
|
|
1183
|
-
async function getRemoteEntry({ origin: r, remoteEntryExports: t, remoteInfo:
|
|
1184
|
-
const
|
|
1185
|
+
async function getRemoteEntry({ origin: r, remoteEntryExports: t, remoteInfo: n }) {
|
|
1186
|
+
const o = getRemoteEntryUniqueKey(n);
|
|
1185
1187
|
if (t)
|
|
1186
1188
|
return t;
|
|
1187
|
-
if (!globalLoading[
|
|
1188
|
-
const s = r.remoteHandler.hooks.lifecycle.loadEntry,
|
|
1189
|
-
globalLoading[
|
|
1190
|
-
loaderHook:
|
|
1191
|
-
remoteInfo:
|
|
1189
|
+
if (!globalLoading[o]) {
|
|
1190
|
+
const s = r.remoteHandler.hooks.lifecycle.loadEntry, a = r.loaderHook;
|
|
1191
|
+
globalLoading[o] = s.emit({
|
|
1192
|
+
loaderHook: a,
|
|
1193
|
+
remoteInfo: n,
|
|
1192
1194
|
remoteEntryExports: t
|
|
1193
|
-
}).then((
|
|
1194
|
-
remoteInfo:
|
|
1195
|
+
}).then((l) => l || (isBrowserEnv() ? loadEntryDom({
|
|
1196
|
+
remoteInfo: n,
|
|
1195
1197
|
remoteEntryExports: t,
|
|
1196
|
-
loaderHook:
|
|
1198
|
+
loaderHook: a
|
|
1197
1199
|
}) : loadEntryNode({
|
|
1198
|
-
remoteInfo:
|
|
1199
|
-
loaderHook:
|
|
1200
|
+
remoteInfo: n,
|
|
1201
|
+
loaderHook: a
|
|
1200
1202
|
})));
|
|
1201
1203
|
}
|
|
1202
|
-
return globalLoading[
|
|
1204
|
+
return globalLoading[o];
|
|
1203
1205
|
}
|
|
1204
1206
|
function getRemoteInfo(r) {
|
|
1205
1207
|
return _extends$1({}, r, {
|
|
@@ -1221,24 +1223,24 @@ let Module = class {
|
|
|
1221
1223
|
remoteEntryExports: this.remoteEntryExports
|
|
1222
1224
|
});
|
|
1223
1225
|
} catch {
|
|
1224
|
-
const
|
|
1226
|
+
const o = getRemoteEntryUniqueKey(this.remoteInfo);
|
|
1225
1227
|
t = await this.host.loaderHook.lifecycle.loadEntryError.emit({
|
|
1226
1228
|
getRemoteEntry,
|
|
1227
1229
|
origin: this.host,
|
|
1228
1230
|
remoteInfo: this.remoteInfo,
|
|
1229
1231
|
remoteEntryExports: this.remoteEntryExports,
|
|
1230
1232
|
globalLoading,
|
|
1231
|
-
uniqueKey:
|
|
1233
|
+
uniqueKey: o
|
|
1232
1234
|
});
|
|
1233
1235
|
}
|
|
1234
1236
|
return assert(t, `remoteEntryExports is undefined
|
|
1235
1237
|
${safeToString(this.remoteInfo)}`), this.remoteEntryExports = t, this.remoteEntryExports;
|
|
1236
1238
|
}
|
|
1237
1239
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1238
|
-
async get(t,
|
|
1239
|
-
const { loadFactory:
|
|
1240
|
+
async get(t, n, o, s) {
|
|
1241
|
+
const { loadFactory: a = !0 } = o || {
|
|
1240
1242
|
loadFactory: !0
|
|
1241
|
-
},
|
|
1243
|
+
}, l = await this.getEntry();
|
|
1242
1244
|
if (!this.inited) {
|
|
1243
1245
|
const p = this.host.shareScopeMap, m = this.remoteInfo.shareScope || "default";
|
|
1244
1246
|
p[m] || (p[m] = {});
|
|
@@ -1258,43 +1260,43 @@ let Module = class {
|
|
|
1258
1260
|
remoteInfo: this.remoteInfo,
|
|
1259
1261
|
origin: this.host
|
|
1260
1262
|
});
|
|
1261
|
-
typeof (
|
|
1263
|
+
typeof (l == null ? void 0 : l.init) > "u" && error(getShortErrorMsg(RUNTIME_002, runtimeDescMap, {
|
|
1262
1264
|
remoteName: name,
|
|
1263
1265
|
remoteEntryUrl: this.remoteInfo.entry,
|
|
1264
1266
|
remoteEntryKey: this.remoteInfo.entryGlobalName
|
|
1265
|
-
})), await
|
|
1267
|
+
})), await l.init(g.shareScope, g.initScope, g.remoteEntryInitOptions), await this.host.hooks.lifecycle.initContainer.emit(_extends$1({}, g, {
|
|
1266
1268
|
id: t,
|
|
1267
1269
|
remoteSnapshot: s,
|
|
1268
|
-
remoteEntryExports:
|
|
1270
|
+
remoteEntryExports: l
|
|
1269
1271
|
}));
|
|
1270
1272
|
}
|
|
1271
|
-
this.lib =
|
|
1273
|
+
this.lib = l, this.inited = !0;
|
|
1272
1274
|
let i;
|
|
1273
1275
|
i = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
|
|
1274
|
-
remoteEntryExports:
|
|
1275
|
-
expose:
|
|
1276
|
+
remoteEntryExports: l,
|
|
1277
|
+
expose: n,
|
|
1276
1278
|
moduleInfo: this.remoteInfo
|
|
1277
|
-
}), i || (i = await
|
|
1278
|
-
const c = processModuleAlias(this.remoteInfo.name,
|
|
1279
|
-
return
|
|
1279
|
+
}), i || (i = await l.get(n)), assert(i, `${getFMId(this.remoteInfo)} remote don't export ${n}.`);
|
|
1280
|
+
const c = processModuleAlias(this.remoteInfo.name, n), u = this.wraperFactory(i, c);
|
|
1281
|
+
return a ? await u() : u;
|
|
1280
1282
|
}
|
|
1281
|
-
wraperFactory(t,
|
|
1282
|
-
function
|
|
1283
|
+
wraperFactory(t, n) {
|
|
1284
|
+
function o(s, a) {
|
|
1283
1285
|
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:
|
|
1286
|
+
value: a,
|
|
1285
1287
|
enumerable: !1
|
|
1286
1288
|
});
|
|
1287
1289
|
}
|
|
1288
1290
|
return t instanceof Promise ? async () => {
|
|
1289
1291
|
const s = await t();
|
|
1290
|
-
return
|
|
1292
|
+
return o(s, n), s;
|
|
1291
1293
|
} : () => {
|
|
1292
1294
|
const s = t();
|
|
1293
|
-
return
|
|
1295
|
+
return o(s, n), s;
|
|
1294
1296
|
};
|
|
1295
1297
|
}
|
|
1296
|
-
constructor({ remoteInfo: t, host:
|
|
1297
|
-
this.inited = !1, this.lib = void 0, this.remoteInfo = t, this.host =
|
|
1298
|
+
constructor({ remoteInfo: t, host: n }) {
|
|
1299
|
+
this.inited = !1, this.lib = void 0, this.remoteInfo = t, this.host = n;
|
|
1298
1300
|
}
|
|
1299
1301
|
};
|
|
1300
1302
|
class SyncHook {
|
|
@@ -1302,16 +1304,16 @@ class SyncHook {
|
|
|
1302
1304
|
typeof t == "function" && this.listeners.add(t);
|
|
1303
1305
|
}
|
|
1304
1306
|
once(t) {
|
|
1305
|
-
const
|
|
1306
|
-
this.on(function
|
|
1307
|
-
return
|
|
1307
|
+
const n = this;
|
|
1308
|
+
this.on(function o(...s) {
|
|
1309
|
+
return n.remove(o), t.apply(null, s);
|
|
1308
1310
|
});
|
|
1309
1311
|
}
|
|
1310
1312
|
emit(...t) {
|
|
1311
|
-
let
|
|
1312
|
-
return this.listeners.size > 0 && this.listeners.forEach((
|
|
1313
|
-
|
|
1314
|
-
}),
|
|
1313
|
+
let n;
|
|
1314
|
+
return this.listeners.size > 0 && this.listeners.forEach((o) => {
|
|
1315
|
+
n = o(...t);
|
|
1316
|
+
}), n;
|
|
1315
1317
|
}
|
|
1316
1318
|
remove(t) {
|
|
1317
1319
|
this.listeners.delete(t);
|
|
@@ -1325,22 +1327,22 @@ class SyncHook {
|
|
|
1325
1327
|
}
|
|
1326
1328
|
class AsyncHook extends SyncHook {
|
|
1327
1329
|
emit(...t) {
|
|
1328
|
-
let
|
|
1329
|
-
const
|
|
1330
|
-
if (
|
|
1330
|
+
let n;
|
|
1331
|
+
const o = Array.from(this.listeners);
|
|
1332
|
+
if (o.length > 0) {
|
|
1331
1333
|
let s = 0;
|
|
1332
|
-
const
|
|
1333
|
-
|
|
1334
|
+
const a = (l) => l === !1 ? !1 : s < o.length ? Promise.resolve(o[s++].apply(null, t)).then(a) : l;
|
|
1335
|
+
n = a();
|
|
1334
1336
|
}
|
|
1335
|
-
return Promise.resolve(
|
|
1337
|
+
return Promise.resolve(n);
|
|
1336
1338
|
}
|
|
1337
1339
|
}
|
|
1338
1340
|
function checkReturnData(r, t) {
|
|
1339
1341
|
if (!isObject(t))
|
|
1340
1342
|
return !1;
|
|
1341
1343
|
if (r !== t) {
|
|
1342
|
-
for (const
|
|
1343
|
-
if (!(
|
|
1344
|
+
for (const n in r)
|
|
1345
|
+
if (!(n in t))
|
|
1344
1346
|
return !1;
|
|
1345
1347
|
}
|
|
1346
1348
|
return !0;
|
|
@@ -1348,17 +1350,17 @@ function checkReturnData(r, t) {
|
|
|
1348
1350
|
class SyncWaterfallHook extends SyncHook {
|
|
1349
1351
|
emit(t) {
|
|
1350
1352
|
isObject(t) || error(`The data for the "${this.type}" hook should be an object.`);
|
|
1351
|
-
for (const
|
|
1353
|
+
for (const n of this.listeners)
|
|
1352
1354
|
try {
|
|
1353
|
-
const
|
|
1354
|
-
if (checkReturnData(t,
|
|
1355
|
-
t =
|
|
1355
|
+
const o = n(t);
|
|
1356
|
+
if (checkReturnData(t, o))
|
|
1357
|
+
t = o;
|
|
1356
1358
|
else {
|
|
1357
1359
|
this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);
|
|
1358
1360
|
break;
|
|
1359
1361
|
}
|
|
1360
|
-
} catch (
|
|
1361
|
-
warn(
|
|
1362
|
+
} catch (o) {
|
|
1363
|
+
warn(o), this.onerror(o);
|
|
1362
1364
|
}
|
|
1363
1365
|
return t;
|
|
1364
1366
|
}
|
|
@@ -1369,14 +1371,14 @@ class SyncWaterfallHook extends SyncHook {
|
|
|
1369
1371
|
class AsyncWaterfallHook extends SyncHook {
|
|
1370
1372
|
emit(t) {
|
|
1371
1373
|
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 =
|
|
1374
|
+
const n = Array.from(this.listeners);
|
|
1375
|
+
if (n.length > 0) {
|
|
1376
|
+
let o = 0;
|
|
1377
|
+
const s = (l) => (warn(l), this.onerror(l), t), a = (l) => {
|
|
1378
|
+
if (checkReturnData(t, l)) {
|
|
1379
|
+
if (t = l, o < n.length)
|
|
1378
1380
|
try {
|
|
1379
|
-
return Promise.resolve(o
|
|
1381
|
+
return Promise.resolve(n[o++](t)).then(a, s);
|
|
1380
1382
|
} catch (i) {
|
|
1381
1383
|
return s(i);
|
|
1382
1384
|
}
|
|
@@ -1384,7 +1386,7 @@ class AsyncWaterfallHook extends SyncHook {
|
|
|
1384
1386
|
this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
|
|
1385
1387
|
return t;
|
|
1386
1388
|
};
|
|
1387
|
-
return Promise.resolve(
|
|
1389
|
+
return Promise.resolve(a(t));
|
|
1388
1390
|
}
|
|
1389
1391
|
return Promise.resolve(t);
|
|
1390
1392
|
}
|
|
@@ -1395,25 +1397,25 @@ class AsyncWaterfallHook extends SyncHook {
|
|
|
1395
1397
|
class PluginSystem {
|
|
1396
1398
|
applyPlugin(t) {
|
|
1397
1399
|
assert(isPlainObject(t), "Plugin configuration is invalid.");
|
|
1398
|
-
const
|
|
1399
|
-
assert(
|
|
1400
|
-
const s = t[
|
|
1401
|
-
s && this.lifecycle[
|
|
1400
|
+
const n = t.name;
|
|
1401
|
+
assert(n, "A name must be provided by the plugin."), this.registerPlugins[n] || (this.registerPlugins[n] = t, Object.keys(this.lifecycle).forEach((o) => {
|
|
1402
|
+
const s = t[o];
|
|
1403
|
+
s && this.lifecycle[o].on(s);
|
|
1402
1404
|
}));
|
|
1403
1405
|
}
|
|
1404
1406
|
removePlugin(t) {
|
|
1405
1407
|
assert(t, "A name is required.");
|
|
1406
|
-
const
|
|
1407
|
-
assert(
|
|
1408
|
-
|
|
1408
|
+
const n = this.registerPlugins[t];
|
|
1409
|
+
assert(n, `The plugin "${t}" is not registered.`), Object.keys(n).forEach((o) => {
|
|
1410
|
+
o !== "name" && this.lifecycle[o].remove(n[o]);
|
|
1409
1411
|
});
|
|
1410
1412
|
}
|
|
1411
1413
|
// 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[
|
|
1414
|
+
inherit({ lifecycle: t, registerPlugins: n }) {
|
|
1415
|
+
Object.keys(t).forEach((o) => {
|
|
1416
|
+
assert(!this.lifecycle[o], `The hook "${o}" has a conflict and cannot be inherited.`), this.lifecycle[o] = t[o];
|
|
1417
|
+
}), Object.keys(n).forEach((o) => {
|
|
1418
|
+
assert(!this.registerPlugins[o], `The plugin "${o}" has a conflict and cannot be inherited.`), this.applyPlugin(n[o]);
|
|
1417
1419
|
});
|
|
1418
1420
|
}
|
|
1419
1421
|
constructor(t) {
|
|
@@ -1429,24 +1431,24 @@ function defaultPreloadArgs(r) {
|
|
|
1429
1431
|
}, r);
|
|
1430
1432
|
}
|
|
1431
1433
|
function formatPreloadArgs(r, t) {
|
|
1432
|
-
return t.map((
|
|
1433
|
-
const
|
|
1434
|
-
return assert(
|
|
1435
|
-
remoteInfo:
|
|
1434
|
+
return t.map((n) => {
|
|
1435
|
+
const o = matchRemote(r, n.nameOrAlias);
|
|
1436
|
+
return assert(o, `Unable to preload ${n.nameOrAlias} as it is not included in ${!o && safeToString({
|
|
1437
|
+
remoteInfo: o,
|
|
1436
1438
|
remotes: r
|
|
1437
1439
|
})}`), {
|
|
1438
|
-
remote:
|
|
1439
|
-
preloadConfig: defaultPreloadArgs(
|
|
1440
|
+
remote: o,
|
|
1441
|
+
preloadConfig: defaultPreloadArgs(n)
|
|
1440
1442
|
};
|
|
1441
1443
|
});
|
|
1442
1444
|
}
|
|
1443
1445
|
function normalizePreloadExposes(r) {
|
|
1444
1446
|
return r ? r.map((t) => t === "." ? t : t.startsWith("./") ? t.replace("./", "") : t) : [];
|
|
1445
1447
|
}
|
|
1446
|
-
function preloadAssets(r, t,
|
|
1447
|
-
const { cssAssets: s, jsAssetsWithoutEntry:
|
|
1448
|
+
function preloadAssets(r, t, n, o = !0) {
|
|
1449
|
+
const { cssAssets: s, jsAssetsWithoutEntry: a, entryAssets: l } = n;
|
|
1448
1450
|
if (t.options.inBrowser) {
|
|
1449
|
-
if (
|
|
1451
|
+
if (l.forEach((i) => {
|
|
1450
1452
|
const { moduleInfo: c } = i, u = t.moduleCache.get(r.name);
|
|
1451
1453
|
getRemoteEntry(u ? {
|
|
1452
1454
|
origin: t,
|
|
@@ -1457,7 +1459,7 @@ function preloadAssets(r, t, o, n = !0) {
|
|
|
1457
1459
|
remoteInfo: c,
|
|
1458
1460
|
remoteEntryExports: void 0
|
|
1459
1461
|
});
|
|
1460
|
-
}),
|
|
1462
|
+
}), o) {
|
|
1461
1463
|
const i = {
|
|
1462
1464
|
rel: "preload",
|
|
1463
1465
|
as: "style"
|
|
@@ -1503,12 +1505,12 @@ function preloadAssets(r, t, o, n = !0) {
|
|
|
1503
1505
|
d && document.head.appendChild(u);
|
|
1504
1506
|
});
|
|
1505
1507
|
}
|
|
1506
|
-
if (
|
|
1508
|
+
if (o) {
|
|
1507
1509
|
const i = {
|
|
1508
1510
|
rel: "preload",
|
|
1509
1511
|
as: "script"
|
|
1510
1512
|
};
|
|
1511
|
-
|
|
1513
|
+
a.forEach((c) => {
|
|
1512
1514
|
const { link: u, needAttach: d } = createLink({
|
|
1513
1515
|
url: c,
|
|
1514
1516
|
cb: () => {
|
|
@@ -1530,7 +1532,7 @@ function preloadAssets(r, t, o, n = !0) {
|
|
|
1530
1532
|
fetchpriority: "high",
|
|
1531
1533
|
type: (r == null ? void 0 : r.type) === "module" ? "module" : "text/javascript"
|
|
1532
1534
|
};
|
|
1533
|
-
|
|
1535
|
+
a.forEach((c) => {
|
|
1534
1536
|
const { script: u, needAttach: d } = createScript({
|
|
1535
1537
|
url: c,
|
|
1536
1538
|
cb: () => {
|
|
@@ -1552,25 +1554,25 @@ function preloadAssets(r, t, o, n = !0) {
|
|
|
1552
1554
|
}
|
|
1553
1555
|
}
|
|
1554
1556
|
function assignRemoteInfo(r, t) {
|
|
1555
|
-
const
|
|
1556
|
-
|
|
1557
|
-
let
|
|
1558
|
-
!isBrowserEnv() && !
|
|
1557
|
+
const n = getRemoteEntryInfoFromSnapshot(t);
|
|
1558
|
+
n.url || error(`The attribute remoteEntry of ${r.name} must not be undefined.`);
|
|
1559
|
+
let o = getResourceUrl(t, n.url);
|
|
1560
|
+
!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
1561
|
}
|
|
1560
1562
|
function snapshotPlugin() {
|
|
1561
1563
|
return {
|
|
1562
1564
|
name: "snapshot-plugin",
|
|
1563
1565
|
async afterResolve(r) {
|
|
1564
|
-
const { remote: t, pkgNameOrAlias:
|
|
1566
|
+
const { remote: t, pkgNameOrAlias: n, expose: o, origin: s, remoteInfo: a } = r;
|
|
1565
1567
|
if (!isRemoteInfoWithEntry(t) || !isPureRemoteEntry(t)) {
|
|
1566
|
-
const { remoteSnapshot:
|
|
1567
|
-
assignRemoteInfo(
|
|
1568
|
+
const { remoteSnapshot: l, globalSnapshot: i } = await s.snapshotHandler.loadRemoteSnapshotInfo(t);
|
|
1569
|
+
assignRemoteInfo(a, l);
|
|
1568
1570
|
const c = {
|
|
1569
1571
|
remote: t,
|
|
1570
1572
|
preloadConfig: {
|
|
1571
|
-
nameOrAlias:
|
|
1573
|
+
nameOrAlias: n,
|
|
1572
1574
|
exposes: [
|
|
1573
|
-
|
|
1575
|
+
o
|
|
1574
1576
|
],
|
|
1575
1577
|
resourceCategory: "sync",
|
|
1576
1578
|
share: !1,
|
|
@@ -1579,13 +1581,13 @@ function snapshotPlugin() {
|
|
|
1579
1581
|
}, u = await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({
|
|
1580
1582
|
origin: s,
|
|
1581
1583
|
preloadOptions: c,
|
|
1582
|
-
remoteInfo:
|
|
1584
|
+
remoteInfo: a,
|
|
1583
1585
|
remote: t,
|
|
1584
|
-
remoteSnapshot:
|
|
1586
|
+
remoteSnapshot: l,
|
|
1585
1587
|
globalSnapshot: i
|
|
1586
1588
|
});
|
|
1587
|
-
return u && preloadAssets(
|
|
1588
|
-
remoteSnapshot:
|
|
1589
|
+
return u && preloadAssets(a, s, u, !1), _extends$1({}, r, {
|
|
1590
|
+
remoteSnapshot: l
|
|
1589
1591
|
});
|
|
1590
1592
|
}
|
|
1591
1593
|
return r;
|
|
@@ -1605,9 +1607,9 @@ function splitId(r) {
|
|
|
1605
1607
|
version: t[2]
|
|
1606
1608
|
};
|
|
1607
1609
|
}
|
|
1608
|
-
function traverseModuleInfo(r, t,
|
|
1609
|
-
const
|
|
1610
|
-
if (c && !isManifestProvider(c) && (
|
|
1610
|
+
function traverseModuleInfo(r, t, n, o, s = {}, a) {
|
|
1611
|
+
const l = getFMId(t), { value: i } = getInfoWithoutType(r, l), c = a || i;
|
|
1612
|
+
if (c && !isManifestProvider(c) && (n(c, t, o), c.remotesInfo)) {
|
|
1611
1613
|
const u = Object.keys(c.remotesInfo);
|
|
1612
1614
|
for (const d of u) {
|
|
1613
1615
|
if (s[d])
|
|
@@ -1617,23 +1619,23 @@ function traverseModuleInfo(r, t, o, n, s = {}, l) {
|
|
|
1617
1619
|
traverseModuleInfo(r, {
|
|
1618
1620
|
name: p.name,
|
|
1619
1621
|
version: m.matchedVersion
|
|
1620
|
-
},
|
|
1622
|
+
}, n, !1, s, void 0);
|
|
1621
1623
|
}
|
|
1622
1624
|
}
|
|
1623
1625
|
}
|
|
1624
|
-
function generatePreloadAssets(r, t,
|
|
1625
|
-
const
|
|
1626
|
-
if (traverseModuleInfo(
|
|
1627
|
-
let
|
|
1628
|
-
if (
|
|
1629
|
-
|
|
1626
|
+
function generatePreloadAssets(r, t, n, o, s) {
|
|
1627
|
+
const a = [], l = [], i = [], c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), { options: d } = r, { preloadConfig: p } = t, { depsRemote: m } = p;
|
|
1628
|
+
if (traverseModuleInfo(o, n, (g, E, v) => {
|
|
1629
|
+
let I;
|
|
1630
|
+
if (v)
|
|
1631
|
+
I = p;
|
|
1630
1632
|
else if (Array.isArray(m)) {
|
|
1631
|
-
const T = m.find((
|
|
1633
|
+
const T = m.find((A) => A.nameOrAlias === E.name || A.nameOrAlias === E.alias);
|
|
1632
1634
|
if (!T)
|
|
1633
1635
|
return;
|
|
1634
|
-
|
|
1636
|
+
I = defaultPreloadArgs(T);
|
|
1635
1637
|
} else if (m === !0)
|
|
1636
|
-
|
|
1638
|
+
I = p;
|
|
1637
1639
|
else
|
|
1638
1640
|
return;
|
|
1639
1641
|
const S = getResourceUrl(g, getRemoteEntryInfoFromSnapshot(g).url);
|
|
@@ -1650,44 +1652,44 @@ function generatePreloadAssets(r, t, o, n, s) {
|
|
|
1650
1652
|
url: S
|
|
1651
1653
|
});
|
|
1652
1654
|
let b = "modules" in g ? g.modules : [];
|
|
1653
|
-
const $ = normalizePreloadExposes(
|
|
1655
|
+
const $ = normalizePreloadExposes(I.exposes);
|
|
1654
1656
|
if ($.length && "modules" in g) {
|
|
1655
|
-
var
|
|
1656
|
-
b = g == null || (
|
|
1657
|
+
var w;
|
|
1658
|
+
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
1659
|
}
|
|
1658
1660
|
function O(T) {
|
|
1659
|
-
const
|
|
1660
|
-
return
|
|
1661
|
+
const A = T.map((P) => getResourceUrl(g, P));
|
|
1662
|
+
return I.filter ? A.filter(I.filter) : A;
|
|
1661
1663
|
}
|
|
1662
1664
|
if (b) {
|
|
1663
1665
|
const T = b.length;
|
|
1664
|
-
for (let
|
|
1665
|
-
const P = b[
|
|
1666
|
+
for (let A = 0; A < T; A++) {
|
|
1667
|
+
const P = b[A], L = `${E.name}/${P.moduleName}`;
|
|
1666
1668
|
r.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({
|
|
1667
|
-
id: P.moduleName === "." ? E.name :
|
|
1669
|
+
id: P.moduleName === "." ? E.name : L,
|
|
1668
1670
|
name: E.name,
|
|
1669
1671
|
remoteSnapshot: g,
|
|
1670
|
-
preloadConfig:
|
|
1672
|
+
preloadConfig: I,
|
|
1671
1673
|
remote: E,
|
|
1672
1674
|
origin: r
|
|
1673
|
-
}), !getPreloaded(
|
|
1675
|
+
}), !getPreloaded(L) && (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(L));
|
|
1674
1676
|
}
|
|
1675
1677
|
}
|
|
1676
1678
|
}, !0, {}, s), s.shared) {
|
|
1677
|
-
const g = (E,
|
|
1678
|
-
const
|
|
1679
|
-
|
|
1679
|
+
const g = (E, v) => {
|
|
1680
|
+
const I = getRegisteredShare(r.shareScopeMap, v.sharedName, E, r.sharedHandler.hooks.lifecycle.resolveShare);
|
|
1681
|
+
I && typeof I.lib == "function" && (v.assets.js.sync.forEach((S) => {
|
|
1680
1682
|
c.add(S);
|
|
1681
|
-
}),
|
|
1683
|
+
}), v.assets.css.sync.forEach((S) => {
|
|
1682
1684
|
u.add(S);
|
|
1683
1685
|
}));
|
|
1684
1686
|
};
|
|
1685
1687
|
s.shared.forEach((E) => {
|
|
1686
|
-
var
|
|
1687
|
-
const
|
|
1688
|
-
if (!
|
|
1688
|
+
var v;
|
|
1689
|
+
const I = (v = d.shared) == null ? void 0 : v[E.sharedName];
|
|
1690
|
+
if (!I)
|
|
1689
1691
|
return;
|
|
1690
|
-
const S = E.version ?
|
|
1692
|
+
const S = E.version ? I.find(($) => $.version === E.version) : I;
|
|
1691
1693
|
if (!S)
|
|
1692
1694
|
return;
|
|
1693
1695
|
arrayOptions(S).forEach(($) => {
|
|
@@ -1695,9 +1697,9 @@ function generatePreloadAssets(r, t, o, n, s) {
|
|
|
1695
1697
|
});
|
|
1696
1698
|
});
|
|
1697
1699
|
}
|
|
1698
|
-
const _ =
|
|
1700
|
+
const _ = l.filter((g) => !c.has(g));
|
|
1699
1701
|
return {
|
|
1700
|
-
cssAssets:
|
|
1702
|
+
cssAssets: a.filter((g) => !u.has(g)),
|
|
1701
1703
|
jsAssetsWithoutEntry: _,
|
|
1702
1704
|
entryAssets: i
|
|
1703
1705
|
};
|
|
@@ -1706,7 +1708,7 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1706
1708
|
return {
|
|
1707
1709
|
name: "generate-preload-assets-plugin",
|
|
1708
1710
|
async generatePreloadAssets(r) {
|
|
1709
|
-
const { origin: t, preloadOptions:
|
|
1711
|
+
const { origin: t, preloadOptions: n, remoteInfo: o, remote: s, globalSnapshot: a, remoteSnapshot: l } = r;
|
|
1710
1712
|
return isRemoteInfoWithEntry(s) && isPureRemoteEntry(s) ? {
|
|
1711
1713
|
cssAssets: [],
|
|
1712
1714
|
jsAssetsWithoutEntry: [],
|
|
@@ -1715,29 +1717,29 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1715
1717
|
name: s.name,
|
|
1716
1718
|
url: s.entry,
|
|
1717
1719
|
moduleInfo: {
|
|
1718
|
-
name:
|
|
1720
|
+
name: o.name,
|
|
1719
1721
|
entry: s.entry,
|
|
1720
|
-
type:
|
|
1722
|
+
type: o.type || "global",
|
|
1721
1723
|
entryGlobalName: "",
|
|
1722
1724
|
shareScope: ""
|
|
1723
1725
|
}
|
|
1724
1726
|
}
|
|
1725
1727
|
]
|
|
1726
|
-
} : (assignRemoteInfo(
|
|
1728
|
+
} : (assignRemoteInfo(o, l), generatePreloadAssets(t, n, o, a, l));
|
|
1727
1729
|
}
|
|
1728
1730
|
};
|
|
1729
1731
|
};
|
|
1730
1732
|
function getGlobalRemoteInfo(r, t) {
|
|
1731
|
-
const
|
|
1733
|
+
const n = getGlobalSnapshotInfoByModuleInfo({
|
|
1732
1734
|
name: t.options.name,
|
|
1733
1735
|
version: t.options.version
|
|
1734
|
-
}),
|
|
1735
|
-
return
|
|
1736
|
-
hostGlobalSnapshot:
|
|
1736
|
+
}), o = n && "remotesInfo" in n && n.remotesInfo && getInfoWithoutType(n.remotesInfo, r.name).value;
|
|
1737
|
+
return o && o.matchedVersion ? {
|
|
1738
|
+
hostGlobalSnapshot: n,
|
|
1737
1739
|
globalSnapshot: getGlobalSnapshot(),
|
|
1738
1740
|
remoteSnapshot: getGlobalSnapshotInfoByModuleInfo({
|
|
1739
1741
|
name: r.name,
|
|
1740
|
-
version:
|
|
1742
|
+
version: o.matchedVersion
|
|
1741
1743
|
})
|
|
1742
1744
|
} : {
|
|
1743
1745
|
hostGlobalSnapshot: void 0,
|
|
@@ -1750,46 +1752,46 @@ function getGlobalRemoteInfo(r, t) {
|
|
|
1750
1752
|
}
|
|
1751
1753
|
class SnapshotHandler {
|
|
1752
1754
|
async loadSnapshot(t) {
|
|
1753
|
-
const { options:
|
|
1754
|
-
options:
|
|
1755
|
+
const { options: n } = this.HostInstance, { hostGlobalSnapshot: o, remoteSnapshot: s, globalSnapshot: a } = this.getGlobalRemoteInfo(t), { remoteSnapshot: l, globalSnapshot: i } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1756
|
+
options: n,
|
|
1755
1757
|
moduleInfo: t,
|
|
1756
|
-
hostGlobalSnapshot:
|
|
1758
|
+
hostGlobalSnapshot: o,
|
|
1757
1759
|
remoteSnapshot: s,
|
|
1758
|
-
globalSnapshot:
|
|
1760
|
+
globalSnapshot: a
|
|
1759
1761
|
});
|
|
1760
1762
|
return {
|
|
1761
|
-
remoteSnapshot:
|
|
1763
|
+
remoteSnapshot: l,
|
|
1762
1764
|
globalSnapshot: i
|
|
1763
1765
|
};
|
|
1764
1766
|
}
|
|
1765
1767
|
// eslint-disable-next-line max-lines-per-function
|
|
1766
1768
|
async loadRemoteSnapshotInfo(t) {
|
|
1767
|
-
const { options:
|
|
1769
|
+
const { options: n } = this.HostInstance;
|
|
1768
1770
|
await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({
|
|
1769
|
-
options:
|
|
1771
|
+
options: n,
|
|
1770
1772
|
moduleInfo: t
|
|
1771
1773
|
});
|
|
1772
|
-
let
|
|
1774
|
+
let o = getGlobalSnapshotInfoByModuleInfo({
|
|
1773
1775
|
name: this.HostInstance.options.name,
|
|
1774
1776
|
version: this.HostInstance.options.version
|
|
1775
1777
|
});
|
|
1776
|
-
|
|
1778
|
+
o || (o = {
|
|
1777
1779
|
version: this.HostInstance.options.version || "",
|
|
1778
1780
|
remoteEntry: "",
|
|
1779
1781
|
remotesInfo: {}
|
|
1780
1782
|
}, addGlobalSnapshot({
|
|
1781
|
-
[this.HostInstance.options.name]:
|
|
1782
|
-
})),
|
|
1783
|
+
[this.HostInstance.options.name]: o
|
|
1784
|
+
})), 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
1785
|
[t.name]: {
|
|
1784
1786
|
matchedVersion: "version" in t ? t.version : t.entry
|
|
1785
1787
|
}
|
|
1786
1788
|
}));
|
|
1787
|
-
const { hostGlobalSnapshot: s, remoteSnapshot:
|
|
1788
|
-
options:
|
|
1789
|
+
const { hostGlobalSnapshot: s, remoteSnapshot: a, globalSnapshot: l } = this.getGlobalRemoteInfo(t), { remoteSnapshot: i, globalSnapshot: c } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1790
|
+
options: n,
|
|
1789
1791
|
moduleInfo: t,
|
|
1790
1792
|
hostGlobalSnapshot: s,
|
|
1791
|
-
remoteSnapshot:
|
|
1792
|
-
globalSnapshot:
|
|
1793
|
+
remoteSnapshot: a,
|
|
1794
|
+
globalSnapshot: l
|
|
1793
1795
|
});
|
|
1794
1796
|
let u, d;
|
|
1795
1797
|
if (i)
|
|
@@ -1824,7 +1826,7 @@ class SnapshotHandler {
|
|
|
1824
1826
|
globalSnapshot: JSON.stringify(c)
|
|
1825
1827
|
}));
|
|
1826
1828
|
return await this.hooks.lifecycle.afterLoadSnapshot.emit({
|
|
1827
|
-
options:
|
|
1829
|
+
options: n,
|
|
1828
1830
|
moduleInfo: t,
|
|
1829
1831
|
remoteSnapshot: u
|
|
1830
1832
|
}), {
|
|
@@ -1835,34 +1837,34 @@ class SnapshotHandler {
|
|
|
1835
1837
|
getGlobalRemoteInfo(t) {
|
|
1836
1838
|
return getGlobalRemoteInfo(t, this.HostInstance);
|
|
1837
1839
|
}
|
|
1838
|
-
async getManifestJson(t,
|
|
1840
|
+
async getManifestJson(t, n, o) {
|
|
1839
1841
|
const s = async () => {
|
|
1840
|
-
let
|
|
1841
|
-
if (
|
|
1842
|
-
return
|
|
1842
|
+
let l = this.manifestCache.get(t);
|
|
1843
|
+
if (l)
|
|
1844
|
+
return l;
|
|
1843
1845
|
try {
|
|
1844
1846
|
let i = await this.loaderHook.lifecycle.fetch.emit(t, {});
|
|
1845
|
-
return (!i || !(i instanceof Response)) && (i = await fetch(t, {})),
|
|
1847
|
+
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
1848
|
} catch (i) {
|
|
1847
1849
|
delete this.manifestLoading[t], error(getShortErrorMsg(RUNTIME_003, runtimeDescMap, {
|
|
1848
1850
|
manifestUrl: t,
|
|
1849
|
-
moduleName:
|
|
1851
|
+
moduleName: n.name
|
|
1850
1852
|
}, `${i}`));
|
|
1851
1853
|
}
|
|
1852
|
-
},
|
|
1853
|
-
const
|
|
1854
|
+
}, a = async () => {
|
|
1855
|
+
const l = await s(), i = generateSnapshotFromManifest(l, {
|
|
1854
1856
|
version: t
|
|
1855
1857
|
}), { remoteSnapshot: c } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1856
1858
|
options: this.HostInstance.options,
|
|
1857
|
-
moduleInfo:
|
|
1858
|
-
manifestJson:
|
|
1859
|
+
moduleInfo: n,
|
|
1860
|
+
manifestJson: l,
|
|
1859
1861
|
remoteSnapshot: i,
|
|
1860
1862
|
manifestUrl: t,
|
|
1861
1863
|
from: "manifest"
|
|
1862
1864
|
});
|
|
1863
1865
|
return c;
|
|
1864
1866
|
};
|
|
1865
|
-
return this.manifestLoading[t] || (this.manifestLoading[t] =
|
|
1867
|
+
return this.manifestLoading[t] || (this.manifestLoading[t] = a().then((l) => l)), this.manifestLoading[t];
|
|
1866
1868
|
}
|
|
1867
1869
|
constructor(t) {
|
|
1868
1870
|
this.loadingHostSnapshot = null, this.manifestCache = /* @__PURE__ */ new Map(), this.hooks = new PluginSystem({
|
|
@@ -1875,44 +1877,44 @@ class SnapshotHandler {
|
|
|
1875
1877
|
}
|
|
1876
1878
|
class SharedHandler {
|
|
1877
1879
|
// register shared in shareScopeMap
|
|
1878
|
-
registerShared(t,
|
|
1879
|
-
const { shareInfos:
|
|
1880
|
-
return Object.keys(
|
|
1881
|
-
|
|
1882
|
-
!getRegisteredShare(this.shareScopeMap,
|
|
1883
|
-
pkgName:
|
|
1880
|
+
registerShared(t, n) {
|
|
1881
|
+
const { shareInfos: o, shared: s } = formatShareConfigs(t, n);
|
|
1882
|
+
return Object.keys(o).forEach((l) => {
|
|
1883
|
+
o[l].forEach((c) => {
|
|
1884
|
+
!getRegisteredShare(this.shareScopeMap, l, c, this.hooks.lifecycle.resolveShare) && c && c.lib && this.setShared({
|
|
1885
|
+
pkgName: l,
|
|
1884
1886
|
lib: c.lib,
|
|
1885
1887
|
get: c.get,
|
|
1886
1888
|
loaded: !0,
|
|
1887
1889
|
shared: c,
|
|
1888
|
-
from:
|
|
1890
|
+
from: n.name
|
|
1889
1891
|
});
|
|
1890
1892
|
});
|
|
1891
1893
|
}), {
|
|
1892
|
-
shareInfos:
|
|
1894
|
+
shareInfos: o,
|
|
1893
1895
|
shared: s
|
|
1894
1896
|
};
|
|
1895
1897
|
}
|
|
1896
|
-
async loadShare(t,
|
|
1897
|
-
const { host:
|
|
1898
|
+
async loadShare(t, n) {
|
|
1899
|
+
const { host: o } = this, s = getTargetSharedOptions({
|
|
1898
1900
|
pkgName: t,
|
|
1899
|
-
extraOptions:
|
|
1900
|
-
shareInfos:
|
|
1901
|
+
extraOptions: n,
|
|
1902
|
+
shareInfos: o.options.shared
|
|
1901
1903
|
});
|
|
1902
1904
|
s != null && s.scope && await Promise.all(s.scope.map(async (u) => {
|
|
1903
1905
|
await Promise.all(this.initializeSharing(u, {
|
|
1904
1906
|
strategy: s.strategy
|
|
1905
1907
|
}));
|
|
1906
1908
|
}));
|
|
1907
|
-
const
|
|
1909
|
+
const a = await this.hooks.lifecycle.beforeLoadShare.emit({
|
|
1908
1910
|
pkgName: t,
|
|
1909
1911
|
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,
|
|
1912
|
+
shared: o.options.shared,
|
|
1913
|
+
origin: o
|
|
1914
|
+
}), { shareInfo: l } = a;
|
|
1915
|
+
assert(l, `Cannot find ${t} Share in the ${o.options.name}. Please ensure that the ${t} Share parameters have been injected`);
|
|
1916
|
+
const i = getRegisteredShare(this.shareScopeMap, t, l, this.hooks.lifecycle.resolveShare), c = (u) => {
|
|
1917
|
+
u.useIn || (u.useIn = []), addUniqueItem(u.useIn, o.options.name);
|
|
1916
1918
|
};
|
|
1917
1919
|
if (i && i.lib)
|
|
1918
1920
|
return c(i), i.lib;
|
|
@@ -1922,32 +1924,32 @@ class SharedHandler {
|
|
|
1922
1924
|
} else if (i) {
|
|
1923
1925
|
const d = (async () => {
|
|
1924
1926
|
const p = await i.get();
|
|
1925
|
-
|
|
1926
|
-
const m = getRegisteredShare(this.shareScopeMap, t,
|
|
1927
|
+
l.lib = p, l.loaded = !0, c(l);
|
|
1928
|
+
const m = getRegisteredShare(this.shareScopeMap, t, l, this.hooks.lifecycle.resolveShare);
|
|
1927
1929
|
return m && (m.lib = p, m.loaded = !0), p;
|
|
1928
1930
|
})();
|
|
1929
1931
|
return this.setShared({
|
|
1930
1932
|
pkgName: t,
|
|
1931
1933
|
loaded: !1,
|
|
1932
1934
|
shared: i,
|
|
1933
|
-
from:
|
|
1935
|
+
from: o.options.name,
|
|
1934
1936
|
lib: null,
|
|
1935
1937
|
loading: d
|
|
1936
1938
|
}), d;
|
|
1937
1939
|
} else {
|
|
1938
|
-
if (
|
|
1940
|
+
if (n != null && n.customShareInfo)
|
|
1939
1941
|
return !1;
|
|
1940
1942
|
const d = (async () => {
|
|
1941
|
-
const p = await
|
|
1942
|
-
|
|
1943
|
-
const m = getRegisteredShare(this.shareScopeMap, t,
|
|
1943
|
+
const p = await l.get();
|
|
1944
|
+
l.lib = p, l.loaded = !0, c(l);
|
|
1945
|
+
const m = getRegisteredShare(this.shareScopeMap, t, l, this.hooks.lifecycle.resolveShare);
|
|
1944
1946
|
return m && (m.lib = p, m.loaded = !0), p;
|
|
1945
1947
|
})();
|
|
1946
1948
|
return this.setShared({
|
|
1947
1949
|
pkgName: t,
|
|
1948
1950
|
loaded: !1,
|
|
1949
|
-
shared:
|
|
1950
|
-
from:
|
|
1951
|
+
shared: l,
|
|
1952
|
+
from: o.options.name,
|
|
1951
1953
|
lib: null,
|
|
1952
1954
|
loading: d
|
|
1953
1955
|
}), d;
|
|
@@ -1959,30 +1961,30 @@ class SharedHandler {
|
|
|
1959
1961
|
* If the share scope does not exist, it creates one.
|
|
1960
1962
|
*/
|
|
1961
1963
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
1962
|
-
initializeSharing(t = DEFAULT_SCOPE,
|
|
1963
|
-
const { host:
|
|
1964
|
-
let
|
|
1964
|
+
initializeSharing(t = DEFAULT_SCOPE, n) {
|
|
1965
|
+
const { host: o } = this, s = n == null ? void 0 : n.from, a = n == null ? void 0 : n.strategy;
|
|
1966
|
+
let l = n == null ? void 0 : n.initScope;
|
|
1965
1967
|
const i = [];
|
|
1966
1968
|
if (s !== "build") {
|
|
1967
1969
|
const { initTokens: _ } = this;
|
|
1968
|
-
|
|
1970
|
+
l || (l = []);
|
|
1969
1971
|
let R = _[t];
|
|
1970
1972
|
if (R || (R = _[t] = {
|
|
1971
1973
|
from: this.host.name
|
|
1972
|
-
}),
|
|
1974
|
+
}), l.indexOf(R) >= 0)
|
|
1973
1975
|
return i;
|
|
1974
|
-
|
|
1976
|
+
l.push(R);
|
|
1975
1977
|
}
|
|
1976
|
-
const c = this.shareScopeMap, u =
|
|
1978
|
+
const c = this.shareScopeMap, u = o.options.name;
|
|
1977
1979
|
c[t] || (c[t] = {});
|
|
1978
1980
|
const d = c[t], p = (_, R) => {
|
|
1979
1981
|
var g;
|
|
1980
|
-
const { version: E, eager:
|
|
1982
|
+
const { version: E, eager: v } = R;
|
|
1981
1983
|
d[_] = d[_] || {};
|
|
1982
|
-
const
|
|
1983
|
-
(!S || S.strategy !== "loaded-first" && !S.loaded && (!
|
|
1984
|
-
}, m = (_) => _ && _.init && _.init(c[t],
|
|
1985
|
-
const { module: R } = await
|
|
1984
|
+
const I = d[_], S = I[E], b = !!(S && (S.eager || (g = S.shareConfig) != null && g.eager));
|
|
1985
|
+
(!S || S.strategy !== "loaded-first" && !S.loaded && (!v != !b ? v : u > S.from)) && (I[E] = R);
|
|
1986
|
+
}, m = (_) => _ && _.init && _.init(c[t], l), y = async (_) => {
|
|
1987
|
+
const { module: R } = await o.remoteHandler.getRemoteModuleAndOptions({
|
|
1986
1988
|
id: _
|
|
1987
1989
|
});
|
|
1988
1990
|
if (R.getEntry) {
|
|
@@ -1990,22 +1992,22 @@ class SharedHandler {
|
|
|
1990
1992
|
try {
|
|
1991
1993
|
g = await R.getEntry();
|
|
1992
1994
|
} catch (E) {
|
|
1993
|
-
g = await
|
|
1995
|
+
g = await o.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
1994
1996
|
id: _,
|
|
1995
1997
|
error: E,
|
|
1996
1998
|
from: "runtime",
|
|
1997
1999
|
lifecycle: "beforeLoadShare",
|
|
1998
|
-
origin:
|
|
2000
|
+
origin: o
|
|
1999
2001
|
});
|
|
2000
2002
|
}
|
|
2001
2003
|
R.inited || (await m(g), R.inited = !0);
|
|
2002
2004
|
}
|
|
2003
2005
|
};
|
|
2004
|
-
return Object.keys(
|
|
2005
|
-
|
|
2006
|
+
return Object.keys(o.options.shared).forEach((_) => {
|
|
2007
|
+
o.options.shared[_].forEach((g) => {
|
|
2006
2008
|
g.scope.includes(t) && p(_, g);
|
|
2007
2009
|
});
|
|
2008
|
-
}), (
|
|
2010
|
+
}), (o.options.shareStrategy === "version-first" || a === "version-first") && o.options.remotes.forEach((_) => {
|
|
2009
2011
|
_.shareScope === t && i.push(y(_.name));
|
|
2010
2012
|
}), i;
|
|
2011
2013
|
}
|
|
@@ -2013,32 +2015,32 @@ class SharedHandler {
|
|
|
2013
2015
|
// 1. If the loaded shared already exists globally, then it will be reused
|
|
2014
2016
|
// 2. If lib exists in local shared, it will be used directly
|
|
2015
2017
|
// 3. If the local get returns something other than Promise, then it will be used directly
|
|
2016
|
-
loadShareSync(t,
|
|
2017
|
-
const { host:
|
|
2018
|
+
loadShareSync(t, n) {
|
|
2019
|
+
const { host: o } = this, s = getTargetSharedOptions({
|
|
2018
2020
|
pkgName: t,
|
|
2019
|
-
extraOptions:
|
|
2020
|
-
shareInfos:
|
|
2021
|
+
extraOptions: n,
|
|
2022
|
+
shareInfos: o.options.shared
|
|
2021
2023
|
});
|
|
2022
2024
|
s != null && s.scope && s.scope.forEach((i) => {
|
|
2023
2025
|
this.initializeSharing(i, {
|
|
2024
2026
|
strategy: s.strategy
|
|
2025
2027
|
});
|
|
2026
2028
|
});
|
|
2027
|
-
const
|
|
2028
|
-
i.useIn || (i.useIn = []), addUniqueItem(i.useIn,
|
|
2029
|
+
const a = getRegisteredShare(this.shareScopeMap, t, s, this.hooks.lifecycle.resolveShare), l = (i) => {
|
|
2030
|
+
i.useIn || (i.useIn = []), addUniqueItem(i.useIn, o.options.name);
|
|
2029
2031
|
};
|
|
2030
|
-
if (
|
|
2031
|
-
if (typeof
|
|
2032
|
-
return a
|
|
2033
|
-
if (typeof
|
|
2034
|
-
const i =
|
|
2032
|
+
if (a) {
|
|
2033
|
+
if (typeof a.lib == "function")
|
|
2034
|
+
return l(a), a.loaded || (a.loaded = !0, a.from === o.options.name && (s.loaded = !0)), a.lib;
|
|
2035
|
+
if (typeof a.get == "function") {
|
|
2036
|
+
const i = a.get();
|
|
2035
2037
|
if (!(i instanceof Promise))
|
|
2036
|
-
return a
|
|
2038
|
+
return l(a), this.setShared({
|
|
2037
2039
|
pkgName: t,
|
|
2038
2040
|
loaded: !0,
|
|
2039
|
-
from:
|
|
2041
|
+
from: o.options.name,
|
|
2040
2042
|
lib: i,
|
|
2041
|
-
shared:
|
|
2043
|
+
shared: a
|
|
2042
2044
|
}), i;
|
|
2043
2045
|
}
|
|
2044
2046
|
}
|
|
@@ -2047,37 +2049,37 @@ class SharedHandler {
|
|
|
2047
2049
|
if (s.get) {
|
|
2048
2050
|
const i = s.get();
|
|
2049
2051
|
if (i instanceof Promise) {
|
|
2050
|
-
const c = (
|
|
2052
|
+
const c = (n == null ? void 0 : n.from) === "build" ? RUNTIME_005 : RUNTIME_006;
|
|
2051
2053
|
throw new Error(getShortErrorMsg(c, runtimeDescMap, {
|
|
2052
|
-
hostName:
|
|
2054
|
+
hostName: o.options.name,
|
|
2053
2055
|
sharedPkgName: t
|
|
2054
2056
|
}));
|
|
2055
2057
|
}
|
|
2056
2058
|
return s.lib = i, this.setShared({
|
|
2057
2059
|
pkgName: t,
|
|
2058
2060
|
loaded: !0,
|
|
2059
|
-
from:
|
|
2061
|
+
from: o.options.name,
|
|
2060
2062
|
lib: s.lib,
|
|
2061
2063
|
shared: s
|
|
2062
2064
|
}), s.lib;
|
|
2063
2065
|
}
|
|
2064
2066
|
throw new Error(getShortErrorMsg(RUNTIME_006, runtimeDescMap, {
|
|
2065
|
-
hostName:
|
|
2067
|
+
hostName: o.options.name,
|
|
2066
2068
|
sharedPkgName: t
|
|
2067
2069
|
}));
|
|
2068
2070
|
}
|
|
2069
|
-
initShareScopeMap(t,
|
|
2071
|
+
initShareScopeMap(t, n, o = {}) {
|
|
2070
2072
|
const { host: s } = this;
|
|
2071
|
-
this.shareScopeMap[t] =
|
|
2072
|
-
shareScope:
|
|
2073
|
+
this.shareScopeMap[t] = n, this.hooks.lifecycle.initContainerShareScopeMap.emit({
|
|
2074
|
+
shareScope: n,
|
|
2073
2075
|
options: s.options,
|
|
2074
2076
|
origin: s,
|
|
2075
2077
|
scopeName: t,
|
|
2076
|
-
hostShareScopeMap:
|
|
2078
|
+
hostShareScopeMap: o.hostShareScopeMap
|
|
2077
2079
|
});
|
|
2078
2080
|
}
|
|
2079
|
-
setShared({ pkgName: t, shared:
|
|
2080
|
-
const { version: c, scope: u = "default" } =
|
|
2081
|
+
setShared({ pkgName: t, shared: n, from: o, lib: s, loading: a, loaded: l, get: i }) {
|
|
2082
|
+
const { version: c, scope: u = "default" } = n, d = _object_without_properties_loose(n, [
|
|
2081
2083
|
"version",
|
|
2082
2084
|
"scope"
|
|
2083
2085
|
]);
|
|
@@ -2092,18 +2094,18 @@ class SharedHandler {
|
|
|
2092
2094
|
]
|
|
2093
2095
|
}, d, {
|
|
2094
2096
|
lib: s,
|
|
2095
|
-
loaded:
|
|
2096
|
-
loading:
|
|
2097
|
+
loaded: l,
|
|
2098
|
+
loading: a
|
|
2097
2099
|
}), i && (this.shareScopeMap[m][t][c].get = i);
|
|
2098
2100
|
return;
|
|
2099
2101
|
}
|
|
2100
2102
|
const y = this.shareScopeMap[m][t][c];
|
|
2101
|
-
|
|
2103
|
+
a && !y.loading && (y.loading = a);
|
|
2102
2104
|
});
|
|
2103
2105
|
}
|
|
2104
2106
|
_setGlobalShareScopeMap(t) {
|
|
2105
|
-
const
|
|
2106
|
-
|
|
2107
|
+
const n = getGlobalShareScope(), o = t.id || t.name;
|
|
2108
|
+
o && !n[o] && (n[o] = this.shareScopeMap);
|
|
2107
2109
|
}
|
|
2108
2110
|
constructor(t) {
|
|
2109
2111
|
this.hooks = new PluginSystem({
|
|
@@ -2118,145 +2120,145 @@ class SharedHandler {
|
|
|
2118
2120
|
}
|
|
2119
2121
|
}
|
|
2120
2122
|
class RemoteHandler {
|
|
2121
|
-
formatAndRegisterRemote(t,
|
|
2122
|
-
return (
|
|
2123
|
+
formatAndRegisterRemote(t, n) {
|
|
2124
|
+
return (n.remotes || []).reduce((s, a) => (this.registerRemote(a, s, {
|
|
2123
2125
|
force: !1
|
|
2124
2126
|
}), s), t.remotes);
|
|
2125
2127
|
}
|
|
2126
|
-
setIdToRemoteMap(t,
|
|
2127
|
-
const { remote:
|
|
2128
|
+
setIdToRemoteMap(t, n) {
|
|
2129
|
+
const { remote: o, expose: s } = n, { name: a, alias: l } = o;
|
|
2128
2130
|
if (this.idToRemoteMap[t] = {
|
|
2129
|
-
name:
|
|
2131
|
+
name: o.name,
|
|
2130
2132
|
expose: s
|
|
2131
|
-
},
|
|
2132
|
-
const i = t.replace(
|
|
2133
|
+
}, l && t.startsWith(a)) {
|
|
2134
|
+
const i = t.replace(a, l);
|
|
2133
2135
|
this.idToRemoteMap[i] = {
|
|
2134
|
-
name:
|
|
2136
|
+
name: o.name,
|
|
2135
2137
|
expose: s
|
|
2136
2138
|
};
|
|
2137
2139
|
return;
|
|
2138
2140
|
}
|
|
2139
|
-
if (
|
|
2140
|
-
const i = t.replace(
|
|
2141
|
+
if (l && t.startsWith(l)) {
|
|
2142
|
+
const i = t.replace(l, a);
|
|
2141
2143
|
this.idToRemoteMap[i] = {
|
|
2142
|
-
name:
|
|
2144
|
+
name: o.name,
|
|
2143
2145
|
expose: s
|
|
2144
2146
|
};
|
|
2145
2147
|
}
|
|
2146
2148
|
}
|
|
2147
2149
|
// eslint-disable-next-line max-lines-per-function
|
|
2148
2150
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
2149
|
-
async loadRemote(t,
|
|
2150
|
-
const { host:
|
|
2151
|
+
async loadRemote(t, n) {
|
|
2152
|
+
const { host: o } = this;
|
|
2151
2153
|
try {
|
|
2152
|
-
const { loadFactory: s = !0 } =
|
|
2154
|
+
const { loadFactory: s = !0 } = n || {
|
|
2153
2155
|
loadFactory: !0
|
|
2154
|
-
}, { module:
|
|
2156
|
+
}, { module: a, moduleOptions: l, remoteMatchInfo: i } = await this.getRemoteModuleAndOptions({
|
|
2155
2157
|
id: t
|
|
2156
|
-
}), { pkgNameOrAlias: c, remote: u, expose: d, id: p, remoteSnapshot: m } = i, y = await
|
|
2158
|
+
}), { 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
2159
|
id: p,
|
|
2158
2160
|
pkgNameOrAlias: c,
|
|
2159
2161
|
expose: d,
|
|
2160
2162
|
exposeModule: s ? y : void 0,
|
|
2161
2163
|
exposeModuleFactory: s ? void 0 : y,
|
|
2162
2164
|
remote: u,
|
|
2163
|
-
options:
|
|
2164
|
-
moduleInstance:
|
|
2165
|
-
origin:
|
|
2165
|
+
options: l,
|
|
2166
|
+
moduleInstance: a,
|
|
2167
|
+
origin: o
|
|
2166
2168
|
});
|
|
2167
2169
|
return this.setIdToRemoteMap(t, i), typeof _ == "function" ? _ : y;
|
|
2168
2170
|
} catch (s) {
|
|
2169
|
-
const { from:
|
|
2171
|
+
const { from: a = "runtime" } = n || {
|
|
2170
2172
|
from: "runtime"
|
|
2171
|
-
},
|
|
2173
|
+
}, l = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2172
2174
|
id: t,
|
|
2173
2175
|
error: s,
|
|
2174
|
-
from:
|
|
2176
|
+
from: a,
|
|
2175
2177
|
lifecycle: "onLoad",
|
|
2176
|
-
origin:
|
|
2178
|
+
origin: o
|
|
2177
2179
|
});
|
|
2178
|
-
if (!
|
|
2180
|
+
if (!l)
|
|
2179
2181
|
throw s;
|
|
2180
|
-
return
|
|
2182
|
+
return l;
|
|
2181
2183
|
}
|
|
2182
2184
|
}
|
|
2183
2185
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
2184
2186
|
async preloadRemote(t) {
|
|
2185
|
-
const { host:
|
|
2187
|
+
const { host: n } = this;
|
|
2186
2188
|
await this.hooks.lifecycle.beforePreloadRemote.emit({
|
|
2187
2189
|
preloadOps: t,
|
|
2188
|
-
options:
|
|
2189
|
-
origin:
|
|
2190
|
+
options: n.options,
|
|
2191
|
+
origin: n
|
|
2190
2192
|
});
|
|
2191
|
-
const
|
|
2192
|
-
await Promise.all(
|
|
2193
|
-
const { remote:
|
|
2194
|
-
origin:
|
|
2193
|
+
const o = formatPreloadArgs(n.options.remotes, t);
|
|
2194
|
+
await Promise.all(o.map(async (s) => {
|
|
2195
|
+
const { remote: a } = s, l = getRemoteInfo(a), { globalSnapshot: i, remoteSnapshot: c } = await n.snapshotHandler.loadRemoteSnapshotInfo(a), u = await this.hooks.lifecycle.generatePreloadAssets.emit({
|
|
2196
|
+
origin: n,
|
|
2195
2197
|
preloadOptions: s,
|
|
2196
|
-
remote:
|
|
2197
|
-
remoteInfo:
|
|
2198
|
+
remote: a,
|
|
2199
|
+
remoteInfo: l,
|
|
2198
2200
|
globalSnapshot: i,
|
|
2199
2201
|
remoteSnapshot: c
|
|
2200
2202
|
});
|
|
2201
|
-
u && preloadAssets(
|
|
2203
|
+
u && preloadAssets(l, n, u);
|
|
2202
2204
|
}));
|
|
2203
2205
|
}
|
|
2204
|
-
registerRemotes(t,
|
|
2205
|
-
const { host:
|
|
2206
|
+
registerRemotes(t, n) {
|
|
2207
|
+
const { host: o } = this;
|
|
2206
2208
|
t.forEach((s) => {
|
|
2207
|
-
this.registerRemote(s,
|
|
2208
|
-
force:
|
|
2209
|
+
this.registerRemote(s, o.options.remotes, {
|
|
2210
|
+
force: n == null ? void 0 : n.force
|
|
2209
2211
|
});
|
|
2210
2212
|
});
|
|
2211
2213
|
}
|
|
2212
2214
|
async getRemoteModuleAndOptions(t) {
|
|
2213
|
-
const { host:
|
|
2215
|
+
const { host: n } = this, { id: o } = t;
|
|
2214
2216
|
let s;
|
|
2215
2217
|
try {
|
|
2216
2218
|
s = await this.hooks.lifecycle.beforeRequest.emit({
|
|
2217
|
-
id:
|
|
2218
|
-
options:
|
|
2219
|
-
origin:
|
|
2219
|
+
id: o,
|
|
2220
|
+
options: n.options,
|
|
2221
|
+
origin: n
|
|
2220
2222
|
});
|
|
2221
2223
|
} catch (_) {
|
|
2222
2224
|
if (s = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2223
|
-
id:
|
|
2224
|
-
options:
|
|
2225
|
-
origin:
|
|
2225
|
+
id: o,
|
|
2226
|
+
options: n.options,
|
|
2227
|
+
origin: n,
|
|
2226
2228
|
from: "runtime",
|
|
2227
2229
|
error: _,
|
|
2228
2230
|
lifecycle: "beforeRequest"
|
|
2229
2231
|
}), !s)
|
|
2230
2232
|
throw _;
|
|
2231
2233
|
}
|
|
2232
|
-
const { id:
|
|
2233
|
-
assert(
|
|
2234
|
-
hostName:
|
|
2235
|
-
requestId:
|
|
2234
|
+
const { id: a } = s, l = matchRemoteWithNameAndExpose(n.options.remotes, a);
|
|
2235
|
+
assert(l, getShortErrorMsg(RUNTIME_004, runtimeDescMap, {
|
|
2236
|
+
hostName: n.options.name,
|
|
2237
|
+
requestId: a
|
|
2236
2238
|
}));
|
|
2237
|
-
const { remote: i } =
|
|
2238
|
-
id:
|
|
2239
|
-
},
|
|
2240
|
-
options:
|
|
2241
|
-
origin:
|
|
2239
|
+
const { remote: i } = l, c = getRemoteInfo(i), u = await n.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({
|
|
2240
|
+
id: a
|
|
2241
|
+
}, l, {
|
|
2242
|
+
options: n.options,
|
|
2243
|
+
origin: n,
|
|
2242
2244
|
remoteInfo: c
|
|
2243
2245
|
})), { 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 =
|
|
2246
|
+
assert(d && p, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${a}.`);
|
|
2247
|
+
let m = n.moduleCache.get(d.name);
|
|
2246
2248
|
const y = {
|
|
2247
|
-
host:
|
|
2249
|
+
host: n,
|
|
2248
2250
|
remoteInfo: c
|
|
2249
2251
|
};
|
|
2250
|
-
return m || (m = new Module(y),
|
|
2252
|
+
return m || (m = new Module(y), n.moduleCache.set(d.name, m)), {
|
|
2251
2253
|
module: m,
|
|
2252
2254
|
moduleOptions: y,
|
|
2253
2255
|
remoteMatchInfo: u
|
|
2254
2256
|
};
|
|
2255
2257
|
}
|
|
2256
|
-
registerRemote(t,
|
|
2257
|
-
const { host: s } = this,
|
|
2258
|
+
registerRemote(t, n, o) {
|
|
2259
|
+
const { host: s } = this, a = () => {
|
|
2258
2260
|
if (t.alias) {
|
|
2259
|
-
const i =
|
|
2261
|
+
const i = n.find((c) => {
|
|
2260
2262
|
var u;
|
|
2261
2263
|
return t.alias && (c.name.startsWith(t.alias) || ((u = c.alias) == null ? void 0 : u.startsWith(t.alias)));
|
|
2262
2264
|
});
|
|
@@ -2268,9 +2270,9 @@ class RemoteHandler {
|
|
|
2268
2270
|
remote: t,
|
|
2269
2271
|
origin: s
|
|
2270
2272
|
});
|
|
2271
|
-
const
|
|
2272
|
-
if (!
|
|
2273
|
-
|
|
2273
|
+
const l = n.find((i) => i.name === t.name);
|
|
2274
|
+
if (!l)
|
|
2275
|
+
a(), n.push(t), this.hooks.lifecycle.registerRemote.emit({
|
|
2274
2276
|
remote: t,
|
|
2275
2277
|
origin: s
|
|
2276
2278
|
});
|
|
@@ -2279,7 +2281,7 @@ class RemoteHandler {
|
|
|
2279
2281
|
`The remote "${t.name}" is already registered.`,
|
|
2280
2282
|
"Please note that overriding it may cause unexpected errors."
|
|
2281
2283
|
];
|
|
2282
|
-
|
|
2284
|
+
o != null && o.force && (this.removeRemote(l), a(), n.push(t), this.hooks.lifecycle.registerRemote.emit({
|
|
2283
2285
|
remote: t,
|
|
2284
2286
|
origin: s
|
|
2285
2287
|
}), warn$1(i.join(" ")));
|
|
@@ -2287,17 +2289,17 @@ class RemoteHandler {
|
|
|
2287
2289
|
}
|
|
2288
2290
|
removeRemote(t) {
|
|
2289
2291
|
try {
|
|
2290
|
-
const { host:
|
|
2291
|
-
|
|
2292
|
-
const
|
|
2293
|
-
if (
|
|
2294
|
-
const i =
|
|
2292
|
+
const { host: o } = this, { name: s } = t, a = o.options.remotes.findIndex((i) => i.name === s);
|
|
2293
|
+
a !== -1 && o.options.remotes.splice(a, 1);
|
|
2294
|
+
const l = o.moduleCache.get(t.name);
|
|
2295
|
+
if (l) {
|
|
2296
|
+
const i = l.remoteInfo, c = i.entryGlobalName;
|
|
2295
2297
|
if (CurrentGlobal[c]) {
|
|
2296
|
-
var
|
|
2297
|
-
(
|
|
2298
|
+
var n;
|
|
2299
|
+
(n = Object.getOwnPropertyDescriptor(CurrentGlobal, c)) != null && n.configurable ? delete CurrentGlobal[c] : CurrentGlobal[c] = void 0;
|
|
2298
2300
|
}
|
|
2299
|
-
const u = getRemoteEntryUniqueKey(
|
|
2300
|
-
globalLoading[u] && delete globalLoading[u],
|
|
2301
|
+
const u = getRemoteEntryUniqueKey(l.remoteInfo);
|
|
2302
|
+
globalLoading[u] && delete globalLoading[u], o.snapshotHandler.manifestCache.delete(i.entry);
|
|
2301
2303
|
let d = i.buildVersion ? composeKeyWithSeparator(i.name, i.buildVersion) : i.name;
|
|
2302
2304
|
const p = CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex((y) => i.buildVersion ? y.options.id === d : y.name === d);
|
|
2303
2305
|
if (p !== -1) {
|
|
@@ -2307,41 +2309,41 @@ class RemoteHandler {
|
|
|
2307
2309
|
let R = !0;
|
|
2308
2310
|
const g = [];
|
|
2309
2311
|
Object.keys(_).forEach((E) => {
|
|
2310
|
-
const
|
|
2311
|
-
|
|
2312
|
-
const S = I
|
|
2312
|
+
const v = _[E];
|
|
2313
|
+
v && Object.keys(v).forEach((I) => {
|
|
2314
|
+
const S = v[I];
|
|
2313
2315
|
S && Object.keys(S).forEach((b) => {
|
|
2314
2316
|
const $ = S[b];
|
|
2315
|
-
$ && Object.keys($).forEach((
|
|
2316
|
-
const O = $[
|
|
2317
|
+
$ && Object.keys($).forEach((w) => {
|
|
2318
|
+
const O = $[w];
|
|
2317
2319
|
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
2320
|
E,
|
|
2319
|
-
|
|
2321
|
+
I,
|
|
2320
2322
|
b,
|
|
2321
|
-
|
|
2323
|
+
w
|
|
2322
2324
|
])) : g.push([
|
|
2323
2325
|
E,
|
|
2324
|
-
|
|
2326
|
+
I,
|
|
2325
2327
|
b,
|
|
2326
|
-
|
|
2328
|
+
w
|
|
2327
2329
|
]));
|
|
2328
2330
|
});
|
|
2329
2331
|
});
|
|
2330
2332
|
});
|
|
2331
|
-
}), R && (y.shareScopeMap = {}, delete _[d]), g.forEach(([E,
|
|
2332
|
-
var b, $,
|
|
2333
|
-
(
|
|
2333
|
+
}), R && (y.shareScopeMap = {}, delete _[d]), g.forEach(([E, v, I, S]) => {
|
|
2334
|
+
var b, $, w;
|
|
2335
|
+
(w = _[E]) == null || ($ = w[v]) == null || (b = $[I]) == null || delete b[S];
|
|
2334
2336
|
}), CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(p, 1);
|
|
2335
2337
|
}
|
|
2336
|
-
const { hostGlobalSnapshot: m } = getGlobalRemoteInfo(t,
|
|
2338
|
+
const { hostGlobalSnapshot: m } = getGlobalRemoteInfo(t, o);
|
|
2337
2339
|
if (m) {
|
|
2338
2340
|
const y = m && "remotesInfo" in m && m.remotesInfo && getInfoWithoutType(m.remotesInfo, t.name).key;
|
|
2339
2341
|
y && (delete m.remotesInfo[y], Global.__FEDERATION__.__MANIFEST_LOADING__[y] && delete Global.__FEDERATION__.__MANIFEST_LOADING__[y]);
|
|
2340
2342
|
}
|
|
2341
|
-
|
|
2343
|
+
o.moduleCache.delete(t.name);
|
|
2342
2344
|
}
|
|
2343
|
-
} catch (
|
|
2344
|
-
logger.log("removeRemote fail: ",
|
|
2345
|
+
} catch (o) {
|
|
2346
|
+
logger.log("removeRemote fail: ", o);
|
|
2345
2347
|
}
|
|
2346
2348
|
}
|
|
2347
2349
|
constructor(t) {
|
|
@@ -2363,59 +2365,59 @@ class RemoteHandler {
|
|
|
2363
2365
|
class FederationHost {
|
|
2364
2366
|
initOptions(t) {
|
|
2365
2367
|
this.registerPlugins(t.plugins);
|
|
2366
|
-
const
|
|
2367
|
-
return this.options =
|
|
2368
|
+
const n = this.formatOptions(this.options, t);
|
|
2369
|
+
return this.options = n, n;
|
|
2368
2370
|
}
|
|
2369
|
-
async loadShare(t,
|
|
2370
|
-
return this.sharedHandler.loadShare(t,
|
|
2371
|
+
async loadShare(t, n) {
|
|
2372
|
+
return this.sharedHandler.loadShare(t, n);
|
|
2371
2373
|
}
|
|
2372
2374
|
// 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
2375
|
// 1. If the loaded shared already exists globally, then it will be reused
|
|
2374
2376
|
// 2. If lib exists in local shared, it will be used directly
|
|
2375
2377
|
// 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,
|
|
2378
|
+
loadShareSync(t, n) {
|
|
2379
|
+
return this.sharedHandler.loadShareSync(t, n);
|
|
2378
2380
|
}
|
|
2379
|
-
initializeSharing(t = DEFAULT_SCOPE,
|
|
2380
|
-
return this.sharedHandler.initializeSharing(t,
|
|
2381
|
+
initializeSharing(t = DEFAULT_SCOPE, n) {
|
|
2382
|
+
return this.sharedHandler.initializeSharing(t, n);
|
|
2381
2383
|
}
|
|
2382
|
-
initRawContainer(t,
|
|
2384
|
+
initRawContainer(t, n, o) {
|
|
2383
2385
|
const s = getRemoteInfo({
|
|
2384
2386
|
name: t,
|
|
2385
|
-
entry:
|
|
2386
|
-
}),
|
|
2387
|
+
entry: n
|
|
2388
|
+
}), a = new Module({
|
|
2387
2389
|
host: this,
|
|
2388
2390
|
remoteInfo: s
|
|
2389
2391
|
});
|
|
2390
|
-
return
|
|
2392
|
+
return a.remoteEntryExports = o, this.moduleCache.set(t, a), a;
|
|
2391
2393
|
}
|
|
2392
2394
|
// eslint-disable-next-line max-lines-per-function
|
|
2393
2395
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
2394
|
-
async loadRemote(t,
|
|
2395
|
-
return this.remoteHandler.loadRemote(t,
|
|
2396
|
+
async loadRemote(t, n) {
|
|
2397
|
+
return this.remoteHandler.loadRemote(t, n);
|
|
2396
2398
|
}
|
|
2397
2399
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
2398
2400
|
async preloadRemote(t) {
|
|
2399
2401
|
return this.remoteHandler.preloadRemote(t);
|
|
2400
2402
|
}
|
|
2401
|
-
initShareScopeMap(t,
|
|
2402
|
-
this.sharedHandler.initShareScopeMap(t,
|
|
2403
|
+
initShareScopeMap(t, n, o = {}) {
|
|
2404
|
+
this.sharedHandler.initShareScopeMap(t, n, o);
|
|
2403
2405
|
}
|
|
2404
|
-
formatOptions(t,
|
|
2405
|
-
const { shared:
|
|
2406
|
+
formatOptions(t, n) {
|
|
2407
|
+
const { shared: o } = formatShareConfigs(t, n), { userOptions: s, options: a } = this.hooks.lifecycle.beforeInit.emit({
|
|
2406
2408
|
origin: this,
|
|
2407
|
-
userOptions:
|
|
2409
|
+
userOptions: n,
|
|
2408
2410
|
options: t,
|
|
2409
|
-
shareInfo:
|
|
2410
|
-
}),
|
|
2411
|
-
...
|
|
2411
|
+
shareInfo: o
|
|
2412
|
+
}), l = this.remoteHandler.formatAndRegisterRemote(a, s), { shared: i } = this.sharedHandler.registerShared(a, s), c = [
|
|
2413
|
+
...a.plugins
|
|
2412
2414
|
];
|
|
2413
2415
|
s.plugins && s.plugins.forEach((d) => {
|
|
2414
2416
|
c.includes(d) || c.push(d);
|
|
2415
2417
|
});
|
|
2416
|
-
const u = _extends$1({}, t,
|
|
2418
|
+
const u = _extends$1({}, t, n, {
|
|
2417
2419
|
plugins: c,
|
|
2418
|
-
remotes:
|
|
2420
|
+
remotes: l,
|
|
2419
2421
|
shared: i
|
|
2420
2422
|
});
|
|
2421
2423
|
return this.hooks.lifecycle.init.emit({
|
|
@@ -2424,7 +2426,7 @@ class FederationHost {
|
|
|
2424
2426
|
}), u;
|
|
2425
2427
|
}
|
|
2426
2428
|
registerPlugins(t) {
|
|
2427
|
-
const
|
|
2429
|
+
const n = registerPlugins$1(t, [
|
|
2428
2430
|
this.hooks,
|
|
2429
2431
|
this.remoteHandler.hooks,
|
|
2430
2432
|
this.sharedHandler.hooks,
|
|
@@ -2432,10 +2434,10 @@ class FederationHost {
|
|
|
2432
2434
|
this.loaderHook,
|
|
2433
2435
|
this.bridgeHook
|
|
2434
2436
|
]);
|
|
2435
|
-
this.options.plugins = this.options.plugins.reduce((
|
|
2437
|
+
this.options.plugins = this.options.plugins.reduce((o, s) => (s && o && !o.find((a) => a.name === s.name) && o.push(s), o), n || []);
|
|
2436
2438
|
}
|
|
2437
|
-
registerRemotes(t,
|
|
2438
|
-
return this.remoteHandler.registerRemotes(t,
|
|
2439
|
+
registerRemotes(t, n) {
|
|
2440
|
+
return this.remoteHandler.registerRemotes(t, n);
|
|
2439
2441
|
}
|
|
2440
2442
|
constructor(t) {
|
|
2441
2443
|
this.hooks = new PluginSystem({
|
|
@@ -2445,7 +2447,7 @@ class FederationHost {
|
|
|
2445
2447
|
beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
|
|
2446
2448
|
// maybe will change, temporarily for internal use only
|
|
2447
2449
|
initContainer: new AsyncWaterfallHook("initContainer")
|
|
2448
|
-
}), this.version = "0.8.
|
|
2450
|
+
}), this.version = "0.8.5", this.moduleCache = /* @__PURE__ */ new Map(), this.loaderHook = new PluginSystem({
|
|
2449
2451
|
// FIXME: may not be suitable , not open to the public yet
|
|
2450
2452
|
getModuleInfo: new SyncHook(),
|
|
2451
2453
|
createScript: new SyncHook(),
|
|
@@ -2459,7 +2461,7 @@ class FederationHost {
|
|
|
2459
2461
|
beforeBridgeDestroy: new SyncHook(),
|
|
2460
2462
|
afterBridgeDestroy: new SyncHook()
|
|
2461
2463
|
});
|
|
2462
|
-
const
|
|
2464
|
+
const n = {
|
|
2463
2465
|
id: getBuilderId(),
|
|
2464
2466
|
name: t.name,
|
|
2465
2467
|
plugins: [
|
|
@@ -2470,41 +2472,49 @@ class FederationHost {
|
|
|
2470
2472
|
shared: {},
|
|
2471
2473
|
inBrowser: isBrowserEnv()
|
|
2472
2474
|
};
|
|
2473
|
-
this.name = t.name, this.options =
|
|
2474
|
-
...
|
|
2475
|
+
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([
|
|
2476
|
+
...n.plugins,
|
|
2475
2477
|
...t.plugins || []
|
|
2476
|
-
]), this.options = this.formatOptions(
|
|
2478
|
+
]), this.options = this.formatOptions(n, t);
|
|
2477
2479
|
}
|
|
2478
2480
|
}
|
|
2481
|
+
let FederationInstance = null;
|
|
2482
|
+
function getInstance() {
|
|
2483
|
+
return FederationInstance;
|
|
2484
|
+
}
|
|
2479
2485
|
setGlobalFederationConstructor(FederationHost);
|
|
2480
2486
|
function createBridgeComponent(r) {
|
|
2481
|
-
const t = /* @__PURE__ */ new Map();
|
|
2487
|
+
const t = /* @__PURE__ */ new Map(), n = getInstance();
|
|
2482
2488
|
return () => ({
|
|
2483
|
-
__APP_VERSION__: "0.8.
|
|
2484
|
-
render(o) {
|
|
2489
|
+
__APP_VERSION__: "0.8.5",
|
|
2490
|
+
async render(o) {
|
|
2491
|
+
var c, u, d;
|
|
2485
2492
|
LoggerInstance.log("createBridgeComponent render Info", o);
|
|
2486
|
-
const
|
|
2487
|
-
t.set(o.dom,
|
|
2488
|
-
const
|
|
2493
|
+
const s = Vue.createApp(r.rootComponent);
|
|
2494
|
+
t.set(o.dom, s);
|
|
2495
|
+
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({
|
|
2496
|
+
app: s,
|
|
2489
2497
|
basename: o.basename,
|
|
2490
2498
|
memoryRoute: o.memoryRoute,
|
|
2491
2499
|
...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
2500
|
});
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2501
|
+
if (i != null && i.router) {
|
|
2502
|
+
const p = o.memoryRoute ? VueRouter.createMemoryHistory(o.basename) : VueRouter.createWebHistory(o.basename), m = VueRouter.createRouter({
|
|
2503
|
+
...i.router.options,
|
|
2504
|
+
history: p,
|
|
2505
|
+
routes: i.router.getRoutes()
|
|
2506
|
+
});
|
|
2507
|
+
LoggerInstance.log("createBridgeComponent render router info>>>", {
|
|
2508
|
+
name: o.moduleName,
|
|
2509
|
+
router: m
|
|
2510
|
+
}), o.memoryRoute && await m.push(o.memoryRoute.entryPath), s.use(m);
|
|
2511
|
+
}
|
|
2512
|
+
s.mount(o.dom);
|
|
2503
2513
|
},
|
|
2504
2514
|
destroy(o) {
|
|
2505
2515
|
LoggerInstance.log("createBridgeComponent destroy Info", o);
|
|
2506
|
-
const
|
|
2507
|
-
|
|
2516
|
+
const s = t.get(o == null ? void 0 : o.dom);
|
|
2517
|
+
s == null || s.unmount();
|
|
2508
2518
|
}
|
|
2509
2519
|
});
|
|
2510
2520
|
}
|
|
@@ -2521,10 +2531,10 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2521
2531
|
providerInfo: Function
|
|
2522
2532
|
},
|
|
2523
2533
|
setup(r) {
|
|
2524
|
-
const t = ref(null),
|
|
2534
|
+
const t = ref(null), n = ref(null), o = ref(""), s = useRoute(), a = () => {
|
|
2525
2535
|
var d;
|
|
2526
2536
|
const i = (d = r.providerInfo) == null ? void 0 : d.call(r);
|
|
2527
|
-
|
|
2537
|
+
n.value = i;
|
|
2528
2538
|
let c = {
|
|
2529
2539
|
name: r.moduleName,
|
|
2530
2540
|
dom: t.value,
|
|
@@ -2535,19 +2545,19 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2535
2545
|
...c,
|
|
2536
2546
|
...{}.extraProps
|
|
2537
2547
|
}, i.render(c);
|
|
2538
|
-
},
|
|
2539
|
-
i !== s.path &&
|
|
2548
|
+
}, l = watch(() => s.path, (i) => {
|
|
2549
|
+
i !== s.path && a(), o.value !== "" && o.value !== i && (LoggerInstance.log("createRemoteComponent dispatchPopstateEnv >>>", {
|
|
2540
2550
|
...r,
|
|
2541
2551
|
pathname: s.path
|
|
2542
|
-
}), e()),
|
|
2552
|
+
}), e()), o.value = i;
|
|
2543
2553
|
});
|
|
2544
2554
|
return onMounted(() => {
|
|
2545
|
-
|
|
2555
|
+
a();
|
|
2546
2556
|
}), onBeforeUnmount(() => {
|
|
2547
2557
|
var i;
|
|
2548
2558
|
LoggerInstance.log("createRemoteComponent LazyComponent destroy >>>", {
|
|
2549
2559
|
...r
|
|
2550
|
-
}),
|
|
2560
|
+
}), l(), (i = n.value) == null || i.destroy({
|
|
2551
2561
|
dom: t.value
|
|
2552
2562
|
});
|
|
2553
2563
|
}), () => createVNode("div", {
|
|
@@ -2557,31 +2567,31 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2557
2567
|
});
|
|
2558
2568
|
function createRemoteComponent(r) {
|
|
2559
2569
|
return defineAsyncComponent({
|
|
2560
|
-
__APP_VERSION__: "0.8.
|
|
2570
|
+
__APP_VERSION__: "0.8.5",
|
|
2561
2571
|
...r.asyncComponentOptions,
|
|
2562
2572
|
//@ts-ignore
|
|
2563
2573
|
loader: async () => {
|
|
2564
2574
|
var c;
|
|
2565
2575
|
const t = useRoute();
|
|
2566
|
-
let
|
|
2567
|
-
const
|
|
2568
|
-
|
|
2576
|
+
let n = "/";
|
|
2577
|
+
const o = (c = t.matched[0]) == null ? void 0 : c.path;
|
|
2578
|
+
o && (o.endsWith("/:pathMatch(.*)*") ? n = o.replace("/:pathMatch(.*)*", "") : n = t.matched[0].path);
|
|
2569
2579
|
const s = (r == null ? void 0 : r.export) || "default";
|
|
2570
2580
|
LoggerInstance.log("createRemoteComponent LazyComponent create >>>", {
|
|
2571
|
-
basename:
|
|
2581
|
+
basename: n,
|
|
2572
2582
|
info: r
|
|
2573
2583
|
});
|
|
2574
|
-
const
|
|
2584
|
+
const a = await r.loader(), l = a && a[Symbol.for("mf_module_id")], i = a[s];
|
|
2575
2585
|
if (LoggerInstance.log(
|
|
2576
2586
|
"createRemoteComponent LazyComponent loadRemote info >>>",
|
|
2577
|
-
{ name:
|
|
2578
|
-
), s in
|
|
2587
|
+
{ name: l, module: a, exportName: s, basename: n, route: t }
|
|
2588
|
+
), s in a && typeof i == "function")
|
|
2579
2589
|
return {
|
|
2580
2590
|
render() {
|
|
2581
2591
|
return h(RemoteApp, {
|
|
2582
|
-
moduleName:
|
|
2592
|
+
moduleName: l,
|
|
2583
2593
|
providerInfo: i,
|
|
2584
|
-
basename:
|
|
2594
|
+
basename: n
|
|
2585
2595
|
});
|
|
2586
2596
|
}
|
|
2587
2597
|
};
|