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