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