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