@module-federation/bridge-vue3 0.0.0-next-20250616123529 → 0.0.0-next-20250616203439
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -12
- package/dist/index.cjs +4 -4
- package/dist/index.js +661 -656
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -4,14 +4,14 @@ import * as VueRouter from "vue-router";
|
|
|
4
4
|
import { useRoute } from "vue-router";
|
|
5
5
|
function _extends$2() {
|
|
6
6
|
return _extends$2 = Object.assign || function(t) {
|
|
7
|
-
for (var
|
|
8
|
-
var
|
|
9
|
-
for (var s in
|
|
7
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
8
|
+
var o = arguments[r];
|
|
9
|
+
for (var s in o) Object.prototype.hasOwnProperty.call(o, s) && (t[s] = o[s]);
|
|
10
10
|
}
|
|
11
11
|
return t;
|
|
12
12
|
}, _extends$2.apply(this, arguments);
|
|
13
13
|
}
|
|
14
|
-
const MANIFEST_EXT = ".json", BROWSER_LOG_KEY = "FEDERATION_DEBUG", SEPARATOR = ":";
|
|
14
|
+
const MANIFEST_EXT = ".json", BROWSER_LOG_KEY = "FEDERATION_DEBUG", BROWSER_LOG_VALUE = "1", SEPARATOR = ":";
|
|
15
15
|
function isBrowserEnv() {
|
|
16
16
|
return typeof window < "u" && typeof window.document < "u";
|
|
17
17
|
}
|
|
@@ -22,7 +22,7 @@ function isReactNativeEnv() {
|
|
|
22
22
|
function isBrowserDebug() {
|
|
23
23
|
try {
|
|
24
24
|
if (isBrowserEnv() && window.localStorage)
|
|
25
|
-
return
|
|
25
|
+
return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE;
|
|
26
26
|
} catch {
|
|
27
27
|
return !1;
|
|
28
28
|
}
|
|
@@ -32,11 +32,11 @@ function isDebugMode() {
|
|
|
32
32
|
return typeof process < "u" && process.env && process.env.FEDERATION_DEBUG ? !!process.env.FEDERATION_DEBUG : typeof FEDERATION_DEBUG < "u" && FEDERATION_DEBUG ? !0 : isBrowserDebug();
|
|
33
33
|
}
|
|
34
34
|
const LOG_CATEGORY$1 = "[ Federation Runtime ]", composeKeyWithSeparator = function(...n) {
|
|
35
|
-
return n.length ? n.reduce((t,
|
|
35
|
+
return n.length ? n.reduce((t, r) => r ? t ? `${t}${SEPARATOR}${r}` : r : t, "") : "";
|
|
36
36
|
}, getResourceUrl = (n, t) => {
|
|
37
37
|
if ("getPublicPath" in n) {
|
|
38
|
-
let
|
|
39
|
-
return n.getPublicPath.startsWith("function") ?
|
|
38
|
+
let r;
|
|
39
|
+
return n.getPublicPath.startsWith("function") ? r = new Function("return " + n.getPublicPath)()() : r = new Function(n.getPublicPath)(), `${r}${t}`;
|
|
40
40
|
} else return "publicPath" in n ? !isBrowserEnv() && !isReactNativeEnv() && "ssrPublicPath" in n ? `${n.ssrPublicPath}${t}` : `${n.publicPath}${t}` : (console.warn("Cannot get resource URL. If in debug mode, please ignore.", n, t), "");
|
|
41
41
|
}, warn$1 = (n) => {
|
|
42
42
|
console.warn(`${LOG_CATEGORY$1}: ${n}`);
|
|
@@ -51,45 +51,45 @@ function safeToString(n) {
|
|
|
51
51
|
const simpleJoinRemoteEntry = (n, t) => {
|
|
52
52
|
if (!n)
|
|
53
53
|
return t;
|
|
54
|
-
const
|
|
54
|
+
const o = ((s) => {
|
|
55
55
|
if (s === ".")
|
|
56
56
|
return "";
|
|
57
57
|
if (s.startsWith("./"))
|
|
58
58
|
return s.replace("./", "");
|
|
59
59
|
if (s.startsWith("/")) {
|
|
60
|
-
const
|
|
61
|
-
return
|
|
60
|
+
const l = s.slice(1);
|
|
61
|
+
return l.endsWith("/") ? l.slice(0, -1) : l;
|
|
62
62
|
}
|
|
63
63
|
return s;
|
|
64
64
|
})(n);
|
|
65
|
-
return
|
|
65
|
+
return o ? o.endsWith("/") ? `${o}${t}` : `${o}/${t}` : t;
|
|
66
66
|
};
|
|
67
67
|
function inferAutoPublicPath(n) {
|
|
68
68
|
return n.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
|
|
69
69
|
}
|
|
70
70
|
function generateSnapshotFromManifest(n, t = {}) {
|
|
71
|
-
var
|
|
72
|
-
const { remotes: s = {}, overrides:
|
|
71
|
+
var r, o;
|
|
72
|
+
const { remotes: s = {}, overrides: l = {}, version: a } = t;
|
|
73
73
|
let i;
|
|
74
|
-
const c = () => "publicPath" in n.metaData ? n.metaData.publicPath === "auto" &&
|
|
74
|
+
const c = () => "publicPath" in n.metaData ? n.metaData.publicPath === "auto" && a ? inferAutoPublicPath(a) : n.metaData.publicPath : n.metaData.getPublicPath, u = Object.keys(l);
|
|
75
75
|
let p = {};
|
|
76
76
|
if (!Object.keys(s).length) {
|
|
77
77
|
var d;
|
|
78
78
|
p = ((d = n.remotes) == null ? void 0 : d.reduce((R, A) => {
|
|
79
79
|
let T;
|
|
80
80
|
const $ = A.federationContainerName;
|
|
81
|
-
return u.includes($) ? T =
|
|
81
|
+
return u.includes($) ? T = l[$] : "version" in A ? T = A.version : T = A.entry, R[$] = {
|
|
82
82
|
matchedVersion: T
|
|
83
83
|
}, R;
|
|
84
84
|
}, {})) || {};
|
|
85
85
|
}
|
|
86
86
|
Object.keys(s).forEach((R) => p[R] = {
|
|
87
87
|
// overrides will override dependencies
|
|
88
|
-
matchedVersion: u.includes(R) ?
|
|
88
|
+
matchedVersion: u.includes(R) ? l[R] : s[R]
|
|
89
89
|
});
|
|
90
90
|
const { remoteEntry: { path: m, name: y, type: g }, types: E, buildInfo: { buildVersion: _ }, globalName: b, ssrRemoteEntry: v } = n.metaData, { exposes: I } = n;
|
|
91
91
|
let S = {
|
|
92
|
-
version:
|
|
92
|
+
version: a || "",
|
|
93
93
|
buildVersion: _,
|
|
94
94
|
globalName: b,
|
|
95
95
|
remoteEntry: simpleJoinRemoteEntry(m, y),
|
|
@@ -109,13 +109,13 @@ function generateSnapshotFromManifest(n, t = {}) {
|
|
|
109
109
|
assets: R.assets
|
|
110
110
|
}))
|
|
111
111
|
};
|
|
112
|
-
if ((
|
|
112
|
+
if ((r = n.metaData) != null && r.prefetchInterface) {
|
|
113
113
|
const R = n.metaData.prefetchInterface;
|
|
114
114
|
S = _extends$2({}, S, {
|
|
115
115
|
prefetchInterface: R
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
|
-
if ((
|
|
118
|
+
if ((o = n.metaData) != null && o.prefetchEntry) {
|
|
119
119
|
const { path: R, name: A, type: T } = n.metaData.prefetchEntry;
|
|
120
120
|
S = _extends$2({}, S, {
|
|
121
121
|
prefetchEntry: simpleJoinRemoteEntry(R, A),
|
|
@@ -171,22 +171,22 @@ function createLogger(n) {
|
|
|
171
171
|
async function safeWrapper(n, t) {
|
|
172
172
|
try {
|
|
173
173
|
return await n();
|
|
174
|
-
} catch (
|
|
175
|
-
warn$1(
|
|
174
|
+
} catch (r) {
|
|
175
|
+
warn$1(r);
|
|
176
176
|
return;
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
function isStaticResourcesEqual(n, t) {
|
|
180
|
-
const
|
|
181
|
-
return
|
|
180
|
+
const r = /^(https?:)?\/\//i, o = n.replace(r, "").replace(/\/$/, ""), s = t.replace(r, "").replace(/\/$/, "");
|
|
181
|
+
return o === s;
|
|
182
182
|
}
|
|
183
183
|
function createScript(n) {
|
|
184
|
-
let t = null,
|
|
185
|
-
const
|
|
186
|
-
for (let i = 0; i <
|
|
187
|
-
const c =
|
|
184
|
+
let t = null, r = !0, o = 2e4, s;
|
|
185
|
+
const l = document.getElementsByTagName("script");
|
|
186
|
+
for (let i = 0; i < l.length; i++) {
|
|
187
|
+
const c = l[i], u = c.getAttribute("src");
|
|
188
188
|
if (u && isStaticResourcesEqual(u, n.url)) {
|
|
189
|
-
t = c,
|
|
189
|
+
t = c, r = !1;
|
|
190
190
|
break;
|
|
191
191
|
}
|
|
192
192
|
}
|
|
@@ -194,11 +194,11 @@ function createScript(n) {
|
|
|
194
194
|
const i = n.attrs;
|
|
195
195
|
t = document.createElement("script"), t.type = (i == null ? void 0 : i.type) === "module" ? "module" : "text/javascript";
|
|
196
196
|
let c;
|
|
197
|
-
n.createScriptHook && (c = n.createScriptHook(n.url, n.attrs), c instanceof HTMLScriptElement ? t = c : typeof c == "object" && ("script" in c && c.script && (t = c.script), "timeout" in c && c.timeout && (
|
|
197
|
+
n.createScriptHook && (c = n.createScriptHook(n.url, n.attrs), c instanceof HTMLScriptElement ? t = c : typeof c == "object" && ("script" in c && c.script && (t = c.script), "timeout" in c && c.timeout && (o = c.timeout))), t.src || (t.src = n.url), i && !c && Object.keys(i).forEach((u) => {
|
|
198
198
|
t && (u === "async" || u === "defer" ? t[u] = i[u] : t.getAttribute(u) || t.setAttribute(u, i[u]));
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
|
-
const
|
|
201
|
+
const a = async (i, c) => {
|
|
202
202
|
clearTimeout(s);
|
|
203
203
|
const u = () => {
|
|
204
204
|
(c == null ? void 0 : c.type) === "error" ? n != null && n.onErrorCallback && (n == null || n.onErrorCallback(c)) : n != null && n.cb && (n == null || n.cb());
|
|
@@ -216,77 +216,77 @@ function createScript(n) {
|
|
|
216
216
|
}
|
|
217
217
|
u();
|
|
218
218
|
};
|
|
219
|
-
return t.onerror =
|
|
220
|
-
|
|
221
|
-
},
|
|
219
|
+
return t.onerror = a.bind(null, t.onerror), t.onload = a.bind(null, t.onload), s = setTimeout(() => {
|
|
220
|
+
a(null, new Error(`Remote script "${n.url}" time-outed.`));
|
|
221
|
+
}, o), {
|
|
222
222
|
script: t,
|
|
223
|
-
needAttach:
|
|
223
|
+
needAttach: r
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
226
|
function createLink(n) {
|
|
227
|
-
let t = null,
|
|
228
|
-
const
|
|
229
|
-
for (let
|
|
230
|
-
const
|
|
227
|
+
let t = null, r = !0;
|
|
228
|
+
const o = document.getElementsByTagName("link");
|
|
229
|
+
for (let l = 0; l < o.length; l++) {
|
|
230
|
+
const a = o[l], i = a.getAttribute("href"), c = a.getAttribute("rel");
|
|
231
231
|
if (i && isStaticResourcesEqual(i, n.url) && c === n.attrs.rel) {
|
|
232
|
-
t =
|
|
232
|
+
t = a, r = !1;
|
|
233
233
|
break;
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
if (!t) {
|
|
237
237
|
t = document.createElement("link"), t.setAttribute("href", n.url);
|
|
238
|
-
let
|
|
239
|
-
const
|
|
240
|
-
n.createLinkHook && (
|
|
241
|
-
t && !t.getAttribute(i) && t.setAttribute(i,
|
|
238
|
+
let l;
|
|
239
|
+
const a = n.attrs;
|
|
240
|
+
n.createLinkHook && (l = n.createLinkHook(n.url, a), l instanceof HTMLLinkElement && (t = l)), a && !l && Object.keys(a).forEach((i) => {
|
|
241
|
+
t && !t.getAttribute(i) && t.setAttribute(i, a[i]);
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
|
-
const s = (
|
|
244
|
+
const s = (l, a) => {
|
|
245
245
|
const i = () => {
|
|
246
|
-
(
|
|
246
|
+
(a == null ? void 0 : a.type) === "error" ? n != null && n.onErrorCallback && (n == null || n.onErrorCallback(a)) : n != null && n.cb && (n == null || n.cb());
|
|
247
247
|
};
|
|
248
248
|
if (t && (t.onerror = null, t.onload = null, safeWrapper(() => {
|
|
249
249
|
const { needDeleteLink: c = !0 } = n;
|
|
250
250
|
c && t != null && t.parentNode && t.parentNode.removeChild(t);
|
|
251
|
-
}),
|
|
252
|
-
const c = a
|
|
251
|
+
}), l)) {
|
|
252
|
+
const c = l(a);
|
|
253
253
|
return i(), c;
|
|
254
254
|
}
|
|
255
255
|
i();
|
|
256
256
|
};
|
|
257
257
|
return t.onerror = s.bind(null, t.onerror), t.onload = s.bind(null, t.onload), {
|
|
258
258
|
link: t,
|
|
259
|
-
needAttach:
|
|
259
|
+
needAttach: r
|
|
260
260
|
};
|
|
261
261
|
}
|
|
262
262
|
function loadScript(n, t) {
|
|
263
|
-
const { attrs:
|
|
264
|
-
return new Promise((s,
|
|
265
|
-
const { script:
|
|
263
|
+
const { attrs: r = {}, createScriptHook: o } = t;
|
|
264
|
+
return new Promise((s, l) => {
|
|
265
|
+
const { script: a, needAttach: i } = createScript({
|
|
266
266
|
url: n,
|
|
267
267
|
cb: s,
|
|
268
|
-
onErrorCallback:
|
|
268
|
+
onErrorCallback: l,
|
|
269
269
|
attrs: _extends$2({
|
|
270
270
|
fetchpriority: "high"
|
|
271
|
-
},
|
|
272
|
-
createScriptHook:
|
|
271
|
+
}, r),
|
|
272
|
+
createScriptHook: o,
|
|
273
273
|
needDeleteScript: !0
|
|
274
274
|
});
|
|
275
|
-
i && document.head.appendChild(
|
|
275
|
+
i && document.head.appendChild(a);
|
|
276
276
|
});
|
|
277
277
|
}
|
|
278
278
|
function importNodeModule(n) {
|
|
279
279
|
if (!n)
|
|
280
280
|
throw new Error("import specifier is required");
|
|
281
|
-
return new Function("name", "return import(name)")(n).then((
|
|
282
|
-
throw console.error(`Error importing module ${n}:`,
|
|
281
|
+
return new Function("name", "return import(name)")(n).then((r) => r).catch((r) => {
|
|
282
|
+
throw console.error(`Error importing module ${n}:`, r), r;
|
|
283
283
|
});
|
|
284
284
|
}
|
|
285
285
|
const loadNodeFetch = async () => {
|
|
286
286
|
const n = await importNodeModule("node-fetch");
|
|
287
287
|
return n.default || n;
|
|
288
|
-
}, lazyLoaderHookFetch = async (n, t,
|
|
289
|
-
const s = await ((
|
|
288
|
+
}, lazyLoaderHookFetch = async (n, t, r) => {
|
|
289
|
+
const s = await ((l, a) => r.lifecycle.fetch.emit(l, a))(n, t || {});
|
|
290
290
|
return !s || !(s instanceof Response) ? (typeof fetch > "u" ? await loadNodeFetch() : fetch)(n, t || {}) : s;
|
|
291
291
|
}, createScriptNode = typeof ENV_TARGET > "u" || ENV_TARGET !== "web" ? (url, cb, attrs, loaderHook) => {
|
|
292
292
|
if (loaderHook != null && loaderHook.createScriptHook) {
|
|
@@ -344,66 +344,66 @@ const loadNodeFetch = async () => {
|
|
|
344
344
|
}).catch((n) => {
|
|
345
345
|
cb(n);
|
|
346
346
|
});
|
|
347
|
-
} : (n, t,
|
|
347
|
+
} : (n, t, r, o) => {
|
|
348
348
|
t(new Error("createScriptNode is disabled in non-Node.js environment"));
|
|
349
|
-
}, loadScriptNode = typeof ENV_TARGET > "u" || ENV_TARGET !== "web" ? (n, t) => new Promise((
|
|
350
|
-
createScriptNode(n, (s,
|
|
349
|
+
}, loadScriptNode = typeof ENV_TARGET > "u" || ENV_TARGET !== "web" ? (n, t) => new Promise((r, o) => {
|
|
350
|
+
createScriptNode(n, (s, l) => {
|
|
351
351
|
if (s)
|
|
352
|
-
|
|
352
|
+
o(s);
|
|
353
353
|
else {
|
|
354
|
-
var
|
|
355
|
-
const c = (t == null || (
|
|
356
|
-
|
|
354
|
+
var a, i;
|
|
355
|
+
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;
|
|
356
|
+
r(u);
|
|
357
357
|
}
|
|
358
358
|
}, t.attrs, t.loaderHook);
|
|
359
359
|
}) : (n, t) => {
|
|
360
360
|
throw new Error("loadScriptNode is disabled in non-Node.js environment");
|
|
361
361
|
};
|
|
362
362
|
async function loadModule(n, t) {
|
|
363
|
-
const { fetch:
|
|
363
|
+
const { fetch: r, vm: o } = t, l = await (await r(n)).text(), a = new o.SourceTextModule(l, {
|
|
364
364
|
// @ts-ignore
|
|
365
365
|
importModuleDynamically: async (i, c) => {
|
|
366
366
|
const u = new URL(i, n).href;
|
|
367
367
|
return loadModule(u, t);
|
|
368
368
|
}
|
|
369
369
|
});
|
|
370
|
-
return await
|
|
370
|
+
return await a.link(async (i) => {
|
|
371
371
|
const c = new URL(i, n).href;
|
|
372
372
|
return await loadModule(c, t);
|
|
373
|
-
}),
|
|
373
|
+
}), a;
|
|
374
374
|
}
|
|
375
375
|
const LoggerInstance = createLogger("[ Module Federation Bridge Vue3 ]");
|
|
376
376
|
function _extends$1() {
|
|
377
377
|
return _extends$1 = Object.assign || function(t) {
|
|
378
|
-
for (var
|
|
379
|
-
var
|
|
380
|
-
for (var s in
|
|
378
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
379
|
+
var o = arguments[r];
|
|
380
|
+
for (var s in o) Object.prototype.hasOwnProperty.call(o, s) && (t[s] = o[s]);
|
|
381
381
|
}
|
|
382
382
|
return t;
|
|
383
383
|
}, _extends$1.apply(this, arguments);
|
|
384
384
|
}
|
|
385
385
|
function _object_without_properties_loose(n, t) {
|
|
386
386
|
if (n == null) return {};
|
|
387
|
-
var
|
|
388
|
-
for (
|
|
389
|
-
s =
|
|
390
|
-
return
|
|
387
|
+
var r = {}, o = Object.keys(n), s, l;
|
|
388
|
+
for (l = 0; l < o.length; l++)
|
|
389
|
+
s = o[l], !(t.indexOf(s) >= 0) && (r[s] = n[s]);
|
|
390
|
+
return r;
|
|
391
391
|
}
|
|
392
|
-
const RUNTIME_001 = "RUNTIME-001", RUNTIME_002 = "RUNTIME-002", RUNTIME_003 = "RUNTIME-003", RUNTIME_004 = "RUNTIME-004", RUNTIME_005 = "RUNTIME-005", RUNTIME_006 = "RUNTIME-006", RUNTIME_007 = "RUNTIME-007", RUNTIME_008 = "RUNTIME-008", TYPE_001 = "TYPE-001", BUILD_001 = "BUILD-001", getDocsUrl = (n) => `View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${n.split("-")[0].toLowerCase()}/${n}`, getShortErrorMsg = (n, t,
|
|
392
|
+
const RUNTIME_001 = "RUNTIME-001", RUNTIME_002 = "RUNTIME-002", RUNTIME_003 = "RUNTIME-003", RUNTIME_004 = "RUNTIME-004", RUNTIME_005 = "RUNTIME-005", RUNTIME_006 = "RUNTIME-006", RUNTIME_007 = "RUNTIME-007", RUNTIME_008 = "RUNTIME-008", TYPE_001 = "TYPE-001", BUILD_001 = "BUILD-001", getDocsUrl = (n) => `View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${n.split("-")[0].toLowerCase()}/${n}`, getShortErrorMsg = (n, t, r, o) => {
|
|
393
393
|
const s = [
|
|
394
394
|
`${[
|
|
395
395
|
t[n]
|
|
396
396
|
]} #${n}`
|
|
397
397
|
];
|
|
398
|
-
return
|
|
399
|
-
${
|
|
398
|
+
return r && s.push(`args: ${JSON.stringify(r)}`), s.push(getDocsUrl(n)), o && s.push(`Original Error Message:
|
|
399
|
+
${o}`), s.join(`
|
|
400
400
|
`);
|
|
401
401
|
};
|
|
402
402
|
function _extends() {
|
|
403
403
|
return _extends = Object.assign || function(t) {
|
|
404
|
-
for (var
|
|
405
|
-
var
|
|
406
|
-
for (var s in
|
|
404
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
405
|
+
var o = arguments[r];
|
|
406
|
+
for (var s in o) Object.prototype.hasOwnProperty.call(o, s) && (t[s] = o[s]);
|
|
407
407
|
}
|
|
408
408
|
return t;
|
|
409
409
|
}, _extends.apply(this, arguments);
|
|
@@ -434,7 +434,7 @@ function warn(n) {
|
|
|
434
434
|
n instanceof Error && (n.message = `${LOG_CATEGORY}: ${n.message}`), logger.warn(n);
|
|
435
435
|
}
|
|
436
436
|
function addUniqueItem(n, t) {
|
|
437
|
-
return n.findIndex((
|
|
437
|
+
return n.findIndex((r) => r === t) === -1 && n.push(t), n;
|
|
438
438
|
}
|
|
439
439
|
function getFMId(n) {
|
|
440
440
|
return "version" in n && n.version ? `${n.name}:${n.version}` : "entry" in n && n.entry ? `${n.name}:${n.entry}` : `${n.name}`;
|
|
@@ -474,8 +474,8 @@ function getRemoteEntryInfoFromSnapshot(n) {
|
|
|
474
474
|
} : t;
|
|
475
475
|
}
|
|
476
476
|
const processModuleAlias = (n, t) => {
|
|
477
|
-
let
|
|
478
|
-
return n.endsWith("/") ?
|
|
477
|
+
let r;
|
|
478
|
+
return n.endsWith("/") ? r = n.slice(0, -1) : r = n, t.startsWith(".") && (t = t.slice(1)), r = r + t, r;
|
|
479
479
|
}, CurrentGlobal = typeof globalThis == "object" ? globalThis : window, nativeGlobal = (() => {
|
|
480
480
|
try {
|
|
481
481
|
return document.defaultView;
|
|
@@ -483,9 +483,9 @@ const processModuleAlias = (n, t) => {
|
|
|
483
483
|
return CurrentGlobal;
|
|
484
484
|
}
|
|
485
485
|
})(), Global = nativeGlobal;
|
|
486
|
-
function definePropertyGlobalVal(n, t,
|
|
486
|
+
function definePropertyGlobalVal(n, t, r) {
|
|
487
487
|
Object.defineProperty(n, t, {
|
|
488
|
-
value:
|
|
488
|
+
value: r,
|
|
489
489
|
configurable: !1,
|
|
490
490
|
writable: !0
|
|
491
491
|
});
|
|
@@ -496,7 +496,7 @@ function includeOwnProperty(n, t) {
|
|
|
496
496
|
includeOwnProperty(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__") || definePropertyGlobalVal(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});
|
|
497
497
|
const globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;
|
|
498
498
|
function setGlobalDefaultVal(n) {
|
|
499
|
-
var t,
|
|
499
|
+
var t, r, o, s, l, a;
|
|
500
500
|
includeOwnProperty(n, "__VMOK__") && !includeOwnProperty(n, "__FEDERATION__") && definePropertyGlobalVal(n, "__FEDERATION__", n.__VMOK__), includeOwnProperty(n, "__FEDERATION__") || (definePropertyGlobalVal(n, "__FEDERATION__", {
|
|
501
501
|
__GLOBAL_PLUGIN__: [],
|
|
502
502
|
__INSTANCES__: [],
|
|
@@ -508,20 +508,20 @@ function setGlobalDefaultVal(n) {
|
|
|
508
508
|
var i;
|
|
509
509
|
(i = (t = n.__FEDERATION__).__GLOBAL_PLUGIN__) != null || (t.__GLOBAL_PLUGIN__ = []);
|
|
510
510
|
var c;
|
|
511
|
-
(c = (
|
|
511
|
+
(c = (r = n.__FEDERATION__).__INSTANCES__) != null || (r.__INSTANCES__ = []);
|
|
512
512
|
var u;
|
|
513
|
-
(u = (
|
|
513
|
+
(u = (o = n.__FEDERATION__).moduleInfo) != null || (o.moduleInfo = {});
|
|
514
514
|
var p;
|
|
515
515
|
(p = (s = n.__FEDERATION__).__SHARE__) != null || (s.__SHARE__ = {});
|
|
516
516
|
var d;
|
|
517
|
-
(d = (
|
|
517
|
+
(d = (l = n.__FEDERATION__).__MANIFEST_LOADING__) != null || (l.__MANIFEST_LOADING__ = {});
|
|
518
518
|
var m;
|
|
519
|
-
(m = (
|
|
519
|
+
(m = (a = n.__FEDERATION__).__PRELOADED_MAP__) != null || (a.__PRELOADED_MAP__ = /* @__PURE__ */ new Map());
|
|
520
520
|
}
|
|
521
521
|
setGlobalDefaultVal(CurrentGlobal);
|
|
522
522
|
setGlobalDefaultVal(nativeGlobal);
|
|
523
523
|
function setGlobalFederationConstructor(n, t = isDebugMode()) {
|
|
524
|
-
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = n, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.
|
|
524
|
+
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = n, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.14.3");
|
|
525
525
|
}
|
|
526
526
|
function getInfoWithoutType(n, t) {
|
|
527
527
|
if (typeof t == "string") {
|
|
@@ -531,9 +531,9 @@ function getInfoWithoutType(n, t) {
|
|
|
531
531
|
key: t
|
|
532
532
|
};
|
|
533
533
|
{
|
|
534
|
-
const
|
|
535
|
-
for (const s of
|
|
536
|
-
const [
|
|
534
|
+
const o = Object.keys(n);
|
|
535
|
+
for (const s of o) {
|
|
536
|
+
const [l, a] = s.split(":"), i = `${l}:${t}`, c = n[i];
|
|
537
537
|
if (c)
|
|
538
538
|
return {
|
|
539
539
|
value: c,
|
|
@@ -549,28 +549,28 @@ function getInfoWithoutType(n, t) {
|
|
|
549
549
|
throw new Error("key must be string");
|
|
550
550
|
}
|
|
551
551
|
const getGlobalSnapshot = () => nativeGlobal.__FEDERATION__.moduleInfo, getTargetSnapshotInfoByModuleInfo = (n, t) => {
|
|
552
|
-
const
|
|
553
|
-
if (
|
|
554
|
-
return
|
|
552
|
+
const r = getFMId(n), o = getInfoWithoutType(t, r).value;
|
|
553
|
+
if (o && !o.version && "version" in n && n.version && (o.version = n.version), o)
|
|
554
|
+
return o;
|
|
555
555
|
if ("version" in n && n.version) {
|
|
556
|
-
const { version: s } = n,
|
|
556
|
+
const { version: s } = n, l = _object_without_properties_loose(n, [
|
|
557
557
|
"version"
|
|
558
|
-
]),
|
|
558
|
+
]), a = getFMId(l), i = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, a).value;
|
|
559
559
|
if ((i == null ? void 0 : i.version) === s)
|
|
560
560
|
return i;
|
|
561
561
|
}
|
|
562
562
|
}, getGlobalSnapshotInfoByModuleInfo = (n) => getTargetSnapshotInfoByModuleInfo(n, nativeGlobal.__FEDERATION__.moduleInfo), setGlobalSnapshotInfoByModuleInfo = (n, t) => {
|
|
563
|
-
const
|
|
564
|
-
return nativeGlobal.__FEDERATION__.moduleInfo[
|
|
563
|
+
const r = getFMId(n);
|
|
564
|
+
return nativeGlobal.__FEDERATION__.moduleInfo[r] = t, nativeGlobal.__FEDERATION__.moduleInfo;
|
|
565
565
|
}, addGlobalSnapshot = (n) => (nativeGlobal.__FEDERATION__.moduleInfo = _extends$1({}, nativeGlobal.__FEDERATION__.moduleInfo, n), () => {
|
|
566
566
|
const t = Object.keys(n);
|
|
567
|
-
for (const
|
|
568
|
-
delete nativeGlobal.__FEDERATION__.moduleInfo[
|
|
567
|
+
for (const r of t)
|
|
568
|
+
delete nativeGlobal.__FEDERATION__.moduleInfo[r];
|
|
569
569
|
}), getRemoteEntryExports = (n, t) => {
|
|
570
|
-
const
|
|
570
|
+
const r = t || `__FEDERATION_${n}:custom__`, o = CurrentGlobal[r];
|
|
571
571
|
return {
|
|
572
|
-
remoteEntryKey:
|
|
573
|
-
entryExports:
|
|
572
|
+
remoteEntryKey: r,
|
|
573
|
+
entryExports: o
|
|
574
574
|
};
|
|
575
575
|
}, getGlobalHostPlugins = () => nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__, getPreloaded = (n) => CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.get(n), setPreloaded = (n) => CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.set(n, !0), DEFAULT_SCOPE = "default", DEFAULT_REMOTE_TYPE = "global", buildIdentifier = "[0-9A-Za-z-]+", build = `(?:\\+(${buildIdentifier}(?:\\.${buildIdentifier})*))`, numericIdentifier = "0|[1-9]\\d*", numericIdentifierLoose = "[0-9]+", nonNumericIdentifier = "\\d*[a-zA-Z-][a-zA-Z0-9-]*", preReleaseIdentifierLoose = `(?:${numericIdentifierLoose}|${nonNumericIdentifier})`, preReleaseLoose = `(?:-?(${preReleaseIdentifierLoose}(?:\\.${preReleaseIdentifierLoose})*))`, preReleaseIdentifier = `(?:${numericIdentifier}|${nonNumericIdentifier})`, preRelease = `(?:-(${preReleaseIdentifier}(?:\\.${preReleaseIdentifier})*))`, xRangeIdentifier = `${numericIdentifier}|x|X|\\*`, xRangePlain = `[v=\\s]*(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:${preRelease})?${build}?)?)?`, hyphenRange = `^\\s*(${xRangePlain})\\s+-\\s+(${xRangePlain})\\s*$`, mainVersionLoose = `(${numericIdentifierLoose})\\.(${numericIdentifierLoose})\\.(${numericIdentifierLoose})`, loosePlain = `[v=\\s]*${mainVersionLoose}${preReleaseLoose}?${build}?`, gtlt = "((?:<|>)?=?)", comparatorTrim = `(\\s*)${gtlt}\\s*(${loosePlain}|${xRangePlain})`, loneTilde = "(?:~>?)", tildeTrim = `(\\s*)${loneTilde}\\s+`, loneCaret = "(?:\\^)", caretTrim = `(\\s*)${loneCaret}\\s+`, star = "(<|>)?=?\\s*\\*", caret = `^${loneCaret}${xRangePlain}$`, mainVersion = `(${numericIdentifier})\\.(${numericIdentifier})\\.(${numericIdentifier})`, fullPlain = `v?${mainVersion}${preRelease}?${build}?`, tilde = `^${loneTilde}${xRangePlain}$`, xRange = `^${gtlt}\\s*${xRangePlain}$`, comparator = `^${gtlt}\\s*(${fullPlain})$|^$`, gte0 = "^\\s*>=\\s*0.0.0\\s*$";
|
|
576
576
|
function parseRegex(n) {
|
|
@@ -580,17 +580,17 @@ function isXVersion(n) {
|
|
|
580
580
|
return !n || n.toLowerCase() === "x" || n === "*";
|
|
581
581
|
}
|
|
582
582
|
function pipe(...n) {
|
|
583
|
-
return (t) => n.reduce((
|
|
583
|
+
return (t) => n.reduce((r, o) => o(r), t);
|
|
584
584
|
}
|
|
585
585
|
function extractComparator(n) {
|
|
586
586
|
return n.match(parseRegex(comparator));
|
|
587
587
|
}
|
|
588
|
-
function combineVersion(n, t,
|
|
589
|
-
const s = `${n}.${t}.${
|
|
590
|
-
return
|
|
588
|
+
function combineVersion(n, t, r, o) {
|
|
589
|
+
const s = `${n}.${t}.${r}`;
|
|
590
|
+
return o ? `${s}-${o}` : s;
|
|
591
591
|
}
|
|
592
592
|
function parseHyphen(n) {
|
|
593
|
-
return n.replace(parseRegex(hyphenRange), (t,
|
|
593
|
+
return n.replace(parseRegex(hyphenRange), (t, r, o, s, l, a, i, c, u, p, d, m) => (isXVersion(o) ? r = "" : isXVersion(s) ? r = `>=${o}.0.0` : isXVersion(l) ? r = `>=${o}.${s}.0` : r = `>=${r}`, isXVersion(u) ? c = "" : isXVersion(p) ? c = `<${Number(u) + 1}.0.0-0` : isXVersion(d) ? c = `<${u}.${Number(p) + 1}.0-0` : m ? c = `<=${u}.${p}.${d}-${m}` : c = `<=${c}`, `${r} ${c}`.trim()));
|
|
594
594
|
}
|
|
595
595
|
function parseComparatorTrim(n) {
|
|
596
596
|
return n.replace(parseRegex(comparatorTrim), "$1$2$3");
|
|
@@ -602,15 +602,15 @@ function parseCaretTrim(n) {
|
|
|
602
602
|
return n.replace(parseRegex(caretTrim), "$1^");
|
|
603
603
|
}
|
|
604
604
|
function parseCarets(n) {
|
|
605
|
-
return n.trim().split(/\s+/).map((t) => t.replace(parseRegex(caret), (
|
|
605
|
+
return n.trim().split(/\s+/).map((t) => t.replace(parseRegex(caret), (r, o, s, l, a) => isXVersion(o) ? "" : isXVersion(s) ? `>=${o}.0.0 <${Number(o) + 1}.0.0-0` : isXVersion(l) ? o === "0" ? `>=${o}.${s}.0 <${o}.${Number(s) + 1}.0-0` : `>=${o}.${s}.0 <${Number(o) + 1}.0.0-0` : a ? o === "0" ? s === "0" ? `>=${o}.${s}.${l}-${a} <${o}.${s}.${Number(l) + 1}-0` : `>=${o}.${s}.${l}-${a} <${o}.${Number(s) + 1}.0-0` : `>=${o}.${s}.${l}-${a} <${Number(o) + 1}.0.0-0` : o === "0" ? s === "0" ? `>=${o}.${s}.${l} <${o}.${s}.${Number(l) + 1}-0` : `>=${o}.${s}.${l} <${o}.${Number(s) + 1}.0-0` : `>=${o}.${s}.${l} <${Number(o) + 1}.0.0-0`)).join(" ");
|
|
606
606
|
}
|
|
607
607
|
function parseTildes(n) {
|
|
608
|
-
return n.trim().split(/\s+/).map((t) => t.replace(parseRegex(tilde), (
|
|
608
|
+
return n.trim().split(/\s+/).map((t) => t.replace(parseRegex(tilde), (r, o, s, l, a) => isXVersion(o) ? "" : isXVersion(s) ? `>=${o}.0.0 <${Number(o) + 1}.0.0-0` : isXVersion(l) ? `>=${o}.${s}.0 <${o}.${Number(s) + 1}.0-0` : a ? `>=${o}.${s}.${l}-${a} <${o}.${Number(s) + 1}.0-0` : `>=${o}.${s}.${l} <${o}.${Number(s) + 1}.0-0`)).join(" ");
|
|
609
609
|
}
|
|
610
610
|
function parseXRanges(n) {
|
|
611
|
-
return n.split(/\s+/).map((t) => t.trim().replace(parseRegex(xRange), (
|
|
612
|
-
const c = isXVersion(s), u = c || isXVersion(
|
|
613
|
-
return
|
|
611
|
+
return n.split(/\s+/).map((t) => t.trim().replace(parseRegex(xRange), (r, o, s, l, a, i) => {
|
|
612
|
+
const c = isXVersion(s), u = c || isXVersion(l), p = u || isXVersion(a);
|
|
613
|
+
return o === "=" && p && (o = ""), i = "", c ? o === ">" || o === "<" ? "<0.0.0-0" : "*" : o && p ? (u && (l = 0), a = 0, o === ">" ? (o = ">=", u ? (s = Number(s) + 1, l = 0, a = 0) : (l = Number(l) + 1, a = 0)) : o === "<=" && (o = "<", u ? s = Number(s) + 1 : l = Number(l) + 1), o === "<" && (i = "-0"), `${o + s}.${l}.${a}${i}`) : u ? `>=${s}.0.0${i} <${Number(s) + 1}.0.0-0` : p ? `>=${s}.${l}.0${i} <${s}.${Number(l) + 1}.0-0` : r;
|
|
614
614
|
})).join(" ");
|
|
615
615
|
}
|
|
616
616
|
function parseStar(n) {
|
|
@@ -623,17 +623,17 @@ function compareAtom(n, t) {
|
|
|
623
623
|
return n = Number(n) || n, t = Number(t) || t, n > t ? 1 : n === t ? 0 : -1;
|
|
624
624
|
}
|
|
625
625
|
function comparePreRelease(n, t) {
|
|
626
|
-
const { preRelease:
|
|
627
|
-
if (
|
|
626
|
+
const { preRelease: r } = n, { preRelease: o } = t;
|
|
627
|
+
if (r === void 0 && o)
|
|
628
628
|
return 1;
|
|
629
|
-
if (
|
|
629
|
+
if (r && o === void 0)
|
|
630
630
|
return -1;
|
|
631
|
-
if (
|
|
631
|
+
if (r === void 0 && o === void 0)
|
|
632
632
|
return 0;
|
|
633
|
-
for (let s = 0,
|
|
634
|
-
const
|
|
635
|
-
if (
|
|
636
|
-
return
|
|
633
|
+
for (let s = 0, l = r.length; s <= l; s++) {
|
|
634
|
+
const a = r[s], i = o[s];
|
|
635
|
+
if (a !== i)
|
|
636
|
+
return a === void 0 && i === void 0 ? 0 : a ? i ? compareAtom(a, i) : -1 : 1;
|
|
637
637
|
}
|
|
638
638
|
return 0;
|
|
639
639
|
}
|
|
@@ -703,15 +703,15 @@ function parseRange(n) {
|
|
|
703
703
|
function satisfy(n, t) {
|
|
704
704
|
if (!n)
|
|
705
705
|
return !1;
|
|
706
|
-
const
|
|
707
|
-
if (!
|
|
706
|
+
const r = extractComparator(n);
|
|
707
|
+
if (!r)
|
|
708
708
|
return !1;
|
|
709
|
-
const [,
|
|
710
|
-
operator:
|
|
711
|
-
version: combineVersion(s,
|
|
709
|
+
const [, o, , s, l, a, i] = r, c = {
|
|
710
|
+
operator: o,
|
|
711
|
+
version: combineVersion(s, l, a, i),
|
|
712
712
|
major: s,
|
|
713
|
-
minor:
|
|
714
|
-
patch:
|
|
713
|
+
minor: l,
|
|
714
|
+
patch: a,
|
|
715
715
|
preRelease: i == null ? void 0 : i.split(".")
|
|
716
716
|
}, u = t.split("||");
|
|
717
717
|
for (const p of u) {
|
|
@@ -757,12 +757,12 @@ function satisfy(n, t) {
|
|
|
757
757
|
}
|
|
758
758
|
return !1;
|
|
759
759
|
}
|
|
760
|
-
function formatShare(n, t,
|
|
760
|
+
function formatShare(n, t, r, o) {
|
|
761
761
|
let s;
|
|
762
762
|
"get" in n ? s = n.get : "lib" in n ? s = () => Promise.resolve(n.lib) : s = () => Promise.resolve(() => {
|
|
763
|
-
throw new Error(`Can not get shared '${
|
|
763
|
+
throw new Error(`Can not get shared '${r}'!`);
|
|
764
764
|
});
|
|
765
|
-
var
|
|
765
|
+
var l, a, i;
|
|
766
766
|
return _extends$1({
|
|
767
767
|
deps: [],
|
|
768
768
|
useIn: [],
|
|
@@ -777,76 +777,76 @@ function formatShare(n, t, o, r) {
|
|
|
777
777
|
}, n.shareConfig),
|
|
778
778
|
get: s,
|
|
779
779
|
loaded: n != null && n.loaded || "lib" in n ? !0 : void 0,
|
|
780
|
-
version: (
|
|
780
|
+
version: (l = n.version) != null ? l : "0",
|
|
781
781
|
scope: Array.isArray(n.scope) ? n.scope : [
|
|
782
|
-
(
|
|
782
|
+
(a = n.scope) != null ? a : "default"
|
|
783
783
|
],
|
|
784
|
-
strategy: ((i = n.strategy) != null ? i :
|
|
784
|
+
strategy: ((i = n.strategy) != null ? i : o) || "version-first"
|
|
785
785
|
});
|
|
786
786
|
}
|
|
787
787
|
function formatShareConfigs(n, t) {
|
|
788
|
-
const
|
|
789
|
-
const c = arrayOptions(
|
|
790
|
-
return
|
|
791
|
-
|
|
792
|
-
}),
|
|
793
|
-
}, {}),
|
|
794
|
-
return Object.keys(s).forEach((
|
|
795
|
-
a
|
|
796
|
-
a
|
|
797
|
-
}) : a
|
|
788
|
+
const r = t.shared || {}, o = t.name, s = Object.keys(r).reduce((a, i) => {
|
|
789
|
+
const c = arrayOptions(r[i]);
|
|
790
|
+
return a[i] = a[i] || [], c.forEach((u) => {
|
|
791
|
+
a[i].push(formatShare(u, o, i, t.shareStrategy));
|
|
792
|
+
}), a;
|
|
793
|
+
}, {}), l = _extends$1({}, n.shared);
|
|
794
|
+
return Object.keys(s).forEach((a) => {
|
|
795
|
+
l[a] ? s[a].forEach((i) => {
|
|
796
|
+
l[a].find((u) => u.version === i.version) || l[a].push(i);
|
|
797
|
+
}) : l[a] = s[a];
|
|
798
798
|
}), {
|
|
799
|
-
shared:
|
|
799
|
+
shared: l,
|
|
800
800
|
shareInfos: s
|
|
801
801
|
};
|
|
802
802
|
}
|
|
803
803
|
function versionLt(n, t) {
|
|
804
|
-
const
|
|
805
|
-
if (!Number.isNaN(Number(
|
|
806
|
-
const
|
|
807
|
-
let
|
|
808
|
-
for (let i = 0; i < 3 -
|
|
809
|
-
|
|
810
|
-
return
|
|
804
|
+
const r = (o) => {
|
|
805
|
+
if (!Number.isNaN(Number(o))) {
|
|
806
|
+
const l = o.split(".");
|
|
807
|
+
let a = o;
|
|
808
|
+
for (let i = 0; i < 3 - l.length; i++)
|
|
809
|
+
a += ".0";
|
|
810
|
+
return a;
|
|
811
811
|
}
|
|
812
|
-
return
|
|
812
|
+
return o;
|
|
813
813
|
};
|
|
814
|
-
return !!satisfy(
|
|
814
|
+
return !!satisfy(r(n), `<=${r(t)}`);
|
|
815
815
|
}
|
|
816
816
|
const findVersion = (n, t) => {
|
|
817
|
-
const
|
|
818
|
-
return versionLt(
|
|
817
|
+
const r = t || function(o, s) {
|
|
818
|
+
return versionLt(o, s);
|
|
819
819
|
};
|
|
820
|
-
return Object.keys(n).reduce((
|
|
820
|
+
return Object.keys(n).reduce((o, s) => !o || r(o, s) || o === "0" ? s : o, 0);
|
|
821
821
|
}, isLoaded = (n) => !!n.loaded || typeof n.lib == "function", isLoading = (n) => !!n.loading;
|
|
822
|
-
function findSingletonVersionOrderByVersion(n, t,
|
|
823
|
-
const
|
|
824
|
-
return !isLoaded(
|
|
822
|
+
function findSingletonVersionOrderByVersion(n, t, r) {
|
|
823
|
+
const o = n[t][r], s = function(l, a) {
|
|
824
|
+
return !isLoaded(o[l]) && versionLt(l, a);
|
|
825
825
|
};
|
|
826
|
-
return findVersion(n[t][
|
|
826
|
+
return findVersion(n[t][r], s);
|
|
827
827
|
}
|
|
828
|
-
function findSingletonVersionOrderByLoaded(n, t,
|
|
829
|
-
const
|
|
828
|
+
function findSingletonVersionOrderByLoaded(n, t, r) {
|
|
829
|
+
const o = n[t][r], s = function(l, a) {
|
|
830
830
|
const i = (c) => isLoaded(c) || isLoading(c);
|
|
831
|
-
return i(
|
|
831
|
+
return i(o[a]) ? i(o[l]) ? !!versionLt(l, a) : !0 : i(o[l]) ? !1 : versionLt(l, a);
|
|
832
832
|
};
|
|
833
|
-
return findVersion(n[t][
|
|
833
|
+
return findVersion(n[t][r], s);
|
|
834
834
|
}
|
|
835
835
|
function getFindShareFunction(n) {
|
|
836
836
|
return n === "loaded-first" ? findSingletonVersionOrderByLoaded : findSingletonVersionOrderByVersion;
|
|
837
837
|
}
|
|
838
|
-
function getRegisteredShare(n, t,
|
|
838
|
+
function getRegisteredShare(n, t, r, o) {
|
|
839
839
|
if (!n)
|
|
840
840
|
return;
|
|
841
|
-
const { shareConfig: s, scope:
|
|
842
|
-
|
|
841
|
+
const { shareConfig: s, scope: l = DEFAULT_SCOPE, strategy: a } = r, i = Array.isArray(l) ? l : [
|
|
842
|
+
l
|
|
843
843
|
];
|
|
844
844
|
for (const c of i)
|
|
845
845
|
if (s && n[c] && n[c][t]) {
|
|
846
|
-
const { requiredVersion: u } = s, d = getFindShareFunction(
|
|
846
|
+
const { requiredVersion: u } = s, d = getFindShareFunction(a)(n, c, t), m = () => {
|
|
847
847
|
if (s.singleton) {
|
|
848
848
|
if (typeof u == "string" && !satisfy(d, u)) {
|
|
849
|
-
const E = `Version ${d} from ${d && n[c][t][d].from} of shared singleton module ${t} does not satisfy the requirement of ${
|
|
849
|
+
const E = `Version ${d} from ${d && n[c][t][d].from} of shared singleton module ${t} does not satisfy the requirement of ${r.from} which needs ${u})`;
|
|
850
850
|
s.strictVersion ? error(E) : warn(E);
|
|
851
851
|
}
|
|
852
852
|
return n[c][t][d];
|
|
@@ -865,14 +865,14 @@ function getRegisteredShare(n, t, o, r) {
|
|
|
865
865
|
GlobalFederation: Global.__FEDERATION__,
|
|
866
866
|
resolver: m
|
|
867
867
|
};
|
|
868
|
-
return (
|
|
868
|
+
return (o.emit(y) || y).resolver();
|
|
869
869
|
}
|
|
870
870
|
}
|
|
871
871
|
function getGlobalShareScope() {
|
|
872
872
|
return Global.__FEDERATION__.__SHARE__;
|
|
873
873
|
}
|
|
874
874
|
function getTargetSharedOptions(n) {
|
|
875
|
-
const { pkgName: t, extraOptions:
|
|
875
|
+
const { pkgName: t, extraOptions: r, shareInfos: o } = n, s = (i) => {
|
|
876
876
|
if (!i)
|
|
877
877
|
return;
|
|
878
878
|
const c = {};
|
|
@@ -884,152 +884,152 @@ function getTargetSharedOptions(n) {
|
|
|
884
884
|
});
|
|
885
885
|
return c[p];
|
|
886
886
|
};
|
|
887
|
-
var
|
|
888
|
-
const
|
|
889
|
-
return Object.assign({},
|
|
887
|
+
var l;
|
|
888
|
+
const a = (l = r == null ? void 0 : r.resolver) != null ? l : s;
|
|
889
|
+
return Object.assign({}, a(o[t]), r == null ? void 0 : r.customShareInfo);
|
|
890
890
|
}
|
|
891
891
|
function getBuilderId() {
|
|
892
892
|
return typeof FEDERATION_BUILD_IDENTIFIER < "u" ? FEDERATION_BUILD_IDENTIFIER : "";
|
|
893
893
|
}
|
|
894
894
|
function matchRemoteWithNameAndExpose(n, t) {
|
|
895
|
-
for (const
|
|
896
|
-
const
|
|
897
|
-
let s = t.replace(
|
|
898
|
-
if (
|
|
895
|
+
for (const r of n) {
|
|
896
|
+
const o = t.startsWith(r.name);
|
|
897
|
+
let s = t.replace(r.name, "");
|
|
898
|
+
if (o) {
|
|
899
899
|
if (s.startsWith("/")) {
|
|
900
|
-
const i =
|
|
900
|
+
const i = r.name;
|
|
901
901
|
return s = `.${s}`, {
|
|
902
902
|
pkgNameOrAlias: i,
|
|
903
903
|
expose: s,
|
|
904
|
-
remote:
|
|
904
|
+
remote: r
|
|
905
905
|
};
|
|
906
906
|
} else if (s === "")
|
|
907
907
|
return {
|
|
908
|
-
pkgNameOrAlias:
|
|
908
|
+
pkgNameOrAlias: r.name,
|
|
909
909
|
expose: ".",
|
|
910
|
-
remote:
|
|
910
|
+
remote: r
|
|
911
911
|
};
|
|
912
912
|
}
|
|
913
|
-
const
|
|
914
|
-
let
|
|
915
|
-
if (
|
|
916
|
-
if (
|
|
917
|
-
const i =
|
|
918
|
-
return
|
|
913
|
+
const l = r.alias && t.startsWith(r.alias);
|
|
914
|
+
let a = r.alias && t.replace(r.alias, "");
|
|
915
|
+
if (r.alias && l) {
|
|
916
|
+
if (a && a.startsWith("/")) {
|
|
917
|
+
const i = r.alias;
|
|
918
|
+
return a = `.${a}`, {
|
|
919
919
|
pkgNameOrAlias: i,
|
|
920
|
-
expose:
|
|
921
|
-
remote:
|
|
920
|
+
expose: a,
|
|
921
|
+
remote: r
|
|
922
922
|
};
|
|
923
|
-
} else if (
|
|
923
|
+
} else if (a === "")
|
|
924
924
|
return {
|
|
925
|
-
pkgNameOrAlias:
|
|
925
|
+
pkgNameOrAlias: r.alias,
|
|
926
926
|
expose: ".",
|
|
927
|
-
remote:
|
|
927
|
+
remote: r
|
|
928
928
|
};
|
|
929
929
|
}
|
|
930
930
|
}
|
|
931
931
|
}
|
|
932
932
|
function matchRemote(n, t) {
|
|
933
|
-
for (const
|
|
934
|
-
if (t ===
|
|
935
|
-
return
|
|
933
|
+
for (const r of n)
|
|
934
|
+
if (t === r.name || r.alias && t === r.alias)
|
|
935
|
+
return r;
|
|
936
936
|
}
|
|
937
937
|
function registerPlugins(n, t) {
|
|
938
|
-
const
|
|
939
|
-
return
|
|
940
|
-
n != null && n.find((s) => s.name !==
|
|
941
|
-
}), n && n.length > 0 && n.forEach((
|
|
938
|
+
const r = getGlobalHostPlugins();
|
|
939
|
+
return r.length > 0 && r.forEach((o) => {
|
|
940
|
+
n != null && n.find((s) => s.name !== o.name) && n.push(o);
|
|
941
|
+
}), n && n.length > 0 && n.forEach((o) => {
|
|
942
942
|
t.forEach((s) => {
|
|
943
|
-
s.applyPlugin(
|
|
943
|
+
s.applyPlugin(o);
|
|
944
944
|
});
|
|
945
945
|
}), n;
|
|
946
946
|
}
|
|
947
947
|
const importCallback = ".then(callbacks[0]).catch(callbacks[1])";
|
|
948
948
|
async function loadEsmEntry({ entry: n, remoteEntryExports: t }) {
|
|
949
|
-
return new Promise((
|
|
949
|
+
return new Promise((r, o) => {
|
|
950
950
|
try {
|
|
951
|
-
t ?
|
|
952
|
-
|
|
953
|
-
|
|
951
|
+
t ? r(t) : typeof FEDERATION_ALLOW_NEW_FUNCTION < "u" ? new Function("callbacks", `import("${n}")${importCallback}`)([
|
|
952
|
+
r,
|
|
953
|
+
o
|
|
954
954
|
]) : import(
|
|
955
955
|
/* webpackIgnore: true */
|
|
956
956
|
/* @vite-ignore */
|
|
957
957
|
n
|
|
958
|
-
).then(
|
|
958
|
+
).then(r).catch(o);
|
|
959
959
|
} catch (s) {
|
|
960
|
-
|
|
960
|
+
o(s);
|
|
961
961
|
}
|
|
962
962
|
});
|
|
963
963
|
}
|
|
964
964
|
async function loadSystemJsEntry({ entry: n, remoteEntryExports: t }) {
|
|
965
|
-
return new Promise((
|
|
965
|
+
return new Promise((r, o) => {
|
|
966
966
|
try {
|
|
967
|
-
t ?
|
|
968
|
-
|
|
969
|
-
|
|
967
|
+
t ? r(t) : typeof __system_context__ > "u" ? System.import(n).then(r).catch(o) : new Function("callbacks", `System.import("${n}")${importCallback}`)([
|
|
968
|
+
r,
|
|
969
|
+
o
|
|
970
970
|
]);
|
|
971
971
|
} catch (s) {
|
|
972
|
-
|
|
972
|
+
o(s);
|
|
973
973
|
}
|
|
974
974
|
});
|
|
975
975
|
}
|
|
976
|
-
function handleRemoteEntryLoaded(n, t,
|
|
977
|
-
const { remoteEntryKey:
|
|
976
|
+
function handleRemoteEntryLoaded(n, t, r) {
|
|
977
|
+
const { remoteEntryKey: o, entryExports: s } = getRemoteEntryExports(n, t);
|
|
978
978
|
return assert(s, getShortErrorMsg(RUNTIME_001, runtimeDescMap, {
|
|
979
979
|
remoteName: n,
|
|
980
|
-
remoteEntryUrl:
|
|
981
|
-
remoteEntryKey:
|
|
980
|
+
remoteEntryUrl: r,
|
|
981
|
+
remoteEntryKey: o
|
|
982
982
|
})), s;
|
|
983
983
|
}
|
|
984
|
-
async function loadEntryScript({ name: n, globalName: t, entry:
|
|
984
|
+
async function loadEntryScript({ name: n, globalName: t, entry: r, loaderHook: o }) {
|
|
985
985
|
const { entryExports: s } = getRemoteEntryExports(n, t);
|
|
986
|
-
return s || loadScript(
|
|
986
|
+
return s || loadScript(r, {
|
|
987
987
|
attrs: {},
|
|
988
|
-
createScriptHook: (
|
|
989
|
-
const i =
|
|
990
|
-
url:
|
|
991
|
-
attrs:
|
|
988
|
+
createScriptHook: (l, a) => {
|
|
989
|
+
const i = o.lifecycle.createScript.emit({
|
|
990
|
+
url: l,
|
|
991
|
+
attrs: a
|
|
992
992
|
});
|
|
993
993
|
if (i && (i instanceof HTMLScriptElement || "script" in i || "timeout" in i))
|
|
994
994
|
return i;
|
|
995
995
|
}
|
|
996
|
-
}).then(() => handleRemoteEntryLoaded(n, t,
|
|
996
|
+
}).then(() => handleRemoteEntryLoaded(n, t, r)).catch((l) => {
|
|
997
997
|
throw assert(void 0, getShortErrorMsg(RUNTIME_008, runtimeDescMap, {
|
|
998
998
|
remoteName: n,
|
|
999
|
-
resourceUrl:
|
|
1000
|
-
})),
|
|
999
|
+
resourceUrl: r
|
|
1000
|
+
})), l;
|
|
1001
1001
|
});
|
|
1002
1002
|
}
|
|
1003
|
-
async function loadEntryDom({ remoteInfo: n, remoteEntryExports: t, loaderHook:
|
|
1004
|
-
const { entry:
|
|
1005
|
-
switch (
|
|
1003
|
+
async function loadEntryDom({ remoteInfo: n, remoteEntryExports: t, loaderHook: r }) {
|
|
1004
|
+
const { entry: o, entryGlobalName: s, name: l, type: a } = n;
|
|
1005
|
+
switch (a) {
|
|
1006
1006
|
case "esm":
|
|
1007
1007
|
case "module":
|
|
1008
1008
|
return loadEsmEntry({
|
|
1009
|
-
entry:
|
|
1009
|
+
entry: o,
|
|
1010
1010
|
remoteEntryExports: t
|
|
1011
1011
|
});
|
|
1012
1012
|
case "system":
|
|
1013
1013
|
return loadSystemJsEntry({
|
|
1014
|
-
entry:
|
|
1014
|
+
entry: o,
|
|
1015
1015
|
remoteEntryExports: t
|
|
1016
1016
|
});
|
|
1017
1017
|
default:
|
|
1018
1018
|
return loadEntryScript({
|
|
1019
|
-
entry:
|
|
1019
|
+
entry: o,
|
|
1020
1020
|
globalName: s,
|
|
1021
|
-
name:
|
|
1022
|
-
loaderHook:
|
|
1021
|
+
name: l,
|
|
1022
|
+
loaderHook: r
|
|
1023
1023
|
});
|
|
1024
1024
|
}
|
|
1025
1025
|
}
|
|
1026
1026
|
async function loadEntryNode({ remoteInfo: n, loaderHook: t }) {
|
|
1027
|
-
const { entry:
|
|
1028
|
-
return
|
|
1027
|
+
const { entry: r, entryGlobalName: o, name: s, type: l } = n, { entryExports: a } = getRemoteEntryExports(s, o);
|
|
1028
|
+
return a || loadScriptNode(r, {
|
|
1029
1029
|
attrs: {
|
|
1030
1030
|
name: s,
|
|
1031
|
-
globalName:
|
|
1032
|
-
type:
|
|
1031
|
+
globalName: o,
|
|
1032
|
+
type: l
|
|
1033
1033
|
},
|
|
1034
1034
|
loaderHook: {
|
|
1035
1035
|
createScriptHook: (i, c = {}) => {
|
|
@@ -1041,34 +1041,34 @@ async function loadEntryNode({ remoteInfo: n, loaderHook: t }) {
|
|
|
1041
1041
|
return u;
|
|
1042
1042
|
}
|
|
1043
1043
|
}
|
|
1044
|
-
}).then(() => handleRemoteEntryLoaded(s,
|
|
1044
|
+
}).then(() => handleRemoteEntryLoaded(s, o, r)).catch((i) => {
|
|
1045
1045
|
throw i;
|
|
1046
1046
|
});
|
|
1047
1047
|
}
|
|
1048
1048
|
function getRemoteEntryUniqueKey(n) {
|
|
1049
|
-
const { entry: t, name:
|
|
1050
|
-
return composeKeyWithSeparator(
|
|
1049
|
+
const { entry: t, name: r } = n;
|
|
1050
|
+
return composeKeyWithSeparator(r, t);
|
|
1051
1051
|
}
|
|
1052
|
-
async function getRemoteEntry({ origin: n, remoteEntryExports: t, remoteInfo:
|
|
1053
|
-
const
|
|
1052
|
+
async function getRemoteEntry({ origin: n, remoteEntryExports: t, remoteInfo: r }) {
|
|
1053
|
+
const o = getRemoteEntryUniqueKey(r);
|
|
1054
1054
|
if (t)
|
|
1055
1055
|
return t;
|
|
1056
|
-
if (!globalLoading[
|
|
1057
|
-
const s = n.remoteHandler.hooks.lifecycle.loadEntry,
|
|
1058
|
-
globalLoading[
|
|
1059
|
-
loaderHook:
|
|
1060
|
-
remoteInfo:
|
|
1056
|
+
if (!globalLoading[o]) {
|
|
1057
|
+
const s = n.remoteHandler.hooks.lifecycle.loadEntry, l = n.loaderHook;
|
|
1058
|
+
globalLoading[o] = s.emit({
|
|
1059
|
+
loaderHook: l,
|
|
1060
|
+
remoteInfo: r,
|
|
1061
1061
|
remoteEntryExports: t
|
|
1062
|
-
}).then((
|
|
1063
|
-
remoteInfo:
|
|
1062
|
+
}).then((a) => a || ((typeof ENV_TARGET < "u" ? ENV_TARGET === "web" : isBrowserEnv()) ? loadEntryDom({
|
|
1063
|
+
remoteInfo: r,
|
|
1064
1064
|
remoteEntryExports: t,
|
|
1065
|
-
loaderHook:
|
|
1065
|
+
loaderHook: l
|
|
1066
1066
|
}) : loadEntryNode({
|
|
1067
|
-
remoteInfo:
|
|
1068
|
-
loaderHook:
|
|
1067
|
+
remoteInfo: r,
|
|
1068
|
+
loaderHook: l
|
|
1069
1069
|
})));
|
|
1070
1070
|
}
|
|
1071
|
-
return globalLoading[
|
|
1071
|
+
return globalLoading[o];
|
|
1072
1072
|
}
|
|
1073
1073
|
function getRemoteInfo(n) {
|
|
1074
1074
|
return _extends$1({}, n, {
|
|
@@ -1090,24 +1090,24 @@ let Module = class {
|
|
|
1090
1090
|
remoteEntryExports: this.remoteEntryExports
|
|
1091
1091
|
});
|
|
1092
1092
|
} catch {
|
|
1093
|
-
const
|
|
1093
|
+
const o = getRemoteEntryUniqueKey(this.remoteInfo);
|
|
1094
1094
|
t = await this.host.loaderHook.lifecycle.loadEntryError.emit({
|
|
1095
1095
|
getRemoteEntry,
|
|
1096
1096
|
origin: this.host,
|
|
1097
1097
|
remoteInfo: this.remoteInfo,
|
|
1098
1098
|
remoteEntryExports: this.remoteEntryExports,
|
|
1099
1099
|
globalLoading,
|
|
1100
|
-
uniqueKey:
|
|
1100
|
+
uniqueKey: o
|
|
1101
1101
|
});
|
|
1102
1102
|
}
|
|
1103
1103
|
return assert(t, `remoteEntryExports is undefined
|
|
1104
1104
|
${safeToString(this.remoteInfo)}`), this.remoteEntryExports = t, this.remoteEntryExports;
|
|
1105
1105
|
}
|
|
1106
1106
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1107
|
-
async get(t,
|
|
1108
|
-
const { loadFactory:
|
|
1107
|
+
async get(t, r, o, s) {
|
|
1108
|
+
const { loadFactory: l = !0 } = o || {
|
|
1109
1109
|
loadFactory: !0
|
|
1110
|
-
},
|
|
1110
|
+
}, a = await this.getEntry();
|
|
1111
1111
|
if (!this.inited) {
|
|
1112
1112
|
const d = this.host.shareScopeMap, m = Array.isArray(this.remoteInfo.shareScope) ? this.remoteInfo.shareScope : [
|
|
1113
1113
|
this.remoteInfo.shareScope
|
|
@@ -1132,44 +1132,43 @@ let Module = class {
|
|
|
1132
1132
|
remoteInfo: this.remoteInfo,
|
|
1133
1133
|
origin: this.host
|
|
1134
1134
|
});
|
|
1135
|
-
typeof (
|
|
1136
|
-
|
|
1137
|
-
remoteName: this.remoteInfo.name,
|
|
1135
|
+
typeof (a == null ? void 0 : a.init) > "u" && error(getShortErrorMsg(RUNTIME_002, runtimeDescMap, {
|
|
1136
|
+
remoteName: name,
|
|
1138
1137
|
remoteEntryUrl: this.remoteInfo.entry,
|
|
1139
1138
|
remoteEntryKey: this.remoteInfo.entryGlobalName
|
|
1140
|
-
})), await
|
|
1139
|
+
})), await a.init(_.shareScope, _.initScope, _.remoteEntryInitOptions), await this.host.hooks.lifecycle.initContainer.emit(_extends$1({}, _, {
|
|
1141
1140
|
id: t,
|
|
1142
1141
|
remoteSnapshot: s,
|
|
1143
|
-
remoteEntryExports:
|
|
1142
|
+
remoteEntryExports: a
|
|
1144
1143
|
}));
|
|
1145
1144
|
}
|
|
1146
|
-
this.lib =
|
|
1145
|
+
this.lib = a, this.inited = !0;
|
|
1147
1146
|
let i;
|
|
1148
1147
|
i = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
|
|
1149
|
-
remoteEntryExports:
|
|
1150
|
-
expose:
|
|
1148
|
+
remoteEntryExports: a,
|
|
1149
|
+
expose: r,
|
|
1151
1150
|
moduleInfo: this.remoteInfo
|
|
1152
|
-
}), i || (i = await
|
|
1153
|
-
const c = processModuleAlias(this.remoteInfo.name,
|
|
1154
|
-
return
|
|
1151
|
+
}), i || (i = await a.get(r)), assert(i, `${getFMId(this.remoteInfo)} remote don't export ${r}.`);
|
|
1152
|
+
const c = processModuleAlias(this.remoteInfo.name, r), u = this.wraperFactory(i, c);
|
|
1153
|
+
return l ? await u() : u;
|
|
1155
1154
|
}
|
|
1156
|
-
wraperFactory(t,
|
|
1157
|
-
function
|
|
1155
|
+
wraperFactory(t, r) {
|
|
1156
|
+
function o(s, l) {
|
|
1158
1157
|
s && typeof s == "object" && Object.isExtensible(s) && !Object.getOwnPropertyDescriptor(s, Symbol.for("mf_module_id")) && Object.defineProperty(s, Symbol.for("mf_module_id"), {
|
|
1159
|
-
value:
|
|
1158
|
+
value: l,
|
|
1160
1159
|
enumerable: !1
|
|
1161
1160
|
});
|
|
1162
1161
|
}
|
|
1163
1162
|
return t instanceof Promise ? async () => {
|
|
1164
1163
|
const s = await t();
|
|
1165
|
-
return
|
|
1164
|
+
return o(s, r), s;
|
|
1166
1165
|
} : () => {
|
|
1167
1166
|
const s = t();
|
|
1168
|
-
return
|
|
1167
|
+
return o(s, r), s;
|
|
1169
1168
|
};
|
|
1170
1169
|
}
|
|
1171
|
-
constructor({ remoteInfo: t, host:
|
|
1172
|
-
this.inited = !1, this.lib = void 0, this.remoteInfo = t, this.host =
|
|
1170
|
+
constructor({ remoteInfo: t, host: r }) {
|
|
1171
|
+
this.inited = !1, this.lib = void 0, this.remoteInfo = t, this.host = r;
|
|
1173
1172
|
}
|
|
1174
1173
|
};
|
|
1175
1174
|
class SyncHook {
|
|
@@ -1177,16 +1176,16 @@ class SyncHook {
|
|
|
1177
1176
|
typeof t == "function" && this.listeners.add(t);
|
|
1178
1177
|
}
|
|
1179
1178
|
once(t) {
|
|
1180
|
-
const
|
|
1181
|
-
this.on(function
|
|
1182
|
-
return
|
|
1179
|
+
const r = this;
|
|
1180
|
+
this.on(function o(...s) {
|
|
1181
|
+
return r.remove(o), t.apply(null, s);
|
|
1183
1182
|
});
|
|
1184
1183
|
}
|
|
1185
1184
|
emit(...t) {
|
|
1186
|
-
let
|
|
1187
|
-
return this.listeners.size > 0 && this.listeners.forEach((
|
|
1188
|
-
|
|
1189
|
-
}),
|
|
1185
|
+
let r;
|
|
1186
|
+
return this.listeners.size > 0 && this.listeners.forEach((o) => {
|
|
1187
|
+
r = o(...t);
|
|
1188
|
+
}), r;
|
|
1190
1189
|
}
|
|
1191
1190
|
remove(t) {
|
|
1192
1191
|
this.listeners.delete(t);
|
|
@@ -1200,22 +1199,22 @@ class SyncHook {
|
|
|
1200
1199
|
}
|
|
1201
1200
|
class AsyncHook extends SyncHook {
|
|
1202
1201
|
emit(...t) {
|
|
1203
|
-
let
|
|
1204
|
-
const
|
|
1205
|
-
if (
|
|
1202
|
+
let r;
|
|
1203
|
+
const o = Array.from(this.listeners);
|
|
1204
|
+
if (o.length > 0) {
|
|
1206
1205
|
let s = 0;
|
|
1207
|
-
const
|
|
1208
|
-
|
|
1206
|
+
const l = (a) => a === !1 ? !1 : s < o.length ? Promise.resolve(o[s++].apply(null, t)).then(l) : a;
|
|
1207
|
+
r = l();
|
|
1209
1208
|
}
|
|
1210
|
-
return Promise.resolve(
|
|
1209
|
+
return Promise.resolve(r);
|
|
1211
1210
|
}
|
|
1212
1211
|
}
|
|
1213
1212
|
function checkReturnData(n, t) {
|
|
1214
1213
|
if (!isObject(t))
|
|
1215
1214
|
return !1;
|
|
1216
1215
|
if (n !== t) {
|
|
1217
|
-
for (const
|
|
1218
|
-
if (!(
|
|
1216
|
+
for (const r in n)
|
|
1217
|
+
if (!(r in t))
|
|
1219
1218
|
return !1;
|
|
1220
1219
|
}
|
|
1221
1220
|
return !0;
|
|
@@ -1223,17 +1222,17 @@ function checkReturnData(n, t) {
|
|
|
1223
1222
|
class SyncWaterfallHook extends SyncHook {
|
|
1224
1223
|
emit(t) {
|
|
1225
1224
|
isObject(t) || error(`The data for the "${this.type}" hook should be an object.`);
|
|
1226
|
-
for (const
|
|
1225
|
+
for (const r of this.listeners)
|
|
1227
1226
|
try {
|
|
1228
|
-
const
|
|
1229
|
-
if (checkReturnData(t,
|
|
1230
|
-
t =
|
|
1227
|
+
const o = r(t);
|
|
1228
|
+
if (checkReturnData(t, o))
|
|
1229
|
+
t = o;
|
|
1231
1230
|
else {
|
|
1232
1231
|
this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);
|
|
1233
1232
|
break;
|
|
1234
1233
|
}
|
|
1235
|
-
} catch (
|
|
1236
|
-
warn(
|
|
1234
|
+
} catch (o) {
|
|
1235
|
+
warn(o), this.onerror(o);
|
|
1237
1236
|
}
|
|
1238
1237
|
return t;
|
|
1239
1238
|
}
|
|
@@ -1244,14 +1243,14 @@ class SyncWaterfallHook extends SyncHook {
|
|
|
1244
1243
|
class AsyncWaterfallHook extends SyncHook {
|
|
1245
1244
|
emit(t) {
|
|
1246
1245
|
isObject(t) || error(`The response data for the "${this.type}" hook must be an object.`);
|
|
1247
|
-
const
|
|
1248
|
-
if (
|
|
1249
|
-
let
|
|
1250
|
-
const s = (
|
|
1251
|
-
if (checkReturnData(t,
|
|
1252
|
-
if (t =
|
|
1246
|
+
const r = Array.from(this.listeners);
|
|
1247
|
+
if (r.length > 0) {
|
|
1248
|
+
let o = 0;
|
|
1249
|
+
const s = (a) => (warn(a), this.onerror(a), t), l = (a) => {
|
|
1250
|
+
if (checkReturnData(t, a)) {
|
|
1251
|
+
if (t = a, o < r.length)
|
|
1253
1252
|
try {
|
|
1254
|
-
return Promise.resolve(o
|
|
1253
|
+
return Promise.resolve(r[o++](t)).then(l, s);
|
|
1255
1254
|
} catch (i) {
|
|
1256
1255
|
return s(i);
|
|
1257
1256
|
}
|
|
@@ -1259,7 +1258,7 @@ class AsyncWaterfallHook extends SyncHook {
|
|
|
1259
1258
|
this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
|
|
1260
1259
|
return t;
|
|
1261
1260
|
};
|
|
1262
|
-
return Promise.resolve(
|
|
1261
|
+
return Promise.resolve(l(t));
|
|
1263
1262
|
}
|
|
1264
1263
|
return Promise.resolve(t);
|
|
1265
1264
|
}
|
|
@@ -1270,25 +1269,25 @@ class AsyncWaterfallHook extends SyncHook {
|
|
|
1270
1269
|
class PluginSystem {
|
|
1271
1270
|
applyPlugin(t) {
|
|
1272
1271
|
assert(isPlainObject(t), "Plugin configuration is invalid.");
|
|
1273
|
-
const
|
|
1274
|
-
assert(
|
|
1275
|
-
const s = t[
|
|
1276
|
-
s && this.lifecycle[
|
|
1272
|
+
const r = t.name;
|
|
1273
|
+
assert(r, "A name must be provided by the plugin."), this.registerPlugins[r] || (this.registerPlugins[r] = t, Object.keys(this.lifecycle).forEach((o) => {
|
|
1274
|
+
const s = t[o];
|
|
1275
|
+
s && this.lifecycle[o].on(s);
|
|
1277
1276
|
}));
|
|
1278
1277
|
}
|
|
1279
1278
|
removePlugin(t) {
|
|
1280
1279
|
assert(t, "A name is required.");
|
|
1281
|
-
const
|
|
1282
|
-
assert(
|
|
1283
|
-
|
|
1280
|
+
const r = this.registerPlugins[t];
|
|
1281
|
+
assert(r, `The plugin "${t}" is not registered.`), Object.keys(r).forEach((o) => {
|
|
1282
|
+
o !== "name" && this.lifecycle[o].remove(r[o]);
|
|
1284
1283
|
});
|
|
1285
1284
|
}
|
|
1286
1285
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
1287
|
-
inherit({ lifecycle: t, registerPlugins:
|
|
1288
|
-
Object.keys(t).forEach((
|
|
1289
|
-
assert(!this.lifecycle[
|
|
1290
|
-
}), Object.keys(
|
|
1291
|
-
assert(!this.registerPlugins[
|
|
1286
|
+
inherit({ lifecycle: t, registerPlugins: r }) {
|
|
1287
|
+
Object.keys(t).forEach((o) => {
|
|
1288
|
+
assert(!this.lifecycle[o], `The hook "${o}" has a conflict and cannot be inherited.`), this.lifecycle[o] = t[o];
|
|
1289
|
+
}), Object.keys(r).forEach((o) => {
|
|
1290
|
+
assert(!this.registerPlugins[o], `The plugin "${o}" has a conflict and cannot be inherited.`), this.applyPlugin(r[o]);
|
|
1292
1291
|
});
|
|
1293
1292
|
}
|
|
1294
1293
|
constructor(t) {
|
|
@@ -1304,24 +1303,24 @@ function defaultPreloadArgs(n) {
|
|
|
1304
1303
|
}, n);
|
|
1305
1304
|
}
|
|
1306
1305
|
function formatPreloadArgs(n, t) {
|
|
1307
|
-
return t.map((
|
|
1308
|
-
const
|
|
1309
|
-
return assert(
|
|
1310
|
-
remoteInfo:
|
|
1306
|
+
return t.map((r) => {
|
|
1307
|
+
const o = matchRemote(n, r.nameOrAlias);
|
|
1308
|
+
return assert(o, `Unable to preload ${r.nameOrAlias} as it is not included in ${!o && safeToString({
|
|
1309
|
+
remoteInfo: o,
|
|
1311
1310
|
remotes: n
|
|
1312
1311
|
})}`), {
|
|
1313
|
-
remote:
|
|
1314
|
-
preloadConfig: defaultPreloadArgs(
|
|
1312
|
+
remote: o,
|
|
1313
|
+
preloadConfig: defaultPreloadArgs(r)
|
|
1315
1314
|
};
|
|
1316
1315
|
});
|
|
1317
1316
|
}
|
|
1318
1317
|
function normalizePreloadExposes(n) {
|
|
1319
1318
|
return n ? n.map((t) => t === "." ? t : t.startsWith("./") ? t.replace("./", "") : t) : [];
|
|
1320
1319
|
}
|
|
1321
|
-
function preloadAssets(n, t,
|
|
1322
|
-
const { cssAssets: s, jsAssetsWithoutEntry:
|
|
1320
|
+
function preloadAssets(n, t, r, o = !0) {
|
|
1321
|
+
const { cssAssets: s, jsAssetsWithoutEntry: l, entryAssets: a } = r;
|
|
1323
1322
|
if (t.options.inBrowser) {
|
|
1324
|
-
if (
|
|
1323
|
+
if (a.forEach((i) => {
|
|
1325
1324
|
const { moduleInfo: c } = i, u = t.moduleCache.get(n.name);
|
|
1326
1325
|
getRemoteEntry(u ? {
|
|
1327
1326
|
origin: t,
|
|
@@ -1332,7 +1331,7 @@ function preloadAssets(n, t, o, r = !0) {
|
|
|
1332
1331
|
remoteInfo: c,
|
|
1333
1332
|
remoteEntryExports: void 0
|
|
1334
1333
|
});
|
|
1335
|
-
}),
|
|
1334
|
+
}), o) {
|
|
1336
1335
|
const i = {
|
|
1337
1336
|
rel: "preload",
|
|
1338
1337
|
as: "style"
|
|
@@ -1378,12 +1377,12 @@ function preloadAssets(n, t, o, r = !0) {
|
|
|
1378
1377
|
p && document.head.appendChild(u);
|
|
1379
1378
|
});
|
|
1380
1379
|
}
|
|
1381
|
-
if (
|
|
1380
|
+
if (o) {
|
|
1382
1381
|
const i = {
|
|
1383
1382
|
rel: "preload",
|
|
1384
1383
|
as: "script"
|
|
1385
1384
|
};
|
|
1386
|
-
|
|
1385
|
+
l.forEach((c) => {
|
|
1387
1386
|
const { link: u, needAttach: p } = createLink({
|
|
1388
1387
|
url: c,
|
|
1389
1388
|
cb: () => {
|
|
@@ -1405,7 +1404,7 @@ function preloadAssets(n, t, o, r = !0) {
|
|
|
1405
1404
|
fetchpriority: "high",
|
|
1406
1405
|
type: (n == null ? void 0 : n.type) === "module" ? "module" : "text/javascript"
|
|
1407
1406
|
};
|
|
1408
|
-
|
|
1407
|
+
l.forEach((c) => {
|
|
1409
1408
|
const { script: u, needAttach: p } = createScript({
|
|
1410
1409
|
url: c,
|
|
1411
1410
|
cb: () => {
|
|
@@ -1427,43 +1426,40 @@ function preloadAssets(n, t, o, r = !0) {
|
|
|
1427
1426
|
}
|
|
1428
1427
|
}
|
|
1429
1428
|
function assignRemoteInfo(n, t) {
|
|
1430
|
-
const
|
|
1431
|
-
|
|
1432
|
-
let
|
|
1433
|
-
!isBrowserEnv() && !
|
|
1429
|
+
const r = getRemoteEntryInfoFromSnapshot(t);
|
|
1430
|
+
r.url || error(`The attribute remoteEntry of ${n.name} must not be undefined.`);
|
|
1431
|
+
let o = getResourceUrl(t, r.url);
|
|
1432
|
+
!isBrowserEnv() && !o.startsWith("http") && (o = `https:${o}`), n.type = r.type, n.entryGlobalName = r.globalName, n.entry = o, n.version = t.version, n.buildVersion = t.buildVersion;
|
|
1434
1433
|
}
|
|
1435
1434
|
function snapshotPlugin() {
|
|
1436
1435
|
return {
|
|
1437
1436
|
name: "snapshot-plugin",
|
|
1438
1437
|
async afterResolve(n) {
|
|
1439
|
-
const { remote: t, pkgNameOrAlias:
|
|
1438
|
+
const { remote: t, pkgNameOrAlias: r, expose: o, origin: s, remoteInfo: l } = n;
|
|
1440
1439
|
if (!isRemoteInfoWithEntry(t) || !isPureRemoteEntry(t)) {
|
|
1441
|
-
const { remoteSnapshot:
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
});
|
|
1445
|
-
assignRemoteInfo(a, i);
|
|
1446
|
-
const u = {
|
|
1440
|
+
const { remoteSnapshot: a, globalSnapshot: i } = await s.snapshotHandler.loadRemoteSnapshotInfo(t);
|
|
1441
|
+
assignRemoteInfo(l, a);
|
|
1442
|
+
const c = {
|
|
1447
1443
|
remote: t,
|
|
1448
1444
|
preloadConfig: {
|
|
1449
|
-
nameOrAlias:
|
|
1445
|
+
nameOrAlias: r,
|
|
1450
1446
|
exposes: [
|
|
1451
|
-
|
|
1447
|
+
o
|
|
1452
1448
|
],
|
|
1453
1449
|
resourceCategory: "sync",
|
|
1454
1450
|
share: !1,
|
|
1455
1451
|
depsRemote: !1
|
|
1456
1452
|
}
|
|
1457
|
-
},
|
|
1453
|
+
}, u = await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({
|
|
1458
1454
|
origin: s,
|
|
1459
|
-
preloadOptions:
|
|
1460
|
-
remoteInfo:
|
|
1455
|
+
preloadOptions: c,
|
|
1456
|
+
remoteInfo: l,
|
|
1461
1457
|
remote: t,
|
|
1462
|
-
remoteSnapshot:
|
|
1463
|
-
globalSnapshot:
|
|
1458
|
+
remoteSnapshot: a,
|
|
1459
|
+
globalSnapshot: i
|
|
1464
1460
|
});
|
|
1465
|
-
return
|
|
1466
|
-
remoteSnapshot:
|
|
1461
|
+
return u && preloadAssets(l, s, u, !1), _extends$1({}, n, {
|
|
1462
|
+
remoteSnapshot: a
|
|
1467
1463
|
});
|
|
1468
1464
|
}
|
|
1469
1465
|
return n;
|
|
@@ -1483,9 +1479,9 @@ function splitId(n) {
|
|
|
1483
1479
|
version: t[2]
|
|
1484
1480
|
};
|
|
1485
1481
|
}
|
|
1486
|
-
function traverseModuleInfo(n, t,
|
|
1487
|
-
const
|
|
1488
|
-
if (c && !isManifestProvider(c) && (
|
|
1482
|
+
function traverseModuleInfo(n, t, r, o, s = {}, l) {
|
|
1483
|
+
const a = getFMId(t), { value: i } = getInfoWithoutType(n, a), c = l || i;
|
|
1484
|
+
if (c && !isManifestProvider(c) && (r(c, t, o), c.remotesInfo)) {
|
|
1489
1485
|
const u = Object.keys(c.remotesInfo);
|
|
1490
1486
|
for (const p of u) {
|
|
1491
1487
|
if (s[p])
|
|
@@ -1495,22 +1491,22 @@ function traverseModuleInfo(n, t, o, r, s = {}, a) {
|
|
|
1495
1491
|
traverseModuleInfo(n, {
|
|
1496
1492
|
name: d.name,
|
|
1497
1493
|
version: m.matchedVersion
|
|
1498
|
-
},
|
|
1494
|
+
}, r, !1, s, void 0);
|
|
1499
1495
|
}
|
|
1500
1496
|
}
|
|
1501
1497
|
}
|
|
1502
1498
|
const isExisted = (n, t) => document.querySelector(`${n}[${n === "link" ? "href" : "src"}="${t}"]`);
|
|
1503
|
-
function generatePreloadAssets(n, t,
|
|
1504
|
-
const
|
|
1505
|
-
if (traverseModuleInfo(
|
|
1499
|
+
function generatePreloadAssets(n, t, r, o, s) {
|
|
1500
|
+
const l = [], a = [], i = [], c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), { options: p } = n, { preloadConfig: d } = t, { depsRemote: m } = d;
|
|
1501
|
+
if (traverseModuleInfo(o, r, (_, b, v) => {
|
|
1506
1502
|
let I;
|
|
1507
1503
|
if (v)
|
|
1508
1504
|
I = d;
|
|
1509
1505
|
else if (Array.isArray(m)) {
|
|
1510
|
-
const
|
|
1511
|
-
if (!
|
|
1506
|
+
const N = m.find((O) => O.nameOrAlias === b.name || O.nameOrAlias === b.alias);
|
|
1507
|
+
if (!N)
|
|
1512
1508
|
return;
|
|
1513
|
-
I = defaultPreloadArgs(
|
|
1509
|
+
I = defaultPreloadArgs(N);
|
|
1514
1510
|
} else if (m === !0)
|
|
1515
1511
|
I = d;
|
|
1516
1512
|
else
|
|
@@ -1532,24 +1528,24 @@ function generatePreloadAssets(n, t, o, r, s) {
|
|
|
1532
1528
|
const A = normalizePreloadExposes(I.exposes);
|
|
1533
1529
|
if (A.length && "modules" in _) {
|
|
1534
1530
|
var T;
|
|
1535
|
-
R = _ == null || (T = _.modules) == null ? void 0 : T.reduce((
|
|
1531
|
+
R = _ == null || (T = _.modules) == null ? void 0 : T.reduce((N, O) => ((A == null ? void 0 : A.indexOf(O.moduleName)) !== -1 && N.push(O), N), []);
|
|
1536
1532
|
}
|
|
1537
|
-
function $(
|
|
1538
|
-
const
|
|
1539
|
-
return I.filter ?
|
|
1533
|
+
function $(N) {
|
|
1534
|
+
const O = N.map((w) => getResourceUrl(_, w));
|
|
1535
|
+
return I.filter ? O.filter(I.filter) : O;
|
|
1540
1536
|
}
|
|
1541
1537
|
if (R) {
|
|
1542
|
-
const
|
|
1543
|
-
for (let
|
|
1544
|
-
const
|
|
1538
|
+
const N = R.length;
|
|
1539
|
+
for (let O = 0; O < N; O++) {
|
|
1540
|
+
const w = R[O], P = `${b.name}/${w.moduleName}`;
|
|
1545
1541
|
n.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({
|
|
1546
|
-
id:
|
|
1542
|
+
id: w.moduleName === "." ? b.name : P,
|
|
1547
1543
|
name: b.name,
|
|
1548
1544
|
remoteSnapshot: _,
|
|
1549
1545
|
preloadConfig: I,
|
|
1550
1546
|
remote: b,
|
|
1551
1547
|
origin: n
|
|
1552
|
-
}), !getPreloaded(P) && (I.resourceCategory === "all" ? (
|
|
1548
|
+
}), !getPreloaded(P) && (I.resourceCategory === "all" ? (l.push(...$(w.assets.css.async)), l.push(...$(w.assets.css.sync)), a.push(...$(w.assets.js.async)), a.push(...$(w.assets.js.sync))) : (I.resourceCategory = "sync") && (l.push(...$(w.assets.css.sync)), a.push(...$(w.assets.js.sync))), setPreloaded(P));
|
|
1553
1549
|
}
|
|
1554
1550
|
}
|
|
1555
1551
|
}, !0, {}, s), s.shared) {
|
|
@@ -1574,9 +1570,9 @@ function generatePreloadAssets(n, t, o, r, s) {
|
|
|
1574
1570
|
});
|
|
1575
1571
|
});
|
|
1576
1572
|
}
|
|
1577
|
-
const g =
|
|
1573
|
+
const g = a.filter((_) => !c.has(_) && !isExisted("script", _));
|
|
1578
1574
|
return {
|
|
1579
|
-
cssAssets:
|
|
1575
|
+
cssAssets: l.filter((_) => !u.has(_) && !isExisted("link", _)),
|
|
1580
1576
|
jsAssetsWithoutEntry: g,
|
|
1581
1577
|
entryAssets: i.filter((_) => !isExisted("script", _.url))
|
|
1582
1578
|
};
|
|
@@ -1585,7 +1581,7 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1585
1581
|
return {
|
|
1586
1582
|
name: "generate-preload-assets-plugin",
|
|
1587
1583
|
async generatePreloadAssets(n) {
|
|
1588
|
-
const { origin: t, preloadOptions:
|
|
1584
|
+
const { origin: t, preloadOptions: r, remoteInfo: o, remote: s, globalSnapshot: l, remoteSnapshot: a } = n;
|
|
1589
1585
|
return isBrowserEnv() ? isRemoteInfoWithEntry(s) && isPureRemoteEntry(s) ? {
|
|
1590
1586
|
cssAssets: [],
|
|
1591
1587
|
jsAssetsWithoutEntry: [],
|
|
@@ -1594,15 +1590,15 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1594
1590
|
name: s.name,
|
|
1595
1591
|
url: s.entry,
|
|
1596
1592
|
moduleInfo: {
|
|
1597
|
-
name:
|
|
1593
|
+
name: o.name,
|
|
1598
1594
|
entry: s.entry,
|
|
1599
|
-
type:
|
|
1595
|
+
type: o.type || "global",
|
|
1600
1596
|
entryGlobalName: "",
|
|
1601
1597
|
shareScope: ""
|
|
1602
1598
|
}
|
|
1603
1599
|
}
|
|
1604
1600
|
]
|
|
1605
|
-
} : (assignRemoteInfo(
|
|
1601
|
+
} : (assignRemoteInfo(o, a), generatePreloadAssets(t, r, o, l, a)) : {
|
|
1606
1602
|
cssAssets: [],
|
|
1607
1603
|
jsAssetsWithoutEntry: [],
|
|
1608
1604
|
entryAssets: []
|
|
@@ -1611,16 +1607,16 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1611
1607
|
};
|
|
1612
1608
|
};
|
|
1613
1609
|
function getGlobalRemoteInfo(n, t) {
|
|
1614
|
-
const
|
|
1615
|
-
name: t.name,
|
|
1610
|
+
const r = getGlobalSnapshotInfoByModuleInfo({
|
|
1611
|
+
name: t.options.name,
|
|
1616
1612
|
version: t.options.version
|
|
1617
|
-
}),
|
|
1618
|
-
return
|
|
1619
|
-
hostGlobalSnapshot:
|
|
1613
|
+
}), o = r && "remotesInfo" in r && r.remotesInfo && getInfoWithoutType(r.remotesInfo, n.name).value;
|
|
1614
|
+
return o && o.matchedVersion ? {
|
|
1615
|
+
hostGlobalSnapshot: r,
|
|
1620
1616
|
globalSnapshot: getGlobalSnapshot(),
|
|
1621
1617
|
remoteSnapshot: getGlobalSnapshotInfoByModuleInfo({
|
|
1622
1618
|
name: n.name,
|
|
1623
|
-
version:
|
|
1619
|
+
version: o.matchedVersion
|
|
1624
1620
|
})
|
|
1625
1621
|
} : {
|
|
1626
1622
|
hostGlobalSnapshot: void 0,
|
|
@@ -1632,117 +1628,128 @@ function getGlobalRemoteInfo(n, t) {
|
|
|
1632
1628
|
};
|
|
1633
1629
|
}
|
|
1634
1630
|
class SnapshotHandler {
|
|
1631
|
+
async loadSnapshot(t) {
|
|
1632
|
+
const { options: r } = this.HostInstance, { hostGlobalSnapshot: o, remoteSnapshot: s, globalSnapshot: l } = this.getGlobalRemoteInfo(t), { remoteSnapshot: a, globalSnapshot: i } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1633
|
+
options: r,
|
|
1634
|
+
moduleInfo: t,
|
|
1635
|
+
hostGlobalSnapshot: o,
|
|
1636
|
+
remoteSnapshot: s,
|
|
1637
|
+
globalSnapshot: l
|
|
1638
|
+
});
|
|
1639
|
+
return {
|
|
1640
|
+
remoteSnapshot: a,
|
|
1641
|
+
globalSnapshot: i
|
|
1642
|
+
};
|
|
1643
|
+
}
|
|
1635
1644
|
// eslint-disable-next-line max-lines-per-function
|
|
1636
|
-
async loadRemoteSnapshotInfo(
|
|
1637
|
-
const { options:
|
|
1645
|
+
async loadRemoteSnapshotInfo(t) {
|
|
1646
|
+
const { options: r } = this.HostInstance;
|
|
1638
1647
|
await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({
|
|
1639
|
-
options:
|
|
1648
|
+
options: r,
|
|
1640
1649
|
moduleInfo: t
|
|
1641
1650
|
});
|
|
1642
|
-
let
|
|
1651
|
+
let o = getGlobalSnapshotInfoByModuleInfo({
|
|
1643
1652
|
name: this.HostInstance.options.name,
|
|
1644
1653
|
version: this.HostInstance.options.version
|
|
1645
1654
|
});
|
|
1646
|
-
|
|
1655
|
+
o || (o = {
|
|
1647
1656
|
version: this.HostInstance.options.version || "",
|
|
1648
1657
|
remoteEntry: "",
|
|
1649
1658
|
remotesInfo: {}
|
|
1650
1659
|
}, addGlobalSnapshot({
|
|
1651
|
-
[this.HostInstance.options.name]:
|
|
1652
|
-
})),
|
|
1660
|
+
[this.HostInstance.options.name]: o
|
|
1661
|
+
})), o && "remotesInfo" in o && !getInfoWithoutType(o.remotesInfo, t.name).value && ("version" in t || "entry" in t) && (o.remotesInfo = _extends$1({}, o == null ? void 0 : o.remotesInfo, {
|
|
1653
1662
|
[t.name]: {
|
|
1654
1663
|
matchedVersion: "version" in t ? t.version : t.entry
|
|
1655
1664
|
}
|
|
1656
1665
|
}));
|
|
1657
|
-
const { hostGlobalSnapshot:
|
|
1658
|
-
options:
|
|
1666
|
+
const { hostGlobalSnapshot: s, remoteSnapshot: l, globalSnapshot: a } = this.getGlobalRemoteInfo(t), { remoteSnapshot: i, globalSnapshot: c } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1667
|
+
options: r,
|
|
1659
1668
|
moduleInfo: t,
|
|
1660
|
-
hostGlobalSnapshot:
|
|
1661
|
-
remoteSnapshot:
|
|
1662
|
-
globalSnapshot:
|
|
1669
|
+
hostGlobalSnapshot: s,
|
|
1670
|
+
remoteSnapshot: l,
|
|
1671
|
+
globalSnapshot: a
|
|
1663
1672
|
});
|
|
1664
|
-
let
|
|
1665
|
-
if (
|
|
1666
|
-
if (isManifestProvider(
|
|
1667
|
-
const
|
|
1673
|
+
let u, p;
|
|
1674
|
+
if (i)
|
|
1675
|
+
if (isManifestProvider(i)) {
|
|
1676
|
+
const d = isBrowserEnv() ? i.remoteEntry : i.ssrRemoteEntry || i.remoteEntry || "", m = await this.getManifestJson(d, t, {}), y = setGlobalSnapshotInfoByModuleInfo(_extends$1({}, t, {
|
|
1668
1677
|
// The global remote may be overridden
|
|
1669
1678
|
// Therefore, set the snapshot key to the global address of the actual request
|
|
1670
|
-
entry:
|
|
1671
|
-
}),
|
|
1672
|
-
|
|
1679
|
+
entry: d
|
|
1680
|
+
}), m);
|
|
1681
|
+
u = m, p = y;
|
|
1673
1682
|
} else {
|
|
1674
|
-
const { remoteSnapshot:
|
|
1683
|
+
const { remoteSnapshot: d } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1675
1684
|
options: this.HostInstance.options,
|
|
1676
1685
|
moduleInfo: t,
|
|
1677
|
-
remoteSnapshot:
|
|
1686
|
+
remoteSnapshot: i,
|
|
1678
1687
|
from: "global"
|
|
1679
1688
|
});
|
|
1680
|
-
|
|
1689
|
+
u = d, p = c;
|
|
1681
1690
|
}
|
|
1682
1691
|
else if (isRemoteInfoWithEntry(t)) {
|
|
1683
|
-
const
|
|
1692
|
+
const d = await this.getManifestJson(t.entry, t, {}), m = setGlobalSnapshotInfoByModuleInfo(t, d), { remoteSnapshot: y } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1684
1693
|
options: this.HostInstance.options,
|
|
1685
1694
|
moduleInfo: t,
|
|
1686
|
-
remoteSnapshot:
|
|
1695
|
+
remoteSnapshot: d,
|
|
1687
1696
|
from: "global"
|
|
1688
1697
|
});
|
|
1689
|
-
|
|
1698
|
+
u = y, p = m;
|
|
1690
1699
|
} else
|
|
1691
1700
|
error(getShortErrorMsg(RUNTIME_007, runtimeDescMap, {
|
|
1692
1701
|
hostName: t.name,
|
|
1693
1702
|
hostVersion: t.version,
|
|
1694
|
-
globalSnapshot: JSON.stringify(
|
|
1703
|
+
globalSnapshot: JSON.stringify(c)
|
|
1695
1704
|
}));
|
|
1696
1705
|
return await this.hooks.lifecycle.afterLoadSnapshot.emit({
|
|
1697
|
-
|
|
1698
|
-
host: this.HostInstance,
|
|
1699
|
-
options: s,
|
|
1706
|
+
options: r,
|
|
1700
1707
|
moduleInfo: t,
|
|
1701
|
-
remoteSnapshot:
|
|
1708
|
+
remoteSnapshot: u
|
|
1702
1709
|
}), {
|
|
1703
|
-
remoteSnapshot:
|
|
1704
|
-
globalSnapshot:
|
|
1710
|
+
remoteSnapshot: u,
|
|
1711
|
+
globalSnapshot: p
|
|
1705
1712
|
};
|
|
1706
1713
|
}
|
|
1707
1714
|
getGlobalRemoteInfo(t) {
|
|
1708
1715
|
return getGlobalRemoteInfo(t, this.HostInstance);
|
|
1709
1716
|
}
|
|
1710
|
-
async getManifestJson(t,
|
|
1717
|
+
async getManifestJson(t, r, o) {
|
|
1711
1718
|
const s = async () => {
|
|
1712
|
-
let
|
|
1713
|
-
if (
|
|
1714
|
-
return
|
|
1719
|
+
let a = this.manifestCache.get(t);
|
|
1720
|
+
if (a)
|
|
1721
|
+
return a;
|
|
1715
1722
|
try {
|
|
1716
1723
|
let i = await this.loaderHook.lifecycle.fetch.emit(t, {});
|
|
1717
|
-
(!i || !(i instanceof Response)) && (i = await fetch(t, {})),
|
|
1724
|
+
(!i || !(i instanceof Response)) && (i = await fetch(t, {})), a = await i.json();
|
|
1718
1725
|
} catch (i) {
|
|
1719
|
-
|
|
1726
|
+
a = await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
1720
1727
|
id: t,
|
|
1721
1728
|
error: i,
|
|
1722
1729
|
from: "runtime",
|
|
1723
1730
|
lifecycle: "afterResolve",
|
|
1724
1731
|
origin: this.HostInstance
|
|
1725
|
-
}),
|
|
1732
|
+
}), a || (delete this.manifestLoading[t], error(getShortErrorMsg(RUNTIME_003, runtimeDescMap, {
|
|
1726
1733
|
manifestUrl: t,
|
|
1727
|
-
moduleName:
|
|
1734
|
+
moduleName: r.name,
|
|
1728
1735
|
hostName: this.HostInstance.options.name
|
|
1729
1736
|
}, `${i}`)));
|
|
1730
1737
|
}
|
|
1731
|
-
return assert(
|
|
1732
|
-
},
|
|
1733
|
-
const
|
|
1738
|
+
return assert(a.metaData && a.exposes && a.shared, `${t} is not a federation manifest`), this.manifestCache.set(t, a), a;
|
|
1739
|
+
}, l = async () => {
|
|
1740
|
+
const a = await s(), i = generateSnapshotFromManifest(a, {
|
|
1734
1741
|
version: t
|
|
1735
1742
|
}), { remoteSnapshot: c } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1736
1743
|
options: this.HostInstance.options,
|
|
1737
|
-
moduleInfo:
|
|
1738
|
-
manifestJson:
|
|
1744
|
+
moduleInfo: r,
|
|
1745
|
+
manifestJson: a,
|
|
1739
1746
|
remoteSnapshot: i,
|
|
1740
1747
|
manifestUrl: t,
|
|
1741
1748
|
from: "manifest"
|
|
1742
1749
|
});
|
|
1743
1750
|
return c;
|
|
1744
1751
|
};
|
|
1745
|
-
return this.manifestLoading[t] || (this.manifestLoading[t] =
|
|
1752
|
+
return this.manifestLoading[t] || (this.manifestLoading[t] = l().then((a) => a)), this.manifestLoading[t];
|
|
1746
1753
|
}
|
|
1747
1754
|
constructor(t) {
|
|
1748
1755
|
this.loadingHostSnapshot = null, this.manifestCache = /* @__PURE__ */ new Map(), this.hooks = new PluginSystem({
|
|
@@ -1755,44 +1762,44 @@ class SnapshotHandler {
|
|
|
1755
1762
|
}
|
|
1756
1763
|
class SharedHandler {
|
|
1757
1764
|
// register shared in shareScopeMap
|
|
1758
|
-
registerShared(t,
|
|
1759
|
-
const { shareInfos:
|
|
1760
|
-
return Object.keys(
|
|
1761
|
-
|
|
1762
|
-
!getRegisteredShare(this.shareScopeMap,
|
|
1763
|
-
pkgName:
|
|
1765
|
+
registerShared(t, r) {
|
|
1766
|
+
const { shareInfos: o, shared: s } = formatShareConfigs(t, r);
|
|
1767
|
+
return Object.keys(o).forEach((a) => {
|
|
1768
|
+
o[a].forEach((c) => {
|
|
1769
|
+
!getRegisteredShare(this.shareScopeMap, a, c, this.hooks.lifecycle.resolveShare) && c && c.lib && this.setShared({
|
|
1770
|
+
pkgName: a,
|
|
1764
1771
|
lib: c.lib,
|
|
1765
1772
|
get: c.get,
|
|
1766
1773
|
loaded: !0,
|
|
1767
1774
|
shared: c,
|
|
1768
|
-
from:
|
|
1775
|
+
from: r.name
|
|
1769
1776
|
});
|
|
1770
1777
|
});
|
|
1771
1778
|
}), {
|
|
1772
|
-
shareInfos:
|
|
1779
|
+
shareInfos: o,
|
|
1773
1780
|
shared: s
|
|
1774
1781
|
};
|
|
1775
1782
|
}
|
|
1776
|
-
async loadShare(t,
|
|
1777
|
-
const { host:
|
|
1783
|
+
async loadShare(t, r) {
|
|
1784
|
+
const { host: o } = this, s = getTargetSharedOptions({
|
|
1778
1785
|
pkgName: t,
|
|
1779
|
-
extraOptions:
|
|
1780
|
-
shareInfos:
|
|
1786
|
+
extraOptions: r,
|
|
1787
|
+
shareInfos: o.options.shared
|
|
1781
1788
|
});
|
|
1782
1789
|
s != null && s.scope && await Promise.all(s.scope.map(async (u) => {
|
|
1783
1790
|
await Promise.all(this.initializeSharing(u, {
|
|
1784
1791
|
strategy: s.strategy
|
|
1785
1792
|
}));
|
|
1786
1793
|
}));
|
|
1787
|
-
const
|
|
1794
|
+
const l = await this.hooks.lifecycle.beforeLoadShare.emit({
|
|
1788
1795
|
pkgName: t,
|
|
1789
1796
|
shareInfo: s,
|
|
1790
|
-
shared:
|
|
1791
|
-
origin:
|
|
1792
|
-
}), { shareInfo:
|
|
1793
|
-
assert(
|
|
1794
|
-
const i = getRegisteredShare(this.shareScopeMap, t,
|
|
1795
|
-
u.useIn || (u.useIn = []), addUniqueItem(u.useIn,
|
|
1797
|
+
shared: o.options.shared,
|
|
1798
|
+
origin: o
|
|
1799
|
+
}), { shareInfo: a } = l;
|
|
1800
|
+
assert(a, `Cannot find ${t} Share in the ${o.options.name}. Please ensure that the ${t} Share parameters have been injected`);
|
|
1801
|
+
const i = getRegisteredShare(this.shareScopeMap, t, a, this.hooks.lifecycle.resolveShare), c = (u) => {
|
|
1802
|
+
u.useIn || (u.useIn = []), addUniqueItem(u.useIn, o.options.name);
|
|
1796
1803
|
};
|
|
1797
1804
|
if (i && i.lib)
|
|
1798
1805
|
return c(i), i.lib;
|
|
@@ -1802,32 +1809,32 @@ class SharedHandler {
|
|
|
1802
1809
|
} else if (i) {
|
|
1803
1810
|
const p = (async () => {
|
|
1804
1811
|
const d = await i.get();
|
|
1805
|
-
|
|
1806
|
-
const m = getRegisteredShare(this.shareScopeMap, t,
|
|
1812
|
+
a.lib = d, a.loaded = !0, c(a);
|
|
1813
|
+
const m = getRegisteredShare(this.shareScopeMap, t, a, this.hooks.lifecycle.resolveShare);
|
|
1807
1814
|
return m && (m.lib = d, m.loaded = !0), d;
|
|
1808
1815
|
})();
|
|
1809
1816
|
return this.setShared({
|
|
1810
1817
|
pkgName: t,
|
|
1811
1818
|
loaded: !1,
|
|
1812
1819
|
shared: i,
|
|
1813
|
-
from:
|
|
1820
|
+
from: o.options.name,
|
|
1814
1821
|
lib: null,
|
|
1815
1822
|
loading: p
|
|
1816
1823
|
}), p;
|
|
1817
1824
|
} else {
|
|
1818
|
-
if (
|
|
1825
|
+
if (r != null && r.customShareInfo)
|
|
1819
1826
|
return !1;
|
|
1820
1827
|
const p = (async () => {
|
|
1821
|
-
const d = await
|
|
1822
|
-
|
|
1823
|
-
const m = getRegisteredShare(this.shareScopeMap, t,
|
|
1828
|
+
const d = await a.get();
|
|
1829
|
+
a.lib = d, a.loaded = !0, c(a);
|
|
1830
|
+
const m = getRegisteredShare(this.shareScopeMap, t, a, this.hooks.lifecycle.resolveShare);
|
|
1824
1831
|
return m && (m.lib = d, m.loaded = !0), d;
|
|
1825
1832
|
})();
|
|
1826
1833
|
return this.setShared({
|
|
1827
1834
|
pkgName: t,
|
|
1828
1835
|
loaded: !1,
|
|
1829
|
-
shared:
|
|
1830
|
-
from:
|
|
1836
|
+
shared: a,
|
|
1837
|
+
from: o.options.name,
|
|
1831
1838
|
lib: null,
|
|
1832
1839
|
loading: p
|
|
1833
1840
|
}), p;
|
|
@@ -1839,20 +1846,20 @@ class SharedHandler {
|
|
|
1839
1846
|
* If the share scope does not exist, it creates one.
|
|
1840
1847
|
*/
|
|
1841
1848
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
1842
|
-
initializeSharing(t = DEFAULT_SCOPE,
|
|
1843
|
-
const { host:
|
|
1844
|
-
let
|
|
1849
|
+
initializeSharing(t = DEFAULT_SCOPE, r) {
|
|
1850
|
+
const { host: o } = this, s = r == null ? void 0 : r.from, l = r == null ? void 0 : r.strategy;
|
|
1851
|
+
let a = r == null ? void 0 : r.initScope;
|
|
1845
1852
|
const i = [];
|
|
1846
1853
|
if (s !== "build") {
|
|
1847
1854
|
const { initTokens: g } = this;
|
|
1848
|
-
|
|
1855
|
+
a || (a = []);
|
|
1849
1856
|
let E = g[t];
|
|
1850
1857
|
if (E || (E = g[t] = {
|
|
1851
1858
|
from: this.host.name
|
|
1852
|
-
}),
|
|
1853
|
-
|
|
1859
|
+
}), a.indexOf(E) >= 0) return i;
|
|
1860
|
+
a.push(E);
|
|
1854
1861
|
}
|
|
1855
|
-
const c = this.shareScopeMap, u =
|
|
1862
|
+
const c = this.shareScopeMap, u = o.options.name;
|
|
1856
1863
|
c[t] || (c[t] = {});
|
|
1857
1864
|
const p = c[t], d = (g, E) => {
|
|
1858
1865
|
var _;
|
|
@@ -1860,8 +1867,8 @@ class SharedHandler {
|
|
|
1860
1867
|
p[g] = p[g] || {};
|
|
1861
1868
|
const I = p[g], S = I[b], R = !!(S && (S.eager || (_ = S.shareConfig) != null && _.eager));
|
|
1862
1869
|
(!S || S.strategy !== "loaded-first" && !S.loaded && (!v != !R ? v : u > S.from)) && (I[b] = E);
|
|
1863
|
-
}, m = (g) => g && g.init && g.init(c[t],
|
|
1864
|
-
const { module: E } = await
|
|
1870
|
+
}, m = (g) => g && g.init && g.init(c[t], a), y = async (g) => {
|
|
1871
|
+
const { module: E } = await o.remoteHandler.getRemoteModuleAndOptions({
|
|
1865
1872
|
id: g
|
|
1866
1873
|
});
|
|
1867
1874
|
if (E.getEntry) {
|
|
@@ -1869,22 +1876,22 @@ class SharedHandler {
|
|
|
1869
1876
|
try {
|
|
1870
1877
|
_ = await E.getEntry();
|
|
1871
1878
|
} catch (b) {
|
|
1872
|
-
_ = await
|
|
1879
|
+
_ = await o.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
1873
1880
|
id: g,
|
|
1874
1881
|
error: b,
|
|
1875
1882
|
from: "runtime",
|
|
1876
1883
|
lifecycle: "beforeLoadShare",
|
|
1877
|
-
origin:
|
|
1884
|
+
origin: o
|
|
1878
1885
|
});
|
|
1879
1886
|
}
|
|
1880
1887
|
E.inited || (await m(_), E.inited = !0);
|
|
1881
1888
|
}
|
|
1882
1889
|
};
|
|
1883
|
-
return Object.keys(
|
|
1884
|
-
|
|
1890
|
+
return Object.keys(o.options.shared).forEach((g) => {
|
|
1891
|
+
o.options.shared[g].forEach((_) => {
|
|
1885
1892
|
_.scope.includes(t) && d(g, _);
|
|
1886
1893
|
});
|
|
1887
|
-
}), (
|
|
1894
|
+
}), (o.options.shareStrategy === "version-first" || l === "version-first") && o.options.remotes.forEach((g) => {
|
|
1888
1895
|
g.shareScope === t && i.push(y(g.name));
|
|
1889
1896
|
}), i;
|
|
1890
1897
|
}
|
|
@@ -1892,32 +1899,32 @@ class SharedHandler {
|
|
|
1892
1899
|
// 1. If the loaded shared already exists globally, then it will be reused
|
|
1893
1900
|
// 2. If lib exists in local shared, it will be used directly
|
|
1894
1901
|
// 3. If the local get returns something other than Promise, then it will be used directly
|
|
1895
|
-
loadShareSync(t,
|
|
1896
|
-
const { host:
|
|
1902
|
+
loadShareSync(t, r) {
|
|
1903
|
+
const { host: o } = this, s = getTargetSharedOptions({
|
|
1897
1904
|
pkgName: t,
|
|
1898
|
-
extraOptions:
|
|
1899
|
-
shareInfos:
|
|
1905
|
+
extraOptions: r,
|
|
1906
|
+
shareInfos: o.options.shared
|
|
1900
1907
|
});
|
|
1901
1908
|
s != null && s.scope && s.scope.forEach((i) => {
|
|
1902
1909
|
this.initializeSharing(i, {
|
|
1903
1910
|
strategy: s.strategy
|
|
1904
1911
|
});
|
|
1905
1912
|
});
|
|
1906
|
-
const
|
|
1907
|
-
i.useIn || (i.useIn = []), addUniqueItem(i.useIn,
|
|
1913
|
+
const l = getRegisteredShare(this.shareScopeMap, t, s, this.hooks.lifecycle.resolveShare), a = (i) => {
|
|
1914
|
+
i.useIn || (i.useIn = []), addUniqueItem(i.useIn, o.options.name);
|
|
1908
1915
|
};
|
|
1909
|
-
if (
|
|
1910
|
-
if (typeof
|
|
1911
|
-
return l
|
|
1912
|
-
if (typeof
|
|
1913
|
-
const i =
|
|
1916
|
+
if (l) {
|
|
1917
|
+
if (typeof l.lib == "function")
|
|
1918
|
+
return a(l), l.loaded || (l.loaded = !0, l.from === o.options.name && (s.loaded = !0)), l.lib;
|
|
1919
|
+
if (typeof l.get == "function") {
|
|
1920
|
+
const i = l.get();
|
|
1914
1921
|
if (!(i instanceof Promise))
|
|
1915
|
-
return l
|
|
1922
|
+
return a(l), this.setShared({
|
|
1916
1923
|
pkgName: t,
|
|
1917
1924
|
loaded: !0,
|
|
1918
|
-
from:
|
|
1925
|
+
from: o.options.name,
|
|
1919
1926
|
lib: i,
|
|
1920
|
-
shared:
|
|
1927
|
+
shared: l
|
|
1921
1928
|
}), i;
|
|
1922
1929
|
}
|
|
1923
1930
|
}
|
|
@@ -1926,37 +1933,37 @@ class SharedHandler {
|
|
|
1926
1933
|
if (s.get) {
|
|
1927
1934
|
const i = s.get();
|
|
1928
1935
|
if (i instanceof Promise) {
|
|
1929
|
-
const c = (
|
|
1936
|
+
const c = (r == null ? void 0 : r.from) === "build" ? RUNTIME_005 : RUNTIME_006;
|
|
1930
1937
|
throw new Error(getShortErrorMsg(c, runtimeDescMap, {
|
|
1931
|
-
hostName:
|
|
1938
|
+
hostName: o.options.name,
|
|
1932
1939
|
sharedPkgName: t
|
|
1933
1940
|
}));
|
|
1934
1941
|
}
|
|
1935
1942
|
return s.lib = i, this.setShared({
|
|
1936
1943
|
pkgName: t,
|
|
1937
1944
|
loaded: !0,
|
|
1938
|
-
from:
|
|
1945
|
+
from: o.options.name,
|
|
1939
1946
|
lib: s.lib,
|
|
1940
1947
|
shared: s
|
|
1941
1948
|
}), s.lib;
|
|
1942
1949
|
}
|
|
1943
1950
|
throw new Error(getShortErrorMsg(RUNTIME_006, runtimeDescMap, {
|
|
1944
|
-
hostName:
|
|
1951
|
+
hostName: o.options.name,
|
|
1945
1952
|
sharedPkgName: t
|
|
1946
1953
|
}));
|
|
1947
1954
|
}
|
|
1948
|
-
initShareScopeMap(t,
|
|
1955
|
+
initShareScopeMap(t, r, o = {}) {
|
|
1949
1956
|
const { host: s } = this;
|
|
1950
|
-
this.shareScopeMap[t] =
|
|
1951
|
-
shareScope:
|
|
1957
|
+
this.shareScopeMap[t] = r, this.hooks.lifecycle.initContainerShareScopeMap.emit({
|
|
1958
|
+
shareScope: r,
|
|
1952
1959
|
options: s.options,
|
|
1953
1960
|
origin: s,
|
|
1954
1961
|
scopeName: t,
|
|
1955
|
-
hostShareScopeMap:
|
|
1962
|
+
hostShareScopeMap: o.hostShareScopeMap
|
|
1956
1963
|
});
|
|
1957
1964
|
}
|
|
1958
|
-
setShared({ pkgName: t, shared:
|
|
1959
|
-
const { version: c, scope: u = "default" } =
|
|
1965
|
+
setShared({ pkgName: t, shared: r, from: o, lib: s, loading: l, loaded: a, get: i }) {
|
|
1966
|
+
const { version: c, scope: u = "default" } = r, p = _object_without_properties_loose(r, [
|
|
1960
1967
|
"version",
|
|
1961
1968
|
"scope"
|
|
1962
1969
|
]);
|
|
@@ -1971,18 +1978,18 @@ class SharedHandler {
|
|
|
1971
1978
|
]
|
|
1972
1979
|
}, p, {
|
|
1973
1980
|
lib: s,
|
|
1974
|
-
loaded:
|
|
1975
|
-
loading:
|
|
1981
|
+
loaded: a,
|
|
1982
|
+
loading: l
|
|
1976
1983
|
}), i && (this.shareScopeMap[m][t][c].get = i);
|
|
1977
1984
|
return;
|
|
1978
1985
|
}
|
|
1979
1986
|
const y = this.shareScopeMap[m][t][c];
|
|
1980
|
-
|
|
1987
|
+
l && !y.loading && (y.loading = l);
|
|
1981
1988
|
});
|
|
1982
1989
|
}
|
|
1983
1990
|
_setGlobalShareScopeMap(t) {
|
|
1984
|
-
const
|
|
1985
|
-
|
|
1991
|
+
const r = getGlobalShareScope(), o = t.id || t.name;
|
|
1992
|
+
o && !r[o] && (r[o] = this.shareScopeMap);
|
|
1986
1993
|
}
|
|
1987
1994
|
constructor(t) {
|
|
1988
1995
|
this.hooks = new PluginSystem({
|
|
@@ -1997,147 +2004,145 @@ class SharedHandler {
|
|
|
1997
2004
|
}
|
|
1998
2005
|
}
|
|
1999
2006
|
class RemoteHandler {
|
|
2000
|
-
formatAndRegisterRemote(t,
|
|
2001
|
-
return (
|
|
2007
|
+
formatAndRegisterRemote(t, r) {
|
|
2008
|
+
return (r.remotes || []).reduce((s, l) => (this.registerRemote(l, s, {
|
|
2002
2009
|
force: !1
|
|
2003
2010
|
}), s), t.remotes);
|
|
2004
2011
|
}
|
|
2005
|
-
setIdToRemoteMap(t,
|
|
2006
|
-
const { remote:
|
|
2012
|
+
setIdToRemoteMap(t, r) {
|
|
2013
|
+
const { remote: o, expose: s } = r, { name: l, alias: a } = o;
|
|
2007
2014
|
if (this.idToRemoteMap[t] = {
|
|
2008
|
-
name:
|
|
2015
|
+
name: o.name,
|
|
2009
2016
|
expose: s
|
|
2010
|
-
},
|
|
2011
|
-
const i = t.replace(
|
|
2017
|
+
}, a && t.startsWith(l)) {
|
|
2018
|
+
const i = t.replace(l, a);
|
|
2012
2019
|
this.idToRemoteMap[i] = {
|
|
2013
|
-
name:
|
|
2020
|
+
name: o.name,
|
|
2014
2021
|
expose: s
|
|
2015
2022
|
};
|
|
2016
2023
|
return;
|
|
2017
2024
|
}
|
|
2018
|
-
if (
|
|
2019
|
-
const i = t.replace(
|
|
2025
|
+
if (a && t.startsWith(a)) {
|
|
2026
|
+
const i = t.replace(a, l);
|
|
2020
2027
|
this.idToRemoteMap[i] = {
|
|
2021
|
-
name:
|
|
2028
|
+
name: o.name,
|
|
2022
2029
|
expose: s
|
|
2023
2030
|
};
|
|
2024
2031
|
}
|
|
2025
2032
|
}
|
|
2026
2033
|
// eslint-disable-next-line max-lines-per-function
|
|
2027
2034
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
2028
|
-
async loadRemote(t,
|
|
2029
|
-
const { host:
|
|
2035
|
+
async loadRemote(t, r) {
|
|
2036
|
+
const { host: o } = this;
|
|
2030
2037
|
try {
|
|
2031
|
-
const { loadFactory: s = !0 } =
|
|
2038
|
+
const { loadFactory: s = !0 } = r || {
|
|
2032
2039
|
loadFactory: !0
|
|
2033
|
-
}, { module:
|
|
2040
|
+
}, { module: l, moduleOptions: a, remoteMatchInfo: i } = await this.getRemoteModuleAndOptions({
|
|
2034
2041
|
id: t
|
|
2035
|
-
}), { pkgNameOrAlias: c, remote: u, expose: p, id: d, remoteSnapshot: m } = i, y = await
|
|
2042
|
+
}), { pkgNameOrAlias: c, remote: u, expose: p, id: d, remoteSnapshot: m } = i, y = await l.get(d, p, r, m), g = await this.hooks.lifecycle.onLoad.emit({
|
|
2036
2043
|
id: d,
|
|
2037
2044
|
pkgNameOrAlias: c,
|
|
2038
2045
|
expose: p,
|
|
2039
2046
|
exposeModule: s ? y : void 0,
|
|
2040
2047
|
exposeModuleFactory: s ? void 0 : y,
|
|
2041
2048
|
remote: u,
|
|
2042
|
-
options:
|
|
2043
|
-
moduleInstance:
|
|
2044
|
-
origin:
|
|
2049
|
+
options: a,
|
|
2050
|
+
moduleInstance: l,
|
|
2051
|
+
origin: o
|
|
2045
2052
|
});
|
|
2046
2053
|
return this.setIdToRemoteMap(t, i), typeof g == "function" ? g : y;
|
|
2047
2054
|
} catch (s) {
|
|
2048
|
-
const { from:
|
|
2055
|
+
const { from: l = "runtime" } = r || {
|
|
2049
2056
|
from: "runtime"
|
|
2050
|
-
},
|
|
2057
|
+
}, a = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2051
2058
|
id: t,
|
|
2052
2059
|
error: s,
|
|
2053
|
-
from:
|
|
2060
|
+
from: l,
|
|
2054
2061
|
lifecycle: "onLoad",
|
|
2055
|
-
origin:
|
|
2062
|
+
origin: o
|
|
2056
2063
|
});
|
|
2057
|
-
if (!
|
|
2064
|
+
if (!a)
|
|
2058
2065
|
throw s;
|
|
2059
|
-
return
|
|
2066
|
+
return a;
|
|
2060
2067
|
}
|
|
2061
2068
|
}
|
|
2062
2069
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
2063
2070
|
async preloadRemote(t) {
|
|
2064
|
-
const { host:
|
|
2071
|
+
const { host: r } = this;
|
|
2065
2072
|
await this.hooks.lifecycle.beforePreloadRemote.emit({
|
|
2066
2073
|
preloadOps: t,
|
|
2067
|
-
options:
|
|
2068
|
-
origin:
|
|
2074
|
+
options: r.options,
|
|
2075
|
+
origin: r
|
|
2069
2076
|
});
|
|
2070
|
-
const
|
|
2071
|
-
await Promise.all(
|
|
2072
|
-
const { remote:
|
|
2073
|
-
|
|
2074
|
-
}), u = await this.hooks.lifecycle.generatePreloadAssets.emit({
|
|
2075
|
-
origin: o,
|
|
2077
|
+
const o = formatPreloadArgs(r.options.remotes, t);
|
|
2078
|
+
await Promise.all(o.map(async (s) => {
|
|
2079
|
+
const { remote: l } = s, a = getRemoteInfo(l), { globalSnapshot: i, remoteSnapshot: c } = await r.snapshotHandler.loadRemoteSnapshotInfo(l), u = await this.hooks.lifecycle.generatePreloadAssets.emit({
|
|
2080
|
+
origin: r,
|
|
2076
2081
|
preloadOptions: s,
|
|
2077
|
-
remote:
|
|
2078
|
-
remoteInfo:
|
|
2082
|
+
remote: l,
|
|
2083
|
+
remoteInfo: a,
|
|
2079
2084
|
globalSnapshot: i,
|
|
2080
2085
|
remoteSnapshot: c
|
|
2081
2086
|
});
|
|
2082
|
-
u && preloadAssets(
|
|
2087
|
+
u && preloadAssets(a, r, u);
|
|
2083
2088
|
}));
|
|
2084
2089
|
}
|
|
2085
|
-
registerRemotes(t,
|
|
2086
|
-
const { host:
|
|
2090
|
+
registerRemotes(t, r) {
|
|
2091
|
+
const { host: o } = this;
|
|
2087
2092
|
t.forEach((s) => {
|
|
2088
|
-
this.registerRemote(s,
|
|
2089
|
-
force:
|
|
2093
|
+
this.registerRemote(s, o.options.remotes, {
|
|
2094
|
+
force: r == null ? void 0 : r.force
|
|
2090
2095
|
});
|
|
2091
2096
|
});
|
|
2092
2097
|
}
|
|
2093
2098
|
async getRemoteModuleAndOptions(t) {
|
|
2094
|
-
const { host:
|
|
2099
|
+
const { host: r } = this, { id: o } = t;
|
|
2095
2100
|
let s;
|
|
2096
2101
|
try {
|
|
2097
2102
|
s = await this.hooks.lifecycle.beforeRequest.emit({
|
|
2098
|
-
id:
|
|
2099
|
-
options:
|
|
2100
|
-
origin:
|
|
2103
|
+
id: o,
|
|
2104
|
+
options: r.options,
|
|
2105
|
+
origin: r
|
|
2101
2106
|
});
|
|
2102
2107
|
} catch (g) {
|
|
2103
2108
|
if (s = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2104
|
-
id:
|
|
2105
|
-
options:
|
|
2106
|
-
origin:
|
|
2109
|
+
id: o,
|
|
2110
|
+
options: r.options,
|
|
2111
|
+
origin: r,
|
|
2107
2112
|
from: "runtime",
|
|
2108
2113
|
error: g,
|
|
2109
2114
|
lifecycle: "beforeRequest"
|
|
2110
2115
|
}), !s)
|
|
2111
2116
|
throw g;
|
|
2112
2117
|
}
|
|
2113
|
-
const { id:
|
|
2114
|
-
assert(
|
|
2115
|
-
hostName:
|
|
2116
|
-
requestId:
|
|
2118
|
+
const { id: l } = s, a = matchRemoteWithNameAndExpose(r.options.remotes, l);
|
|
2119
|
+
assert(a, getShortErrorMsg(RUNTIME_004, runtimeDescMap, {
|
|
2120
|
+
hostName: r.options.name,
|
|
2121
|
+
requestId: l
|
|
2117
2122
|
}));
|
|
2118
|
-
const { remote: i } =
|
|
2119
|
-
id:
|
|
2120
|
-
},
|
|
2121
|
-
options:
|
|
2122
|
-
origin:
|
|
2123
|
+
const { remote: i } = a, c = getRemoteInfo(i), u = await r.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({
|
|
2124
|
+
id: l
|
|
2125
|
+
}, a, {
|
|
2126
|
+
options: r.options,
|
|
2127
|
+
origin: r,
|
|
2123
2128
|
remoteInfo: c
|
|
2124
2129
|
})), { remote: p, expose: d } = u;
|
|
2125
|
-
assert(p && d, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${
|
|
2126
|
-
let m =
|
|
2130
|
+
assert(p && d, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${l}.`);
|
|
2131
|
+
let m = r.moduleCache.get(p.name);
|
|
2127
2132
|
const y = {
|
|
2128
|
-
host:
|
|
2133
|
+
host: r,
|
|
2129
2134
|
remoteInfo: c
|
|
2130
2135
|
};
|
|
2131
|
-
return m || (m = new Module(y),
|
|
2136
|
+
return m || (m = new Module(y), r.moduleCache.set(p.name, m)), {
|
|
2132
2137
|
module: m,
|
|
2133
2138
|
moduleOptions: y,
|
|
2134
2139
|
remoteMatchInfo: u
|
|
2135
2140
|
};
|
|
2136
2141
|
}
|
|
2137
|
-
registerRemote(t,
|
|
2138
|
-
const { host: s } = this,
|
|
2142
|
+
registerRemote(t, r, o) {
|
|
2143
|
+
const { host: s } = this, l = () => {
|
|
2139
2144
|
if (t.alias) {
|
|
2140
|
-
const i =
|
|
2145
|
+
const i = r.find((c) => {
|
|
2141
2146
|
var u;
|
|
2142
2147
|
return t.alias && (c.name.startsWith(t.alias) || ((u = c.alias) == null ? void 0 : u.startsWith(t.alias)));
|
|
2143
2148
|
});
|
|
@@ -2149,9 +2154,9 @@ class RemoteHandler {
|
|
|
2149
2154
|
remote: t,
|
|
2150
2155
|
origin: s
|
|
2151
2156
|
});
|
|
2152
|
-
const
|
|
2153
|
-
if (!
|
|
2154
|
-
|
|
2157
|
+
const a = r.find((i) => i.name === t.name);
|
|
2158
|
+
if (!a)
|
|
2159
|
+
l(), r.push(t), this.hooks.lifecycle.registerRemote.emit({
|
|
2155
2160
|
remote: t,
|
|
2156
2161
|
origin: s
|
|
2157
2162
|
});
|
|
@@ -2160,7 +2165,7 @@ class RemoteHandler {
|
|
|
2160
2165
|
`The remote "${t.name}" is already registered.`,
|
|
2161
2166
|
"Please note that overriding it may cause unexpected errors."
|
|
2162
2167
|
];
|
|
2163
|
-
|
|
2168
|
+
o != null && o.force && (this.removeRemote(a), l(), r.push(t), this.hooks.lifecycle.registerRemote.emit({
|
|
2164
2169
|
remote: t,
|
|
2165
2170
|
origin: s
|
|
2166
2171
|
}), warn$1(i.join(" ")));
|
|
@@ -2168,17 +2173,17 @@ class RemoteHandler {
|
|
|
2168
2173
|
}
|
|
2169
2174
|
removeRemote(t) {
|
|
2170
2175
|
try {
|
|
2171
|
-
const { host:
|
|
2172
|
-
|
|
2173
|
-
const
|
|
2174
|
-
if (
|
|
2175
|
-
const i =
|
|
2176
|
+
const { host: o } = this, { name: s } = t, l = o.options.remotes.findIndex((i) => i.name === s);
|
|
2177
|
+
l !== -1 && o.options.remotes.splice(l, 1);
|
|
2178
|
+
const a = o.moduleCache.get(t.name);
|
|
2179
|
+
if (a) {
|
|
2180
|
+
const i = a.remoteInfo, c = i.entryGlobalName;
|
|
2176
2181
|
if (CurrentGlobal[c]) {
|
|
2177
|
-
var
|
|
2178
|
-
(
|
|
2182
|
+
var r;
|
|
2183
|
+
(r = Object.getOwnPropertyDescriptor(CurrentGlobal, c)) != null && r.configurable ? delete CurrentGlobal[c] : CurrentGlobal[c] = void 0;
|
|
2179
2184
|
}
|
|
2180
|
-
const u = getRemoteEntryUniqueKey(
|
|
2181
|
-
globalLoading[u] && delete globalLoading[u],
|
|
2185
|
+
const u = getRemoteEntryUniqueKey(a.remoteInfo);
|
|
2186
|
+
globalLoading[u] && delete globalLoading[u], o.snapshotHandler.manifestCache.delete(i.entry);
|
|
2182
2187
|
let p = i.buildVersion ? composeKeyWithSeparator(i.name, i.buildVersion) : i.name;
|
|
2183
2188
|
const d = CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex((y) => i.buildVersion ? y.options.id === p : y.name === p);
|
|
2184
2189
|
if (d !== -1) {
|
|
@@ -2195,7 +2200,7 @@ class RemoteHandler {
|
|
|
2195
2200
|
const A = S[R];
|
|
2196
2201
|
A && Object.keys(A).forEach((T) => {
|
|
2197
2202
|
const $ = A[T];
|
|
2198
|
-
$ && typeof $ == "object" && $.from === i.name && ($.loaded || $.loading ? ($.useIn = $.useIn.filter((
|
|
2203
|
+
$ && typeof $ == "object" && $.from === i.name && ($.loaded || $.loading ? ($.useIn = $.useIn.filter((N) => N !== i.name), $.useIn.length ? E = !1 : _.push([
|
|
2199
2204
|
b,
|
|
2200
2205
|
I,
|
|
2201
2206
|
R,
|
|
@@ -2214,15 +2219,15 @@ class RemoteHandler {
|
|
|
2214
2219
|
(T = g[b]) == null || (A = T[v]) == null || (R = A[I]) == null || delete R[S];
|
|
2215
2220
|
}), CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(d, 1);
|
|
2216
2221
|
}
|
|
2217
|
-
const { hostGlobalSnapshot: m } = getGlobalRemoteInfo(t,
|
|
2222
|
+
const { hostGlobalSnapshot: m } = getGlobalRemoteInfo(t, o);
|
|
2218
2223
|
if (m) {
|
|
2219
2224
|
const y = m && "remotesInfo" in m && m.remotesInfo && getInfoWithoutType(m.remotesInfo, t.name).key;
|
|
2220
2225
|
y && (delete m.remotesInfo[y], Global.__FEDERATION__.__MANIFEST_LOADING__[y] && delete Global.__FEDERATION__.__MANIFEST_LOADING__[y]);
|
|
2221
2226
|
}
|
|
2222
|
-
|
|
2227
|
+
o.moduleCache.delete(t.name);
|
|
2223
2228
|
}
|
|
2224
|
-
} catch (
|
|
2225
|
-
logger.log("removeRemote fail: ",
|
|
2229
|
+
} catch (o) {
|
|
2230
|
+
logger.log("removeRemote fail: ", o);
|
|
2226
2231
|
}
|
|
2227
2232
|
}
|
|
2228
2233
|
constructor(t) {
|
|
@@ -2245,59 +2250,59 @@ const USE_SNAPSHOT = typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN == "boolean"
|
|
|
2245
2250
|
class FederationHost {
|
|
2246
2251
|
initOptions(t) {
|
|
2247
2252
|
this.registerPlugins(t.plugins);
|
|
2248
|
-
const
|
|
2249
|
-
return this.options =
|
|
2253
|
+
const r = this.formatOptions(this.options, t);
|
|
2254
|
+
return this.options = r, r;
|
|
2250
2255
|
}
|
|
2251
|
-
async loadShare(t,
|
|
2252
|
-
return this.sharedHandler.loadShare(t,
|
|
2256
|
+
async loadShare(t, r) {
|
|
2257
|
+
return this.sharedHandler.loadShare(t, r);
|
|
2253
2258
|
}
|
|
2254
2259
|
// The lib function will only be available if the shared set by eager or runtime init is set or the shared is successfully loaded.
|
|
2255
2260
|
// 1. If the loaded shared already exists globally, then it will be reused
|
|
2256
2261
|
// 2. If lib exists in local shared, it will be used directly
|
|
2257
2262
|
// 3. If the local get returns something other than Promise, then it will be used directly
|
|
2258
|
-
loadShareSync(t,
|
|
2259
|
-
return this.sharedHandler.loadShareSync(t,
|
|
2263
|
+
loadShareSync(t, r) {
|
|
2264
|
+
return this.sharedHandler.loadShareSync(t, r);
|
|
2260
2265
|
}
|
|
2261
|
-
initializeSharing(t = DEFAULT_SCOPE,
|
|
2262
|
-
return this.sharedHandler.initializeSharing(t,
|
|
2266
|
+
initializeSharing(t = DEFAULT_SCOPE, r) {
|
|
2267
|
+
return this.sharedHandler.initializeSharing(t, r);
|
|
2263
2268
|
}
|
|
2264
|
-
initRawContainer(t,
|
|
2269
|
+
initRawContainer(t, r, o) {
|
|
2265
2270
|
const s = getRemoteInfo({
|
|
2266
2271
|
name: t,
|
|
2267
|
-
entry:
|
|
2268
|
-
}),
|
|
2272
|
+
entry: r
|
|
2273
|
+
}), l = new Module({
|
|
2269
2274
|
host: this,
|
|
2270
2275
|
remoteInfo: s
|
|
2271
2276
|
});
|
|
2272
|
-
return
|
|
2277
|
+
return l.remoteEntryExports = o, this.moduleCache.set(t, l), l;
|
|
2273
2278
|
}
|
|
2274
2279
|
// eslint-disable-next-line max-lines-per-function
|
|
2275
2280
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
2276
|
-
async loadRemote(t,
|
|
2277
|
-
return this.remoteHandler.loadRemote(t,
|
|
2281
|
+
async loadRemote(t, r) {
|
|
2282
|
+
return this.remoteHandler.loadRemote(t, r);
|
|
2278
2283
|
}
|
|
2279
2284
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
2280
2285
|
async preloadRemote(t) {
|
|
2281
2286
|
return this.remoteHandler.preloadRemote(t);
|
|
2282
2287
|
}
|
|
2283
|
-
initShareScopeMap(t,
|
|
2284
|
-
this.sharedHandler.initShareScopeMap(t,
|
|
2288
|
+
initShareScopeMap(t, r, o = {}) {
|
|
2289
|
+
this.sharedHandler.initShareScopeMap(t, r, o);
|
|
2285
2290
|
}
|
|
2286
|
-
formatOptions(t,
|
|
2287
|
-
const { shared:
|
|
2291
|
+
formatOptions(t, r) {
|
|
2292
|
+
const { shared: o } = formatShareConfigs(t, r), { userOptions: s, options: l } = this.hooks.lifecycle.beforeInit.emit({
|
|
2288
2293
|
origin: this,
|
|
2289
|
-
userOptions:
|
|
2294
|
+
userOptions: r,
|
|
2290
2295
|
options: t,
|
|
2291
|
-
shareInfo:
|
|
2292
|
-
}),
|
|
2293
|
-
...
|
|
2296
|
+
shareInfo: o
|
|
2297
|
+
}), a = this.remoteHandler.formatAndRegisterRemote(l, s), { shared: i } = this.sharedHandler.registerShared(l, s), c = [
|
|
2298
|
+
...l.plugins
|
|
2294
2299
|
];
|
|
2295
2300
|
s.plugins && s.plugins.forEach((p) => {
|
|
2296
2301
|
c.includes(p) || c.push(p);
|
|
2297
2302
|
});
|
|
2298
|
-
const u = _extends$1({}, t,
|
|
2303
|
+
const u = _extends$1({}, t, r, {
|
|
2299
2304
|
plugins: c,
|
|
2300
|
-
remotes:
|
|
2305
|
+
remotes: a,
|
|
2301
2306
|
shared: i
|
|
2302
2307
|
});
|
|
2303
2308
|
return this.hooks.lifecycle.init.emit({
|
|
@@ -2306,7 +2311,7 @@ class FederationHost {
|
|
|
2306
2311
|
}), u;
|
|
2307
2312
|
}
|
|
2308
2313
|
registerPlugins(t) {
|
|
2309
|
-
const
|
|
2314
|
+
const r = registerPlugins(t, [
|
|
2310
2315
|
this.hooks,
|
|
2311
2316
|
this.remoteHandler.hooks,
|
|
2312
2317
|
this.sharedHandler.hooks,
|
|
@@ -2314,10 +2319,10 @@ class FederationHost {
|
|
|
2314
2319
|
this.loaderHook,
|
|
2315
2320
|
this.bridgeHook
|
|
2316
2321
|
]);
|
|
2317
|
-
this.options.plugins = this.options.plugins.reduce((
|
|
2322
|
+
this.options.plugins = this.options.plugins.reduce((o, s) => (s && o && !o.find((l) => l.name === s.name) && o.push(s), o), r || []);
|
|
2318
2323
|
}
|
|
2319
|
-
registerRemotes(t,
|
|
2320
|
-
return this.remoteHandler.registerRemotes(t,
|
|
2324
|
+
registerRemotes(t, r) {
|
|
2325
|
+
return this.remoteHandler.registerRemotes(t, r);
|
|
2321
2326
|
}
|
|
2322
2327
|
constructor(t) {
|
|
2323
2328
|
this.hooks = new PluginSystem({
|
|
@@ -2327,7 +2332,7 @@ class FederationHost {
|
|
|
2327
2332
|
beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
|
|
2328
2333
|
// maybe will change, temporarily for internal use only
|
|
2329
2334
|
initContainer: new AsyncWaterfallHook("initContainer")
|
|
2330
|
-
}), this.version = "0.
|
|
2335
|
+
}), this.version = "0.14.3", this.moduleCache = /* @__PURE__ */ new Map(), this.loaderHook = new PluginSystem({
|
|
2331
2336
|
// FIXME: may not be suitable , not open to the public yet
|
|
2332
2337
|
getModuleInfo: new SyncHook(),
|
|
2333
2338
|
createScript: new SyncHook(),
|
|
@@ -2341,21 +2346,21 @@ class FederationHost {
|
|
|
2341
2346
|
beforeBridgeDestroy: new SyncHook(),
|
|
2342
2347
|
afterBridgeDestroy: new SyncHook()
|
|
2343
2348
|
});
|
|
2344
|
-
const
|
|
2349
|
+
const r = USE_SNAPSHOT ? [
|
|
2345
2350
|
snapshotPlugin(),
|
|
2346
2351
|
generatePreloadAssetsPlugin()
|
|
2347
|
-
] : [],
|
|
2352
|
+
] : [], o = {
|
|
2348
2353
|
id: getBuilderId(),
|
|
2349
2354
|
name: t.name,
|
|
2350
|
-
plugins:
|
|
2355
|
+
plugins: r,
|
|
2351
2356
|
remotes: [],
|
|
2352
2357
|
shared: {},
|
|
2353
2358
|
inBrowser: isBrowserEnv()
|
|
2354
2359
|
};
|
|
2355
|
-
this.name = t.name, this.options =
|
|
2356
|
-
...
|
|
2360
|
+
this.name = t.name, this.options = o, this.snapshotHandler = new SnapshotHandler(this), this.sharedHandler = new SharedHandler(this), this.remoteHandler = new RemoteHandler(this), this.shareScopeMap = this.sharedHandler.shareScopeMap, this.registerPlugins([
|
|
2361
|
+
...o.plugins,
|
|
2357
2362
|
...t.plugins || []
|
|
2358
|
-
]), this.options = this.formatOptions(
|
|
2363
|
+
]), this.options = this.formatOptions(o, t);
|
|
2359
2364
|
}
|
|
2360
2365
|
}
|
|
2361
2366
|
let FederationInstance = null;
|
|
@@ -2364,24 +2369,24 @@ function getInstance() {
|
|
|
2364
2369
|
}
|
|
2365
2370
|
setGlobalFederationConstructor(FederationHost);
|
|
2366
2371
|
function createBridgeComponent(n) {
|
|
2367
|
-
const t = /* @__PURE__ */ new Map(),
|
|
2372
|
+
const t = /* @__PURE__ */ new Map(), r = getInstance();
|
|
2368
2373
|
return () => ({
|
|
2369
|
-
__APP_VERSION__: "0.
|
|
2370
|
-
async render(
|
|
2374
|
+
__APP_VERSION__: "0.14.3",
|
|
2375
|
+
async render(o) {
|
|
2371
2376
|
var g, E, _;
|
|
2372
|
-
LoggerInstance.debug("createBridgeComponent render Info",
|
|
2377
|
+
LoggerInstance.debug("createBridgeComponent render Info", o);
|
|
2373
2378
|
const {
|
|
2374
2379
|
moduleName: s,
|
|
2375
|
-
dom:
|
|
2376
|
-
basename:
|
|
2380
|
+
dom: l,
|
|
2381
|
+
basename: a,
|
|
2377
2382
|
memoryRoute: i,
|
|
2378
2383
|
hashRoute: c,
|
|
2379
2384
|
...u
|
|
2380
|
-
} =
|
|
2381
|
-
t.set(
|
|
2382
|
-
const d = await ((_ = (E = (g =
|
|
2385
|
+
} = o, p = Vue.createApp(n.rootComponent, u);
|
|
2386
|
+
t.set(l, p);
|
|
2387
|
+
const d = await ((_ = (E = (g = r == null ? void 0 : r.bridgeHook) == null ? void 0 : g.lifecycle) == null ? void 0 : E.beforeBridgeRender) == null ? void 0 : _.emit(o)), m = d && typeof d == "object" && (d != null && d.extraProps) ? d == null ? void 0 : d.extraProps : {}, y = n.appOptions({
|
|
2383
2388
|
app: p,
|
|
2384
|
-
basename:
|
|
2389
|
+
basename: a,
|
|
2385
2390
|
memoryRoute: i,
|
|
2386
2391
|
hashRoute: c,
|
|
2387
2392
|
...u,
|
|
@@ -2389,10 +2394,10 @@ function createBridgeComponent(n) {
|
|
|
2389
2394
|
});
|
|
2390
2395
|
if (y != null && y.router) {
|
|
2391
2396
|
let b, v = y.router.getRoutes();
|
|
2392
|
-
|
|
2397
|
+
o.memoryRoute ? b = VueRouter.createMemoryHistory(o.basename) : o.hashRoute ? (b = VueRouter.createWebHashHistory(), v = v.map((S) => ({
|
|
2393
2398
|
...S,
|
|
2394
|
-
path:
|
|
2395
|
-
}))) : b = VueRouter.createWebHistory(
|
|
2399
|
+
path: o.basename + S.path
|
|
2400
|
+
}))) : b = VueRouter.createWebHistory(o.basename);
|
|
2396
2401
|
const I = VueRouter.createRouter({
|
|
2397
2402
|
...y.router.options,
|
|
2398
2403
|
history: b,
|
|
@@ -2403,11 +2408,11 @@ function createBridgeComponent(n) {
|
|
|
2403
2408
|
router: I
|
|
2404
2409
|
}), i && await I.push(i.entryPath), p.use(I);
|
|
2405
2410
|
}
|
|
2406
|
-
p.mount(
|
|
2411
|
+
p.mount(l);
|
|
2407
2412
|
},
|
|
2408
|
-
destroy(
|
|
2409
|
-
LoggerInstance.debug("createBridgeComponent destroy Info",
|
|
2410
|
-
const s = t.get(
|
|
2413
|
+
destroy(o) {
|
|
2414
|
+
LoggerInstance.debug("createBridgeComponent destroy Info", o);
|
|
2415
|
+
const s = t.get(o == null ? void 0 : o.dom);
|
|
2411
2416
|
s == null || s.unmount();
|
|
2412
2417
|
}
|
|
2413
2418
|
});
|
|
@@ -2428,12 +2433,12 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2428
2433
|
},
|
|
2429
2434
|
inheritAttrs: !1,
|
|
2430
2435
|
setup(n) {
|
|
2431
|
-
const t = ref(null),
|
|
2436
|
+
const t = ref(null), r = ref(null), o = ref(""), s = useRoute(), l = getInstance(), a = useAttrs(), i = async () => {
|
|
2432
2437
|
var m, y, g, E;
|
|
2433
2438
|
const u = (m = n.providerInfo) == null ? void 0 : m.call(n);
|
|
2434
|
-
|
|
2439
|
+
r.value = u;
|
|
2435
2440
|
let p = {
|
|
2436
|
-
...
|
|
2441
|
+
...a,
|
|
2437
2442
|
moduleName: n.moduleName,
|
|
2438
2443
|
dom: t.value,
|
|
2439
2444
|
basename: n.basename,
|
|
@@ -2441,16 +2446,16 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2441
2446
|
hashRoute: n.hashRoute
|
|
2442
2447
|
};
|
|
2443
2448
|
LoggerInstance.debug("createRemoteComponent LazyComponent render >>>", p);
|
|
2444
|
-
const d = await ((E = (g = (y =
|
|
2449
|
+
const d = await ((E = (g = (y = l == null ? void 0 : l.bridgeHook) == null ? void 0 : y.lifecycle) == null ? void 0 : g.beforeBridgeRender) == null ? void 0 : E.emit(p)) || {};
|
|
2445
2450
|
p = {
|
|
2446
2451
|
...p,
|
|
2447
2452
|
...d.extraProps
|
|
2448
2453
|
}, u.render(p);
|
|
2449
2454
|
}, c = watch(() => s == null ? void 0 : s.path, (u) => {
|
|
2450
|
-
u !== s.path && i(),
|
|
2455
|
+
u !== s.path && i(), o.value !== "" && o.value !== u && (LoggerInstance.debug("createRemoteComponent dispatchPopstateEnv >>>", {
|
|
2451
2456
|
...n,
|
|
2452
2457
|
pathname: s.path
|
|
2453
|
-
}), e()),
|
|
2458
|
+
}), e()), o.value = u;
|
|
2454
2459
|
});
|
|
2455
2460
|
return onMounted(() => {
|
|
2456
2461
|
i();
|
|
@@ -2458,7 +2463,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2458
2463
|
var u;
|
|
2459
2464
|
LoggerInstance.debug("createRemoteComponent LazyComponent destroy >>>", {
|
|
2460
2465
|
...n
|
|
2461
|
-
}), c(), (u =
|
|
2466
|
+
}), c(), (u = r.value) == null || u.destroy({
|
|
2462
2467
|
dom: t.value
|
|
2463
2468
|
});
|
|
2464
2469
|
}), () => createVNode("div", mergeProps(n.rootAttrs || {}, {
|
|
@@ -2468,31 +2473,31 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2468
2473
|
});
|
|
2469
2474
|
function createRemoteComponent(n) {
|
|
2470
2475
|
return defineAsyncComponent({
|
|
2471
|
-
__APP_VERSION__: "0.
|
|
2476
|
+
__APP_VERSION__: "0.14.3",
|
|
2472
2477
|
...n.asyncComponentOptions,
|
|
2473
2478
|
//@ts-ignore
|
|
2474
2479
|
loader: async () => {
|
|
2475
2480
|
var c, u;
|
|
2476
2481
|
const t = useRoute();
|
|
2477
|
-
let
|
|
2478
|
-
const
|
|
2479
|
-
|
|
2482
|
+
let r = "/";
|
|
2483
|
+
const o = (u = (c = t == null ? void 0 : t.matched) == null ? void 0 : c[0]) == null ? void 0 : u.path;
|
|
2484
|
+
o && (o.endsWith("/:pathMatch(.*)*") ? r = o.replace("/:pathMatch(.*)*", "") : r = t.matched[0].path);
|
|
2480
2485
|
const s = (n == null ? void 0 : n.export) || "default";
|
|
2481
2486
|
LoggerInstance.debug("createRemoteComponent LazyComponent create >>>", {
|
|
2482
|
-
basename:
|
|
2487
|
+
basename: r,
|
|
2483
2488
|
info: n
|
|
2484
2489
|
});
|
|
2485
|
-
const
|
|
2490
|
+
const l = await n.loader(), a = l && l[Symbol.for("mf_module_id")], i = l[s];
|
|
2486
2491
|
if (LoggerInstance.debug(
|
|
2487
2492
|
"createRemoteComponent LazyComponent loadRemote info >>>",
|
|
2488
|
-
{ moduleName:
|
|
2489
|
-
), s in
|
|
2493
|
+
{ moduleName: a, module: l, exportName: s, basename: r, route: t }
|
|
2494
|
+
), s in l && typeof i == "function")
|
|
2490
2495
|
return {
|
|
2491
2496
|
render() {
|
|
2492
2497
|
return h(RemoteApp, {
|
|
2493
|
-
moduleName:
|
|
2498
|
+
moduleName: a,
|
|
2494
2499
|
providerInfo: i,
|
|
2495
|
-
basename:
|
|
2500
|
+
basename: r,
|
|
2496
2501
|
rootAttrs: n.rootAttrs
|
|
2497
2502
|
});
|
|
2498
2503
|
}
|