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