@module-federation/bridge-vue3 0.22.0 → 0.22.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 +8 -0
- package/dist/index.cjs +6 -6
- package/dist/index.js +594 -603
- package/package.json +4 -4
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 i = s.slice(1);
|
|
51
|
+
return i.endsWith("/") ? i.slice(0, -1) : i;
|
|
52
52
|
}
|
|
53
53
|
return s;
|
|
54
54
|
})(r);
|
|
@@ -58,70 +58,70 @@ function inferAutoPublicPath(r) {
|
|
|
58
58
|
return r.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
|
|
59
59
|
}
|
|
60
60
|
function generateSnapshotFromManifest(r, t = {}) {
|
|
61
|
-
var
|
|
61
|
+
var S, I, A;
|
|
62
62
|
const { remotes: o = {}, overrides: n = {}, version: s } = t;
|
|
63
|
-
let
|
|
64
|
-
const c = () => "publicPath" in r.metaData ? r.metaData.publicPath === "auto" && s ? inferAutoPublicPath(s) : r.metaData.publicPath : r.metaData.getPublicPath,
|
|
63
|
+
let i;
|
|
64
|
+
const c = () => "publicPath" in r.metaData ? r.metaData.publicPath === "auto" && s ? inferAutoPublicPath(s) : r.metaData.publicPath : r.metaData.getPublicPath, a = Object.keys(n);
|
|
65
65
|
let l = {};
|
|
66
|
-
Object.keys(o).length || (l = ((
|
|
66
|
+
Object.keys(o).length || (l = ((S = r.remotes) == null ? void 0 : S.reduce((R, T) => {
|
|
67
67
|
let w;
|
|
68
68
|
const $ = T.federationContainerName;
|
|
69
|
-
return
|
|
69
|
+
return a.includes($) ? w = n[$] : "version" in T ? w = T.version : w = T.entry, R[$] = {
|
|
70
70
|
matchedVersion: w
|
|
71
|
-
},
|
|
72
|
-
}, {})) || {}), Object.keys(o).forEach((
|
|
71
|
+
}, R;
|
|
72
|
+
}, {})) || {}), Object.keys(o).forEach((R) => l[R] = {
|
|
73
73
|
// overrides will override dependencies
|
|
74
|
-
matchedVersion:
|
|
74
|
+
matchedVersion: a.includes(R) ? n[R] : o[R]
|
|
75
75
|
});
|
|
76
|
-
const { remoteEntry: { path: u, name:
|
|
77
|
-
let
|
|
76
|
+
const { remoteEntry: { path: u, name: d, type: y }, types: p = { path: "", name: "", zip: "", api: "" }, buildInfo: { buildVersion: m }, globalName: g, ssrRemoteEntry: _ } = r.metaData, { exposes: E } = r;
|
|
77
|
+
let b = {
|
|
78
78
|
version: s || "",
|
|
79
|
-
buildVersion:
|
|
79
|
+
buildVersion: m,
|
|
80
80
|
globalName: g,
|
|
81
|
-
remoteEntry: simpleJoinRemoteEntry(u,
|
|
82
|
-
remoteEntryType:
|
|
83
|
-
remoteTypes: simpleJoinRemoteEntry(
|
|
84
|
-
remoteTypesZip:
|
|
85
|
-
remoteTypesAPI:
|
|
81
|
+
remoteEntry: simpleJoinRemoteEntry(u, d),
|
|
82
|
+
remoteEntryType: y,
|
|
83
|
+
remoteTypes: simpleJoinRemoteEntry(p.path, p.name),
|
|
84
|
+
remoteTypesZip: p.zip || "",
|
|
85
|
+
remoteTypesAPI: p.api || "",
|
|
86
86
|
remotesInfo: l,
|
|
87
|
-
shared: r == null ? void 0 : r.shared.map((
|
|
88
|
-
assets:
|
|
89
|
-
sharedName:
|
|
90
|
-
version:
|
|
87
|
+
shared: r == null ? void 0 : r.shared.map((R) => ({
|
|
88
|
+
assets: R.assets,
|
|
89
|
+
sharedName: R.name,
|
|
90
|
+
version: R.version
|
|
91
91
|
})),
|
|
92
|
-
modules: E == null ? void 0 : E.map((
|
|
93
|
-
moduleName:
|
|
94
|
-
modulePath:
|
|
95
|
-
assets:
|
|
92
|
+
modules: E == null ? void 0 : E.map((R) => ({
|
|
93
|
+
moduleName: R.name,
|
|
94
|
+
modulePath: R.path,
|
|
95
|
+
assets: R.assets
|
|
96
96
|
}))
|
|
97
97
|
};
|
|
98
|
-
if ((
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
...
|
|
102
|
-
prefetchInterface:
|
|
98
|
+
if ((I = r.metaData) != null && I.prefetchInterface) {
|
|
99
|
+
const R = r.metaData.prefetchInterface;
|
|
100
|
+
b = {
|
|
101
|
+
...b,
|
|
102
|
+
prefetchInterface: R
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
105
|
if ((A = r.metaData) != null && A.prefetchEntry) {
|
|
106
|
-
const { path:
|
|
107
|
-
|
|
108
|
-
...
|
|
109
|
-
prefetchEntry: simpleJoinRemoteEntry(
|
|
106
|
+
const { path: R, name: T, type: w } = r.metaData.prefetchEntry;
|
|
107
|
+
b = {
|
|
108
|
+
...b,
|
|
109
|
+
prefetchEntry: simpleJoinRemoteEntry(R, T),
|
|
110
110
|
prefetchEntryType: w
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
|
-
if ("publicPath" in r.metaData ?
|
|
114
|
-
...
|
|
113
|
+
if ("publicPath" in r.metaData ? i = {
|
|
114
|
+
...b,
|
|
115
115
|
publicPath: c(),
|
|
116
116
|
ssrPublicPath: r.metaData.ssrPublicPath
|
|
117
|
-
} :
|
|
118
|
-
...
|
|
117
|
+
} : i = {
|
|
118
|
+
...b,
|
|
119
119
|
getPublicPath: c()
|
|
120
|
-
},
|
|
121
|
-
const
|
|
122
|
-
|
|
120
|
+
}, _) {
|
|
121
|
+
const R = simpleJoinRemoteEntry(_.path, _.name);
|
|
122
|
+
i.ssrRemoteEntry = R, i.ssrRemoteEntryType = _.type || "commonjs-module";
|
|
123
123
|
}
|
|
124
|
-
return
|
|
124
|
+
return i;
|
|
125
125
|
}
|
|
126
126
|
function isManifestProvider(r) {
|
|
127
127
|
return !!("remoteEntry" in r && r.remoteEntry.includes(MANIFEST_EXT));
|
|
@@ -143,7 +143,7 @@ function captureStackTrace() {
|
|
|
143
143
|
if (!r)
|
|
144
144
|
return;
|
|
145
145
|
const [, ...t] = r.split(`
|
|
146
|
-
`), o = t.filter((s) => !LOGGER_STACK_SKIP_TOKENS.some((
|
|
146
|
+
`), o = t.filter((s) => !LOGGER_STACK_SKIP_TOKENS.some((i) => s.includes(i)));
|
|
147
147
|
return o.length ? `Stack trace:
|
|
148
148
|
${o.slice(0, 5).join(`
|
|
149
149
|
`)}` : void 0;
|
|
@@ -162,7 +162,7 @@ class Logger {
|
|
|
162
162
|
this.delegate = t ?? DEFAULT_DELEGATE;
|
|
163
163
|
}
|
|
164
164
|
emit(t, o) {
|
|
165
|
-
const n = this.delegate,
|
|
165
|
+
const n = this.delegate, i = isDebugMode() ? captureStackTrace() : void 0, c = i ? [...o, i] : o, a = (() => {
|
|
166
166
|
switch (t) {
|
|
167
167
|
case "log":
|
|
168
168
|
return ["log", "info"];
|
|
@@ -177,14 +177,14 @@ class Logger {
|
|
|
177
177
|
return ["debug", "log"];
|
|
178
178
|
}
|
|
179
179
|
})();
|
|
180
|
-
for (const l of
|
|
180
|
+
for (const l of a) {
|
|
181
181
|
const u = n[l];
|
|
182
182
|
if (typeof u == "function") {
|
|
183
183
|
u.call(n, this.prefix, ...c);
|
|
184
184
|
return;
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
-
for (const l of
|
|
187
|
+
for (const l of a) {
|
|
188
188
|
const u = DEFAULT_DELEGATE[l];
|
|
189
189
|
if (typeof u == "function") {
|
|
190
190
|
u.call(DEFAULT_DELEGATE, this.prefix, ...c);
|
|
@@ -240,37 +240,37 @@ function isStaticResourcesEqual(r, t) {
|
|
|
240
240
|
}
|
|
241
241
|
function createScript(r) {
|
|
242
242
|
let t = null, o = !0, n = 2e4, s;
|
|
243
|
-
const
|
|
244
|
-
for (let
|
|
245
|
-
const l = a
|
|
243
|
+
const i = document.getElementsByTagName("script");
|
|
244
|
+
for (let a = 0; a < i.length; a++) {
|
|
245
|
+
const l = i[a], u = l.getAttribute("src");
|
|
246
246
|
if (u && isStaticResourcesEqual(u, r.url)) {
|
|
247
247
|
t = l, o = !1;
|
|
248
248
|
break;
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
251
|
if (!t) {
|
|
252
|
-
const
|
|
253
|
-
t = document.createElement("script"), t.type = (
|
|
252
|
+
const a = r.attrs;
|
|
253
|
+
t = document.createElement("script"), t.type = (a == null ? void 0 : a.type) === "module" ? "module" : "text/javascript";
|
|
254
254
|
let l;
|
|
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),
|
|
256
|
-
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), a && !l && Object.keys(a).forEach((u) => {
|
|
256
|
+
t && (u === "async" || u === "defer" ? t[u] = a[u] : t.getAttribute(u) || t.setAttribute(u, a[u]));
|
|
257
257
|
});
|
|
258
258
|
}
|
|
259
|
-
const c = async (
|
|
259
|
+
const c = async (a, l) => {
|
|
260
260
|
clearTimeout(s);
|
|
261
261
|
const u = () => {
|
|
262
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());
|
|
263
263
|
};
|
|
264
264
|
if (t && (t.onerror = null, t.onload = null, safeWrapper(() => {
|
|
265
|
-
const { needDeleteScript:
|
|
266
|
-
|
|
267
|
-
}),
|
|
268
|
-
const
|
|
269
|
-
if (
|
|
270
|
-
const
|
|
271
|
-
return u(),
|
|
265
|
+
const { needDeleteScript: d = !0 } = r;
|
|
266
|
+
d && t != null && t.parentNode && t.parentNode.removeChild(t);
|
|
267
|
+
}), a && typeof a == "function")) {
|
|
268
|
+
const d = a(l);
|
|
269
|
+
if (d instanceof Promise) {
|
|
270
|
+
const y = await d;
|
|
271
|
+
return u(), y;
|
|
272
272
|
}
|
|
273
|
-
return u(),
|
|
273
|
+
return u(), d;
|
|
274
274
|
}
|
|
275
275
|
u();
|
|
276
276
|
};
|
|
@@ -281,43 +281,43 @@ function createScript(r) {
|
|
|
281
281
|
function createLink(r) {
|
|
282
282
|
let t = null, o = !0;
|
|
283
283
|
const n = document.getElementsByTagName("link");
|
|
284
|
-
for (let
|
|
285
|
-
const c = n[
|
|
286
|
-
if (
|
|
284
|
+
for (let i = 0; i < n.length; i++) {
|
|
285
|
+
const c = n[i], a = c.getAttribute("href"), l = c.getAttribute("rel");
|
|
286
|
+
if (a && isStaticResourcesEqual(a, r.url) && l === r.attrs.rel) {
|
|
287
287
|
t = c, o = !1;
|
|
288
288
|
break;
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
291
|
if (!t) {
|
|
292
292
|
t = document.createElement("link"), t.setAttribute("href", r.url);
|
|
293
|
-
let
|
|
293
|
+
let i;
|
|
294
294
|
const c = r.attrs;
|
|
295
|
-
r.createLinkHook && (
|
|
296
|
-
t && !t.getAttribute(
|
|
295
|
+
r.createLinkHook && (i = r.createLinkHook(r.url, c), i instanceof HTMLLinkElement && (t = i)), c && !i && Object.keys(c).forEach((a) => {
|
|
296
|
+
t && !t.getAttribute(a) && t.setAttribute(a, c[a]);
|
|
297
297
|
});
|
|
298
298
|
}
|
|
299
|
-
const s = (
|
|
300
|
-
const
|
|
299
|
+
const s = (i, c) => {
|
|
300
|
+
const a = () => {
|
|
301
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());
|
|
302
302
|
};
|
|
303
303
|
if (t && (t.onerror = null, t.onload = null, safeWrapper(() => {
|
|
304
304
|
const { needDeleteLink: l = !0 } = r;
|
|
305
305
|
l && t != null && t.parentNode && t.parentNode.removeChild(t);
|
|
306
|
-
}),
|
|
307
|
-
const l =
|
|
308
|
-
return
|
|
306
|
+
}), i)) {
|
|
307
|
+
const l = i(c);
|
|
308
|
+
return a(), l;
|
|
309
309
|
}
|
|
310
|
-
|
|
310
|
+
a();
|
|
311
311
|
};
|
|
312
312
|
return t.onerror = s.bind(null, t.onerror), t.onload = s.bind(null, t.onload), { link: t, needAttach: o };
|
|
313
313
|
}
|
|
314
314
|
function loadScript(r, t) {
|
|
315
315
|
const { attrs: o = {}, createScriptHook: n } = t;
|
|
316
|
-
return new Promise((s,
|
|
317
|
-
const { script: c, needAttach:
|
|
316
|
+
return new Promise((s, i) => {
|
|
317
|
+
const { script: c, needAttach: a } = createScript({
|
|
318
318
|
url: r,
|
|
319
319
|
cb: s,
|
|
320
|
-
onErrorCallback:
|
|
320
|
+
onErrorCallback: i,
|
|
321
321
|
attrs: {
|
|
322
322
|
fetchpriority: "high",
|
|
323
323
|
...o
|
|
@@ -325,7 +325,7 @@ function loadScript(r, t) {
|
|
|
325
325
|
createScriptHook: n,
|
|
326
326
|
needDeleteScript: !0
|
|
327
327
|
});
|
|
328
|
-
|
|
328
|
+
a && document.head.appendChild(c);
|
|
329
329
|
});
|
|
330
330
|
}
|
|
331
331
|
const sdkImportCache = /* @__PURE__ */ new Map();
|
|
@@ -343,7 +343,7 @@ const loadNodeFetch = async () => {
|
|
|
343
343
|
const r = await importNodeModule("node-fetch");
|
|
344
344
|
return r.default || r;
|
|
345
345
|
}, lazyLoaderHookFetch = async (r, t, o) => {
|
|
346
|
-
const s = await ((
|
|
346
|
+
const s = await ((i, c) => o.lifecycle.fetch.emit(i, c))(r, t || {});
|
|
347
347
|
return !s || !(s instanceof Response) ? (typeof fetch > "u" ? await loadNodeFetch() : fetch)(r, t || {}) : s;
|
|
348
348
|
}, createScriptNode = typeof ENV_TARGET > "u" || ENV_TARGET !== "web" ? (url, cb, attrs, loaderHook) => {
|
|
349
349
|
if (loaderHook != null && loaderHook.createScriptHook) {
|
|
@@ -400,12 +400,12 @@ const loadNodeFetch = async () => {
|
|
|
400
400
|
} : (r, t, o, n) => {
|
|
401
401
|
t(new Error("createScriptNode is disabled in non-Node.js environment"));
|
|
402
402
|
}, loadScriptNode = typeof ENV_TARGET > "u" || ENV_TARGET !== "web" ? (r, t) => new Promise((o, n) => {
|
|
403
|
-
createScriptNode(r, (s,
|
|
404
|
-
var c,
|
|
403
|
+
createScriptNode(r, (s, i) => {
|
|
404
|
+
var c, a;
|
|
405
405
|
if (s)
|
|
406
406
|
n(s);
|
|
407
407
|
else {
|
|
408
|
-
const l = ((c = t == null ? void 0 : t.attrs) == null ? void 0 : c.globalName) || `__FEDERATION_${(
|
|
408
|
+
const l = ((c = t == null ? void 0 : t.attrs) == null ? void 0 : c.globalName) || `__FEDERATION_${(a = t == null ? void 0 : t.attrs) == null ? void 0 : a.name}:custom__`, u = globalThis[l] = i;
|
|
409
409
|
o(u);
|
|
410
410
|
}
|
|
411
411
|
}, t.attrs, t.loaderHook);
|
|
@@ -415,15 +415,15 @@ const loadNodeFetch = async () => {
|
|
|
415
415
|
async function loadModule(r, t) {
|
|
416
416
|
if (esmModuleCache.has(r))
|
|
417
417
|
return esmModuleCache.get(r);
|
|
418
|
-
const { fetch: o, vm: n } = t,
|
|
418
|
+
const { fetch: o, vm: n } = t, i = await (await o(r)).text(), c = new n.SourceTextModule(i, {
|
|
419
419
|
// @ts-ignore
|
|
420
|
-
importModuleDynamically: async (
|
|
421
|
-
const u = new URL(
|
|
420
|
+
importModuleDynamically: async (a, l) => {
|
|
421
|
+
const u = new URL(a, r).href;
|
|
422
422
|
return loadModule(u, t);
|
|
423
423
|
}
|
|
424
424
|
});
|
|
425
|
-
return esmModuleCache.set(r, c), await c.link(async (
|
|
426
|
-
const l = new URL(
|
|
425
|
+
return esmModuleCache.set(r, c), await c.link(async (a) => {
|
|
426
|
+
const l = new URL(a, r).href;
|
|
427
427
|
return await loadModule(l, t);
|
|
428
428
|
}), c;
|
|
429
429
|
}
|
|
@@ -513,7 +513,7 @@ function includeOwnProperty(r, t) {
|
|
|
513
513
|
includeOwnProperty(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__") || definePropertyGlobalVal(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});
|
|
514
514
|
const globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;
|
|
515
515
|
function setGlobalDefaultVal(r) {
|
|
516
|
-
var t, o, n, s,
|
|
516
|
+
var t, o, n, s, i, c;
|
|
517
517
|
includeOwnProperty(r, "__VMOK__") && !includeOwnProperty(r, "__FEDERATION__") && definePropertyGlobalVal(r, "__FEDERATION__", r.__VMOK__), includeOwnProperty(r, "__FEDERATION__") || (definePropertyGlobalVal(r, "__FEDERATION__", {
|
|
518
518
|
__GLOBAL_PLUGIN__: [],
|
|
519
519
|
__INSTANCES__: [],
|
|
@@ -521,12 +521,12 @@ function setGlobalDefaultVal(r) {
|
|
|
521
521
|
__SHARE__: {},
|
|
522
522
|
__MANIFEST_LOADING__: {},
|
|
523
523
|
__PRELOADED_MAP__: /* @__PURE__ */ new Map()
|
|
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__ = {}), (
|
|
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__ = {}), (i = r.__FEDERATION__).__MANIFEST_LOADING__ ?? (i.__MANIFEST_LOADING__ = {}), (c = r.__FEDERATION__).__PRELOADED_MAP__ ?? (c.__PRELOADED_MAP__ = /* @__PURE__ */ new Map());
|
|
525
525
|
}
|
|
526
526
|
setGlobalDefaultVal(CurrentGlobal);
|
|
527
527
|
setGlobalDefaultVal(nativeGlobal);
|
|
528
528
|
function setGlobalFederationConstructor(r, t = isDebugMode()) {
|
|
529
|
-
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = r, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.22.
|
|
529
|
+
t && (CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = r, CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.22.1");
|
|
530
530
|
}
|
|
531
531
|
function getInfoWithoutType(r, t) {
|
|
532
532
|
if (typeof t == "string") {
|
|
@@ -538,11 +538,11 @@ function getInfoWithoutType(r, t) {
|
|
|
538
538
|
{
|
|
539
539
|
const n = Object.keys(r);
|
|
540
540
|
for (const s of n) {
|
|
541
|
-
const [
|
|
541
|
+
const [i, c] = s.split(":"), a = `${i}:${t}`, l = r[a];
|
|
542
542
|
if (l)
|
|
543
543
|
return {
|
|
544
544
|
value: l,
|
|
545
|
-
key:
|
|
545
|
+
key: a
|
|
546
546
|
};
|
|
547
547
|
}
|
|
548
548
|
return {
|
|
@@ -558,9 +558,9 @@ const getGlobalSnapshot = () => nativeGlobal.__FEDERATION__.moduleInfo, getTarge
|
|
|
558
558
|
if (n && !n.version && "version" in r && r.version && (n.version = r.version), n)
|
|
559
559
|
return n;
|
|
560
560
|
if ("version" in r && r.version) {
|
|
561
|
-
const { version: s, ...
|
|
562
|
-
if ((
|
|
563
|
-
return
|
|
561
|
+
const { version: s, ...i } = r, c = getFMId(i), a = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, c).value;
|
|
562
|
+
if ((a == null ? void 0 : a.version) === s)
|
|
563
|
+
return a;
|
|
564
564
|
}
|
|
565
565
|
}, getGlobalSnapshotInfoByModuleInfo = (r) => getTargetSnapshotInfoByModuleInfo(r, nativeGlobal.__FEDERATION__.moduleInfo), setGlobalSnapshotInfoByModuleInfo = (r, t) => {
|
|
566
566
|
const o = getFMId(r);
|
|
@@ -596,7 +596,7 @@ function combineVersion(r, t, o, n) {
|
|
|
596
596
|
return n ? `${s}-${n}` : s;
|
|
597
597
|
}
|
|
598
598
|
function parseHyphen(r) {
|
|
599
|
-
return r.replace(parseRegex(hyphenRange), (t, o, n, s,
|
|
599
|
+
return r.replace(parseRegex(hyphenRange), (t, o, n, s, i, c, a, l, u, d, y, p) => (isXVersion(n) ? o = "" : isXVersion(s) ? o = `>=${n}.0.0` : isXVersion(i) ? o = `>=${n}.${s}.0` : o = `>=${o}`, isXVersion(u) ? l = "" : isXVersion(d) ? l = `<${Number(u) + 1}.0.0-0` : isXVersion(y) ? l = `<${u}.${Number(d) + 1}.0-0` : p ? l = `<=${u}.${d}.${y}-${p}` : l = `<=${l}`, `${o} ${l}`.trim()));
|
|
600
600
|
}
|
|
601
601
|
function parseComparatorTrim(r) {
|
|
602
602
|
return r.replace(parseRegex(comparatorTrim), "$1$2$3");
|
|
@@ -608,15 +608,15 @@ function parseCaretTrim(r) {
|
|
|
608
608
|
return r.replace(parseRegex(caretTrim), "$1^");
|
|
609
609
|
}
|
|
610
610
|
function parseCarets(r) {
|
|
611
|
-
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, i, c) => isXVersion(n) ? "" : isXVersion(s) ? `>=${n}.0.0 <${Number(n) + 1}.0.0-0` : isXVersion(i) ? 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}.${i}-${c} <${n}.${s}.${Number(i) + 1}-0` : `>=${n}.${s}.${i}-${c} <${n}.${Number(s) + 1}.0-0` : `>=${n}.${s}.${i}-${c} <${Number(n) + 1}.0.0-0` : n === "0" ? s === "0" ? `>=${n}.${s}.${i} <${n}.${s}.${Number(i) + 1}-0` : `>=${n}.${s}.${i} <${n}.${Number(s) + 1}.0-0` : `>=${n}.${s}.${i} <${Number(n) + 1}.0.0-0`)).join(" ");
|
|
612
612
|
}
|
|
613
613
|
function parseTildes(r) {
|
|
614
|
-
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, i, c) => isXVersion(n) ? "" : isXVersion(s) ? `>=${n}.0.0 <${Number(n) + 1}.0.0-0` : isXVersion(i) ? `>=${n}.${s}.0 <${n}.${Number(s) + 1}.0-0` : c ? `>=${n}.${s}.${i}-${c} <${n}.${Number(s) + 1}.0-0` : `>=${n}.${s}.${i} <${n}.${Number(s) + 1}.0-0`)).join(" ");
|
|
615
615
|
}
|
|
616
616
|
function parseXRanges(r) {
|
|
617
|
-
return r.split(/\s+/).map((t) => t.trim().replace(parseRegex(xRange), (o, n, s,
|
|
618
|
-
const l = isXVersion(s), u = l || isXVersion(
|
|
619
|
-
return n === "=" &&
|
|
617
|
+
return r.split(/\s+/).map((t) => t.trim().replace(parseRegex(xRange), (o, n, s, i, c, a) => {
|
|
618
|
+
const l = isXVersion(s), u = l || isXVersion(i), d = u || isXVersion(c);
|
|
619
|
+
return n === "=" && d && (n = ""), a = "", l ? n === ">" || n === "<" ? "<0.0.0-0" : "*" : n && d ? (u && (i = 0), c = 0, n === ">" ? (n = ">=", u ? (s = Number(s) + 1, i = 0, c = 0) : (i = Number(i) + 1, c = 0)) : n === "<=" && (n = "<", u ? s = Number(s) + 1 : i = Number(i) + 1), n === "<" && (a = "-0"), `${n + s}.${i}.${c}${a}`) : u ? `>=${s}.0.0${a} <${Number(s) + 1}.0.0-0` : d ? `>=${s}.${i}.0${a} <${s}.${Number(i) + 1}.0-0` : o;
|
|
620
620
|
})).join(" ");
|
|
621
621
|
}
|
|
622
622
|
function parseStar(r) {
|
|
@@ -636,10 +636,10 @@ function comparePreRelease(r, t) {
|
|
|
636
636
|
return -1;
|
|
637
637
|
if (o === void 0 && n === void 0)
|
|
638
638
|
return 0;
|
|
639
|
-
for (let s = 0,
|
|
640
|
-
const c = o[s],
|
|
641
|
-
if (c !==
|
|
642
|
-
return c === void 0 &&
|
|
639
|
+
for (let s = 0, i = o.length; s <= i; s++) {
|
|
640
|
+
const c = o[s], a = n[s];
|
|
641
|
+
if (c !== a)
|
|
642
|
+
return c === void 0 && a === void 0 ? 0 : c ? a ? compareAtom(c, a) : -1 : 1;
|
|
643
643
|
}
|
|
644
644
|
return 0;
|
|
645
645
|
}
|
|
@@ -712,53 +712,53 @@ function satisfy(r, t) {
|
|
|
712
712
|
const o = extractComparator(r);
|
|
713
713
|
if (!o)
|
|
714
714
|
return !1;
|
|
715
|
-
const [, n, , s,
|
|
715
|
+
const [, n, , s, i, c, a] = o, l = {
|
|
716
716
|
operator: n,
|
|
717
|
-
version: combineVersion(s,
|
|
717
|
+
version: combineVersion(s, i, c, a),
|
|
718
718
|
// exclude build atom
|
|
719
719
|
major: s,
|
|
720
|
-
minor:
|
|
720
|
+
minor: i,
|
|
721
721
|
patch: c,
|
|
722
|
-
preRelease:
|
|
722
|
+
preRelease: a == null ? void 0 : a.split(".")
|
|
723
723
|
}, u = t.split("||");
|
|
724
|
-
for (const
|
|
725
|
-
const
|
|
726
|
-
if (!
|
|
724
|
+
for (const d of u) {
|
|
725
|
+
const y = d.trim();
|
|
726
|
+
if (!y || y === "*" || y === "x")
|
|
727
727
|
return !0;
|
|
728
728
|
try {
|
|
729
|
-
const
|
|
730
|
-
if (!
|
|
729
|
+
const p = parseRange(y);
|
|
730
|
+
if (!p.trim())
|
|
731
731
|
return !0;
|
|
732
|
-
const
|
|
733
|
-
if (!
|
|
732
|
+
const m = p.split(" ").map((E) => parseComparatorString(E)).join(" ");
|
|
733
|
+
if (!m.trim())
|
|
734
734
|
return !0;
|
|
735
|
-
const g =
|
|
735
|
+
const g = m.split(/\s+/).map((E) => parseGTE0(E)).filter(Boolean);
|
|
736
736
|
if (g.length === 0)
|
|
737
737
|
continue;
|
|
738
|
-
let
|
|
738
|
+
let _ = !0;
|
|
739
739
|
for (const E of g) {
|
|
740
|
-
const
|
|
741
|
-
if (!
|
|
742
|
-
|
|
740
|
+
const b = extractComparator(E);
|
|
741
|
+
if (!b) {
|
|
742
|
+
_ = !1;
|
|
743
743
|
break;
|
|
744
744
|
}
|
|
745
|
-
const [,
|
|
746
|
-
operator:
|
|
747
|
-
version: combineVersion(
|
|
748
|
-
major:
|
|
745
|
+
const [, S, , I, A, R, T] = b, w = {
|
|
746
|
+
operator: S,
|
|
747
|
+
version: combineVersion(I, A, R, T),
|
|
748
|
+
major: I,
|
|
749
749
|
minor: A,
|
|
750
|
-
patch:
|
|
750
|
+
patch: R,
|
|
751
751
|
preRelease: T == null ? void 0 : T.split(".")
|
|
752
752
|
};
|
|
753
753
|
if (!compare(w, l)) {
|
|
754
|
-
|
|
754
|
+
_ = !1;
|
|
755
755
|
break;
|
|
756
756
|
}
|
|
757
757
|
}
|
|
758
|
-
if (
|
|
758
|
+
if (_)
|
|
759
759
|
return !0;
|
|
760
|
-
} catch (
|
|
761
|
-
console.error(`[semver] Error processing range part "${
|
|
760
|
+
} catch (p) {
|
|
761
|
+
console.error(`[semver] Error processing range part "${y}":`, p);
|
|
762
762
|
continue;
|
|
763
763
|
}
|
|
764
764
|
}
|
|
@@ -789,26 +789,26 @@ function formatShare(r, t, o, n) {
|
|
|
789
789
|
};
|
|
790
790
|
}
|
|
791
791
|
function formatShareConfigs(r, t) {
|
|
792
|
-
const o = t.shared || {}, n = t.name, s = Object.keys(o).reduce((c,
|
|
793
|
-
const l = arrayOptions(o[
|
|
794
|
-
return c[
|
|
795
|
-
c[
|
|
792
|
+
const o = t.shared || {}, n = t.name, s = Object.keys(o).reduce((c, a) => {
|
|
793
|
+
const l = arrayOptions(o[a]);
|
|
794
|
+
return c[a] = c[a] || [], l.forEach((u) => {
|
|
795
|
+
c[a].push(formatShare(u, n, a, t.shareStrategy));
|
|
796
796
|
}), c;
|
|
797
|
-
}, {}),
|
|
797
|
+
}, {}), i = {
|
|
798
798
|
...r.shared
|
|
799
799
|
};
|
|
800
800
|
return Object.keys(s).forEach((c) => {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
}) :
|
|
804
|
-
}), { shared:
|
|
801
|
+
i[c] ? s[c].forEach((a) => {
|
|
802
|
+
i[c].find((u) => u.version === a.version) || i[c].push(a);
|
|
803
|
+
}) : i[c] = s[c];
|
|
804
|
+
}), { shared: i, shareInfos: s };
|
|
805
805
|
}
|
|
806
806
|
function versionLt(r, t) {
|
|
807
807
|
const o = (n) => {
|
|
808
808
|
if (!Number.isNaN(Number(n))) {
|
|
809
|
-
const
|
|
809
|
+
const i = n.split(".");
|
|
810
810
|
let c = n;
|
|
811
|
-
for (let
|
|
811
|
+
for (let a = 0; a < 3 - i.length; a++)
|
|
812
812
|
c += ".0";
|
|
813
813
|
return c;
|
|
814
814
|
}
|
|
@@ -823,15 +823,15 @@ const findVersion = (r, t) => {
|
|
|
823
823
|
return Object.keys(r).reduce((n, s) => !n || o(n, s) || n === "0" ? s : n, 0);
|
|
824
824
|
}, isLoaded = (r) => !!r.loaded || typeof r.lib == "function", isLoading = (r) => !!r.loading;
|
|
825
825
|
function findSingletonVersionOrderByVersion(r, t, o) {
|
|
826
|
-
const n = r[t][o], s = function(
|
|
827
|
-
return !isLoaded(n[
|
|
826
|
+
const n = r[t][o], s = function(i, c) {
|
|
827
|
+
return !isLoaded(n[i]) && versionLt(i, c);
|
|
828
828
|
};
|
|
829
829
|
return findVersion(r[t][o], s);
|
|
830
830
|
}
|
|
831
831
|
function findSingletonVersionOrderByLoaded(r, t, o) {
|
|
832
|
-
const n = r[t][o], s = function(
|
|
833
|
-
const
|
|
834
|
-
return
|
|
832
|
+
const n = r[t][o], s = function(i, c) {
|
|
833
|
+
const a = (l) => isLoaded(l) || isLoading(l);
|
|
834
|
+
return a(n[c]) ? a(n[i]) ? !!versionLt(i, c) : !0 : a(n[i]) ? !1 : versionLt(i, c);
|
|
835
835
|
};
|
|
836
836
|
return findVersion(r[t][o], s);
|
|
837
837
|
}
|
|
@@ -841,32 +841,32 @@ function getFindShareFunction(r) {
|
|
|
841
841
|
function getRegisteredShare(r, t, o, n) {
|
|
842
842
|
if (!r)
|
|
843
843
|
return;
|
|
844
|
-
const { shareConfig: s, scope:
|
|
845
|
-
for (const l of
|
|
844
|
+
const { shareConfig: s, scope: i = DEFAULT_SCOPE, strategy: c } = o, a = Array.isArray(i) ? i : [i];
|
|
845
|
+
for (const l of a)
|
|
846
846
|
if (s && r[l] && r[l][t]) {
|
|
847
|
-
const { requiredVersion: u } = s,
|
|
847
|
+
const { requiredVersion: u } = s, y = getFindShareFunction(c)(r, l, t), p = () => {
|
|
848
848
|
if (s.singleton) {
|
|
849
|
-
if (typeof u == "string" && !satisfy(
|
|
850
|
-
const
|
|
851
|
-
s.strictVersion ? error(
|
|
849
|
+
if (typeof u == "string" && !satisfy(y, u)) {
|
|
850
|
+
const _ = `Version ${y} from ${y && r[l][t][y].from} of shared singleton module ${t} does not satisfy the requirement of ${o.from} which needs ${u})`;
|
|
851
|
+
s.strictVersion ? error(_) : warn(_);
|
|
852
852
|
}
|
|
853
|
-
return r[l][t][
|
|
853
|
+
return r[l][t][y];
|
|
854
854
|
} else {
|
|
855
|
-
if (u === !1 || u === "*" || satisfy(
|
|
856
|
-
return r[l][t][
|
|
857
|
-
for (const [
|
|
858
|
-
if (satisfy(
|
|
855
|
+
if (u === !1 || u === "*" || satisfy(y, u))
|
|
856
|
+
return r[l][t][y];
|
|
857
|
+
for (const [_, E] of Object.entries(r[l][t]))
|
|
858
|
+
if (satisfy(_, u))
|
|
859
859
|
return E;
|
|
860
860
|
}
|
|
861
|
-
},
|
|
861
|
+
}, m = {
|
|
862
862
|
shareScopeMap: r,
|
|
863
863
|
scope: l,
|
|
864
864
|
pkgName: t,
|
|
865
|
-
version:
|
|
865
|
+
version: y,
|
|
866
866
|
GlobalFederation: Global.__FEDERATION__,
|
|
867
|
-
resolver:
|
|
867
|
+
resolver: p
|
|
868
868
|
};
|
|
869
|
-
return (n.emit(
|
|
869
|
+
return (n.emit(m) || m).resolver();
|
|
870
870
|
}
|
|
871
871
|
}
|
|
872
872
|
function getGlobalShareScope() {
|
|
@@ -876,16 +876,16 @@ function getTargetSharedOptions(r) {
|
|
|
876
876
|
const { pkgName: t, extraOptions: o, shareInfos: n } = r, s = (c) => {
|
|
877
877
|
if (!c)
|
|
878
878
|
return;
|
|
879
|
-
const
|
|
880
|
-
c.forEach((
|
|
881
|
-
|
|
879
|
+
const a = {};
|
|
880
|
+
c.forEach((d) => {
|
|
881
|
+
a[d.version] = d;
|
|
882
882
|
});
|
|
883
|
-
const u = findVersion(
|
|
884
|
-
return !isLoaded(
|
|
883
|
+
const u = findVersion(a, function(d, y) {
|
|
884
|
+
return !isLoaded(a[d]) && versionLt(d, y);
|
|
885
885
|
});
|
|
886
|
-
return
|
|
887
|
-
},
|
|
888
|
-
return Object.assign({},
|
|
886
|
+
return a[u];
|
|
887
|
+
}, i = (o == null ? void 0 : o.resolver) ?? s;
|
|
888
|
+
return Object.assign({}, i(n[t]), o == null ? void 0 : o.customShareInfo);
|
|
889
889
|
}
|
|
890
890
|
function getBuilderId() {
|
|
891
891
|
return typeof FEDERATION_BUILD_IDENTIFIER < "u" ? (
|
|
@@ -899,9 +899,9 @@ function matchRemoteWithNameAndExpose(r, t) {
|
|
|
899
899
|
let s = t.replace(o.name, "");
|
|
900
900
|
if (n) {
|
|
901
901
|
if (s.startsWith("/")) {
|
|
902
|
-
const
|
|
902
|
+
const a = o.name;
|
|
903
903
|
return s = `.${s}`, {
|
|
904
|
-
pkgNameOrAlias:
|
|
904
|
+
pkgNameOrAlias: a,
|
|
905
905
|
expose: s,
|
|
906
906
|
remote: o
|
|
907
907
|
};
|
|
@@ -912,13 +912,13 @@ function matchRemoteWithNameAndExpose(r, t) {
|
|
|
912
912
|
remote: o
|
|
913
913
|
};
|
|
914
914
|
}
|
|
915
|
-
const
|
|
915
|
+
const i = o.alias && t.startsWith(o.alias);
|
|
916
916
|
let c = o.alias && t.replace(o.alias, "");
|
|
917
|
-
if (o.alias &&
|
|
917
|
+
if (o.alias && i) {
|
|
918
918
|
if (c && c.startsWith("/")) {
|
|
919
|
-
const
|
|
919
|
+
const a = o.alias;
|
|
920
920
|
return c = `.${c}`, {
|
|
921
|
-
pkgNameOrAlias:
|
|
921
|
+
pkgNameOrAlias: a,
|
|
922
922
|
expose: c,
|
|
923
923
|
remote: o
|
|
924
924
|
};
|
|
@@ -946,10 +946,10 @@ function registerPlugins(r, t) {
|
|
|
946
946
|
t.bridgeHook
|
|
947
947
|
];
|
|
948
948
|
return o.length > 0 && o.forEach((s) => {
|
|
949
|
-
r != null && r.find((
|
|
949
|
+
r != null && r.find((i) => i.name !== s.name) && r.push(s);
|
|
950
950
|
}), r && r.length > 0 && r.forEach((s) => {
|
|
951
|
-
n.forEach((
|
|
952
|
-
|
|
951
|
+
n.forEach((i) => {
|
|
952
|
+
i.applyPlugin(s, t);
|
|
953
953
|
});
|
|
954
954
|
}), r;
|
|
955
955
|
}
|
|
@@ -988,27 +988,27 @@ function handleRemoteEntryLoaded(r, t, o) {
|
|
|
988
988
|
})), s;
|
|
989
989
|
}
|
|
990
990
|
async function loadEntryScript({ name: r, globalName: t, entry: o, loaderHook: n, getEntryUrl: s }) {
|
|
991
|
-
const { entryExports:
|
|
992
|
-
if (
|
|
993
|
-
return
|
|
991
|
+
const { entryExports: i } = getRemoteEntryExports(r, t);
|
|
992
|
+
if (i)
|
|
993
|
+
return i;
|
|
994
994
|
const c = s ? s(o) : o;
|
|
995
995
|
return loadScript(c, {
|
|
996
996
|
attrs: {},
|
|
997
|
-
createScriptHook: (
|
|
998
|
-
const u = n.lifecycle.createScript.emit({ url:
|
|
997
|
+
createScriptHook: (a, l) => {
|
|
998
|
+
const u = n.lifecycle.createScript.emit({ url: a, attrs: l });
|
|
999
999
|
if (u && (u instanceof HTMLScriptElement || "script" in u || "timeout" in u))
|
|
1000
1000
|
return u;
|
|
1001
1001
|
}
|
|
1002
|
-
}).then(() => handleRemoteEntryLoaded(r, t, o)).catch((
|
|
1002
|
+
}).then(() => handleRemoteEntryLoaded(r, t, o)).catch((a) => {
|
|
1003
1003
|
throw assert(void 0, getShortErrorMsg(RUNTIME_008, runtimeDescMap, {
|
|
1004
1004
|
remoteName: r,
|
|
1005
1005
|
resourceUrl: o
|
|
1006
|
-
})),
|
|
1006
|
+
})), a;
|
|
1007
1007
|
});
|
|
1008
1008
|
}
|
|
1009
1009
|
async function loadEntryDom({ remoteInfo: r, remoteEntryExports: t, loaderHook: o, getEntryUrl: n }) {
|
|
1010
|
-
const { entry: s, entryGlobalName:
|
|
1011
|
-
switch (
|
|
1010
|
+
const { entry: s, entryGlobalName: i, name: c, type: a } = r;
|
|
1011
|
+
switch (a) {
|
|
1012
1012
|
case "esm":
|
|
1013
1013
|
case "module":
|
|
1014
1014
|
return loadEsmEntry({ entry: s, remoteEntryExports: t });
|
|
@@ -1017,7 +1017,7 @@ async function loadEntryDom({ remoteInfo: r, remoteEntryExports: t, loaderHook:
|
|
|
1017
1017
|
default:
|
|
1018
1018
|
return loadEntryScript({
|
|
1019
1019
|
entry: s,
|
|
1020
|
-
globalName:
|
|
1020
|
+
globalName: i,
|
|
1021
1021
|
name: c,
|
|
1022
1022
|
loaderHook: o,
|
|
1023
1023
|
getEntryUrl: n
|
|
@@ -1025,18 +1025,18 @@ async function loadEntryDom({ remoteInfo: r, remoteEntryExports: t, loaderHook:
|
|
|
1025
1025
|
}
|
|
1026
1026
|
}
|
|
1027
1027
|
async function loadEntryNode({ remoteInfo: r, loaderHook: t }) {
|
|
1028
|
-
const { entry: o, entryGlobalName: n, name: s, type:
|
|
1028
|
+
const { entry: o, entryGlobalName: n, name: s, type: i } = r, { entryExports: c } = getRemoteEntryExports(s, n);
|
|
1029
1029
|
return c || loadScriptNode(o, {
|
|
1030
|
-
attrs: { name: s, globalName: n, type:
|
|
1030
|
+
attrs: { name: s, globalName: n, type: i },
|
|
1031
1031
|
loaderHook: {
|
|
1032
|
-
createScriptHook: (
|
|
1033
|
-
const u = t.lifecycle.createScript.emit({ url:
|
|
1032
|
+
createScriptHook: (a, l = {}) => {
|
|
1033
|
+
const u = t.lifecycle.createScript.emit({ url: a, attrs: l });
|
|
1034
1034
|
if (u && "url" in u)
|
|
1035
1035
|
return u;
|
|
1036
1036
|
}
|
|
1037
1037
|
}
|
|
1038
|
-
}).then(() => handleRemoteEntryLoaded(s, n, o)).catch((
|
|
1039
|
-
throw
|
|
1038
|
+
}).then(() => handleRemoteEntryLoaded(s, n, o)).catch((a) => {
|
|
1039
|
+
throw a;
|
|
1040
1040
|
});
|
|
1041
1041
|
}
|
|
1042
1042
|
function getRemoteEntryUniqueKey(r) {
|
|
@@ -1044,12 +1044,12 @@ function getRemoteEntryUniqueKey(r) {
|
|
|
1044
1044
|
return composeKeyWithSeparator(o, t);
|
|
1045
1045
|
}
|
|
1046
1046
|
async function getRemoteEntry(r) {
|
|
1047
|
-
const { origin: t, remoteEntryExports: o, remoteInfo: n, getEntryUrl: s, _inErrorHandling:
|
|
1047
|
+
const { origin: t, remoteEntryExports: o, remoteInfo: n, getEntryUrl: s, _inErrorHandling: i = !1 } = r, c = getRemoteEntryUniqueKey(n);
|
|
1048
1048
|
if (o)
|
|
1049
1049
|
return o;
|
|
1050
1050
|
if (!globalLoading[c]) {
|
|
1051
|
-
const
|
|
1052
|
-
globalLoading[c] =
|
|
1051
|
+
const a = t.remoteHandler.hooks.lifecycle.loadEntry, l = t.loaderHook;
|
|
1052
|
+
globalLoading[c] = a.emit({
|
|
1053
1053
|
loaderHook: l,
|
|
1054
1054
|
remoteInfo: n,
|
|
1055
1055
|
remoteEntryExports: o
|
|
@@ -1059,18 +1059,18 @@ async function getRemoteEntry(r) {
|
|
|
1059
1059
|
loaderHook: l,
|
|
1060
1060
|
getEntryUrl: s
|
|
1061
1061
|
}) : loadEntryNode({ remoteInfo: n, loaderHook: l }))).catch(async (u) => {
|
|
1062
|
-
const
|
|
1063
|
-
if (u instanceof Error && u.message.includes(RUNTIME_008) && !
|
|
1064
|
-
const
|
|
1065
|
-
getRemoteEntry:
|
|
1062
|
+
const d = getRemoteEntryUniqueKey(n);
|
|
1063
|
+
if (u instanceof Error && u.message.includes(RUNTIME_008) && !i) {
|
|
1064
|
+
const p = (g) => getRemoteEntry({ ...g, _inErrorHandling: !0 }), m = await t.loaderHook.lifecycle.loadEntryError.emit({
|
|
1065
|
+
getRemoteEntry: p,
|
|
1066
1066
|
origin: t,
|
|
1067
1067
|
remoteInfo: n,
|
|
1068
1068
|
remoteEntryExports: o,
|
|
1069
1069
|
globalLoading,
|
|
1070
|
-
uniqueKey:
|
|
1070
|
+
uniqueKey: d
|
|
1071
1071
|
});
|
|
1072
|
-
if (
|
|
1073
|
-
return
|
|
1072
|
+
if (m)
|
|
1073
|
+
return m;
|
|
1074
1074
|
}
|
|
1075
1075
|
throw u;
|
|
1076
1076
|
});
|
|
@@ -1111,10 +1111,10 @@ function normalizePreloadExposes(r) {
|
|
|
1111
1111
|
return r ? r.map((t) => t === "." ? t : t.startsWith("./") ? t.replace("./", "") : t) : [];
|
|
1112
1112
|
}
|
|
1113
1113
|
function preloadAssets(r, t, o, n = !0) {
|
|
1114
|
-
const { cssAssets: s, jsAssetsWithoutEntry:
|
|
1114
|
+
const { cssAssets: s, jsAssetsWithoutEntry: i, entryAssets: c } = o;
|
|
1115
1115
|
if (t.options.inBrowser) {
|
|
1116
|
-
if (c.forEach((
|
|
1117
|
-
const { moduleInfo: l } =
|
|
1116
|
+
if (c.forEach((a) => {
|
|
1117
|
+
const { moduleInfo: l } = a, u = t.moduleCache.get(r.name);
|
|
1118
1118
|
getRemoteEntry(u ? {
|
|
1119
1119
|
origin: t,
|
|
1120
1120
|
remoteInfo: l,
|
|
@@ -1125,95 +1125,95 @@ function preloadAssets(r, t, o, n = !0) {
|
|
|
1125
1125
|
remoteEntryExports: void 0
|
|
1126
1126
|
});
|
|
1127
1127
|
}), n) {
|
|
1128
|
-
const
|
|
1128
|
+
const a = {
|
|
1129
1129
|
rel: "preload",
|
|
1130
1130
|
as: "style"
|
|
1131
1131
|
};
|
|
1132
1132
|
s.forEach((l) => {
|
|
1133
|
-
const { link: u, needAttach:
|
|
1133
|
+
const { link: u, needAttach: d } = createLink({
|
|
1134
1134
|
url: l,
|
|
1135
1135
|
cb: () => {
|
|
1136
1136
|
},
|
|
1137
|
-
attrs:
|
|
1138
|
-
createLinkHook: (
|
|
1139
|
-
const
|
|
1140
|
-
url:
|
|
1141
|
-
attrs:
|
|
1137
|
+
attrs: a,
|
|
1138
|
+
createLinkHook: (y, p) => {
|
|
1139
|
+
const m = t.loaderHook.lifecycle.createLink.emit({
|
|
1140
|
+
url: y,
|
|
1141
|
+
attrs: p
|
|
1142
1142
|
});
|
|
1143
|
-
if (
|
|
1144
|
-
return
|
|
1143
|
+
if (m instanceof HTMLLinkElement)
|
|
1144
|
+
return m;
|
|
1145
1145
|
}
|
|
1146
1146
|
});
|
|
1147
|
-
|
|
1147
|
+
d && document.head.appendChild(u);
|
|
1148
1148
|
});
|
|
1149
1149
|
} else {
|
|
1150
|
-
const
|
|
1150
|
+
const a = {
|
|
1151
1151
|
rel: "stylesheet",
|
|
1152
1152
|
type: "text/css"
|
|
1153
1153
|
};
|
|
1154
1154
|
s.forEach((l) => {
|
|
1155
|
-
const { link: u, needAttach:
|
|
1155
|
+
const { link: u, needAttach: d } = createLink({
|
|
1156
1156
|
url: l,
|
|
1157
1157
|
cb: () => {
|
|
1158
1158
|
},
|
|
1159
|
-
attrs:
|
|
1160
|
-
createLinkHook: (
|
|
1161
|
-
const
|
|
1162
|
-
url:
|
|
1163
|
-
attrs:
|
|
1159
|
+
attrs: a,
|
|
1160
|
+
createLinkHook: (y, p) => {
|
|
1161
|
+
const m = t.loaderHook.lifecycle.createLink.emit({
|
|
1162
|
+
url: y,
|
|
1163
|
+
attrs: p
|
|
1164
1164
|
});
|
|
1165
|
-
if (
|
|
1166
|
-
return
|
|
1165
|
+
if (m instanceof HTMLLinkElement)
|
|
1166
|
+
return m;
|
|
1167
1167
|
},
|
|
1168
1168
|
needDeleteLink: !1
|
|
1169
1169
|
});
|
|
1170
|
-
|
|
1170
|
+
d && document.head.appendChild(u);
|
|
1171
1171
|
});
|
|
1172
1172
|
}
|
|
1173
1173
|
if (n) {
|
|
1174
|
-
const
|
|
1174
|
+
const a = {
|
|
1175
1175
|
rel: "preload",
|
|
1176
1176
|
as: "script"
|
|
1177
1177
|
};
|
|
1178
|
-
|
|
1179
|
-
const { link: u, needAttach:
|
|
1178
|
+
i.forEach((l) => {
|
|
1179
|
+
const { link: u, needAttach: d } = createLink({
|
|
1180
1180
|
url: l,
|
|
1181
1181
|
cb: () => {
|
|
1182
1182
|
},
|
|
1183
|
-
attrs:
|
|
1184
|
-
createLinkHook: (
|
|
1185
|
-
const
|
|
1186
|
-
url:
|
|
1187
|
-
attrs:
|
|
1183
|
+
attrs: a,
|
|
1184
|
+
createLinkHook: (y, p) => {
|
|
1185
|
+
const m = t.loaderHook.lifecycle.createLink.emit({
|
|
1186
|
+
url: y,
|
|
1187
|
+
attrs: p
|
|
1188
1188
|
});
|
|
1189
|
-
if (
|
|
1190
|
-
return
|
|
1189
|
+
if (m instanceof HTMLLinkElement)
|
|
1190
|
+
return m;
|
|
1191
1191
|
}
|
|
1192
1192
|
});
|
|
1193
|
-
|
|
1193
|
+
d && document.head.appendChild(u);
|
|
1194
1194
|
});
|
|
1195
1195
|
} else {
|
|
1196
|
-
const
|
|
1196
|
+
const a = {
|
|
1197
1197
|
fetchpriority: "high",
|
|
1198
1198
|
type: (r == null ? void 0 : r.type) === "module" ? "module" : "text/javascript"
|
|
1199
1199
|
};
|
|
1200
|
-
|
|
1201
|
-
const { script: u, needAttach:
|
|
1200
|
+
i.forEach((l) => {
|
|
1201
|
+
const { script: u, needAttach: d } = createScript({
|
|
1202
1202
|
url: l,
|
|
1203
1203
|
cb: () => {
|
|
1204
1204
|
},
|
|
1205
|
-
attrs:
|
|
1206
|
-
createScriptHook: (
|
|
1207
|
-
const
|
|
1208
|
-
url:
|
|
1209
|
-
attrs:
|
|
1205
|
+
attrs: a,
|
|
1206
|
+
createScriptHook: (y, p) => {
|
|
1207
|
+
const m = t.loaderHook.lifecycle.createScript.emit({
|
|
1208
|
+
url: y,
|
|
1209
|
+
attrs: p
|
|
1210
1210
|
});
|
|
1211
|
-
if (
|
|
1212
|
-
return
|
|
1211
|
+
if (m instanceof HTMLScriptElement)
|
|
1212
|
+
return m;
|
|
1213
1213
|
},
|
|
1214
1214
|
needDeleteScript: !0
|
|
1215
1215
|
});
|
|
1216
|
-
|
|
1216
|
+
d && document.head.appendChild(u);
|
|
1217
1217
|
});
|
|
1218
1218
|
}
|
|
1219
1219
|
}
|
|
@@ -1225,65 +1225,70 @@ class Module {
|
|
|
1225
1225
|
async getEntry() {
|
|
1226
1226
|
if (this.remoteEntryExports)
|
|
1227
1227
|
return this.remoteEntryExports;
|
|
1228
|
-
|
|
1229
|
-
return t = await getRemoteEntry({
|
|
1228
|
+
const t = await getRemoteEntry({
|
|
1230
1229
|
origin: this.host,
|
|
1231
1230
|
remoteInfo: this.remoteInfo,
|
|
1232
1231
|
remoteEntryExports: this.remoteEntryExports
|
|
1233
|
-
})
|
|
1232
|
+
});
|
|
1233
|
+
return assert(t, `remoteEntryExports is undefined
|
|
1234
1234
|
${safeToString(this.remoteInfo)}`), this.remoteEntryExports = t, this.remoteEntryExports;
|
|
1235
1235
|
}
|
|
1236
1236
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1237
|
-
async
|
|
1238
|
-
const
|
|
1237
|
+
async init(t, o) {
|
|
1238
|
+
const n = await this.getEntry();
|
|
1239
1239
|
if (!this.inited) {
|
|
1240
|
-
const
|
|
1241
|
-
|
|
1242
|
-
|
|
1240
|
+
const s = this.host.shareScopeMap, i = Array.isArray(this.remoteInfo.shareScope) ? this.remoteInfo.shareScope : [this.remoteInfo.shareScope];
|
|
1241
|
+
i.length || i.push("default"), i.forEach((d) => {
|
|
1242
|
+
s[d] || (s[d] = {});
|
|
1243
1243
|
});
|
|
1244
|
-
const
|
|
1244
|
+
const c = s[i[0]], a = [], l = {
|
|
1245
1245
|
version: this.remoteInfo.version || "",
|
|
1246
|
-
shareScopeKeys: Array.isArray(this.remoteInfo.shareScope) ?
|
|
1246
|
+
shareScopeKeys: Array.isArray(this.remoteInfo.shareScope) ? i : this.remoteInfo.shareScope || "default"
|
|
1247
1247
|
};
|
|
1248
|
-
Object.defineProperty(
|
|
1249
|
-
value:
|
|
1248
|
+
Object.defineProperty(l, "shareScopeMap", {
|
|
1249
|
+
value: s,
|
|
1250
1250
|
// remoteEntryInitOptions will be traversed and assigned during container init, ,so this attribute is not allowed to be traversed
|
|
1251
1251
|
enumerable: !1
|
|
1252
1252
|
});
|
|
1253
|
-
const
|
|
1254
|
-
shareScope:
|
|
1253
|
+
const u = await this.host.hooks.lifecycle.beforeInitContainer.emit({
|
|
1254
|
+
shareScope: c,
|
|
1255
1255
|
// @ts-ignore shareScopeMap will be set by Object.defineProperty
|
|
1256
|
-
remoteEntryInitOptions:
|
|
1257
|
-
initScope:
|
|
1256
|
+
remoteEntryInitOptions: l,
|
|
1257
|
+
initScope: a,
|
|
1258
1258
|
remoteInfo: this.remoteInfo,
|
|
1259
1259
|
origin: this.host
|
|
1260
1260
|
});
|
|
1261
|
-
typeof (
|
|
1261
|
+
typeof (n == null ? void 0 : n.init) > "u" && error(getShortErrorMsg(RUNTIME_002, runtimeDescMap, {
|
|
1262
1262
|
hostName: this.host.name,
|
|
1263
1263
|
remoteName: this.remoteInfo.name,
|
|
1264
1264
|
remoteEntryUrl: this.remoteInfo.entry,
|
|
1265
1265
|
remoteEntryKey: this.remoteInfo.entryGlobalName
|
|
1266
|
-
})), await
|
|
1267
|
-
...
|
|
1266
|
+
})), await n.init(u.shareScope, u.initScope, u.remoteEntryInitOptions), await this.host.hooks.lifecycle.initContainer.emit({
|
|
1267
|
+
...u,
|
|
1268
1268
|
id: t,
|
|
1269
|
-
remoteSnapshot:
|
|
1270
|
-
remoteEntryExports:
|
|
1269
|
+
remoteSnapshot: o,
|
|
1270
|
+
remoteEntryExports: n
|
|
1271
1271
|
});
|
|
1272
1272
|
}
|
|
1273
|
+
return n;
|
|
1274
|
+
}
|
|
1275
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1276
|
+
async get(t, o, n, s) {
|
|
1277
|
+
const { loadFactory: i = !0 } = n || { loadFactory: !0 }, c = await this.init(t, s);
|
|
1273
1278
|
this.lib = c, this.inited = !0;
|
|
1274
|
-
let
|
|
1275
|
-
|
|
1279
|
+
let a;
|
|
1280
|
+
a = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
|
|
1276
1281
|
remoteEntryExports: c,
|
|
1277
1282
|
expose: o,
|
|
1278
1283
|
moduleInfo: this.remoteInfo
|
|
1279
|
-
}),
|
|
1280
|
-
const l = processModuleAlias(this.remoteInfo.name, o), u = this.wraperFactory(
|
|
1281
|
-
return
|
|
1284
|
+
}), a || (a = await c.get(o)), assert(a, `${getFMId(this.remoteInfo)} remote don't export ${o}.`);
|
|
1285
|
+
const l = processModuleAlias(this.remoteInfo.name, o), u = this.wraperFactory(a, l);
|
|
1286
|
+
return i ? await u() : u;
|
|
1282
1287
|
}
|
|
1283
1288
|
wraperFactory(t, o) {
|
|
1284
|
-
function n(s,
|
|
1289
|
+
function n(s, i) {
|
|
1285
1290
|
s && typeof s == "object" && Object.isExtensible(s) && !Object.getOwnPropertyDescriptor(s, Symbol.for("mf_module_id")) && Object.defineProperty(s, Symbol.for("mf_module_id"), {
|
|
1286
|
-
value:
|
|
1291
|
+
value: i,
|
|
1287
1292
|
enumerable: !1
|
|
1288
1293
|
});
|
|
1289
1294
|
}
|
|
@@ -1328,8 +1333,8 @@ class AsyncHook extends SyncHook {
|
|
|
1328
1333
|
const n = Array.from(this.listeners);
|
|
1329
1334
|
if (n.length > 0) {
|
|
1330
1335
|
let s = 0;
|
|
1331
|
-
const
|
|
1332
|
-
o =
|
|
1336
|
+
const i = (c) => c === !1 ? !1 : s < n.length ? Promise.resolve(n[s++].apply(null, t)).then(i) : c;
|
|
1337
|
+
o = i();
|
|
1333
1338
|
}
|
|
1334
1339
|
return Promise.resolve(o);
|
|
1335
1340
|
}
|
|
@@ -1374,19 +1379,19 @@ class AsyncWaterfallHook extends SyncHook {
|
|
|
1374
1379
|
const o = Array.from(this.listeners);
|
|
1375
1380
|
if (o.length > 0) {
|
|
1376
1381
|
let n = 0;
|
|
1377
|
-
const s = (c) => (warn(c), this.onerror(c), t),
|
|
1382
|
+
const s = (c) => (warn(c), this.onerror(c), t), i = (c) => {
|
|
1378
1383
|
if (checkReturnData(t, c)) {
|
|
1379
1384
|
if (t = c, n < o.length)
|
|
1380
1385
|
try {
|
|
1381
|
-
return Promise.resolve(o[n++](t)).then(
|
|
1382
|
-
} catch (
|
|
1383
|
-
return s(
|
|
1386
|
+
return Promise.resolve(o[n++](t)).then(i, s);
|
|
1387
|
+
} catch (a) {
|
|
1388
|
+
return s(a);
|
|
1384
1389
|
}
|
|
1385
1390
|
} else
|
|
1386
1391
|
this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
|
|
1387
1392
|
return t;
|
|
1388
1393
|
};
|
|
1389
|
-
return Promise.resolve(
|
|
1394
|
+
return Promise.resolve(i(t));
|
|
1390
1395
|
}
|
|
1391
1396
|
return Promise.resolve(t);
|
|
1392
1397
|
}
|
|
@@ -1399,9 +1404,9 @@ class PluginSystem {
|
|
|
1399
1404
|
var s;
|
|
1400
1405
|
assert(isPlainObject(t), "Plugin configuration is invalid.");
|
|
1401
1406
|
const n = t.name;
|
|
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((
|
|
1403
|
-
const c = t[
|
|
1404
|
-
c && this.lifecycle[
|
|
1407
|
+
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((i) => {
|
|
1408
|
+
const c = t[i];
|
|
1409
|
+
c && this.lifecycle[i].on(c);
|
|
1405
1410
|
}));
|
|
1406
1411
|
}
|
|
1407
1412
|
removePlugin(t) {
|
|
@@ -1422,13 +1427,13 @@ function snapshotPlugin() {
|
|
|
1422
1427
|
return {
|
|
1423
1428
|
name: "snapshot-plugin",
|
|
1424
1429
|
async afterResolve(r) {
|
|
1425
|
-
const { remote: t, pkgNameOrAlias: o, expose: n, origin: s, remoteInfo:
|
|
1430
|
+
const { remote: t, pkgNameOrAlias: o, expose: n, origin: s, remoteInfo: i, id: c } = r;
|
|
1426
1431
|
if (!isRemoteInfoWithEntry(t) || !isPureRemoteEntry(t)) {
|
|
1427
|
-
const { remoteSnapshot:
|
|
1432
|
+
const { remoteSnapshot: a, globalSnapshot: l } = await s.snapshotHandler.loadRemoteSnapshotInfo({
|
|
1428
1433
|
moduleInfo: t,
|
|
1429
1434
|
id: c
|
|
1430
1435
|
});
|
|
1431
|
-
assignRemoteInfo(
|
|
1436
|
+
assignRemoteInfo(i, a);
|
|
1432
1437
|
const u = {
|
|
1433
1438
|
remote: t,
|
|
1434
1439
|
preloadConfig: {
|
|
@@ -1438,17 +1443,17 @@ function snapshotPlugin() {
|
|
|
1438
1443
|
share: !1,
|
|
1439
1444
|
depsRemote: !1
|
|
1440
1445
|
}
|
|
1441
|
-
},
|
|
1446
|
+
}, d = await s.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({
|
|
1442
1447
|
origin: s,
|
|
1443
1448
|
preloadOptions: u,
|
|
1444
|
-
remoteInfo:
|
|
1449
|
+
remoteInfo: i,
|
|
1445
1450
|
remote: t,
|
|
1446
|
-
remoteSnapshot:
|
|
1451
|
+
remoteSnapshot: a,
|
|
1447
1452
|
globalSnapshot: l
|
|
1448
1453
|
});
|
|
1449
|
-
return
|
|
1454
|
+
return d && preloadAssets(i, s, d, !1), {
|
|
1450
1455
|
...r,
|
|
1451
|
-
remoteSnapshot:
|
|
1456
|
+
remoteSnapshot: a
|
|
1452
1457
|
};
|
|
1453
1458
|
}
|
|
1454
1459
|
return r;
|
|
@@ -1468,107 +1473,107 @@ function splitId(r) {
|
|
|
1468
1473
|
version: t[2]
|
|
1469
1474
|
};
|
|
1470
1475
|
}
|
|
1471
|
-
function traverseModuleInfo(r, t, o, n, s = {},
|
|
1472
|
-
const c = getFMId(t), { value:
|
|
1476
|
+
function traverseModuleInfo(r, t, o, n, s = {}, i) {
|
|
1477
|
+
const c = getFMId(t), { value: a } = getInfoWithoutType(r, c), l = i || a;
|
|
1473
1478
|
if (l && !isManifestProvider(l) && (o(l, t, n), l.remotesInfo)) {
|
|
1474
1479
|
const u = Object.keys(l.remotesInfo);
|
|
1475
|
-
for (const
|
|
1476
|
-
if (s[
|
|
1480
|
+
for (const d of u) {
|
|
1481
|
+
if (s[d])
|
|
1477
1482
|
continue;
|
|
1478
|
-
s[
|
|
1479
|
-
const
|
|
1483
|
+
s[d] = !0;
|
|
1484
|
+
const y = splitId(d), p = l.remotesInfo[d];
|
|
1480
1485
|
traverseModuleInfo(r, {
|
|
1481
|
-
name:
|
|
1482
|
-
version:
|
|
1486
|
+
name: y.name,
|
|
1487
|
+
version: p.matchedVersion
|
|
1483
1488
|
}, o, !1, s, void 0);
|
|
1484
1489
|
}
|
|
1485
1490
|
}
|
|
1486
1491
|
}
|
|
1487
1492
|
const isExisted = (r, t) => document.querySelector(`${r}[${r === "link" ? "href" : "src"}="${t}"]`);
|
|
1488
1493
|
function generatePreloadAssets(r, t, o, n, s) {
|
|
1489
|
-
const
|
|
1490
|
-
if (traverseModuleInfo(n, o, (E,
|
|
1494
|
+
const i = [], c = [], a = [], l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), { options: d } = r, { preloadConfig: y } = t, { depsRemote: p } = y;
|
|
1495
|
+
if (traverseModuleInfo(n, o, (E, b, S) => {
|
|
1491
1496
|
var $;
|
|
1492
|
-
let
|
|
1493
|
-
if (
|
|
1494
|
-
|
|
1495
|
-
else if (Array.isArray(
|
|
1496
|
-
const P =
|
|
1497
|
+
let I;
|
|
1498
|
+
if (S)
|
|
1499
|
+
I = y;
|
|
1500
|
+
else if (Array.isArray(p)) {
|
|
1501
|
+
const P = p.find((N) => N.nameOrAlias === b.name || N.nameOrAlias === b.alias);
|
|
1497
1502
|
if (!P)
|
|
1498
1503
|
return;
|
|
1499
|
-
|
|
1500
|
-
} else if (
|
|
1501
|
-
|
|
1504
|
+
I = defaultPreloadArgs(P);
|
|
1505
|
+
} else if (p === !0)
|
|
1506
|
+
I = y;
|
|
1502
1507
|
else
|
|
1503
1508
|
return;
|
|
1504
1509
|
const A = getResourceUrl(E, getRemoteEntryInfoFromSnapshot(E).url);
|
|
1505
|
-
A &&
|
|
1506
|
-
name:
|
|
1510
|
+
A && a.push({
|
|
1511
|
+
name: b.name,
|
|
1507
1512
|
moduleInfo: {
|
|
1508
|
-
name:
|
|
1513
|
+
name: b.name,
|
|
1509
1514
|
entry: A,
|
|
1510
1515
|
type: "remoteEntryType" in E ? E.remoteEntryType : "global",
|
|
1511
|
-
entryGlobalName: "globalName" in E ? E.globalName :
|
|
1516
|
+
entryGlobalName: "globalName" in E ? E.globalName : b.name,
|
|
1512
1517
|
shareScope: "",
|
|
1513
1518
|
version: "version" in E ? E.version : void 0
|
|
1514
1519
|
},
|
|
1515
1520
|
url: A
|
|
1516
1521
|
});
|
|
1517
|
-
let
|
|
1518
|
-
const T = normalizePreloadExposes(
|
|
1519
|
-
T.length && "modules" in E && (
|
|
1522
|
+
let R = "modules" in E ? E.modules : [];
|
|
1523
|
+
const T = normalizePreloadExposes(I.exposes);
|
|
1524
|
+
T.length && "modules" in E && (R = ($ = 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
1525
|
function w(P) {
|
|
1521
1526
|
const N = P.map((M) => getResourceUrl(E, M));
|
|
1522
|
-
return
|
|
1527
|
+
return I.filter ? N.filter(I.filter) : N;
|
|
1523
1528
|
}
|
|
1524
|
-
if (
|
|
1525
|
-
const P =
|
|
1529
|
+
if (R) {
|
|
1530
|
+
const P = R.length;
|
|
1526
1531
|
for (let N = 0; N < P; N++) {
|
|
1527
|
-
const M =
|
|
1532
|
+
const M = R[N], L = `${b.name}/${M.moduleName}`;
|
|
1528
1533
|
r.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({
|
|
1529
|
-
id: M.moduleName === "." ?
|
|
1530
|
-
name:
|
|
1534
|
+
id: M.moduleName === "." ? b.name : L,
|
|
1535
|
+
name: b.name,
|
|
1531
1536
|
remoteSnapshot: E,
|
|
1532
|
-
preloadConfig:
|
|
1533
|
-
remote:
|
|
1537
|
+
preloadConfig: I,
|
|
1538
|
+
remote: b,
|
|
1534
1539
|
origin: r
|
|
1535
|
-
}), !getPreloaded(L) && (
|
|
1540
|
+
}), !getPreloaded(L) && (I.resourceCategory === "all" ? (i.push(...w(M.assets.css.async)), i.push(...w(M.assets.css.sync)), c.push(...w(M.assets.js.async)), c.push(...w(M.assets.js.sync))) : (I.resourceCategory = "sync") && (i.push(...w(M.assets.css.sync)), c.push(...w(M.assets.js.sync))), setPreloaded(L));
|
|
1536
1541
|
}
|
|
1537
1542
|
}
|
|
1538
1543
|
}, !0, {}, s), s.shared && s.shared.length > 0) {
|
|
1539
|
-
const E = (
|
|
1540
|
-
const
|
|
1541
|
-
|
|
1544
|
+
const E = (b, S) => {
|
|
1545
|
+
const I = getRegisteredShare(r.shareScopeMap, S.sharedName, b, r.sharedHandler.hooks.lifecycle.resolveShare);
|
|
1546
|
+
I && typeof I.lib == "function" && (S.assets.js.sync.forEach((A) => {
|
|
1542
1547
|
l.add(A);
|
|
1543
|
-
}),
|
|
1548
|
+
}), S.assets.css.sync.forEach((A) => {
|
|
1544
1549
|
u.add(A);
|
|
1545
1550
|
}));
|
|
1546
1551
|
};
|
|
1547
|
-
s.shared.forEach((
|
|
1548
|
-
var
|
|
1549
|
-
const
|
|
1550
|
-
if (!I)
|
|
1551
|
-
return;
|
|
1552
|
-
const S = R.version ? I.find((T) => T.version === R.version) : I;
|
|
1552
|
+
s.shared.forEach((b) => {
|
|
1553
|
+
var R;
|
|
1554
|
+
const S = (R = d.shared) == null ? void 0 : R[b.sharedName];
|
|
1553
1555
|
if (!S)
|
|
1554
1556
|
return;
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
+
const I = b.version ? S.find((T) => T.version === b.version) : S;
|
|
1558
|
+
if (!I)
|
|
1559
|
+
return;
|
|
1560
|
+
arrayOptions(I).forEach((T) => {
|
|
1561
|
+
E(T, b);
|
|
1557
1562
|
});
|
|
1558
1563
|
});
|
|
1559
1564
|
}
|
|
1560
1565
|
const g = c.filter((E) => !l.has(E) && !isExisted("script", E));
|
|
1561
1566
|
return {
|
|
1562
|
-
cssAssets:
|
|
1567
|
+
cssAssets: i.filter((E) => !u.has(E) && !isExisted("link", E)),
|
|
1563
1568
|
jsAssetsWithoutEntry: g,
|
|
1564
|
-
entryAssets:
|
|
1569
|
+
entryAssets: a.filter((E) => !isExisted("script", E.url))
|
|
1565
1570
|
};
|
|
1566
1571
|
}
|
|
1567
1572
|
const generatePreloadAssetsPlugin = function() {
|
|
1568
1573
|
return {
|
|
1569
1574
|
name: "generate-preload-assets-plugin",
|
|
1570
1575
|
async generatePreloadAssets(r) {
|
|
1571
|
-
const { origin: t, preloadOptions: o, remoteInfo: n, remote: s, globalSnapshot:
|
|
1576
|
+
const { origin: t, preloadOptions: o, remoteInfo: n, remote: s, globalSnapshot: i, remoteSnapshot: c } = r;
|
|
1572
1577
|
return isBrowserEnv() ? isRemoteInfoWithEntry(s) && isPureRemoteEntry(s) ? {
|
|
1573
1578
|
cssAssets: [],
|
|
1574
1579
|
jsAssetsWithoutEntry: [],
|
|
@@ -1585,7 +1590,7 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1585
1590
|
}
|
|
1586
1591
|
}
|
|
1587
1592
|
]
|
|
1588
|
-
} : (assignRemoteInfo(n, c), generatePreloadAssets(t, o, n,
|
|
1593
|
+
} : (assignRemoteInfo(n, c), generatePreloadAssets(t, o, n, i, c)) : {
|
|
1589
1594
|
cssAssets: [],
|
|
1590
1595
|
jsAssetsWithoutEntry: [],
|
|
1591
1596
|
entryAssets: []
|
|
@@ -1630,71 +1635,71 @@ class SnapshotHandler {
|
|
|
1630
1635
|
options: s,
|
|
1631
1636
|
moduleInfo: t
|
|
1632
1637
|
});
|
|
1633
|
-
let
|
|
1638
|
+
let i = getGlobalSnapshotInfoByModuleInfo({
|
|
1634
1639
|
name: this.HostInstance.options.name,
|
|
1635
1640
|
version: this.HostInstance.options.version
|
|
1636
1641
|
});
|
|
1637
|
-
|
|
1642
|
+
i || (i = {
|
|
1638
1643
|
version: this.HostInstance.options.version || "",
|
|
1639
1644
|
remoteEntry: "",
|
|
1640
1645
|
remotesInfo: {}
|
|
1641
1646
|
}, addGlobalSnapshot({
|
|
1642
|
-
[this.HostInstance.options.name]:
|
|
1643
|
-
})),
|
|
1644
|
-
...
|
|
1647
|
+
[this.HostInstance.options.name]: i
|
|
1648
|
+
})), i && "remotesInfo" in i && !getInfoWithoutType(i.remotesInfo, t.name).value && ("version" in t || "entry" in t) && (i.remotesInfo = {
|
|
1649
|
+
...i == null ? void 0 : i.remotesInfo,
|
|
1645
1650
|
[t.name]: {
|
|
1646
1651
|
matchedVersion: "version" in t ? t.version : t.entry
|
|
1647
1652
|
}
|
|
1648
1653
|
});
|
|
1649
|
-
const { hostGlobalSnapshot: c, remoteSnapshot:
|
|
1654
|
+
const { hostGlobalSnapshot: c, remoteSnapshot: a, globalSnapshot: l } = this.getGlobalRemoteInfo(t), { remoteSnapshot: u, globalSnapshot: d } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1650
1655
|
options: s,
|
|
1651
1656
|
moduleInfo: t,
|
|
1652
1657
|
hostGlobalSnapshot: c,
|
|
1653
|
-
remoteSnapshot:
|
|
1658
|
+
remoteSnapshot: a,
|
|
1654
1659
|
globalSnapshot: l
|
|
1655
1660
|
});
|
|
1656
|
-
let
|
|
1661
|
+
let y, p;
|
|
1657
1662
|
if (u)
|
|
1658
1663
|
if (isManifestProvider(u)) {
|
|
1659
|
-
const
|
|
1664
|
+
const m = isBrowserEnv() ? u.remoteEntry : u.ssrRemoteEntry || u.remoteEntry || "", g = await this.getManifestJson(m, t, {}), _ = setGlobalSnapshotInfoByModuleInfo({
|
|
1660
1665
|
...t,
|
|
1661
1666
|
// The global remote may be overridden
|
|
1662
1667
|
// Therefore, set the snapshot key to the global address of the actual request
|
|
1663
|
-
entry:
|
|
1668
|
+
entry: m
|
|
1664
1669
|
}, g);
|
|
1665
|
-
|
|
1670
|
+
y = g, p = _;
|
|
1666
1671
|
} else {
|
|
1667
|
-
const { remoteSnapshot:
|
|
1672
|
+
const { remoteSnapshot: m } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1668
1673
|
options: this.HostInstance.options,
|
|
1669
1674
|
moduleInfo: t,
|
|
1670
1675
|
remoteSnapshot: u,
|
|
1671
1676
|
from: "global"
|
|
1672
1677
|
});
|
|
1673
|
-
|
|
1678
|
+
y = m, p = d;
|
|
1674
1679
|
}
|
|
1675
1680
|
else if (isRemoteInfoWithEntry(t)) {
|
|
1676
|
-
const
|
|
1681
|
+
const m = await this.getManifestJson(t.entry, t, {}), g = setGlobalSnapshotInfoByModuleInfo(t, m), { remoteSnapshot: _ } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1677
1682
|
options: this.HostInstance.options,
|
|
1678
1683
|
moduleInfo: t,
|
|
1679
|
-
remoteSnapshot:
|
|
1684
|
+
remoteSnapshot: m,
|
|
1680
1685
|
from: "global"
|
|
1681
1686
|
});
|
|
1682
|
-
|
|
1687
|
+
y = _, p = g;
|
|
1683
1688
|
} else
|
|
1684
1689
|
error(getShortErrorMsg(RUNTIME_007, runtimeDescMap, {
|
|
1685
1690
|
hostName: t.name,
|
|
1686
1691
|
hostVersion: t.version,
|
|
1687
|
-
globalSnapshot: JSON.stringify(
|
|
1692
|
+
globalSnapshot: JSON.stringify(d)
|
|
1688
1693
|
}));
|
|
1689
1694
|
return await this.hooks.lifecycle.afterLoadSnapshot.emit({
|
|
1690
1695
|
id: o,
|
|
1691
1696
|
host: this.HostInstance,
|
|
1692
1697
|
options: s,
|
|
1693
1698
|
moduleInfo: t,
|
|
1694
|
-
remoteSnapshot:
|
|
1699
|
+
remoteSnapshot: y
|
|
1695
1700
|
}), {
|
|
1696
|
-
remoteSnapshot:
|
|
1697
|
-
globalSnapshot:
|
|
1701
|
+
remoteSnapshot: y,
|
|
1702
|
+
globalSnapshot: p
|
|
1698
1703
|
};
|
|
1699
1704
|
}
|
|
1700
1705
|
getGlobalRemoteInfo(t) {
|
|
@@ -1706,12 +1711,12 @@ class SnapshotHandler {
|
|
|
1706
1711
|
if (c)
|
|
1707
1712
|
return c;
|
|
1708
1713
|
try {
|
|
1709
|
-
let
|
|
1710
|
-
(!
|
|
1711
|
-
} catch (
|
|
1714
|
+
let a = await this.loaderHook.lifecycle.fetch.emit(t, {});
|
|
1715
|
+
(!a || !(a instanceof Response)) && (a = await fetch(t, {})), c = await a.json();
|
|
1716
|
+
} catch (a) {
|
|
1712
1717
|
c = await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
1713
1718
|
id: t,
|
|
1714
|
-
error:
|
|
1719
|
+
error: a,
|
|
1715
1720
|
from: "runtime",
|
|
1716
1721
|
lifecycle: "afterResolve",
|
|
1717
1722
|
origin: this.HostInstance
|
|
@@ -1719,23 +1724,23 @@ class SnapshotHandler {
|
|
|
1719
1724
|
manifestUrl: t,
|
|
1720
1725
|
moduleName: o.name,
|
|
1721
1726
|
hostName: this.HostInstance.options.name
|
|
1722
|
-
}, `${
|
|
1727
|
+
}, `${a}`)));
|
|
1723
1728
|
}
|
|
1724
1729
|
return assert(c.metaData && c.exposes && c.shared, `${t} is not a federation manifest`), this.manifestCache.set(t, c), c;
|
|
1725
|
-
},
|
|
1726
|
-
const c = await s(),
|
|
1730
|
+
}, i = async () => {
|
|
1731
|
+
const c = await s(), a = generateSnapshotFromManifest(c, {
|
|
1727
1732
|
version: t
|
|
1728
1733
|
}), { remoteSnapshot: l } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1729
1734
|
options: this.HostInstance.options,
|
|
1730
1735
|
moduleInfo: o,
|
|
1731
1736
|
manifestJson: c,
|
|
1732
|
-
remoteSnapshot:
|
|
1737
|
+
remoteSnapshot: a,
|
|
1733
1738
|
manifestUrl: t,
|
|
1734
1739
|
from: "manifest"
|
|
1735
1740
|
});
|
|
1736
1741
|
return l;
|
|
1737
1742
|
};
|
|
1738
|
-
return this.manifestLoading[t] || (this.manifestLoading[t] =
|
|
1743
|
+
return this.manifestLoading[t] || (this.manifestLoading[t] = i().then((c) => c)), this.manifestLoading[t];
|
|
1739
1744
|
}
|
|
1740
1745
|
}
|
|
1741
1746
|
class SharedHandler {
|
|
@@ -1756,8 +1761,8 @@ class SharedHandler {
|
|
|
1756
1761
|
return Object.keys(n).forEach((c) => {
|
|
1757
1762
|
n[c].forEach((l) => {
|
|
1758
1763
|
l.scope.forEach((u) => {
|
|
1759
|
-
var
|
|
1760
|
-
((
|
|
1764
|
+
var y;
|
|
1765
|
+
((y = this.shareScopeMap[u]) == null ? void 0 : y[c]) || this.setShared({
|
|
1761
1766
|
pkgName: c,
|
|
1762
1767
|
lib: l.lib,
|
|
1763
1768
|
get: l.get,
|
|
@@ -1783,42 +1788,42 @@ class SharedHandler {
|
|
|
1783
1788
|
strategy: s.strategy
|
|
1784
1789
|
}));
|
|
1785
1790
|
}));
|
|
1786
|
-
const
|
|
1791
|
+
const i = await this.hooks.lifecycle.beforeLoadShare.emit({
|
|
1787
1792
|
pkgName: t,
|
|
1788
1793
|
shareInfo: s,
|
|
1789
1794
|
shared: n.options.shared,
|
|
1790
1795
|
origin: n
|
|
1791
|
-
}), { shareInfo: c } =
|
|
1796
|
+
}), { shareInfo: c } = i;
|
|
1792
1797
|
assert(c, `Cannot find ${t} Share in the ${n.options.name}. Please ensure that the ${t} Share parameters have been injected`);
|
|
1793
|
-
const
|
|
1798
|
+
const a = getRegisteredShare(this.shareScopeMap, t, c, this.hooks.lifecycle.resolveShare), l = (u) => {
|
|
1794
1799
|
u.useIn || (u.useIn = []), addUniqueItem(u.useIn, n.options.name);
|
|
1795
1800
|
};
|
|
1796
|
-
if (
|
|
1797
|
-
return l(
|
|
1798
|
-
if (
|
|
1799
|
-
const u = await
|
|
1800
|
-
return
|
|
1801
|
-
} else if (
|
|
1802
|
-
const
|
|
1803
|
-
const
|
|
1804
|
-
return l(
|
|
1801
|
+
if (a && a.lib)
|
|
1802
|
+
return l(a), a.lib;
|
|
1803
|
+
if (a && a.loading && !a.loaded) {
|
|
1804
|
+
const u = await a.loading;
|
|
1805
|
+
return a.loaded = !0, a.lib || (a.lib = u), l(a), u;
|
|
1806
|
+
} else if (a) {
|
|
1807
|
+
const d = (async () => {
|
|
1808
|
+
const y = await a.get();
|
|
1809
|
+
return l(a), a.loaded = !0, a.lib = y, y;
|
|
1805
1810
|
})();
|
|
1806
1811
|
return this.setShared({
|
|
1807
1812
|
pkgName: t,
|
|
1808
1813
|
loaded: !1,
|
|
1809
|
-
shared:
|
|
1814
|
+
shared: a,
|
|
1810
1815
|
from: n.options.name,
|
|
1811
1816
|
lib: null,
|
|
1812
|
-
loading:
|
|
1813
|
-
}),
|
|
1817
|
+
loading: d
|
|
1818
|
+
}), d;
|
|
1814
1819
|
} else {
|
|
1815
1820
|
if (o != null && o.customShareInfo)
|
|
1816
1821
|
return !1;
|
|
1817
|
-
const
|
|
1818
|
-
const
|
|
1819
|
-
c.lib =
|
|
1820
|
-
const
|
|
1821
|
-
return
|
|
1822
|
+
const d = (async () => {
|
|
1823
|
+
const y = await c.get();
|
|
1824
|
+
c.lib = y, c.loaded = !0, l(c);
|
|
1825
|
+
const p = getRegisteredShare(this.shareScopeMap, t, c, this.hooks.lifecycle.resolveShare);
|
|
1826
|
+
return p && (p.lib = y, p.loaded = !0, p.from = c.from), y;
|
|
1822
1827
|
})();
|
|
1823
1828
|
return this.setShared({
|
|
1824
1829
|
pkgName: t,
|
|
@@ -1826,8 +1831,8 @@ class SharedHandler {
|
|
|
1826
1831
|
shared: c,
|
|
1827
1832
|
from: n.options.name,
|
|
1828
1833
|
lib: null,
|
|
1829
|
-
loading:
|
|
1830
|
-
}),
|
|
1834
|
+
loading: d
|
|
1835
|
+
}), d;
|
|
1831
1836
|
}
|
|
1832
1837
|
}
|
|
1833
1838
|
/**
|
|
@@ -1837,52 +1842,38 @@ class SharedHandler {
|
|
|
1837
1842
|
*/
|
|
1838
1843
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
1839
1844
|
initializeSharing(t = DEFAULT_SCOPE, o) {
|
|
1840
|
-
const { host: n } = this, s = o == null ? void 0 : o.from,
|
|
1845
|
+
const { host: n } = this, s = o == null ? void 0 : o.from, i = o == null ? void 0 : o.strategy;
|
|
1841
1846
|
let c = o == null ? void 0 : o.initScope;
|
|
1842
|
-
const
|
|
1847
|
+
const a = [];
|
|
1843
1848
|
if (s !== "build") {
|
|
1844
|
-
const { initTokens:
|
|
1849
|
+
const { initTokens: m } = this;
|
|
1845
1850
|
c || (c = []);
|
|
1846
|
-
let
|
|
1847
|
-
if (
|
|
1848
|
-
return
|
|
1849
|
-
c.push(
|
|
1851
|
+
let g = m[t];
|
|
1852
|
+
if (g || (g = m[t] = { from: this.host.name }), c.indexOf(g) >= 0)
|
|
1853
|
+
return a;
|
|
1854
|
+
c.push(g);
|
|
1850
1855
|
}
|
|
1851
1856
|
const l = this.shareScopeMap, u = n.options.name;
|
|
1852
1857
|
l[t] || (l[t] = {});
|
|
1853
|
-
const
|
|
1854
|
-
var
|
|
1855
|
-
const { version:
|
|
1856
|
-
|
|
1857
|
-
const
|
|
1858
|
-
(!S || S.strategy !== "loaded-first" && !S.loaded && (!
|
|
1859
|
-
},
|
|
1860
|
-
const { module:
|
|
1861
|
-
id:
|
|
1858
|
+
const d = l[t], y = (m, g) => {
|
|
1859
|
+
var A;
|
|
1860
|
+
const { version: _, eager: E } = g;
|
|
1861
|
+
d[m] = d[m] || {};
|
|
1862
|
+
const b = d[m], S = b[_], I = !!(S && (S.eager || (A = S.shareConfig) != null && A.eager));
|
|
1863
|
+
(!S || S.strategy !== "loaded-first" && !S.loaded && (!E != !I ? E : u > S.from)) && (b[_] = g);
|
|
1864
|
+
}, p = async (m) => {
|
|
1865
|
+
const { module: g } = await n.remoteHandler.getRemoteModuleAndOptions({
|
|
1866
|
+
id: m
|
|
1862
1867
|
});
|
|
1863
|
-
|
|
1864
|
-
let E;
|
|
1865
|
-
try {
|
|
1866
|
-
E = await b.getEntry();
|
|
1867
|
-
} catch (R) {
|
|
1868
|
-
E = await n.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
1869
|
-
id: g,
|
|
1870
|
-
error: R,
|
|
1871
|
-
from: "runtime",
|
|
1872
|
-
lifecycle: "beforeLoadShare",
|
|
1873
|
-
origin: n
|
|
1874
|
-
});
|
|
1875
|
-
}
|
|
1876
|
-
b.inited || (await d(E), b.inited = !0);
|
|
1877
|
-
}
|
|
1868
|
+
await g.init();
|
|
1878
1869
|
};
|
|
1879
|
-
return Object.keys(n.options.shared).forEach((
|
|
1880
|
-
n.options.shared[
|
|
1881
|
-
|
|
1870
|
+
return Object.keys(n.options.shared).forEach((m) => {
|
|
1871
|
+
n.options.shared[m].forEach((_) => {
|
|
1872
|
+
_.scope.includes(t) && y(m, _);
|
|
1882
1873
|
});
|
|
1883
|
-
}), (n.options.shareStrategy === "version-first" ||
|
|
1884
|
-
|
|
1885
|
-
}),
|
|
1874
|
+
}), (n.options.shareStrategy === "version-first" || i === "version-first") && n.options.remotes.forEach((m) => {
|
|
1875
|
+
m.shareScope === t && a.push(p(m.name));
|
|
1876
|
+
}), a;
|
|
1886
1877
|
}
|
|
1887
1878
|
// The lib function will only be available if the shared set by eager or runtime init is set or the shared is successfully loaded.
|
|
1888
1879
|
// 1. If the loaded shared already exists globally, then it will be reused
|
|
@@ -1894,39 +1885,39 @@ class SharedHandler {
|
|
|
1894
1885
|
extraOptions: o,
|
|
1895
1886
|
shareInfos: n.options.shared
|
|
1896
1887
|
});
|
|
1897
|
-
s != null && s.scope && s.scope.forEach((
|
|
1898
|
-
this.initializeSharing(
|
|
1888
|
+
s != null && s.scope && s.scope.forEach((a) => {
|
|
1889
|
+
this.initializeSharing(a, { strategy: s.strategy });
|
|
1899
1890
|
});
|
|
1900
|
-
const
|
|
1901
|
-
|
|
1891
|
+
const i = getRegisteredShare(this.shareScopeMap, t, s, this.hooks.lifecycle.resolveShare), c = (a) => {
|
|
1892
|
+
a.useIn || (a.useIn = []), addUniqueItem(a.useIn, n.options.name);
|
|
1902
1893
|
};
|
|
1903
|
-
if (
|
|
1904
|
-
if (typeof
|
|
1905
|
-
return c(
|
|
1906
|
-
if (typeof
|
|
1907
|
-
const
|
|
1908
|
-
if (!(
|
|
1909
|
-
return c(
|
|
1894
|
+
if (i) {
|
|
1895
|
+
if (typeof i.lib == "function")
|
|
1896
|
+
return c(i), i.loaded || (i.loaded = !0, i.from === n.options.name && (s.loaded = !0)), i.lib;
|
|
1897
|
+
if (typeof i.get == "function") {
|
|
1898
|
+
const a = i.get();
|
|
1899
|
+
if (!(a instanceof Promise))
|
|
1900
|
+
return c(i), this.setShared({
|
|
1910
1901
|
pkgName: t,
|
|
1911
1902
|
loaded: !0,
|
|
1912
1903
|
from: n.options.name,
|
|
1913
|
-
lib:
|
|
1914
|
-
shared:
|
|
1915
|
-
}),
|
|
1904
|
+
lib: a,
|
|
1905
|
+
shared: i
|
|
1906
|
+
}), a;
|
|
1916
1907
|
}
|
|
1917
1908
|
}
|
|
1918
1909
|
if (s.lib)
|
|
1919
1910
|
return s.loaded || (s.loaded = !0), s.lib;
|
|
1920
1911
|
if (s.get) {
|
|
1921
|
-
const
|
|
1922
|
-
if (
|
|
1912
|
+
const a = s.get();
|
|
1913
|
+
if (a instanceof Promise) {
|
|
1923
1914
|
const l = (o == null ? void 0 : o.from) === "build" ? RUNTIME_005 : RUNTIME_006;
|
|
1924
1915
|
throw new Error(getShortErrorMsg(l, runtimeDescMap, {
|
|
1925
1916
|
hostName: n.options.name,
|
|
1926
1917
|
sharedPkgName: t
|
|
1927
1918
|
}));
|
|
1928
1919
|
}
|
|
1929
|
-
return s.lib =
|
|
1920
|
+
return s.lib = a, this.setShared({
|
|
1930
1921
|
pkgName: t,
|
|
1931
1922
|
loaded: !0,
|
|
1932
1923
|
from: n.options.name,
|
|
@@ -1949,22 +1940,22 @@ class SharedHandler {
|
|
|
1949
1940
|
hostShareScopeMap: n.hostShareScopeMap
|
|
1950
1941
|
});
|
|
1951
1942
|
}
|
|
1952
|
-
setShared({ pkgName: t, shared: o, from: n, lib: s, loading:
|
|
1953
|
-
const { version: l, scope: u = "default", ...
|
|
1954
|
-
(Array.isArray(u) ? u : [u]).forEach((
|
|
1955
|
-
if (this.shareScopeMap[
|
|
1956
|
-
this.shareScopeMap[
|
|
1943
|
+
setShared({ pkgName: t, shared: o, from: n, lib: s, loading: i, loaded: c, get: a }) {
|
|
1944
|
+
const { version: l, scope: u = "default", ...d } = o;
|
|
1945
|
+
(Array.isArray(u) ? u : [u]).forEach((p) => {
|
|
1946
|
+
if (this.shareScopeMap[p] || (this.shareScopeMap[p] = {}), this.shareScopeMap[p][t] || (this.shareScopeMap[p][t] = {}), !this.shareScopeMap[p][t][l]) {
|
|
1947
|
+
this.shareScopeMap[p][t][l] = {
|
|
1957
1948
|
version: l,
|
|
1958
|
-
scope: [
|
|
1959
|
-
...
|
|
1949
|
+
scope: [p],
|
|
1950
|
+
...d,
|
|
1960
1951
|
lib: s,
|
|
1961
1952
|
loaded: c,
|
|
1962
|
-
loading:
|
|
1963
|
-
},
|
|
1953
|
+
loading: i
|
|
1954
|
+
}, a && (this.shareScopeMap[p][t][l].get = a);
|
|
1964
1955
|
return;
|
|
1965
1956
|
}
|
|
1966
|
-
const
|
|
1967
|
-
|
|
1957
|
+
const m = this.shareScopeMap[p][t][l];
|
|
1958
|
+
i && !m.loading && (m.loading = i), c && !m.loaded && (m.loaded = c), n && m.from !== n && (m.from = n);
|
|
1968
1959
|
});
|
|
1969
1960
|
}
|
|
1970
1961
|
_setGlobalShareScopeMap(t) {
|
|
@@ -1989,18 +1980,18 @@ class RemoteHandler {
|
|
|
1989
1980
|
}), this.host = t, this.idToRemoteMap = {};
|
|
1990
1981
|
}
|
|
1991
1982
|
formatAndRegisterRemote(t, o) {
|
|
1992
|
-
return (o.remotes || []).reduce((s,
|
|
1983
|
+
return (o.remotes || []).reduce((s, i) => (this.registerRemote(i, s, { force: !1 }), s), t.remotes);
|
|
1993
1984
|
}
|
|
1994
1985
|
setIdToRemoteMap(t, o) {
|
|
1995
|
-
const { remote: n, expose: s } = o, { name:
|
|
1996
|
-
if (this.idToRemoteMap[t] = { name: n.name, expose: s }, c && t.startsWith(
|
|
1997
|
-
const
|
|
1998
|
-
this.idToRemoteMap[
|
|
1986
|
+
const { remote: n, expose: s } = o, { name: i, alias: c } = n;
|
|
1987
|
+
if (this.idToRemoteMap[t] = { name: n.name, expose: s }, c && t.startsWith(i)) {
|
|
1988
|
+
const a = t.replace(i, c);
|
|
1989
|
+
this.idToRemoteMap[a] = { name: n.name, expose: s };
|
|
1999
1990
|
return;
|
|
2000
1991
|
}
|
|
2001
1992
|
if (c && t.startsWith(c)) {
|
|
2002
|
-
const
|
|
2003
|
-
this.idToRemoteMap[
|
|
1993
|
+
const a = t.replace(c, i);
|
|
1994
|
+
this.idToRemoteMap[a] = { name: n.name, expose: s };
|
|
2004
1995
|
}
|
|
2005
1996
|
}
|
|
2006
1997
|
// eslint-disable-next-line max-lines-per-function
|
|
@@ -2010,25 +2001,25 @@ class RemoteHandler {
|
|
|
2010
2001
|
try {
|
|
2011
2002
|
const { loadFactory: s = !0 } = o || {
|
|
2012
2003
|
loadFactory: !0
|
|
2013
|
-
}, { module:
|
|
2004
|
+
}, { module: i, moduleOptions: c, remoteMatchInfo: a } = await this.getRemoteModuleAndOptions({
|
|
2014
2005
|
id: t
|
|
2015
|
-
}), { pkgNameOrAlias: l, remote: u, expose:
|
|
2016
|
-
id:
|
|
2006
|
+
}), { pkgNameOrAlias: l, remote: u, expose: d, id: y, remoteSnapshot: p } = a, m = await i.get(y, d, o, p), g = await this.hooks.lifecycle.onLoad.emit({
|
|
2007
|
+
id: y,
|
|
2017
2008
|
pkgNameOrAlias: l,
|
|
2018
|
-
expose:
|
|
2019
|
-
exposeModule: s ?
|
|
2020
|
-
exposeModuleFactory: s ? void 0 :
|
|
2009
|
+
expose: d,
|
|
2010
|
+
exposeModule: s ? m : void 0,
|
|
2011
|
+
exposeModuleFactory: s ? void 0 : m,
|
|
2021
2012
|
remote: u,
|
|
2022
2013
|
options: c,
|
|
2023
|
-
moduleInstance:
|
|
2014
|
+
moduleInstance: i,
|
|
2024
2015
|
origin: n
|
|
2025
2016
|
});
|
|
2026
|
-
return this.setIdToRemoteMap(t,
|
|
2017
|
+
return this.setIdToRemoteMap(t, a), typeof g == "function" ? g : m;
|
|
2027
2018
|
} catch (s) {
|
|
2028
|
-
const { from:
|
|
2019
|
+
const { from: i = "runtime" } = o || { from: "runtime" }, c = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2029
2020
|
id: t,
|
|
2030
2021
|
error: s,
|
|
2031
|
-
from:
|
|
2022
|
+
from: i,
|
|
2032
2023
|
lifecycle: "onLoad",
|
|
2033
2024
|
origin: n
|
|
2034
2025
|
});
|
|
@@ -2047,14 +2038,14 @@ class RemoteHandler {
|
|
|
2047
2038
|
});
|
|
2048
2039
|
const n = formatPreloadArgs(o.options.remotes, t);
|
|
2049
2040
|
await Promise.all(n.map(async (s) => {
|
|
2050
|
-
const { remote:
|
|
2051
|
-
moduleInfo:
|
|
2041
|
+
const { remote: i } = s, c = getRemoteInfo(i), { globalSnapshot: a, remoteSnapshot: l } = await o.snapshotHandler.loadRemoteSnapshotInfo({
|
|
2042
|
+
moduleInfo: i
|
|
2052
2043
|
}), u = await this.hooks.lifecycle.generatePreloadAssets.emit({
|
|
2053
2044
|
origin: o,
|
|
2054
2045
|
preloadOptions: s,
|
|
2055
|
-
remote:
|
|
2046
|
+
remote: i,
|
|
2056
2047
|
remoteInfo: c,
|
|
2057
|
-
globalSnapshot:
|
|
2048
|
+
globalSnapshot: a,
|
|
2058
2049
|
remoteSnapshot: l
|
|
2059
2050
|
});
|
|
2060
2051
|
u && preloadAssets(c, o, u);
|
|
@@ -2088,103 +2079,103 @@ class RemoteHandler {
|
|
|
2088
2079
|
}), !s)
|
|
2089
2080
|
throw g;
|
|
2090
2081
|
}
|
|
2091
|
-
const { id:
|
|
2082
|
+
const { id: i } = s, c = matchRemoteWithNameAndExpose(o.options.remotes, i);
|
|
2092
2083
|
assert(c, getShortErrorMsg(RUNTIME_004, runtimeDescMap, {
|
|
2093
2084
|
hostName: o.options.name,
|
|
2094
|
-
requestId:
|
|
2085
|
+
requestId: i
|
|
2095
2086
|
}));
|
|
2096
|
-
const { remote:
|
|
2097
|
-
id:
|
|
2087
|
+
const { remote: a } = c, l = getRemoteInfo(a), u = await o.sharedHandler.hooks.lifecycle.afterResolve.emit({
|
|
2088
|
+
id: i,
|
|
2098
2089
|
...c,
|
|
2099
2090
|
options: o.options,
|
|
2100
2091
|
origin: o,
|
|
2101
2092
|
remoteInfo: l
|
|
2102
|
-
}), { remote:
|
|
2103
|
-
assert(
|
|
2104
|
-
let
|
|
2105
|
-
const
|
|
2093
|
+
}), { remote: d, expose: y } = u;
|
|
2094
|
+
assert(d && y, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${i}.`);
|
|
2095
|
+
let p = o.moduleCache.get(d.name);
|
|
2096
|
+
const m = {
|
|
2106
2097
|
host: o,
|
|
2107
2098
|
remoteInfo: l
|
|
2108
2099
|
};
|
|
2109
|
-
return
|
|
2110
|
-
module:
|
|
2111
|
-
moduleOptions:
|
|
2100
|
+
return p || (p = new Module(m), o.moduleCache.set(d.name, p)), {
|
|
2101
|
+
module: p,
|
|
2102
|
+
moduleOptions: m,
|
|
2112
2103
|
remoteMatchInfo: u
|
|
2113
2104
|
};
|
|
2114
2105
|
}
|
|
2115
2106
|
registerRemote(t, o, n) {
|
|
2116
|
-
const { host: s } = this,
|
|
2107
|
+
const { host: s } = this, i = () => {
|
|
2117
2108
|
if (t.alias) {
|
|
2118
|
-
const
|
|
2109
|
+
const a = o.find((l) => {
|
|
2119
2110
|
var u;
|
|
2120
2111
|
return t.alias && (l.name.startsWith(t.alias) || ((u = l.alias) == null ? void 0 : u.startsWith(t.alias)));
|
|
2121
2112
|
});
|
|
2122
|
-
assert(!
|
|
2113
|
+
assert(!a, `The alias ${t.alias} of remote ${t.name} is not allowed to be the prefix of ${a && a.name} name or alias`);
|
|
2123
2114
|
}
|
|
2124
2115
|
"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);
|
|
2125
2116
|
};
|
|
2126
2117
|
this.hooks.lifecycle.beforeRegisterRemote.emit({ remote: t, origin: s });
|
|
2127
|
-
const c = o.find((
|
|
2118
|
+
const c = o.find((a) => a.name === t.name);
|
|
2128
2119
|
if (!c)
|
|
2129
|
-
|
|
2120
|
+
i(), o.push(t), this.hooks.lifecycle.registerRemote.emit({ remote: t, origin: s });
|
|
2130
2121
|
else {
|
|
2131
|
-
const
|
|
2122
|
+
const a = [
|
|
2132
2123
|
`The remote "${t.name}" is already registered.`,
|
|
2133
2124
|
"Please note that overriding it may cause unexpected errors."
|
|
2134
2125
|
];
|
|
2135
|
-
n != null && n.force && (this.removeRemote(c),
|
|
2126
|
+
n != null && n.force && (this.removeRemote(c), i(), o.push(t), this.hooks.lifecycle.registerRemote.emit({ remote: t, origin: s }), warn$1(a.join(" ")));
|
|
2136
2127
|
}
|
|
2137
2128
|
}
|
|
2138
2129
|
removeRemote(t) {
|
|
2139
2130
|
var o;
|
|
2140
2131
|
try {
|
|
2141
|
-
const { host: n } = this, { name: s } = t,
|
|
2142
|
-
|
|
2132
|
+
const { host: n } = this, { name: s } = t, i = n.options.remotes.findIndex((a) => a.name === s);
|
|
2133
|
+
i !== -1 && n.options.remotes.splice(i, 1);
|
|
2143
2134
|
const c = n.moduleCache.get(t.name);
|
|
2144
2135
|
if (c) {
|
|
2145
|
-
const
|
|
2136
|
+
const a = c.remoteInfo, l = a.entryGlobalName;
|
|
2146
2137
|
CurrentGlobal[l] && ((o = Object.getOwnPropertyDescriptor(CurrentGlobal, l)) != null && o.configurable ? delete CurrentGlobal[l] : CurrentGlobal[l] = void 0);
|
|
2147
2138
|
const u = getRemoteEntryUniqueKey(c.remoteInfo);
|
|
2148
|
-
globalLoading[u] && delete globalLoading[u], n.snapshotHandler.manifestCache.delete(
|
|
2149
|
-
let
|
|
2150
|
-
const
|
|
2151
|
-
if (
|
|
2152
|
-
const
|
|
2153
|
-
|
|
2139
|
+
globalLoading[u] && delete globalLoading[u], n.snapshotHandler.manifestCache.delete(a.entry);
|
|
2140
|
+
let d = a.buildVersion ? composeKeyWithSeparator(a.name, a.buildVersion) : a.name;
|
|
2141
|
+
const y = CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex((m) => a.buildVersion ? m.options.id === d : m.name === d);
|
|
2142
|
+
if (y !== -1) {
|
|
2143
|
+
const m = CurrentGlobal.__FEDERATION__.__INSTANCES__[y];
|
|
2144
|
+
d = m.options.id || d;
|
|
2154
2145
|
const g = getGlobalShareScope();
|
|
2155
|
-
let
|
|
2146
|
+
let _ = !0;
|
|
2156
2147
|
const E = [];
|
|
2157
|
-
Object.keys(g).forEach((
|
|
2158
|
-
const
|
|
2159
|
-
|
|
2160
|
-
const A = I
|
|
2161
|
-
A && Object.keys(A).forEach((
|
|
2162
|
-
const T = A[
|
|
2148
|
+
Object.keys(g).forEach((b) => {
|
|
2149
|
+
const S = g[b];
|
|
2150
|
+
S && Object.keys(S).forEach((I) => {
|
|
2151
|
+
const A = S[I];
|
|
2152
|
+
A && Object.keys(A).forEach((R) => {
|
|
2153
|
+
const T = A[R];
|
|
2163
2154
|
T && Object.keys(T).forEach((w) => {
|
|
2164
2155
|
const $ = T[w];
|
|
2165
|
-
$ && typeof $ == "object" && $.from ===
|
|
2156
|
+
$ && typeof $ == "object" && $.from === a.name && ($.loaded || $.loading ? ($.useIn = $.useIn.filter((P) => P !== a.name), $.useIn.length ? _ = !1 : E.push([
|
|
2157
|
+
b,
|
|
2158
|
+
I,
|
|
2166
2159
|
R,
|
|
2167
|
-
S,
|
|
2168
|
-
_,
|
|
2169
2160
|
w
|
|
2170
2161
|
])) : E.push([
|
|
2162
|
+
b,
|
|
2163
|
+
I,
|
|
2171
2164
|
R,
|
|
2172
|
-
S,
|
|
2173
|
-
_,
|
|
2174
2165
|
w
|
|
2175
2166
|
]));
|
|
2176
2167
|
});
|
|
2177
2168
|
});
|
|
2178
2169
|
});
|
|
2179
|
-
}),
|
|
2180
|
-
var
|
|
2181
|
-
(w = (T = (
|
|
2182
|
-
}), CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(
|
|
2170
|
+
}), _ && (m.shareScopeMap = {}, delete g[d]), E.forEach(([b, S, I, A]) => {
|
|
2171
|
+
var R, T, w;
|
|
2172
|
+
(w = (T = (R = g[b]) == null ? void 0 : R[S]) == null ? void 0 : T[I]) == null || delete w[A];
|
|
2173
|
+
}), CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(y, 1);
|
|
2183
2174
|
}
|
|
2184
|
-
const { hostGlobalSnapshot:
|
|
2185
|
-
if (
|
|
2186
|
-
const
|
|
2187
|
-
|
|
2175
|
+
const { hostGlobalSnapshot: p } = getGlobalRemoteInfo(t, n);
|
|
2176
|
+
if (p) {
|
|
2177
|
+
const m = p && "remotesInfo" in p && p.remotesInfo && getInfoWithoutType(p.remotesInfo, t.name).key;
|
|
2178
|
+
m && (delete p.remotesInfo[m], Global.__FEDERATION__.__MANIFEST_LOADING__[m] && delete Global.__FEDERATION__.__MANIFEST_LOADING__[m]);
|
|
2188
2179
|
}
|
|
2189
2180
|
n.moduleCache.delete(t.name);
|
|
2190
2181
|
}
|
|
@@ -2203,7 +2194,7 @@ class ModuleFederation {
|
|
|
2203
2194
|
beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
|
|
2204
2195
|
// maybe will change, temporarily for internal use only
|
|
2205
2196
|
initContainer: new AsyncWaterfallHook("initContainer")
|
|
2206
|
-
}), this.version = "0.22.
|
|
2197
|
+
}), this.version = "0.22.1", this.moduleCache = /* @__PURE__ */ new Map(), this.loaderHook = new PluginSystem({
|
|
2207
2198
|
// FIXME: may not be suitable , not open to the public yet
|
|
2208
2199
|
getModuleInfo: new SyncHook(),
|
|
2209
2200
|
createScript: new SyncHook(),
|
|
@@ -2249,8 +2240,8 @@ class ModuleFederation {
|
|
|
2249
2240
|
return this.sharedHandler.initializeSharing(t, o);
|
|
2250
2241
|
}
|
|
2251
2242
|
initRawContainer(t, o, n) {
|
|
2252
|
-
const s = getRemoteInfo({ name: t, entry: o }),
|
|
2253
|
-
return
|
|
2243
|
+
const s = getRemoteInfo({ name: t, entry: o }), i = new Module({ host: this, remoteInfo: s });
|
|
2244
|
+
return i.remoteEntryExports = n, this.moduleCache.set(t, i), i;
|
|
2254
2245
|
}
|
|
2255
2246
|
// eslint-disable-next-line max-lines-per-function
|
|
2256
2247
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
@@ -2265,21 +2256,21 @@ class ModuleFederation {
|
|
|
2265
2256
|
this.sharedHandler.initShareScopeMap(t, o, n);
|
|
2266
2257
|
}
|
|
2267
2258
|
formatOptions(t, o) {
|
|
2268
|
-
const { shared: n } = formatShareConfigs(t, o), { userOptions: s, options:
|
|
2259
|
+
const { shared: n } = formatShareConfigs(t, o), { userOptions: s, options: i } = this.hooks.lifecycle.beforeInit.emit({
|
|
2269
2260
|
origin: this,
|
|
2270
2261
|
userOptions: o,
|
|
2271
2262
|
options: t,
|
|
2272
2263
|
shareInfo: n
|
|
2273
|
-
}), c = this.remoteHandler.formatAndRegisterRemote(
|
|
2274
|
-
s.plugins && s.plugins.forEach((
|
|
2275
|
-
l.includes(
|
|
2264
|
+
}), c = this.remoteHandler.formatAndRegisterRemote(i, s), { shared: a } = this.sharedHandler.registerShared(i, s), l = [...i.plugins];
|
|
2265
|
+
s.plugins && s.plugins.forEach((d) => {
|
|
2266
|
+
l.includes(d) || l.push(d);
|
|
2276
2267
|
});
|
|
2277
2268
|
const u = {
|
|
2278
2269
|
...t,
|
|
2279
2270
|
...o,
|
|
2280
2271
|
plugins: l,
|
|
2281
2272
|
remotes: c,
|
|
2282
|
-
shared:
|
|
2273
|
+
shared: a
|
|
2283
2274
|
};
|
|
2284
2275
|
return this.hooks.lifecycle.init.emit({
|
|
2285
2276
|
origin: this,
|
|
@@ -2288,7 +2279,7 @@ class ModuleFederation {
|
|
|
2288
2279
|
}
|
|
2289
2280
|
registerPlugins(t) {
|
|
2290
2281
|
const o = registerPlugins(t, this);
|
|
2291
|
-
this.options.plugins = this.options.plugins.reduce((n, s) => (s && n && !n.find((
|
|
2282
|
+
this.options.plugins = this.options.plugins.reduce((n, s) => (s && n && !n.find((i) => i.name === s.name) && n.push(s), n), o || []);
|
|
2292
2283
|
}
|
|
2293
2284
|
registerRemotes(t, o) {
|
|
2294
2285
|
return this.remoteHandler.registerRemotes(t, o);
|
|
@@ -2318,81 +2309,81 @@ function addBasenameToNestedRoutes(r, t) {
|
|
|
2318
2309
|
});
|
|
2319
2310
|
}
|
|
2320
2311
|
function processRoutes(r) {
|
|
2321
|
-
const { router: t, basename: o, memoryRoute: n, hashRoute: s } = r,
|
|
2322
|
-
(
|
|
2323
|
-
), c = /* @__PURE__ */ new Map(),
|
|
2324
|
-
|
|
2325
|
-
c.set(
|
|
2312
|
+
const { router: t, basename: o, memoryRoute: n, hashRoute: s } = r, i = t.getRoutes().sort(
|
|
2313
|
+
(p, m) => p.path.split("/").filter((g) => g).length - m.path.split("/").filter((g) => g).length
|
|
2314
|
+
), c = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set();
|
|
2315
|
+
i.forEach((p) => {
|
|
2316
|
+
c.set(p.path, p);
|
|
2326
2317
|
});
|
|
2327
|
-
const l = (
|
|
2328
|
-
if (!
|
|
2329
|
-
return
|
|
2330
|
-
for (let g = 0; g <
|
|
2331
|
-
const
|
|
2332
|
-
if (
|
|
2333
|
-
const
|
|
2334
|
-
...
|
|
2335
|
-
path:
|
|
2318
|
+
const l = (p, m) => `${p}/${m}`.replace(/\/+/g, "/").replace(/\/$/, "") || "/", u = (p, m = "") => {
|
|
2319
|
+
if (!p.children || p.children.length === 0)
|
|
2320
|
+
return p;
|
|
2321
|
+
for (let g = 0; g < p.children.length; g++) {
|
|
2322
|
+
const _ = p.children[g], E = l(m, _.path), b = c.get(E);
|
|
2323
|
+
if (b && !a.has(b)) {
|
|
2324
|
+
const S = {
|
|
2325
|
+
...b,
|
|
2326
|
+
path: _.path
|
|
2336
2327
|
// Keep the original relative path from static route
|
|
2337
2328
|
};
|
|
2338
|
-
|
|
2329
|
+
p.children[g] = S, a.add(b), u(S, E);
|
|
2339
2330
|
}
|
|
2340
2331
|
}
|
|
2341
|
-
return
|
|
2332
|
+
return p;
|
|
2342
2333
|
};
|
|
2343
|
-
let
|
|
2344
|
-
for (const
|
|
2345
|
-
if (!
|
|
2346
|
-
const
|
|
2347
|
-
|
|
2334
|
+
let d = [];
|
|
2335
|
+
for (const p of i)
|
|
2336
|
+
if (!a.has(p)) {
|
|
2337
|
+
const m = u(p, p.path);
|
|
2338
|
+
a.add(p), d.push(m);
|
|
2348
2339
|
}
|
|
2349
|
-
let
|
|
2350
|
-
return n ?
|
|
2351
|
-
history:
|
|
2352
|
-
routes:
|
|
2340
|
+
let y;
|
|
2341
|
+
return n ? y = VueRouter.createMemoryHistory(o) : s ? (y = VueRouter.createWebHashHistory(), o && (d = addBasenameToNestedRoutes(d, o))) : y = VueRouter.createWebHistory(o), {
|
|
2342
|
+
history: y,
|
|
2343
|
+
routes: d
|
|
2353
2344
|
};
|
|
2354
2345
|
}
|
|
2355
2346
|
function createBridgeComponent(r) {
|
|
2356
2347
|
const t = /* @__PURE__ */ new Map(), o = getInstance();
|
|
2357
2348
|
return () => ({
|
|
2358
|
-
__APP_VERSION__: "0.22.
|
|
2349
|
+
__APP_VERSION__: "0.22.1",
|
|
2359
2350
|
async render(n) {
|
|
2360
|
-
var g,
|
|
2351
|
+
var g, _, E;
|
|
2361
2352
|
LoggerInstance.debug("createBridgeComponent render Info", n);
|
|
2362
2353
|
const {
|
|
2363
2354
|
moduleName: s,
|
|
2364
|
-
dom:
|
|
2355
|
+
dom: i,
|
|
2365
2356
|
basename: c,
|
|
2366
|
-
memoryRoute:
|
|
2357
|
+
memoryRoute: a,
|
|
2367
2358
|
hashRoute: l,
|
|
2368
2359
|
...u
|
|
2369
|
-
} = n,
|
|
2370
|
-
t.set(
|
|
2371
|
-
const
|
|
2372
|
-
app:
|
|
2360
|
+
} = n, d = Vue.createApp(r.rootComponent, u);
|
|
2361
|
+
t.set(i, d);
|
|
2362
|
+
const y = await ((E = (_ = (g = o == null ? void 0 : o.bridgeHook) == null ? void 0 : g.lifecycle) == null ? void 0 : _.beforeBridgeRender) == null ? void 0 : E.emit(n)), p = y && typeof y == "object" && (y != null && y.extraProps) ? y == null ? void 0 : y.extraProps : {}, m = r.appOptions({
|
|
2363
|
+
app: d,
|
|
2373
2364
|
basename: c,
|
|
2374
|
-
memoryRoute:
|
|
2365
|
+
memoryRoute: a,
|
|
2375
2366
|
hashRoute: l,
|
|
2376
2367
|
...u,
|
|
2377
|
-
...
|
|
2368
|
+
...p
|
|
2378
2369
|
});
|
|
2379
|
-
if (
|
|
2380
|
-
const { history:
|
|
2381
|
-
router:
|
|
2370
|
+
if (m != null && m.router) {
|
|
2371
|
+
const { history: b, routes: S } = processRoutes({
|
|
2372
|
+
router: m.router,
|
|
2382
2373
|
basename: n.basename,
|
|
2383
2374
|
memoryRoute: n.memoryRoute,
|
|
2384
2375
|
hashRoute: n.hashRoute
|
|
2385
|
-
}),
|
|
2386
|
-
...
|
|
2387
|
-
history:
|
|
2388
|
-
routes:
|
|
2376
|
+
}), I = VueRouter.createRouter({
|
|
2377
|
+
...m.router.options,
|
|
2378
|
+
history: b,
|
|
2379
|
+
routes: S
|
|
2389
2380
|
});
|
|
2390
2381
|
LoggerInstance.debug("createBridgeComponent render router info>>>", {
|
|
2391
2382
|
moduleName: s,
|
|
2392
|
-
router:
|
|
2393
|
-
}),
|
|
2383
|
+
router: I
|
|
2384
|
+
}), a && await I.push(a.entryPath), d.use(I);
|
|
2394
2385
|
}
|
|
2395
|
-
|
|
2386
|
+
d.mount(i);
|
|
2396
2387
|
},
|
|
2397
2388
|
destroy(n) {
|
|
2398
2389
|
LoggerInstance.debug("createBridgeComponent destroy Info", n);
|
|
@@ -2417,11 +2408,11 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2417
2408
|
},
|
|
2418
2409
|
inheritAttrs: !1,
|
|
2419
2410
|
setup(r) {
|
|
2420
|
-
const t = ref(null), o = ref(null), n = ref(""), s = useRoute(),
|
|
2421
|
-
var
|
|
2422
|
-
const u = (
|
|
2411
|
+
const t = ref(null), o = ref(null), n = ref(""), s = useRoute(), i = getInstance(), c = useAttrs(), a = async () => {
|
|
2412
|
+
var p, m, g, _;
|
|
2413
|
+
const u = (p = r.providerInfo) == null ? void 0 : p.call(r);
|
|
2423
2414
|
o.value = u;
|
|
2424
|
-
let
|
|
2415
|
+
let d = {
|
|
2425
2416
|
...c,
|
|
2426
2417
|
moduleName: r.moduleName,
|
|
2427
2418
|
dom: t.value,
|
|
@@ -2429,20 +2420,20 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2429
2420
|
memoryRoute: r.memoryRoute,
|
|
2430
2421
|
hashRoute: r.hashRoute
|
|
2431
2422
|
};
|
|
2432
|
-
LoggerInstance.debug("createRemoteAppComponent LazyComponent render >>>",
|
|
2433
|
-
const
|
|
2434
|
-
|
|
2435
|
-
...
|
|
2436
|
-
...
|
|
2437
|
-
}, u.render(
|
|
2423
|
+
LoggerInstance.debug("createRemoteAppComponent LazyComponent render >>>", d);
|
|
2424
|
+
const y = await ((_ = (g = (m = i == null ? void 0 : i.bridgeHook) == null ? void 0 : m.lifecycle) == null ? void 0 : g.beforeBridgeRender) == null ? void 0 : _.emit(d)) || {};
|
|
2425
|
+
d = {
|
|
2426
|
+
...d,
|
|
2427
|
+
...y.extraProps
|
|
2428
|
+
}, u.render(d);
|
|
2438
2429
|
}, l = watch(() => s == null ? void 0 : s.path, (u) => {
|
|
2439
|
-
u !== s.path &&
|
|
2430
|
+
u !== s.path && a(), n.value !== "" && n.value !== u && (LoggerInstance.debug("createRemoteAppComponent dispatchPopstateEnv >>>", {
|
|
2440
2431
|
...r,
|
|
2441
2432
|
pathname: s.path
|
|
2442
2433
|
}), e()), n.value = u;
|
|
2443
2434
|
});
|
|
2444
2435
|
return onMounted(() => {
|
|
2445
|
-
|
|
2436
|
+
a();
|
|
2446
2437
|
}), onBeforeUnmount(() => {
|
|
2447
2438
|
var u;
|
|
2448
2439
|
LoggerInstance.debug("createRemoteAppComponent LazyComponent destroy >>>", {
|
|
@@ -2457,7 +2448,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2457
2448
|
});
|
|
2458
2449
|
function createRemoteAppComponent(r) {
|
|
2459
2450
|
return defineAsyncComponent({
|
|
2460
|
-
__APP_VERSION__: "0.22.
|
|
2451
|
+
__APP_VERSION__: "0.22.1",
|
|
2461
2452
|
...r.asyncComponentOptions,
|
|
2462
2453
|
//@ts-ignore
|
|
2463
2454
|
loader: async () => {
|
|
@@ -2474,16 +2465,16 @@ function createRemoteAppComponent(r) {
|
|
|
2474
2465
|
info: r
|
|
2475
2466
|
}
|
|
2476
2467
|
);
|
|
2477
|
-
const
|
|
2468
|
+
const i = await r.loader(), c = i && i[Symbol.for("mf_module_id")], a = i[s];
|
|
2478
2469
|
if (LoggerInstance.debug(
|
|
2479
2470
|
"createRemoteAppComponent LazyComponent loadRemote info >>>",
|
|
2480
|
-
{ moduleName: c, module:
|
|
2481
|
-
), s in
|
|
2471
|
+
{ moduleName: c, module: i, exportName: s, basename: o, route: t }
|
|
2472
|
+
), s in i && typeof a == "function")
|
|
2482
2473
|
return {
|
|
2483
2474
|
render() {
|
|
2484
2475
|
return h(RemoteApp, {
|
|
2485
2476
|
moduleName: c,
|
|
2486
|
-
providerInfo:
|
|
2477
|
+
providerInfo: a,
|
|
2487
2478
|
basename: o,
|
|
2488
2479
|
rootAttrs: r.rootAttrs
|
|
2489
2480
|
});
|