@module-federation/bridge-vue3 0.0.0-next-20241119071808 → 0.0.0-next-20241121062244
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 +21 -4
- package/dist/index.cjs.js +3 -3
- package/dist/index.es.js +619 -618
- package/package.json +6 -6
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 = (o, t) => {
|
|
6
|
+
for (var r in t)
|
|
7
|
+
__defProp(o, r, { get: t[r], enumerable: !0 });
|
|
8
|
+
}, __copyProps = (o, t, r, 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(o, s) && s !== r && __defProp(o, s, { get: () => t[s], enumerable: !(n = __getOwnPropDesc(t, s)) || n.enumerable });
|
|
12
|
+
return o;
|
|
13
|
+
}, __toCommonJS = (o) => __copyProps(__defProp({}, "__esModule", { value: !0 }), o), 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 o = "color test", t = "color: red;", r = console.log;
|
|
23
23
|
console.log = (...n) => {
|
|
24
|
-
n[0] === `%c${
|
|
25
|
-
}, console.log(`%c${
|
|
24
|
+
n[0] === `%c${o}` && n[1] === t && (supportsSubstitutions = !0);
|
|
25
|
+
}, console.log(`%c${o}`, t), console.log = r;
|
|
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 = (o) => supportColor() ? (t) => {
|
|
39
39
|
if (Array.isArray(t)) {
|
|
40
|
-
const [
|
|
41
|
-
return [`%c${
|
|
40
|
+
const [r, n] = t;
|
|
41
|
+
return [`%c${r.replace("%c", "")}`, n ? `${ansiToCss[o]}${n}` : `${ansiToCss[o] || ""}`];
|
|
42
42
|
}
|
|
43
|
-
return [`%c${String(t).replace("%c", "")}`, ansiToCss[
|
|
43
|
+
return [`%c${String(t).replace("%c", "")}`, ansiToCss[o] || ""];
|
|
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(o, t, r) {
|
|
47
47
|
let n = [""];
|
|
48
|
-
return "label" in t && (n = [o
|
|
48
|
+
return "label" in t && (n = [r[o] || 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(o, t, r, n) {
|
|
51
|
+
o.length ? Array.isArray(n) ? console.log(...o, ...n) : console.log(...o, t) : Array.isArray(n) ? console.log(...n) : console.log(t, ...r);
|
|
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 = (o) => errorStackRegExp.test(o) || anonymousErrorStackRegExp.test(o), createLogger$1 = (o = {}, { getLabel: t, handleError: r, finalLog: n, greet: s, LOG_TYPES: l }) => {
|
|
60
|
+
let a = o.level || "log", i = o.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
|
+
${r(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) ? r(E) : E).join(`
|
|
79
79
|
`) : _ = `${p}`;
|
|
80
80
|
n(R, _, m, p);
|
|
81
81
|
}, u = {
|
|
@@ -97,17 +97,17 @@ ${o(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 = (o) => !/[\s\n]/.test(o);
|
|
101
|
+
function gradient(o) {
|
|
102
102
|
if (!supportColor())
|
|
103
|
-
return [
|
|
104
|
-
const t = [...
|
|
103
|
+
return [o];
|
|
104
|
+
const t = [...o], r = t.filter(isWord), n = r.length - 1;
|
|
105
105
|
if (n === 0)
|
|
106
|
-
return console.log(`%c${
|
|
106
|
+
return console.log(`%c${o}`, `color: rgb(${startColor.join(",")}); font-weight: bold;`), [o];
|
|
107
107
|
let s = "", l = [];
|
|
108
108
|
return t.forEach((a) => {
|
|
109
109
|
if (isWord(a)) {
|
|
110
|
-
const i =
|
|
110
|
+
const i = r.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(o = {}) {
|
|
162
|
+
return createLogger$1(o, {
|
|
163
163
|
handleError: (t) => t,
|
|
164
164
|
getLabel,
|
|
165
165
|
gradient,
|
|
@@ -171,8 +171,8 @@ function createLogger2(r = {}) {
|
|
|
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 r = 1; r < arguments.length; r++) {
|
|
175
|
+
var n = arguments[r];
|
|
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(o) {
|
|
200
|
+
isDebugMode() && (o.level = "verbose");
|
|
201
201
|
}
|
|
202
|
-
function setPrefix(
|
|
203
|
-
|
|
202
|
+
function setPrefix(o, t) {
|
|
203
|
+
o.labels = {
|
|
204
204
|
warn: `${t} Warn`,
|
|
205
205
|
error: `${t} Error`,
|
|
206
206
|
success: `${t} Success`,
|
|
@@ -209,7 +209,7 @@ function setPrefix(r, t) {
|
|
|
209
209
|
debug: `${t} Debug`
|
|
210
210
|
};
|
|
211
211
|
}
|
|
212
|
-
function createLogger(
|
|
212
|
+
function createLogger(o) {
|
|
213
213
|
const t = browser.createLogger({
|
|
214
214
|
labels: {
|
|
215
215
|
warn: `${PREFIX} Warn`,
|
|
@@ -220,29 +220,29 @@ function createLogger(r) {
|
|
|
220
220
|
debug: `${PREFIX} Debug`
|
|
221
221
|
}
|
|
222
222
|
});
|
|
223
|
-
return setDebug(t), setPrefix(t,
|
|
223
|
+
return setDebug(t), setPrefix(t, o), 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(...o) {
|
|
227
|
+
return o.length ? o.reduce((t, r) => r ? t ? `${t}${SEPARATOR}${r}` : r : t, "") : "";
|
|
228
|
+
}, getResourceUrl = (o, t) => {
|
|
229
|
+
if ("getPublicPath" in o) {
|
|
230
|
+
let r;
|
|
231
|
+
return o.getPublicPath.startsWith("function") ? r = new Function("return " + o.getPublicPath)()() : r = new Function(o.getPublicPath)(), `${r}${t}`;
|
|
232
232
|
} else
|
|
233
|
-
return "publicPath" in
|
|
234
|
-
}, warn$1 = (
|
|
235
|
-
console.warn(`${LOG_CATEGORY$1}: ${
|
|
233
|
+
return "publicPath" in o ? `${o.publicPath}${t}` : (console.warn("Cannot get resource URL. If in debug mode, please ignore.", o, t), "");
|
|
234
|
+
}, warn$1 = (o) => {
|
|
235
|
+
console.warn(`${LOG_CATEGORY$1}: ${o}`);
|
|
236
236
|
};
|
|
237
|
-
function safeToString(
|
|
237
|
+
function safeToString(o) {
|
|
238
238
|
try {
|
|
239
|
-
return JSON.stringify(
|
|
239
|
+
return JSON.stringify(o, null, 2);
|
|
240
240
|
} catch {
|
|
241
241
|
return "";
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
|
-
const simpleJoinRemoteEntry = (
|
|
245
|
-
if (!
|
|
244
|
+
const simpleJoinRemoteEntry = (o, t) => {
|
|
245
|
+
if (!o)
|
|
246
246
|
return t;
|
|
247
247
|
const n = ((s) => {
|
|
248
248
|
if (s === ".")
|
|
@@ -254,25 +254,25 @@ const simpleJoinRemoteEntry = (r, t) => {
|
|
|
254
254
|
return l.endsWith("/") ? l.slice(0, -1) : l;
|
|
255
255
|
}
|
|
256
256
|
return s;
|
|
257
|
-
})(
|
|
257
|
+
})(o);
|
|
258
258
|
return n ? n.endsWith("/") ? `${n}${t}` : `${n}/${t}` : t;
|
|
259
259
|
};
|
|
260
|
-
function inferAutoPublicPath(
|
|
261
|
-
return
|
|
260
|
+
function inferAutoPublicPath(o) {
|
|
261
|
+
return o.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
|
|
262
262
|
}
|
|
263
|
-
function generateSnapshotFromManifest(
|
|
264
|
-
var
|
|
263
|
+
function generateSnapshotFromManifest(o, t = {}) {
|
|
264
|
+
var r, 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 o.metaData ? o.metaData.publicPath === "auto" && a ? inferAutoPublicPath(a) : o.metaData.publicPath : o.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 = o.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(r, 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 } = o.metaData, { exposes: v } = o;
|
|
284
284
|
let S = {
|
|
285
285
|
version: a || "",
|
|
286
286
|
buildVersion: g,
|
|
@@ -291,7 +291,7 @@ function generateSnapshotFromManifest(r, t = {}) {
|
|
|
291
291
|
remoteTypesZip: R.zip || "",
|
|
292
292
|
remoteTypesAPI: R.api || "",
|
|
293
293
|
remotesInfo: d,
|
|
294
|
-
shared:
|
|
294
|
+
shared: o == null ? void 0 : o.shared.map((b) => ({
|
|
295
295
|
assets: b.assets,
|
|
296
296
|
sharedName: b.name,
|
|
297
297
|
version: b.version
|
|
@@ -302,20 +302,20 @@ function generateSnapshotFromManifest(r, t = {}) {
|
|
|
302
302
|
assets: b.assets
|
|
303
303
|
}))
|
|
304
304
|
};
|
|
305
|
-
if ((
|
|
306
|
-
const b =
|
|
305
|
+
if ((r = o.metaData) != null && r.prefetchInterface) {
|
|
306
|
+
const b = o.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 = o.metaData) != null && n.prefetchEntry) {
|
|
312
|
+
const { path: b, name: $, type: A } = o.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 o.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(r, t = {}) {
|
|
|
325
325
|
}
|
|
326
326
|
return i;
|
|
327
327
|
}
|
|
328
|
-
function isManifestProvider(
|
|
329
|
-
return !!("remoteEntry" in
|
|
328
|
+
function isManifestProvider(o) {
|
|
329
|
+
return !!("remoteEntry" in o && o.remoteEntry.includes(MANIFEST_EXT));
|
|
330
330
|
}
|
|
331
|
-
async function safeWrapper(
|
|
331
|
+
async function safeWrapper(o, t) {
|
|
332
332
|
try {
|
|
333
|
-
return await
|
|
334
|
-
} catch (
|
|
335
|
-
warn$1(
|
|
333
|
+
return await o();
|
|
334
|
+
} catch (r) {
|
|
335
|
+
warn$1(r);
|
|
336
336
|
return;
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
|
-
function isStaticResourcesEqual(
|
|
340
|
-
const
|
|
339
|
+
function isStaticResourcesEqual(o, t) {
|
|
340
|
+
const r = /^(https?:)?\/\//i, n = o.replace(r, "").replace(/\/$/, ""), s = t.replace(r, "").replace(/\/$/, "");
|
|
341
341
|
return n === s;
|
|
342
342
|
}
|
|
343
|
-
function createScript(
|
|
344
|
-
let t = null,
|
|
343
|
+
function createScript(o) {
|
|
344
|
+
let t = null, r = !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, o.url)) {
|
|
349
|
+
t = c, r = !1;
|
|
350
350
|
break;
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
353
|
if (!t) {
|
|
354
|
-
const i =
|
|
354
|
+
const i = o.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
|
+
o.createScriptHook && (c = o.createScriptHook(o.url, o.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 = o.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 } = o;
|
|
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(r) {
|
|
|
369
369
|
if (m instanceof Promise) {
|
|
370
370
|
var p;
|
|
371
371
|
const y = await m;
|
|
372
|
-
return
|
|
372
|
+
return o == null || (p = o.cb) == null || p.call(o), y;
|
|
373
373
|
}
|
|
374
|
-
return
|
|
374
|
+
return o == null || (d = o.cb) == null || d.call(o), m;
|
|
375
375
|
}
|
|
376
|
-
|
|
376
|
+
o == null || (u = o.cb) == null || u.call(o);
|
|
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 "${o.url}" time-outed.`));
|
|
380
380
|
}, n), {
|
|
381
381
|
script: t,
|
|
382
|
-
needAttach:
|
|
382
|
+
needAttach: r
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
|
-
function createLink(
|
|
386
|
-
let t = null,
|
|
385
|
+
function createLink(o) {
|
|
386
|
+
let t = null, r = !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, o.url) && c === o.attrs.ref) {
|
|
391
|
+
t = a, r = !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", o.url);
|
|
397
397
|
let l;
|
|
398
|
-
const a =
|
|
399
|
-
|
|
398
|
+
const a = o.attrs;
|
|
399
|
+
o.createLinkHook && (l = o.createLinkHook(o.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 } = o;
|
|
406
406
|
i && t != null && t.parentNode && t.parentNode.removeChild(t);
|
|
407
407
|
}), l)) {
|
|
408
408
|
const i = l(a);
|
|
409
|
-
return
|
|
409
|
+
return o.cb(), i;
|
|
410
410
|
}
|
|
411
|
-
|
|
411
|
+
o.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: r
|
|
416
416
|
};
|
|
417
417
|
}
|
|
418
|
-
function loadScript(
|
|
419
|
-
const { attrs:
|
|
418
|
+
function loadScript(o, t) {
|
|
419
|
+
const { attrs: r = {}, createScriptHook: n } = t;
|
|
420
420
|
return new Promise((s, l) => {
|
|
421
421
|
const { script: a, needAttach: i } = createScript({
|
|
422
|
-
url:
|
|
422
|
+
url: o,
|
|
423
423
|
cb: s,
|
|
424
424
|
attrs: _extends$2({
|
|
425
425
|
fetchpriority: "high"
|
|
426
|
-
},
|
|
426
|
+
}, r),
|
|
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(o) {
|
|
434
|
+
if (!o)
|
|
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)")(o).then((r) => r).catch((r) => {
|
|
437
|
+
throw console.error(`Error importing module ${o}:`, r), r;
|
|
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 o = await importNodeModule("node-fetch");
|
|
442
|
+
return o.default || o;
|
|
443
|
+
}, lazyLoaderHookFetch = async (o, t, r) => {
|
|
444
|
+
const s = await ((l, a) => r.lifecycle.fetch.emit(l, a))(o, t || {});
|
|
445
|
+
return !s || !(s instanceof Response) ? (typeof fetch > "u" ? await loadNodeFetch() : fetch)(o, t || {}) : s;
|
|
446
446
|
};
|
|
447
447
|
function createScriptNode(url, cb, attrs, loaderHook) {
|
|
448
448
|
if (loaderHook != null && loaderHook.createScriptHook) {
|
|
449
|
-
const
|
|
450
|
-
|
|
449
|
+
const o = loaderHook.createScriptHook(url);
|
|
450
|
+
o && typeof o == "object" && "url" in o && (url = o.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 (o) {
|
|
456
|
+
console.error("Error constructing URL:", o), cb(new Error(`Invalid URL: ${o}`));
|
|
457
457
|
return;
|
|
458
458
|
}
|
|
459
|
-
const getFetch = async () => loaderHook != null && loaderHook.fetch ? (
|
|
459
|
+
const getFetch = async () => loaderHook != null && loaderHook.fetch ? (o, t) => lazyLoaderHookFetch(o, 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 o = exportedInterface[attrs.globalName] || exportedInterface;
|
|
481
|
+
cb(void 0, o);
|
|
482
482
|
return;
|
|
483
483
|
}
|
|
484
484
|
cb(void 0, exportedInterface);
|
|
485
|
-
} catch (
|
|
486
|
-
cb(
|
|
485
|
+
} catch (o) {
|
|
486
|
+
cb(o instanceof Error ? o : new Error(`Script execution error: ${o}`));
|
|
487
487
|
}
|
|
488
488
|
};
|
|
489
|
-
getFetch().then(async (
|
|
489
|
+
getFetch().then(async (o) => {
|
|
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: o,
|
|
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(o, urlObj);
|
|
500
|
+
}).catch((o) => {
|
|
501
|
+
cb(o);
|
|
502
502
|
});
|
|
503
503
|
}
|
|
504
|
-
function loadScriptNode(
|
|
505
|
-
return new Promise((
|
|
506
|
-
createScriptNode(
|
|
504
|
+
function loadScriptNode(o, t) {
|
|
505
|
+
return new Promise((r, n) => {
|
|
506
|
+
createScriptNode(o, (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
|
+
r(u);
|
|
513
513
|
}
|
|
514
514
|
}, t.attrs, t.loaderHook);
|
|
515
515
|
});
|
|
516
516
|
}
|
|
517
|
-
async function loadModule(
|
|
518
|
-
const { fetch:
|
|
517
|
+
async function loadModule(o, t) {
|
|
518
|
+
const { fetch: r, vm: n } = t, l = await (await r(o)).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, o).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, o).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 r = 1; r < arguments.length; r++) {
|
|
534
|
+
var n = arguments[r];
|
|
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(o, t) {
|
|
542
|
+
if (o == null)
|
|
543
543
|
return {};
|
|
544
|
-
var
|
|
544
|
+
var r = {}, n = Object.keys(o), 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) && (r[s] = o[s]);
|
|
547
|
+
return r;
|
|
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(o, t) {
|
|
554
|
+
o || error(t);
|
|
555
555
|
}
|
|
556
|
-
function error(
|
|
557
|
-
throw
|
|
556
|
+
function error(o) {
|
|
557
|
+
throw o instanceof Error ? (o.message = `${LOG_CATEGORY}: ${o.message}`, o) : new Error(`${LOG_CATEGORY}: ${o}`);
|
|
558
558
|
}
|
|
559
|
-
function warn(
|
|
560
|
-
|
|
559
|
+
function warn(o) {
|
|
560
|
+
o instanceof Error && (o.message = `${LOG_CATEGORY}: ${o.message}`), logger.warn(o);
|
|
561
561
|
}
|
|
562
|
-
function addUniqueItem(
|
|
563
|
-
return
|
|
562
|
+
function addUniqueItem(o, t) {
|
|
563
|
+
return o.findIndex((r) => r === t) === -1 && o.push(t), o;
|
|
564
564
|
}
|
|
565
|
-
function getFMId(
|
|
566
|
-
return "version" in
|
|
565
|
+
function getFMId(o) {
|
|
566
|
+
return "version" in o && o.version ? `${o.name}:${o.version}` : "entry" in o && o.entry ? `${o.name}:${o.entry}` : `${o.name}`;
|
|
567
567
|
}
|
|
568
|
-
function isRemoteInfoWithEntry(
|
|
569
|
-
return typeof
|
|
568
|
+
function isRemoteInfoWithEntry(o) {
|
|
569
|
+
return typeof o.entry < "u";
|
|
570
570
|
}
|
|
571
|
-
function isPureRemoteEntry(
|
|
572
|
-
return !
|
|
571
|
+
function isPureRemoteEntry(o) {
|
|
572
|
+
return !o.entry.includes(".json") && o.entry.includes(".js");
|
|
573
573
|
}
|
|
574
|
-
function isObject(
|
|
575
|
-
return
|
|
574
|
+
function isObject(o) {
|
|
575
|
+
return o && typeof o == "object";
|
|
576
576
|
}
|
|
577
577
|
const objectToString = Object.prototype.toString;
|
|
578
|
-
function isPlainObject(
|
|
579
|
-
return objectToString.call(
|
|
578
|
+
function isPlainObject(o) {
|
|
579
|
+
return objectToString.call(o) === "[object Object]";
|
|
580
580
|
}
|
|
581
|
-
function arrayOptions(
|
|
582
|
-
return Array.isArray(
|
|
583
|
-
|
|
581
|
+
function arrayOptions(o) {
|
|
582
|
+
return Array.isArray(o) ? o : [
|
|
583
|
+
o
|
|
584
584
|
];
|
|
585
585
|
}
|
|
586
|
-
function getRemoteEntryInfoFromSnapshot(
|
|
586
|
+
function getRemoteEntryInfoFromSnapshot(o) {
|
|
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 o ? {
|
|
593
|
+
url: o.remoteEntry,
|
|
594
|
+
type: o.remoteEntryType,
|
|
595
|
+
globalName: o.globalName
|
|
596
|
+
} : t : "ssrRemoteEntry" in o ? {
|
|
597
|
+
url: o.ssrRemoteEntry || t.url,
|
|
598
|
+
type: o.ssrRemoteEntryType || t.type,
|
|
599
|
+
globalName: o.globalName
|
|
600
600
|
} : t;
|
|
601
601
|
}
|
|
602
|
-
const processModuleAlias = (
|
|
603
|
-
let
|
|
604
|
-
return
|
|
602
|
+
const processModuleAlias = (o, t) => {
|
|
603
|
+
let r;
|
|
604
|
+
return o.endsWith("/") ? r = o.slice(0, -1) : r = o, t.startsWith(".") && (t = t.slice(1)), r = r + t, r;
|
|
605
605
|
}, CurrentGlobal = typeof globalThis == "object" ? globalThis : window, nativeGlobal = (() => {
|
|
606
606
|
try {
|
|
607
607
|
return document.defaultView;
|
|
@@ -609,57 +609,57 @@ const processModuleAlias = (r, t) => {
|
|
|
609
609
|
return CurrentGlobal;
|
|
610
610
|
}
|
|
611
611
|
})(), Global = nativeGlobal;
|
|
612
|
-
function definePropertyGlobalVal(
|
|
613
|
-
Object.defineProperty(
|
|
614
|
-
value:
|
|
612
|
+
function definePropertyGlobalVal(o, t, r) {
|
|
613
|
+
Object.defineProperty(o, t, {
|
|
614
|
+
value: r,
|
|
615
615
|
configurable: !1,
|
|
616
616
|
writable: !0
|
|
617
617
|
});
|
|
618
618
|
}
|
|
619
|
-
function includeOwnProperty(
|
|
620
|
-
return Object.hasOwnProperty.call(
|
|
619
|
+
function includeOwnProperty(o, t) {
|
|
620
|
+
return Object.hasOwnProperty.call(o, 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(o) {
|
|
625
|
+
var t, r, n, s, l, a;
|
|
626
|
+
includeOwnProperty(o, "__VMOK__") && !includeOwnProperty(o, "__FEDERATION__") && definePropertyGlobalVal(o, "__FEDERATION__", o.__VMOK__), includeOwnProperty(o, "__FEDERATION__") || (definePropertyGlobalVal(o, "__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(o, "__VMOK__", o.__FEDERATION__));
|
|
634
634
|
var i;
|
|
635
|
-
(i = (t =
|
|
635
|
+
(i = (t = o.__FEDERATION__).__GLOBAL_PLUGIN__) != null || (t.__GLOBAL_PLUGIN__ = []);
|
|
636
636
|
var c;
|
|
637
|
-
(c = (
|
|
637
|
+
(c = (r = o.__FEDERATION__).__INSTANCES__) != null || (r.__INSTANCES__ = []);
|
|
638
638
|
var u;
|
|
639
|
-
(u = (n =
|
|
639
|
+
(u = (n = o.__FEDERATION__).moduleInfo) != null || (n.moduleInfo = {});
|
|
640
640
|
var d;
|
|
641
|
-
(d = (s =
|
|
641
|
+
(d = (s = o.__FEDERATION__).__SHARE__) != null || (s.__SHARE__ = {});
|
|
642
642
|
var p;
|
|
643
|
-
(p = (l =
|
|
643
|
+
(p = (l = o.__FEDERATION__).__MANIFEST_LOADING__) != null || (l.__MANIFEST_LOADING__ = {});
|
|
644
644
|
var m;
|
|
645
|
-
(m = (a =
|
|
645
|
+
(m = (a = o.__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(o, t = isDebugMode()) {
|
|
650
|
+
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = o, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.7.6");
|
|
651
651
|
}
|
|
652
|
-
function getInfoWithoutType(
|
|
652
|
+
function getInfoWithoutType(o, t) {
|
|
653
653
|
if (typeof t == "string") {
|
|
654
|
-
if (
|
|
654
|
+
if (o[t])
|
|
655
655
|
return {
|
|
656
|
-
value:
|
|
656
|
+
value: o[t],
|
|
657
657
|
key: t
|
|
658
658
|
};
|
|
659
659
|
{
|
|
660
|
-
const n = Object.keys(
|
|
660
|
+
const n = Object.keys(o);
|
|
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 = o[i];
|
|
663
663
|
if (c)
|
|
664
664
|
return {
|
|
665
665
|
value: c,
|
|
@@ -674,121 +674,121 @@ function getInfoWithoutType(r, 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 = (o, t) => {
|
|
678
|
+
const r = getFMId(o), n = getInfoWithoutType(t, r).value;
|
|
679
|
+
if (n && !n.version && "version" in o && o.version && (n.version = o.version), n)
|
|
680
680
|
return n;
|
|
681
|
-
if ("version" in
|
|
682
|
-
const { version: s } =
|
|
681
|
+
if ("version" in o && o.version) {
|
|
682
|
+
const { version: s } = o, l = _object_without_properties_loose(o, [
|
|
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 = (o) => getTargetSnapshotInfoByModuleInfo(o, nativeGlobal.__FEDERATION__.moduleInfo), setGlobalSnapshotInfoByModuleInfo = (o, t) => {
|
|
689
|
+
const r = getFMId(o);
|
|
690
|
+
return nativeGlobal.__FEDERATION__.moduleInfo[r] = t, nativeGlobal.__FEDERATION__.moduleInfo;
|
|
691
|
+
}, addGlobalSnapshot = (o) => (nativeGlobal.__FEDERATION__.moduleInfo = _extends$1({}, nativeGlobal.__FEDERATION__.moduleInfo, o), () => {
|
|
692
|
+
const t = Object.keys(o);
|
|
693
|
+
for (const r of t)
|
|
694
|
+
delete nativeGlobal.__FEDERATION__.moduleInfo[r];
|
|
695
|
+
}), getRemoteEntryExports = (o, t) => {
|
|
696
|
+
const r = t || `__FEDERATION_${o}:custom__`, n = CurrentGlobal[r];
|
|
697
697
|
return {
|
|
698
|
-
remoteEntryKey:
|
|
698
|
+
remoteEntryKey: r,
|
|
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 = (o) => CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.get(o), setPreloaded = (o) => CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.set(o, !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(o) {
|
|
703
|
+
return new RegExp(o);
|
|
704
704
|
}
|
|
705
|
-
function isXVersion(
|
|
706
|
-
return !
|
|
705
|
+
function isXVersion(o) {
|
|
706
|
+
return !o || o.toLowerCase() === "x" || o === "*";
|
|
707
707
|
}
|
|
708
|
-
function pipe(...
|
|
709
|
-
return (t) =>
|
|
708
|
+
function pipe(...o) {
|
|
709
|
+
return (t) => o.reduce((r, n) => n(r), t);
|
|
710
710
|
}
|
|
711
|
-
function extractComparator(
|
|
712
|
-
return
|
|
711
|
+
function extractComparator(o) {
|
|
712
|
+
return o.match(parseRegex(comparator));
|
|
713
713
|
}
|
|
714
|
-
function combineVersion(
|
|
715
|
-
const s = `${
|
|
714
|
+
function combineVersion(o, t, r, n) {
|
|
715
|
+
const s = `${o}.${t}.${r}`;
|
|
716
716
|
return n ? `${s}-${n}` : s;
|
|
717
717
|
}
|
|
718
|
-
function parseHyphen(
|
|
719
|
-
return
|
|
718
|
+
function parseHyphen(o) {
|
|
719
|
+
return o.replace(parseRegex(hyphenRange), (t, r, n, s, l, a, i, c, u, d, p, m) => (isXVersion(n) ? r = "" : isXVersion(s) ? r = `>=${n}.0.0` : isXVersion(l) ? r = `>=${n}.${s}.0` : r = `>=${r}`, 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}`, `${r} ${c}`.trim()));
|
|
720
720
|
}
|
|
721
|
-
function parseComparatorTrim(
|
|
722
|
-
return
|
|
721
|
+
function parseComparatorTrim(o) {
|
|
722
|
+
return o.replace(parseRegex(comparatorTrim), "$1$2$3");
|
|
723
723
|
}
|
|
724
|
-
function parseTildeTrim(
|
|
725
|
-
return
|
|
724
|
+
function parseTildeTrim(o) {
|
|
725
|
+
return o.replace(parseRegex(tildeTrim), "$1~");
|
|
726
726
|
}
|
|
727
|
-
function parseCaretTrim(
|
|
728
|
-
return
|
|
727
|
+
function parseCaretTrim(o) {
|
|
728
|
+
return o.replace(parseRegex(caretTrim), "$1^");
|
|
729
729
|
}
|
|
730
|
-
function parseCarets(
|
|
731
|
-
return
|
|
730
|
+
function parseCarets(o) {
|
|
731
|
+
return o.trim().split(/\s+/).map((t) => t.replace(parseRegex(caret), (r, 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(o) {
|
|
734
|
+
return o.trim().split(/\s+/).map((t) => t.replace(parseRegex(tilde), (r, 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(o) {
|
|
737
|
+
return o.split(/\s+/).map((t) => t.trim().replace(parseRegex(xRange), (r, 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` : r;
|
|
740
740
|
})).join(" ");
|
|
741
741
|
}
|
|
742
|
-
function parseStar(
|
|
743
|
-
return
|
|
742
|
+
function parseStar(o) {
|
|
743
|
+
return o.trim().replace(parseRegex(star), "");
|
|
744
744
|
}
|
|
745
|
-
function parseGTE0(
|
|
746
|
-
return
|
|
745
|
+
function parseGTE0(o) {
|
|
746
|
+
return o.trim().replace(parseRegex(gte0), "");
|
|
747
747
|
}
|
|
748
|
-
function compareAtom(
|
|
749
|
-
return
|
|
748
|
+
function compareAtom(o, t) {
|
|
749
|
+
return o = Number(o) || o, t = Number(t) || t, o > t ? 1 : o === t ? 0 : -1;
|
|
750
750
|
}
|
|
751
|
-
function comparePreRelease(
|
|
752
|
-
const { preRelease:
|
|
753
|
-
if (
|
|
751
|
+
function comparePreRelease(o, t) {
|
|
752
|
+
const { preRelease: r } = o, { preRelease: n } = t;
|
|
753
|
+
if (r === void 0 && n)
|
|
754
754
|
return 1;
|
|
755
|
-
if (
|
|
755
|
+
if (r && n === void 0)
|
|
756
756
|
return -1;
|
|
757
|
-
if (
|
|
757
|
+
if (r === void 0 && n === void 0)
|
|
758
758
|
return 0;
|
|
759
|
-
for (let s = 0, l =
|
|
760
|
-
const a =
|
|
759
|
+
for (let s = 0, l = r.length; s <= l; s++) {
|
|
760
|
+
const a = r[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(o, t) {
|
|
767
|
+
return compareAtom(o.major, t.major) || compareAtom(o.minor, t.minor) || compareAtom(o.patch, t.patch) || comparePreRelease(o, t);
|
|
768
768
|
}
|
|
769
|
-
function eq(
|
|
770
|
-
return
|
|
769
|
+
function eq(o, t) {
|
|
770
|
+
return o.version === t.version;
|
|
771
771
|
}
|
|
772
|
-
function compare(
|
|
773
|
-
switch (
|
|
772
|
+
function compare(o, t) {
|
|
773
|
+
switch (o.operator) {
|
|
774
774
|
case "":
|
|
775
775
|
case "=":
|
|
776
|
-
return eq(
|
|
776
|
+
return eq(o, t);
|
|
777
777
|
case ">":
|
|
778
|
-
return compareVersion(
|
|
778
|
+
return compareVersion(o, t) < 0;
|
|
779
779
|
case ">=":
|
|
780
|
-
return eq(
|
|
780
|
+
return eq(o, t) || compareVersion(o, t) < 0;
|
|
781
781
|
case "<":
|
|
782
|
-
return compareVersion(
|
|
782
|
+
return compareVersion(o, t) > 0;
|
|
783
783
|
case "<=":
|
|
784
|
-
return eq(
|
|
784
|
+
return eq(o, t) || compareVersion(o, 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(o) {
|
|
792
792
|
return pipe(
|
|
793
793
|
// handle caret
|
|
794
794
|
// ^ --> * (any, kinda silly)
|
|
@@ -808,9 +808,9 @@ function parseComparatorString(r) {
|
|
|
808
808
|
parseTildes,
|
|
809
809
|
parseXRanges,
|
|
810
810
|
parseStar
|
|
811
|
-
)(
|
|
811
|
+
)(o);
|
|
812
812
|
}
|
|
813
|
-
function parseRange(
|
|
813
|
+
function parseRange(o) {
|
|
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(r) {
|
|
|
824
824
|
// handle trim caret
|
|
825
825
|
// `^ 1.2.3` => `^1.2.3`
|
|
826
826
|
parseCaretTrim
|
|
827
|
-
)(
|
|
827
|
+
)(o.trim()).split(/\s+/).join(" ");
|
|
828
828
|
}
|
|
829
|
-
function satisfy(
|
|
830
|
-
if (!
|
|
829
|
+
function satisfy(o, t) {
|
|
830
|
+
if (!o)
|
|
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(o);
|
|
833
833
|
if (!l)
|
|
834
834
|
return !1;
|
|
835
835
|
const [, a, , i, c, u, d] = l, p = {
|
|
@@ -857,40 +857,40 @@ function satisfy(r, t) {
|
|
|
857
857
|
}
|
|
858
858
|
return !0;
|
|
859
859
|
}
|
|
860
|
-
function formatShare(
|
|
860
|
+
function formatShare(o, t, r, n) {
|
|
861
861
|
let s;
|
|
862
|
-
"get" in
|
|
863
|
-
throw new Error(`Can not get shared '${
|
|
864
|
-
}),
|
|
862
|
+
"get" in o ? s = o.get : "lib" in o ? s = () => Promise.resolve(o.lib) : s = () => Promise.resolve(() => {
|
|
863
|
+
throw new Error(`Can not get shared '${r}'!`);
|
|
864
|
+
}), o.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
|
+
}, o, {
|
|
872
872
|
shareConfig: _extends$1({
|
|
873
|
-
requiredVersion: `^${
|
|
873
|
+
requiredVersion: `^${o.version}`,
|
|
874
874
|
singleton: !1,
|
|
875
875
|
eager: !1,
|
|
876
876
|
strictVersion: !1
|
|
877
|
-
},
|
|
877
|
+
}, o.shareConfig),
|
|
878
878
|
get: s,
|
|
879
|
-
loaded:
|
|
880
|
-
version: (l =
|
|
881
|
-
scope: Array.isArray(
|
|
882
|
-
(a =
|
|
879
|
+
loaded: o != null && o.loaded || "lib" in o ? !0 : void 0,
|
|
880
|
+
version: (l = o.version) != null ? l : "0",
|
|
881
|
+
scope: Array.isArray(o.scope) ? o.scope : [
|
|
882
|
+
(a = o.scope) != null ? a : "default"
|
|
883
883
|
],
|
|
884
|
-
strategy: ((i =
|
|
884
|
+
strategy: ((i = o.strategy) != null ? i : n) || "version-first"
|
|
885
885
|
});
|
|
886
886
|
}
|
|
887
|
-
function formatShareConfigs(
|
|
888
|
-
const
|
|
889
|
-
const c = arrayOptions(
|
|
887
|
+
function formatShareConfigs(o, t) {
|
|
888
|
+
const r = t.shared || {}, n = t.name, s = Object.keys(r).reduce((a, i) => {
|
|
889
|
+
const c = arrayOptions(r[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({}, o.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(r, t) {
|
|
|
900
900
|
shareInfos: s
|
|
901
901
|
};
|
|
902
902
|
}
|
|
903
|
-
function versionLt(
|
|
904
|
-
const
|
|
903
|
+
function versionLt(o, t) {
|
|
904
|
+
const r = (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(r, t) {
|
|
|
911
911
|
}
|
|
912
912
|
return n;
|
|
913
913
|
};
|
|
914
|
-
return !!satisfy(o
|
|
914
|
+
return !!satisfy(r(o), `<=${r(t)}`);
|
|
915
915
|
}
|
|
916
|
-
const findVersion = (
|
|
917
|
-
const
|
|
916
|
+
const findVersion = (o, t) => {
|
|
917
|
+
const r = 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(o).reduce((n, s) => !n || r(n, s) || n === "0" ? s : n, 0);
|
|
921
|
+
}, isLoaded = (o) => !!o.loaded || typeof o.lib == "function", isLoading = (o) => !!o.loading;
|
|
922
|
+
function findSingletonVersionOrderByVersion(o, t, r) {
|
|
923
|
+
const n = o[t][r], s = function(l, a) {
|
|
924
924
|
return !isLoaded(n[l]) && versionLt(l, a);
|
|
925
925
|
};
|
|
926
|
-
return findVersion(
|
|
926
|
+
return findVersion(o[t][r], s);
|
|
927
927
|
}
|
|
928
|
-
function findSingletonVersionOrderByLoaded(
|
|
929
|
-
const n =
|
|
928
|
+
function findSingletonVersionOrderByLoaded(o, t, r) {
|
|
929
|
+
const n = o[t][r], 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(o[t][r], s);
|
|
934
934
|
}
|
|
935
|
-
function getFindShareFunction(
|
|
936
|
-
return
|
|
935
|
+
function getFindShareFunction(o) {
|
|
936
|
+
return o === "loaded-first" ? findSingletonVersionOrderByLoaded : findSingletonVersionOrderByVersion;
|
|
937
937
|
}
|
|
938
|
-
function getRegisteredShare(
|
|
939
|
-
if (!
|
|
938
|
+
function getRegisteredShare(o, t, r, n) {
|
|
939
|
+
if (!o)
|
|
940
940
|
return;
|
|
941
|
-
const { shareConfig: s, scope: l = DEFAULT_SCOPE, strategy: a } =
|
|
941
|
+
const { shareConfig: s, scope: l = DEFAULT_SCOPE, strategy: a } = r, 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 && o[c] && o[c][t]) {
|
|
946
|
+
const { requiredVersion: u } = s, p = getFindShareFunction(a)(o, 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 && o[c][t][p].from} of shared singleton module ${t} does not satisfy the requirement of ${r.from} which needs ${u})`;
|
|
950
950
|
s.strictVersion ? error(R) : warn(R);
|
|
951
951
|
}
|
|
952
|
-
return
|
|
952
|
+
return o[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 o[c][t][p];
|
|
956
|
+
for (const [R, g] of Object.entries(o[c][t]))
|
|
957
957
|
if (satisfy(R, u))
|
|
958
958
|
return g;
|
|
959
959
|
}
|
|
960
960
|
}, y = {
|
|
961
|
-
shareScopeMap:
|
|
961
|
+
shareScopeMap: o,
|
|
962
962
|
scope: c,
|
|
963
963
|
pkgName: t,
|
|
964
964
|
version: p,
|
|
@@ -971,8 +971,8 @@ function getRegisteredShare(r, t, o, n) {
|
|
|
971
971
|
function getGlobalShareScope() {
|
|
972
972
|
return Global.__FEDERATION__.__SHARE__;
|
|
973
973
|
}
|
|
974
|
-
function getTargetSharedOptions(
|
|
975
|
-
const { pkgName: t, extraOptions:
|
|
974
|
+
function getTargetSharedOptions(o) {
|
|
975
|
+
const { pkgName: t, extraOptions: r, shareInfos: n } = o, s = (i) => {
|
|
976
976
|
if (!i)
|
|
977
977
|
return;
|
|
978
978
|
const c = {};
|
|
@@ -985,23 +985,23 @@ function getTargetSharedOptions(r) {
|
|
|
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 = r == null ? void 0 : r.resolver) != null ? l : s;
|
|
989
|
+
return Object.assign({}, a(n[t]), r == null ? void 0 : r.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 = (o) => `https://module-federation.io/guide/troubleshooting/${o.split("-")[0].toLowerCase()}/${o}`, getShortErrorMsg = (o, t, r, n) => {
|
|
992
992
|
const s = [
|
|
993
993
|
`${[
|
|
994
|
-
t[
|
|
995
|
-
]} #${
|
|
994
|
+
t[o]
|
|
995
|
+
]} #${o}`
|
|
996
996
|
];
|
|
997
|
-
return
|
|
997
|
+
return r && s.push(`args: ${JSON.stringify(r)}`), s.push(getDocsUrl(o)), 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 r = 1; r < arguments.length; r++) {
|
|
1004
|
+
var n = arguments[r];
|
|
1005
1005
|
for (var s in n)
|
|
1006
1006
|
Object.prototype.hasOwnProperty.call(n, s) && (t[s] = n[s]);
|
|
1007
1007
|
}
|
|
@@ -1020,76 +1020,79 @@ 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(o, t) {
|
|
1024
|
+
for (const r of o) {
|
|
1025
|
+
const n = t.startsWith(r.name);
|
|
1026
|
+
let s = t.replace(r.name, "");
|
|
1027
1027
|
if (n) {
|
|
1028
1028
|
if (s.startsWith("/")) {
|
|
1029
|
-
const i =
|
|
1029
|
+
const i = r.name;
|
|
1030
1030
|
return s = `.${s}`, {
|
|
1031
1031
|
pkgNameOrAlias: i,
|
|
1032
1032
|
expose: s,
|
|
1033
|
-
remote:
|
|
1033
|
+
remote: r
|
|
1034
1034
|
};
|
|
1035
1035
|
} else if (s === "")
|
|
1036
1036
|
return {
|
|
1037
|
-
pkgNameOrAlias:
|
|
1037
|
+
pkgNameOrAlias: r.name,
|
|
1038
1038
|
expose: ".",
|
|
1039
|
-
remote:
|
|
1039
|
+
remote: r
|
|
1040
1040
|
};
|
|
1041
1041
|
}
|
|
1042
|
-
const l =
|
|
1043
|
-
let a =
|
|
1044
|
-
if (
|
|
1042
|
+
const l = r.alias && t.startsWith(r.alias);
|
|
1043
|
+
let a = r.alias && t.replace(r.alias, "");
|
|
1044
|
+
if (r.alias && l) {
|
|
1045
1045
|
if (a && a.startsWith("/")) {
|
|
1046
|
-
const i =
|
|
1046
|
+
const i = r.alias;
|
|
1047
1047
|
return a = `.${a}`, {
|
|
1048
1048
|
pkgNameOrAlias: i,
|
|
1049
1049
|
expose: a,
|
|
1050
|
-
remote:
|
|
1050
|
+
remote: r
|
|
1051
1051
|
};
|
|
1052
1052
|
} else if (a === "")
|
|
1053
1053
|
return {
|
|
1054
|
-
pkgNameOrAlias:
|
|
1054
|
+
pkgNameOrAlias: r.alias,
|
|
1055
1055
|
expose: ".",
|
|
1056
|
-
remote:
|
|
1056
|
+
remote: r
|
|
1057
1057
|
};
|
|
1058
1058
|
}
|
|
1059
1059
|
}
|
|
1060
1060
|
}
|
|
1061
|
-
function matchRemote(
|
|
1062
|
-
for (const
|
|
1063
|
-
if (t ===
|
|
1064
|
-
return
|
|
1061
|
+
function matchRemote(o, t) {
|
|
1062
|
+
for (const r of o)
|
|
1063
|
+
if (t === r.name || r.alias && t === r.alias)
|
|
1064
|
+
return r;
|
|
1065
1065
|
}
|
|
1066
|
-
function registerPlugins$1(
|
|
1067
|
-
const
|
|
1068
|
-
return
|
|
1069
|
-
|
|
1070
|
-
}),
|
|
1066
|
+
function registerPlugins$1(o, t) {
|
|
1067
|
+
const r = getGlobalHostPlugins();
|
|
1068
|
+
return r.length > 0 && r.forEach((n) => {
|
|
1069
|
+
o != null && o.find((s) => s.name !== n.name) && o.push(n);
|
|
1070
|
+
}), o && o.length > 0 && o.forEach((n) => {
|
|
1071
1071
|
t.forEach((s) => {
|
|
1072
1072
|
s.applyPlugin(n);
|
|
1073
1073
|
});
|
|
1074
|
-
}),
|
|
1074
|
+
}), o;
|
|
1075
1075
|
}
|
|
1076
|
-
async function loadEsmEntry({ entry:
|
|
1077
|
-
return new Promise((
|
|
1076
|
+
async function loadEsmEntry({ entry: o, remoteEntryExports: t }) {
|
|
1077
|
+
return new Promise((r, n) => {
|
|
1078
1078
|
try {
|
|
1079
|
-
t ?
|
|
1079
|
+
t ? r(t) : typeof FEDERATION_ALLOW_NEW_FUNCTION < "u" ? new Function("callbacks", `import("${o}").then(callbacks[0]).catch(callbacks[1])`)([
|
|
1080
|
+
r,
|
|
1081
|
+
n
|
|
1082
|
+
]) : import(
|
|
1080
1083
|
/* webpackIgnore: true */
|
|
1081
|
-
|
|
1082
|
-
).then(
|
|
1084
|
+
o
|
|
1085
|
+
).then(r).catch(n);
|
|
1083
1086
|
} catch (s) {
|
|
1084
1087
|
n(s);
|
|
1085
1088
|
}
|
|
1086
1089
|
});
|
|
1087
1090
|
}
|
|
1088
|
-
async function loadSystemJsEntry({ entry:
|
|
1089
|
-
return new Promise((
|
|
1091
|
+
async function loadSystemJsEntry({ entry: o, remoteEntryExports: t }) {
|
|
1092
|
+
return new Promise((r, n) => {
|
|
1090
1093
|
try {
|
|
1091
|
-
t ?
|
|
1092
|
-
|
|
1094
|
+
t ? r(t) : typeof __system_context__ > "u" ? System.import(o).then(r).catch(n) : new Function("callbacks", `System.import("${o}").then(callbacks[0]).catch(callbacks[1])`)([
|
|
1095
|
+
r,
|
|
1093
1096
|
n
|
|
1094
1097
|
]);
|
|
1095
1098
|
} catch (s) {
|
|
@@ -1097,9 +1100,9 @@ async function loadSystemJsEntry({ entry: r, remoteEntryExports: t }) {
|
|
|
1097
1100
|
}
|
|
1098
1101
|
});
|
|
1099
1102
|
}
|
|
1100
|
-
async function loadEntryScript({ name:
|
|
1101
|
-
const { entryExports: s } = getRemoteEntryExports(
|
|
1102
|
-
return s || loadScript(
|
|
1103
|
+
async function loadEntryScript({ name: o, globalName: t, entry: r, loaderHook: n }) {
|
|
1104
|
+
const { entryExports: s } = getRemoteEntryExports(o, t);
|
|
1105
|
+
return s || loadScript(r, {
|
|
1103
1106
|
attrs: {},
|
|
1104
1107
|
createScriptHook: (l, a) => {
|
|
1105
1108
|
const i = n.lifecycle.createScript.emit({
|
|
@@ -1110,18 +1113,18 @@ async function loadEntryScript({ name: r, globalName: t, entry: o, loaderHook: n
|
|
|
1110
1113
|
return i;
|
|
1111
1114
|
}
|
|
1112
1115
|
}).then(() => {
|
|
1113
|
-
const { remoteEntryKey: l, entryExports: a } = getRemoteEntryExports(
|
|
1116
|
+
const { remoteEntryKey: l, entryExports: a } = getRemoteEntryExports(o, t);
|
|
1114
1117
|
return assert(a, getShortErrorMsg(RUNTIME_001, runtimeDescMap, {
|
|
1115
|
-
remoteName:
|
|
1116
|
-
remoteEntryUrl:
|
|
1118
|
+
remoteName: o,
|
|
1119
|
+
remoteEntryUrl: r,
|
|
1117
1120
|
remoteEntryKey: l
|
|
1118
1121
|
})), a;
|
|
1119
1122
|
}).catch((l) => {
|
|
1120
1123
|
throw l;
|
|
1121
1124
|
});
|
|
1122
1125
|
}
|
|
1123
|
-
async function loadEntryDom({ remoteInfo:
|
|
1124
|
-
const { entry: n, entryGlobalName: s, name: l, type: a } =
|
|
1126
|
+
async function loadEntryDom({ remoteInfo: o, remoteEntryExports: t, loaderHook: r }) {
|
|
1127
|
+
const { entry: n, entryGlobalName: s, name: l, type: a } = o;
|
|
1125
1128
|
switch (a) {
|
|
1126
1129
|
case "esm":
|
|
1127
1130
|
case "module":
|
|
@@ -1139,13 +1142,13 @@ async function loadEntryDom({ remoteInfo: r, remoteEntryExports: t, loaderHook:
|
|
|
1139
1142
|
entry: n,
|
|
1140
1143
|
globalName: s,
|
|
1141
1144
|
name: l,
|
|
1142
|
-
loaderHook:
|
|
1145
|
+
loaderHook: r
|
|
1143
1146
|
});
|
|
1144
1147
|
}
|
|
1145
1148
|
}
|
|
1146
|
-
async function loadEntryNode({ remoteInfo:
|
|
1147
|
-
const { entry:
|
|
1148
|
-
return a || loadScriptNode(
|
|
1149
|
+
async function loadEntryNode({ remoteInfo: o, loaderHook: t }) {
|
|
1150
|
+
const { entry: r, entryGlobalName: n, name: s, type: l } = o, { entryExports: a } = getRemoteEntryExports(s, n);
|
|
1151
|
+
return a || loadScriptNode(r, {
|
|
1149
1152
|
attrs: {
|
|
1150
1153
|
name: s,
|
|
1151
1154
|
globalName: n,
|
|
@@ -1165,46 +1168,44 @@ async function loadEntryNode({ remoteInfo: r, loaderHook: t }) {
|
|
|
1165
1168
|
const { remoteEntryKey: i, entryExports: c } = getRemoteEntryExports(s, n);
|
|
1166
1169
|
return assert(c, getShortErrorMsg(RUNTIME_001, runtimeDescMap, {
|
|
1167
1170
|
remoteName: s,
|
|
1168
|
-
remoteEntryUrl:
|
|
1171
|
+
remoteEntryUrl: r,
|
|
1169
1172
|
remoteEntryKey: i
|
|
1170
1173
|
})), c;
|
|
1171
1174
|
}).catch((i) => {
|
|
1172
1175
|
throw i;
|
|
1173
1176
|
});
|
|
1174
1177
|
}
|
|
1175
|
-
function getRemoteEntryUniqueKey(
|
|
1176
|
-
const { entry: t, name:
|
|
1177
|
-
return composeKeyWithSeparator(
|
|
1178
|
+
function getRemoteEntryUniqueKey(o) {
|
|
1179
|
+
const { entry: t, name: r } = o;
|
|
1180
|
+
return composeKeyWithSeparator(r, t);
|
|
1178
1181
|
}
|
|
1179
|
-
async function getRemoteEntry({ origin:
|
|
1180
|
-
const n = getRemoteEntryUniqueKey(
|
|
1182
|
+
async function getRemoteEntry({ origin: o, remoteEntryExports: t, remoteInfo: r }) {
|
|
1183
|
+
const n = getRemoteEntryUniqueKey(r);
|
|
1181
1184
|
if (t)
|
|
1182
1185
|
return t;
|
|
1183
1186
|
if (!globalLoading[n]) {
|
|
1184
|
-
const s =
|
|
1185
|
-
r.loaderHook.lifecycle.createScript;
|
|
1186
|
-
const l = r.loaderHook;
|
|
1187
|
+
const s = o.remoteHandler.hooks.lifecycle.loadEntry, l = o.loaderHook;
|
|
1187
1188
|
globalLoading[n] = s.emit({
|
|
1188
1189
|
loaderHook: l,
|
|
1189
|
-
remoteInfo:
|
|
1190
|
+
remoteInfo: r,
|
|
1190
1191
|
remoteEntryExports: t
|
|
1191
1192
|
}).then((a) => a || (isBrowserEnv() ? loadEntryDom({
|
|
1192
|
-
remoteInfo:
|
|
1193
|
+
remoteInfo: r,
|
|
1193
1194
|
remoteEntryExports: t,
|
|
1194
1195
|
loaderHook: l
|
|
1195
1196
|
}) : loadEntryNode({
|
|
1196
|
-
remoteInfo:
|
|
1197
|
+
remoteInfo: r,
|
|
1197
1198
|
loaderHook: l
|
|
1198
1199
|
})));
|
|
1199
1200
|
}
|
|
1200
1201
|
return globalLoading[n];
|
|
1201
1202
|
}
|
|
1202
|
-
function getRemoteInfo(
|
|
1203
|
-
return _extends$1({},
|
|
1204
|
-
entry: "entry" in
|
|
1205
|
-
type:
|
|
1206
|
-
entryGlobalName:
|
|
1207
|
-
shareScope:
|
|
1203
|
+
function getRemoteInfo(o) {
|
|
1204
|
+
return _extends$1({}, o, {
|
|
1205
|
+
entry: "entry" in o ? o.entry : "",
|
|
1206
|
+
type: o.type || DEFAULT_REMOTE_TYPE,
|
|
1207
|
+
entryGlobalName: o.entryGlobalName || o.name,
|
|
1208
|
+
shareScope: o.shareScope || DEFAULT_SCOPE
|
|
1208
1209
|
});
|
|
1209
1210
|
}
|
|
1210
1211
|
let Module = class {
|
|
@@ -1220,7 +1221,7 @@ let Module = class {
|
|
|
1220
1221
|
${safeToString(this.remoteInfo)}`), this.remoteEntryExports = t, this.remoteEntryExports;
|
|
1221
1222
|
}
|
|
1222
1223
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1223
|
-
async get(t,
|
|
1224
|
+
async get(t, r, n, s) {
|
|
1224
1225
|
const { loadFactory: l = !0 } = n || {
|
|
1225
1226
|
loadFactory: !0
|
|
1226
1227
|
}, a = await this.getEntry();
|
|
@@ -1257,13 +1258,13 @@ let Module = class {
|
|
|
1257
1258
|
let i;
|
|
1258
1259
|
i = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
|
|
1259
1260
|
remoteEntryExports: a,
|
|
1260
|
-
expose:
|
|
1261
|
+
expose: r,
|
|
1261
1262
|
moduleInfo: this.remoteInfo
|
|
1262
|
-
}), i || (i = await a.get(
|
|
1263
|
-
const c = processModuleAlias(this.remoteInfo.name,
|
|
1263
|
+
}), i || (i = await a.get(r)), assert(i, `${getFMId(this.remoteInfo)} remote don't export ${r}.`);
|
|
1264
|
+
const c = processModuleAlias(this.remoteInfo.name, r), u = this.wraperFactory(i, c);
|
|
1264
1265
|
return l ? await u() : u;
|
|
1265
1266
|
}
|
|
1266
|
-
wraperFactory(t,
|
|
1267
|
+
wraperFactory(t, r) {
|
|
1267
1268
|
function n(s, l) {
|
|
1268
1269
|
s && typeof s == "object" && Object.isExtensible(s) && !Object.getOwnPropertyDescriptor(s, Symbol.for("mf_module_id")) && Object.defineProperty(s, Symbol.for("mf_module_id"), {
|
|
1269
1270
|
value: l,
|
|
@@ -1272,14 +1273,14 @@ let Module = class {
|
|
|
1272
1273
|
}
|
|
1273
1274
|
return t instanceof Promise ? async () => {
|
|
1274
1275
|
const s = await t();
|
|
1275
|
-
return n(s,
|
|
1276
|
+
return n(s, r), s;
|
|
1276
1277
|
} : () => {
|
|
1277
1278
|
const s = t();
|
|
1278
|
-
return n(s,
|
|
1279
|
+
return n(s, r), s;
|
|
1279
1280
|
};
|
|
1280
1281
|
}
|
|
1281
|
-
constructor({ remoteInfo: t, host:
|
|
1282
|
-
this.inited = !1, this.lib = void 0, this.remoteInfo = t, this.host =
|
|
1282
|
+
constructor({ remoteInfo: t, host: r }) {
|
|
1283
|
+
this.inited = !1, this.lib = void 0, this.remoteInfo = t, this.host = r;
|
|
1283
1284
|
}
|
|
1284
1285
|
};
|
|
1285
1286
|
class SyncHook {
|
|
@@ -1287,16 +1288,16 @@ class SyncHook {
|
|
|
1287
1288
|
typeof t == "function" && this.listeners.add(t);
|
|
1288
1289
|
}
|
|
1289
1290
|
once(t) {
|
|
1290
|
-
const
|
|
1291
|
+
const r = this;
|
|
1291
1292
|
this.on(function n(...s) {
|
|
1292
|
-
return
|
|
1293
|
+
return r.remove(n), t.apply(null, s);
|
|
1293
1294
|
});
|
|
1294
1295
|
}
|
|
1295
1296
|
emit(...t) {
|
|
1296
|
-
let
|
|
1297
|
+
let r;
|
|
1297
1298
|
return this.listeners.size > 0 && this.listeners.forEach((n) => {
|
|
1298
|
-
|
|
1299
|
-
}),
|
|
1299
|
+
r = n(...t);
|
|
1300
|
+
}), r;
|
|
1300
1301
|
}
|
|
1301
1302
|
remove(t) {
|
|
1302
1303
|
this.listeners.delete(t);
|
|
@@ -1310,22 +1311,22 @@ class SyncHook {
|
|
|
1310
1311
|
}
|
|
1311
1312
|
class AsyncHook extends SyncHook {
|
|
1312
1313
|
emit(...t) {
|
|
1313
|
-
let
|
|
1314
|
+
let r;
|
|
1314
1315
|
const n = Array.from(this.listeners);
|
|
1315
1316
|
if (n.length > 0) {
|
|
1316
1317
|
let s = 0;
|
|
1317
1318
|
const l = (a) => a === !1 ? !1 : s < n.length ? Promise.resolve(n[s++].apply(null, t)).then(l) : a;
|
|
1318
|
-
|
|
1319
|
+
r = l();
|
|
1319
1320
|
}
|
|
1320
|
-
return Promise.resolve(
|
|
1321
|
+
return Promise.resolve(r);
|
|
1321
1322
|
}
|
|
1322
1323
|
}
|
|
1323
|
-
function checkReturnData(
|
|
1324
|
+
function checkReturnData(o, t) {
|
|
1324
1325
|
if (!isObject(t))
|
|
1325
1326
|
return !1;
|
|
1326
|
-
if (
|
|
1327
|
-
for (const
|
|
1328
|
-
if (!(
|
|
1327
|
+
if (o !== t) {
|
|
1328
|
+
for (const r in o)
|
|
1329
|
+
if (!(r in t))
|
|
1329
1330
|
return !1;
|
|
1330
1331
|
}
|
|
1331
1332
|
return !0;
|
|
@@ -1333,9 +1334,9 @@ function checkReturnData(r, t) {
|
|
|
1333
1334
|
class SyncWaterfallHook extends SyncHook {
|
|
1334
1335
|
emit(t) {
|
|
1335
1336
|
isObject(t) || error(`The data for the "${this.type}" hook should be an object.`);
|
|
1336
|
-
for (const
|
|
1337
|
+
for (const r of this.listeners)
|
|
1337
1338
|
try {
|
|
1338
|
-
const n =
|
|
1339
|
+
const n = r(t);
|
|
1339
1340
|
if (checkReturnData(t, n))
|
|
1340
1341
|
t = n;
|
|
1341
1342
|
else {
|
|
@@ -1354,14 +1355,14 @@ class SyncWaterfallHook extends SyncHook {
|
|
|
1354
1355
|
class AsyncWaterfallHook extends SyncHook {
|
|
1355
1356
|
emit(t) {
|
|
1356
1357
|
isObject(t) || error(`The response data for the "${this.type}" hook must be an object.`);
|
|
1357
|
-
const
|
|
1358
|
-
if (
|
|
1358
|
+
const r = Array.from(this.listeners);
|
|
1359
|
+
if (r.length > 0) {
|
|
1359
1360
|
let n = 0;
|
|
1360
1361
|
const s = (a) => (warn(a), this.onerror(a), t), l = (a) => {
|
|
1361
1362
|
if (checkReturnData(t, a)) {
|
|
1362
|
-
if (t = a, n <
|
|
1363
|
+
if (t = a, n < r.length)
|
|
1363
1364
|
try {
|
|
1364
|
-
return Promise.resolve(
|
|
1365
|
+
return Promise.resolve(r[n++](t)).then(l, s);
|
|
1365
1366
|
} catch (i) {
|
|
1366
1367
|
return s(i);
|
|
1367
1368
|
}
|
|
@@ -1380,59 +1381,59 @@ class AsyncWaterfallHook extends SyncHook {
|
|
|
1380
1381
|
class PluginSystem {
|
|
1381
1382
|
applyPlugin(t) {
|
|
1382
1383
|
assert(isPlainObject(t), "Plugin configuration is invalid.");
|
|
1383
|
-
const
|
|
1384
|
-
assert(
|
|
1384
|
+
const r = t.name;
|
|
1385
|
+
assert(r, "A name must be provided by the plugin."), this.registerPlugins[r] || (this.registerPlugins[r] = t, Object.keys(this.lifecycle).forEach((n) => {
|
|
1385
1386
|
const s = t[n];
|
|
1386
1387
|
s && this.lifecycle[n].on(s);
|
|
1387
1388
|
}));
|
|
1388
1389
|
}
|
|
1389
1390
|
removePlugin(t) {
|
|
1390
1391
|
assert(t, "A name is required.");
|
|
1391
|
-
const
|
|
1392
|
-
assert(
|
|
1393
|
-
n !== "name" && this.lifecycle[n].remove(
|
|
1392
|
+
const r = this.registerPlugins[t];
|
|
1393
|
+
assert(r, `The plugin "${t}" is not registered.`), Object.keys(r).forEach((n) => {
|
|
1394
|
+
n !== "name" && this.lifecycle[n].remove(r[n]);
|
|
1394
1395
|
});
|
|
1395
1396
|
}
|
|
1396
1397
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
1397
|
-
inherit({ lifecycle: t, registerPlugins:
|
|
1398
|
+
inherit({ lifecycle: t, registerPlugins: r }) {
|
|
1398
1399
|
Object.keys(t).forEach((n) => {
|
|
1399
1400
|
assert(!this.lifecycle[n], `The hook "${n}" has a conflict and cannot be inherited.`), this.lifecycle[n] = t[n];
|
|
1400
|
-
}), Object.keys(
|
|
1401
|
-
assert(!this.registerPlugins[n], `The plugin "${n}" has a conflict and cannot be inherited.`), this.applyPlugin(
|
|
1401
|
+
}), Object.keys(r).forEach((n) => {
|
|
1402
|
+
assert(!this.registerPlugins[n], `The plugin "${n}" has a conflict and cannot be inherited.`), this.applyPlugin(r[n]);
|
|
1402
1403
|
});
|
|
1403
1404
|
}
|
|
1404
1405
|
constructor(t) {
|
|
1405
1406
|
this.registerPlugins = {}, this.lifecycle = t, this.lifecycleKeys = Object.keys(t);
|
|
1406
1407
|
}
|
|
1407
1408
|
}
|
|
1408
|
-
function defaultPreloadArgs(
|
|
1409
|
+
function defaultPreloadArgs(o) {
|
|
1409
1410
|
return _extends$1({
|
|
1410
1411
|
resourceCategory: "sync",
|
|
1411
1412
|
share: !0,
|
|
1412
1413
|
depsRemote: !0,
|
|
1413
1414
|
prefetchInterface: !1
|
|
1414
|
-
},
|
|
1415
|
+
}, o);
|
|
1415
1416
|
}
|
|
1416
|
-
function formatPreloadArgs(
|
|
1417
|
-
return t.map((
|
|
1418
|
-
const n = matchRemote(
|
|
1419
|
-
return assert(n, `Unable to preload ${
|
|
1417
|
+
function formatPreloadArgs(o, t) {
|
|
1418
|
+
return t.map((r) => {
|
|
1419
|
+
const n = matchRemote(o, r.nameOrAlias);
|
|
1420
|
+
return assert(n, `Unable to preload ${r.nameOrAlias} as it is not included in ${!n && safeToString({
|
|
1420
1421
|
remoteInfo: n,
|
|
1421
|
-
remotes:
|
|
1422
|
+
remotes: o
|
|
1422
1423
|
})}`), {
|
|
1423
1424
|
remote: n,
|
|
1424
|
-
preloadConfig: defaultPreloadArgs(
|
|
1425
|
+
preloadConfig: defaultPreloadArgs(r)
|
|
1425
1426
|
};
|
|
1426
1427
|
});
|
|
1427
1428
|
}
|
|
1428
|
-
function normalizePreloadExposes(
|
|
1429
|
-
return
|
|
1429
|
+
function normalizePreloadExposes(o) {
|
|
1430
|
+
return o ? o.map((t) => t === "." ? t : t.startsWith("./") ? t.replace("./", "") : t) : [];
|
|
1430
1431
|
}
|
|
1431
|
-
function preloadAssets(
|
|
1432
|
-
const { cssAssets: s, jsAssetsWithoutEntry: l, entryAssets: a } =
|
|
1432
|
+
function preloadAssets(o, t, r, n = !0) {
|
|
1433
|
+
const { cssAssets: s, jsAssetsWithoutEntry: l, entryAssets: a } = r;
|
|
1433
1434
|
if (t.options.inBrowser) {
|
|
1434
1435
|
if (a.forEach((i) => {
|
|
1435
|
-
const { moduleInfo: c } = i, u = t.moduleCache.get(
|
|
1436
|
+
const { moduleInfo: c } = i, u = t.moduleCache.get(o.name);
|
|
1436
1437
|
getRemoteEntry(u ? {
|
|
1437
1438
|
origin: t,
|
|
1438
1439
|
remoteInfo: c,
|
|
@@ -1513,7 +1514,7 @@ function preloadAssets(r, t, o, n = !0) {
|
|
|
1513
1514
|
} else {
|
|
1514
1515
|
const i = {
|
|
1515
1516
|
fetchpriority: "high",
|
|
1516
|
-
type: (
|
|
1517
|
+
type: (o == null ? void 0 : o.type) === "module" ? "module" : "text/javascript"
|
|
1517
1518
|
};
|
|
1518
1519
|
l.forEach((c) => {
|
|
1519
1520
|
const { script: u, needAttach: d } = createScript({
|
|
@@ -1536,24 +1537,24 @@ function preloadAssets(r, t, o, n = !0) {
|
|
|
1536
1537
|
}
|
|
1537
1538
|
}
|
|
1538
1539
|
}
|
|
1539
|
-
function assignRemoteInfo(
|
|
1540
|
-
const
|
|
1541
|
-
|
|
1542
|
-
let n = getResourceUrl(t,
|
|
1543
|
-
!isBrowserEnv() && !n.startsWith("http") && (n = `https:${n}`),
|
|
1540
|
+
function assignRemoteInfo(o, t) {
|
|
1541
|
+
const r = getRemoteEntryInfoFromSnapshot(t);
|
|
1542
|
+
r.url || error(`The attribute remoteEntry of ${o.name} must not be undefined.`);
|
|
1543
|
+
let n = getResourceUrl(t, r.url);
|
|
1544
|
+
!isBrowserEnv() && !n.startsWith("http") && (n = `https:${n}`), o.type = r.type, o.entryGlobalName = r.globalName, o.entry = n, o.version = t.version, o.buildVersion = t.buildVersion;
|
|
1544
1545
|
}
|
|
1545
1546
|
function snapshotPlugin() {
|
|
1546
1547
|
return {
|
|
1547
1548
|
name: "snapshot-plugin",
|
|
1548
|
-
async afterResolve(
|
|
1549
|
-
const { remote: t, pkgNameOrAlias:
|
|
1549
|
+
async afterResolve(o) {
|
|
1550
|
+
const { remote: t, pkgNameOrAlias: r, expose: n, origin: s, remoteInfo: l } = o;
|
|
1550
1551
|
if (!isRemoteInfoWithEntry(t) || !isPureRemoteEntry(t)) {
|
|
1551
1552
|
const { remoteSnapshot: a, globalSnapshot: i } = await s.snapshotHandler.loadRemoteSnapshotInfo(t);
|
|
1552
1553
|
assignRemoteInfo(l, a);
|
|
1553
1554
|
const c = {
|
|
1554
1555
|
remote: t,
|
|
1555
1556
|
preloadConfig: {
|
|
1556
|
-
nameOrAlias:
|
|
1557
|
+
nameOrAlias: r,
|
|
1557
1558
|
exposes: [
|
|
1558
1559
|
n
|
|
1559
1560
|
],
|
|
@@ -1569,16 +1570,16 @@ function snapshotPlugin() {
|
|
|
1569
1570
|
remoteSnapshot: a,
|
|
1570
1571
|
globalSnapshot: i
|
|
1571
1572
|
});
|
|
1572
|
-
return u && preloadAssets(l, s, u, !1), _extends$1({},
|
|
1573
|
+
return u && preloadAssets(l, s, u, !1), _extends$1({}, o, {
|
|
1573
1574
|
remoteSnapshot: a
|
|
1574
1575
|
});
|
|
1575
1576
|
}
|
|
1576
|
-
return
|
|
1577
|
+
return o;
|
|
1577
1578
|
}
|
|
1578
1579
|
};
|
|
1579
1580
|
}
|
|
1580
|
-
function splitId(
|
|
1581
|
-
const t =
|
|
1581
|
+
function splitId(o) {
|
|
1582
|
+
const t = o.split(":");
|
|
1582
1583
|
return t.length === 1 ? {
|
|
1583
1584
|
name: t[0],
|
|
1584
1585
|
version: void 0
|
|
@@ -1590,33 +1591,33 @@ function splitId(r) {
|
|
|
1590
1591
|
version: t[2]
|
|
1591
1592
|
};
|
|
1592
1593
|
}
|
|
1593
|
-
function traverseModuleInfo(
|
|
1594
|
-
const a = getFMId(t), { value: i } = getInfoWithoutType(
|
|
1595
|
-
if (c && !isManifestProvider(c) && (
|
|
1594
|
+
function traverseModuleInfo(o, t, r, n, s = {}, l) {
|
|
1595
|
+
const a = getFMId(t), { value: i } = getInfoWithoutType(o, a), c = l || i;
|
|
1596
|
+
if (c && !isManifestProvider(c) && (r(c, t, n), c.remotesInfo)) {
|
|
1596
1597
|
const u = Object.keys(c.remotesInfo);
|
|
1597
1598
|
for (const d of u) {
|
|
1598
1599
|
if (s[d])
|
|
1599
1600
|
continue;
|
|
1600
1601
|
s[d] = !0;
|
|
1601
1602
|
const p = splitId(d), m = c.remotesInfo[d];
|
|
1602
|
-
traverseModuleInfo(
|
|
1603
|
+
traverseModuleInfo(o, {
|
|
1603
1604
|
name: p.name,
|
|
1604
1605
|
version: m.matchedVersion
|
|
1605
|
-
},
|
|
1606
|
+
}, r, !1, s, void 0);
|
|
1606
1607
|
}
|
|
1607
1608
|
}
|
|
1608
1609
|
}
|
|
1609
|
-
function generatePreloadAssets(
|
|
1610
|
-
const l = [], a = [], i = [], c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), { options: d } =
|
|
1611
|
-
if (traverseModuleInfo(n,
|
|
1610
|
+
function generatePreloadAssets(o, t, r, n, s) {
|
|
1611
|
+
const l = [], a = [], i = [], c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), { options: d } = o, { preloadConfig: p } = t, { depsRemote: m } = p;
|
|
1612
|
+
if (traverseModuleInfo(n, r, (g, E, I) => {
|
|
1612
1613
|
let v;
|
|
1613
1614
|
if (I)
|
|
1614
1615
|
v = p;
|
|
1615
1616
|
else if (Array.isArray(m)) {
|
|
1616
|
-
const
|
|
1617
|
-
if (!
|
|
1617
|
+
const T = m.find((w) => w.nameOrAlias === E.name || w.nameOrAlias === E.alias);
|
|
1618
|
+
if (!T)
|
|
1618
1619
|
return;
|
|
1619
|
-
v = defaultPreloadArgs(
|
|
1620
|
+
v = defaultPreloadArgs(T);
|
|
1620
1621
|
} else if (m === !0)
|
|
1621
1622
|
v = p;
|
|
1622
1623
|
else
|
|
@@ -1637,30 +1638,30 @@ function generatePreloadAssets(r, t, o, n, s) {
|
|
|
1637
1638
|
let b = "modules" in g ? g.modules : [];
|
|
1638
1639
|
const $ = normalizePreloadExposes(v.exposes);
|
|
1639
1640
|
if ($.length && "modules" in g) {
|
|
1640
|
-
var
|
|
1641
|
-
b = g == null || (
|
|
1641
|
+
var A;
|
|
1642
|
+
b = g == null || (A = g.modules) == null ? void 0 : A.reduce((T, w) => (($ == null ? void 0 : $.indexOf(w.moduleName)) !== -1 && T.push(w), T), []);
|
|
1642
1643
|
}
|
|
1643
|
-
function O(
|
|
1644
|
-
const
|
|
1645
|
-
return v.filter ?
|
|
1644
|
+
function O(T) {
|
|
1645
|
+
const w = T.map((P) => getResourceUrl(g, P));
|
|
1646
|
+
return v.filter ? w.filter(v.filter) : w;
|
|
1646
1647
|
}
|
|
1647
1648
|
if (b) {
|
|
1648
|
-
const
|
|
1649
|
-
for (let
|
|
1650
|
-
const
|
|
1651
|
-
|
|
1652
|
-
id:
|
|
1649
|
+
const T = b.length;
|
|
1650
|
+
for (let w = 0; w < T; w++) {
|
|
1651
|
+
const P = b[w], M = `${E.name}/${P.moduleName}`;
|
|
1652
|
+
o.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({
|
|
1653
|
+
id: P.moduleName === "." ? E.name : M,
|
|
1653
1654
|
name: E.name,
|
|
1654
1655
|
remoteSnapshot: g,
|
|
1655
1656
|
preloadConfig: v,
|
|
1656
1657
|
remote: E,
|
|
1657
|
-
origin:
|
|
1658
|
-
}), !getPreloaded(M) && (v.resourceCategory === "all" ? (l.push(...O(
|
|
1658
|
+
origin: o
|
|
1659
|
+
}), !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));
|
|
1659
1660
|
}
|
|
1660
1661
|
}
|
|
1661
1662
|
}, !0, {}, s), s.shared) {
|
|
1662
1663
|
const g = (E, I) => {
|
|
1663
|
-
const v = getRegisteredShare(
|
|
1664
|
+
const v = getRegisteredShare(o.shareScopeMap, I.sharedName, E, o.sharedHandler.hooks.lifecycle.resolveShare);
|
|
1664
1665
|
v && typeof v.lib == "function" && (I.assets.js.sync.forEach((S) => {
|
|
1665
1666
|
c.add(S);
|
|
1666
1667
|
}), I.assets.css.sync.forEach((S) => {
|
|
@@ -1690,8 +1691,8 @@ function generatePreloadAssets(r, t, o, n, s) {
|
|
|
1690
1691
|
const generatePreloadAssetsPlugin = function() {
|
|
1691
1692
|
return {
|
|
1692
1693
|
name: "generate-preload-assets-plugin",
|
|
1693
|
-
async generatePreloadAssets(
|
|
1694
|
-
const { origin: t, preloadOptions:
|
|
1694
|
+
async generatePreloadAssets(o) {
|
|
1695
|
+
const { origin: t, preloadOptions: r, remoteInfo: n, remote: s, globalSnapshot: l, remoteSnapshot: a } = o;
|
|
1695
1696
|
return isRemoteInfoWithEntry(s) && isPureRemoteEntry(s) ? {
|
|
1696
1697
|
cssAssets: [],
|
|
1697
1698
|
jsAssetsWithoutEntry: [],
|
|
@@ -1708,35 +1709,35 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1708
1709
|
}
|
|
1709
1710
|
}
|
|
1710
1711
|
]
|
|
1711
|
-
} : (assignRemoteInfo(n, a), generatePreloadAssets(t,
|
|
1712
|
+
} : (assignRemoteInfo(n, a), generatePreloadAssets(t, r, n, l, a));
|
|
1712
1713
|
}
|
|
1713
1714
|
};
|
|
1714
1715
|
};
|
|
1715
|
-
function getGlobalRemoteInfo(
|
|
1716
|
-
const
|
|
1716
|
+
function getGlobalRemoteInfo(o, t) {
|
|
1717
|
+
const r = getGlobalSnapshotInfoByModuleInfo({
|
|
1717
1718
|
name: t.options.name,
|
|
1718
1719
|
version: t.options.version
|
|
1719
|
-
}), n =
|
|
1720
|
+
}), n = r && "remotesInfo" in r && r.remotesInfo && getInfoWithoutType(r.remotesInfo, o.name).value;
|
|
1720
1721
|
return n && n.matchedVersion ? {
|
|
1721
|
-
hostGlobalSnapshot:
|
|
1722
|
+
hostGlobalSnapshot: r,
|
|
1722
1723
|
globalSnapshot: getGlobalSnapshot(),
|
|
1723
1724
|
remoteSnapshot: getGlobalSnapshotInfoByModuleInfo({
|
|
1724
|
-
name:
|
|
1725
|
+
name: o.name,
|
|
1725
1726
|
version: n.matchedVersion
|
|
1726
1727
|
})
|
|
1727
1728
|
} : {
|
|
1728
1729
|
hostGlobalSnapshot: void 0,
|
|
1729
1730
|
globalSnapshot: getGlobalSnapshot(),
|
|
1730
1731
|
remoteSnapshot: getGlobalSnapshotInfoByModuleInfo({
|
|
1731
|
-
name:
|
|
1732
|
-
version: "version" in
|
|
1732
|
+
name: o.name,
|
|
1733
|
+
version: "version" in o ? o.version : void 0
|
|
1733
1734
|
})
|
|
1734
1735
|
};
|
|
1735
1736
|
}
|
|
1736
1737
|
class SnapshotHandler {
|
|
1737
1738
|
async loadSnapshot(t) {
|
|
1738
|
-
const { options:
|
|
1739
|
-
options:
|
|
1739
|
+
const { options: r } = this.HostInstance, { hostGlobalSnapshot: n, remoteSnapshot: s, globalSnapshot: l } = this.getGlobalRemoteInfo(t), { remoteSnapshot: a, globalSnapshot: i } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1740
|
+
options: r,
|
|
1740
1741
|
moduleInfo: t,
|
|
1741
1742
|
hostGlobalSnapshot: n,
|
|
1742
1743
|
remoteSnapshot: s,
|
|
@@ -1749,9 +1750,9 @@ class SnapshotHandler {
|
|
|
1749
1750
|
}
|
|
1750
1751
|
// eslint-disable-next-line max-lines-per-function
|
|
1751
1752
|
async loadRemoteSnapshotInfo(t) {
|
|
1752
|
-
const { options:
|
|
1753
|
+
const { options: r } = this.HostInstance;
|
|
1753
1754
|
await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({
|
|
1754
|
-
options:
|
|
1755
|
+
options: r,
|
|
1755
1756
|
moduleInfo: t
|
|
1756
1757
|
});
|
|
1757
1758
|
let n = getGlobalSnapshotInfoByModuleInfo({
|
|
@@ -1770,7 +1771,7 @@ class SnapshotHandler {
|
|
|
1770
1771
|
}
|
|
1771
1772
|
}));
|
|
1772
1773
|
const { hostGlobalSnapshot: s, remoteSnapshot: l, globalSnapshot: a } = this.getGlobalRemoteInfo(t), { remoteSnapshot: i, globalSnapshot: c } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1773
|
-
options:
|
|
1774
|
+
options: r,
|
|
1774
1775
|
moduleInfo: t,
|
|
1775
1776
|
hostGlobalSnapshot: s,
|
|
1776
1777
|
remoteSnapshot: l,
|
|
@@ -1809,7 +1810,7 @@ class SnapshotHandler {
|
|
|
1809
1810
|
globalSnapshot: JSON.stringify(c)
|
|
1810
1811
|
}));
|
|
1811
1812
|
return await this.hooks.lifecycle.afterLoadSnapshot.emit({
|
|
1812
|
-
options:
|
|
1813
|
+
options: r,
|
|
1813
1814
|
moduleInfo: t,
|
|
1814
1815
|
remoteSnapshot: u
|
|
1815
1816
|
}), {
|
|
@@ -1820,7 +1821,7 @@ class SnapshotHandler {
|
|
|
1820
1821
|
getGlobalRemoteInfo(t) {
|
|
1821
1822
|
return getGlobalRemoteInfo(t, this.HostInstance);
|
|
1822
1823
|
}
|
|
1823
|
-
async getManifestJson(t,
|
|
1824
|
+
async getManifestJson(t, r, n) {
|
|
1824
1825
|
const s = async () => {
|
|
1825
1826
|
let a = this.manifestCache.get(t);
|
|
1826
1827
|
if (a)
|
|
@@ -1831,7 +1832,7 @@ class SnapshotHandler {
|
|
|
1831
1832
|
} catch (i) {
|
|
1832
1833
|
delete this.manifestLoading[t], error(getShortErrorMsg(RUNTIME_003, runtimeDescMap, {
|
|
1833
1834
|
manifestUrl: t,
|
|
1834
|
-
moduleName:
|
|
1835
|
+
moduleName: r.name
|
|
1835
1836
|
}, `${i}`));
|
|
1836
1837
|
}
|
|
1837
1838
|
}, l = async () => {
|
|
@@ -1839,7 +1840,7 @@ class SnapshotHandler {
|
|
|
1839
1840
|
version: t
|
|
1840
1841
|
}), { remoteSnapshot: c } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1841
1842
|
options: this.HostInstance.options,
|
|
1842
|
-
moduleInfo:
|
|
1843
|
+
moduleInfo: r,
|
|
1843
1844
|
manifestJson: a,
|
|
1844
1845
|
remoteSnapshot: i,
|
|
1845
1846
|
manifestUrl: t,
|
|
@@ -1860,8 +1861,8 @@ class SnapshotHandler {
|
|
|
1860
1861
|
}
|
|
1861
1862
|
class SharedHandler {
|
|
1862
1863
|
// register shared in shareScopeMap
|
|
1863
|
-
registerShared(t,
|
|
1864
|
-
const { shareInfos: n, shared: s } = formatShareConfigs(t,
|
|
1864
|
+
registerShared(t, r) {
|
|
1865
|
+
const { shareInfos: n, shared: s } = formatShareConfigs(t, r);
|
|
1865
1866
|
return Object.keys(n).forEach((a) => {
|
|
1866
1867
|
n[a].forEach((c) => {
|
|
1867
1868
|
!getRegisteredShare(this.shareScopeMap, a, c, this.hooks.lifecycle.resolveShare) && c && c.lib && this.setShared({
|
|
@@ -1870,7 +1871,7 @@ class SharedHandler {
|
|
|
1870
1871
|
get: c.get,
|
|
1871
1872
|
loaded: !0,
|
|
1872
1873
|
shared: c,
|
|
1873
|
-
from:
|
|
1874
|
+
from: r.name
|
|
1874
1875
|
});
|
|
1875
1876
|
});
|
|
1876
1877
|
}), {
|
|
@@ -1878,10 +1879,10 @@ class SharedHandler {
|
|
|
1878
1879
|
shared: s
|
|
1879
1880
|
};
|
|
1880
1881
|
}
|
|
1881
|
-
async loadShare(t,
|
|
1882
|
+
async loadShare(t, r) {
|
|
1882
1883
|
const { host: n } = this, s = getTargetSharedOptions({
|
|
1883
1884
|
pkgName: t,
|
|
1884
|
-
extraOptions:
|
|
1885
|
+
extraOptions: r,
|
|
1885
1886
|
shareInfos: n.options.shared
|
|
1886
1887
|
});
|
|
1887
1888
|
s != null && s.scope && await Promise.all(s.scope.map(async (u) => {
|
|
@@ -1920,7 +1921,7 @@ class SharedHandler {
|
|
|
1920
1921
|
loading: d
|
|
1921
1922
|
}), d;
|
|
1922
1923
|
} else {
|
|
1923
|
-
if (
|
|
1924
|
+
if (r != null && r.customShareInfo)
|
|
1924
1925
|
return !1;
|
|
1925
1926
|
const d = (async () => {
|
|
1926
1927
|
const p = await a.get();
|
|
@@ -1944,9 +1945,9 @@ class SharedHandler {
|
|
|
1944
1945
|
* If the share scope does not exist, it creates one.
|
|
1945
1946
|
*/
|
|
1946
1947
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
1947
|
-
initializeSharing(t = DEFAULT_SCOPE,
|
|
1948
|
-
const { host: n } = this, s =
|
|
1949
|
-
let a =
|
|
1948
|
+
initializeSharing(t = DEFAULT_SCOPE, r) {
|
|
1949
|
+
const { host: n } = this, s = r == null ? void 0 : r.from, l = r == null ? void 0 : r.strategy;
|
|
1950
|
+
let a = r == null ? void 0 : r.initScope;
|
|
1950
1951
|
const i = [];
|
|
1951
1952
|
if (s !== "build") {
|
|
1952
1953
|
const { initTokens: _ } = this;
|
|
@@ -1998,10 +1999,10 @@ class SharedHandler {
|
|
|
1998
1999
|
// 1. If the loaded shared already exists globally, then it will be reused
|
|
1999
2000
|
// 2. If lib exists in local shared, it will be used directly
|
|
2000
2001
|
// 3. If the local get returns something other than Promise, then it will be used directly
|
|
2001
|
-
loadShareSync(t,
|
|
2002
|
+
loadShareSync(t, r) {
|
|
2002
2003
|
const { host: n } = this, s = getTargetSharedOptions({
|
|
2003
2004
|
pkgName: t,
|
|
2004
|
-
extraOptions:
|
|
2005
|
+
extraOptions: r,
|
|
2005
2006
|
shareInfos: n.options.shared
|
|
2006
2007
|
});
|
|
2007
2008
|
s != null && s.scope && s.scope.forEach((i) => {
|
|
@@ -2032,7 +2033,7 @@ class SharedHandler {
|
|
|
2032
2033
|
if (s.get) {
|
|
2033
2034
|
const i = s.get();
|
|
2034
2035
|
if (i instanceof Promise) {
|
|
2035
|
-
const c = (
|
|
2036
|
+
const c = (r == null ? void 0 : r.from) === "build" ? RUNTIME_005 : RUNTIME_006;
|
|
2036
2037
|
throw new Error(getShortErrorMsg(c, runtimeDescMap, {
|
|
2037
2038
|
hostName: n.options.name,
|
|
2038
2039
|
sharedPkgName: t
|
|
@@ -2051,18 +2052,18 @@ class SharedHandler {
|
|
|
2051
2052
|
sharedPkgName: t
|
|
2052
2053
|
}));
|
|
2053
2054
|
}
|
|
2054
|
-
initShareScopeMap(t,
|
|
2055
|
+
initShareScopeMap(t, r, n = {}) {
|
|
2055
2056
|
const { host: s } = this;
|
|
2056
|
-
this.shareScopeMap[t] =
|
|
2057
|
-
shareScope:
|
|
2057
|
+
this.shareScopeMap[t] = r, this.hooks.lifecycle.initContainerShareScopeMap.emit({
|
|
2058
|
+
shareScope: r,
|
|
2058
2059
|
options: s.options,
|
|
2059
2060
|
origin: s,
|
|
2060
2061
|
scopeName: t,
|
|
2061
2062
|
hostShareScopeMap: n.hostShareScopeMap
|
|
2062
2063
|
});
|
|
2063
2064
|
}
|
|
2064
|
-
setShared({ pkgName: t, shared:
|
|
2065
|
-
const { version: c, scope: u = "default" } =
|
|
2065
|
+
setShared({ pkgName: t, shared: r, from: n, lib: s, loading: l, loaded: a, get: i }) {
|
|
2066
|
+
const { version: c, scope: u = "default" } = r, d = _object_without_properties_loose(r, [
|
|
2066
2067
|
"version",
|
|
2067
2068
|
"scope"
|
|
2068
2069
|
]);
|
|
@@ -2087,8 +2088,8 @@ class SharedHandler {
|
|
|
2087
2088
|
});
|
|
2088
2089
|
}
|
|
2089
2090
|
_setGlobalShareScopeMap(t) {
|
|
2090
|
-
const
|
|
2091
|
-
n && !
|
|
2091
|
+
const r = getGlobalShareScope(), n = t.id || t.name;
|
|
2092
|
+
n && !r[n] && (r[n] = this.shareScopeMap);
|
|
2092
2093
|
}
|
|
2093
2094
|
constructor(t) {
|
|
2094
2095
|
this.hooks = new PluginSystem({
|
|
@@ -2103,13 +2104,13 @@ class SharedHandler {
|
|
|
2103
2104
|
}
|
|
2104
2105
|
}
|
|
2105
2106
|
class RemoteHandler {
|
|
2106
|
-
formatAndRegisterRemote(t,
|
|
2107
|
-
return (
|
|
2107
|
+
formatAndRegisterRemote(t, r) {
|
|
2108
|
+
return (r.remotes || []).reduce((s, l) => (this.registerRemote(l, s, {
|
|
2108
2109
|
force: !1
|
|
2109
2110
|
}), s), t.remotes);
|
|
2110
2111
|
}
|
|
2111
|
-
setIdToRemoteMap(t,
|
|
2112
|
-
const { remote: n, expose: s } =
|
|
2112
|
+
setIdToRemoteMap(t, r) {
|
|
2113
|
+
const { remote: n, expose: s } = r, { name: l, alias: a } = n;
|
|
2113
2114
|
if (this.idToRemoteMap[t] = {
|
|
2114
2115
|
name: n.name,
|
|
2115
2116
|
expose: s
|
|
@@ -2131,14 +2132,14 @@ class RemoteHandler {
|
|
|
2131
2132
|
}
|
|
2132
2133
|
// eslint-disable-next-line max-lines-per-function
|
|
2133
2134
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
2134
|
-
async loadRemote(t,
|
|
2135
|
+
async loadRemote(t, r) {
|
|
2135
2136
|
const { host: n } = this;
|
|
2136
2137
|
try {
|
|
2137
|
-
const { loadFactory: s = !0 } =
|
|
2138
|
+
const { loadFactory: s = !0 } = r || {
|
|
2138
2139
|
loadFactory: !0
|
|
2139
2140
|
}, { module: l, moduleOptions: a, remoteMatchInfo: i } = await this.getRemoteModuleAndOptions({
|
|
2140
2141
|
id: t
|
|
2141
|
-
}), { pkgNameOrAlias: c, remote: u, expose: d, id: p, remoteSnapshot: m } = i, y = await l.get(p, d,
|
|
2142
|
+
}), { pkgNameOrAlias: c, remote: u, expose: d, id: p, remoteSnapshot: m } = i, y = await l.get(p, d, r, m), _ = await this.hooks.lifecycle.onLoad.emit({
|
|
2142
2143
|
id: p,
|
|
2143
2144
|
pkgNameOrAlias: c,
|
|
2144
2145
|
expose: d,
|
|
@@ -2151,7 +2152,7 @@ class RemoteHandler {
|
|
|
2151
2152
|
});
|
|
2152
2153
|
return this.setIdToRemoteMap(t, i), typeof _ == "function" ? _ : y;
|
|
2153
2154
|
} catch (s) {
|
|
2154
|
-
const { from: l = "runtime" } =
|
|
2155
|
+
const { from: l = "runtime" } = r || {
|
|
2155
2156
|
from: "runtime"
|
|
2156
2157
|
}, a = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2157
2158
|
id: t,
|
|
@@ -2167,81 +2168,81 @@ class RemoteHandler {
|
|
|
2167
2168
|
}
|
|
2168
2169
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
2169
2170
|
async preloadRemote(t) {
|
|
2170
|
-
const { host:
|
|
2171
|
+
const { host: r } = this;
|
|
2171
2172
|
await this.hooks.lifecycle.beforePreloadRemote.emit({
|
|
2172
2173
|
preloadOps: t,
|
|
2173
|
-
options:
|
|
2174
|
-
origin:
|
|
2174
|
+
options: r.options,
|
|
2175
|
+
origin: r
|
|
2175
2176
|
});
|
|
2176
|
-
const n = formatPreloadArgs(
|
|
2177
|
+
const n = formatPreloadArgs(r.options.remotes, t);
|
|
2177
2178
|
await Promise.all(n.map(async (s) => {
|
|
2178
|
-
const { remote: l } = s, a = getRemoteInfo(l), { globalSnapshot: i, remoteSnapshot: c } = await
|
|
2179
|
-
origin:
|
|
2179
|
+
const { remote: l } = s, a = getRemoteInfo(l), { globalSnapshot: i, remoteSnapshot: c } = await r.snapshotHandler.loadRemoteSnapshotInfo(l), u = await this.hooks.lifecycle.generatePreloadAssets.emit({
|
|
2180
|
+
origin: r,
|
|
2180
2181
|
preloadOptions: s,
|
|
2181
2182
|
remote: l,
|
|
2182
2183
|
remoteInfo: a,
|
|
2183
2184
|
globalSnapshot: i,
|
|
2184
2185
|
remoteSnapshot: c
|
|
2185
2186
|
});
|
|
2186
|
-
u && preloadAssets(a,
|
|
2187
|
+
u && preloadAssets(a, r, u);
|
|
2187
2188
|
}));
|
|
2188
2189
|
}
|
|
2189
|
-
registerRemotes(t,
|
|
2190
|
+
registerRemotes(t, r) {
|
|
2190
2191
|
const { host: n } = this;
|
|
2191
2192
|
t.forEach((s) => {
|
|
2192
2193
|
this.registerRemote(s, n.options.remotes, {
|
|
2193
|
-
force:
|
|
2194
|
+
force: r == null ? void 0 : r.force
|
|
2194
2195
|
});
|
|
2195
2196
|
});
|
|
2196
2197
|
}
|
|
2197
2198
|
async getRemoteModuleAndOptions(t) {
|
|
2198
|
-
const { host:
|
|
2199
|
+
const { host: r } = this, { id: n } = t;
|
|
2199
2200
|
let s;
|
|
2200
2201
|
try {
|
|
2201
2202
|
s = await this.hooks.lifecycle.beforeRequest.emit({
|
|
2202
2203
|
id: n,
|
|
2203
|
-
options:
|
|
2204
|
-
origin:
|
|
2204
|
+
options: r.options,
|
|
2205
|
+
origin: r
|
|
2205
2206
|
});
|
|
2206
2207
|
} catch (_) {
|
|
2207
2208
|
if (s = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2208
2209
|
id: n,
|
|
2209
|
-
options:
|
|
2210
|
-
origin:
|
|
2210
|
+
options: r.options,
|
|
2211
|
+
origin: r,
|
|
2211
2212
|
from: "runtime",
|
|
2212
2213
|
error: _,
|
|
2213
2214
|
lifecycle: "beforeRequest"
|
|
2214
2215
|
}), !s)
|
|
2215
2216
|
throw _;
|
|
2216
2217
|
}
|
|
2217
|
-
const { id: l } = s, a = matchRemoteWithNameAndExpose(
|
|
2218
|
+
const { id: l } = s, a = matchRemoteWithNameAndExpose(r.options.remotes, l);
|
|
2218
2219
|
assert(a, getShortErrorMsg(RUNTIME_004, runtimeDescMap, {
|
|
2219
|
-
hostName:
|
|
2220
|
+
hostName: r.options.name,
|
|
2220
2221
|
requestId: l
|
|
2221
2222
|
}));
|
|
2222
|
-
const { remote: i } = a, c = getRemoteInfo(i), u = await
|
|
2223
|
+
const { remote: i } = a, c = getRemoteInfo(i), u = await r.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({
|
|
2223
2224
|
id: l
|
|
2224
2225
|
}, a, {
|
|
2225
|
-
options:
|
|
2226
|
-
origin:
|
|
2226
|
+
options: r.options,
|
|
2227
|
+
origin: r,
|
|
2227
2228
|
remoteInfo: c
|
|
2228
2229
|
})), { remote: d, expose: p } = u;
|
|
2229
2230
|
assert(d && p, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${l}.`);
|
|
2230
|
-
let m =
|
|
2231
|
+
let m = r.moduleCache.get(d.name);
|
|
2231
2232
|
const y = {
|
|
2232
|
-
host:
|
|
2233
|
+
host: r,
|
|
2233
2234
|
remoteInfo: c
|
|
2234
2235
|
};
|
|
2235
|
-
return m || (m = new Module(y),
|
|
2236
|
+
return m || (m = new Module(y), r.moduleCache.set(d.name, m)), {
|
|
2236
2237
|
module: m,
|
|
2237
2238
|
moduleOptions: y,
|
|
2238
2239
|
remoteMatchInfo: u
|
|
2239
2240
|
};
|
|
2240
2241
|
}
|
|
2241
|
-
registerRemote(t,
|
|
2242
|
+
registerRemote(t, r, n) {
|
|
2242
2243
|
const { host: s } = this, l = () => {
|
|
2243
2244
|
if (t.alias) {
|
|
2244
|
-
const i =
|
|
2245
|
+
const i = r.find((c) => {
|
|
2245
2246
|
var u;
|
|
2246
2247
|
return t.alias && (c.name.startsWith(t.alias) || ((u = c.alias) == null ? void 0 : u.startsWith(t.alias)));
|
|
2247
2248
|
});
|
|
@@ -2253,9 +2254,9 @@ class RemoteHandler {
|
|
|
2253
2254
|
remote: t,
|
|
2254
2255
|
origin: s
|
|
2255
2256
|
});
|
|
2256
|
-
const a =
|
|
2257
|
+
const a = r.find((i) => i.name === t.name);
|
|
2257
2258
|
if (!a)
|
|
2258
|
-
l(),
|
|
2259
|
+
l(), r.push(t), this.hooks.lifecycle.registerRemote.emit({
|
|
2259
2260
|
remote: t,
|
|
2260
2261
|
origin: s
|
|
2261
2262
|
});
|
|
@@ -2264,7 +2265,7 @@ class RemoteHandler {
|
|
|
2264
2265
|
`The remote "${t.name}" is already registered.`,
|
|
2265
2266
|
n != null && n.force ? "Hope you have known that OVERRIDE it may have some unexpected errors" : 'If you want to merge the remote, you can set "force: true".'
|
|
2266
2267
|
];
|
|
2267
|
-
n != null && n.force && (this.removeRemote(a), l(),
|
|
2268
|
+
n != null && n.force && (this.removeRemote(a), l(), r.push(t), this.hooks.lifecycle.registerRemote.emit({
|
|
2268
2269
|
remote: t,
|
|
2269
2270
|
origin: s
|
|
2270
2271
|
})), warn$1(i.join(" "));
|
|
@@ -2278,8 +2279,8 @@ class RemoteHandler {
|
|
|
2278
2279
|
if (a) {
|
|
2279
2280
|
const i = a.remoteInfo, c = i.entryGlobalName;
|
|
2280
2281
|
if (CurrentGlobal[c]) {
|
|
2281
|
-
var
|
|
2282
|
-
(
|
|
2282
|
+
var r;
|
|
2283
|
+
(r = Object.getOwnPropertyDescriptor(CurrentGlobal, c)) != null && r.configurable ? delete CurrentGlobal[c] : CurrentGlobal[c] = void 0;
|
|
2283
2284
|
}
|
|
2284
2285
|
const u = getRemoteEntryUniqueKey(a.remoteInfo);
|
|
2285
2286
|
globalLoading[u] && delete globalLoading[u], n.snapshotHandler.manifestCache.delete(i.entry);
|
|
@@ -2297,25 +2298,25 @@ class RemoteHandler {
|
|
|
2297
2298
|
const S = I[v];
|
|
2298
2299
|
S && Object.keys(S).forEach((b) => {
|
|
2299
2300
|
const $ = S[b];
|
|
2300
|
-
$ && Object.keys($).forEach((
|
|
2301
|
-
const O = $[
|
|
2302
|
-
O && typeof O == "object" && O.from === i.name && (O.loaded || O.loading ? (O.useIn = O.useIn.filter((
|
|
2301
|
+
$ && Object.keys($).forEach((A) => {
|
|
2302
|
+
const O = $[A];
|
|
2303
|
+
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([
|
|
2303
2304
|
E,
|
|
2304
2305
|
v,
|
|
2305
2306
|
b,
|
|
2306
|
-
|
|
2307
|
+
A
|
|
2307
2308
|
])) : g.push([
|
|
2308
2309
|
E,
|
|
2309
2310
|
v,
|
|
2310
2311
|
b,
|
|
2311
|
-
|
|
2312
|
+
A
|
|
2312
2313
|
]));
|
|
2313
2314
|
});
|
|
2314
2315
|
});
|
|
2315
2316
|
});
|
|
2316
2317
|
}), R && (y.shareScopeMap = {}, delete _[d]), g.forEach(([E, I, v, S]) => {
|
|
2317
|
-
var b, $,
|
|
2318
|
-
(
|
|
2318
|
+
var b, $, A;
|
|
2319
|
+
(A = _[E]) == null || ($ = A[I]) == null || (b = $[v]) == null || delete b[S];
|
|
2319
2320
|
}), CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(p, 1);
|
|
2320
2321
|
}
|
|
2321
2322
|
const { hostGlobalSnapshot: m } = getGlobalRemoteInfo(t, n);
|
|
@@ -2348,26 +2349,26 @@ class RemoteHandler {
|
|
|
2348
2349
|
class FederationHost {
|
|
2349
2350
|
initOptions(t) {
|
|
2350
2351
|
this.registerPlugins(t.plugins);
|
|
2351
|
-
const
|
|
2352
|
-
return this.options =
|
|
2352
|
+
const r = this.formatOptions(this.options, t);
|
|
2353
|
+
return this.options = r, r;
|
|
2353
2354
|
}
|
|
2354
|
-
async loadShare(t,
|
|
2355
|
-
return this.sharedHandler.loadShare(t,
|
|
2355
|
+
async loadShare(t, r) {
|
|
2356
|
+
return this.sharedHandler.loadShare(t, r);
|
|
2356
2357
|
}
|
|
2357
2358
|
// The lib function will only be available if the shared set by eager or runtime init is set or the shared is successfully loaded.
|
|
2358
2359
|
// 1. If the loaded shared already exists globally, then it will be reused
|
|
2359
2360
|
// 2. If lib exists in local shared, it will be used directly
|
|
2360
2361
|
// 3. If the local get returns something other than Promise, then it will be used directly
|
|
2361
|
-
loadShareSync(t,
|
|
2362
|
-
return this.sharedHandler.loadShareSync(t,
|
|
2362
|
+
loadShareSync(t, r) {
|
|
2363
|
+
return this.sharedHandler.loadShareSync(t, r);
|
|
2363
2364
|
}
|
|
2364
|
-
initializeSharing(t = DEFAULT_SCOPE,
|
|
2365
|
-
return this.sharedHandler.initializeSharing(t,
|
|
2365
|
+
initializeSharing(t = DEFAULT_SCOPE, r) {
|
|
2366
|
+
return this.sharedHandler.initializeSharing(t, r);
|
|
2366
2367
|
}
|
|
2367
|
-
initRawContainer(t,
|
|
2368
|
+
initRawContainer(t, r, n) {
|
|
2368
2369
|
const s = getRemoteInfo({
|
|
2369
2370
|
name: t,
|
|
2370
|
-
entry:
|
|
2371
|
+
entry: r
|
|
2371
2372
|
}), l = new Module({
|
|
2372
2373
|
host: this,
|
|
2373
2374
|
remoteInfo: s
|
|
@@ -2376,20 +2377,20 @@ class FederationHost {
|
|
|
2376
2377
|
}
|
|
2377
2378
|
// eslint-disable-next-line max-lines-per-function
|
|
2378
2379
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
2379
|
-
async loadRemote(t,
|
|
2380
|
-
return this.remoteHandler.loadRemote(t,
|
|
2380
|
+
async loadRemote(t, r) {
|
|
2381
|
+
return this.remoteHandler.loadRemote(t, r);
|
|
2381
2382
|
}
|
|
2382
2383
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
2383
2384
|
async preloadRemote(t) {
|
|
2384
2385
|
return this.remoteHandler.preloadRemote(t);
|
|
2385
2386
|
}
|
|
2386
|
-
initShareScopeMap(t,
|
|
2387
|
-
this.sharedHandler.initShareScopeMap(t,
|
|
2387
|
+
initShareScopeMap(t, r, n = {}) {
|
|
2388
|
+
this.sharedHandler.initShareScopeMap(t, r, n);
|
|
2388
2389
|
}
|
|
2389
|
-
formatOptions(t,
|
|
2390
|
-
const { shared: n } = formatShareConfigs(t,
|
|
2390
|
+
formatOptions(t, r) {
|
|
2391
|
+
const { shared: n } = formatShareConfigs(t, r), { userOptions: s, options: l } = this.hooks.lifecycle.beforeInit.emit({
|
|
2391
2392
|
origin: this,
|
|
2392
|
-
userOptions:
|
|
2393
|
+
userOptions: r,
|
|
2393
2394
|
options: t,
|
|
2394
2395
|
shareInfo: n
|
|
2395
2396
|
}), a = this.remoteHandler.formatAndRegisterRemote(l, s), { shared: i } = this.sharedHandler.registerShared(l, s), c = [
|
|
@@ -2398,7 +2399,7 @@ class FederationHost {
|
|
|
2398
2399
|
s.plugins && s.plugins.forEach((d) => {
|
|
2399
2400
|
c.includes(d) || c.push(d);
|
|
2400
2401
|
});
|
|
2401
|
-
const u = _extends$1({}, t,
|
|
2402
|
+
const u = _extends$1({}, t, r, {
|
|
2402
2403
|
plugins: c,
|
|
2403
2404
|
remotes: a,
|
|
2404
2405
|
shared: i
|
|
@@ -2409,7 +2410,7 @@ class FederationHost {
|
|
|
2409
2410
|
}), u;
|
|
2410
2411
|
}
|
|
2411
2412
|
registerPlugins(t) {
|
|
2412
|
-
const
|
|
2413
|
+
const r = registerPlugins$1(t, [
|
|
2413
2414
|
this.hooks,
|
|
2414
2415
|
this.remoteHandler.hooks,
|
|
2415
2416
|
this.sharedHandler.hooks,
|
|
@@ -2417,10 +2418,10 @@ class FederationHost {
|
|
|
2417
2418
|
this.loaderHook,
|
|
2418
2419
|
this.bridgeHook
|
|
2419
2420
|
]);
|
|
2420
|
-
this.options.plugins = this.options.plugins.reduce((n, s) => (s && n && !n.find((l) => l.name === s.name) && n.push(s), n),
|
|
2421
|
+
this.options.plugins = this.options.plugins.reduce((n, s) => (s && n && !n.find((l) => l.name === s.name) && n.push(s), n), r || []);
|
|
2421
2422
|
}
|
|
2422
|
-
registerRemotes(t,
|
|
2423
|
-
return this.remoteHandler.registerRemotes(t,
|
|
2423
|
+
registerRemotes(t, r) {
|
|
2424
|
+
return this.remoteHandler.registerRemotes(t, r);
|
|
2424
2425
|
}
|
|
2425
2426
|
constructor(t) {
|
|
2426
2427
|
this.hooks = new PluginSystem({
|
|
@@ -2430,7 +2431,7 @@ class FederationHost {
|
|
|
2430
2431
|
beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
|
|
2431
2432
|
// maybe will change, temporarily for internal use only
|
|
2432
2433
|
initContainer: new AsyncWaterfallHook("initContainer")
|
|
2433
|
-
}), this.version = "0.7.
|
|
2434
|
+
}), this.version = "0.7.6", this.moduleCache = /* @__PURE__ */ new Map(), this.loaderHook = new PluginSystem({
|
|
2434
2435
|
// FIXME: may not be suitable , not open to the public yet
|
|
2435
2436
|
getModuleInfo: new SyncHook(),
|
|
2436
2437
|
createScript: new SyncHook(),
|
|
@@ -2444,7 +2445,7 @@ class FederationHost {
|
|
|
2444
2445
|
beforeBridgeDestroy: new SyncHook(),
|
|
2445
2446
|
afterBridgeDestroy: new SyncHook()
|
|
2446
2447
|
});
|
|
2447
|
-
const
|
|
2448
|
+
const r = {
|
|
2448
2449
|
id: getBuilderId(),
|
|
2449
2450
|
name: t.name,
|
|
2450
2451
|
plugins: [
|
|
@@ -2455,47 +2456,47 @@ class FederationHost {
|
|
|
2455
2456
|
shared: {},
|
|
2456
2457
|
inBrowser: isBrowserEnv()
|
|
2457
2458
|
};
|
|
2458
|
-
this.name = t.name, this.options =
|
|
2459
|
-
...
|
|
2459
|
+
this.name = t.name, this.options = r, this.snapshotHandler = new SnapshotHandler(this), this.sharedHandler = new SharedHandler(this), this.remoteHandler = new RemoteHandler(this), this.shareScopeMap = this.sharedHandler.shareScopeMap, this.registerPlugins([
|
|
2460
|
+
...r.plugins,
|
|
2460
2461
|
...t.plugins || []
|
|
2461
|
-
]), this.options = this.formatOptions(
|
|
2462
|
+
]), this.options = this.formatOptions(r, t);
|
|
2462
2463
|
}
|
|
2463
2464
|
}
|
|
2464
2465
|
setGlobalFederationConstructor(FederationHost);
|
|
2465
|
-
function createBridgeComponent(
|
|
2466
|
+
function createBridgeComponent(o) {
|
|
2466
2467
|
const t = /* @__PURE__ */ new Map();
|
|
2467
2468
|
return () => ({
|
|
2468
|
-
__APP_VERSION__: "0.7.
|
|
2469
|
-
render(
|
|
2470
|
-
LoggerInstance.log("createBridgeComponent render Info",
|
|
2471
|
-
const n = Vue.createApp(
|
|
2472
|
-
t.set(
|
|
2473
|
-
const s = {}, l = s && typeof s == "object" && (s != null && s.extraProps) ? s == null ? void 0 : s.extraProps : {}, a =
|
|
2474
|
-
basename:
|
|
2475
|
-
memoryRoute:
|
|
2469
|
+
__APP_VERSION__: "0.7.6",
|
|
2470
|
+
render(r) {
|
|
2471
|
+
LoggerInstance.log("createBridgeComponent render Info", r);
|
|
2472
|
+
const n = Vue.createApp(o.rootComponent);
|
|
2473
|
+
t.set(r.dom, n);
|
|
2474
|
+
const s = {}, l = s && typeof s == "object" && (s != null && s.extraProps) ? s == null ? void 0 : s.extraProps : {}, a = o.appOptions({
|
|
2475
|
+
basename: r.basename,
|
|
2476
|
+
memoryRoute: r.memoryRoute,
|
|
2476
2477
|
...l
|
|
2477
|
-
}), i =
|
|
2478
|
+
}), i = r.memoryRoute ? VueRouter.createMemoryHistory(r.basename) : VueRouter.createWebHistory(r.basename), c = VueRouter.createRouter({
|
|
2478
2479
|
...a.router.options,
|
|
2479
2480
|
history: i,
|
|
2480
2481
|
routes: a.router.getRoutes()
|
|
2481
2482
|
});
|
|
2482
2483
|
LoggerInstance.log("createBridgeComponent render router info>>>", {
|
|
2483
|
-
name:
|
|
2484
|
+
name: r.moduleName,
|
|
2484
2485
|
router: c
|
|
2485
|
-
}),
|
|
2486
|
-
n.use(c), n.mount(
|
|
2487
|
-
}) : (n.use(c), n.mount(
|
|
2486
|
+
}), r.memoryRoute ? c.push(r.memoryRoute.entryPath).then(() => {
|
|
2487
|
+
n.use(c), n.mount(r.dom);
|
|
2488
|
+
}) : (n.use(c), n.mount(r.dom));
|
|
2488
2489
|
},
|
|
2489
|
-
destroy(
|
|
2490
|
-
LoggerInstance.log("createBridgeComponent destroy Info",
|
|
2491
|
-
const n = t.get(
|
|
2490
|
+
destroy(r) {
|
|
2491
|
+
LoggerInstance.log("createBridgeComponent destroy Info", r);
|
|
2492
|
+
const n = t.get(r == null ? void 0 : r.dom);
|
|
2492
2493
|
n == null || n.unmount();
|
|
2493
2494
|
}
|
|
2494
2495
|
});
|
|
2495
2496
|
}
|
|
2496
2497
|
function e() {
|
|
2497
|
-
const
|
|
2498
|
-
window.dispatchEvent(
|
|
2498
|
+
const o = new PopStateEvent("popstate", { state: window.history.state });
|
|
2499
|
+
window.dispatchEvent(o);
|
|
2499
2500
|
}
|
|
2500
2501
|
const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
2501
2502
|
name: "RemoteApp",
|
|
@@ -2505,16 +2506,16 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2505
2506
|
memoryRoute: Object,
|
|
2506
2507
|
providerInfo: Function
|
|
2507
2508
|
},
|
|
2508
|
-
setup(
|
|
2509
|
-
const t = ref(null),
|
|
2509
|
+
setup(o) {
|
|
2510
|
+
const t = ref(null), r = ref(null), n = ref(""), s = useRoute(), l = () => {
|
|
2510
2511
|
var d;
|
|
2511
|
-
const i = (d =
|
|
2512
|
-
|
|
2512
|
+
const i = (d = o.providerInfo) == null ? void 0 : d.call(o);
|
|
2513
|
+
r.value = i;
|
|
2513
2514
|
let c = {
|
|
2514
|
-
name:
|
|
2515
|
+
name: o.moduleName,
|
|
2515
2516
|
dom: t.value,
|
|
2516
|
-
basename:
|
|
2517
|
-
memoryRoute:
|
|
2517
|
+
basename: o.basename,
|
|
2518
|
+
memoryRoute: o.memoryRoute
|
|
2518
2519
|
};
|
|
2519
2520
|
LoggerInstance.log("createRemoteComponent LazyComponent render >>>", c), c = {
|
|
2520
2521
|
...c,
|
|
@@ -2522,7 +2523,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2522
2523
|
}, i.render(c);
|
|
2523
2524
|
}, a = watch(() => s.path, (i) => {
|
|
2524
2525
|
i !== s.path && l(), n.value !== "" && n.value !== i && (LoggerInstance.log("createRemoteComponent dispatchPopstateEnv >>>", {
|
|
2525
|
-
...
|
|
2526
|
+
...o,
|
|
2526
2527
|
pathname: s.path
|
|
2527
2528
|
}), e()), n.value = i;
|
|
2528
2529
|
});
|
|
@@ -2531,8 +2532,8 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2531
2532
|
}), onBeforeUnmount(() => {
|
|
2532
2533
|
var i;
|
|
2533
2534
|
LoggerInstance.log("createRemoteComponent LazyComponent destroy >>>", {
|
|
2534
|
-
...
|
|
2535
|
-
}), a(), (i =
|
|
2535
|
+
...o
|
|
2536
|
+
}), a(), (i = r.value) == null || i.destroy({
|
|
2536
2537
|
dom: t.value
|
|
2537
2538
|
});
|
|
2538
2539
|
}), () => createVNode("div", {
|
|
@@ -2540,33 +2541,33 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2540
2541
|
}, null);
|
|
2541
2542
|
}
|
|
2542
2543
|
});
|
|
2543
|
-
function createRemoteComponent(
|
|
2544
|
+
function createRemoteComponent(o) {
|
|
2544
2545
|
return defineAsyncComponent({
|
|
2545
|
-
__APP_VERSION__: "0.7.
|
|
2546
|
+
__APP_VERSION__: "0.7.6",
|
|
2546
2547
|
//@ts-ignore
|
|
2547
2548
|
loader: async () => {
|
|
2548
2549
|
var c;
|
|
2549
2550
|
const t = useRoute();
|
|
2550
|
-
let
|
|
2551
|
+
let r = "/";
|
|
2551
2552
|
const n = (c = t.matched[0]) == null ? void 0 : c.path;
|
|
2552
|
-
n && (n.endsWith("/:pathMatch(.*)*") ?
|
|
2553
|
-
const s = (
|
|
2553
|
+
n && (n.endsWith("/:pathMatch(.*)*") ? r = n.replace("/:pathMatch(.*)*", "") : r = t.matched[0].path);
|
|
2554
|
+
const s = (o == null ? void 0 : o.export) || "default";
|
|
2554
2555
|
LoggerInstance.log("createRemoteComponent LazyComponent create >>>", {
|
|
2555
|
-
basename:
|
|
2556
|
-
info:
|
|
2556
|
+
basename: r,
|
|
2557
|
+
info: o
|
|
2557
2558
|
});
|
|
2558
|
-
const l = await
|
|
2559
|
+
const l = await o.loader(), a = l && l[Symbol.for("mf_module_id")], i = l[s];
|
|
2559
2560
|
if (LoggerInstance.log(
|
|
2560
2561
|
"createRemoteComponent LazyComponent loadRemote info >>>",
|
|
2561
|
-
{ name: a, module: l, exportName: s, basename:
|
|
2562
|
+
{ name: a, module: l, exportName: s, basename: r, route: t }
|
|
2562
2563
|
), s in l && typeof i == "function")
|
|
2563
2564
|
return {
|
|
2564
2565
|
render() {
|
|
2565
2566
|
return h(RemoteApp, {
|
|
2566
2567
|
moduleName: a,
|
|
2567
|
-
...
|
|
2568
|
+
...o,
|
|
2568
2569
|
providerInfo: i,
|
|
2569
|
-
basename:
|
|
2570
|
+
basename: r
|
|
2570
2571
|
});
|
|
2571
2572
|
}
|
|
2572
2573
|
};
|