@module-federation/bridge-vue3 0.8.2 → 0.8.3
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 +10 -0
- package/dist/index.cjs.js +2 -2
- package/dist/index.es.js +612 -612
- package/package.json +4 -4
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
|
|
22
|
+
const r = "color test", t = "color: red;", o = console.log;
|
|
23
23
|
console.log = (...n) => {
|
|
24
|
-
n[0] === `%c${
|
|
25
|
-
}, console.log(`%c${
|
|
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(
|
|
46
|
+
function getLabel(r, t, o) {
|
|
47
47
|
let n = [""];
|
|
48
|
-
return "label" in t && (n = [r
|
|
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,8 +56,8 @@ 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)
|
|
@@ -69,13 +69,13 @@ var LOG_LEVEL = {
|
|
|
69
69
|
let [g, ...E] = p.stack.split(`
|
|
70
70
|
`);
|
|
71
71
|
g.startsWith("Error: ") && (g = g.slice(7)), _ = `${g}
|
|
72
|
-
${
|
|
72
|
+
${o(E.join(`
|
|
73
73
|
`))}`;
|
|
74
74
|
} else
|
|
75
75
|
_ = p.message;
|
|
76
76
|
else
|
|
77
77
|
y.level === "error" && typeof p == "string" ? _ = p.split(`
|
|
78
|
-
`).map((E) => isErrorStackMessage(E) ?
|
|
78
|
+
`).map((E) => isErrorStackMessage(E) ? o(E) : E).join(`
|
|
79
79
|
`) : _ = `${p}`;
|
|
80
80
|
n(R, _, m, p);
|
|
81
81
|
}, u = {
|
|
@@ -97,17 +97,17 @@ ${r(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 = [...
|
|
103
|
+
return [r];
|
|
104
|
+
const t = [...r], o = t.filter(isWord), n = o.length - 1;
|
|
105
105
|
if (n === 0)
|
|
106
|
-
return console.log(`%c${
|
|
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,8 +171,8 @@ 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 n = arguments[
|
|
174
|
+
for (var o = 1; o < arguments.length; o++) {
|
|
175
|
+
var n = arguments[o];
|
|
176
176
|
for (var s in n)
|
|
177
177
|
Object.prototype.hasOwnProperty.call(n, s) && (t[s] = n[s]);
|
|
178
178
|
}
|
|
@@ -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,29 +220,29 @@ 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
247
|
const n = ((s) => {
|
|
248
248
|
if (s === ".")
|
|
@@ -254,25 +254,25 @@ const simpleJoinRemoteEntry = (o, t) => {
|
|
|
254
254
|
return l.endsWith("/") ? l.slice(0, -1) : l;
|
|
255
255
|
}
|
|
256
256
|
return s;
|
|
257
|
-
})(
|
|
257
|
+
})(r);
|
|
258
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 =
|
|
272
|
-
let
|
|
271
|
+
d = ((p = r.remotes) == null ? void 0 : p.reduce((b, $) => {
|
|
272
|
+
let A;
|
|
273
273
|
const O = $.federationContainerName;
|
|
274
|
-
return u.includes(O) ?
|
|
275
|
-
matchedVersion:
|
|
274
|
+
return u.includes(O) ? A = l[O] : "version" in $ ? A = $.version : A = $.entry, b[O] = {
|
|
275
|
+
matchedVersion: A
|
|
276
276
|
}, b;
|
|
277
277
|
}, {})) || {};
|
|
278
278
|
}
|
|
@@ -280,7 +280,7 @@ 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: _ }, types: R, buildInfo: { buildVersion: g }, globalName: E, ssrRemoteEntry: I } =
|
|
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
286
|
buildVersion: g,
|
|
@@ -291,7 +291,7 @@ function generateSnapshotFromManifest(o, t = {}) {
|
|
|
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,20 +302,20 @@ 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 ((n =
|
|
312
|
-
const { path: b, name: $, type:
|
|
311
|
+
if ((n = r.metaData) != null && n.prefetchEntry) {
|
|
312
|
+
const { path: b, name: $, type: A } = r.metaData.prefetchEntry;
|
|
313
313
|
S = _extends$2({}, S, {
|
|
314
314
|
prefetchEntry: simpleJoinRemoteEntry(b, $),
|
|
315
|
-
prefetchEntryType:
|
|
315
|
+
prefetchEntryType: A
|
|
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()
|
|
@@ -325,43 +325,43 @@ function generateSnapshotFromManifest(o, t = {}) {
|
|
|
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
|
|
339
|
+
function isStaticResourcesEqual(r, t) {
|
|
340
|
+
const o = /^(https?:)?\/\//i, n = r.replace(o, "").replace(/\/$/, ""), s = t.replace(o, "").replace(/\/$/, "");
|
|
341
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 "${
|
|
379
|
+
a(null, new Error(`Remote script "${r.url}" time-outed.`));
|
|
380
380
|
}, n), {
|
|
381
381
|
script: t,
|
|
382
|
-
needAttach:
|
|
382
|
+
needAttach: o
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
|
-
function createLink(
|
|
386
|
-
let t = null,
|
|
385
|
+
function createLink(r) {
|
|
386
|
+
let t = null, o = !0;
|
|
387
387
|
const n = document.getElementsByTagName("link");
|
|
388
388
|
for (let l = 0; l < n.length; l++) {
|
|
389
389
|
const a = n[l], i = a.getAttribute("href"), c = a.getAttribute("ref");
|
|
390
|
-
if (i && isStaticResourcesEqual(i,
|
|
391
|
-
t = a,
|
|
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
|
-
},
|
|
426
|
+
}, o),
|
|
427
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,131 +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
531
|
function _extends$1() {
|
|
532
532
|
return _extends$1 = Object.assign || function(t) {
|
|
533
|
-
for (var
|
|
534
|
-
var n = arguments[
|
|
533
|
+
for (var o = 1; o < arguments.length; o++) {
|
|
534
|
+
var n = arguments[o];
|
|
535
535
|
for (var s in n)
|
|
536
536
|
Object.prototype.hasOwnProperty.call(n, s) && (t[s] = n[s]);
|
|
537
537
|
}
|
|
538
538
|
return t;
|
|
539
539
|
}, _extends$1.apply(this, arguments);
|
|
540
540
|
}
|
|
541
|
-
function _object_without_properties_loose(
|
|
542
|
-
if (
|
|
541
|
+
function _object_without_properties_loose(r, t) {
|
|
542
|
+
if (r == null)
|
|
543
543
|
return {};
|
|
544
|
-
var
|
|
544
|
+
var o = {}, n = Object.keys(r), s, l;
|
|
545
545
|
for (l = 0; l < n.length; l++)
|
|
546
|
-
s = n[l], !(t.indexOf(s) >= 0) && (
|
|
547
|
-
return
|
|
546
|
+
s = n[l], !(t.indexOf(s) >= 0) && (o[s] = r[s]);
|
|
547
|
+
return o;
|
|
548
548
|
}
|
|
549
549
|
function getBuilderId() {
|
|
550
550
|
return typeof FEDERATION_BUILD_IDENTIFIER < "u" ? FEDERATION_BUILD_IDENTIFIER : "";
|
|
551
551
|
}
|
|
552
552
|
const LOG_CATEGORY = "[ Federation Runtime ]", logger = createLogger(LOG_CATEGORY);
|
|
553
|
-
function assert(
|
|
554
|
-
|
|
553
|
+
function assert(r, t) {
|
|
554
|
+
r || error(t);
|
|
555
555
|
}
|
|
556
|
-
function error(
|
|
557
|
-
throw
|
|
556
|
+
function error(r) {
|
|
557
|
+
throw r instanceof Error ? (r.message = `${LOG_CATEGORY}: ${r.message}`, r) : new Error(`${LOG_CATEGORY}: ${r}`);
|
|
558
558
|
}
|
|
559
|
-
function warn(
|
|
560
|
-
|
|
559
|
+
function warn(r) {
|
|
560
|
+
r instanceof Error && (r.message = `${LOG_CATEGORY}: ${r.message}`), logger.warn(r);
|
|
561
561
|
}
|
|
562
|
-
function addUniqueItem(
|
|
563
|
-
return
|
|
562
|
+
function addUniqueItem(r, t) {
|
|
563
|
+
return r.findIndex((o) => o === t) === -1 && r.push(t), r;
|
|
564
564
|
}
|
|
565
|
-
function getFMId(
|
|
566
|
-
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}`;
|
|
567
567
|
}
|
|
568
|
-
function isRemoteInfoWithEntry(
|
|
569
|
-
return typeof
|
|
568
|
+
function isRemoteInfoWithEntry(r) {
|
|
569
|
+
return typeof r.entry < "u";
|
|
570
570
|
}
|
|
571
|
-
function isPureRemoteEntry(
|
|
572
|
-
return !
|
|
571
|
+
function isPureRemoteEntry(r) {
|
|
572
|
+
return !r.entry.includes(".json") && r.entry.includes(".js");
|
|
573
573
|
}
|
|
574
|
-
function isObject(
|
|
575
|
-
return
|
|
574
|
+
function isObject(r) {
|
|
575
|
+
return r && typeof r == "object";
|
|
576
576
|
}
|
|
577
577
|
const objectToString = Object.prototype.toString;
|
|
578
|
-
function isPlainObject(
|
|
579
|
-
return objectToString.call(
|
|
578
|
+
function isPlainObject(r) {
|
|
579
|
+
return objectToString.call(r) === "[object Object]";
|
|
580
580
|
}
|
|
581
|
-
function arrayOptions(
|
|
582
|
-
return Array.isArray(
|
|
583
|
-
|
|
581
|
+
function arrayOptions(r) {
|
|
582
|
+
return Array.isArray(r) ? r : [
|
|
583
|
+
r
|
|
584
584
|
];
|
|
585
585
|
}
|
|
586
|
-
function getRemoteEntryInfoFromSnapshot(
|
|
586
|
+
function getRemoteEntryInfoFromSnapshot(r) {
|
|
587
587
|
const t = {
|
|
588
588
|
url: "",
|
|
589
589
|
type: "global",
|
|
590
590
|
globalName: ""
|
|
591
591
|
};
|
|
592
|
-
return isBrowserEnv() ? "remoteEntry" in
|
|
593
|
-
url:
|
|
594
|
-
type:
|
|
595
|
-
globalName:
|
|
596
|
-
} : t : "ssrRemoteEntry" in
|
|
597
|
-
url:
|
|
598
|
-
type:
|
|
599
|
-
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
|
|
600
600
|
} : t;
|
|
601
601
|
}
|
|
602
|
-
const processModuleAlias = (
|
|
603
|
-
let
|
|
604
|
-
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;
|
|
605
605
|
}, CurrentGlobal = typeof globalThis == "object" ? globalThis : window, nativeGlobal = (() => {
|
|
606
606
|
try {
|
|
607
607
|
return document.defaultView;
|
|
@@ -609,57 +609,57 @@ const processModuleAlias = (o, t) => {
|
|
|
609
609
|
return CurrentGlobal;
|
|
610
610
|
}
|
|
611
611
|
})(), Global = nativeGlobal;
|
|
612
|
-
function definePropertyGlobalVal(
|
|
613
|
-
Object.defineProperty(
|
|
614
|
-
value:
|
|
612
|
+
function definePropertyGlobalVal(r, t, o) {
|
|
613
|
+
Object.defineProperty(r, t, {
|
|
614
|
+
value: o,
|
|
615
615
|
configurable: !1,
|
|
616
616
|
writable: !0
|
|
617
617
|
});
|
|
618
618
|
}
|
|
619
|
-
function includeOwnProperty(
|
|
620
|
-
return Object.hasOwnProperty.call(
|
|
619
|
+
function includeOwnProperty(r, t) {
|
|
620
|
+
return Object.hasOwnProperty.call(r, t);
|
|
621
621
|
}
|
|
622
622
|
includeOwnProperty(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__") || definePropertyGlobalVal(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});
|
|
623
623
|
const globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;
|
|
624
|
-
function setGlobalDefaultVal(
|
|
625
|
-
var t,
|
|
626
|
-
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__", {
|
|
627
627
|
__GLOBAL_PLUGIN__: [],
|
|
628
628
|
__INSTANCES__: [],
|
|
629
629
|
moduleInfo: {},
|
|
630
630
|
__SHARE__: {},
|
|
631
631
|
__MANIFEST_LOADING__: {},
|
|
632
632
|
__PRELOADED_MAP__: /* @__PURE__ */ new Map()
|
|
633
|
-
}), definePropertyGlobalVal(
|
|
633
|
+
}), definePropertyGlobalVal(r, "__VMOK__", r.__FEDERATION__));
|
|
634
634
|
var i;
|
|
635
|
-
(i = (t =
|
|
635
|
+
(i = (t = r.__FEDERATION__).__GLOBAL_PLUGIN__) != null || (t.__GLOBAL_PLUGIN__ = []);
|
|
636
636
|
var c;
|
|
637
|
-
(c = (
|
|
637
|
+
(c = (o = r.__FEDERATION__).__INSTANCES__) != null || (o.__INSTANCES__ = []);
|
|
638
638
|
var u;
|
|
639
|
-
(u = (n =
|
|
639
|
+
(u = (n = r.__FEDERATION__).moduleInfo) != null || (n.moduleInfo = {});
|
|
640
640
|
var d;
|
|
641
|
-
(d = (s =
|
|
641
|
+
(d = (s = r.__FEDERATION__).__SHARE__) != null || (s.__SHARE__ = {});
|
|
642
642
|
var p;
|
|
643
|
-
(p = (l =
|
|
643
|
+
(p = (l = r.__FEDERATION__).__MANIFEST_LOADING__) != null || (l.__MANIFEST_LOADING__ = {});
|
|
644
644
|
var m;
|
|
645
|
-
(m = (a =
|
|
645
|
+
(m = (a = r.__FEDERATION__).__PRELOADED_MAP__) != null || (a.__PRELOADED_MAP__ = /* @__PURE__ */ new Map());
|
|
646
646
|
}
|
|
647
647
|
setGlobalDefaultVal(CurrentGlobal);
|
|
648
648
|
setGlobalDefaultVal(nativeGlobal);
|
|
649
|
-
function setGlobalFederationConstructor(
|
|
650
|
-
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ =
|
|
649
|
+
function setGlobalFederationConstructor(r, t = isDebugMode()) {
|
|
650
|
+
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = r, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.8.3");
|
|
651
651
|
}
|
|
652
|
-
function getInfoWithoutType(
|
|
652
|
+
function getInfoWithoutType(r, t) {
|
|
653
653
|
if (typeof t == "string") {
|
|
654
|
-
if (
|
|
654
|
+
if (r[t])
|
|
655
655
|
return {
|
|
656
|
-
value:
|
|
656
|
+
value: r[t],
|
|
657
657
|
key: t
|
|
658
658
|
};
|
|
659
659
|
{
|
|
660
|
-
const n = Object.keys(
|
|
660
|
+
const n = Object.keys(r);
|
|
661
661
|
for (const s of n) {
|
|
662
|
-
const [l, a] = s.split(":"), i = `${l}:${t}`, c =
|
|
662
|
+
const [l, a] = s.split(":"), i = `${l}:${t}`, c = r[i];
|
|
663
663
|
if (c)
|
|
664
664
|
return {
|
|
665
665
|
value: c,
|
|
@@ -674,121 +674,121 @@ function getInfoWithoutType(o, t) {
|
|
|
674
674
|
} else
|
|
675
675
|
throw new Error("key must be string");
|
|
676
676
|
}
|
|
677
|
-
const getGlobalSnapshot = () => nativeGlobal.__FEDERATION__.moduleInfo, getTargetSnapshotInfoByModuleInfo = (
|
|
678
|
-
const
|
|
679
|
-
if (n && !n.version && "version" in
|
|
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
680
|
return n;
|
|
681
|
-
if ("version" in
|
|
682
|
-
const { version: s } =
|
|
681
|
+
if ("version" in r && r.version) {
|
|
682
|
+
const { version: s } = r, l = _object_without_properties_loose(r, [
|
|
683
683
|
"version"
|
|
684
684
|
]), a = getFMId(l), i = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, a).value;
|
|
685
685
|
if ((i == null ? void 0 : i.version) === s)
|
|
686
686
|
return i;
|
|
687
687
|
}
|
|
688
|
-
}, getGlobalSnapshotInfoByModuleInfo = (
|
|
689
|
-
const
|
|
690
|
-
return nativeGlobal.__FEDERATION__.moduleInfo[
|
|
691
|
-
}, addGlobalSnapshot = (
|
|
692
|
-
const t = Object.keys(
|
|
693
|
-
for (const
|
|
694
|
-
delete nativeGlobal.__FEDERATION__.moduleInfo[
|
|
695
|
-
}), getRemoteEntryExports = (
|
|
696
|
-
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];
|
|
697
697
|
return {
|
|
698
|
-
remoteEntryKey:
|
|
698
|
+
remoteEntryKey: o,
|
|
699
699
|
entryExports: n
|
|
700
700
|
};
|
|
701
|
-
}, getGlobalHostPlugins = () => nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__, getPreloaded = (
|
|
702
|
-
function parseRegex(
|
|
703
|
-
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);
|
|
704
704
|
}
|
|
705
|
-
function isXVersion(
|
|
706
|
-
return !
|
|
705
|
+
function isXVersion(r) {
|
|
706
|
+
return !r || r.toLowerCase() === "x" || r === "*";
|
|
707
707
|
}
|
|
708
|
-
function pipe(...
|
|
709
|
-
return (t) =>
|
|
708
|
+
function pipe(...r) {
|
|
709
|
+
return (t) => r.reduce((o, n) => n(o), t);
|
|
710
710
|
}
|
|
711
|
-
function extractComparator(
|
|
712
|
-
return
|
|
711
|
+
function extractComparator(r) {
|
|
712
|
+
return r.match(parseRegex(comparator));
|
|
713
713
|
}
|
|
714
|
-
function combineVersion(
|
|
715
|
-
const s = `${
|
|
714
|
+
function combineVersion(r, t, o, n) {
|
|
715
|
+
const s = `${r}.${t}.${o}`;
|
|
716
716
|
return n ? `${s}-${n}` : s;
|
|
717
717
|
}
|
|
718
|
-
function parseHyphen(
|
|
719
|
-
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()));
|
|
720
720
|
}
|
|
721
|
-
function parseComparatorTrim(
|
|
722
|
-
return
|
|
721
|
+
function parseComparatorTrim(r) {
|
|
722
|
+
return r.replace(parseRegex(comparatorTrim), "$1$2$3");
|
|
723
723
|
}
|
|
724
|
-
function parseTildeTrim(
|
|
725
|
-
return
|
|
724
|
+
function parseTildeTrim(r) {
|
|
725
|
+
return r.replace(parseRegex(tildeTrim), "$1~");
|
|
726
726
|
}
|
|
727
|
-
function parseCaretTrim(
|
|
728
|
-
return
|
|
727
|
+
function parseCaretTrim(r) {
|
|
728
|
+
return r.replace(parseRegex(caretTrim), "$1^");
|
|
729
729
|
}
|
|
730
|
-
function parseCarets(
|
|
731
|
-
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(" ");
|
|
732
732
|
}
|
|
733
|
-
function parseTildes(
|
|
734
|
-
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(" ");
|
|
735
735
|
}
|
|
736
|
-
function parseXRanges(
|
|
737
|
-
return
|
|
736
|
+
function parseXRanges(r) {
|
|
737
|
+
return r.split(/\s+/).map((t) => t.trim().replace(parseRegex(xRange), (o, n, s, l, a, i) => {
|
|
738
738
|
const c = isXVersion(s), u = c || isXVersion(l), d = u || isXVersion(a);
|
|
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` :
|
|
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;
|
|
740
740
|
})).join(" ");
|
|
741
741
|
}
|
|
742
|
-
function parseStar(
|
|
743
|
-
return
|
|
742
|
+
function parseStar(r) {
|
|
743
|
+
return r.trim().replace(parseRegex(star), "");
|
|
744
744
|
}
|
|
745
|
-
function parseGTE0(
|
|
746
|
-
return
|
|
745
|
+
function parseGTE0(r) {
|
|
746
|
+
return r.trim().replace(parseRegex(gte0), "");
|
|
747
747
|
}
|
|
748
|
-
function compareAtom(
|
|
749
|
-
return
|
|
748
|
+
function compareAtom(r, t) {
|
|
749
|
+
return r = Number(r) || r, t = Number(t) || t, r > t ? 1 : r === t ? 0 : -1;
|
|
750
750
|
}
|
|
751
|
-
function comparePreRelease(
|
|
752
|
-
const { preRelease:
|
|
753
|
-
if (
|
|
751
|
+
function comparePreRelease(r, t) {
|
|
752
|
+
const { preRelease: o } = r, { preRelease: n } = t;
|
|
753
|
+
if (o === void 0 && n)
|
|
754
754
|
return 1;
|
|
755
|
-
if (
|
|
755
|
+
if (o && n === void 0)
|
|
756
756
|
return -1;
|
|
757
|
-
if (
|
|
757
|
+
if (o === void 0 && n === void 0)
|
|
758
758
|
return 0;
|
|
759
|
-
for (let s = 0, l =
|
|
760
|
-
const a =
|
|
759
|
+
for (let s = 0, l = o.length; s <= l; s++) {
|
|
760
|
+
const a = o[s], i = n[s];
|
|
761
761
|
if (a !== i)
|
|
762
762
|
return a === void 0 && i === void 0 ? 0 : a ? i ? compareAtom(a, i) : -1 : 1;
|
|
763
763
|
}
|
|
764
764
|
return 0;
|
|
765
765
|
}
|
|
766
|
-
function compareVersion(
|
|
767
|
-
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);
|
|
768
768
|
}
|
|
769
|
-
function eq(
|
|
770
|
-
return
|
|
769
|
+
function eq(r, t) {
|
|
770
|
+
return r.version === t.version;
|
|
771
771
|
}
|
|
772
|
-
function compare(
|
|
773
|
-
switch (
|
|
772
|
+
function compare(r, t) {
|
|
773
|
+
switch (r.operator) {
|
|
774
774
|
case "":
|
|
775
775
|
case "=":
|
|
776
|
-
return eq(
|
|
776
|
+
return eq(r, t);
|
|
777
777
|
case ">":
|
|
778
|
-
return compareVersion(
|
|
778
|
+
return compareVersion(r, t) < 0;
|
|
779
779
|
case ">=":
|
|
780
|
-
return eq(
|
|
780
|
+
return eq(r, t) || compareVersion(r, t) < 0;
|
|
781
781
|
case "<":
|
|
782
|
-
return compareVersion(
|
|
782
|
+
return compareVersion(r, t) > 0;
|
|
783
783
|
case "<=":
|
|
784
|
-
return eq(
|
|
784
|
+
return eq(r, t) || compareVersion(r, t) > 0;
|
|
785
785
|
case void 0:
|
|
786
786
|
return !0;
|
|
787
787
|
default:
|
|
788
788
|
return !1;
|
|
789
789
|
}
|
|
790
790
|
}
|
|
791
|
-
function parseComparatorString(
|
|
791
|
+
function parseComparatorString(r) {
|
|
792
792
|
return pipe(
|
|
793
793
|
// handle caret
|
|
794
794
|
// ^ --> * (any, kinda silly)
|
|
@@ -808,9 +808,9 @@ function parseComparatorString(o) {
|
|
|
808
808
|
parseTildes,
|
|
809
809
|
parseXRanges,
|
|
810
810
|
parseStar
|
|
811
|
-
)(
|
|
811
|
+
)(r);
|
|
812
812
|
}
|
|
813
|
-
function parseRange(
|
|
813
|
+
function parseRange(r) {
|
|
814
814
|
return pipe(
|
|
815
815
|
// handle hyphenRange
|
|
816
816
|
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
|
@@ -824,12 +824,12 @@ function parseRange(o) {
|
|
|
824
824
|
// handle trim caret
|
|
825
825
|
// `^ 1.2.3` => `^1.2.3`
|
|
826
826
|
parseCaretTrim
|
|
827
|
-
)(
|
|
827
|
+
)(r.trim()).split(/\s+/).join(" ");
|
|
828
828
|
}
|
|
829
|
-
function satisfy(
|
|
830
|
-
if (!
|
|
829
|
+
function satisfy(r, t) {
|
|
830
|
+
if (!r)
|
|
831
831
|
return !1;
|
|
832
|
-
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);
|
|
833
833
|
if (!l)
|
|
834
834
|
return !1;
|
|
835
835
|
const [, a, , i, c, u, d] = l, p = {
|
|
@@ -857,40 +857,40 @@ function satisfy(o, t) {
|
|
|
857
857
|
}
|
|
858
858
|
return !0;
|
|
859
859
|
}
|
|
860
|
-
function formatShare(
|
|
860
|
+
function formatShare(r, t, o, n) {
|
|
861
861
|
let s;
|
|
862
|
-
"get" in
|
|
863
|
-
throw new Error(`Can not get shared '${
|
|
864
|
-
}),
|
|
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!"');
|
|
865
865
|
var l, a, i;
|
|
866
866
|
return _extends$1({
|
|
867
867
|
deps: [],
|
|
868
868
|
useIn: [],
|
|
869
869
|
from: t,
|
|
870
870
|
loading: null
|
|
871
|
-
},
|
|
871
|
+
}, r, {
|
|
872
872
|
shareConfig: _extends$1({
|
|
873
|
-
requiredVersion: `^${
|
|
873
|
+
requiredVersion: `^${r.version}`,
|
|
874
874
|
singleton: !1,
|
|
875
875
|
eager: !1,
|
|
876
876
|
strictVersion: !1
|
|
877
|
-
},
|
|
877
|
+
}, r.shareConfig),
|
|
878
878
|
get: s,
|
|
879
|
-
loaded:
|
|
880
|
-
version: (l =
|
|
881
|
-
scope: Array.isArray(
|
|
882
|
-
(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"
|
|
883
883
|
],
|
|
884
|
-
strategy: ((i =
|
|
884
|
+
strategy: ((i = r.strategy) != null ? i : n) || "version-first"
|
|
885
885
|
});
|
|
886
886
|
}
|
|
887
|
-
function formatShareConfigs(
|
|
888
|
-
const
|
|
889
|
-
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]);
|
|
890
890
|
return a[i] = a[i] || [], c.forEach((u) => {
|
|
891
891
|
a[i].push(formatShare(u, n, i, t.shareStrategy));
|
|
892
892
|
}), a;
|
|
893
|
-
}, {}), l = _extends$1({},
|
|
893
|
+
}, {}), l = _extends$1({}, r.shared);
|
|
894
894
|
return Object.keys(s).forEach((a) => {
|
|
895
895
|
l[a] ? s[a].forEach((i) => {
|
|
896
896
|
l[a].find((u) => u.version === i.version) || l[a].push(i);
|
|
@@ -900,8 +900,8 @@ function formatShareConfigs(o, t) {
|
|
|
900
900
|
shareInfos: s
|
|
901
901
|
};
|
|
902
902
|
}
|
|
903
|
-
function versionLt(
|
|
904
|
-
const
|
|
903
|
+
function versionLt(r, t) {
|
|
904
|
+
const o = (n) => {
|
|
905
905
|
if (!Number.isNaN(Number(n))) {
|
|
906
906
|
const l = n.split(".");
|
|
907
907
|
let a = n;
|
|
@@ -911,54 +911,54 @@ function versionLt(o, t) {
|
|
|
911
911
|
}
|
|
912
912
|
return n;
|
|
913
913
|
};
|
|
914
|
-
return !!satisfy(r
|
|
914
|
+
return !!satisfy(o(r), `<=${o(t)}`);
|
|
915
915
|
}
|
|
916
|
-
const findVersion = (
|
|
917
|
-
const
|
|
916
|
+
const findVersion = (r, t) => {
|
|
917
|
+
const o = t || function(n, s) {
|
|
918
918
|
return versionLt(n, s);
|
|
919
919
|
};
|
|
920
|
-
return Object.keys(
|
|
921
|
-
}, isLoaded = (
|
|
922
|
-
function findSingletonVersionOrderByVersion(
|
|
923
|
-
const n =
|
|
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
924
|
return !isLoaded(n[l]) && versionLt(l, a);
|
|
925
925
|
};
|
|
926
|
-
return findVersion(
|
|
926
|
+
return findVersion(r[t][o], s);
|
|
927
927
|
}
|
|
928
|
-
function findSingletonVersionOrderByLoaded(
|
|
929
|
-
const n =
|
|
928
|
+
function findSingletonVersionOrderByLoaded(r, t, o) {
|
|
929
|
+
const n = r[t][o], s = function(l, a) {
|
|
930
930
|
const i = (c) => isLoaded(c) || isLoading(c);
|
|
931
931
|
return i(n[a]) ? i(n[l]) ? !!versionLt(l, a) : !0 : i(n[l]) ? !1 : versionLt(l, a);
|
|
932
932
|
};
|
|
933
|
-
return findVersion(
|
|
933
|
+
return findVersion(r[t][o], s);
|
|
934
934
|
}
|
|
935
|
-
function getFindShareFunction(
|
|
936
|
-
return
|
|
935
|
+
function getFindShareFunction(r) {
|
|
936
|
+
return r === "loaded-first" ? findSingletonVersionOrderByLoaded : findSingletonVersionOrderByVersion;
|
|
937
937
|
}
|
|
938
|
-
function getRegisteredShare(
|
|
939
|
-
if (!
|
|
938
|
+
function getRegisteredShare(r, t, o, n) {
|
|
939
|
+
if (!r)
|
|
940
940
|
return;
|
|
941
|
-
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 : [
|
|
942
942
|
l
|
|
943
943
|
];
|
|
944
944
|
for (const c of i)
|
|
945
|
-
if (s &&
|
|
946
|
-
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 = () => {
|
|
947
947
|
if (s.singleton) {
|
|
948
948
|
if (typeof u == "string" && !satisfy(p, u)) {
|
|
949
|
-
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})`;
|
|
950
950
|
s.strictVersion ? error(R) : warn(R);
|
|
951
951
|
}
|
|
952
|
-
return
|
|
952
|
+
return r[c][t][p];
|
|
953
953
|
} else {
|
|
954
954
|
if (u === !1 || u === "*" || satisfy(p, u))
|
|
955
|
-
return
|
|
956
|
-
for (const [R, g] of Object.entries(
|
|
955
|
+
return r[c][t][p];
|
|
956
|
+
for (const [R, g] of Object.entries(r[c][t]))
|
|
957
957
|
if (satisfy(R, u))
|
|
958
958
|
return g;
|
|
959
959
|
}
|
|
960
960
|
}, y = {
|
|
961
|
-
shareScopeMap:
|
|
961
|
+
shareScopeMap: r,
|
|
962
962
|
scope: c,
|
|
963
963
|
pkgName: t,
|
|
964
964
|
version: p,
|
|
@@ -971,8 +971,8 @@ function getRegisteredShare(o, t, r, n) {
|
|
|
971
971
|
function getGlobalShareScope() {
|
|
972
972
|
return Global.__FEDERATION__.__SHARE__;
|
|
973
973
|
}
|
|
974
|
-
function getTargetSharedOptions(
|
|
975
|
-
const { pkgName: t, extraOptions:
|
|
974
|
+
function getTargetSharedOptions(r) {
|
|
975
|
+
const { pkgName: t, extraOptions: o, shareInfos: n } = r, s = (i) => {
|
|
976
976
|
if (!i)
|
|
977
977
|
return;
|
|
978
978
|
const c = {};
|
|
@@ -985,23 +985,23 @@ function getTargetSharedOptions(o) {
|
|
|
985
985
|
return c[d];
|
|
986
986
|
};
|
|
987
987
|
var l;
|
|
988
|
-
const a = (l =
|
|
989
|
-
return Object.assign({}, a(n[t]),
|
|
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);
|
|
990
990
|
}
|
|
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 = (
|
|
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) => {
|
|
992
992
|
const s = [
|
|
993
993
|
`${[
|
|
994
|
-
t[
|
|
995
|
-
]} #${
|
|
994
|
+
t[r]
|
|
995
|
+
]} #${r}`
|
|
996
996
|
];
|
|
997
|
-
return
|
|
997
|
+
return o && s.push(`args: ${JSON.stringify(o)}`), s.push(getDocsUrl(r)), n && s.push(`Original Error Message:
|
|
998
998
|
${n}`), s.join(`
|
|
999
999
|
`);
|
|
1000
1000
|
};
|
|
1001
1001
|
function _extends() {
|
|
1002
1002
|
return _extends = Object.assign || function(t) {
|
|
1003
|
-
for (var
|
|
1004
|
-
var n = arguments[
|
|
1003
|
+
for (var o = 1; o < arguments.length; o++) {
|
|
1004
|
+
var n = arguments[o];
|
|
1005
1005
|
for (var s in n)
|
|
1006
1006
|
Object.prototype.hasOwnProperty.call(n, s) && (t[s] = n[s]);
|
|
1007
1007
|
}
|
|
@@ -1020,80 +1020,80 @@ const runtimeDescMap = {
|
|
|
1020
1020
|
[TYPE_001]: "Failed to generate type declaration."
|
|
1021
1021
|
};
|
|
1022
1022
|
_extends({}, runtimeDescMap, typeDescMap);
|
|
1023
|
-
function matchRemoteWithNameAndExpose(
|
|
1024
|
-
for (const
|
|
1025
|
-
const n = t.startsWith(
|
|
1026
|
-
let s = t.replace(
|
|
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
1027
|
if (n) {
|
|
1028
1028
|
if (s.startsWith("/")) {
|
|
1029
|
-
const i =
|
|
1029
|
+
const i = o.name;
|
|
1030
1030
|
return s = `.${s}`, {
|
|
1031
1031
|
pkgNameOrAlias: i,
|
|
1032
1032
|
expose: s,
|
|
1033
|
-
remote:
|
|
1033
|
+
remote: o
|
|
1034
1034
|
};
|
|
1035
1035
|
} else if (s === "")
|
|
1036
1036
|
return {
|
|
1037
|
-
pkgNameOrAlias:
|
|
1037
|
+
pkgNameOrAlias: o.name,
|
|
1038
1038
|
expose: ".",
|
|
1039
|
-
remote:
|
|
1039
|
+
remote: o
|
|
1040
1040
|
};
|
|
1041
1041
|
}
|
|
1042
|
-
const l =
|
|
1043
|
-
let a =
|
|
1044
|
-
if (
|
|
1042
|
+
const l = o.alias && t.startsWith(o.alias);
|
|
1043
|
+
let a = o.alias && t.replace(o.alias, "");
|
|
1044
|
+
if (o.alias && l) {
|
|
1045
1045
|
if (a && a.startsWith("/")) {
|
|
1046
|
-
const i =
|
|
1046
|
+
const i = o.alias;
|
|
1047
1047
|
return a = `.${a}`, {
|
|
1048
1048
|
pkgNameOrAlias: i,
|
|
1049
1049
|
expose: a,
|
|
1050
|
-
remote:
|
|
1050
|
+
remote: o
|
|
1051
1051
|
};
|
|
1052
1052
|
} else if (a === "")
|
|
1053
1053
|
return {
|
|
1054
|
-
pkgNameOrAlias:
|
|
1054
|
+
pkgNameOrAlias: o.alias,
|
|
1055
1055
|
expose: ".",
|
|
1056
|
-
remote:
|
|
1056
|
+
remote: o
|
|
1057
1057
|
};
|
|
1058
1058
|
}
|
|
1059
1059
|
}
|
|
1060
1060
|
}
|
|
1061
|
-
function matchRemote(
|
|
1062
|
-
for (const
|
|
1063
|
-
if (t ===
|
|
1064
|
-
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;
|
|
1065
1065
|
}
|
|
1066
|
-
function registerPlugins$1(
|
|
1067
|
-
const
|
|
1068
|
-
return
|
|
1069
|
-
|
|
1070
|
-
}),
|
|
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) => {
|
|
1071
1071
|
t.forEach((s) => {
|
|
1072
1072
|
s.applyPlugin(n);
|
|
1073
1073
|
});
|
|
1074
|
-
}),
|
|
1074
|
+
}), r;
|
|
1075
1075
|
}
|
|
1076
|
-
async function loadEsmEntry({ entry:
|
|
1077
|
-
return new Promise((
|
|
1076
|
+
async function loadEsmEntry({ entry: r, remoteEntryExports: t }) {
|
|
1077
|
+
return new Promise((o, n) => {
|
|
1078
1078
|
try {
|
|
1079
|
-
t ?
|
|
1080
|
-
|
|
1079
|
+
t ? o(t) : typeof FEDERATION_ALLOW_NEW_FUNCTION < "u" ? new Function("callbacks", `import("${r}").then(callbacks[0]).catch(callbacks[1])`)([
|
|
1080
|
+
o,
|
|
1081
1081
|
n
|
|
1082
1082
|
]) : import(
|
|
1083
1083
|
/* webpackIgnore: true */
|
|
1084
1084
|
/* @vite-ignore */
|
|
1085
|
-
|
|
1086
|
-
).then(
|
|
1085
|
+
r
|
|
1086
|
+
).then(o).catch(n);
|
|
1087
1087
|
} catch (s) {
|
|
1088
1088
|
n(s);
|
|
1089
1089
|
}
|
|
1090
1090
|
});
|
|
1091
1091
|
}
|
|
1092
|
-
async function loadSystemJsEntry({ entry:
|
|
1093
|
-
return new Promise((
|
|
1092
|
+
async function loadSystemJsEntry({ entry: r, remoteEntryExports: t }) {
|
|
1093
|
+
return new Promise((o, n) => {
|
|
1094
1094
|
try {
|
|
1095
|
-
t ?
|
|
1096
|
-
|
|
1095
|
+
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])`)([
|
|
1096
|
+
o,
|
|
1097
1097
|
n
|
|
1098
1098
|
]);
|
|
1099
1099
|
} catch (s) {
|
|
@@ -1101,9 +1101,9 @@ async function loadSystemJsEntry({ entry: o, remoteEntryExports: t }) {
|
|
|
1101
1101
|
}
|
|
1102
1102
|
});
|
|
1103
1103
|
}
|
|
1104
|
-
async function loadEntryScript({ name:
|
|
1105
|
-
const { entryExports: s } = getRemoteEntryExports(
|
|
1106
|
-
return s || loadScript(
|
|
1104
|
+
async function loadEntryScript({ name: r, globalName: t, entry: o, loaderHook: n }) {
|
|
1105
|
+
const { entryExports: s } = getRemoteEntryExports(r, t);
|
|
1106
|
+
return s || loadScript(o, {
|
|
1107
1107
|
attrs: {},
|
|
1108
1108
|
createScriptHook: (l, a) => {
|
|
1109
1109
|
const i = n.lifecycle.createScript.emit({
|
|
@@ -1114,18 +1114,18 @@ async function loadEntryScript({ name: o, globalName: t, entry: r, loaderHook: n
|
|
|
1114
1114
|
return i;
|
|
1115
1115
|
}
|
|
1116
1116
|
}).then(() => {
|
|
1117
|
-
const { remoteEntryKey: l, entryExports: a } = getRemoteEntryExports(
|
|
1117
|
+
const { remoteEntryKey: l, entryExports: a } = getRemoteEntryExports(r, t);
|
|
1118
1118
|
return assert(a, getShortErrorMsg(RUNTIME_001, runtimeDescMap, {
|
|
1119
|
-
remoteName:
|
|
1120
|
-
remoteEntryUrl:
|
|
1119
|
+
remoteName: r,
|
|
1120
|
+
remoteEntryUrl: o,
|
|
1121
1121
|
remoteEntryKey: l
|
|
1122
1122
|
})), a;
|
|
1123
1123
|
}).catch((l) => {
|
|
1124
1124
|
throw l;
|
|
1125
1125
|
});
|
|
1126
1126
|
}
|
|
1127
|
-
async function loadEntryDom({ remoteInfo:
|
|
1128
|
-
const { entry: n, entryGlobalName: s, name: l, type: a } =
|
|
1127
|
+
async function loadEntryDom({ remoteInfo: r, remoteEntryExports: t, loaderHook: o }) {
|
|
1128
|
+
const { entry: n, entryGlobalName: s, name: l, type: a } = r;
|
|
1129
1129
|
switch (a) {
|
|
1130
1130
|
case "esm":
|
|
1131
1131
|
case "module":
|
|
@@ -1143,13 +1143,13 @@ async function loadEntryDom({ remoteInfo: o, remoteEntryExports: t, loaderHook:
|
|
|
1143
1143
|
entry: n,
|
|
1144
1144
|
globalName: s,
|
|
1145
1145
|
name: l,
|
|
1146
|
-
loaderHook:
|
|
1146
|
+
loaderHook: o
|
|
1147
1147
|
});
|
|
1148
1148
|
}
|
|
1149
1149
|
}
|
|
1150
|
-
async function loadEntryNode({ remoteInfo:
|
|
1151
|
-
const { entry:
|
|
1152
|
-
return a || loadScriptNode(
|
|
1150
|
+
async function loadEntryNode({ remoteInfo: r, loaderHook: t }) {
|
|
1151
|
+
const { entry: o, entryGlobalName: n, name: s, type: l } = r, { entryExports: a } = getRemoteEntryExports(s, n);
|
|
1152
|
+
return a || loadScriptNode(o, {
|
|
1153
1153
|
attrs: {
|
|
1154
1154
|
name: s,
|
|
1155
1155
|
globalName: n,
|
|
@@ -1169,44 +1169,44 @@ async function loadEntryNode({ remoteInfo: o, loaderHook: t }) {
|
|
|
1169
1169
|
const { remoteEntryKey: i, entryExports: c } = getRemoteEntryExports(s, n);
|
|
1170
1170
|
return assert(c, getShortErrorMsg(RUNTIME_001, runtimeDescMap, {
|
|
1171
1171
|
remoteName: s,
|
|
1172
|
-
remoteEntryUrl:
|
|
1172
|
+
remoteEntryUrl: o,
|
|
1173
1173
|
remoteEntryKey: i
|
|
1174
1174
|
})), c;
|
|
1175
1175
|
}).catch((i) => {
|
|
1176
1176
|
throw i;
|
|
1177
1177
|
});
|
|
1178
1178
|
}
|
|
1179
|
-
function getRemoteEntryUniqueKey(
|
|
1180
|
-
const { entry: t, name:
|
|
1181
|
-
return composeKeyWithSeparator(
|
|
1179
|
+
function getRemoteEntryUniqueKey(r) {
|
|
1180
|
+
const { entry: t, name: o } = r;
|
|
1181
|
+
return composeKeyWithSeparator(o, t);
|
|
1182
1182
|
}
|
|
1183
|
-
async function getRemoteEntry({ origin:
|
|
1184
|
-
const n = getRemoteEntryUniqueKey(
|
|
1183
|
+
async function getRemoteEntry({ origin: r, remoteEntryExports: t, remoteInfo: o }) {
|
|
1184
|
+
const n = getRemoteEntryUniqueKey(o);
|
|
1185
1185
|
if (t)
|
|
1186
1186
|
return t;
|
|
1187
1187
|
if (!globalLoading[n]) {
|
|
1188
|
-
const s =
|
|
1188
|
+
const s = r.remoteHandler.hooks.lifecycle.loadEntry, l = r.loaderHook;
|
|
1189
1189
|
globalLoading[n] = s.emit({
|
|
1190
1190
|
loaderHook: l,
|
|
1191
|
-
remoteInfo:
|
|
1191
|
+
remoteInfo: o,
|
|
1192
1192
|
remoteEntryExports: t
|
|
1193
1193
|
}).then((a) => a || (isBrowserEnv() ? loadEntryDom({
|
|
1194
|
-
remoteInfo:
|
|
1194
|
+
remoteInfo: o,
|
|
1195
1195
|
remoteEntryExports: t,
|
|
1196
1196
|
loaderHook: l
|
|
1197
1197
|
}) : loadEntryNode({
|
|
1198
|
-
remoteInfo:
|
|
1198
|
+
remoteInfo: o,
|
|
1199
1199
|
loaderHook: l
|
|
1200
1200
|
})));
|
|
1201
1201
|
}
|
|
1202
1202
|
return globalLoading[n];
|
|
1203
1203
|
}
|
|
1204
|
-
function getRemoteInfo(
|
|
1205
|
-
return _extends$1({},
|
|
1206
|
-
entry: "entry" in
|
|
1207
|
-
type:
|
|
1208
|
-
entryGlobalName:
|
|
1209
|
-
shareScope:
|
|
1204
|
+
function getRemoteInfo(r) {
|
|
1205
|
+
return _extends$1({}, r, {
|
|
1206
|
+
entry: "entry" in r ? r.entry : "",
|
|
1207
|
+
type: r.type || DEFAULT_REMOTE_TYPE,
|
|
1208
|
+
entryGlobalName: r.entryGlobalName || r.name,
|
|
1209
|
+
shareScope: r.shareScope || DEFAULT_SCOPE
|
|
1210
1210
|
});
|
|
1211
1211
|
}
|
|
1212
1212
|
let Module = class {
|
|
@@ -1235,7 +1235,7 @@ let Module = class {
|
|
|
1235
1235
|
${safeToString(this.remoteInfo)}`), this.remoteEntryExports = t, this.remoteEntryExports;
|
|
1236
1236
|
}
|
|
1237
1237
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1238
|
-
async get(t,
|
|
1238
|
+
async get(t, o, n, s) {
|
|
1239
1239
|
const { loadFactory: l = !0 } = n || {
|
|
1240
1240
|
loadFactory: !0
|
|
1241
1241
|
}, a = await this.getEntry();
|
|
@@ -1272,13 +1272,13 @@ let Module = class {
|
|
|
1272
1272
|
let i;
|
|
1273
1273
|
i = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
|
|
1274
1274
|
remoteEntryExports: a,
|
|
1275
|
-
expose:
|
|
1275
|
+
expose: o,
|
|
1276
1276
|
moduleInfo: this.remoteInfo
|
|
1277
|
-
}), i || (i = await a.get(
|
|
1278
|
-
const c = processModuleAlias(this.remoteInfo.name,
|
|
1277
|
+
}), i || (i = await a.get(o)), assert(i, `${getFMId(this.remoteInfo)} remote don't export ${o}.`);
|
|
1278
|
+
const c = processModuleAlias(this.remoteInfo.name, o), u = this.wraperFactory(i, c);
|
|
1279
1279
|
return l ? await u() : u;
|
|
1280
1280
|
}
|
|
1281
|
-
wraperFactory(t,
|
|
1281
|
+
wraperFactory(t, o) {
|
|
1282
1282
|
function n(s, l) {
|
|
1283
1283
|
s && typeof s == "object" && Object.isExtensible(s) && !Object.getOwnPropertyDescriptor(s, Symbol.for("mf_module_id")) && Object.defineProperty(s, Symbol.for("mf_module_id"), {
|
|
1284
1284
|
value: l,
|
|
@@ -1287,14 +1287,14 @@ let Module = class {
|
|
|
1287
1287
|
}
|
|
1288
1288
|
return t instanceof Promise ? async () => {
|
|
1289
1289
|
const s = await t();
|
|
1290
|
-
return n(s,
|
|
1290
|
+
return n(s, o), s;
|
|
1291
1291
|
} : () => {
|
|
1292
1292
|
const s = t();
|
|
1293
|
-
return n(s,
|
|
1293
|
+
return n(s, o), s;
|
|
1294
1294
|
};
|
|
1295
1295
|
}
|
|
1296
|
-
constructor({ remoteInfo: t, host:
|
|
1297
|
-
this.inited = !1, this.lib = void 0, this.remoteInfo = t, this.host =
|
|
1296
|
+
constructor({ remoteInfo: t, host: o }) {
|
|
1297
|
+
this.inited = !1, this.lib = void 0, this.remoteInfo = t, this.host = o;
|
|
1298
1298
|
}
|
|
1299
1299
|
};
|
|
1300
1300
|
class SyncHook {
|
|
@@ -1302,16 +1302,16 @@ class SyncHook {
|
|
|
1302
1302
|
typeof t == "function" && this.listeners.add(t);
|
|
1303
1303
|
}
|
|
1304
1304
|
once(t) {
|
|
1305
|
-
const
|
|
1305
|
+
const o = this;
|
|
1306
1306
|
this.on(function n(...s) {
|
|
1307
|
-
return
|
|
1307
|
+
return o.remove(n), t.apply(null, s);
|
|
1308
1308
|
});
|
|
1309
1309
|
}
|
|
1310
1310
|
emit(...t) {
|
|
1311
|
-
let
|
|
1311
|
+
let o;
|
|
1312
1312
|
return this.listeners.size > 0 && this.listeners.forEach((n) => {
|
|
1313
|
-
|
|
1314
|
-
}),
|
|
1313
|
+
o = n(...t);
|
|
1314
|
+
}), o;
|
|
1315
1315
|
}
|
|
1316
1316
|
remove(t) {
|
|
1317
1317
|
this.listeners.delete(t);
|
|
@@ -1325,22 +1325,22 @@ class SyncHook {
|
|
|
1325
1325
|
}
|
|
1326
1326
|
class AsyncHook extends SyncHook {
|
|
1327
1327
|
emit(...t) {
|
|
1328
|
-
let
|
|
1328
|
+
let o;
|
|
1329
1329
|
const n = Array.from(this.listeners);
|
|
1330
1330
|
if (n.length > 0) {
|
|
1331
1331
|
let s = 0;
|
|
1332
1332
|
const l = (a) => a === !1 ? !1 : s < n.length ? Promise.resolve(n[s++].apply(null, t)).then(l) : a;
|
|
1333
|
-
|
|
1333
|
+
o = l();
|
|
1334
1334
|
}
|
|
1335
|
-
return Promise.resolve(
|
|
1335
|
+
return Promise.resolve(o);
|
|
1336
1336
|
}
|
|
1337
1337
|
}
|
|
1338
|
-
function checkReturnData(
|
|
1338
|
+
function checkReturnData(r, t) {
|
|
1339
1339
|
if (!isObject(t))
|
|
1340
1340
|
return !1;
|
|
1341
|
-
if (
|
|
1342
|
-
for (const
|
|
1343
|
-
if (!(
|
|
1341
|
+
if (r !== t) {
|
|
1342
|
+
for (const o in r)
|
|
1343
|
+
if (!(o in t))
|
|
1344
1344
|
return !1;
|
|
1345
1345
|
}
|
|
1346
1346
|
return !0;
|
|
@@ -1348,9 +1348,9 @@ function checkReturnData(o, t) {
|
|
|
1348
1348
|
class SyncWaterfallHook extends SyncHook {
|
|
1349
1349
|
emit(t) {
|
|
1350
1350
|
isObject(t) || error(`The data for the "${this.type}" hook should be an object.`);
|
|
1351
|
-
for (const
|
|
1351
|
+
for (const o of this.listeners)
|
|
1352
1352
|
try {
|
|
1353
|
-
const n =
|
|
1353
|
+
const n = o(t);
|
|
1354
1354
|
if (checkReturnData(t, n))
|
|
1355
1355
|
t = n;
|
|
1356
1356
|
else {
|
|
@@ -1369,14 +1369,14 @@ class SyncWaterfallHook extends SyncHook {
|
|
|
1369
1369
|
class AsyncWaterfallHook extends SyncHook {
|
|
1370
1370
|
emit(t) {
|
|
1371
1371
|
isObject(t) || error(`The response data for the "${this.type}" hook must be an object.`);
|
|
1372
|
-
const
|
|
1373
|
-
if (
|
|
1372
|
+
const o = Array.from(this.listeners);
|
|
1373
|
+
if (o.length > 0) {
|
|
1374
1374
|
let n = 0;
|
|
1375
1375
|
const s = (a) => (warn(a), this.onerror(a), t), l = (a) => {
|
|
1376
1376
|
if (checkReturnData(t, a)) {
|
|
1377
|
-
if (t = a, n <
|
|
1377
|
+
if (t = a, n < o.length)
|
|
1378
1378
|
try {
|
|
1379
|
-
return Promise.resolve(
|
|
1379
|
+
return Promise.resolve(o[n++](t)).then(l, s);
|
|
1380
1380
|
} catch (i) {
|
|
1381
1381
|
return s(i);
|
|
1382
1382
|
}
|
|
@@ -1395,59 +1395,59 @@ class AsyncWaterfallHook extends SyncHook {
|
|
|
1395
1395
|
class PluginSystem {
|
|
1396
1396
|
applyPlugin(t) {
|
|
1397
1397
|
assert(isPlainObject(t), "Plugin configuration is invalid.");
|
|
1398
|
-
const
|
|
1399
|
-
assert(
|
|
1398
|
+
const o = t.name;
|
|
1399
|
+
assert(o, "A name must be provided by the plugin."), this.registerPlugins[o] || (this.registerPlugins[o] = t, Object.keys(this.lifecycle).forEach((n) => {
|
|
1400
1400
|
const s = t[n];
|
|
1401
1401
|
s && this.lifecycle[n].on(s);
|
|
1402
1402
|
}));
|
|
1403
1403
|
}
|
|
1404
1404
|
removePlugin(t) {
|
|
1405
1405
|
assert(t, "A name is required.");
|
|
1406
|
-
const
|
|
1407
|
-
assert(
|
|
1408
|
-
n !== "name" && this.lifecycle[n].remove(
|
|
1406
|
+
const o = this.registerPlugins[t];
|
|
1407
|
+
assert(o, `The plugin "${t}" is not registered.`), Object.keys(o).forEach((n) => {
|
|
1408
|
+
n !== "name" && this.lifecycle[n].remove(o[n]);
|
|
1409
1409
|
});
|
|
1410
1410
|
}
|
|
1411
1411
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
1412
|
-
inherit({ lifecycle: t, registerPlugins:
|
|
1412
|
+
inherit({ lifecycle: t, registerPlugins: o }) {
|
|
1413
1413
|
Object.keys(t).forEach((n) => {
|
|
1414
1414
|
assert(!this.lifecycle[n], `The hook "${n}" has a conflict and cannot be inherited.`), this.lifecycle[n] = t[n];
|
|
1415
|
-
}), Object.keys(
|
|
1416
|
-
assert(!this.registerPlugins[n], `The plugin "${n}" has a conflict and cannot be inherited.`), this.applyPlugin(
|
|
1415
|
+
}), Object.keys(o).forEach((n) => {
|
|
1416
|
+
assert(!this.registerPlugins[n], `The plugin "${n}" has a conflict and cannot be inherited.`), this.applyPlugin(o[n]);
|
|
1417
1417
|
});
|
|
1418
1418
|
}
|
|
1419
1419
|
constructor(t) {
|
|
1420
1420
|
this.registerPlugins = {}, this.lifecycle = t, this.lifecycleKeys = Object.keys(t);
|
|
1421
1421
|
}
|
|
1422
1422
|
}
|
|
1423
|
-
function defaultPreloadArgs(
|
|
1423
|
+
function defaultPreloadArgs(r) {
|
|
1424
1424
|
return _extends$1({
|
|
1425
1425
|
resourceCategory: "sync",
|
|
1426
1426
|
share: !0,
|
|
1427
1427
|
depsRemote: !0,
|
|
1428
1428
|
prefetchInterface: !1
|
|
1429
|
-
},
|
|
1429
|
+
}, r);
|
|
1430
1430
|
}
|
|
1431
|
-
function formatPreloadArgs(
|
|
1432
|
-
return t.map((
|
|
1433
|
-
const n = matchRemote(
|
|
1434
|
-
return assert(n, `Unable to preload ${
|
|
1431
|
+
function formatPreloadArgs(r, t) {
|
|
1432
|
+
return t.map((o) => {
|
|
1433
|
+
const n = matchRemote(r, o.nameOrAlias);
|
|
1434
|
+
return assert(n, `Unable to preload ${o.nameOrAlias} as it is not included in ${!n && safeToString({
|
|
1435
1435
|
remoteInfo: n,
|
|
1436
|
-
remotes:
|
|
1436
|
+
remotes: r
|
|
1437
1437
|
})}`), {
|
|
1438
1438
|
remote: n,
|
|
1439
|
-
preloadConfig: defaultPreloadArgs(
|
|
1439
|
+
preloadConfig: defaultPreloadArgs(o)
|
|
1440
1440
|
};
|
|
1441
1441
|
});
|
|
1442
1442
|
}
|
|
1443
|
-
function normalizePreloadExposes(
|
|
1444
|
-
return
|
|
1443
|
+
function normalizePreloadExposes(r) {
|
|
1444
|
+
return r ? r.map((t) => t === "." ? t : t.startsWith("./") ? t.replace("./", "") : t) : [];
|
|
1445
1445
|
}
|
|
1446
|
-
function preloadAssets(
|
|
1447
|
-
const { cssAssets: s, jsAssetsWithoutEntry: l, entryAssets: a } =
|
|
1446
|
+
function preloadAssets(r, t, o, n = !0) {
|
|
1447
|
+
const { cssAssets: s, jsAssetsWithoutEntry: l, entryAssets: a } = o;
|
|
1448
1448
|
if (t.options.inBrowser) {
|
|
1449
1449
|
if (a.forEach((i) => {
|
|
1450
|
-
const { moduleInfo: c } = i, u = t.moduleCache.get(
|
|
1450
|
+
const { moduleInfo: c } = i, u = t.moduleCache.get(r.name);
|
|
1451
1451
|
getRemoteEntry(u ? {
|
|
1452
1452
|
origin: t,
|
|
1453
1453
|
remoteInfo: c,
|
|
@@ -1528,7 +1528,7 @@ function preloadAssets(o, t, r, n = !0) {
|
|
|
1528
1528
|
} else {
|
|
1529
1529
|
const i = {
|
|
1530
1530
|
fetchpriority: "high",
|
|
1531
|
-
type: (
|
|
1531
|
+
type: (r == null ? void 0 : r.type) === "module" ? "module" : "text/javascript"
|
|
1532
1532
|
};
|
|
1533
1533
|
l.forEach((c) => {
|
|
1534
1534
|
const { script: u, needAttach: d } = createScript({
|
|
@@ -1551,24 +1551,24 @@ function preloadAssets(o, t, r, n = !0) {
|
|
|
1551
1551
|
}
|
|
1552
1552
|
}
|
|
1553
1553
|
}
|
|
1554
|
-
function assignRemoteInfo(
|
|
1555
|
-
const
|
|
1556
|
-
|
|
1557
|
-
let n = getResourceUrl(t,
|
|
1558
|
-
!isBrowserEnv() && !n.startsWith("http") && (n = `https:${n}`),
|
|
1554
|
+
function assignRemoteInfo(r, t) {
|
|
1555
|
+
const o = getRemoteEntryInfoFromSnapshot(t);
|
|
1556
|
+
o.url || error(`The attribute remoteEntry of ${r.name} must not be undefined.`);
|
|
1557
|
+
let n = getResourceUrl(t, o.url);
|
|
1558
|
+
!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;
|
|
1559
1559
|
}
|
|
1560
1560
|
function snapshotPlugin() {
|
|
1561
1561
|
return {
|
|
1562
1562
|
name: "snapshot-plugin",
|
|
1563
|
-
async afterResolve(
|
|
1564
|
-
const { remote: t, pkgNameOrAlias:
|
|
1563
|
+
async afterResolve(r) {
|
|
1564
|
+
const { remote: t, pkgNameOrAlias: o, expose: n, origin: s, remoteInfo: l } = r;
|
|
1565
1565
|
if (!isRemoteInfoWithEntry(t) || !isPureRemoteEntry(t)) {
|
|
1566
1566
|
const { remoteSnapshot: a, globalSnapshot: i } = await s.snapshotHandler.loadRemoteSnapshotInfo(t);
|
|
1567
1567
|
assignRemoteInfo(l, a);
|
|
1568
1568
|
const c = {
|
|
1569
1569
|
remote: t,
|
|
1570
1570
|
preloadConfig: {
|
|
1571
|
-
nameOrAlias:
|
|
1571
|
+
nameOrAlias: o,
|
|
1572
1572
|
exposes: [
|
|
1573
1573
|
n
|
|
1574
1574
|
],
|
|
@@ -1584,16 +1584,16 @@ function snapshotPlugin() {
|
|
|
1584
1584
|
remoteSnapshot: a,
|
|
1585
1585
|
globalSnapshot: i
|
|
1586
1586
|
});
|
|
1587
|
-
return u && preloadAssets(l, s, u, !1), _extends$1({},
|
|
1587
|
+
return u && preloadAssets(l, s, u, !1), _extends$1({}, r, {
|
|
1588
1588
|
remoteSnapshot: a
|
|
1589
1589
|
});
|
|
1590
1590
|
}
|
|
1591
|
-
return
|
|
1591
|
+
return r;
|
|
1592
1592
|
}
|
|
1593
1593
|
};
|
|
1594
1594
|
}
|
|
1595
|
-
function splitId(
|
|
1596
|
-
const t =
|
|
1595
|
+
function splitId(r) {
|
|
1596
|
+
const t = r.split(":");
|
|
1597
1597
|
return t.length === 1 ? {
|
|
1598
1598
|
name: t[0],
|
|
1599
1599
|
version: void 0
|
|
@@ -1605,30 +1605,30 @@ function splitId(o) {
|
|
|
1605
1605
|
version: t[2]
|
|
1606
1606
|
};
|
|
1607
1607
|
}
|
|
1608
|
-
function traverseModuleInfo(
|
|
1609
|
-
const a = getFMId(t), { value: i } = getInfoWithoutType(
|
|
1610
|
-
if (c && !isManifestProvider(c) && (
|
|
1608
|
+
function traverseModuleInfo(r, t, o, n, s = {}, l) {
|
|
1609
|
+
const a = getFMId(t), { value: i } = getInfoWithoutType(r, a), c = l || i;
|
|
1610
|
+
if (c && !isManifestProvider(c) && (o(c, t, n), c.remotesInfo)) {
|
|
1611
1611
|
const u = Object.keys(c.remotesInfo);
|
|
1612
1612
|
for (const d of u) {
|
|
1613
1613
|
if (s[d])
|
|
1614
1614
|
continue;
|
|
1615
1615
|
s[d] = !0;
|
|
1616
1616
|
const p = splitId(d), m = c.remotesInfo[d];
|
|
1617
|
-
traverseModuleInfo(
|
|
1617
|
+
traverseModuleInfo(r, {
|
|
1618
1618
|
name: p.name,
|
|
1619
1619
|
version: m.matchedVersion
|
|
1620
|
-
},
|
|
1620
|
+
}, o, !1, s, void 0);
|
|
1621
1621
|
}
|
|
1622
1622
|
}
|
|
1623
1623
|
}
|
|
1624
|
-
function generatePreloadAssets(
|
|
1625
|
-
const l = [], a = [], i = [], c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), { options: d } =
|
|
1626
|
-
if (traverseModuleInfo(n,
|
|
1624
|
+
function generatePreloadAssets(r, t, o, n, s) {
|
|
1625
|
+
const l = [], a = [], i = [], c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), { options: d } = r, { preloadConfig: p } = t, { depsRemote: m } = p;
|
|
1626
|
+
if (traverseModuleInfo(n, o, (g, E, I) => {
|
|
1627
1627
|
let v;
|
|
1628
1628
|
if (I)
|
|
1629
1629
|
v = p;
|
|
1630
1630
|
else if (Array.isArray(m)) {
|
|
1631
|
-
const T = m.find((
|
|
1631
|
+
const T = m.find((w) => w.nameOrAlias === E.name || w.nameOrAlias === E.alias);
|
|
1632
1632
|
if (!T)
|
|
1633
1633
|
return;
|
|
1634
1634
|
v = defaultPreloadArgs(T);
|
|
@@ -1652,30 +1652,30 @@ function generatePreloadAssets(o, t, r, n, s) {
|
|
|
1652
1652
|
let b = "modules" in g ? g.modules : [];
|
|
1653
1653
|
const $ = normalizePreloadExposes(v.exposes);
|
|
1654
1654
|
if ($.length && "modules" in g) {
|
|
1655
|
-
var
|
|
1656
|
-
b = g == null || (
|
|
1655
|
+
var A;
|
|
1656
|
+
b = g == null || (A = g.modules) == null ? void 0 : A.reduce((T, w) => (($ == null ? void 0 : $.indexOf(w.moduleName)) !== -1 && T.push(w), T), []);
|
|
1657
1657
|
}
|
|
1658
1658
|
function O(T) {
|
|
1659
|
-
const
|
|
1660
|
-
return v.filter ?
|
|
1659
|
+
const w = T.map((P) => getResourceUrl(g, P));
|
|
1660
|
+
return v.filter ? w.filter(v.filter) : w;
|
|
1661
1661
|
}
|
|
1662
1662
|
if (b) {
|
|
1663
1663
|
const T = b.length;
|
|
1664
|
-
for (let
|
|
1665
|
-
const P = b[
|
|
1666
|
-
|
|
1664
|
+
for (let w = 0; w < T; w++) {
|
|
1665
|
+
const P = b[w], M = `${E.name}/${P.moduleName}`;
|
|
1666
|
+
r.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({
|
|
1667
1667
|
id: P.moduleName === "." ? E.name : M,
|
|
1668
1668
|
name: E.name,
|
|
1669
1669
|
remoteSnapshot: g,
|
|
1670
1670
|
preloadConfig: v,
|
|
1671
1671
|
remote: E,
|
|
1672
|
-
origin:
|
|
1672
|
+
origin: r
|
|
1673
1673
|
}), !getPreloaded(M) && (v.resourceCategory === "all" ? (l.push(...O(P.assets.css.async)), l.push(...O(P.assets.css.sync)), a.push(...O(P.assets.js.async)), a.push(...O(P.assets.js.sync))) : (v.resourceCategory = "sync") && (l.push(...O(P.assets.css.sync)), a.push(...O(P.assets.js.sync))), setPreloaded(M));
|
|
1674
1674
|
}
|
|
1675
1675
|
}
|
|
1676
1676
|
}, !0, {}, s), s.shared) {
|
|
1677
1677
|
const g = (E, I) => {
|
|
1678
|
-
const v = getRegisteredShare(
|
|
1678
|
+
const v = getRegisteredShare(r.shareScopeMap, I.sharedName, E, r.sharedHandler.hooks.lifecycle.resolveShare);
|
|
1679
1679
|
v && typeof v.lib == "function" && (I.assets.js.sync.forEach((S) => {
|
|
1680
1680
|
c.add(S);
|
|
1681
1681
|
}), I.assets.css.sync.forEach((S) => {
|
|
@@ -1705,8 +1705,8 @@ function generatePreloadAssets(o, t, r, n, s) {
|
|
|
1705
1705
|
const generatePreloadAssetsPlugin = function() {
|
|
1706
1706
|
return {
|
|
1707
1707
|
name: "generate-preload-assets-plugin",
|
|
1708
|
-
async generatePreloadAssets(
|
|
1709
|
-
const { origin: t, preloadOptions:
|
|
1708
|
+
async generatePreloadAssets(r) {
|
|
1709
|
+
const { origin: t, preloadOptions: o, remoteInfo: n, remote: s, globalSnapshot: l, remoteSnapshot: a } = r;
|
|
1710
1710
|
return isRemoteInfoWithEntry(s) && isPureRemoteEntry(s) ? {
|
|
1711
1711
|
cssAssets: [],
|
|
1712
1712
|
jsAssetsWithoutEntry: [],
|
|
@@ -1723,35 +1723,35 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1723
1723
|
}
|
|
1724
1724
|
}
|
|
1725
1725
|
]
|
|
1726
|
-
} : (assignRemoteInfo(n, a), generatePreloadAssets(t,
|
|
1726
|
+
} : (assignRemoteInfo(n, a), generatePreloadAssets(t, o, n, l, a));
|
|
1727
1727
|
}
|
|
1728
1728
|
};
|
|
1729
1729
|
};
|
|
1730
|
-
function getGlobalRemoteInfo(
|
|
1731
|
-
const
|
|
1730
|
+
function getGlobalRemoteInfo(r, t) {
|
|
1731
|
+
const o = getGlobalSnapshotInfoByModuleInfo({
|
|
1732
1732
|
name: t.options.name,
|
|
1733
1733
|
version: t.options.version
|
|
1734
|
-
}), n =
|
|
1734
|
+
}), n = o && "remotesInfo" in o && o.remotesInfo && getInfoWithoutType(o.remotesInfo, r.name).value;
|
|
1735
1735
|
return n && n.matchedVersion ? {
|
|
1736
|
-
hostGlobalSnapshot:
|
|
1736
|
+
hostGlobalSnapshot: o,
|
|
1737
1737
|
globalSnapshot: getGlobalSnapshot(),
|
|
1738
1738
|
remoteSnapshot: getGlobalSnapshotInfoByModuleInfo({
|
|
1739
|
-
name:
|
|
1739
|
+
name: r.name,
|
|
1740
1740
|
version: n.matchedVersion
|
|
1741
1741
|
})
|
|
1742
1742
|
} : {
|
|
1743
1743
|
hostGlobalSnapshot: void 0,
|
|
1744
1744
|
globalSnapshot: getGlobalSnapshot(),
|
|
1745
1745
|
remoteSnapshot: getGlobalSnapshotInfoByModuleInfo({
|
|
1746
|
-
name:
|
|
1747
|
-
version: "version" in
|
|
1746
|
+
name: r.name,
|
|
1747
|
+
version: "version" in r ? r.version : void 0
|
|
1748
1748
|
})
|
|
1749
1749
|
};
|
|
1750
1750
|
}
|
|
1751
1751
|
class SnapshotHandler {
|
|
1752
1752
|
async loadSnapshot(t) {
|
|
1753
|
-
const { options:
|
|
1754
|
-
options:
|
|
1753
|
+
const { options: o } = this.HostInstance, { hostGlobalSnapshot: n, remoteSnapshot: s, globalSnapshot: l } = this.getGlobalRemoteInfo(t), { remoteSnapshot: a, globalSnapshot: i } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1754
|
+
options: o,
|
|
1755
1755
|
moduleInfo: t,
|
|
1756
1756
|
hostGlobalSnapshot: n,
|
|
1757
1757
|
remoteSnapshot: s,
|
|
@@ -1764,9 +1764,9 @@ class SnapshotHandler {
|
|
|
1764
1764
|
}
|
|
1765
1765
|
// eslint-disable-next-line max-lines-per-function
|
|
1766
1766
|
async loadRemoteSnapshotInfo(t) {
|
|
1767
|
-
const { options:
|
|
1767
|
+
const { options: o } = this.HostInstance;
|
|
1768
1768
|
await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({
|
|
1769
|
-
options:
|
|
1769
|
+
options: o,
|
|
1770
1770
|
moduleInfo: t
|
|
1771
1771
|
});
|
|
1772
1772
|
let n = getGlobalSnapshotInfoByModuleInfo({
|
|
@@ -1785,7 +1785,7 @@ class SnapshotHandler {
|
|
|
1785
1785
|
}
|
|
1786
1786
|
}));
|
|
1787
1787
|
const { hostGlobalSnapshot: s, remoteSnapshot: l, globalSnapshot: a } = this.getGlobalRemoteInfo(t), { remoteSnapshot: i, globalSnapshot: c } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1788
|
-
options:
|
|
1788
|
+
options: o,
|
|
1789
1789
|
moduleInfo: t,
|
|
1790
1790
|
hostGlobalSnapshot: s,
|
|
1791
1791
|
remoteSnapshot: l,
|
|
@@ -1824,7 +1824,7 @@ class SnapshotHandler {
|
|
|
1824
1824
|
globalSnapshot: JSON.stringify(c)
|
|
1825
1825
|
}));
|
|
1826
1826
|
return await this.hooks.lifecycle.afterLoadSnapshot.emit({
|
|
1827
|
-
options:
|
|
1827
|
+
options: o,
|
|
1828
1828
|
moduleInfo: t,
|
|
1829
1829
|
remoteSnapshot: u
|
|
1830
1830
|
}), {
|
|
@@ -1835,7 +1835,7 @@ class SnapshotHandler {
|
|
|
1835
1835
|
getGlobalRemoteInfo(t) {
|
|
1836
1836
|
return getGlobalRemoteInfo(t, this.HostInstance);
|
|
1837
1837
|
}
|
|
1838
|
-
async getManifestJson(t,
|
|
1838
|
+
async getManifestJson(t, o, n) {
|
|
1839
1839
|
const s = async () => {
|
|
1840
1840
|
let a = this.manifestCache.get(t);
|
|
1841
1841
|
if (a)
|
|
@@ -1846,7 +1846,7 @@ class SnapshotHandler {
|
|
|
1846
1846
|
} catch (i) {
|
|
1847
1847
|
delete this.manifestLoading[t], error(getShortErrorMsg(RUNTIME_003, runtimeDescMap, {
|
|
1848
1848
|
manifestUrl: t,
|
|
1849
|
-
moduleName:
|
|
1849
|
+
moduleName: o.name
|
|
1850
1850
|
}, `${i}`));
|
|
1851
1851
|
}
|
|
1852
1852
|
}, l = async () => {
|
|
@@ -1854,7 +1854,7 @@ class SnapshotHandler {
|
|
|
1854
1854
|
version: t
|
|
1855
1855
|
}), { remoteSnapshot: c } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1856
1856
|
options: this.HostInstance.options,
|
|
1857
|
-
moduleInfo:
|
|
1857
|
+
moduleInfo: o,
|
|
1858
1858
|
manifestJson: a,
|
|
1859
1859
|
remoteSnapshot: i,
|
|
1860
1860
|
manifestUrl: t,
|
|
@@ -1875,8 +1875,8 @@ class SnapshotHandler {
|
|
|
1875
1875
|
}
|
|
1876
1876
|
class SharedHandler {
|
|
1877
1877
|
// register shared in shareScopeMap
|
|
1878
|
-
registerShared(t,
|
|
1879
|
-
const { shareInfos: n, shared: s } = formatShareConfigs(t,
|
|
1878
|
+
registerShared(t, o) {
|
|
1879
|
+
const { shareInfos: n, shared: s } = formatShareConfigs(t, o);
|
|
1880
1880
|
return Object.keys(n).forEach((a) => {
|
|
1881
1881
|
n[a].forEach((c) => {
|
|
1882
1882
|
!getRegisteredShare(this.shareScopeMap, a, c, this.hooks.lifecycle.resolveShare) && c && c.lib && this.setShared({
|
|
@@ -1885,7 +1885,7 @@ class SharedHandler {
|
|
|
1885
1885
|
get: c.get,
|
|
1886
1886
|
loaded: !0,
|
|
1887
1887
|
shared: c,
|
|
1888
|
-
from:
|
|
1888
|
+
from: o.name
|
|
1889
1889
|
});
|
|
1890
1890
|
});
|
|
1891
1891
|
}), {
|
|
@@ -1893,10 +1893,10 @@ class SharedHandler {
|
|
|
1893
1893
|
shared: s
|
|
1894
1894
|
};
|
|
1895
1895
|
}
|
|
1896
|
-
async loadShare(t,
|
|
1896
|
+
async loadShare(t, o) {
|
|
1897
1897
|
const { host: n } = this, s = getTargetSharedOptions({
|
|
1898
1898
|
pkgName: t,
|
|
1899
|
-
extraOptions:
|
|
1899
|
+
extraOptions: o,
|
|
1900
1900
|
shareInfos: n.options.shared
|
|
1901
1901
|
});
|
|
1902
1902
|
s != null && s.scope && await Promise.all(s.scope.map(async (u) => {
|
|
@@ -1935,7 +1935,7 @@ class SharedHandler {
|
|
|
1935
1935
|
loading: d
|
|
1936
1936
|
}), d;
|
|
1937
1937
|
} else {
|
|
1938
|
-
if (
|
|
1938
|
+
if (o != null && o.customShareInfo)
|
|
1939
1939
|
return !1;
|
|
1940
1940
|
const d = (async () => {
|
|
1941
1941
|
const p = await a.get();
|
|
@@ -1959,9 +1959,9 @@ class SharedHandler {
|
|
|
1959
1959
|
* If the share scope does not exist, it creates one.
|
|
1960
1960
|
*/
|
|
1961
1961
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
1962
|
-
initializeSharing(t = DEFAULT_SCOPE,
|
|
1963
|
-
const { host: n } = this, s =
|
|
1964
|
-
let a =
|
|
1962
|
+
initializeSharing(t = DEFAULT_SCOPE, o) {
|
|
1963
|
+
const { host: n } = this, s = o == null ? void 0 : o.from, l = o == null ? void 0 : o.strategy;
|
|
1964
|
+
let a = o == null ? void 0 : o.initScope;
|
|
1965
1965
|
const i = [];
|
|
1966
1966
|
if (s !== "build") {
|
|
1967
1967
|
const { initTokens: _ } = this;
|
|
@@ -2013,10 +2013,10 @@ class SharedHandler {
|
|
|
2013
2013
|
// 1. If the loaded shared already exists globally, then it will be reused
|
|
2014
2014
|
// 2. If lib exists in local shared, it will be used directly
|
|
2015
2015
|
// 3. If the local get returns something other than Promise, then it will be used directly
|
|
2016
|
-
loadShareSync(t,
|
|
2016
|
+
loadShareSync(t, o) {
|
|
2017
2017
|
const { host: n } = this, s = getTargetSharedOptions({
|
|
2018
2018
|
pkgName: t,
|
|
2019
|
-
extraOptions:
|
|
2019
|
+
extraOptions: o,
|
|
2020
2020
|
shareInfos: n.options.shared
|
|
2021
2021
|
});
|
|
2022
2022
|
s != null && s.scope && s.scope.forEach((i) => {
|
|
@@ -2047,7 +2047,7 @@ class SharedHandler {
|
|
|
2047
2047
|
if (s.get) {
|
|
2048
2048
|
const i = s.get();
|
|
2049
2049
|
if (i instanceof Promise) {
|
|
2050
|
-
const c = (
|
|
2050
|
+
const c = (o == null ? void 0 : o.from) === "build" ? RUNTIME_005 : RUNTIME_006;
|
|
2051
2051
|
throw new Error(getShortErrorMsg(c, runtimeDescMap, {
|
|
2052
2052
|
hostName: n.options.name,
|
|
2053
2053
|
sharedPkgName: t
|
|
@@ -2066,18 +2066,18 @@ class SharedHandler {
|
|
|
2066
2066
|
sharedPkgName: t
|
|
2067
2067
|
}));
|
|
2068
2068
|
}
|
|
2069
|
-
initShareScopeMap(t,
|
|
2069
|
+
initShareScopeMap(t, o, n = {}) {
|
|
2070
2070
|
const { host: s } = this;
|
|
2071
|
-
this.shareScopeMap[t] =
|
|
2072
|
-
shareScope:
|
|
2071
|
+
this.shareScopeMap[t] = o, this.hooks.lifecycle.initContainerShareScopeMap.emit({
|
|
2072
|
+
shareScope: o,
|
|
2073
2073
|
options: s.options,
|
|
2074
2074
|
origin: s,
|
|
2075
2075
|
scopeName: t,
|
|
2076
2076
|
hostShareScopeMap: n.hostShareScopeMap
|
|
2077
2077
|
});
|
|
2078
2078
|
}
|
|
2079
|
-
setShared({ pkgName: t, shared:
|
|
2080
|
-
const { version: c, scope: u = "default" } =
|
|
2079
|
+
setShared({ pkgName: t, shared: o, from: n, lib: s, loading: l, loaded: a, get: i }) {
|
|
2080
|
+
const { version: c, scope: u = "default" } = o, d = _object_without_properties_loose(o, [
|
|
2081
2081
|
"version",
|
|
2082
2082
|
"scope"
|
|
2083
2083
|
]);
|
|
@@ -2102,8 +2102,8 @@ class SharedHandler {
|
|
|
2102
2102
|
});
|
|
2103
2103
|
}
|
|
2104
2104
|
_setGlobalShareScopeMap(t) {
|
|
2105
|
-
const
|
|
2106
|
-
n && !
|
|
2105
|
+
const o = getGlobalShareScope(), n = t.id || t.name;
|
|
2106
|
+
n && !o[n] && (o[n] = this.shareScopeMap);
|
|
2107
2107
|
}
|
|
2108
2108
|
constructor(t) {
|
|
2109
2109
|
this.hooks = new PluginSystem({
|
|
@@ -2118,13 +2118,13 @@ class SharedHandler {
|
|
|
2118
2118
|
}
|
|
2119
2119
|
}
|
|
2120
2120
|
class RemoteHandler {
|
|
2121
|
-
formatAndRegisterRemote(t,
|
|
2122
|
-
return (
|
|
2121
|
+
formatAndRegisterRemote(t, o) {
|
|
2122
|
+
return (o.remotes || []).reduce((s, l) => (this.registerRemote(l, s, {
|
|
2123
2123
|
force: !1
|
|
2124
2124
|
}), s), t.remotes);
|
|
2125
2125
|
}
|
|
2126
|
-
setIdToRemoteMap(t,
|
|
2127
|
-
const { remote: n, expose: s } =
|
|
2126
|
+
setIdToRemoteMap(t, o) {
|
|
2127
|
+
const { remote: n, expose: s } = o, { name: l, alias: a } = n;
|
|
2128
2128
|
if (this.idToRemoteMap[t] = {
|
|
2129
2129
|
name: n.name,
|
|
2130
2130
|
expose: s
|
|
@@ -2146,14 +2146,14 @@ class RemoteHandler {
|
|
|
2146
2146
|
}
|
|
2147
2147
|
// eslint-disable-next-line max-lines-per-function
|
|
2148
2148
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
2149
|
-
async loadRemote(t,
|
|
2149
|
+
async loadRemote(t, o) {
|
|
2150
2150
|
const { host: n } = this;
|
|
2151
2151
|
try {
|
|
2152
|
-
const { loadFactory: s = !0 } =
|
|
2152
|
+
const { loadFactory: s = !0 } = o || {
|
|
2153
2153
|
loadFactory: !0
|
|
2154
2154
|
}, { module: l, moduleOptions: a, remoteMatchInfo: i } = await this.getRemoteModuleAndOptions({
|
|
2155
2155
|
id: t
|
|
2156
|
-
}), { pkgNameOrAlias: c, remote: u, expose: d, id: p, remoteSnapshot: m } = i, y = await l.get(p, d,
|
|
2156
|
+
}), { 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({
|
|
2157
2157
|
id: p,
|
|
2158
2158
|
pkgNameOrAlias: c,
|
|
2159
2159
|
expose: d,
|
|
@@ -2166,7 +2166,7 @@ class RemoteHandler {
|
|
|
2166
2166
|
});
|
|
2167
2167
|
return this.setIdToRemoteMap(t, i), typeof _ == "function" ? _ : y;
|
|
2168
2168
|
} catch (s) {
|
|
2169
|
-
const { from: l = "runtime" } =
|
|
2169
|
+
const { from: l = "runtime" } = o || {
|
|
2170
2170
|
from: "runtime"
|
|
2171
2171
|
}, a = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2172
2172
|
id: t,
|
|
@@ -2182,81 +2182,81 @@ class RemoteHandler {
|
|
|
2182
2182
|
}
|
|
2183
2183
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
2184
2184
|
async preloadRemote(t) {
|
|
2185
|
-
const { host:
|
|
2185
|
+
const { host: o } = this;
|
|
2186
2186
|
await this.hooks.lifecycle.beforePreloadRemote.emit({
|
|
2187
2187
|
preloadOps: t,
|
|
2188
|
-
options:
|
|
2189
|
-
origin:
|
|
2188
|
+
options: o.options,
|
|
2189
|
+
origin: o
|
|
2190
2190
|
});
|
|
2191
|
-
const n = formatPreloadArgs(
|
|
2191
|
+
const n = formatPreloadArgs(o.options.remotes, t);
|
|
2192
2192
|
await Promise.all(n.map(async (s) => {
|
|
2193
|
-
const { remote: l } = s, a = getRemoteInfo(l), { globalSnapshot: i, remoteSnapshot: c } = await
|
|
2194
|
-
origin:
|
|
2193
|
+
const { remote: l } = s, a = getRemoteInfo(l), { globalSnapshot: i, remoteSnapshot: c } = await o.snapshotHandler.loadRemoteSnapshotInfo(l), u = await this.hooks.lifecycle.generatePreloadAssets.emit({
|
|
2194
|
+
origin: o,
|
|
2195
2195
|
preloadOptions: s,
|
|
2196
2196
|
remote: l,
|
|
2197
2197
|
remoteInfo: a,
|
|
2198
2198
|
globalSnapshot: i,
|
|
2199
2199
|
remoteSnapshot: c
|
|
2200
2200
|
});
|
|
2201
|
-
u && preloadAssets(a,
|
|
2201
|
+
u && preloadAssets(a, o, u);
|
|
2202
2202
|
}));
|
|
2203
2203
|
}
|
|
2204
|
-
registerRemotes(t,
|
|
2204
|
+
registerRemotes(t, o) {
|
|
2205
2205
|
const { host: n } = this;
|
|
2206
2206
|
t.forEach((s) => {
|
|
2207
2207
|
this.registerRemote(s, n.options.remotes, {
|
|
2208
|
-
force:
|
|
2208
|
+
force: o == null ? void 0 : o.force
|
|
2209
2209
|
});
|
|
2210
2210
|
});
|
|
2211
2211
|
}
|
|
2212
2212
|
async getRemoteModuleAndOptions(t) {
|
|
2213
|
-
const { host:
|
|
2213
|
+
const { host: o } = this, { id: n } = t;
|
|
2214
2214
|
let s;
|
|
2215
2215
|
try {
|
|
2216
2216
|
s = await this.hooks.lifecycle.beforeRequest.emit({
|
|
2217
2217
|
id: n,
|
|
2218
|
-
options:
|
|
2219
|
-
origin:
|
|
2218
|
+
options: o.options,
|
|
2219
|
+
origin: o
|
|
2220
2220
|
});
|
|
2221
2221
|
} catch (_) {
|
|
2222
2222
|
if (s = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2223
2223
|
id: n,
|
|
2224
|
-
options:
|
|
2225
|
-
origin:
|
|
2224
|
+
options: o.options,
|
|
2225
|
+
origin: o,
|
|
2226
2226
|
from: "runtime",
|
|
2227
2227
|
error: _,
|
|
2228
2228
|
lifecycle: "beforeRequest"
|
|
2229
2229
|
}), !s)
|
|
2230
2230
|
throw _;
|
|
2231
2231
|
}
|
|
2232
|
-
const { id: l } = s, a = matchRemoteWithNameAndExpose(
|
|
2232
|
+
const { id: l } = s, a = matchRemoteWithNameAndExpose(o.options.remotes, l);
|
|
2233
2233
|
assert(a, getShortErrorMsg(RUNTIME_004, runtimeDescMap, {
|
|
2234
|
-
hostName:
|
|
2234
|
+
hostName: o.options.name,
|
|
2235
2235
|
requestId: l
|
|
2236
2236
|
}));
|
|
2237
|
-
const { remote: i } = a, c = getRemoteInfo(i), u = await
|
|
2237
|
+
const { remote: i } = a, c = getRemoteInfo(i), u = await o.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({
|
|
2238
2238
|
id: l
|
|
2239
2239
|
}, a, {
|
|
2240
|
-
options:
|
|
2241
|
-
origin:
|
|
2240
|
+
options: o.options,
|
|
2241
|
+
origin: o,
|
|
2242
2242
|
remoteInfo: c
|
|
2243
2243
|
})), { remote: d, expose: p } = u;
|
|
2244
2244
|
assert(d && p, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${l}.`);
|
|
2245
|
-
let m =
|
|
2245
|
+
let m = o.moduleCache.get(d.name);
|
|
2246
2246
|
const y = {
|
|
2247
|
-
host:
|
|
2247
|
+
host: o,
|
|
2248
2248
|
remoteInfo: c
|
|
2249
2249
|
};
|
|
2250
|
-
return m || (m = new Module(y),
|
|
2250
|
+
return m || (m = new Module(y), o.moduleCache.set(d.name, m)), {
|
|
2251
2251
|
module: m,
|
|
2252
2252
|
moduleOptions: y,
|
|
2253
2253
|
remoteMatchInfo: u
|
|
2254
2254
|
};
|
|
2255
2255
|
}
|
|
2256
|
-
registerRemote(t,
|
|
2256
|
+
registerRemote(t, o, n) {
|
|
2257
2257
|
const { host: s } = this, l = () => {
|
|
2258
2258
|
if (t.alias) {
|
|
2259
|
-
const i =
|
|
2259
|
+
const i = o.find((c) => {
|
|
2260
2260
|
var u;
|
|
2261
2261
|
return t.alias && (c.name.startsWith(t.alias) || ((u = c.alias) == null ? void 0 : u.startsWith(t.alias)));
|
|
2262
2262
|
});
|
|
@@ -2268,21 +2268,21 @@ class RemoteHandler {
|
|
|
2268
2268
|
remote: t,
|
|
2269
2269
|
origin: s
|
|
2270
2270
|
});
|
|
2271
|
-
const a =
|
|
2271
|
+
const a = o.find((i) => i.name === t.name);
|
|
2272
2272
|
if (!a)
|
|
2273
|
-
l(),
|
|
2273
|
+
l(), o.push(t), this.hooks.lifecycle.registerRemote.emit({
|
|
2274
2274
|
remote: t,
|
|
2275
2275
|
origin: s
|
|
2276
2276
|
});
|
|
2277
2277
|
else {
|
|
2278
2278
|
const i = [
|
|
2279
2279
|
`The remote "${t.name}" is already registered.`,
|
|
2280
|
-
|
|
2280
|
+
"Please note that overriding it may cause unexpected errors."
|
|
2281
2281
|
];
|
|
2282
|
-
n != null && n.force && (this.removeRemote(a), l(),
|
|
2282
|
+
n != null && n.force && (this.removeRemote(a), l(), o.push(t), this.hooks.lifecycle.registerRemote.emit({
|
|
2283
2283
|
remote: t,
|
|
2284
2284
|
origin: s
|
|
2285
|
-
})
|
|
2285
|
+
}), warn$1(i.join(" ")));
|
|
2286
2286
|
}
|
|
2287
2287
|
}
|
|
2288
2288
|
removeRemote(t) {
|
|
@@ -2293,8 +2293,8 @@ class RemoteHandler {
|
|
|
2293
2293
|
if (a) {
|
|
2294
2294
|
const i = a.remoteInfo, c = i.entryGlobalName;
|
|
2295
2295
|
if (CurrentGlobal[c]) {
|
|
2296
|
-
var
|
|
2297
|
-
(
|
|
2296
|
+
var o;
|
|
2297
|
+
(o = Object.getOwnPropertyDescriptor(CurrentGlobal, c)) != null && o.configurable ? delete CurrentGlobal[c] : CurrentGlobal[c] = void 0;
|
|
2298
2298
|
}
|
|
2299
2299
|
const u = getRemoteEntryUniqueKey(a.remoteInfo);
|
|
2300
2300
|
globalLoading[u] && delete globalLoading[u], n.snapshotHandler.manifestCache.delete(i.entry);
|
|
@@ -2312,25 +2312,25 @@ class RemoteHandler {
|
|
|
2312
2312
|
const S = I[v];
|
|
2313
2313
|
S && Object.keys(S).forEach((b) => {
|
|
2314
2314
|
const $ = S[b];
|
|
2315
|
-
$ && Object.keys($).forEach((
|
|
2316
|
-
const O = $[
|
|
2315
|
+
$ && Object.keys($).forEach((A) => {
|
|
2316
|
+
const O = $[A];
|
|
2317
2317
|
O && typeof O == "object" && O.from === i.name && (O.loaded || O.loading ? (O.useIn = O.useIn.filter((T) => T !== i.name), O.useIn.length ? R = !1 : g.push([
|
|
2318
2318
|
E,
|
|
2319
2319
|
v,
|
|
2320
2320
|
b,
|
|
2321
|
-
|
|
2321
|
+
A
|
|
2322
2322
|
])) : g.push([
|
|
2323
2323
|
E,
|
|
2324
2324
|
v,
|
|
2325
2325
|
b,
|
|
2326
|
-
|
|
2326
|
+
A
|
|
2327
2327
|
]));
|
|
2328
2328
|
});
|
|
2329
2329
|
});
|
|
2330
2330
|
});
|
|
2331
2331
|
}), R && (y.shareScopeMap = {}, delete _[d]), g.forEach(([E, I, v, S]) => {
|
|
2332
|
-
var b, $,
|
|
2333
|
-
(
|
|
2332
|
+
var b, $, A;
|
|
2333
|
+
(A = _[E]) == null || ($ = A[I]) == null || (b = $[v]) == null || delete b[S];
|
|
2334
2334
|
}), CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(p, 1);
|
|
2335
2335
|
}
|
|
2336
2336
|
const { hostGlobalSnapshot: m } = getGlobalRemoteInfo(t, n);
|
|
@@ -2363,26 +2363,26 @@ class RemoteHandler {
|
|
|
2363
2363
|
class FederationHost {
|
|
2364
2364
|
initOptions(t) {
|
|
2365
2365
|
this.registerPlugins(t.plugins);
|
|
2366
|
-
const
|
|
2367
|
-
return this.options =
|
|
2366
|
+
const o = this.formatOptions(this.options, t);
|
|
2367
|
+
return this.options = o, o;
|
|
2368
2368
|
}
|
|
2369
|
-
async loadShare(t,
|
|
2370
|
-
return this.sharedHandler.loadShare(t,
|
|
2369
|
+
async loadShare(t, o) {
|
|
2370
|
+
return this.sharedHandler.loadShare(t, o);
|
|
2371
2371
|
}
|
|
2372
2372
|
// The lib function will only be available if the shared set by eager or runtime init is set or the shared is successfully loaded.
|
|
2373
2373
|
// 1. If the loaded shared already exists globally, then it will be reused
|
|
2374
2374
|
// 2. If lib exists in local shared, it will be used directly
|
|
2375
2375
|
// 3. If the local get returns something other than Promise, then it will be used directly
|
|
2376
|
-
loadShareSync(t,
|
|
2377
|
-
return this.sharedHandler.loadShareSync(t,
|
|
2376
|
+
loadShareSync(t, o) {
|
|
2377
|
+
return this.sharedHandler.loadShareSync(t, o);
|
|
2378
2378
|
}
|
|
2379
|
-
initializeSharing(t = DEFAULT_SCOPE,
|
|
2380
|
-
return this.sharedHandler.initializeSharing(t,
|
|
2379
|
+
initializeSharing(t = DEFAULT_SCOPE, o) {
|
|
2380
|
+
return this.sharedHandler.initializeSharing(t, o);
|
|
2381
2381
|
}
|
|
2382
|
-
initRawContainer(t,
|
|
2382
|
+
initRawContainer(t, o, n) {
|
|
2383
2383
|
const s = getRemoteInfo({
|
|
2384
2384
|
name: t,
|
|
2385
|
-
entry:
|
|
2385
|
+
entry: o
|
|
2386
2386
|
}), l = new Module({
|
|
2387
2387
|
host: this,
|
|
2388
2388
|
remoteInfo: s
|
|
@@ -2391,20 +2391,20 @@ class FederationHost {
|
|
|
2391
2391
|
}
|
|
2392
2392
|
// eslint-disable-next-line max-lines-per-function
|
|
2393
2393
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
2394
|
-
async loadRemote(t,
|
|
2395
|
-
return this.remoteHandler.loadRemote(t,
|
|
2394
|
+
async loadRemote(t, o) {
|
|
2395
|
+
return this.remoteHandler.loadRemote(t, o);
|
|
2396
2396
|
}
|
|
2397
2397
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
2398
2398
|
async preloadRemote(t) {
|
|
2399
2399
|
return this.remoteHandler.preloadRemote(t);
|
|
2400
2400
|
}
|
|
2401
|
-
initShareScopeMap(t,
|
|
2402
|
-
this.sharedHandler.initShareScopeMap(t,
|
|
2401
|
+
initShareScopeMap(t, o, n = {}) {
|
|
2402
|
+
this.sharedHandler.initShareScopeMap(t, o, n);
|
|
2403
2403
|
}
|
|
2404
|
-
formatOptions(t,
|
|
2405
|
-
const { shared: n } = formatShareConfigs(t,
|
|
2404
|
+
formatOptions(t, o) {
|
|
2405
|
+
const { shared: n } = formatShareConfigs(t, o), { userOptions: s, options: l } = this.hooks.lifecycle.beforeInit.emit({
|
|
2406
2406
|
origin: this,
|
|
2407
|
-
userOptions:
|
|
2407
|
+
userOptions: o,
|
|
2408
2408
|
options: t,
|
|
2409
2409
|
shareInfo: n
|
|
2410
2410
|
}), a = this.remoteHandler.formatAndRegisterRemote(l, s), { shared: i } = this.sharedHandler.registerShared(l, s), c = [
|
|
@@ -2413,7 +2413,7 @@ class FederationHost {
|
|
|
2413
2413
|
s.plugins && s.plugins.forEach((d) => {
|
|
2414
2414
|
c.includes(d) || c.push(d);
|
|
2415
2415
|
});
|
|
2416
|
-
const u = _extends$1({}, t,
|
|
2416
|
+
const u = _extends$1({}, t, o, {
|
|
2417
2417
|
plugins: c,
|
|
2418
2418
|
remotes: a,
|
|
2419
2419
|
shared: i
|
|
@@ -2424,7 +2424,7 @@ class FederationHost {
|
|
|
2424
2424
|
}), u;
|
|
2425
2425
|
}
|
|
2426
2426
|
registerPlugins(t) {
|
|
2427
|
-
const
|
|
2427
|
+
const o = registerPlugins$1(t, [
|
|
2428
2428
|
this.hooks,
|
|
2429
2429
|
this.remoteHandler.hooks,
|
|
2430
2430
|
this.sharedHandler.hooks,
|
|
@@ -2432,10 +2432,10 @@ class FederationHost {
|
|
|
2432
2432
|
this.loaderHook,
|
|
2433
2433
|
this.bridgeHook
|
|
2434
2434
|
]);
|
|
2435
|
-
this.options.plugins = this.options.plugins.reduce((n, s) => (s && n && !n.find((l) => l.name === s.name) && n.push(s), n),
|
|
2435
|
+
this.options.plugins = this.options.plugins.reduce((n, s) => (s && n && !n.find((l) => l.name === s.name) && n.push(s), n), o || []);
|
|
2436
2436
|
}
|
|
2437
|
-
registerRemotes(t,
|
|
2438
|
-
return this.remoteHandler.registerRemotes(t,
|
|
2437
|
+
registerRemotes(t, o) {
|
|
2438
|
+
return this.remoteHandler.registerRemotes(t, o);
|
|
2439
2439
|
}
|
|
2440
2440
|
constructor(t) {
|
|
2441
2441
|
this.hooks = new PluginSystem({
|
|
@@ -2445,7 +2445,7 @@ class FederationHost {
|
|
|
2445
2445
|
beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
|
|
2446
2446
|
// maybe will change, temporarily for internal use only
|
|
2447
2447
|
initContainer: new AsyncWaterfallHook("initContainer")
|
|
2448
|
-
}), this.version = "0.8.
|
|
2448
|
+
}), this.version = "0.8.3", this.moduleCache = /* @__PURE__ */ new Map(), this.loaderHook = new PluginSystem({
|
|
2449
2449
|
// FIXME: may not be suitable , not open to the public yet
|
|
2450
2450
|
getModuleInfo: new SyncHook(),
|
|
2451
2451
|
createScript: new SyncHook(),
|
|
@@ -2459,7 +2459,7 @@ class FederationHost {
|
|
|
2459
2459
|
beforeBridgeDestroy: new SyncHook(),
|
|
2460
2460
|
afterBridgeDestroy: new SyncHook()
|
|
2461
2461
|
});
|
|
2462
|
-
const
|
|
2462
|
+
const o = {
|
|
2463
2463
|
id: getBuilderId(),
|
|
2464
2464
|
name: t.name,
|
|
2465
2465
|
plugins: [
|
|
@@ -2470,47 +2470,47 @@ class FederationHost {
|
|
|
2470
2470
|
shared: {},
|
|
2471
2471
|
inBrowser: isBrowserEnv()
|
|
2472
2472
|
};
|
|
2473
|
-
this.name = t.name, this.options =
|
|
2474
|
-
...
|
|
2473
|
+
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([
|
|
2474
|
+
...o.plugins,
|
|
2475
2475
|
...t.plugins || []
|
|
2476
|
-
]), this.options = this.formatOptions(
|
|
2476
|
+
]), this.options = this.formatOptions(o, t);
|
|
2477
2477
|
}
|
|
2478
2478
|
}
|
|
2479
2479
|
setGlobalFederationConstructor(FederationHost);
|
|
2480
|
-
function createBridgeComponent(
|
|
2480
|
+
function createBridgeComponent(r) {
|
|
2481
2481
|
const t = /* @__PURE__ */ new Map();
|
|
2482
2482
|
return () => ({
|
|
2483
|
-
__APP_VERSION__: "0.8.
|
|
2484
|
-
render(
|
|
2485
|
-
LoggerInstance.log("createBridgeComponent render Info",
|
|
2486
|
-
const n = Vue.createApp(
|
|
2487
|
-
t.set(
|
|
2488
|
-
const s = {}, l = s && typeof s == "object" && (s != null && s.extraProps) ? s == null ? void 0 : s.extraProps : {}, a =
|
|
2489
|
-
basename:
|
|
2490
|
-
memoryRoute:
|
|
2483
|
+
__APP_VERSION__: "0.8.3",
|
|
2484
|
+
render(o) {
|
|
2485
|
+
LoggerInstance.log("createBridgeComponent render Info", o);
|
|
2486
|
+
const n = Vue.createApp(r.rootComponent);
|
|
2487
|
+
t.set(o.dom, n);
|
|
2488
|
+
const s = {}, l = s && typeof s == "object" && (s != null && s.extraProps) ? s == null ? void 0 : s.extraProps : {}, a = r.appOptions({
|
|
2489
|
+
basename: o.basename,
|
|
2490
|
+
memoryRoute: o.memoryRoute,
|
|
2491
2491
|
...l
|
|
2492
|
-
}), i =
|
|
2492
|
+
}), i = o.memoryRoute ? VueRouter.createMemoryHistory(o.basename) : VueRouter.createWebHistory(o.basename), c = VueRouter.createRouter({
|
|
2493
2493
|
...a.router.options,
|
|
2494
2494
|
history: i,
|
|
2495
2495
|
routes: a.router.getRoutes()
|
|
2496
2496
|
});
|
|
2497
2497
|
LoggerInstance.log("createBridgeComponent render router info>>>", {
|
|
2498
|
-
name:
|
|
2498
|
+
name: o.moduleName,
|
|
2499
2499
|
router: c
|
|
2500
|
-
}),
|
|
2501
|
-
n.use(c), n.mount(
|
|
2502
|
-
}) : (n.use(c), n.mount(
|
|
2500
|
+
}), o.memoryRoute ? c.push(o.memoryRoute.entryPath).then(() => {
|
|
2501
|
+
n.use(c), n.mount(o.dom);
|
|
2502
|
+
}) : (n.use(c), n.mount(o.dom));
|
|
2503
2503
|
},
|
|
2504
|
-
destroy(
|
|
2505
|
-
LoggerInstance.log("createBridgeComponent destroy Info",
|
|
2506
|
-
const n = t.get(
|
|
2504
|
+
destroy(o) {
|
|
2505
|
+
LoggerInstance.log("createBridgeComponent destroy Info", o);
|
|
2506
|
+
const n = t.get(o == null ? void 0 : o.dom);
|
|
2507
2507
|
n == null || n.unmount();
|
|
2508
2508
|
}
|
|
2509
2509
|
});
|
|
2510
2510
|
}
|
|
2511
2511
|
function e() {
|
|
2512
|
-
const
|
|
2513
|
-
window.dispatchEvent(
|
|
2512
|
+
const r = new PopStateEvent("popstate", { state: window.history.state });
|
|
2513
|
+
window.dispatchEvent(r);
|
|
2514
2514
|
}
|
|
2515
2515
|
const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
2516
2516
|
name: "RemoteApp",
|
|
@@ -2520,16 +2520,16 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2520
2520
|
memoryRoute: Object,
|
|
2521
2521
|
providerInfo: Function
|
|
2522
2522
|
},
|
|
2523
|
-
setup(
|
|
2524
|
-
const t = ref(null),
|
|
2523
|
+
setup(r) {
|
|
2524
|
+
const t = ref(null), o = ref(null), n = ref(""), s = useRoute(), l = () => {
|
|
2525
2525
|
var d;
|
|
2526
|
-
const i = (d =
|
|
2527
|
-
|
|
2526
|
+
const i = (d = r.providerInfo) == null ? void 0 : d.call(r);
|
|
2527
|
+
o.value = i;
|
|
2528
2528
|
let c = {
|
|
2529
|
-
name:
|
|
2529
|
+
name: r.moduleName,
|
|
2530
2530
|
dom: t.value,
|
|
2531
|
-
basename:
|
|
2532
|
-
memoryRoute:
|
|
2531
|
+
basename: r.basename,
|
|
2532
|
+
memoryRoute: r.memoryRoute
|
|
2533
2533
|
};
|
|
2534
2534
|
LoggerInstance.log("createRemoteComponent LazyComponent render >>>", c), c = {
|
|
2535
2535
|
...c,
|
|
@@ -2537,7 +2537,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2537
2537
|
}, i.render(c);
|
|
2538
2538
|
}, a = watch(() => s.path, (i) => {
|
|
2539
2539
|
i !== s.path && l(), n.value !== "" && n.value !== i && (LoggerInstance.log("createRemoteComponent dispatchPopstateEnv >>>", {
|
|
2540
|
-
...
|
|
2540
|
+
...r,
|
|
2541
2541
|
pathname: s.path
|
|
2542
2542
|
}), e()), n.value = i;
|
|
2543
2543
|
});
|
|
@@ -2546,8 +2546,8 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2546
2546
|
}), onBeforeUnmount(() => {
|
|
2547
2547
|
var i;
|
|
2548
2548
|
LoggerInstance.log("createRemoteComponent LazyComponent destroy >>>", {
|
|
2549
|
-
...
|
|
2550
|
-
}), a(), (i =
|
|
2549
|
+
...r
|
|
2550
|
+
}), a(), (i = o.value) == null || i.destroy({
|
|
2551
2551
|
dom: t.value
|
|
2552
2552
|
});
|
|
2553
2553
|
}), () => createVNode("div", {
|
|
@@ -2555,33 +2555,33 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2555
2555
|
}, null);
|
|
2556
2556
|
}
|
|
2557
2557
|
});
|
|
2558
|
-
function createRemoteComponent(
|
|
2558
|
+
function createRemoteComponent(r) {
|
|
2559
2559
|
return defineAsyncComponent({
|
|
2560
|
-
__APP_VERSION__: "0.8.
|
|
2561
|
-
...
|
|
2560
|
+
__APP_VERSION__: "0.8.3",
|
|
2561
|
+
...r.asyncComponentOptions,
|
|
2562
2562
|
//@ts-ignore
|
|
2563
2563
|
loader: async () => {
|
|
2564
2564
|
var c;
|
|
2565
2565
|
const t = useRoute();
|
|
2566
|
-
let
|
|
2566
|
+
let o = "/";
|
|
2567
2567
|
const n = (c = t.matched[0]) == null ? void 0 : c.path;
|
|
2568
|
-
n && (n.endsWith("/:pathMatch(.*)*") ?
|
|
2569
|
-
const s = (
|
|
2568
|
+
n && (n.endsWith("/:pathMatch(.*)*") ? o = n.replace("/:pathMatch(.*)*", "") : o = t.matched[0].path);
|
|
2569
|
+
const s = (r == null ? void 0 : r.export) || "default";
|
|
2570
2570
|
LoggerInstance.log("createRemoteComponent LazyComponent create >>>", {
|
|
2571
|
-
basename:
|
|
2572
|
-
info:
|
|
2571
|
+
basename: o,
|
|
2572
|
+
info: r
|
|
2573
2573
|
});
|
|
2574
|
-
const l = await
|
|
2574
|
+
const l = await r.loader(), a = l && l[Symbol.for("mf_module_id")], i = l[s];
|
|
2575
2575
|
if (LoggerInstance.log(
|
|
2576
2576
|
"createRemoteComponent LazyComponent loadRemote info >>>",
|
|
2577
|
-
{ name: a, module: l, exportName: s, basename:
|
|
2577
|
+
{ name: a, module: l, exportName: s, basename: o, route: t }
|
|
2578
2578
|
), s in l && typeof i == "function")
|
|
2579
2579
|
return {
|
|
2580
2580
|
render() {
|
|
2581
2581
|
return h(RemoteApp, {
|
|
2582
2582
|
moduleName: a,
|
|
2583
2583
|
providerInfo: i,
|
|
2584
|
-
basename:
|
|
2584
|
+
basename: o
|
|
2585
2585
|
});
|
|
2586
2586
|
}
|
|
2587
2587
|
};
|