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