@module-federation/bridge-vue3 0.20.0 → 0.21.1
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 +17 -0
- package/dist/index.cjs +7 -4
- package/dist/index.js +655 -584
- package/package.json +6 -5
- package/src/provider.ts +7 -16
- package/src/routeUtils.ts +139 -0
package/dist/index.js
CHANGED
|
@@ -47,8 +47,8 @@ const simpleJoinRemoteEntry = (r, t) => {
|
|
|
47
47
|
if (s.startsWith("./"))
|
|
48
48
|
return s.replace("./", "");
|
|
49
49
|
if (s.startsWith("/")) {
|
|
50
|
-
const
|
|
51
|
-
return
|
|
50
|
+
const a = s.slice(1);
|
|
51
|
+
return a.endsWith("/") ? a.slice(0, -1) : a;
|
|
52
52
|
}
|
|
53
53
|
return s;
|
|
54
54
|
})(r);
|
|
@@ -58,31 +58,31 @@ function inferAutoPublicPath(r) {
|
|
|
58
58
|
return r.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
|
|
59
59
|
}
|
|
60
60
|
function generateSnapshotFromManifest(r, t = {}) {
|
|
61
|
-
var I, S,
|
|
61
|
+
var I, S, A;
|
|
62
62
|
const { remotes: o = {}, overrides: n = {}, version: s } = t;
|
|
63
|
-
let
|
|
64
|
-
const
|
|
63
|
+
let a;
|
|
64
|
+
const c = () => "publicPath" in r.metaData ? r.metaData.publicPath === "auto" && s ? inferAutoPublicPath(s) : r.metaData.publicPath : r.metaData.getPublicPath, i = Object.keys(n);
|
|
65
65
|
let l = {};
|
|
66
|
-
Object.keys(o).length || (l = ((I = r.remotes) == null ? void 0 : I.reduce((_,
|
|
66
|
+
Object.keys(o).length || (l = ((I = r.remotes) == null ? void 0 : I.reduce((_, T) => {
|
|
67
67
|
let w;
|
|
68
|
-
const $ =
|
|
69
|
-
return
|
|
68
|
+
const $ = T.federationContainerName;
|
|
69
|
+
return i.includes($) ? w = n[$] : "version" in T ? w = T.version : w = T.entry, _[$] = {
|
|
70
70
|
matchedVersion: w
|
|
71
71
|
}, _;
|
|
72
72
|
}, {})) || {}), Object.keys(o).forEach((_) => l[_] = {
|
|
73
73
|
// overrides will override dependencies
|
|
74
|
-
matchedVersion:
|
|
74
|
+
matchedVersion: i.includes(_) ? n[_] : o[_]
|
|
75
75
|
});
|
|
76
|
-
const { remoteEntry: { path: u, name:
|
|
77
|
-
let
|
|
76
|
+
const { remoteEntry: { path: u, name: p, type: m }, types: d, buildInfo: { buildVersion: y }, globalName: g, ssrRemoteEntry: b } = r.metaData, { exposes: E } = r;
|
|
77
|
+
let R = {
|
|
78
78
|
version: s || "",
|
|
79
79
|
buildVersion: y,
|
|
80
80
|
globalName: g,
|
|
81
|
-
remoteEntry: simpleJoinRemoteEntry(u,
|
|
82
|
-
remoteEntryType:
|
|
83
|
-
remoteTypes: simpleJoinRemoteEntry(
|
|
84
|
-
remoteTypesZip:
|
|
85
|
-
remoteTypesAPI:
|
|
81
|
+
remoteEntry: simpleJoinRemoteEntry(u, p),
|
|
82
|
+
remoteEntryType: m,
|
|
83
|
+
remoteTypes: simpleJoinRemoteEntry(d.path, d.name),
|
|
84
|
+
remoteTypesZip: d.zip || "",
|
|
85
|
+
remoteTypesAPI: d.api || "",
|
|
86
86
|
remotesInfo: l,
|
|
87
87
|
shared: r == null ? void 0 : r.shared.map((_) => ({
|
|
88
88
|
assets: _.assets,
|
|
@@ -97,36 +97,60 @@ function generateSnapshotFromManifest(r, t = {}) {
|
|
|
97
97
|
};
|
|
98
98
|
if ((S = r.metaData) != null && S.prefetchInterface) {
|
|
99
99
|
const _ = r.metaData.prefetchInterface;
|
|
100
|
-
|
|
101
|
-
...
|
|
100
|
+
R = {
|
|
101
|
+
...R,
|
|
102
102
|
prefetchInterface: _
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
|
-
if ((
|
|
106
|
-
const { path: _, name:
|
|
107
|
-
|
|
108
|
-
...
|
|
109
|
-
prefetchEntry: simpleJoinRemoteEntry(_,
|
|
105
|
+
if ((A = r.metaData) != null && A.prefetchEntry) {
|
|
106
|
+
const { path: _, name: T, type: w } = r.metaData.prefetchEntry;
|
|
107
|
+
R = {
|
|
108
|
+
...R,
|
|
109
|
+
prefetchEntry: simpleJoinRemoteEntry(_, T),
|
|
110
110
|
prefetchEntryType: w
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
|
-
if ("publicPath" in r.metaData ?
|
|
114
|
-
...
|
|
115
|
-
publicPath:
|
|
113
|
+
if ("publicPath" in r.metaData ? a = {
|
|
114
|
+
...R,
|
|
115
|
+
publicPath: c(),
|
|
116
116
|
ssrPublicPath: r.metaData.ssrPublicPath
|
|
117
|
-
} :
|
|
118
|
-
...
|
|
119
|
-
getPublicPath:
|
|
120
|
-
},
|
|
121
|
-
const _ = simpleJoinRemoteEntry(
|
|
122
|
-
|
|
117
|
+
} : a = {
|
|
118
|
+
...R,
|
|
119
|
+
getPublicPath: c()
|
|
120
|
+
}, b) {
|
|
121
|
+
const _ = simpleJoinRemoteEntry(b.path, b.name);
|
|
122
|
+
a.ssrRemoteEntry = _, a.ssrRemoteEntryType = b.type || "commonjs-module";
|
|
123
123
|
}
|
|
124
|
-
return
|
|
124
|
+
return a;
|
|
125
125
|
}
|
|
126
126
|
function isManifestProvider(r) {
|
|
127
127
|
return !!("remoteEntry" in r && r.remoteEntry.includes(MANIFEST_EXT));
|
|
128
128
|
}
|
|
129
|
-
const PREFIX = "[ Module Federation ]", DEFAULT_DELEGATE = console
|
|
129
|
+
const PREFIX = "[ Module Federation ]", DEFAULT_DELEGATE = console, LOGGER_STACK_SKIP_TOKENS = [
|
|
130
|
+
"logger.ts",
|
|
131
|
+
"logger.js",
|
|
132
|
+
"captureStackTrace",
|
|
133
|
+
"Logger.emit",
|
|
134
|
+
"Logger.log",
|
|
135
|
+
"Logger.info",
|
|
136
|
+
"Logger.warn",
|
|
137
|
+
"Logger.error",
|
|
138
|
+
"Logger.debug"
|
|
139
|
+
];
|
|
140
|
+
function captureStackTrace() {
|
|
141
|
+
try {
|
|
142
|
+
const r = new Error().stack;
|
|
143
|
+
if (!r)
|
|
144
|
+
return;
|
|
145
|
+
const [, ...t] = r.split(`
|
|
146
|
+
`), o = t.filter((s) => !LOGGER_STACK_SKIP_TOKENS.some((a) => s.includes(a)));
|
|
147
|
+
return o.length ? `Stack trace:
|
|
148
|
+
${o.slice(0, 5).join(`
|
|
149
|
+
`)}` : void 0;
|
|
150
|
+
} catch {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
130
154
|
class Logger {
|
|
131
155
|
constructor(t, o = DEFAULT_DELEGATE) {
|
|
132
156
|
this.prefix = t, this.delegate = o ?? DEFAULT_DELEGATE;
|
|
@@ -138,7 +162,7 @@ class Logger {
|
|
|
138
162
|
this.delegate = t ?? DEFAULT_DELEGATE;
|
|
139
163
|
}
|
|
140
164
|
emit(t, o) {
|
|
141
|
-
const n = this.delegate,
|
|
165
|
+
const n = this.delegate, a = isDebugMode() ? captureStackTrace() : void 0, c = a ? [...o, a] : o, i = (() => {
|
|
142
166
|
switch (t) {
|
|
143
167
|
case "log":
|
|
144
168
|
return ["log", "info"];
|
|
@@ -153,17 +177,17 @@ class Logger {
|
|
|
153
177
|
return ["debug", "log"];
|
|
154
178
|
}
|
|
155
179
|
})();
|
|
156
|
-
for (const
|
|
157
|
-
const
|
|
158
|
-
if (typeof
|
|
159
|
-
|
|
180
|
+
for (const l of i) {
|
|
181
|
+
const u = n[l];
|
|
182
|
+
if (typeof u == "function") {
|
|
183
|
+
u.call(n, this.prefix, ...c);
|
|
160
184
|
return;
|
|
161
185
|
}
|
|
162
186
|
}
|
|
163
|
-
for (const
|
|
164
|
-
const
|
|
165
|
-
if (typeof
|
|
166
|
-
|
|
187
|
+
for (const l of i) {
|
|
188
|
+
const u = DEFAULT_DELEGATE[l];
|
|
189
|
+
if (typeof u == "function") {
|
|
190
|
+
u.call(DEFAULT_DELEGATE, this.prefix, ...c);
|
|
167
191
|
return;
|
|
168
192
|
}
|
|
169
193
|
}
|
|
@@ -216,84 +240,84 @@ function isStaticResourcesEqual(r, t) {
|
|
|
216
240
|
}
|
|
217
241
|
function createScript(r) {
|
|
218
242
|
let t = null, o = !0, n = 2e4, s;
|
|
219
|
-
const
|
|
220
|
-
for (let
|
|
221
|
-
const l = i
|
|
243
|
+
const a = document.getElementsByTagName("script");
|
|
244
|
+
for (let i = 0; i < a.length; i++) {
|
|
245
|
+
const l = a[i], u = l.getAttribute("src");
|
|
222
246
|
if (u && isStaticResourcesEqual(u, r.url)) {
|
|
223
247
|
t = l, o = !1;
|
|
224
248
|
break;
|
|
225
249
|
}
|
|
226
250
|
}
|
|
227
251
|
if (!t) {
|
|
228
|
-
const
|
|
229
|
-
t = document.createElement("script"), t.type = (
|
|
252
|
+
const i = r.attrs;
|
|
253
|
+
t = document.createElement("script"), t.type = (i == null ? void 0 : i.type) === "module" ? "module" : "text/javascript";
|
|
230
254
|
let l;
|
|
231
|
-
r.createScriptHook && (l = r.createScriptHook(r.url, r.attrs), l instanceof HTMLScriptElement ? t = l : typeof l == "object" && ("script" in l && l.script && (t = l.script), "timeout" in l && l.timeout && (n = l.timeout))), t.src || (t.src = r.url),
|
|
232
|
-
t && (u === "async" || u === "defer" ? t[u] =
|
|
255
|
+
r.createScriptHook && (l = r.createScriptHook(r.url, r.attrs), l instanceof HTMLScriptElement ? t = l : typeof l == "object" && ("script" in l && l.script && (t = l.script), "timeout" in l && l.timeout && (n = l.timeout))), t.src || (t.src = r.url), i && !l && Object.keys(i).forEach((u) => {
|
|
256
|
+
t && (u === "async" || u === "defer" ? t[u] = i[u] : t.getAttribute(u) || t.setAttribute(u, i[u]));
|
|
233
257
|
});
|
|
234
258
|
}
|
|
235
|
-
const
|
|
259
|
+
const c = async (i, l) => {
|
|
236
260
|
clearTimeout(s);
|
|
237
261
|
const u = () => {
|
|
238
262
|
(l == null ? void 0 : l.type) === "error" ? r != null && r.onErrorCallback && (r == null || r.onErrorCallback(l)) : r != null && r.cb && (r == null || r.cb());
|
|
239
263
|
};
|
|
240
264
|
if (t && (t.onerror = null, t.onload = null, safeWrapper(() => {
|
|
241
|
-
const { needDeleteScript:
|
|
242
|
-
|
|
243
|
-
}),
|
|
244
|
-
const
|
|
245
|
-
if (
|
|
246
|
-
const
|
|
247
|
-
return u(),
|
|
265
|
+
const { needDeleteScript: p = !0 } = r;
|
|
266
|
+
p && t != null && t.parentNode && t.parentNode.removeChild(t);
|
|
267
|
+
}), i && typeof i == "function")) {
|
|
268
|
+
const p = i(l);
|
|
269
|
+
if (p instanceof Promise) {
|
|
270
|
+
const m = await p;
|
|
271
|
+
return u(), m;
|
|
248
272
|
}
|
|
249
|
-
return u(),
|
|
273
|
+
return u(), p;
|
|
250
274
|
}
|
|
251
275
|
u();
|
|
252
276
|
};
|
|
253
|
-
return t.onerror =
|
|
254
|
-
|
|
277
|
+
return t.onerror = c.bind(null, t.onerror), t.onload = c.bind(null, t.onload), s = setTimeout(() => {
|
|
278
|
+
c(null, new Error(`Remote script "${r.url}" time-outed.`));
|
|
255
279
|
}, n), { script: t, needAttach: o };
|
|
256
280
|
}
|
|
257
281
|
function createLink(r) {
|
|
258
282
|
let t = null, o = !0;
|
|
259
283
|
const n = document.getElementsByTagName("link");
|
|
260
|
-
for (let
|
|
261
|
-
const
|
|
262
|
-
if (
|
|
263
|
-
t =
|
|
284
|
+
for (let a = 0; a < n.length; a++) {
|
|
285
|
+
const c = n[a], i = c.getAttribute("href"), l = c.getAttribute("rel");
|
|
286
|
+
if (i && isStaticResourcesEqual(i, r.url) && l === r.attrs.rel) {
|
|
287
|
+
t = c, o = !1;
|
|
264
288
|
break;
|
|
265
289
|
}
|
|
266
290
|
}
|
|
267
291
|
if (!t) {
|
|
268
292
|
t = document.createElement("link"), t.setAttribute("href", r.url);
|
|
269
|
-
let
|
|
270
|
-
const
|
|
271
|
-
r.createLinkHook && (
|
|
272
|
-
t && !t.getAttribute(
|
|
293
|
+
let a;
|
|
294
|
+
const c = r.attrs;
|
|
295
|
+
r.createLinkHook && (a = r.createLinkHook(r.url, c), a instanceof HTMLLinkElement && (t = a)), c && !a && Object.keys(c).forEach((i) => {
|
|
296
|
+
t && !t.getAttribute(i) && t.setAttribute(i, c[i]);
|
|
273
297
|
});
|
|
274
298
|
}
|
|
275
|
-
const s = (
|
|
276
|
-
const
|
|
277
|
-
(
|
|
299
|
+
const s = (a, c) => {
|
|
300
|
+
const i = () => {
|
|
301
|
+
(c == null ? void 0 : c.type) === "error" ? r != null && r.onErrorCallback && (r == null || r.onErrorCallback(c)) : r != null && r.cb && (r == null || r.cb());
|
|
278
302
|
};
|
|
279
303
|
if (t && (t.onerror = null, t.onload = null, safeWrapper(() => {
|
|
280
304
|
const { needDeleteLink: l = !0 } = r;
|
|
281
305
|
l && t != null && t.parentNode && t.parentNode.removeChild(t);
|
|
282
|
-
}),
|
|
283
|
-
const l =
|
|
284
|
-
return
|
|
306
|
+
}), a)) {
|
|
307
|
+
const l = a(c);
|
|
308
|
+
return i(), l;
|
|
285
309
|
}
|
|
286
|
-
|
|
310
|
+
i();
|
|
287
311
|
};
|
|
288
312
|
return t.onerror = s.bind(null, t.onerror), t.onload = s.bind(null, t.onload), { link: t, needAttach: o };
|
|
289
313
|
}
|
|
290
314
|
function loadScript(r, t) {
|
|
291
315
|
const { attrs: o = {}, createScriptHook: n } = t;
|
|
292
|
-
return new Promise((s,
|
|
293
|
-
const { script:
|
|
316
|
+
return new Promise((s, a) => {
|
|
317
|
+
const { script: c, needAttach: i } = createScript({
|
|
294
318
|
url: r,
|
|
295
319
|
cb: s,
|
|
296
|
-
onErrorCallback:
|
|
320
|
+
onErrorCallback: a,
|
|
297
321
|
attrs: {
|
|
298
322
|
fetchpriority: "high",
|
|
299
323
|
...o
|
|
@@ -301,7 +325,7 @@ function loadScript(r, t) {
|
|
|
301
325
|
createScriptHook: n,
|
|
302
326
|
needDeleteScript: !0
|
|
303
327
|
});
|
|
304
|
-
|
|
328
|
+
i && document.head.appendChild(c);
|
|
305
329
|
});
|
|
306
330
|
}
|
|
307
331
|
const sdkImportCache = /* @__PURE__ */ new Map();
|
|
@@ -319,7 +343,7 @@ const loadNodeFetch = async () => {
|
|
|
319
343
|
const r = await importNodeModule("node-fetch");
|
|
320
344
|
return r.default || r;
|
|
321
345
|
}, lazyLoaderHookFetch = async (r, t, o) => {
|
|
322
|
-
const s = await ((
|
|
346
|
+
const s = await ((a, c) => o.lifecycle.fetch.emit(a, c))(r, t || {});
|
|
323
347
|
return !s || !(s instanceof Response) ? (typeof fetch > "u" ? await loadNodeFetch() : fetch)(r, t || {}) : s;
|
|
324
348
|
}, createScriptNode = typeof ENV_TARGET > "u" || ENV_TARGET !== "web" ? (url, cb, attrs, loaderHook) => {
|
|
325
349
|
if (loaderHook != null && loaderHook.createScriptHook) {
|
|
@@ -376,12 +400,12 @@ const loadNodeFetch = async () => {
|
|
|
376
400
|
} : (r, t, o, n) => {
|
|
377
401
|
t(new Error("createScriptNode is disabled in non-Node.js environment"));
|
|
378
402
|
}, loadScriptNode = typeof ENV_TARGET > "u" || ENV_TARGET !== "web" ? (r, t) => new Promise((o, n) => {
|
|
379
|
-
createScriptNode(r, (s,
|
|
380
|
-
var
|
|
403
|
+
createScriptNode(r, (s, a) => {
|
|
404
|
+
var c, i;
|
|
381
405
|
if (s)
|
|
382
406
|
n(s);
|
|
383
407
|
else {
|
|
384
|
-
const l = ((
|
|
408
|
+
const l = ((c = t == null ? void 0 : t.attrs) == null ? void 0 : c.globalName) || `__FEDERATION_${(i = t == null ? void 0 : t.attrs) == null ? void 0 : i.name}:custom__`, u = globalThis[l] = a;
|
|
385
409
|
o(u);
|
|
386
410
|
}
|
|
387
411
|
}, t.attrs, t.loaderHook);
|
|
@@ -391,17 +415,17 @@ const loadNodeFetch = async () => {
|
|
|
391
415
|
async function loadModule(r, t) {
|
|
392
416
|
if (esmModuleCache.has(r))
|
|
393
417
|
return esmModuleCache.get(r);
|
|
394
|
-
const { fetch: o, vm: n } = t,
|
|
418
|
+
const { fetch: o, vm: n } = t, a = await (await o(r)).text(), c = new n.SourceTextModule(a, {
|
|
395
419
|
// @ts-ignore
|
|
396
|
-
importModuleDynamically: async (
|
|
397
|
-
const u = new URL(
|
|
420
|
+
importModuleDynamically: async (i, l) => {
|
|
421
|
+
const u = new URL(i, r).href;
|
|
398
422
|
return loadModule(u, t);
|
|
399
423
|
}
|
|
400
424
|
});
|
|
401
|
-
return esmModuleCache.set(r,
|
|
402
|
-
const l = new URL(
|
|
425
|
+
return esmModuleCache.set(r, c), await c.link(async (i) => {
|
|
426
|
+
const l = new URL(i, r).href;
|
|
403
427
|
return await loadModule(l, t);
|
|
404
|
-
}),
|
|
428
|
+
}), c;
|
|
405
429
|
}
|
|
406
430
|
const LoggerInstance = createLogger("[ Module Federation Bridge Vue3 ]"), 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", RUNTIME_009 = "RUNTIME-009", getDocsUrl = (r) => `View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${r.split("-")[0].toLowerCase()}/${r}`, getShortErrorMsg = (r, t, o, n) => {
|
|
407
431
|
const s = [`${[t[r]]} #${r}`];
|
|
@@ -489,7 +513,7 @@ function includeOwnProperty(r, t) {
|
|
|
489
513
|
includeOwnProperty(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__") || definePropertyGlobalVal(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});
|
|
490
514
|
const globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;
|
|
491
515
|
function setGlobalDefaultVal(r) {
|
|
492
|
-
var t, o, n, s,
|
|
516
|
+
var t, o, n, s, a, c;
|
|
493
517
|
includeOwnProperty(r, "__VMOK__") && !includeOwnProperty(r, "__FEDERATION__") && definePropertyGlobalVal(r, "__FEDERATION__", r.__VMOK__), includeOwnProperty(r, "__FEDERATION__") || (definePropertyGlobalVal(r, "__FEDERATION__", {
|
|
494
518
|
__GLOBAL_PLUGIN__: [],
|
|
495
519
|
__INSTANCES__: [],
|
|
@@ -497,12 +521,12 @@ function setGlobalDefaultVal(r) {
|
|
|
497
521
|
__SHARE__: {},
|
|
498
522
|
__MANIFEST_LOADING__: {},
|
|
499
523
|
__PRELOADED_MAP__: /* @__PURE__ */ new Map()
|
|
500
|
-
}), definePropertyGlobalVal(r, "__VMOK__", r.__FEDERATION__)), (t = r.__FEDERATION__).__GLOBAL_PLUGIN__ ?? (t.__GLOBAL_PLUGIN__ = []), (o = r.__FEDERATION__).__INSTANCES__ ?? (o.__INSTANCES__ = []), (n = r.__FEDERATION__).moduleInfo ?? (n.moduleInfo = {}), (s = r.__FEDERATION__).__SHARE__ ?? (s.__SHARE__ = {}), (
|
|
524
|
+
}), definePropertyGlobalVal(r, "__VMOK__", r.__FEDERATION__)), (t = r.__FEDERATION__).__GLOBAL_PLUGIN__ ?? (t.__GLOBAL_PLUGIN__ = []), (o = r.__FEDERATION__).__INSTANCES__ ?? (o.__INSTANCES__ = []), (n = r.__FEDERATION__).moduleInfo ?? (n.moduleInfo = {}), (s = r.__FEDERATION__).__SHARE__ ?? (s.__SHARE__ = {}), (a = r.__FEDERATION__).__MANIFEST_LOADING__ ?? (a.__MANIFEST_LOADING__ = {}), (c = r.__FEDERATION__).__PRELOADED_MAP__ ?? (c.__PRELOADED_MAP__ = /* @__PURE__ */ new Map());
|
|
501
525
|
}
|
|
502
526
|
setGlobalDefaultVal(CurrentGlobal);
|
|
503
527
|
setGlobalDefaultVal(nativeGlobal);
|
|
504
528
|
function setGlobalFederationConstructor(r, t = isDebugMode()) {
|
|
505
|
-
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = r, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.
|
|
529
|
+
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = r, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.21.1");
|
|
506
530
|
}
|
|
507
531
|
function getInfoWithoutType(r, t) {
|
|
508
532
|
if (typeof t == "string") {
|
|
@@ -514,11 +538,11 @@ function getInfoWithoutType(r, t) {
|
|
|
514
538
|
{
|
|
515
539
|
const n = Object.keys(r);
|
|
516
540
|
for (const s of n) {
|
|
517
|
-
const [
|
|
541
|
+
const [a, c] = s.split(":"), i = `${a}:${t}`, l = r[i];
|
|
518
542
|
if (l)
|
|
519
543
|
return {
|
|
520
544
|
value: l,
|
|
521
|
-
key:
|
|
545
|
+
key: i
|
|
522
546
|
};
|
|
523
547
|
}
|
|
524
548
|
return {
|
|
@@ -534,9 +558,9 @@ const getGlobalSnapshot = () => nativeGlobal.__FEDERATION__.moduleInfo, getTarge
|
|
|
534
558
|
if (n && !n.version && "version" in r && r.version && (n.version = r.version), n)
|
|
535
559
|
return n;
|
|
536
560
|
if ("version" in r && r.version) {
|
|
537
|
-
const { version: s, ...
|
|
538
|
-
if ((
|
|
539
|
-
return
|
|
561
|
+
const { version: s, ...a } = r, c = getFMId(a), i = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, c).value;
|
|
562
|
+
if ((i == null ? void 0 : i.version) === s)
|
|
563
|
+
return i;
|
|
540
564
|
}
|
|
541
565
|
}, getGlobalSnapshotInfoByModuleInfo = (r) => getTargetSnapshotInfoByModuleInfo(r, nativeGlobal.__FEDERATION__.moduleInfo), setGlobalSnapshotInfoByModuleInfo = (r, t) => {
|
|
542
566
|
const o = getFMId(r);
|
|
@@ -572,7 +596,7 @@ function combineVersion(r, t, o, n) {
|
|
|
572
596
|
return n ? `${s}-${n}` : s;
|
|
573
597
|
}
|
|
574
598
|
function parseHyphen(r) {
|
|
575
|
-
return r.replace(parseRegex(hyphenRange), (t, o, n, s,
|
|
599
|
+
return r.replace(parseRegex(hyphenRange), (t, o, n, s, a, c, i, l, u, p, m, d) => (isXVersion(n) ? o = "" : isXVersion(s) ? o = `>=${n}.0.0` : isXVersion(a) ? o = `>=${n}.${s}.0` : o = `>=${o}`, isXVersion(u) ? l = "" : isXVersion(p) ? l = `<${Number(u) + 1}.0.0-0` : isXVersion(m) ? l = `<${u}.${Number(p) + 1}.0-0` : d ? l = `<=${u}.${p}.${m}-${d}` : l = `<=${l}`, `${o} ${l}`.trim()));
|
|
576
600
|
}
|
|
577
601
|
function parseComparatorTrim(r) {
|
|
578
602
|
return r.replace(parseRegex(comparatorTrim), "$1$2$3");
|
|
@@ -584,15 +608,15 @@ function parseCaretTrim(r) {
|
|
|
584
608
|
return r.replace(parseRegex(caretTrim), "$1^");
|
|
585
609
|
}
|
|
586
610
|
function parseCarets(r) {
|
|
587
|
-
return r.trim().split(/\s+/).map((t) => t.replace(parseRegex(caret), (o, n, s,
|
|
611
|
+
return r.trim().split(/\s+/).map((t) => t.replace(parseRegex(caret), (o, n, s, a, c) => isXVersion(n) ? "" : isXVersion(s) ? `>=${n}.0.0 <${Number(n) + 1}.0.0-0` : isXVersion(a) ? n === "0" ? `>=${n}.${s}.0 <${n}.${Number(s) + 1}.0-0` : `>=${n}.${s}.0 <${Number(n) + 1}.0.0-0` : c ? n === "0" ? s === "0" ? `>=${n}.${s}.${a}-${c} <${n}.${s}.${Number(a) + 1}-0` : `>=${n}.${s}.${a}-${c} <${n}.${Number(s) + 1}.0-0` : `>=${n}.${s}.${a}-${c} <${Number(n) + 1}.0.0-0` : n === "0" ? s === "0" ? `>=${n}.${s}.${a} <${n}.${s}.${Number(a) + 1}-0` : `>=${n}.${s}.${a} <${n}.${Number(s) + 1}.0-0` : `>=${n}.${s}.${a} <${Number(n) + 1}.0.0-0`)).join(" ");
|
|
588
612
|
}
|
|
589
613
|
function parseTildes(r) {
|
|
590
|
-
return r.trim().split(/\s+/).map((t) => t.replace(parseRegex(tilde), (o, n, s,
|
|
614
|
+
return r.trim().split(/\s+/).map((t) => t.replace(parseRegex(tilde), (o, n, s, a, c) => isXVersion(n) ? "" : isXVersion(s) ? `>=${n}.0.0 <${Number(n) + 1}.0.0-0` : isXVersion(a) ? `>=${n}.${s}.0 <${n}.${Number(s) + 1}.0-0` : c ? `>=${n}.${s}.${a}-${c} <${n}.${Number(s) + 1}.0-0` : `>=${n}.${s}.${a} <${n}.${Number(s) + 1}.0-0`)).join(" ");
|
|
591
615
|
}
|
|
592
616
|
function parseXRanges(r) {
|
|
593
|
-
return r.split(/\s+/).map((t) => t.trim().replace(parseRegex(xRange), (o, n, s,
|
|
594
|
-
const l = isXVersion(s), u = l || isXVersion(
|
|
595
|
-
return n === "=" &&
|
|
617
|
+
return r.split(/\s+/).map((t) => t.trim().replace(parseRegex(xRange), (o, n, s, a, c, i) => {
|
|
618
|
+
const l = isXVersion(s), u = l || isXVersion(a), p = u || isXVersion(c);
|
|
619
|
+
return n === "=" && p && (n = ""), i = "", l ? n === ">" || n === "<" ? "<0.0.0-0" : "*" : n && p ? (u && (a = 0), c = 0, n === ">" ? (n = ">=", u ? (s = Number(s) + 1, a = 0, c = 0) : (a = Number(a) + 1, c = 0)) : n === "<=" && (n = "<", u ? s = Number(s) + 1 : a = Number(a) + 1), n === "<" && (i = "-0"), `${n + s}.${a}.${c}${i}`) : u ? `>=${s}.0.0${i} <${Number(s) + 1}.0.0-0` : p ? `>=${s}.${a}.0${i} <${s}.${Number(a) + 1}.0-0` : o;
|
|
596
620
|
})).join(" ");
|
|
597
621
|
}
|
|
598
622
|
function parseStar(r) {
|
|
@@ -612,10 +636,10 @@ function comparePreRelease(r, t) {
|
|
|
612
636
|
return -1;
|
|
613
637
|
if (o === void 0 && n === void 0)
|
|
614
638
|
return 0;
|
|
615
|
-
for (let s = 0,
|
|
616
|
-
const
|
|
617
|
-
if (
|
|
618
|
-
return
|
|
639
|
+
for (let s = 0, a = o.length; s <= a; s++) {
|
|
640
|
+
const c = o[s], i = n[s];
|
|
641
|
+
if (c !== i)
|
|
642
|
+
return c === void 0 && i === void 0 ? 0 : c ? i ? compareAtom(c, i) : -1 : 1;
|
|
619
643
|
}
|
|
620
644
|
return 0;
|
|
621
645
|
}
|
|
@@ -688,53 +712,53 @@ function satisfy(r, t) {
|
|
|
688
712
|
const o = extractComparator(r);
|
|
689
713
|
if (!o)
|
|
690
714
|
return !1;
|
|
691
|
-
const [, n, , s,
|
|
715
|
+
const [, n, , s, a, c, i] = o, l = {
|
|
692
716
|
operator: n,
|
|
693
|
-
version: combineVersion(s,
|
|
717
|
+
version: combineVersion(s, a, c, i),
|
|
694
718
|
// exclude build atom
|
|
695
719
|
major: s,
|
|
696
|
-
minor:
|
|
697
|
-
patch:
|
|
698
|
-
preRelease:
|
|
720
|
+
minor: a,
|
|
721
|
+
patch: c,
|
|
722
|
+
preRelease: i == null ? void 0 : i.split(".")
|
|
699
723
|
}, u = t.split("||");
|
|
700
|
-
for (const
|
|
701
|
-
const
|
|
702
|
-
if (!
|
|
724
|
+
for (const p of u) {
|
|
725
|
+
const m = p.trim();
|
|
726
|
+
if (!m || m === "*" || m === "x")
|
|
703
727
|
return !0;
|
|
704
728
|
try {
|
|
705
|
-
const
|
|
706
|
-
if (!
|
|
729
|
+
const d = parseRange(m);
|
|
730
|
+
if (!d.trim())
|
|
707
731
|
return !0;
|
|
708
|
-
const y =
|
|
732
|
+
const y = d.split(" ").map((E) => parseComparatorString(E)).join(" ");
|
|
709
733
|
if (!y.trim())
|
|
710
734
|
return !0;
|
|
711
735
|
const g = y.split(/\s+/).map((E) => parseGTE0(E)).filter(Boolean);
|
|
712
736
|
if (g.length === 0)
|
|
713
737
|
continue;
|
|
714
|
-
let
|
|
738
|
+
let b = !0;
|
|
715
739
|
for (const E of g) {
|
|
716
|
-
const
|
|
717
|
-
if (!
|
|
718
|
-
|
|
740
|
+
const R = extractComparator(E);
|
|
741
|
+
if (!R) {
|
|
742
|
+
b = !1;
|
|
719
743
|
break;
|
|
720
744
|
}
|
|
721
|
-
const [, I, , S,
|
|
745
|
+
const [, I, , S, A, _, T] = R, w = {
|
|
722
746
|
operator: I,
|
|
723
|
-
version: combineVersion(S,
|
|
747
|
+
version: combineVersion(S, A, _, T),
|
|
724
748
|
major: S,
|
|
725
|
-
minor:
|
|
749
|
+
minor: A,
|
|
726
750
|
patch: _,
|
|
727
|
-
preRelease:
|
|
751
|
+
preRelease: T == null ? void 0 : T.split(".")
|
|
728
752
|
};
|
|
729
753
|
if (!compare(w, l)) {
|
|
730
|
-
|
|
754
|
+
b = !1;
|
|
731
755
|
break;
|
|
732
756
|
}
|
|
733
757
|
}
|
|
734
|
-
if (
|
|
758
|
+
if (b)
|
|
735
759
|
return !0;
|
|
736
|
-
} catch (
|
|
737
|
-
console.error(`[semver] Error processing range part "${
|
|
760
|
+
} catch (d) {
|
|
761
|
+
console.error(`[semver] Error processing range part "${m}":`, d);
|
|
738
762
|
continue;
|
|
739
763
|
}
|
|
740
764
|
}
|
|
@@ -765,28 +789,28 @@ function formatShare(r, t, o, n) {
|
|
|
765
789
|
};
|
|
766
790
|
}
|
|
767
791
|
function formatShareConfigs(r, t) {
|
|
768
|
-
const o = t.shared || {}, n = t.name, s = Object.keys(o).reduce((
|
|
769
|
-
const l = arrayOptions(o[
|
|
770
|
-
return
|
|
771
|
-
|
|
772
|
-
}),
|
|
773
|
-
}, {}),
|
|
792
|
+
const o = t.shared || {}, n = t.name, s = Object.keys(o).reduce((c, i) => {
|
|
793
|
+
const l = arrayOptions(o[i]);
|
|
794
|
+
return c[i] = c[i] || [], l.forEach((u) => {
|
|
795
|
+
c[i].push(formatShare(u, n, i, t.shareStrategy));
|
|
796
|
+
}), c;
|
|
797
|
+
}, {}), a = {
|
|
774
798
|
...r.shared
|
|
775
799
|
};
|
|
776
|
-
return Object.keys(s).forEach((
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
}) :
|
|
780
|
-
}), { shared:
|
|
800
|
+
return Object.keys(s).forEach((c) => {
|
|
801
|
+
a[c] ? s[c].forEach((i) => {
|
|
802
|
+
a[c].find((u) => u.version === i.version) || a[c].push(i);
|
|
803
|
+
}) : a[c] = s[c];
|
|
804
|
+
}), { shared: a, shareInfos: s };
|
|
781
805
|
}
|
|
782
806
|
function versionLt(r, t) {
|
|
783
807
|
const o = (n) => {
|
|
784
808
|
if (!Number.isNaN(Number(n))) {
|
|
785
|
-
const
|
|
786
|
-
let
|
|
787
|
-
for (let
|
|
788
|
-
|
|
789
|
-
return
|
|
809
|
+
const a = n.split(".");
|
|
810
|
+
let c = n;
|
|
811
|
+
for (let i = 0; i < 3 - a.length; i++)
|
|
812
|
+
c += ".0";
|
|
813
|
+
return c;
|
|
790
814
|
}
|
|
791
815
|
return n;
|
|
792
816
|
};
|
|
@@ -799,15 +823,15 @@ const findVersion = (r, t) => {
|
|
|
799
823
|
return Object.keys(r).reduce((n, s) => !n || o(n, s) || n === "0" ? s : n, 0);
|
|
800
824
|
}, isLoaded = (r) => !!r.loaded || typeof r.lib == "function", isLoading = (r) => !!r.loading;
|
|
801
825
|
function findSingletonVersionOrderByVersion(r, t, o) {
|
|
802
|
-
const n = r[t][o], s = function(
|
|
803
|
-
return !isLoaded(n[
|
|
826
|
+
const n = r[t][o], s = function(a, c) {
|
|
827
|
+
return !isLoaded(n[a]) && versionLt(a, c);
|
|
804
828
|
};
|
|
805
829
|
return findVersion(r[t][o], s);
|
|
806
830
|
}
|
|
807
831
|
function findSingletonVersionOrderByLoaded(r, t, o) {
|
|
808
|
-
const n = r[t][o], s = function(
|
|
809
|
-
const
|
|
810
|
-
return
|
|
832
|
+
const n = r[t][o], s = function(a, c) {
|
|
833
|
+
const i = (l) => isLoaded(l) || isLoading(l);
|
|
834
|
+
return i(n[c]) ? i(n[a]) ? !!versionLt(a, c) : !0 : i(n[a]) ? !1 : versionLt(a, c);
|
|
811
835
|
};
|
|
812
836
|
return findVersion(r[t][o], s);
|
|
813
837
|
}
|
|
@@ -817,30 +841,30 @@ function getFindShareFunction(r) {
|
|
|
817
841
|
function getRegisteredShare(r, t, o, n) {
|
|
818
842
|
if (!r)
|
|
819
843
|
return;
|
|
820
|
-
const { shareConfig: s, scope:
|
|
821
|
-
for (const l of
|
|
844
|
+
const { shareConfig: s, scope: a = DEFAULT_SCOPE, strategy: c } = o, i = Array.isArray(a) ? a : [a];
|
|
845
|
+
for (const l of i)
|
|
822
846
|
if (s && r[l] && r[l][t]) {
|
|
823
|
-
const { requiredVersion: u } = s,
|
|
847
|
+
const { requiredVersion: u } = s, m = getFindShareFunction(c)(r, l, t), d = () => {
|
|
824
848
|
if (s.singleton) {
|
|
825
|
-
if (typeof u == "string" && !satisfy(
|
|
826
|
-
const
|
|
827
|
-
s.strictVersion ? error(
|
|
849
|
+
if (typeof u == "string" && !satisfy(m, u)) {
|
|
850
|
+
const b = `Version ${m} from ${m && r[l][t][m].from} of shared singleton module ${t} does not satisfy the requirement of ${o.from} which needs ${u})`;
|
|
851
|
+
s.strictVersion ? error(b) : warn(b);
|
|
828
852
|
}
|
|
829
|
-
return r[l][t][
|
|
853
|
+
return r[l][t][m];
|
|
830
854
|
} else {
|
|
831
|
-
if (u === !1 || u === "*" || satisfy(
|
|
832
|
-
return r[l][t][
|
|
833
|
-
for (const [
|
|
834
|
-
if (satisfy(
|
|
855
|
+
if (u === !1 || u === "*" || satisfy(m, u))
|
|
856
|
+
return r[l][t][m];
|
|
857
|
+
for (const [b, E] of Object.entries(r[l][t]))
|
|
858
|
+
if (satisfy(b, u))
|
|
835
859
|
return E;
|
|
836
860
|
}
|
|
837
861
|
}, y = {
|
|
838
862
|
shareScopeMap: r,
|
|
839
863
|
scope: l,
|
|
840
864
|
pkgName: t,
|
|
841
|
-
version:
|
|
865
|
+
version: m,
|
|
842
866
|
GlobalFederation: Global.__FEDERATION__,
|
|
843
|
-
resolver:
|
|
867
|
+
resolver: d
|
|
844
868
|
};
|
|
845
869
|
return (n.emit(y) || y).resolver();
|
|
846
870
|
}
|
|
@@ -849,19 +873,19 @@ function getGlobalShareScope() {
|
|
|
849
873
|
return Global.__FEDERATION__.__SHARE__;
|
|
850
874
|
}
|
|
851
875
|
function getTargetSharedOptions(r) {
|
|
852
|
-
const { pkgName: t, extraOptions: o, shareInfos: n } = r, s = (
|
|
853
|
-
if (!
|
|
876
|
+
const { pkgName: t, extraOptions: o, shareInfos: n } = r, s = (c) => {
|
|
877
|
+
if (!c)
|
|
854
878
|
return;
|
|
855
|
-
const
|
|
856
|
-
|
|
857
|
-
|
|
879
|
+
const i = {};
|
|
880
|
+
c.forEach((p) => {
|
|
881
|
+
i[p.version] = p;
|
|
858
882
|
});
|
|
859
|
-
const u = findVersion(
|
|
860
|
-
return !isLoaded(
|
|
883
|
+
const u = findVersion(i, function(p, m) {
|
|
884
|
+
return !isLoaded(i[p]) && versionLt(p, m);
|
|
861
885
|
});
|
|
862
|
-
return
|
|
863
|
-
},
|
|
864
|
-
return Object.assign({},
|
|
886
|
+
return i[u];
|
|
887
|
+
}, a = (o == null ? void 0 : o.resolver) ?? s;
|
|
888
|
+
return Object.assign({}, a(n[t]), o == null ? void 0 : o.customShareInfo);
|
|
865
889
|
}
|
|
866
890
|
function getBuilderId() {
|
|
867
891
|
return typeof FEDERATION_BUILD_IDENTIFIER < "u" ? (
|
|
@@ -875,9 +899,9 @@ function matchRemoteWithNameAndExpose(r, t) {
|
|
|
875
899
|
let s = t.replace(o.name, "");
|
|
876
900
|
if (n) {
|
|
877
901
|
if (s.startsWith("/")) {
|
|
878
|
-
const
|
|
902
|
+
const i = o.name;
|
|
879
903
|
return s = `.${s}`, {
|
|
880
|
-
pkgNameOrAlias:
|
|
904
|
+
pkgNameOrAlias: i,
|
|
881
905
|
expose: s,
|
|
882
906
|
remote: o
|
|
883
907
|
};
|
|
@@ -888,17 +912,17 @@ function matchRemoteWithNameAndExpose(r, t) {
|
|
|
888
912
|
remote: o
|
|
889
913
|
};
|
|
890
914
|
}
|
|
891
|
-
const
|
|
892
|
-
let
|
|
893
|
-
if (o.alias &&
|
|
894
|
-
if (
|
|
895
|
-
const
|
|
896
|
-
return
|
|
897
|
-
pkgNameOrAlias:
|
|
898
|
-
expose:
|
|
915
|
+
const a = o.alias && t.startsWith(o.alias);
|
|
916
|
+
let c = o.alias && t.replace(o.alias, "");
|
|
917
|
+
if (o.alias && a) {
|
|
918
|
+
if (c && c.startsWith("/")) {
|
|
919
|
+
const i = o.alias;
|
|
920
|
+
return c = `.${c}`, {
|
|
921
|
+
pkgNameOrAlias: i,
|
|
922
|
+
expose: c,
|
|
899
923
|
remote: o
|
|
900
924
|
};
|
|
901
|
-
} else if (
|
|
925
|
+
} else if (c === "")
|
|
902
926
|
return {
|
|
903
927
|
pkgNameOrAlias: o.alias,
|
|
904
928
|
expose: ".",
|
|
@@ -922,10 +946,10 @@ function registerPlugins(r, t) {
|
|
|
922
946
|
t.bridgeHook
|
|
923
947
|
];
|
|
924
948
|
return o.length > 0 && o.forEach((s) => {
|
|
925
|
-
r != null && r.find((
|
|
949
|
+
r != null && r.find((a) => a.name !== s.name) && r.push(s);
|
|
926
950
|
}), r && r.length > 0 && r.forEach((s) => {
|
|
927
|
-
n.forEach((
|
|
928
|
-
|
|
951
|
+
n.forEach((a) => {
|
|
952
|
+
a.applyPlugin(s, t);
|
|
929
953
|
});
|
|
930
954
|
}), r;
|
|
931
955
|
}
|
|
@@ -964,27 +988,27 @@ function handleRemoteEntryLoaded(r, t, o) {
|
|
|
964
988
|
})), s;
|
|
965
989
|
}
|
|
966
990
|
async function loadEntryScript({ name: r, globalName: t, entry: o, loaderHook: n, getEntryUrl: s }) {
|
|
967
|
-
const { entryExports:
|
|
968
|
-
if (
|
|
969
|
-
return
|
|
970
|
-
const
|
|
971
|
-
return loadScript(
|
|
991
|
+
const { entryExports: a } = getRemoteEntryExports(r, t);
|
|
992
|
+
if (a)
|
|
993
|
+
return a;
|
|
994
|
+
const c = s ? s(o) : o;
|
|
995
|
+
return loadScript(c, {
|
|
972
996
|
attrs: {},
|
|
973
|
-
createScriptHook: (
|
|
974
|
-
const u = n.lifecycle.createScript.emit({ url:
|
|
997
|
+
createScriptHook: (i, l) => {
|
|
998
|
+
const u = n.lifecycle.createScript.emit({ url: i, attrs: l });
|
|
975
999
|
if (u && (u instanceof HTMLScriptElement || "script" in u || "timeout" in u))
|
|
976
1000
|
return u;
|
|
977
1001
|
}
|
|
978
|
-
}).then(() => handleRemoteEntryLoaded(r, t, o)).catch((
|
|
1002
|
+
}).then(() => handleRemoteEntryLoaded(r, t, o)).catch((i) => {
|
|
979
1003
|
throw assert(void 0, getShortErrorMsg(RUNTIME_008, runtimeDescMap, {
|
|
980
1004
|
remoteName: r,
|
|
981
1005
|
resourceUrl: o
|
|
982
|
-
})),
|
|
1006
|
+
})), i;
|
|
983
1007
|
});
|
|
984
1008
|
}
|
|
985
1009
|
async function loadEntryDom({ remoteInfo: r, remoteEntryExports: t, loaderHook: o, getEntryUrl: n }) {
|
|
986
|
-
const { entry: s, entryGlobalName:
|
|
987
|
-
switch (
|
|
1010
|
+
const { entry: s, entryGlobalName: a, name: c, type: i } = r;
|
|
1011
|
+
switch (i) {
|
|
988
1012
|
case "esm":
|
|
989
1013
|
case "module":
|
|
990
1014
|
return loadEsmEntry({ entry: s, remoteEntryExports: t });
|
|
@@ -993,26 +1017,26 @@ async function loadEntryDom({ remoteInfo: r, remoteEntryExports: t, loaderHook:
|
|
|
993
1017
|
default:
|
|
994
1018
|
return loadEntryScript({
|
|
995
1019
|
entry: s,
|
|
996
|
-
globalName:
|
|
997
|
-
name:
|
|
1020
|
+
globalName: a,
|
|
1021
|
+
name: c,
|
|
998
1022
|
loaderHook: o,
|
|
999
1023
|
getEntryUrl: n
|
|
1000
1024
|
});
|
|
1001
1025
|
}
|
|
1002
1026
|
}
|
|
1003
1027
|
async function loadEntryNode({ remoteInfo: r, loaderHook: t }) {
|
|
1004
|
-
const { entry: o, entryGlobalName: n, name: s, type:
|
|
1005
|
-
return
|
|
1006
|
-
attrs: { name: s, globalName: n, type:
|
|
1028
|
+
const { entry: o, entryGlobalName: n, name: s, type: a } = r, { entryExports: c } = getRemoteEntryExports(s, n);
|
|
1029
|
+
return c || loadScriptNode(o, {
|
|
1030
|
+
attrs: { name: s, globalName: n, type: a },
|
|
1007
1031
|
loaderHook: {
|
|
1008
|
-
createScriptHook: (
|
|
1009
|
-
const u = t.lifecycle.createScript.emit({ url:
|
|
1032
|
+
createScriptHook: (i, l = {}) => {
|
|
1033
|
+
const u = t.lifecycle.createScript.emit({ url: i, attrs: l });
|
|
1010
1034
|
if (u && "url" in u)
|
|
1011
1035
|
return u;
|
|
1012
1036
|
}
|
|
1013
1037
|
}
|
|
1014
|
-
}).then(() => handleRemoteEntryLoaded(s, n, o)).catch((
|
|
1015
|
-
throw
|
|
1038
|
+
}).then(() => handleRemoteEntryLoaded(s, n, o)).catch((i) => {
|
|
1039
|
+
throw i;
|
|
1016
1040
|
});
|
|
1017
1041
|
}
|
|
1018
1042
|
function getRemoteEntryUniqueKey(r) {
|
|
@@ -1020,12 +1044,12 @@ function getRemoteEntryUniqueKey(r) {
|
|
|
1020
1044
|
return composeKeyWithSeparator(o, t);
|
|
1021
1045
|
}
|
|
1022
1046
|
async function getRemoteEntry(r) {
|
|
1023
|
-
const { origin: t, remoteEntryExports: o, remoteInfo: n, getEntryUrl: s, _inErrorHandling:
|
|
1047
|
+
const { origin: t, remoteEntryExports: o, remoteInfo: n, getEntryUrl: s, _inErrorHandling: a = !1 } = r, c = getRemoteEntryUniqueKey(n);
|
|
1024
1048
|
if (o)
|
|
1025
1049
|
return o;
|
|
1026
|
-
if (!globalLoading[
|
|
1027
|
-
const
|
|
1028
|
-
globalLoading[
|
|
1050
|
+
if (!globalLoading[c]) {
|
|
1051
|
+
const i = t.remoteHandler.hooks.lifecycle.loadEntry, l = t.loaderHook;
|
|
1052
|
+
globalLoading[c] = i.emit({
|
|
1029
1053
|
loaderHook: l,
|
|
1030
1054
|
remoteInfo: n,
|
|
1031
1055
|
remoteEntryExports: o
|
|
@@ -1035,15 +1059,15 @@ async function getRemoteEntry(r) {
|
|
|
1035
1059
|
loaderHook: l,
|
|
1036
1060
|
getEntryUrl: s
|
|
1037
1061
|
}) : loadEntryNode({ remoteInfo: n, loaderHook: l }))).catch(async (u) => {
|
|
1038
|
-
const
|
|
1039
|
-
if (u instanceof Error && u.message.includes(RUNTIME_008) && !
|
|
1040
|
-
const
|
|
1041
|
-
getRemoteEntry:
|
|
1062
|
+
const p = getRemoteEntryUniqueKey(n);
|
|
1063
|
+
if (u instanceof Error && u.message.includes(RUNTIME_008) && !a) {
|
|
1064
|
+
const d = (g) => getRemoteEntry({ ...g, _inErrorHandling: !0 }), y = await t.loaderHook.lifecycle.loadEntryError.emit({
|
|
1065
|
+
getRemoteEntry: d,
|
|
1042
1066
|
origin: t,
|
|
1043
1067
|
remoteInfo: n,
|
|
1044
1068
|
remoteEntryExports: o,
|
|
1045
1069
|
globalLoading,
|
|
1046
|
-
uniqueKey:
|
|
1070
|
+
uniqueKey: p
|
|
1047
1071
|
});
|
|
1048
1072
|
if (y)
|
|
1049
1073
|
return y;
|
|
@@ -1051,7 +1075,7 @@ async function getRemoteEntry(r) {
|
|
|
1051
1075
|
throw u;
|
|
1052
1076
|
});
|
|
1053
1077
|
}
|
|
1054
|
-
return globalLoading[
|
|
1078
|
+
return globalLoading[c];
|
|
1055
1079
|
}
|
|
1056
1080
|
function getRemoteInfo(r) {
|
|
1057
1081
|
return {
|
|
@@ -1087,10 +1111,10 @@ function normalizePreloadExposes(r) {
|
|
|
1087
1111
|
return r ? r.map((t) => t === "." ? t : t.startsWith("./") ? t.replace("./", "") : t) : [];
|
|
1088
1112
|
}
|
|
1089
1113
|
function preloadAssets(r, t, o, n = !0) {
|
|
1090
|
-
const { cssAssets: s, jsAssetsWithoutEntry:
|
|
1114
|
+
const { cssAssets: s, jsAssetsWithoutEntry: a, entryAssets: c } = o;
|
|
1091
1115
|
if (t.options.inBrowser) {
|
|
1092
|
-
if (
|
|
1093
|
-
const { moduleInfo: l } =
|
|
1116
|
+
if (c.forEach((i) => {
|
|
1117
|
+
const { moduleInfo: l } = i, u = t.moduleCache.get(r.name);
|
|
1094
1118
|
getRemoteEntry(u ? {
|
|
1095
1119
|
origin: t,
|
|
1096
1120
|
remoteInfo: l,
|
|
@@ -1101,95 +1125,95 @@ function preloadAssets(r, t, o, n = !0) {
|
|
|
1101
1125
|
remoteEntryExports: void 0
|
|
1102
1126
|
});
|
|
1103
1127
|
}), n) {
|
|
1104
|
-
const
|
|
1128
|
+
const i = {
|
|
1105
1129
|
rel: "preload",
|
|
1106
1130
|
as: "style"
|
|
1107
1131
|
};
|
|
1108
1132
|
s.forEach((l) => {
|
|
1109
|
-
const { link: u, needAttach:
|
|
1133
|
+
const { link: u, needAttach: p } = createLink({
|
|
1110
1134
|
url: l,
|
|
1111
1135
|
cb: () => {
|
|
1112
1136
|
},
|
|
1113
|
-
attrs:
|
|
1114
|
-
createLinkHook: (
|
|
1137
|
+
attrs: i,
|
|
1138
|
+
createLinkHook: (m, d) => {
|
|
1115
1139
|
const y = t.loaderHook.lifecycle.createLink.emit({
|
|
1116
|
-
url:
|
|
1117
|
-
attrs:
|
|
1140
|
+
url: m,
|
|
1141
|
+
attrs: d
|
|
1118
1142
|
});
|
|
1119
1143
|
if (y instanceof HTMLLinkElement)
|
|
1120
1144
|
return y;
|
|
1121
1145
|
}
|
|
1122
1146
|
});
|
|
1123
|
-
|
|
1147
|
+
p && document.head.appendChild(u);
|
|
1124
1148
|
});
|
|
1125
1149
|
} else {
|
|
1126
|
-
const
|
|
1150
|
+
const i = {
|
|
1127
1151
|
rel: "stylesheet",
|
|
1128
1152
|
type: "text/css"
|
|
1129
1153
|
};
|
|
1130
1154
|
s.forEach((l) => {
|
|
1131
|
-
const { link: u, needAttach:
|
|
1155
|
+
const { link: u, needAttach: p } = createLink({
|
|
1132
1156
|
url: l,
|
|
1133
1157
|
cb: () => {
|
|
1134
1158
|
},
|
|
1135
|
-
attrs:
|
|
1136
|
-
createLinkHook: (
|
|
1159
|
+
attrs: i,
|
|
1160
|
+
createLinkHook: (m, d) => {
|
|
1137
1161
|
const y = t.loaderHook.lifecycle.createLink.emit({
|
|
1138
|
-
url:
|
|
1139
|
-
attrs:
|
|
1162
|
+
url: m,
|
|
1163
|
+
attrs: d
|
|
1140
1164
|
});
|
|
1141
1165
|
if (y instanceof HTMLLinkElement)
|
|
1142
1166
|
return y;
|
|
1143
1167
|
},
|
|
1144
1168
|
needDeleteLink: !1
|
|
1145
1169
|
});
|
|
1146
|
-
|
|
1170
|
+
p && document.head.appendChild(u);
|
|
1147
1171
|
});
|
|
1148
1172
|
}
|
|
1149
1173
|
if (n) {
|
|
1150
|
-
const
|
|
1174
|
+
const i = {
|
|
1151
1175
|
rel: "preload",
|
|
1152
1176
|
as: "script"
|
|
1153
1177
|
};
|
|
1154
|
-
|
|
1155
|
-
const { link: u, needAttach:
|
|
1178
|
+
a.forEach((l) => {
|
|
1179
|
+
const { link: u, needAttach: p } = createLink({
|
|
1156
1180
|
url: l,
|
|
1157
1181
|
cb: () => {
|
|
1158
1182
|
},
|
|
1159
|
-
attrs:
|
|
1160
|
-
createLinkHook: (
|
|
1183
|
+
attrs: i,
|
|
1184
|
+
createLinkHook: (m, d) => {
|
|
1161
1185
|
const y = t.loaderHook.lifecycle.createLink.emit({
|
|
1162
|
-
url:
|
|
1163
|
-
attrs:
|
|
1186
|
+
url: m,
|
|
1187
|
+
attrs: d
|
|
1164
1188
|
});
|
|
1165
1189
|
if (y instanceof HTMLLinkElement)
|
|
1166
1190
|
return y;
|
|
1167
1191
|
}
|
|
1168
1192
|
});
|
|
1169
|
-
|
|
1193
|
+
p && document.head.appendChild(u);
|
|
1170
1194
|
});
|
|
1171
1195
|
} else {
|
|
1172
|
-
const
|
|
1196
|
+
const i = {
|
|
1173
1197
|
fetchpriority: "high",
|
|
1174
1198
|
type: (r == null ? void 0 : r.type) === "module" ? "module" : "text/javascript"
|
|
1175
1199
|
};
|
|
1176
|
-
|
|
1177
|
-
const { script: u, needAttach:
|
|
1200
|
+
a.forEach((l) => {
|
|
1201
|
+
const { script: u, needAttach: p } = createScript({
|
|
1178
1202
|
url: l,
|
|
1179
1203
|
cb: () => {
|
|
1180
1204
|
},
|
|
1181
|
-
attrs:
|
|
1182
|
-
createScriptHook: (
|
|
1205
|
+
attrs: i,
|
|
1206
|
+
createScriptHook: (m, d) => {
|
|
1183
1207
|
const y = t.loaderHook.lifecycle.createScript.emit({
|
|
1184
|
-
url:
|
|
1185
|
-
attrs:
|
|
1208
|
+
url: m,
|
|
1209
|
+
attrs: d
|
|
1186
1210
|
});
|
|
1187
1211
|
if (y instanceof HTMLScriptElement)
|
|
1188
1212
|
return y;
|
|
1189
1213
|
},
|
|
1190
1214
|
needDeleteScript: !0
|
|
1191
1215
|
});
|
|
1192
|
-
|
|
1216
|
+
p && document.head.appendChild(u);
|
|
1193
1217
|
});
|
|
1194
1218
|
}
|
|
1195
1219
|
}
|
|
@@ -1211,55 +1235,55 @@ class Module {
|
|
|
1211
1235
|
}
|
|
1212
1236
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1213
1237
|
async get(t, o, n, s) {
|
|
1214
|
-
const { loadFactory:
|
|
1238
|
+
const { loadFactory: a = !0 } = n || { loadFactory: !0 }, c = await this.getEntry();
|
|
1215
1239
|
if (!this.inited) {
|
|
1216
|
-
const
|
|
1217
|
-
|
|
1218
|
-
|
|
1240
|
+
const m = this.host.shareScopeMap, d = Array.isArray(this.remoteInfo.shareScope) ? this.remoteInfo.shareScope : [this.remoteInfo.shareScope];
|
|
1241
|
+
d.length || d.push("default"), d.forEach((R) => {
|
|
1242
|
+
m[R] || (m[R] = {});
|
|
1219
1243
|
});
|
|
1220
|
-
const y =
|
|
1244
|
+
const y = m[d[0]], g = [], b = {
|
|
1221
1245
|
version: this.remoteInfo.version || "",
|
|
1222
|
-
shareScopeKeys: Array.isArray(this.remoteInfo.shareScope) ?
|
|
1246
|
+
shareScopeKeys: Array.isArray(this.remoteInfo.shareScope) ? d : this.remoteInfo.shareScope || "default"
|
|
1223
1247
|
};
|
|
1224
|
-
Object.defineProperty(
|
|
1225
|
-
value:
|
|
1248
|
+
Object.defineProperty(b, "shareScopeMap", {
|
|
1249
|
+
value: m,
|
|
1226
1250
|
// remoteEntryInitOptions will be traversed and assigned during container init, ,so this attribute is not allowed to be traversed
|
|
1227
1251
|
enumerable: !1
|
|
1228
1252
|
});
|
|
1229
1253
|
const E = await this.host.hooks.lifecycle.beforeInitContainer.emit({
|
|
1230
1254
|
shareScope: y,
|
|
1231
1255
|
// @ts-ignore shareScopeMap will be set by Object.defineProperty
|
|
1232
|
-
remoteEntryInitOptions:
|
|
1256
|
+
remoteEntryInitOptions: b,
|
|
1233
1257
|
initScope: g,
|
|
1234
1258
|
remoteInfo: this.remoteInfo,
|
|
1235
1259
|
origin: this.host
|
|
1236
1260
|
});
|
|
1237
|
-
typeof (
|
|
1261
|
+
typeof (c == null ? void 0 : c.init) > "u" && error(getShortErrorMsg(RUNTIME_002, runtimeDescMap, {
|
|
1238
1262
|
hostName: this.host.name,
|
|
1239
1263
|
remoteName: this.remoteInfo.name,
|
|
1240
1264
|
remoteEntryUrl: this.remoteInfo.entry,
|
|
1241
1265
|
remoteEntryKey: this.remoteInfo.entryGlobalName
|
|
1242
|
-
})), await
|
|
1266
|
+
})), await c.init(E.shareScope, E.initScope, E.remoteEntryInitOptions), await this.host.hooks.lifecycle.initContainer.emit({
|
|
1243
1267
|
...E,
|
|
1244
1268
|
id: t,
|
|
1245
1269
|
remoteSnapshot: s,
|
|
1246
|
-
remoteEntryExports:
|
|
1270
|
+
remoteEntryExports: c
|
|
1247
1271
|
});
|
|
1248
1272
|
}
|
|
1249
|
-
this.lib =
|
|
1250
|
-
let
|
|
1251
|
-
|
|
1252
|
-
remoteEntryExports:
|
|
1273
|
+
this.lib = c, this.inited = !0;
|
|
1274
|
+
let i;
|
|
1275
|
+
i = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
|
|
1276
|
+
remoteEntryExports: c,
|
|
1253
1277
|
expose: o,
|
|
1254
1278
|
moduleInfo: this.remoteInfo
|
|
1255
|
-
}),
|
|
1256
|
-
const l = processModuleAlias(this.remoteInfo.name, o), u = this.wraperFactory(
|
|
1257
|
-
return
|
|
1279
|
+
}), i || (i = await c.get(o)), assert(i, `${getFMId(this.remoteInfo)} remote don't export ${o}.`);
|
|
1280
|
+
const l = processModuleAlias(this.remoteInfo.name, o), u = this.wraperFactory(i, l);
|
|
1281
|
+
return a ? await u() : u;
|
|
1258
1282
|
}
|
|
1259
1283
|
wraperFactory(t, o) {
|
|
1260
|
-
function n(s,
|
|
1284
|
+
function n(s, a) {
|
|
1261
1285
|
s && typeof s == "object" && Object.isExtensible(s) && !Object.getOwnPropertyDescriptor(s, Symbol.for("mf_module_id")) && Object.defineProperty(s, Symbol.for("mf_module_id"), {
|
|
1262
|
-
value:
|
|
1286
|
+
value: a,
|
|
1263
1287
|
enumerable: !1
|
|
1264
1288
|
});
|
|
1265
1289
|
}
|
|
@@ -1304,8 +1328,8 @@ class AsyncHook extends SyncHook {
|
|
|
1304
1328
|
const n = Array.from(this.listeners);
|
|
1305
1329
|
if (n.length > 0) {
|
|
1306
1330
|
let s = 0;
|
|
1307
|
-
const
|
|
1308
|
-
o =
|
|
1331
|
+
const a = (c) => c === !1 ? !1 : s < n.length ? Promise.resolve(n[s++].apply(null, t)).then(a) : c;
|
|
1332
|
+
o = a();
|
|
1309
1333
|
}
|
|
1310
1334
|
return Promise.resolve(o);
|
|
1311
1335
|
}
|
|
@@ -1350,19 +1374,19 @@ class AsyncWaterfallHook extends SyncHook {
|
|
|
1350
1374
|
const o = Array.from(this.listeners);
|
|
1351
1375
|
if (o.length > 0) {
|
|
1352
1376
|
let n = 0;
|
|
1353
|
-
const s = (
|
|
1354
|
-
if (checkReturnData(t,
|
|
1355
|
-
if (t =
|
|
1377
|
+
const s = (c) => (warn(c), this.onerror(c), t), a = (c) => {
|
|
1378
|
+
if (checkReturnData(t, c)) {
|
|
1379
|
+
if (t = c, n < o.length)
|
|
1356
1380
|
try {
|
|
1357
|
-
return Promise.resolve(o[n++](t)).then(
|
|
1358
|
-
} catch (
|
|
1359
|
-
return s(
|
|
1381
|
+
return Promise.resolve(o[n++](t)).then(a, s);
|
|
1382
|
+
} catch (i) {
|
|
1383
|
+
return s(i);
|
|
1360
1384
|
}
|
|
1361
1385
|
} else
|
|
1362
1386
|
this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
|
|
1363
1387
|
return t;
|
|
1364
1388
|
};
|
|
1365
|
-
return Promise.resolve(
|
|
1389
|
+
return Promise.resolve(a(t));
|
|
1366
1390
|
}
|
|
1367
1391
|
return Promise.resolve(t);
|
|
1368
1392
|
}
|
|
@@ -1375,9 +1399,9 @@ class PluginSystem {
|
|
|
1375
1399
|
var s;
|
|
1376
1400
|
assert(isPlainObject(t), "Plugin configuration is invalid.");
|
|
1377
1401
|
const n = t.name;
|
|
1378
|
-
assert(n, "A name must be provided by the plugin."), this.registerPlugins[n] || (this.registerPlugins[n] = t, (s = t.apply) == null || s.call(t, o), Object.keys(this.lifecycle).forEach((
|
|
1379
|
-
const
|
|
1380
|
-
|
|
1402
|
+
assert(n, "A name must be provided by the plugin."), this.registerPlugins[n] || (this.registerPlugins[n] = t, (s = t.apply) == null || s.call(t, o), Object.keys(this.lifecycle).forEach((a) => {
|
|
1403
|
+
const c = t[a];
|
|
1404
|
+
c && this.lifecycle[a].on(c);
|
|
1381
1405
|
}));
|
|
1382
1406
|
}
|
|
1383
1407
|
removePlugin(t) {
|
|
@@ -1398,13 +1422,13 @@ function snapshotPlugin() {
|
|
|
1398
1422
|
return {
|
|
1399
1423
|
name: "snapshot-plugin",
|
|
1400
1424
|
async afterResolve(r) {
|
|
1401
|
-
const { remote: t, pkgNameOrAlias: o, expose: n, origin: s, remoteInfo:
|
|
1425
|
+
const { remote: t, pkgNameOrAlias: o, expose: n, origin: s, remoteInfo: a, id: c } = r;
|
|
1402
1426
|
if (!isRemoteInfoWithEntry(t) || !isPureRemoteEntry(t)) {
|
|
1403
|
-
const { remoteSnapshot:
|
|
1427
|
+
const { remoteSnapshot: i, globalSnapshot: l } = await s.snapshotHandler.loadRemoteSnapshotInfo({
|
|
1404
1428
|
moduleInfo: t,
|
|
1405
|
-
id:
|
|
1429
|
+
id: c
|
|
1406
1430
|
});
|
|
1407
|
-
assignRemoteInfo(
|
|
1431
|
+
assignRemoteInfo(a, i);
|
|
1408
1432
|
const u = {
|
|
1409
1433
|
remote: t,
|
|
1410
1434
|
preloadConfig: {
|
|
@@ -1414,17 +1438,17 @@ function snapshotPlugin() {
|
|
|
1414
1438
|
share: !1,
|
|
1415
1439
|
depsRemote: !1
|
|
1416
1440
|
}
|
|
1417
|
-
},
|
|
1441
|
+
}, p = await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({
|
|
1418
1442
|
origin: s,
|
|
1419
1443
|
preloadOptions: u,
|
|
1420
|
-
remoteInfo:
|
|
1444
|
+
remoteInfo: a,
|
|
1421
1445
|
remote: t,
|
|
1422
|
-
remoteSnapshot:
|
|
1446
|
+
remoteSnapshot: i,
|
|
1423
1447
|
globalSnapshot: l
|
|
1424
1448
|
});
|
|
1425
|
-
return
|
|
1449
|
+
return p && preloadAssets(a, s, p, !1), {
|
|
1426
1450
|
...r,
|
|
1427
|
-
remoteSnapshot:
|
|
1451
|
+
remoteSnapshot: i
|
|
1428
1452
|
};
|
|
1429
1453
|
}
|
|
1430
1454
|
return r;
|
|
@@ -1444,107 +1468,107 @@ function splitId(r) {
|
|
|
1444
1468
|
version: t[2]
|
|
1445
1469
|
};
|
|
1446
1470
|
}
|
|
1447
|
-
function traverseModuleInfo(r, t, o, n, s = {},
|
|
1448
|
-
const
|
|
1471
|
+
function traverseModuleInfo(r, t, o, n, s = {}, a) {
|
|
1472
|
+
const c = getFMId(t), { value: i } = getInfoWithoutType(r, c), l = a || i;
|
|
1449
1473
|
if (l && !isManifestProvider(l) && (o(l, t, n), l.remotesInfo)) {
|
|
1450
1474
|
const u = Object.keys(l.remotesInfo);
|
|
1451
|
-
for (const
|
|
1452
|
-
if (s[
|
|
1475
|
+
for (const p of u) {
|
|
1476
|
+
if (s[p])
|
|
1453
1477
|
continue;
|
|
1454
|
-
s[
|
|
1455
|
-
const
|
|
1478
|
+
s[p] = !0;
|
|
1479
|
+
const m = splitId(p), d = l.remotesInfo[p];
|
|
1456
1480
|
traverseModuleInfo(r, {
|
|
1457
|
-
name:
|
|
1458
|
-
version:
|
|
1481
|
+
name: m.name,
|
|
1482
|
+
version: d.matchedVersion
|
|
1459
1483
|
}, o, !1, s, void 0);
|
|
1460
1484
|
}
|
|
1461
1485
|
}
|
|
1462
1486
|
}
|
|
1463
1487
|
const isExisted = (r, t) => document.querySelector(`${r}[${r === "link" ? "href" : "src"}="${t}"]`);
|
|
1464
1488
|
function generatePreloadAssets(r, t, o, n, s) {
|
|
1465
|
-
const
|
|
1466
|
-
if (traverseModuleInfo(n, o, (E,
|
|
1489
|
+
const a = [], c = [], i = [], l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), { options: p } = r, { preloadConfig: m } = t, { depsRemote: d } = m;
|
|
1490
|
+
if (traverseModuleInfo(n, o, (E, R, I) => {
|
|
1467
1491
|
var $;
|
|
1468
1492
|
let S;
|
|
1469
1493
|
if (I)
|
|
1470
|
-
S =
|
|
1471
|
-
else if (Array.isArray(
|
|
1472
|
-
const
|
|
1473
|
-
if (!
|
|
1494
|
+
S = m;
|
|
1495
|
+
else if (Array.isArray(d)) {
|
|
1496
|
+
const P = d.find((N) => N.nameOrAlias === R.name || N.nameOrAlias === R.alias);
|
|
1497
|
+
if (!P)
|
|
1474
1498
|
return;
|
|
1475
|
-
S = defaultPreloadArgs(
|
|
1476
|
-
} else if (
|
|
1477
|
-
S =
|
|
1499
|
+
S = defaultPreloadArgs(P);
|
|
1500
|
+
} else if (d === !0)
|
|
1501
|
+
S = m;
|
|
1478
1502
|
else
|
|
1479
1503
|
return;
|
|
1480
|
-
const
|
|
1481
|
-
|
|
1482
|
-
name:
|
|
1504
|
+
const A = getResourceUrl(E, getRemoteEntryInfoFromSnapshot(E).url);
|
|
1505
|
+
A && i.push({
|
|
1506
|
+
name: R.name,
|
|
1483
1507
|
moduleInfo: {
|
|
1484
|
-
name:
|
|
1485
|
-
entry:
|
|
1508
|
+
name: R.name,
|
|
1509
|
+
entry: A,
|
|
1486
1510
|
type: "remoteEntryType" in E ? E.remoteEntryType : "global",
|
|
1487
|
-
entryGlobalName: "globalName" in E ? E.globalName :
|
|
1511
|
+
entryGlobalName: "globalName" in E ? E.globalName : R.name,
|
|
1488
1512
|
shareScope: "",
|
|
1489
1513
|
version: "version" in E ? E.version : void 0
|
|
1490
1514
|
},
|
|
1491
|
-
url:
|
|
1515
|
+
url: A
|
|
1492
1516
|
});
|
|
1493
1517
|
let _ = "modules" in E ? E.modules : [];
|
|
1494
|
-
const
|
|
1495
|
-
|
|
1496
|
-
function w(
|
|
1497
|
-
const N =
|
|
1518
|
+
const T = normalizePreloadExposes(S.exposes);
|
|
1519
|
+
T.length && "modules" in E && (_ = ($ = E == null ? void 0 : E.modules) == null ? void 0 : $.reduce((P, N) => ((T == null ? void 0 : T.indexOf(N.moduleName)) !== -1 && P.push(N), P), []));
|
|
1520
|
+
function w(P) {
|
|
1521
|
+
const N = P.map((M) => getResourceUrl(E, M));
|
|
1498
1522
|
return S.filter ? N.filter(S.filter) : N;
|
|
1499
1523
|
}
|
|
1500
1524
|
if (_) {
|
|
1501
|
-
const
|
|
1502
|
-
for (let N = 0; N <
|
|
1503
|
-
const
|
|
1525
|
+
const P = _.length;
|
|
1526
|
+
for (let N = 0; N < P; N++) {
|
|
1527
|
+
const M = _[N], L = `${R.name}/${M.moduleName}`;
|
|
1504
1528
|
r.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({
|
|
1505
|
-
id:
|
|
1506
|
-
name:
|
|
1529
|
+
id: M.moduleName === "." ? R.name : L,
|
|
1530
|
+
name: R.name,
|
|
1507
1531
|
remoteSnapshot: E,
|
|
1508
1532
|
preloadConfig: S,
|
|
1509
|
-
remote:
|
|
1533
|
+
remote: R,
|
|
1510
1534
|
origin: r
|
|
1511
|
-
}), !getPreloaded(L) && (S.resourceCategory === "all" ? (
|
|
1535
|
+
}), !getPreloaded(L) && (S.resourceCategory === "all" ? (a.push(...w(M.assets.css.async)), a.push(...w(M.assets.css.sync)), c.push(...w(M.assets.js.async)), c.push(...w(M.assets.js.sync))) : (S.resourceCategory = "sync") && (a.push(...w(M.assets.css.sync)), c.push(...w(M.assets.js.sync))), setPreloaded(L));
|
|
1512
1536
|
}
|
|
1513
1537
|
}
|
|
1514
1538
|
}, !0, {}, s), s.shared && s.shared.length > 0) {
|
|
1515
|
-
const E = (
|
|
1516
|
-
const S = getRegisteredShare(r.shareScopeMap, I.sharedName,
|
|
1517
|
-
S && typeof S.lib == "function" && (I.assets.js.sync.forEach((
|
|
1518
|
-
l.add(
|
|
1519
|
-
}), I.assets.css.sync.forEach((
|
|
1520
|
-
u.add(
|
|
1539
|
+
const E = (R, I) => {
|
|
1540
|
+
const S = getRegisteredShare(r.shareScopeMap, I.sharedName, R, r.sharedHandler.hooks.lifecycle.resolveShare);
|
|
1541
|
+
S && typeof S.lib == "function" && (I.assets.js.sync.forEach((A) => {
|
|
1542
|
+
l.add(A);
|
|
1543
|
+
}), I.assets.css.sync.forEach((A) => {
|
|
1544
|
+
u.add(A);
|
|
1521
1545
|
}));
|
|
1522
1546
|
};
|
|
1523
|
-
s.shared.forEach((
|
|
1547
|
+
s.shared.forEach((R) => {
|
|
1524
1548
|
var _;
|
|
1525
|
-
const I = (_ =
|
|
1549
|
+
const I = (_ = p.shared) == null ? void 0 : _[R.sharedName];
|
|
1526
1550
|
if (!I)
|
|
1527
1551
|
return;
|
|
1528
|
-
const S =
|
|
1552
|
+
const S = R.version ? I.find((T) => T.version === R.version) : I;
|
|
1529
1553
|
if (!S)
|
|
1530
1554
|
return;
|
|
1531
|
-
arrayOptions(S).forEach((
|
|
1532
|
-
E(
|
|
1555
|
+
arrayOptions(S).forEach((T) => {
|
|
1556
|
+
E(T, R);
|
|
1533
1557
|
});
|
|
1534
1558
|
});
|
|
1535
1559
|
}
|
|
1536
|
-
const g =
|
|
1560
|
+
const g = c.filter((E) => !l.has(E) && !isExisted("script", E));
|
|
1537
1561
|
return {
|
|
1538
|
-
cssAssets:
|
|
1562
|
+
cssAssets: a.filter((E) => !u.has(E) && !isExisted("link", E)),
|
|
1539
1563
|
jsAssetsWithoutEntry: g,
|
|
1540
|
-
entryAssets:
|
|
1564
|
+
entryAssets: i.filter((E) => !isExisted("script", E.url))
|
|
1541
1565
|
};
|
|
1542
1566
|
}
|
|
1543
1567
|
const generatePreloadAssetsPlugin = function() {
|
|
1544
1568
|
return {
|
|
1545
1569
|
name: "generate-preload-assets-plugin",
|
|
1546
1570
|
async generatePreloadAssets(r) {
|
|
1547
|
-
const { origin: t, preloadOptions: o, remoteInfo: n, remote: s, globalSnapshot:
|
|
1571
|
+
const { origin: t, preloadOptions: o, remoteInfo: n, remote: s, globalSnapshot: a, remoteSnapshot: c } = r;
|
|
1548
1572
|
return isBrowserEnv() ? isRemoteInfoWithEntry(s) && isPureRemoteEntry(s) ? {
|
|
1549
1573
|
cssAssets: [],
|
|
1550
1574
|
jsAssetsWithoutEntry: [],
|
|
@@ -1561,7 +1585,7 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1561
1585
|
}
|
|
1562
1586
|
}
|
|
1563
1587
|
]
|
|
1564
|
-
} : (assignRemoteInfo(n,
|
|
1588
|
+
} : (assignRemoteInfo(n, c), generatePreloadAssets(t, o, n, a, c)) : {
|
|
1565
1589
|
cssAssets: [],
|
|
1566
1590
|
jsAssetsWithoutEntry: [],
|
|
1567
1591
|
entryAssets: []
|
|
@@ -1606,39 +1630,39 @@ class SnapshotHandler {
|
|
|
1606
1630
|
options: s,
|
|
1607
1631
|
moduleInfo: t
|
|
1608
1632
|
});
|
|
1609
|
-
let
|
|
1633
|
+
let a = getGlobalSnapshotInfoByModuleInfo({
|
|
1610
1634
|
name: this.HostInstance.options.name,
|
|
1611
1635
|
version: this.HostInstance.options.version
|
|
1612
1636
|
});
|
|
1613
|
-
|
|
1637
|
+
a || (a = {
|
|
1614
1638
|
version: this.HostInstance.options.version || "",
|
|
1615
1639
|
remoteEntry: "",
|
|
1616
1640
|
remotesInfo: {}
|
|
1617
1641
|
}, addGlobalSnapshot({
|
|
1618
|
-
[this.HostInstance.options.name]:
|
|
1619
|
-
})),
|
|
1620
|
-
...
|
|
1642
|
+
[this.HostInstance.options.name]: a
|
|
1643
|
+
})), a && "remotesInfo" in a && !getInfoWithoutType(a.remotesInfo, t.name).value && ("version" in t || "entry" in t) && (a.remotesInfo = {
|
|
1644
|
+
...a == null ? void 0 : a.remotesInfo,
|
|
1621
1645
|
[t.name]: {
|
|
1622
1646
|
matchedVersion: "version" in t ? t.version : t.entry
|
|
1623
1647
|
}
|
|
1624
1648
|
});
|
|
1625
|
-
const { hostGlobalSnapshot:
|
|
1649
|
+
const { hostGlobalSnapshot: c, remoteSnapshot: i, globalSnapshot: l } = this.getGlobalRemoteInfo(t), { remoteSnapshot: u, globalSnapshot: p } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1626
1650
|
options: s,
|
|
1627
1651
|
moduleInfo: t,
|
|
1628
|
-
hostGlobalSnapshot:
|
|
1629
|
-
remoteSnapshot:
|
|
1652
|
+
hostGlobalSnapshot: c,
|
|
1653
|
+
remoteSnapshot: i,
|
|
1630
1654
|
globalSnapshot: l
|
|
1631
1655
|
});
|
|
1632
|
-
let
|
|
1656
|
+
let m, d;
|
|
1633
1657
|
if (u)
|
|
1634
1658
|
if (isManifestProvider(u)) {
|
|
1635
|
-
const y = isBrowserEnv() ? u.remoteEntry : u.ssrRemoteEntry || u.remoteEntry || "", g = await this.getManifestJson(y, t, {}),
|
|
1659
|
+
const y = isBrowserEnv() ? u.remoteEntry : u.ssrRemoteEntry || u.remoteEntry || "", g = await this.getManifestJson(y, t, {}), b = setGlobalSnapshotInfoByModuleInfo({
|
|
1636
1660
|
...t,
|
|
1637
1661
|
// The global remote may be overridden
|
|
1638
1662
|
// Therefore, set the snapshot key to the global address of the actual request
|
|
1639
1663
|
entry: y
|
|
1640
1664
|
}, g);
|
|
1641
|
-
|
|
1665
|
+
m = g, d = b;
|
|
1642
1666
|
} else {
|
|
1643
1667
|
const { remoteSnapshot: y } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1644
1668
|
options: this.HostInstance.options,
|
|
@@ -1646,31 +1670,31 @@ class SnapshotHandler {
|
|
|
1646
1670
|
remoteSnapshot: u,
|
|
1647
1671
|
from: "global"
|
|
1648
1672
|
});
|
|
1649
|
-
|
|
1673
|
+
m = y, d = p;
|
|
1650
1674
|
}
|
|
1651
1675
|
else if (isRemoteInfoWithEntry(t)) {
|
|
1652
|
-
const y = await this.getManifestJson(t.entry, t, {}), g = setGlobalSnapshotInfoByModuleInfo(t, y), { remoteSnapshot:
|
|
1676
|
+
const y = await this.getManifestJson(t.entry, t, {}), g = setGlobalSnapshotInfoByModuleInfo(t, y), { remoteSnapshot: b } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1653
1677
|
options: this.HostInstance.options,
|
|
1654
1678
|
moduleInfo: t,
|
|
1655
1679
|
remoteSnapshot: y,
|
|
1656
1680
|
from: "global"
|
|
1657
1681
|
});
|
|
1658
|
-
|
|
1682
|
+
m = b, d = g;
|
|
1659
1683
|
} else
|
|
1660
1684
|
error(getShortErrorMsg(RUNTIME_007, runtimeDescMap, {
|
|
1661
1685
|
hostName: t.name,
|
|
1662
1686
|
hostVersion: t.version,
|
|
1663
|
-
globalSnapshot: JSON.stringify(
|
|
1687
|
+
globalSnapshot: JSON.stringify(p)
|
|
1664
1688
|
}));
|
|
1665
1689
|
return await this.hooks.lifecycle.afterLoadSnapshot.emit({
|
|
1666
1690
|
id: o,
|
|
1667
1691
|
host: this.HostInstance,
|
|
1668
1692
|
options: s,
|
|
1669
1693
|
moduleInfo: t,
|
|
1670
|
-
remoteSnapshot:
|
|
1694
|
+
remoteSnapshot: m
|
|
1671
1695
|
}), {
|
|
1672
|
-
remoteSnapshot:
|
|
1673
|
-
globalSnapshot:
|
|
1696
|
+
remoteSnapshot: m,
|
|
1697
|
+
globalSnapshot: d
|
|
1674
1698
|
};
|
|
1675
1699
|
}
|
|
1676
1700
|
getGlobalRemoteInfo(t) {
|
|
@@ -1678,40 +1702,40 @@ class SnapshotHandler {
|
|
|
1678
1702
|
}
|
|
1679
1703
|
async getManifestJson(t, o, n) {
|
|
1680
1704
|
const s = async () => {
|
|
1681
|
-
let
|
|
1682
|
-
if (
|
|
1683
|
-
return
|
|
1705
|
+
let c = this.manifestCache.get(t);
|
|
1706
|
+
if (c)
|
|
1707
|
+
return c;
|
|
1684
1708
|
try {
|
|
1685
|
-
let
|
|
1686
|
-
(!
|
|
1687
|
-
} catch (
|
|
1688
|
-
|
|
1709
|
+
let i = await this.loaderHook.lifecycle.fetch.emit(t, {});
|
|
1710
|
+
(!i || !(i instanceof Response)) && (i = await fetch(t, {})), c = await i.json();
|
|
1711
|
+
} catch (i) {
|
|
1712
|
+
c = await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
1689
1713
|
id: t,
|
|
1690
|
-
error:
|
|
1714
|
+
error: i,
|
|
1691
1715
|
from: "runtime",
|
|
1692
1716
|
lifecycle: "afterResolve",
|
|
1693
1717
|
origin: this.HostInstance
|
|
1694
|
-
}),
|
|
1718
|
+
}), c || (delete this.manifestLoading[t], error(getShortErrorMsg(RUNTIME_003, runtimeDescMap, {
|
|
1695
1719
|
manifestUrl: t,
|
|
1696
1720
|
moduleName: o.name,
|
|
1697
1721
|
hostName: this.HostInstance.options.name
|
|
1698
|
-
}, `${
|
|
1722
|
+
}, `${i}`)));
|
|
1699
1723
|
}
|
|
1700
|
-
return assert(
|
|
1701
|
-
},
|
|
1702
|
-
const
|
|
1724
|
+
return assert(c.metaData && c.exposes && c.shared, `${t} is not a federation manifest`), this.manifestCache.set(t, c), c;
|
|
1725
|
+
}, a = async () => {
|
|
1726
|
+
const c = await s(), i = generateSnapshotFromManifest(c, {
|
|
1703
1727
|
version: t
|
|
1704
1728
|
}), { remoteSnapshot: l } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1705
1729
|
options: this.HostInstance.options,
|
|
1706
1730
|
moduleInfo: o,
|
|
1707
|
-
manifestJson:
|
|
1708
|
-
remoteSnapshot:
|
|
1731
|
+
manifestJson: c,
|
|
1732
|
+
remoteSnapshot: i,
|
|
1709
1733
|
manifestUrl: t,
|
|
1710
1734
|
from: "manifest"
|
|
1711
1735
|
});
|
|
1712
1736
|
return l;
|
|
1713
1737
|
};
|
|
1714
|
-
return this.manifestLoading[t] || (this.manifestLoading[t] =
|
|
1738
|
+
return this.manifestLoading[t] || (this.manifestLoading[t] = a().then((c) => c)), this.manifestLoading[t];
|
|
1715
1739
|
}
|
|
1716
1740
|
}
|
|
1717
1741
|
class SharedHandler {
|
|
@@ -1729,10 +1753,10 @@ class SharedHandler {
|
|
|
1729
1753
|
// register shared in shareScopeMap
|
|
1730
1754
|
registerShared(t, o) {
|
|
1731
1755
|
const { shareInfos: n, shared: s } = formatShareConfigs(t, o);
|
|
1732
|
-
return Object.keys(n).forEach((
|
|
1733
|
-
n[
|
|
1734
|
-
!getRegisteredShare(this.shareScopeMap,
|
|
1735
|
-
pkgName:
|
|
1756
|
+
return Object.keys(n).forEach((c) => {
|
|
1757
|
+
n[c].forEach((l) => {
|
|
1758
|
+
!getRegisteredShare(this.shareScopeMap, c, l, this.hooks.lifecycle.resolveShare) && l && l.lib && this.setShared({
|
|
1759
|
+
pkgName: c,
|
|
1736
1760
|
lib: l.lib,
|
|
1737
1761
|
get: l.get,
|
|
1738
1762
|
loaded: !0,
|
|
@@ -1756,51 +1780,51 @@ class SharedHandler {
|
|
|
1756
1780
|
strategy: s.strategy
|
|
1757
1781
|
}));
|
|
1758
1782
|
}));
|
|
1759
|
-
const
|
|
1783
|
+
const a = await this.hooks.lifecycle.beforeLoadShare.emit({
|
|
1760
1784
|
pkgName: t,
|
|
1761
1785
|
shareInfo: s,
|
|
1762
1786
|
shared: n.options.shared,
|
|
1763
1787
|
origin: n
|
|
1764
|
-
}), { shareInfo:
|
|
1765
|
-
assert(
|
|
1766
|
-
const
|
|
1788
|
+
}), { shareInfo: c } = a;
|
|
1789
|
+
assert(c, `Cannot find ${t} Share in the ${n.options.name}. Please ensure that the ${t} Share parameters have been injected`);
|
|
1790
|
+
const i = getRegisteredShare(this.shareScopeMap, t, c, this.hooks.lifecycle.resolveShare), l = (u) => {
|
|
1767
1791
|
u.useIn || (u.useIn = []), addUniqueItem(u.useIn, n.options.name);
|
|
1768
1792
|
};
|
|
1769
|
-
if (
|
|
1770
|
-
return l(
|
|
1771
|
-
if (
|
|
1772
|
-
const u = await
|
|
1773
|
-
return
|
|
1774
|
-
} else if (
|
|
1775
|
-
const
|
|
1776
|
-
const
|
|
1777
|
-
return l(
|
|
1793
|
+
if (i && i.lib)
|
|
1794
|
+
return l(i), i.lib;
|
|
1795
|
+
if (i && i.loading && !i.loaded) {
|
|
1796
|
+
const u = await i.loading;
|
|
1797
|
+
return i.loaded = !0, i.lib || (i.lib = u), l(i), u;
|
|
1798
|
+
} else if (i) {
|
|
1799
|
+
const p = (async () => {
|
|
1800
|
+
const m = await i.get();
|
|
1801
|
+
return l(i), i.loaded = !0, i.lib = m, m;
|
|
1778
1802
|
})();
|
|
1779
1803
|
return this.setShared({
|
|
1780
1804
|
pkgName: t,
|
|
1781
1805
|
loaded: !1,
|
|
1782
|
-
shared:
|
|
1806
|
+
shared: i,
|
|
1783
1807
|
from: n.options.name,
|
|
1784
1808
|
lib: null,
|
|
1785
|
-
loading:
|
|
1786
|
-
}),
|
|
1809
|
+
loading: p
|
|
1810
|
+
}), p;
|
|
1787
1811
|
} else {
|
|
1788
1812
|
if (o != null && o.customShareInfo)
|
|
1789
1813
|
return !1;
|
|
1790
|
-
const
|
|
1791
|
-
const
|
|
1792
|
-
|
|
1793
|
-
const
|
|
1794
|
-
return
|
|
1814
|
+
const p = (async () => {
|
|
1815
|
+
const m = await c.get();
|
|
1816
|
+
c.lib = m, c.loaded = !0, l(c);
|
|
1817
|
+
const d = getRegisteredShare(this.shareScopeMap, t, c, this.hooks.lifecycle.resolveShare);
|
|
1818
|
+
return d && (d.lib = m, d.loaded = !0, d.from = c.from), m;
|
|
1795
1819
|
})();
|
|
1796
1820
|
return this.setShared({
|
|
1797
1821
|
pkgName: t,
|
|
1798
1822
|
loaded: !1,
|
|
1799
|
-
shared:
|
|
1823
|
+
shared: c,
|
|
1800
1824
|
from: n.options.name,
|
|
1801
1825
|
lib: null,
|
|
1802
|
-
loading:
|
|
1803
|
-
}),
|
|
1826
|
+
loading: p
|
|
1827
|
+
}), p;
|
|
1804
1828
|
}
|
|
1805
1829
|
}
|
|
1806
1830
|
/**
|
|
@@ -1810,52 +1834,52 @@ class SharedHandler {
|
|
|
1810
1834
|
*/
|
|
1811
1835
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
1812
1836
|
initializeSharing(t = DEFAULT_SCOPE, o) {
|
|
1813
|
-
const { host: n } = this, s = o == null ? void 0 : o.from,
|
|
1814
|
-
let
|
|
1815
|
-
const
|
|
1837
|
+
const { host: n } = this, s = o == null ? void 0 : o.from, a = o == null ? void 0 : o.strategy;
|
|
1838
|
+
let c = o == null ? void 0 : o.initScope;
|
|
1839
|
+
const i = [];
|
|
1816
1840
|
if (s !== "build") {
|
|
1817
1841
|
const { initTokens: g } = this;
|
|
1818
|
-
|
|
1819
|
-
let
|
|
1820
|
-
if (
|
|
1821
|
-
return
|
|
1822
|
-
|
|
1842
|
+
c || (c = []);
|
|
1843
|
+
let b = g[t];
|
|
1844
|
+
if (b || (b = g[t] = { from: this.host.name }), c.indexOf(b) >= 0)
|
|
1845
|
+
return i;
|
|
1846
|
+
c.push(b);
|
|
1823
1847
|
}
|
|
1824
1848
|
const l = this.shareScopeMap, u = n.options.name;
|
|
1825
1849
|
l[t] || (l[t] = {});
|
|
1826
|
-
const
|
|
1850
|
+
const p = l[t], m = (g, b) => {
|
|
1827
1851
|
var _;
|
|
1828
|
-
const { version: E, eager:
|
|
1829
|
-
|
|
1830
|
-
const I =
|
|
1831
|
-
(!S || S.strategy !== "loaded-first" && !S.loaded && (!
|
|
1832
|
-
},
|
|
1833
|
-
const { module:
|
|
1852
|
+
const { version: E, eager: R } = b;
|
|
1853
|
+
p[g] = p[g] || {};
|
|
1854
|
+
const I = p[g], S = I[E], A = !!(S && (S.eager || (_ = S.shareConfig) != null && _.eager));
|
|
1855
|
+
(!S || S.strategy !== "loaded-first" && !S.loaded && (!R != !A ? R : u > S.from)) && (I[E] = b);
|
|
1856
|
+
}, d = (g) => g && g.init && g.init(l[t], c), y = async (g) => {
|
|
1857
|
+
const { module: b } = await n.remoteHandler.getRemoteModuleAndOptions({
|
|
1834
1858
|
id: g
|
|
1835
1859
|
});
|
|
1836
|
-
if (
|
|
1860
|
+
if (b.getEntry) {
|
|
1837
1861
|
let E;
|
|
1838
1862
|
try {
|
|
1839
|
-
E = await
|
|
1840
|
-
} catch (
|
|
1863
|
+
E = await b.getEntry();
|
|
1864
|
+
} catch (R) {
|
|
1841
1865
|
E = await n.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
1842
1866
|
id: g,
|
|
1843
|
-
error:
|
|
1867
|
+
error: R,
|
|
1844
1868
|
from: "runtime",
|
|
1845
1869
|
lifecycle: "beforeLoadShare",
|
|
1846
1870
|
origin: n
|
|
1847
1871
|
});
|
|
1848
1872
|
}
|
|
1849
|
-
|
|
1873
|
+
b.inited || (await d(E), b.inited = !0);
|
|
1850
1874
|
}
|
|
1851
1875
|
};
|
|
1852
1876
|
return Object.keys(n.options.shared).forEach((g) => {
|
|
1853
1877
|
n.options.shared[g].forEach((E) => {
|
|
1854
|
-
E.scope.includes(t) &&
|
|
1878
|
+
E.scope.includes(t) && m(g, E);
|
|
1855
1879
|
});
|
|
1856
|
-
}), (n.options.shareStrategy === "version-first" ||
|
|
1857
|
-
g.shareScope === t &&
|
|
1858
|
-
}),
|
|
1880
|
+
}), (n.options.shareStrategy === "version-first" || a === "version-first") && n.options.remotes.forEach((g) => {
|
|
1881
|
+
g.shareScope === t && i.push(y(g.name));
|
|
1882
|
+
}), i;
|
|
1859
1883
|
}
|
|
1860
1884
|
// The lib function will only be available if the shared set by eager or runtime init is set or the shared is successfully loaded.
|
|
1861
1885
|
// 1. If the loaded shared already exists globally, then it will be reused
|
|
@@ -1867,39 +1891,39 @@ class SharedHandler {
|
|
|
1867
1891
|
extraOptions: o,
|
|
1868
1892
|
shareInfos: n.options.shared
|
|
1869
1893
|
});
|
|
1870
|
-
s != null && s.scope && s.scope.forEach((
|
|
1871
|
-
this.initializeSharing(
|
|
1894
|
+
s != null && s.scope && s.scope.forEach((i) => {
|
|
1895
|
+
this.initializeSharing(i, { strategy: s.strategy });
|
|
1872
1896
|
});
|
|
1873
|
-
const
|
|
1874
|
-
|
|
1897
|
+
const a = getRegisteredShare(this.shareScopeMap, t, s, this.hooks.lifecycle.resolveShare), c = (i) => {
|
|
1898
|
+
i.useIn || (i.useIn = []), addUniqueItem(i.useIn, n.options.name);
|
|
1875
1899
|
};
|
|
1876
|
-
if (
|
|
1877
|
-
if (typeof
|
|
1878
|
-
return a
|
|
1879
|
-
if (typeof
|
|
1880
|
-
const
|
|
1881
|
-
if (!(
|
|
1882
|
-
return a
|
|
1900
|
+
if (a) {
|
|
1901
|
+
if (typeof a.lib == "function")
|
|
1902
|
+
return c(a), a.loaded || (a.loaded = !0, a.from === n.options.name && (s.loaded = !0)), a.lib;
|
|
1903
|
+
if (typeof a.get == "function") {
|
|
1904
|
+
const i = a.get();
|
|
1905
|
+
if (!(i instanceof Promise))
|
|
1906
|
+
return c(a), this.setShared({
|
|
1883
1907
|
pkgName: t,
|
|
1884
1908
|
loaded: !0,
|
|
1885
1909
|
from: n.options.name,
|
|
1886
|
-
lib:
|
|
1887
|
-
shared:
|
|
1888
|
-
}),
|
|
1910
|
+
lib: i,
|
|
1911
|
+
shared: a
|
|
1912
|
+
}), i;
|
|
1889
1913
|
}
|
|
1890
1914
|
}
|
|
1891
1915
|
if (s.lib)
|
|
1892
1916
|
return s.loaded || (s.loaded = !0), s.lib;
|
|
1893
1917
|
if (s.get) {
|
|
1894
|
-
const
|
|
1895
|
-
if (
|
|
1918
|
+
const i = s.get();
|
|
1919
|
+
if (i instanceof Promise) {
|
|
1896
1920
|
const l = (o == null ? void 0 : o.from) === "build" ? RUNTIME_005 : RUNTIME_006;
|
|
1897
1921
|
throw new Error(getShortErrorMsg(l, runtimeDescMap, {
|
|
1898
1922
|
hostName: n.options.name,
|
|
1899
1923
|
sharedPkgName: t
|
|
1900
1924
|
}));
|
|
1901
1925
|
}
|
|
1902
|
-
return s.lib =
|
|
1926
|
+
return s.lib = i, this.setShared({
|
|
1903
1927
|
pkgName: t,
|
|
1904
1928
|
loaded: !0,
|
|
1905
1929
|
from: n.options.name,
|
|
@@ -1922,22 +1946,22 @@ class SharedHandler {
|
|
|
1922
1946
|
hostShareScopeMap: n.hostShareScopeMap
|
|
1923
1947
|
});
|
|
1924
1948
|
}
|
|
1925
|
-
setShared({ pkgName: t, shared: o, from: n, lib: s, loading:
|
|
1926
|
-
const { version: l, scope: u = "default", ...
|
|
1927
|
-
(Array.isArray(u) ? u : [u]).forEach((
|
|
1928
|
-
if (this.shareScopeMap[
|
|
1929
|
-
this.shareScopeMap[
|
|
1949
|
+
setShared({ pkgName: t, shared: o, from: n, lib: s, loading: a, loaded: c, get: i }) {
|
|
1950
|
+
const { version: l, scope: u = "default", ...p } = o;
|
|
1951
|
+
(Array.isArray(u) ? u : [u]).forEach((d) => {
|
|
1952
|
+
if (this.shareScopeMap[d] || (this.shareScopeMap[d] = {}), this.shareScopeMap[d][t] || (this.shareScopeMap[d][t] = {}), !this.shareScopeMap[d][t][l]) {
|
|
1953
|
+
this.shareScopeMap[d][t][l] = {
|
|
1930
1954
|
version: l,
|
|
1931
1955
|
scope: ["default"],
|
|
1932
|
-
...
|
|
1956
|
+
...p,
|
|
1933
1957
|
lib: s,
|
|
1934
|
-
loaded:
|
|
1935
|
-
loading:
|
|
1936
|
-
},
|
|
1958
|
+
loaded: c,
|
|
1959
|
+
loading: a
|
|
1960
|
+
}, i && (this.shareScopeMap[d][t][l].get = i);
|
|
1937
1961
|
return;
|
|
1938
1962
|
}
|
|
1939
|
-
const y = this.shareScopeMap[
|
|
1940
|
-
|
|
1963
|
+
const y = this.shareScopeMap[d][t][l];
|
|
1964
|
+
a && !y.loading && (y.loading = a), c && !y.loaded && (y.loaded = c), n && y.from !== n && (y.from = n);
|
|
1941
1965
|
});
|
|
1942
1966
|
}
|
|
1943
1967
|
_setGlobalShareScopeMap(t) {
|
|
@@ -1962,18 +1986,18 @@ class RemoteHandler {
|
|
|
1962
1986
|
}), this.host = t, this.idToRemoteMap = {};
|
|
1963
1987
|
}
|
|
1964
1988
|
formatAndRegisterRemote(t, o) {
|
|
1965
|
-
return (o.remotes || []).reduce((s,
|
|
1989
|
+
return (o.remotes || []).reduce((s, a) => (this.registerRemote(a, s, { force: !1 }), s), t.remotes);
|
|
1966
1990
|
}
|
|
1967
1991
|
setIdToRemoteMap(t, o) {
|
|
1968
|
-
const { remote: n, expose: s } = o, { name:
|
|
1969
|
-
if (this.idToRemoteMap[t] = { name: n.name, expose: s },
|
|
1970
|
-
const
|
|
1971
|
-
this.idToRemoteMap[
|
|
1992
|
+
const { remote: n, expose: s } = o, { name: a, alias: c } = n;
|
|
1993
|
+
if (this.idToRemoteMap[t] = { name: n.name, expose: s }, c && t.startsWith(a)) {
|
|
1994
|
+
const i = t.replace(a, c);
|
|
1995
|
+
this.idToRemoteMap[i] = { name: n.name, expose: s };
|
|
1972
1996
|
return;
|
|
1973
1997
|
}
|
|
1974
|
-
if (
|
|
1975
|
-
const
|
|
1976
|
-
this.idToRemoteMap[
|
|
1998
|
+
if (c && t.startsWith(c)) {
|
|
1999
|
+
const i = t.replace(c, a);
|
|
2000
|
+
this.idToRemoteMap[i] = { name: n.name, expose: s };
|
|
1977
2001
|
}
|
|
1978
2002
|
}
|
|
1979
2003
|
// eslint-disable-next-line max-lines-per-function
|
|
@@ -1983,31 +2007,31 @@ class RemoteHandler {
|
|
|
1983
2007
|
try {
|
|
1984
2008
|
const { loadFactory: s = !0 } = o || {
|
|
1985
2009
|
loadFactory: !0
|
|
1986
|
-
}, { module:
|
|
2010
|
+
}, { module: a, moduleOptions: c, remoteMatchInfo: i } = await this.getRemoteModuleAndOptions({
|
|
1987
2011
|
id: t
|
|
1988
|
-
}), { pkgNameOrAlias: l, remote: u, expose:
|
|
1989
|
-
id:
|
|
2012
|
+
}), { pkgNameOrAlias: l, remote: u, expose: p, id: m, remoteSnapshot: d } = i, y = await a.get(m, p, o, d), g = await this.hooks.lifecycle.onLoad.emit({
|
|
2013
|
+
id: m,
|
|
1990
2014
|
pkgNameOrAlias: l,
|
|
1991
|
-
expose:
|
|
2015
|
+
expose: p,
|
|
1992
2016
|
exposeModule: s ? y : void 0,
|
|
1993
2017
|
exposeModuleFactory: s ? void 0 : y,
|
|
1994
2018
|
remote: u,
|
|
1995
|
-
options:
|
|
1996
|
-
moduleInstance:
|
|
2019
|
+
options: c,
|
|
2020
|
+
moduleInstance: a,
|
|
1997
2021
|
origin: n
|
|
1998
2022
|
});
|
|
1999
|
-
return this.setIdToRemoteMap(t,
|
|
2023
|
+
return this.setIdToRemoteMap(t, i), typeof g == "function" ? g : y;
|
|
2000
2024
|
} catch (s) {
|
|
2001
|
-
const { from:
|
|
2025
|
+
const { from: a = "runtime" } = o || { from: "runtime" }, c = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2002
2026
|
id: t,
|
|
2003
2027
|
error: s,
|
|
2004
|
-
from:
|
|
2028
|
+
from: a,
|
|
2005
2029
|
lifecycle: "onLoad",
|
|
2006
2030
|
origin: n
|
|
2007
2031
|
});
|
|
2008
|
-
if (!
|
|
2032
|
+
if (!c)
|
|
2009
2033
|
throw s;
|
|
2010
|
-
return
|
|
2034
|
+
return c;
|
|
2011
2035
|
}
|
|
2012
2036
|
}
|
|
2013
2037
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
@@ -2020,17 +2044,17 @@ class RemoteHandler {
|
|
|
2020
2044
|
});
|
|
2021
2045
|
const n = formatPreloadArgs(o.options.remotes, t);
|
|
2022
2046
|
await Promise.all(n.map(async (s) => {
|
|
2023
|
-
const { remote:
|
|
2024
|
-
moduleInfo:
|
|
2047
|
+
const { remote: a } = s, c = getRemoteInfo(a), { globalSnapshot: i, remoteSnapshot: l } = await o.snapshotHandler.loadRemoteSnapshotInfo({
|
|
2048
|
+
moduleInfo: a
|
|
2025
2049
|
}), u = await this.hooks.lifecycle.generatePreloadAssets.emit({
|
|
2026
2050
|
origin: o,
|
|
2027
2051
|
preloadOptions: s,
|
|
2028
|
-
remote:
|
|
2029
|
-
remoteInfo:
|
|
2030
|
-
globalSnapshot:
|
|
2052
|
+
remote: a,
|
|
2053
|
+
remoteInfo: c,
|
|
2054
|
+
globalSnapshot: i,
|
|
2031
2055
|
remoteSnapshot: l
|
|
2032
2056
|
});
|
|
2033
|
-
u && preloadAssets(
|
|
2057
|
+
u && preloadAssets(c, o, u);
|
|
2034
2058
|
}));
|
|
2035
2059
|
}
|
|
2036
2060
|
registerRemotes(t, o) {
|
|
@@ -2061,87 +2085,87 @@ class RemoteHandler {
|
|
|
2061
2085
|
}), !s)
|
|
2062
2086
|
throw g;
|
|
2063
2087
|
}
|
|
2064
|
-
const { id:
|
|
2065
|
-
assert(
|
|
2088
|
+
const { id: a } = s, c = matchRemoteWithNameAndExpose(o.options.remotes, a);
|
|
2089
|
+
assert(c, getShortErrorMsg(RUNTIME_004, runtimeDescMap, {
|
|
2066
2090
|
hostName: o.options.name,
|
|
2067
|
-
requestId:
|
|
2091
|
+
requestId: a
|
|
2068
2092
|
}));
|
|
2069
|
-
const { remote:
|
|
2070
|
-
id:
|
|
2071
|
-
...
|
|
2093
|
+
const { remote: i } = c, l = getRemoteInfo(i), u = await o.sharedHandler.hooks.lifecycle.afterResolve.emit({
|
|
2094
|
+
id: a,
|
|
2095
|
+
...c,
|
|
2072
2096
|
options: o.options,
|
|
2073
2097
|
origin: o,
|
|
2074
2098
|
remoteInfo: l
|
|
2075
|
-
}), { remote:
|
|
2076
|
-
assert(
|
|
2077
|
-
let
|
|
2099
|
+
}), { remote: p, expose: m } = u;
|
|
2100
|
+
assert(p && m, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${a}.`);
|
|
2101
|
+
let d = o.moduleCache.get(p.name);
|
|
2078
2102
|
const y = {
|
|
2079
2103
|
host: o,
|
|
2080
2104
|
remoteInfo: l
|
|
2081
2105
|
};
|
|
2082
|
-
return
|
|
2083
|
-
module:
|
|
2106
|
+
return d || (d = new Module(y), o.moduleCache.set(p.name, d)), {
|
|
2107
|
+
module: d,
|
|
2084
2108
|
moduleOptions: y,
|
|
2085
2109
|
remoteMatchInfo: u
|
|
2086
2110
|
};
|
|
2087
2111
|
}
|
|
2088
2112
|
registerRemote(t, o, n) {
|
|
2089
|
-
const { host: s } = this,
|
|
2113
|
+
const { host: s } = this, a = () => {
|
|
2090
2114
|
if (t.alias) {
|
|
2091
|
-
const
|
|
2115
|
+
const i = o.find((l) => {
|
|
2092
2116
|
var u;
|
|
2093
2117
|
return t.alias && (l.name.startsWith(t.alias) || ((u = l.alias) == null ? void 0 : u.startsWith(t.alias)));
|
|
2094
2118
|
});
|
|
2095
|
-
assert(!
|
|
2119
|
+
assert(!i, `The alias ${t.alias} of remote ${t.name} is not allowed to be the prefix of ${i && i.name} name or alias`);
|
|
2096
2120
|
}
|
|
2097
2121
|
"entry" in t && isBrowserEnv() && !t.entry.startsWith("http") && (t.entry = new URL(t.entry, window.location.origin).href), t.shareScope || (t.shareScope = DEFAULT_SCOPE), t.type || (t.type = DEFAULT_REMOTE_TYPE);
|
|
2098
2122
|
};
|
|
2099
2123
|
this.hooks.lifecycle.beforeRegisterRemote.emit({ remote: t, origin: s });
|
|
2100
|
-
const
|
|
2101
|
-
if (!
|
|
2102
|
-
|
|
2124
|
+
const c = o.find((i) => i.name === t.name);
|
|
2125
|
+
if (!c)
|
|
2126
|
+
a(), o.push(t), this.hooks.lifecycle.registerRemote.emit({ remote: t, origin: s });
|
|
2103
2127
|
else {
|
|
2104
|
-
const
|
|
2128
|
+
const i = [
|
|
2105
2129
|
`The remote "${t.name}" is already registered.`,
|
|
2106
2130
|
"Please note that overriding it may cause unexpected errors."
|
|
2107
2131
|
];
|
|
2108
|
-
n != null && n.force && (this.removeRemote(
|
|
2132
|
+
n != null && n.force && (this.removeRemote(c), a(), o.push(t), this.hooks.lifecycle.registerRemote.emit({ remote: t, origin: s }), warn$1(i.join(" ")));
|
|
2109
2133
|
}
|
|
2110
2134
|
}
|
|
2111
2135
|
removeRemote(t) {
|
|
2112
2136
|
var o;
|
|
2113
2137
|
try {
|
|
2114
|
-
const { host: n } = this, { name: s } = t,
|
|
2115
|
-
|
|
2116
|
-
const
|
|
2117
|
-
if (
|
|
2118
|
-
const
|
|
2138
|
+
const { host: n } = this, { name: s } = t, a = n.options.remotes.findIndex((i) => i.name === s);
|
|
2139
|
+
a !== -1 && n.options.remotes.splice(a, 1);
|
|
2140
|
+
const c = n.moduleCache.get(t.name);
|
|
2141
|
+
if (c) {
|
|
2142
|
+
const i = c.remoteInfo, l = i.entryGlobalName;
|
|
2119
2143
|
CurrentGlobal[l] && ((o = Object.getOwnPropertyDescriptor(CurrentGlobal, l)) != null && o.configurable ? delete CurrentGlobal[l] : CurrentGlobal[l] = void 0);
|
|
2120
|
-
const u = getRemoteEntryUniqueKey(
|
|
2121
|
-
globalLoading[u] && delete globalLoading[u], n.snapshotHandler.manifestCache.delete(
|
|
2122
|
-
let
|
|
2123
|
-
const
|
|
2124
|
-
if (
|
|
2125
|
-
const y = CurrentGlobal.__FEDERATION__.__INSTANCES__[
|
|
2126
|
-
|
|
2144
|
+
const u = getRemoteEntryUniqueKey(c.remoteInfo);
|
|
2145
|
+
globalLoading[u] && delete globalLoading[u], n.snapshotHandler.manifestCache.delete(i.entry);
|
|
2146
|
+
let p = i.buildVersion ? composeKeyWithSeparator(i.name, i.buildVersion) : i.name;
|
|
2147
|
+
const m = CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex((y) => i.buildVersion ? y.options.id === p : y.name === p);
|
|
2148
|
+
if (m !== -1) {
|
|
2149
|
+
const y = CurrentGlobal.__FEDERATION__.__INSTANCES__[m];
|
|
2150
|
+
p = y.options.id || p;
|
|
2127
2151
|
const g = getGlobalShareScope();
|
|
2128
|
-
let
|
|
2152
|
+
let b = !0;
|
|
2129
2153
|
const E = [];
|
|
2130
|
-
Object.keys(g).forEach((
|
|
2131
|
-
const I = g[
|
|
2154
|
+
Object.keys(g).forEach((R) => {
|
|
2155
|
+
const I = g[R];
|
|
2132
2156
|
I && Object.keys(I).forEach((S) => {
|
|
2133
|
-
const
|
|
2134
|
-
|
|
2135
|
-
const
|
|
2136
|
-
|
|
2137
|
-
const $ =
|
|
2138
|
-
$ && typeof $ == "object" && $.from ===
|
|
2139
|
-
|
|
2157
|
+
const A = I[S];
|
|
2158
|
+
A && Object.keys(A).forEach((_) => {
|
|
2159
|
+
const T = A[_];
|
|
2160
|
+
T && Object.keys(T).forEach((w) => {
|
|
2161
|
+
const $ = T[w];
|
|
2162
|
+
$ && typeof $ == "object" && $.from === i.name && ($.loaded || $.loading ? ($.useIn = $.useIn.filter((P) => P !== i.name), $.useIn.length ? b = !1 : E.push([
|
|
2163
|
+
R,
|
|
2140
2164
|
S,
|
|
2141
2165
|
_,
|
|
2142
2166
|
w
|
|
2143
2167
|
])) : E.push([
|
|
2144
|
-
|
|
2168
|
+
R,
|
|
2145
2169
|
S,
|
|
2146
2170
|
_,
|
|
2147
2171
|
w
|
|
@@ -2149,15 +2173,15 @@ class RemoteHandler {
|
|
|
2149
2173
|
});
|
|
2150
2174
|
});
|
|
2151
2175
|
});
|
|
2152
|
-
}),
|
|
2153
|
-
var _,
|
|
2154
|
-
(w = (
|
|
2155
|
-
}), CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(
|
|
2176
|
+
}), b && (y.shareScopeMap = {}, delete g[p]), E.forEach(([R, I, S, A]) => {
|
|
2177
|
+
var _, T, w;
|
|
2178
|
+
(w = (T = (_ = g[R]) == null ? void 0 : _[I]) == null ? void 0 : T[S]) == null || delete w[A];
|
|
2179
|
+
}), CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(m, 1);
|
|
2156
2180
|
}
|
|
2157
|
-
const { hostGlobalSnapshot:
|
|
2158
|
-
if (
|
|
2159
|
-
const y =
|
|
2160
|
-
y && (delete
|
|
2181
|
+
const { hostGlobalSnapshot: d } = getGlobalRemoteInfo(t, n);
|
|
2182
|
+
if (d) {
|
|
2183
|
+
const y = d && "remotesInfo" in d && d.remotesInfo && getInfoWithoutType(d.remotesInfo, t.name).key;
|
|
2184
|
+
y && (delete d.remotesInfo[y], Global.__FEDERATION__.__MANIFEST_LOADING__[y] && delete Global.__FEDERATION__.__MANIFEST_LOADING__[y]);
|
|
2161
2185
|
}
|
|
2162
2186
|
n.moduleCache.delete(t.name);
|
|
2163
2187
|
}
|
|
@@ -2176,7 +2200,7 @@ class ModuleFederation {
|
|
|
2176
2200
|
beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
|
|
2177
2201
|
// maybe will change, temporarily for internal use only
|
|
2178
2202
|
initContainer: new AsyncWaterfallHook("initContainer")
|
|
2179
|
-
}), this.version = "0.
|
|
2203
|
+
}), this.version = "0.21.1", this.moduleCache = /* @__PURE__ */ new Map(), this.loaderHook = new PluginSystem({
|
|
2180
2204
|
// FIXME: may not be suitable , not open to the public yet
|
|
2181
2205
|
getModuleInfo: new SyncHook(),
|
|
2182
2206
|
createScript: new SyncHook(),
|
|
@@ -2222,8 +2246,8 @@ class ModuleFederation {
|
|
|
2222
2246
|
return this.sharedHandler.initializeSharing(t, o);
|
|
2223
2247
|
}
|
|
2224
2248
|
initRawContainer(t, o, n) {
|
|
2225
|
-
const s = getRemoteInfo({ name: t, entry: o }),
|
|
2226
|
-
return
|
|
2249
|
+
const s = getRemoteInfo({ name: t, entry: o }), a = new Module({ host: this, remoteInfo: s });
|
|
2250
|
+
return a.remoteEntryExports = n, this.moduleCache.set(t, a), a;
|
|
2227
2251
|
}
|
|
2228
2252
|
// eslint-disable-next-line max-lines-per-function
|
|
2229
2253
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
@@ -2238,21 +2262,21 @@ class ModuleFederation {
|
|
|
2238
2262
|
this.sharedHandler.initShareScopeMap(t, o, n);
|
|
2239
2263
|
}
|
|
2240
2264
|
formatOptions(t, o) {
|
|
2241
|
-
const { shared: n } = formatShareConfigs(t, o), { userOptions: s, options:
|
|
2265
|
+
const { shared: n } = formatShareConfigs(t, o), { userOptions: s, options: a } = this.hooks.lifecycle.beforeInit.emit({
|
|
2242
2266
|
origin: this,
|
|
2243
2267
|
userOptions: o,
|
|
2244
2268
|
options: t,
|
|
2245
2269
|
shareInfo: n
|
|
2246
|
-
}),
|
|
2247
|
-
s.plugins && s.plugins.forEach((
|
|
2248
|
-
l.includes(
|
|
2270
|
+
}), c = this.remoteHandler.formatAndRegisterRemote(a, s), { shared: i } = this.sharedHandler.registerShared(a, s), l = [...a.plugins];
|
|
2271
|
+
s.plugins && s.plugins.forEach((p) => {
|
|
2272
|
+
l.includes(p) || l.push(p);
|
|
2249
2273
|
});
|
|
2250
2274
|
const u = {
|
|
2251
2275
|
...t,
|
|
2252
2276
|
...o,
|
|
2253
2277
|
plugins: l,
|
|
2254
|
-
remotes:
|
|
2255
|
-
shared:
|
|
2278
|
+
remotes: c,
|
|
2279
|
+
shared: i
|
|
2256
2280
|
};
|
|
2257
2281
|
return this.hooks.lifecycle.init.emit({
|
|
2258
2282
|
origin: this,
|
|
@@ -2261,7 +2285,7 @@ class ModuleFederation {
|
|
|
2261
2285
|
}
|
|
2262
2286
|
registerPlugins(t) {
|
|
2263
2287
|
const o = registerPlugins(t, this);
|
|
2264
|
-
this.options.plugins = this.options.plugins.reduce((n, s) => (s && n && !n.find((
|
|
2288
|
+
this.options.plugins = this.options.plugins.reduce((n, s) => (s && n && !n.find((a) => a.name === s.name) && n.push(s), n), o || []);
|
|
2265
2289
|
}
|
|
2266
2290
|
registerRemotes(t, o) {
|
|
2267
2291
|
return this.remoteHandler.registerRemotes(t, o);
|
|
@@ -2278,47 +2302,94 @@ function getInstance() {
|
|
|
2278
2302
|
return FederationInstance;
|
|
2279
2303
|
}
|
|
2280
2304
|
setGlobalFederationConstructor(ModuleFederation);
|
|
2305
|
+
function addBasenameToNestedRoutes(r, t) {
|
|
2306
|
+
return r.map((o) => {
|
|
2307
|
+
const n = {
|
|
2308
|
+
...o,
|
|
2309
|
+
path: t + o.path
|
|
2310
|
+
};
|
|
2311
|
+
return o.children && o.children.length > 0 && (n.children = addBasenameToNestedRoutes(
|
|
2312
|
+
o.children,
|
|
2313
|
+
t
|
|
2314
|
+
)), n;
|
|
2315
|
+
});
|
|
2316
|
+
}
|
|
2317
|
+
function processRoutes(r) {
|
|
2318
|
+
const { router: t, basename: o, memoryRoute: n, hashRoute: s } = r, a = t.getRoutes().sort(
|
|
2319
|
+
(d, y) => d.path.split("/").filter((g) => g).length - y.path.split("/").filter((g) => g).length
|
|
2320
|
+
), c = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
|
|
2321
|
+
a.forEach((d) => {
|
|
2322
|
+
c.set(d.path, d);
|
|
2323
|
+
});
|
|
2324
|
+
const l = (d, y) => `${d}/${y}`.replace(/\/+/g, "/").replace(/\/$/, "") || "/", u = (d, y = "") => {
|
|
2325
|
+
if (!d.children || d.children.length === 0)
|
|
2326
|
+
return d;
|
|
2327
|
+
for (let g = 0; g < d.children.length; g++) {
|
|
2328
|
+
const b = d.children[g], E = l(y, b.path), R = c.get(E);
|
|
2329
|
+
if (R && !i.has(R)) {
|
|
2330
|
+
const I = {
|
|
2331
|
+
...R,
|
|
2332
|
+
path: b.path
|
|
2333
|
+
// Keep the original relative path from static route
|
|
2334
|
+
};
|
|
2335
|
+
d.children[g] = I, i.add(R), u(I, E);
|
|
2336
|
+
}
|
|
2337
|
+
}
|
|
2338
|
+
return d;
|
|
2339
|
+
};
|
|
2340
|
+
let p = [];
|
|
2341
|
+
for (const d of a)
|
|
2342
|
+
if (!i.has(d)) {
|
|
2343
|
+
const y = u(d, d.path);
|
|
2344
|
+
i.add(d), p.push(y);
|
|
2345
|
+
}
|
|
2346
|
+
let m;
|
|
2347
|
+
return n ? m = VueRouter.createMemoryHistory(o) : s ? (m = VueRouter.createWebHashHistory(), o && (p = addBasenameToNestedRoutes(p, o))) : m = VueRouter.createWebHistory(o), {
|
|
2348
|
+
history: m,
|
|
2349
|
+
routes: p
|
|
2350
|
+
};
|
|
2351
|
+
}
|
|
2281
2352
|
function createBridgeComponent(r) {
|
|
2282
2353
|
const t = /* @__PURE__ */ new Map(), o = getInstance();
|
|
2283
2354
|
return () => ({
|
|
2284
|
-
__APP_VERSION__: "0.
|
|
2355
|
+
__APP_VERSION__: "0.21.1",
|
|
2285
2356
|
async render(n) {
|
|
2286
|
-
var g,
|
|
2357
|
+
var g, b, E;
|
|
2287
2358
|
LoggerInstance.debug("createBridgeComponent render Info", n);
|
|
2288
2359
|
const {
|
|
2289
2360
|
moduleName: s,
|
|
2290
|
-
dom:
|
|
2291
|
-
basename:
|
|
2292
|
-
memoryRoute:
|
|
2361
|
+
dom: a,
|
|
2362
|
+
basename: c,
|
|
2363
|
+
memoryRoute: i,
|
|
2293
2364
|
hashRoute: l,
|
|
2294
2365
|
...u
|
|
2295
|
-
} = n,
|
|
2296
|
-
t.set(
|
|
2297
|
-
const
|
|
2298
|
-
app:
|
|
2299
|
-
basename:
|
|
2300
|
-
memoryRoute:
|
|
2366
|
+
} = n, p = Vue.createApp(r.rootComponent, u);
|
|
2367
|
+
t.set(a, p);
|
|
2368
|
+
const m = await ((E = (b = (g = o == null ? void 0 : o.bridgeHook) == null ? void 0 : g.lifecycle) == null ? void 0 : b.beforeBridgeRender) == null ? void 0 : E.emit(n)), d = m && typeof m == "object" && (m != null && m.extraProps) ? m == null ? void 0 : m.extraProps : {}, y = r.appOptions({
|
|
2369
|
+
app: p,
|
|
2370
|
+
basename: c,
|
|
2371
|
+
memoryRoute: i,
|
|
2301
2372
|
hashRoute: l,
|
|
2302
2373
|
...u,
|
|
2303
|
-
...
|
|
2374
|
+
...d
|
|
2304
2375
|
});
|
|
2305
2376
|
if (y != null && y.router) {
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2377
|
+
const { history: R, routes: I } = processRoutes({
|
|
2378
|
+
router: y.router,
|
|
2379
|
+
basename: n.basename,
|
|
2380
|
+
memoryRoute: n.memoryRoute,
|
|
2381
|
+
hashRoute: n.hashRoute
|
|
2382
|
+
}), S = VueRouter.createRouter({
|
|
2312
2383
|
...y.router.options,
|
|
2313
|
-
history:
|
|
2384
|
+
history: R,
|
|
2314
2385
|
routes: I
|
|
2315
2386
|
});
|
|
2316
2387
|
LoggerInstance.debug("createBridgeComponent render router info>>>", {
|
|
2317
2388
|
moduleName: s,
|
|
2318
2389
|
router: S
|
|
2319
|
-
}),
|
|
2390
|
+
}), i && await S.push(i.entryPath), p.use(S);
|
|
2320
2391
|
}
|
|
2321
|
-
|
|
2392
|
+
p.mount(a);
|
|
2322
2393
|
},
|
|
2323
2394
|
destroy(n) {
|
|
2324
2395
|
LoggerInstance.debug("createBridgeComponent destroy Info", n);
|
|
@@ -2343,32 +2414,32 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2343
2414
|
},
|
|
2344
2415
|
inheritAttrs: !1,
|
|
2345
2416
|
setup(r) {
|
|
2346
|
-
const t = ref(null), o = ref(null), n = ref(""), s = useRoute(),
|
|
2347
|
-
var
|
|
2348
|
-
const u = (
|
|
2417
|
+
const t = ref(null), o = ref(null), n = ref(""), s = useRoute(), a = getInstance(), c = useAttrs(), i = async () => {
|
|
2418
|
+
var d, y, g, b;
|
|
2419
|
+
const u = (d = r.providerInfo) == null ? void 0 : d.call(r);
|
|
2349
2420
|
o.value = u;
|
|
2350
|
-
let
|
|
2351
|
-
...
|
|
2421
|
+
let p = {
|
|
2422
|
+
...c,
|
|
2352
2423
|
moduleName: r.moduleName,
|
|
2353
2424
|
dom: t.value,
|
|
2354
2425
|
basename: r.basename,
|
|
2355
2426
|
memoryRoute: r.memoryRoute,
|
|
2356
2427
|
hashRoute: r.hashRoute
|
|
2357
2428
|
};
|
|
2358
|
-
LoggerInstance.debug("createRemoteAppComponent LazyComponent render >>>",
|
|
2359
|
-
const
|
|
2360
|
-
|
|
2361
|
-
...
|
|
2362
|
-
...
|
|
2363
|
-
}, u.render(
|
|
2429
|
+
LoggerInstance.debug("createRemoteAppComponent LazyComponent render >>>", p);
|
|
2430
|
+
const m = await ((b = (g = (y = a == null ? void 0 : a.bridgeHook) == null ? void 0 : y.lifecycle) == null ? void 0 : g.beforeBridgeRender) == null ? void 0 : b.emit(p)) || {};
|
|
2431
|
+
p = {
|
|
2432
|
+
...p,
|
|
2433
|
+
...m.extraProps
|
|
2434
|
+
}, u.render(p);
|
|
2364
2435
|
}, l = watch(() => s == null ? void 0 : s.path, (u) => {
|
|
2365
|
-
u !== s.path &&
|
|
2436
|
+
u !== s.path && i(), n.value !== "" && n.value !== u && (LoggerInstance.debug("createRemoteAppComponent dispatchPopstateEnv >>>", {
|
|
2366
2437
|
...r,
|
|
2367
2438
|
pathname: s.path
|
|
2368
2439
|
}), e()), n.value = u;
|
|
2369
2440
|
});
|
|
2370
2441
|
return onMounted(() => {
|
|
2371
|
-
|
|
2442
|
+
i();
|
|
2372
2443
|
}), onBeforeUnmount(() => {
|
|
2373
2444
|
var u;
|
|
2374
2445
|
LoggerInstance.debug("createRemoteAppComponent LazyComponent destroy >>>", {
|
|
@@ -2383,7 +2454,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2383
2454
|
});
|
|
2384
2455
|
function createRemoteAppComponent(r) {
|
|
2385
2456
|
return defineAsyncComponent({
|
|
2386
|
-
__APP_VERSION__: "0.
|
|
2457
|
+
__APP_VERSION__: "0.21.1",
|
|
2387
2458
|
...r.asyncComponentOptions,
|
|
2388
2459
|
//@ts-ignore
|
|
2389
2460
|
loader: async () => {
|
|
@@ -2400,16 +2471,16 @@ function createRemoteAppComponent(r) {
|
|
|
2400
2471
|
info: r
|
|
2401
2472
|
}
|
|
2402
2473
|
);
|
|
2403
|
-
const
|
|
2474
|
+
const a = await r.loader(), c = a && a[Symbol.for("mf_module_id")], i = a[s];
|
|
2404
2475
|
if (LoggerInstance.debug(
|
|
2405
2476
|
"createRemoteAppComponent LazyComponent loadRemote info >>>",
|
|
2406
|
-
{ moduleName:
|
|
2407
|
-
), s in
|
|
2477
|
+
{ moduleName: c, module: a, exportName: s, basename: o, route: t }
|
|
2478
|
+
), s in a && typeof i == "function")
|
|
2408
2479
|
return {
|
|
2409
2480
|
render() {
|
|
2410
2481
|
return h(RemoteApp, {
|
|
2411
|
-
moduleName:
|
|
2412
|
-
providerInfo:
|
|
2482
|
+
moduleName: c,
|
|
2483
|
+
providerInfo: i,
|
|
2413
2484
|
basename: o,
|
|
2414
2485
|
rootAttrs: r.rootAttrs
|
|
2415
2486
|
});
|