@module-federation/bridge-vue3 0.0.0-next-20240919100820 → 0.0.0-next-20240920040817
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 +15 -3
- package/dist/index.cjs.js +22 -22
- package/dist/index.es.js +397 -395
- package/package.json +3 -3
package/dist/index.es.js
CHANGED
|
@@ -10,9 +10,9 @@ class g {
|
|
|
10
10
|
log(...e) {
|
|
11
11
|
var n, o;
|
|
12
12
|
if (this.isDebugEnabled) {
|
|
13
|
-
const r = `color: ${this.color}; font-weight: bold`,
|
|
13
|
+
const r = `color: ${this.color}; font-weight: bold`, l = `%c[${this.name}]`, u = ((o = (n = new Error().stack) == null ? void 0 : n.split(`
|
|
14
14
|
`)[2]) == null ? void 0 : o.trim()) || "Stack information not available";
|
|
15
|
-
typeof console < "u" && console.debug && console.debug(
|
|
15
|
+
typeof console < "u" && console.debug && console.debug(l, r, ...e, `
|
|
16
16
|
(${u})`);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -22,8 +22,8 @@ class g {
|
|
|
22
22
|
n = e.charCodeAt(r) + ((n << 5) - n);
|
|
23
23
|
let o = "#";
|
|
24
24
|
for (let r = 0; r < 3; r++) {
|
|
25
|
-
const
|
|
26
|
-
o += ("00" +
|
|
25
|
+
const l = n >> r * 8 & 255;
|
|
26
|
+
o += ("00" + l.toString(16)).substr(-2);
|
|
27
27
|
}
|
|
28
28
|
return o;
|
|
29
29
|
}
|
|
@@ -36,18 +36,18 @@ const LoggerInstance = new g("vue3-bridge");
|
|
|
36
36
|
function createBridgeComponent(t) {
|
|
37
37
|
const e = /* @__PURE__ */ new Map();
|
|
38
38
|
return () => ({
|
|
39
|
-
__APP_VERSION__: "0.6.
|
|
39
|
+
__APP_VERSION__: "0.6.6",
|
|
40
40
|
render(n) {
|
|
41
|
-
var
|
|
41
|
+
var s;
|
|
42
42
|
LoggerInstance.log("createBridgeComponent render Info", n);
|
|
43
43
|
const o = Vue.createApp(t.rootComponent);
|
|
44
|
-
e.set(n.dom, o), (
|
|
44
|
+
e.set(n.dom, o), (s = t == null ? void 0 : t.renderLifecycle) == null || s.call(t, n);
|
|
45
45
|
const r = t.appOptions({
|
|
46
46
|
basename: n.basename,
|
|
47
47
|
memoryRoute: n.memoryRoute
|
|
48
|
-
}),
|
|
48
|
+
}), l = n.memoryRoute ? VueRouter.createMemoryHistory(n.basename) : VueRouter.createWebHistory(n.basename), u = VueRouter.createRouter({
|
|
49
49
|
...r.router.options,
|
|
50
|
-
history:
|
|
50
|
+
history: l,
|
|
51
51
|
routes: r.router.getRoutes()
|
|
52
52
|
});
|
|
53
53
|
LoggerInstance.log("createBridgeComponent render router info>>>", {
|
|
@@ -78,9 +78,9 @@ function _extends$1() {
|
|
|
78
78
|
function _object_without_properties_loose(t, e) {
|
|
79
79
|
if (t == null)
|
|
80
80
|
return {};
|
|
81
|
-
var n = {}, o = Object.keys(t), r,
|
|
82
|
-
for (
|
|
83
|
-
r = o[
|
|
81
|
+
var n = {}, o = Object.keys(t), r, l;
|
|
82
|
+
for (l = 0; l < o.length; l++)
|
|
83
|
+
r = o[l], !(e.indexOf(r) >= 0) && (n[r] = t[r]);
|
|
84
84
|
return n;
|
|
85
85
|
}
|
|
86
86
|
function _extends() {
|
|
@@ -154,8 +154,8 @@ const simpleJoinRemoteEntry = (t, e) => {
|
|
|
154
154
|
if (r.startsWith("./"))
|
|
155
155
|
return r.replace("./", "");
|
|
156
156
|
if (r.startsWith("/")) {
|
|
157
|
-
const
|
|
158
|
-
return
|
|
157
|
+
const l = r.slice(1);
|
|
158
|
+
return l.endsWith("/") ? l.slice(0, -1) : l;
|
|
159
159
|
}
|
|
160
160
|
return r;
|
|
161
161
|
})(t);
|
|
@@ -166,23 +166,23 @@ function inferAutoPublicPath(t) {
|
|
|
166
166
|
}
|
|
167
167
|
function generateSnapshotFromManifest(t, e = {}) {
|
|
168
168
|
var n, o;
|
|
169
|
-
const { remotes: r = {}, overrides:
|
|
170
|
-
let
|
|
171
|
-
const d = () => "publicPath" in t.metaData ? t.metaData.publicPath === "auto" && u ? inferAutoPublicPath(u) : t.metaData.publicPath : t.metaData.getPublicPath, p = Object.keys(
|
|
172
|
-
let
|
|
169
|
+
const { remotes: r = {}, overrides: l = {}, version: u } = e;
|
|
170
|
+
let s;
|
|
171
|
+
const d = () => "publicPath" in t.metaData ? t.metaData.publicPath === "auto" && u ? inferAutoPublicPath(u) : t.metaData.publicPath : t.metaData.getPublicPath, p = Object.keys(l);
|
|
172
|
+
let _ = {};
|
|
173
173
|
if (!Object.keys(r).length) {
|
|
174
|
-
var
|
|
175
|
-
|
|
174
|
+
var y;
|
|
175
|
+
_ = ((y = t.remotes) == null ? void 0 : y.reduce((R, O) => {
|
|
176
176
|
let P;
|
|
177
177
|
const w = O.federationContainerName;
|
|
178
|
-
return p.includes(w) ? P =
|
|
178
|
+
return p.includes(w) ? P = l[w] : "version" in O ? P = O.version : P = O.entry, R[w] = {
|
|
179
179
|
matchedVersion: P
|
|
180
180
|
}, R;
|
|
181
181
|
}, {})) || {};
|
|
182
182
|
}
|
|
183
|
-
Object.keys(r).forEach((R) =>
|
|
183
|
+
Object.keys(r).forEach((R) => _[R] = {
|
|
184
184
|
// overrides will override dependencies
|
|
185
|
-
matchedVersion: p.includes(R) ?
|
|
185
|
+
matchedVersion: p.includes(R) ? l[R] : r[R]
|
|
186
186
|
});
|
|
187
187
|
const { remoteEntry: { path: m, name: b, type: S }, types: $, buildInfo: { buildVersion: E }, globalName: v, ssrRemoteEntry: T } = t.metaData, { exposes: A } = t;
|
|
188
188
|
let I = {
|
|
@@ -194,7 +194,7 @@ function generateSnapshotFromManifest(t, e = {}) {
|
|
|
194
194
|
remoteTypes: simpleJoinRemoteEntry($.path, $.name),
|
|
195
195
|
remoteTypesZip: $.zip || "",
|
|
196
196
|
remoteTypesAPI: $.api || "",
|
|
197
|
-
remotesInfo:
|
|
197
|
+
remotesInfo: _,
|
|
198
198
|
shared: t == null ? void 0 : t.shared.map((R) => ({
|
|
199
199
|
assets: R.assets,
|
|
200
200
|
sharedName: R.name,
|
|
@@ -219,15 +219,15 @@ function generateSnapshotFromManifest(t, e = {}) {
|
|
|
219
219
|
prefetchEntryType: P
|
|
220
220
|
});
|
|
221
221
|
}
|
|
222
|
-
if ("publicPath" in t.metaData ?
|
|
222
|
+
if ("publicPath" in t.metaData ? s = _extends({}, I, {
|
|
223
223
|
publicPath: d()
|
|
224
|
-
}) :
|
|
224
|
+
}) : s = _extends({}, I, {
|
|
225
225
|
getPublicPath: d()
|
|
226
226
|
}), T) {
|
|
227
227
|
const R = simpleJoinRemoteEntry(T.path, T.name);
|
|
228
|
-
|
|
228
|
+
s.ssrRemoteEntry = R, s.ssrRemoteEntryType = "commonjs-module";
|
|
229
229
|
}
|
|
230
|
-
return
|
|
230
|
+
return s;
|
|
231
231
|
}
|
|
232
232
|
function isManifestProvider(t) {
|
|
233
233
|
return !!("remoteEntry" in t && t.remoteEntry.includes(MANIFEST_EXT));
|
|
@@ -246,9 +246,9 @@ function isStaticResourcesEqual(t, e) {
|
|
|
246
246
|
}
|
|
247
247
|
function createScript(t) {
|
|
248
248
|
let e = null, n = !0, o = 2e4, r;
|
|
249
|
-
const
|
|
250
|
-
for (let
|
|
251
|
-
const d = s
|
|
249
|
+
const l = document.getElementsByTagName("script");
|
|
250
|
+
for (let s = 0; s < l.length; s++) {
|
|
251
|
+
const d = l[s], p = d.getAttribute("src");
|
|
252
252
|
if (p && isStaticResourcesEqual(p, t.url)) {
|
|
253
253
|
e = d, n = !1;
|
|
254
254
|
break;
|
|
@@ -256,27 +256,27 @@ function createScript(t) {
|
|
|
256
256
|
}
|
|
257
257
|
if (!e) {
|
|
258
258
|
e = document.createElement("script"), e.type = "text/javascript", e.src = t.url;
|
|
259
|
-
let
|
|
260
|
-
t.createScriptHook && (
|
|
259
|
+
let s;
|
|
260
|
+
t.createScriptHook && (s = t.createScriptHook(t.url, t.attrs), s instanceof HTMLScriptElement ? e = s : typeof s == "object" && ("script" in s && s.script && (e = s.script), "timeout" in s && s.timeout && (o = s.timeout)));
|
|
261
261
|
const d = t.attrs;
|
|
262
|
-
d && !
|
|
262
|
+
d && !s && Object.keys(d).forEach((p) => {
|
|
263
263
|
e && (p === "async" || p === "defer" ? e[p] = d[p] : e.getAttribute(p) || e.setAttribute(p, d[p]));
|
|
264
264
|
});
|
|
265
265
|
}
|
|
266
|
-
const u = async (
|
|
266
|
+
const u = async (s, d) => {
|
|
267
267
|
var p;
|
|
268
268
|
if (clearTimeout(r), e && (e.onerror = null, e.onload = null, safeWrapper(() => {
|
|
269
269
|
const { needDeleteScript: m = !0 } = t;
|
|
270
270
|
m && e != null && e.parentNode && e.parentNode.removeChild(e);
|
|
271
|
-
}),
|
|
272
|
-
var
|
|
273
|
-
const m =
|
|
271
|
+
}), s && typeof s == "function")) {
|
|
272
|
+
var _;
|
|
273
|
+
const m = s(d);
|
|
274
274
|
if (m instanceof Promise) {
|
|
275
|
-
var
|
|
275
|
+
var y;
|
|
276
276
|
const b = await m;
|
|
277
|
-
return t == null || (
|
|
277
|
+
return t == null || (y = t.cb) == null || y.call(t), b;
|
|
278
278
|
}
|
|
279
|
-
return t == null || (
|
|
279
|
+
return t == null || (_ = t.cb) == null || _.call(t), m;
|
|
280
280
|
}
|
|
281
281
|
t == null || (p = t.cb) == null || p.call(t);
|
|
282
282
|
};
|
|
@@ -290,28 +290,28 @@ function createScript(t) {
|
|
|
290
290
|
function createLink(t) {
|
|
291
291
|
let e = null, n = !0;
|
|
292
292
|
const o = document.getElementsByTagName("link");
|
|
293
|
-
for (let
|
|
294
|
-
const u = o[
|
|
295
|
-
if (
|
|
293
|
+
for (let l = 0; l < o.length; l++) {
|
|
294
|
+
const u = o[l], s = u.getAttribute("href"), d = u.getAttribute("ref");
|
|
295
|
+
if (s && isStaticResourcesEqual(s, t.url) && d === t.attrs.ref) {
|
|
296
296
|
e = u, n = !1;
|
|
297
297
|
break;
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
if (!e) {
|
|
301
301
|
e = document.createElement("link"), e.setAttribute("href", t.url);
|
|
302
|
-
let
|
|
302
|
+
let l;
|
|
303
303
|
const u = t.attrs;
|
|
304
|
-
t.createLinkHook && (
|
|
305
|
-
e && !e.getAttribute(
|
|
304
|
+
t.createLinkHook && (l = t.createLinkHook(t.url, u), l instanceof HTMLLinkElement && (e = l)), u && !l && Object.keys(u).forEach((s) => {
|
|
305
|
+
e && !e.getAttribute(s) && e.setAttribute(s, u[s]);
|
|
306
306
|
});
|
|
307
307
|
}
|
|
308
|
-
const r = (
|
|
308
|
+
const r = (l, u) => {
|
|
309
309
|
if (e && (e.onerror = null, e.onload = null, safeWrapper(() => {
|
|
310
|
-
const { needDeleteLink:
|
|
311
|
-
|
|
312
|
-
}),
|
|
313
|
-
const
|
|
314
|
-
return t.cb(),
|
|
310
|
+
const { needDeleteLink: s = !0 } = t;
|
|
311
|
+
s && e != null && e.parentNode && e.parentNode.removeChild(e);
|
|
312
|
+
}), l)) {
|
|
313
|
+
const s = l(u);
|
|
314
|
+
return t.cb(), s;
|
|
315
315
|
}
|
|
316
316
|
t.cb();
|
|
317
317
|
};
|
|
@@ -322,8 +322,8 @@ function createLink(t) {
|
|
|
322
322
|
}
|
|
323
323
|
function loadScript(t, e) {
|
|
324
324
|
const { attrs: n = {}, createScriptHook: o } = e;
|
|
325
|
-
return new Promise((r,
|
|
326
|
-
const { script: u, needAttach:
|
|
325
|
+
return new Promise((r, l) => {
|
|
326
|
+
const { script: u, needAttach: s } = createScript({
|
|
327
327
|
url: t,
|
|
328
328
|
cb: r,
|
|
329
329
|
attrs: _extends({
|
|
@@ -332,7 +332,7 @@ function loadScript(t, e) {
|
|
|
332
332
|
createScriptHook: o,
|
|
333
333
|
needDeleteScript: !0
|
|
334
334
|
});
|
|
335
|
-
|
|
335
|
+
s && document.head.appendChild(u);
|
|
336
336
|
});
|
|
337
337
|
}
|
|
338
338
|
function importNodeModule(t) {
|
|
@@ -346,7 +346,7 @@ const loadNodeFetch = async () => {
|
|
|
346
346
|
const t = await importNodeModule("node-fetch");
|
|
347
347
|
return t.default || t;
|
|
348
348
|
}, lazyLoaderHookFetch = async (t, e) => {
|
|
349
|
-
const n = __webpack_require__.federation.instance.loaderHook, r = await ((
|
|
349
|
+
const n = __webpack_require__.federation.instance.loaderHook, r = await ((l, u) => n.lifecycle.fetch.emit(l, u))(t, e || {});
|
|
350
350
|
return !r || !(r instanceof Response) ? (typeof fetch > "u" ? await loadNodeFetch() : fetch)(t, e || {}) : r;
|
|
351
351
|
};
|
|
352
352
|
function createScriptNode(url, cb, attrs, createScriptHook) {
|
|
@@ -406,12 +406,12 @@ function createScriptNode(url, cb, attrs, createScriptHook) {
|
|
|
406
406
|
}
|
|
407
407
|
function loadScriptNode(t, e) {
|
|
408
408
|
return new Promise((n, o) => {
|
|
409
|
-
createScriptNode(t, (r,
|
|
409
|
+
createScriptNode(t, (r, l) => {
|
|
410
410
|
if (r)
|
|
411
411
|
o(r);
|
|
412
412
|
else {
|
|
413
|
-
var u,
|
|
414
|
-
const d = (e == null || (u = e.attrs) == null ? void 0 : u.globalName) || `__FEDERATION_${e == null || (
|
|
413
|
+
var u, s;
|
|
414
|
+
const d = (e == null || (u = e.attrs) == null ? void 0 : u.globalName) || `__FEDERATION_${e == null || (s = e.attrs) == null ? void 0 : s.name}:custom__`, p = globalThis[d] = l;
|
|
415
415
|
n(p);
|
|
416
416
|
}
|
|
417
417
|
}, e.attrs, e.createScriptHook);
|
|
@@ -493,7 +493,7 @@ function includeOwnProperty(t, e) {
|
|
|
493
493
|
includeOwnProperty(globalThis, "__GLOBAL_LOADING_REMOTE_ENTRY__") || definePropertyGlobalVal(globalThis, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});
|
|
494
494
|
const globalLoading = globalThis.__GLOBAL_LOADING_REMOTE_ENTRY__;
|
|
495
495
|
function setGlobalDefaultVal(t) {
|
|
496
|
-
var e, n, o, r,
|
|
496
|
+
var e, n, o, r, l, u;
|
|
497
497
|
includeOwnProperty(t, "__VMOK__") && !includeOwnProperty(t, "__FEDERATION__") && definePropertyGlobalVal(t, "__FEDERATION__", t.__VMOK__), includeOwnProperty(t, "__FEDERATION__") || (definePropertyGlobalVal(t, "__FEDERATION__", {
|
|
498
498
|
__GLOBAL_PLUGIN__: [],
|
|
499
499
|
__INSTANCES__: [],
|
|
@@ -502,16 +502,16 @@ function setGlobalDefaultVal(t) {
|
|
|
502
502
|
__MANIFEST_LOADING__: {},
|
|
503
503
|
__PRELOADED_MAP__: /* @__PURE__ */ new Map()
|
|
504
504
|
}), definePropertyGlobalVal(t, "__VMOK__", t.__FEDERATION__));
|
|
505
|
-
var
|
|
506
|
-
(
|
|
505
|
+
var s;
|
|
506
|
+
(s = (e = t.__FEDERATION__).__GLOBAL_PLUGIN__) != null || (e.__GLOBAL_PLUGIN__ = []);
|
|
507
507
|
var d;
|
|
508
508
|
(d = (n = t.__FEDERATION__).__INSTANCES__) != null || (n.__INSTANCES__ = []);
|
|
509
509
|
var p;
|
|
510
510
|
(p = (o = t.__FEDERATION__).moduleInfo) != null || (o.moduleInfo = {});
|
|
511
|
-
var y;
|
|
512
|
-
(y = (r = t.__FEDERATION__).__SHARE__) != null || (r.__SHARE__ = {});
|
|
513
511
|
var _;
|
|
514
|
-
(_ = (
|
|
512
|
+
(_ = (r = t.__FEDERATION__).__SHARE__) != null || (r.__SHARE__ = {});
|
|
513
|
+
var y;
|
|
514
|
+
(y = (l = t.__FEDERATION__).__MANIFEST_LOADING__) != null || (l.__MANIFEST_LOADING__ = {});
|
|
515
515
|
var m;
|
|
516
516
|
(m = (u = t.__FEDERATION__).__PRELOADED_MAP__) != null || (u.__PRELOADED_MAP__ = /* @__PURE__ */ new Map());
|
|
517
517
|
}
|
|
@@ -531,7 +531,7 @@ function getGlobalFederationConstructor() {
|
|
|
531
531
|
return globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__;
|
|
532
532
|
}
|
|
533
533
|
function setGlobalFederationConstructor(t, e = isDebugMode()) {
|
|
534
|
-
e && (globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = t, globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.
|
|
534
|
+
e && (globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = t, globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.6");
|
|
535
535
|
}
|
|
536
536
|
function getInfoWithoutType(t, e) {
|
|
537
537
|
if (typeof e == "string") {
|
|
@@ -543,11 +543,11 @@ function getInfoWithoutType(t, e) {
|
|
|
543
543
|
{
|
|
544
544
|
const o = Object.keys(t);
|
|
545
545
|
for (const r of o) {
|
|
546
|
-
const [
|
|
546
|
+
const [l, u] = r.split(":"), s = `${l}:${e}`, d = t[s];
|
|
547
547
|
if (d)
|
|
548
548
|
return {
|
|
549
549
|
value: d,
|
|
550
|
-
key:
|
|
550
|
+
key: s
|
|
551
551
|
};
|
|
552
552
|
}
|
|
553
553
|
return {
|
|
@@ -563,11 +563,11 @@ const getGlobalSnapshot = () => nativeGlobal.__FEDERATION__.moduleInfo, getTarge
|
|
|
563
563
|
if (o && !o.version && "version" in t && t.version && (o.version = t.version), o)
|
|
564
564
|
return o;
|
|
565
565
|
if ("version" in t && t.version) {
|
|
566
|
-
const { version: r } = t,
|
|
566
|
+
const { version: r } = t, l = _object_without_properties_loose(t, [
|
|
567
567
|
"version"
|
|
568
|
-
]), u = getFMId(
|
|
569
|
-
if ((
|
|
570
|
-
return
|
|
568
|
+
]), u = getFMId(l), s = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, u).value;
|
|
569
|
+
if ((s == null ? void 0 : s.version) === r)
|
|
570
|
+
return s;
|
|
571
571
|
}
|
|
572
572
|
}, getGlobalSnapshotInfoByModuleInfo = (t) => getTargetSnapshotInfoByModuleInfo(t, nativeGlobal.__FEDERATION__.moduleInfo), setGlobalSnapshotInfoByModuleInfo = (t, e) => {
|
|
573
573
|
const n = getFMId(t);
|
|
@@ -631,8 +631,8 @@ class AsyncHook extends SyncHook {
|
|
|
631
631
|
const o = Array.from(this.listeners);
|
|
632
632
|
if (o.length > 0) {
|
|
633
633
|
let r = 0;
|
|
634
|
-
const
|
|
635
|
-
n =
|
|
634
|
+
const l = (u) => u === !1 ? !1 : r < o.length ? Promise.resolve(o[r++].apply(null, e)).then(l) : u;
|
|
635
|
+
n = l();
|
|
636
636
|
}
|
|
637
637
|
return Promise.resolve(n);
|
|
638
638
|
}
|
|
@@ -674,19 +674,19 @@ class AsyncWaterfallHook extends SyncHook {
|
|
|
674
674
|
const n = Array.from(this.listeners);
|
|
675
675
|
if (n.length > 0) {
|
|
676
676
|
let o = 0;
|
|
677
|
-
const r = (u) => (warn(u), this.onerror(u), e),
|
|
677
|
+
const r = (u) => (warn(u), this.onerror(u), e), l = (u) => {
|
|
678
678
|
if (checkReturnData(e, u)) {
|
|
679
679
|
if (e = u, o < n.length)
|
|
680
680
|
try {
|
|
681
|
-
return Promise.resolve(n[o++](e)).then(
|
|
682
|
-
} catch (
|
|
683
|
-
return r(
|
|
681
|
+
return Promise.resolve(n[o++](e)).then(l, r);
|
|
682
|
+
} catch (s) {
|
|
683
|
+
return r(s);
|
|
684
684
|
}
|
|
685
685
|
} else
|
|
686
686
|
this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
|
|
687
687
|
return e;
|
|
688
688
|
};
|
|
689
|
-
return Promise.resolve(
|
|
689
|
+
return Promise.resolve(l(e));
|
|
690
690
|
}
|
|
691
691
|
return Promise.resolve(e);
|
|
692
692
|
}
|
|
@@ -740,7 +740,7 @@ function combineVersion(t, e, n, o) {
|
|
|
740
740
|
return o ? `${r}-${o}` : r;
|
|
741
741
|
}
|
|
742
742
|
function parseHyphen(t) {
|
|
743
|
-
return t.replace(parseRegex(hyphenRange), (e, n, o, r,
|
|
743
|
+
return t.replace(parseRegex(hyphenRange), (e, n, o, r, l, u, s, d, p, _, y, m) => (isXVersion(o) ? n = "" : isXVersion(r) ? n = `>=${o}.0.0` : isXVersion(l) ? n = `>=${o}.${r}.0` : n = `>=${n}`, isXVersion(p) ? d = "" : isXVersion(_) ? d = `<${Number(p) + 1}.0.0-0` : isXVersion(y) ? d = `<${p}.${Number(_) + 1}.0-0` : m ? d = `<=${p}.${_}.${y}-${m}` : d = `<=${d}`, `${n} ${d}`.trim()));
|
|
744
744
|
}
|
|
745
745
|
function parseComparatorTrim(t) {
|
|
746
746
|
return t.replace(parseRegex(comparatorTrim), "$1$2$3");
|
|
@@ -752,15 +752,15 @@ function parseCaretTrim(t) {
|
|
|
752
752
|
return t.replace(parseRegex(caretTrim), "$1^");
|
|
753
753
|
}
|
|
754
754
|
function parseCarets(t) {
|
|
755
|
-
return t.trim().split(/\s+/).map((e) => e.replace(parseRegex(caret), (n, o, r,
|
|
755
|
+
return t.trim().split(/\s+/).map((e) => e.replace(parseRegex(caret), (n, o, r, l, u) => isXVersion(o) ? "" : isXVersion(r) ? `>=${o}.0.0 <${Number(o) + 1}.0.0-0` : isXVersion(l) ? o === "0" ? `>=${o}.${r}.0 <${o}.${Number(r) + 1}.0-0` : `>=${o}.${r}.0 <${Number(o) + 1}.0.0-0` : u ? o === "0" ? r === "0" ? `>=${o}.${r}.${l}-${u} <${o}.${r}.${Number(l) + 1}-0` : `>=${o}.${r}.${l}-${u} <${o}.${Number(r) + 1}.0-0` : `>=${o}.${r}.${l}-${u} <${Number(o) + 1}.0.0-0` : o === "0" ? r === "0" ? `>=${o}.${r}.${l} <${o}.${r}.${Number(l) + 1}-0` : `>=${o}.${r}.${l} <${o}.${Number(r) + 1}.0-0` : `>=${o}.${r}.${l} <${Number(o) + 1}.0.0-0`)).join(" ");
|
|
756
756
|
}
|
|
757
757
|
function parseTildes(t) {
|
|
758
|
-
return t.trim().split(/\s+/).map((e) => e.replace(parseRegex(tilde), (n, o, r,
|
|
758
|
+
return t.trim().split(/\s+/).map((e) => e.replace(parseRegex(tilde), (n, o, r, l, u) => isXVersion(o) ? "" : isXVersion(r) ? `>=${o}.0.0 <${Number(o) + 1}.0.0-0` : isXVersion(l) ? `>=${o}.${r}.0 <${o}.${Number(r) + 1}.0-0` : u ? `>=${o}.${r}.${l}-${u} <${o}.${Number(r) + 1}.0-0` : `>=${o}.${r}.${l} <${o}.${Number(r) + 1}.0-0`)).join(" ");
|
|
759
759
|
}
|
|
760
760
|
function parseXRanges(t) {
|
|
761
|
-
return t.split(/\s+/).map((e) => e.trim().replace(parseRegex(xRange), (n, o, r,
|
|
762
|
-
const d = isXVersion(r), p = d || isXVersion(
|
|
763
|
-
return o === "=" &&
|
|
761
|
+
return t.split(/\s+/).map((e) => e.trim().replace(parseRegex(xRange), (n, o, r, l, u, s) => {
|
|
762
|
+
const d = isXVersion(r), p = d || isXVersion(l), _ = p || isXVersion(u);
|
|
763
|
+
return o === "=" && _ && (o = ""), s = "", d ? o === ">" || o === "<" ? "<0.0.0-0" : "*" : o && _ ? (p && (l = 0), u = 0, o === ">" ? (o = ">=", p ? (r = Number(r) + 1, l = 0, u = 0) : (l = Number(l) + 1, u = 0)) : o === "<=" && (o = "<", p ? r = Number(r) + 1 : l = Number(l) + 1), o === "<" && (s = "-0"), `${o + r}.${l}.${u}${s}`) : p ? `>=${r}.0.0${s} <${Number(r) + 1}.0.0-0` : _ ? `>=${r}.${l}.0${s} <${r}.${Number(l) + 1}.0-0` : n;
|
|
764
764
|
})).join(" ");
|
|
765
765
|
}
|
|
766
766
|
function parseStar(t) {
|
|
@@ -780,10 +780,10 @@ function comparePreRelease(t, e) {
|
|
|
780
780
|
return -1;
|
|
781
781
|
if (n === void 0 && o === void 0)
|
|
782
782
|
return 0;
|
|
783
|
-
for (let r = 0,
|
|
784
|
-
const u = n[r],
|
|
785
|
-
if (u !==
|
|
786
|
-
return u === void 0 &&
|
|
783
|
+
for (let r = 0, l = n.length; r <= l; r++) {
|
|
784
|
+
const u = n[r], s = o[r];
|
|
785
|
+
if (u !== s)
|
|
786
|
+
return u === void 0 && s === void 0 ? 0 : u ? s ? compareAtom(u, s) : -1 : 1;
|
|
787
787
|
}
|
|
788
788
|
return 0;
|
|
789
789
|
}
|
|
@@ -853,16 +853,16 @@ function parseRange(t) {
|
|
|
853
853
|
function satisfy(t, e) {
|
|
854
854
|
if (!t)
|
|
855
855
|
return !1;
|
|
856
|
-
const r = parseRange(e).split(" ").map((m) => parseComparatorString(m)).join(" ").split(/\s+/).map((m) => parseGTE0(m)),
|
|
857
|
-
if (!
|
|
856
|
+
const r = parseRange(e).split(" ").map((m) => parseComparatorString(m)).join(" ").split(/\s+/).map((m) => parseGTE0(m)), l = extractComparator(t);
|
|
857
|
+
if (!l)
|
|
858
858
|
return !1;
|
|
859
|
-
const [, u, ,
|
|
859
|
+
const [, u, , s, d, p, _] = l, y = {
|
|
860
860
|
operator: u,
|
|
861
|
-
version: combineVersion(
|
|
862
|
-
major:
|
|
861
|
+
version: combineVersion(s, d, p, _),
|
|
862
|
+
major: s,
|
|
863
863
|
minor: d,
|
|
864
864
|
patch: p,
|
|
865
|
-
preRelease:
|
|
865
|
+
preRelease: _ == null ? void 0 : _.split(".")
|
|
866
866
|
};
|
|
867
867
|
for (const m of r) {
|
|
868
868
|
const b = extractComparator(m);
|
|
@@ -876,7 +876,7 @@ function satisfy(t, e) {
|
|
|
876
876
|
patch: v,
|
|
877
877
|
preRelease: T == null ? void 0 : T.split(".")
|
|
878
878
|
};
|
|
879
|
-
if (!compare(A,
|
|
879
|
+
if (!compare(A, y))
|
|
880
880
|
return !1;
|
|
881
881
|
}
|
|
882
882
|
return !0;
|
|
@@ -886,7 +886,7 @@ function formatShare(t, e, n, o) {
|
|
|
886
886
|
"get" in t ? r = t.get : "lib" in t ? r = () => Promise.resolve(t.lib) : r = () => Promise.resolve(() => {
|
|
887
887
|
throw new Error(`Can not get shared '${n}'!`);
|
|
888
888
|
}), t.strategy && warn('"shared.strategy is deprecated, please set in initOptions.shareStrategy instead!"');
|
|
889
|
-
var
|
|
889
|
+
var l, u, s;
|
|
890
890
|
return _extends$1({
|
|
891
891
|
deps: [],
|
|
892
892
|
useIn: [],
|
|
@@ -901,35 +901,35 @@ function formatShare(t, e, n, o) {
|
|
|
901
901
|
}, t.shareConfig),
|
|
902
902
|
get: r,
|
|
903
903
|
loaded: t != null && t.loaded || "lib" in t ? !0 : void 0,
|
|
904
|
-
version: (
|
|
904
|
+
version: (l = t.version) != null ? l : "0",
|
|
905
905
|
scope: Array.isArray(t.scope) ? t.scope : [
|
|
906
906
|
(u = t.scope) != null ? u : "default"
|
|
907
907
|
],
|
|
908
|
-
strategy: ((
|
|
908
|
+
strategy: ((s = t.strategy) != null ? s : o) || "version-first"
|
|
909
909
|
});
|
|
910
910
|
}
|
|
911
911
|
function formatShareConfigs(t, e) {
|
|
912
|
-
const n = e.shared || {}, o = e.name, r = Object.keys(n).reduce((u,
|
|
913
|
-
const d = arrayOptions(n[
|
|
914
|
-
return u[
|
|
915
|
-
u[
|
|
912
|
+
const n = e.shared || {}, o = e.name, r = Object.keys(n).reduce((u, s) => {
|
|
913
|
+
const d = arrayOptions(n[s]);
|
|
914
|
+
return u[s] = u[s] || [], d.forEach((p) => {
|
|
915
|
+
u[s].push(formatShare(p, o, s, e.shareStrategy));
|
|
916
916
|
}), u;
|
|
917
|
-
}, {}),
|
|
917
|
+
}, {}), l = _extends$1({}, t.shared);
|
|
918
918
|
return Object.keys(r).forEach((u) => {
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
}) :
|
|
919
|
+
l[u] ? r[u].forEach((s) => {
|
|
920
|
+
l[u].find((p) => p.version === s.version) || l[u].push(s);
|
|
921
|
+
}) : l[u] = r[u];
|
|
922
922
|
}), {
|
|
923
|
-
shared:
|
|
923
|
+
shared: l,
|
|
924
924
|
shareInfos: r
|
|
925
925
|
};
|
|
926
926
|
}
|
|
927
927
|
function versionLt(t, e) {
|
|
928
928
|
const n = (o) => {
|
|
929
929
|
if (!Number.isNaN(Number(o))) {
|
|
930
|
-
const
|
|
930
|
+
const l = o.split(".");
|
|
931
931
|
let u = o;
|
|
932
|
-
for (let
|
|
932
|
+
for (let s = 0; s < 3 - l.length; s++)
|
|
933
933
|
u += ".0";
|
|
934
934
|
return u;
|
|
935
935
|
}
|
|
@@ -944,14 +944,14 @@ const findVersion = (t, e) => {
|
|
|
944
944
|
return Object.keys(t).reduce((o, r) => !o || n(o, r) || o === "0" ? r : o, 0);
|
|
945
945
|
}, isLoaded = (t) => !!t.loaded || typeof t.lib == "function";
|
|
946
946
|
function findSingletonVersionOrderByVersion(t, e, n) {
|
|
947
|
-
const o = t[e][n], r = function(
|
|
948
|
-
return !isLoaded(o[
|
|
947
|
+
const o = t[e][n], r = function(l, u) {
|
|
948
|
+
return !isLoaded(o[l]) && versionLt(l, u);
|
|
949
949
|
};
|
|
950
950
|
return findVersion(t[e][n], r);
|
|
951
951
|
}
|
|
952
952
|
function findSingletonVersionOrderByLoaded(t, e, n) {
|
|
953
|
-
const o = t[e][n], r = function(
|
|
954
|
-
return isLoaded(o[u]) ? isLoaded(o[
|
|
953
|
+
const o = t[e][n], r = function(l, u) {
|
|
954
|
+
return isLoaded(o[u]) ? isLoaded(o[l]) ? !!versionLt(l, u) : !0 : isLoaded(o[l]) ? !1 : versionLt(l, u);
|
|
955
955
|
};
|
|
956
956
|
return findVersion(t[e][n], r);
|
|
957
957
|
}
|
|
@@ -961,21 +961,21 @@ function getFindShareFunction(t) {
|
|
|
961
961
|
function getRegisteredShare(t, e, n, o) {
|
|
962
962
|
if (!t)
|
|
963
963
|
return;
|
|
964
|
-
const { shareConfig: r, scope:
|
|
965
|
-
|
|
964
|
+
const { shareConfig: r, scope: l = DEFAULT_SCOPE, strategy: u } = n, s = Array.isArray(l) ? l : [
|
|
965
|
+
l
|
|
966
966
|
];
|
|
967
|
-
for (const d of
|
|
967
|
+
for (const d of s)
|
|
968
968
|
if (r && t[d] && t[d][e]) {
|
|
969
|
-
const { requiredVersion: p } = r,
|
|
969
|
+
const { requiredVersion: p } = r, y = getFindShareFunction(u)(t, d, e), m = () => {
|
|
970
970
|
if (r.singleton) {
|
|
971
|
-
if (typeof p == "string" && !satisfy(
|
|
972
|
-
const $ = `Version ${
|
|
971
|
+
if (typeof p == "string" && !satisfy(y, p)) {
|
|
972
|
+
const $ = `Version ${y} from ${y && t[d][e][y].from} of shared singleton module ${e} does not satisfy the requirement of ${n.from} which needs ${p})`;
|
|
973
973
|
r.strictVersion ? error($) : warn($);
|
|
974
974
|
}
|
|
975
|
-
return t[d][e][
|
|
975
|
+
return t[d][e][y];
|
|
976
976
|
} else {
|
|
977
|
-
if (p === !1 || p === "*" || satisfy(
|
|
978
|
-
return t[d][e][
|
|
977
|
+
if (p === !1 || p === "*" || satisfy(y, p))
|
|
978
|
+
return t[d][e][y];
|
|
979
979
|
for (const [$, E] of Object.entries(t[d][e]))
|
|
980
980
|
if (satisfy($, p))
|
|
981
981
|
return E;
|
|
@@ -984,7 +984,7 @@ function getRegisteredShare(t, e, n, o) {
|
|
|
984
984
|
shareScopeMap: t,
|
|
985
985
|
scope: d,
|
|
986
986
|
pkgName: e,
|
|
987
|
-
version:
|
|
987
|
+
version: y,
|
|
988
988
|
GlobalFederation: Global.__FEDERATION__,
|
|
989
989
|
resolver: m
|
|
990
990
|
};
|
|
@@ -995,20 +995,20 @@ function getGlobalShareScope() {
|
|
|
995
995
|
return Global.__FEDERATION__.__SHARE__;
|
|
996
996
|
}
|
|
997
997
|
function getTargetSharedOptions(t) {
|
|
998
|
-
const { pkgName: e, extraOptions: n, shareInfos: o } = t, r = (
|
|
999
|
-
if (!
|
|
998
|
+
const { pkgName: e, extraOptions: n, shareInfos: o } = t, r = (s) => {
|
|
999
|
+
if (!s)
|
|
1000
1000
|
return;
|
|
1001
1001
|
const d = {};
|
|
1002
|
-
|
|
1003
|
-
d[
|
|
1002
|
+
s.forEach((y) => {
|
|
1003
|
+
d[y.version] = y;
|
|
1004
1004
|
});
|
|
1005
|
-
const
|
|
1006
|
-
return !isLoaded(d[
|
|
1005
|
+
const _ = findVersion(d, function(y, m) {
|
|
1006
|
+
return !isLoaded(d[y]) && versionLt(y, m);
|
|
1007
1007
|
});
|
|
1008
|
-
return d[
|
|
1008
|
+
return d[_];
|
|
1009
1009
|
};
|
|
1010
|
-
var
|
|
1011
|
-
const u = (
|
|
1010
|
+
var l;
|
|
1011
|
+
const u = (l = n == null ? void 0 : n.resolver) != null ? l : r;
|
|
1012
1012
|
return Object.assign({}, u(o[e]), n == null ? void 0 : n.customShareInfo);
|
|
1013
1013
|
}
|
|
1014
1014
|
function matchRemoteWithNameAndExpose(t, e) {
|
|
@@ -1017,9 +1017,9 @@ function matchRemoteWithNameAndExpose(t, e) {
|
|
|
1017
1017
|
let r = e.replace(n.name, "");
|
|
1018
1018
|
if (o) {
|
|
1019
1019
|
if (r.startsWith("/")) {
|
|
1020
|
-
const
|
|
1020
|
+
const s = n.name;
|
|
1021
1021
|
return r = `.${r}`, {
|
|
1022
|
-
pkgNameOrAlias:
|
|
1022
|
+
pkgNameOrAlias: s,
|
|
1023
1023
|
expose: r,
|
|
1024
1024
|
remote: n
|
|
1025
1025
|
};
|
|
@@ -1030,13 +1030,13 @@ function matchRemoteWithNameAndExpose(t, e) {
|
|
|
1030
1030
|
remote: n
|
|
1031
1031
|
};
|
|
1032
1032
|
}
|
|
1033
|
-
const
|
|
1033
|
+
const l = n.alias && e.startsWith(n.alias);
|
|
1034
1034
|
let u = n.alias && e.replace(n.alias, "");
|
|
1035
|
-
if (n.alias &&
|
|
1035
|
+
if (n.alias && l) {
|
|
1036
1036
|
if (u && u.startsWith("/")) {
|
|
1037
|
-
const
|
|
1037
|
+
const s = n.alias;
|
|
1038
1038
|
return u = `.${u}`, {
|
|
1039
|
-
pkgNameOrAlias:
|
|
1039
|
+
pkgNameOrAlias: s,
|
|
1040
1040
|
expose: u,
|
|
1041
1041
|
remote: n
|
|
1042
1042
|
};
|
|
@@ -1082,30 +1082,30 @@ async function loadEntryScript({ name: t, globalName: e, entry: n, createScriptH
|
|
|
1082
1082
|
const { entryExports: r } = getRemoteEntryExports(t, e);
|
|
1083
1083
|
return r || loadScript(n, {
|
|
1084
1084
|
attrs: {},
|
|
1085
|
-
createScriptHook: (
|
|
1086
|
-
const
|
|
1087
|
-
url:
|
|
1085
|
+
createScriptHook: (l, u) => {
|
|
1086
|
+
const s = o.emit({
|
|
1087
|
+
url: l,
|
|
1088
1088
|
attrs: u
|
|
1089
1089
|
});
|
|
1090
|
-
if (
|
|
1091
|
-
return
|
|
1090
|
+
if (s && (s instanceof HTMLScriptElement || "script" in s || "timeout" in s))
|
|
1091
|
+
return s;
|
|
1092
1092
|
}
|
|
1093
1093
|
}).then(() => {
|
|
1094
|
-
const { remoteEntryKey:
|
|
1094
|
+
const { remoteEntryKey: l, entryExports: u } = getRemoteEntryExports(t, e);
|
|
1095
1095
|
return assert(u, `
|
|
1096
|
-
Unable to use the ${t}'s '${n}' URL with ${
|
|
1096
|
+
Unable to use the ${t}'s '${n}' URL with ${l}'s globalName to get remoteEntry exports.
|
|
1097
1097
|
Possible reasons could be:
|
|
1098
1098
|
|
|
1099
1099
|
1. '${n}' is not the correct URL, or the remoteEntry resource or name is incorrect.
|
|
1100
1100
|
|
|
1101
|
-
2. ${
|
|
1101
|
+
2. ${l} cannot be used to get remoteEntry exports in the window object.
|
|
1102
1102
|
`), u;
|
|
1103
|
-
}).catch((
|
|
1104
|
-
throw
|
|
1103
|
+
}).catch((l) => {
|
|
1104
|
+
throw l;
|
|
1105
1105
|
});
|
|
1106
1106
|
}
|
|
1107
1107
|
async function loadEntryDom({ remoteInfo: t, remoteEntryExports: e, createScriptHook: n }) {
|
|
1108
|
-
const { entry: o, entryGlobalName: r, name:
|
|
1108
|
+
const { entry: o, entryGlobalName: r, name: l, type: u } = t;
|
|
1109
1109
|
switch (u) {
|
|
1110
1110
|
case "esm":
|
|
1111
1111
|
case "module":
|
|
@@ -1122,36 +1122,36 @@ async function loadEntryDom({ remoteInfo: t, remoteEntryExports: e, createScript
|
|
|
1122
1122
|
return loadEntryScript({
|
|
1123
1123
|
entry: o,
|
|
1124
1124
|
globalName: r,
|
|
1125
|
-
name:
|
|
1125
|
+
name: l,
|
|
1126
1126
|
createScriptHook: n
|
|
1127
1127
|
});
|
|
1128
1128
|
}
|
|
1129
1129
|
}
|
|
1130
1130
|
async function loadEntryNode({ remoteInfo: t, createScriptHook: e }) {
|
|
1131
|
-
const { entry: n, entryGlobalName: o, name: r } = t, { entryExports:
|
|
1132
|
-
return
|
|
1131
|
+
const { entry: n, entryGlobalName: o, name: r } = t, { entryExports: l } = getRemoteEntryExports(r, o);
|
|
1132
|
+
return l || loadScriptNode(n, {
|
|
1133
1133
|
attrs: {
|
|
1134
1134
|
name: r,
|
|
1135
1135
|
globalName: o
|
|
1136
1136
|
},
|
|
1137
|
-
createScriptHook: (u,
|
|
1137
|
+
createScriptHook: (u, s) => {
|
|
1138
1138
|
const d = e.emit({
|
|
1139
1139
|
url: u,
|
|
1140
|
-
attrs:
|
|
1140
|
+
attrs: s
|
|
1141
1141
|
});
|
|
1142
1142
|
if (d && "url" in d)
|
|
1143
1143
|
return d;
|
|
1144
1144
|
}
|
|
1145
1145
|
}).then(() => {
|
|
1146
|
-
const { remoteEntryKey: u, entryExports:
|
|
1147
|
-
return assert(
|
|
1146
|
+
const { remoteEntryKey: u, entryExports: s } = getRemoteEntryExports(r, o);
|
|
1147
|
+
return assert(s, `
|
|
1148
1148
|
Unable to use the ${r}'s '${n}' URL with ${u}'s globalName to get remoteEntry exports.
|
|
1149
1149
|
Possible reasons could be:
|
|
1150
1150
|
|
|
1151
1151
|
1. '${n}' is not the correct URL, or the remoteEntry resource or name is incorrect.
|
|
1152
1152
|
|
|
1153
1153
|
2. ${u} cannot be used to get remoteEntry exports in the window object.
|
|
1154
|
-
`),
|
|
1154
|
+
`), s;
|
|
1155
1155
|
}).catch((u) => {
|
|
1156
1156
|
throw u;
|
|
1157
1157
|
});
|
|
@@ -1171,16 +1171,16 @@ async function getRemoteEntry({ origin: t, remoteEntryExports: e, remoteInfo: n
|
|
|
1171
1171
|
createScriptHook: t.loaderHook.lifecycle.createScript,
|
|
1172
1172
|
remoteInfo: n,
|
|
1173
1173
|
remoteEntryExports: e
|
|
1174
|
-
}).then((
|
|
1174
|
+
}).then((l) => l || void 0);
|
|
1175
1175
|
else {
|
|
1176
|
-
const
|
|
1176
|
+
const l = t.loaderHook.lifecycle.createScript;
|
|
1177
1177
|
isBrowserEnv() ? globalLoading[o] = loadEntryDom({
|
|
1178
1178
|
remoteInfo: n,
|
|
1179
1179
|
remoteEntryExports: e,
|
|
1180
|
-
createScriptHook:
|
|
1180
|
+
createScriptHook: l
|
|
1181
1181
|
}) : globalLoading[o] = loadEntryNode({
|
|
1182
1182
|
remoteInfo: n,
|
|
1183
|
-
createScriptHook:
|
|
1183
|
+
createScriptHook: l
|
|
1184
1184
|
});
|
|
1185
1185
|
}
|
|
1186
1186
|
}
|
|
@@ -1207,45 +1207,47 @@ let Module = class {
|
|
|
1207
1207
|
${safeToString(this.remoteInfo)}`), this.remoteEntryExports = e, this.remoteEntryExports;
|
|
1208
1208
|
}
|
|
1209
1209
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
1210
|
-
async get(e, n, o) {
|
|
1211
|
-
const { loadFactory:
|
|
1210
|
+
async get(e, n, o, r) {
|
|
1211
|
+
const { loadFactory: l = !0 } = o || {
|
|
1212
1212
|
loadFactory: !0
|
|
1213
|
-
},
|
|
1213
|
+
}, u = await this.getEntry();
|
|
1214
1214
|
if (!this.inited) {
|
|
1215
|
-
const y = this.host.shareScopeMap,
|
|
1216
|
-
y[
|
|
1217
|
-
const
|
|
1215
|
+
const y = this.host.shareScopeMap, m = this.remoteInfo.shareScope || "default";
|
|
1216
|
+
y[m] || (y[m] = {});
|
|
1217
|
+
const b = y[m], S = [], $ = {
|
|
1218
1218
|
version: this.remoteInfo.version || ""
|
|
1219
1219
|
};
|
|
1220
|
-
Object.defineProperty(
|
|
1220
|
+
Object.defineProperty($, "shareScopeMap", {
|
|
1221
1221
|
value: y,
|
|
1222
1222
|
// remoteEntryInitOptions will be traversed and assigned during container init, ,so this attribute is not allowed to be traversed
|
|
1223
1223
|
enumerable: !1
|
|
1224
1224
|
});
|
|
1225
|
-
const
|
|
1226
|
-
shareScope:
|
|
1225
|
+
const E = await this.host.hooks.lifecycle.beforeInitContainer.emit({
|
|
1226
|
+
shareScope: b,
|
|
1227
1227
|
// @ts-ignore shareScopeMap will be set by Object.defineProperty
|
|
1228
|
-
remoteEntryInitOptions:
|
|
1229
|
-
initScope:
|
|
1228
|
+
remoteEntryInitOptions: $,
|
|
1229
|
+
initScope: S,
|
|
1230
1230
|
remoteInfo: this.remoteInfo,
|
|
1231
1231
|
origin: this.host
|
|
1232
1232
|
});
|
|
1233
|
-
typeof (
|
|
1233
|
+
typeof (u == null ? void 0 : u.init) > "u" && console.error('The remote entry interface does not contain "init"', `
|
|
1234
1234
|
`, "Ensure the name of this remote is not reserved or in use. Check if anything already exists on window[nameOfRemote]", `
|
|
1235
|
-
`, "Ensure that window[nameOfRemote] is returning a {get,init} object."), await
|
|
1236
|
-
|
|
1235
|
+
`, "Ensure that window[nameOfRemote] is returning a {get,init} object."), await u.init(E.shareScope, E.initScope, E.remoteEntryInitOptions), await this.host.hooks.lifecycle.initContainer.emit(_extends$1({}, E, {
|
|
1236
|
+
id: e,
|
|
1237
|
+
remoteSnapshot: r,
|
|
1238
|
+
remoteEntryExports: u
|
|
1237
1239
|
}));
|
|
1238
1240
|
}
|
|
1239
|
-
this.lib =
|
|
1240
|
-
const
|
|
1241
|
-
assert(
|
|
1242
|
-
const
|
|
1243
|
-
return
|
|
1241
|
+
this.lib = u, this.inited = !0;
|
|
1242
|
+
const s = await u.get(n);
|
|
1243
|
+
assert(s, `${getFMId(this.remoteInfo)} remote don't export ${n}.`);
|
|
1244
|
+
const d = processModuleAlias(this.remoteInfo.name, n), p = this.wraperFactory(s, d);
|
|
1245
|
+
return l ? await p() : p;
|
|
1244
1246
|
}
|
|
1245
1247
|
wraperFactory(e, n) {
|
|
1246
|
-
function o(r,
|
|
1248
|
+
function o(r, l) {
|
|
1247
1249
|
r && typeof r == "object" && Object.isExtensible(r) && !Object.getOwnPropertyDescriptor(r, Symbol.for("mf_module_id")) && Object.defineProperty(r, Symbol.for("mf_module_id"), {
|
|
1248
|
-
value:
|
|
1250
|
+
value: l,
|
|
1249
1251
|
enumerable: !1
|
|
1250
1252
|
});
|
|
1251
1253
|
}
|
|
@@ -1285,10 +1287,10 @@ function normalizePreloadExposes(t) {
|
|
|
1285
1287
|
return t ? t.map((e) => e === "." ? e : e.startsWith("./") ? e.replace("./", "") : e) : [];
|
|
1286
1288
|
}
|
|
1287
1289
|
function preloadAssets(t, e, n, o = !0) {
|
|
1288
|
-
const { cssAssets: r, jsAssetsWithoutEntry:
|
|
1290
|
+
const { cssAssets: r, jsAssetsWithoutEntry: l, entryAssets: u } = n;
|
|
1289
1291
|
if (e.options.inBrowser) {
|
|
1290
|
-
if (u.forEach((
|
|
1291
|
-
const { moduleInfo: d } =
|
|
1292
|
+
if (u.forEach((s) => {
|
|
1293
|
+
const { moduleInfo: d } = s, p = e.moduleCache.get(t.name);
|
|
1292
1294
|
getRemoteEntry(p ? {
|
|
1293
1295
|
origin: e,
|
|
1294
1296
|
remoteInfo: d,
|
|
@@ -1299,42 +1301,42 @@ function preloadAssets(t, e, n, o = !0) {
|
|
|
1299
1301
|
remoteEntryExports: void 0
|
|
1300
1302
|
});
|
|
1301
1303
|
}), o) {
|
|
1302
|
-
const
|
|
1304
|
+
const s = {
|
|
1303
1305
|
rel: "preload",
|
|
1304
1306
|
as: "style",
|
|
1305
1307
|
crossorigin: "anonymous"
|
|
1306
1308
|
};
|
|
1307
1309
|
r.forEach((d) => {
|
|
1308
|
-
const { link: p, needAttach:
|
|
1310
|
+
const { link: p, needAttach: _ } = createLink({
|
|
1309
1311
|
url: d,
|
|
1310
1312
|
cb: () => {
|
|
1311
1313
|
},
|
|
1312
|
-
attrs:
|
|
1313
|
-
createLinkHook: (
|
|
1314
|
+
attrs: s,
|
|
1315
|
+
createLinkHook: (y, m) => {
|
|
1314
1316
|
const b = e.loaderHook.lifecycle.createLink.emit({
|
|
1315
|
-
url:
|
|
1317
|
+
url: y,
|
|
1316
1318
|
attrs: m
|
|
1317
1319
|
});
|
|
1318
1320
|
if (b instanceof HTMLLinkElement)
|
|
1319
1321
|
return b;
|
|
1320
1322
|
}
|
|
1321
1323
|
});
|
|
1322
|
-
|
|
1324
|
+
_ && document.head.appendChild(p);
|
|
1323
1325
|
});
|
|
1324
1326
|
} else {
|
|
1325
|
-
const
|
|
1327
|
+
const s = {
|
|
1326
1328
|
rel: "stylesheet",
|
|
1327
1329
|
type: "text/css"
|
|
1328
1330
|
};
|
|
1329
1331
|
r.forEach((d) => {
|
|
1330
|
-
const { link: p, needAttach:
|
|
1332
|
+
const { link: p, needAttach: _ } = createLink({
|
|
1331
1333
|
url: d,
|
|
1332
1334
|
cb: () => {
|
|
1333
1335
|
},
|
|
1334
|
-
attrs:
|
|
1335
|
-
createLinkHook: (
|
|
1336
|
+
attrs: s,
|
|
1337
|
+
createLinkHook: (y, m) => {
|
|
1336
1338
|
const b = e.loaderHook.lifecycle.createLink.emit({
|
|
1337
|
-
url:
|
|
1339
|
+
url: y,
|
|
1338
1340
|
attrs: m
|
|
1339
1341
|
});
|
|
1340
1342
|
if (b instanceof HTMLLinkElement)
|
|
@@ -1342,46 +1344,46 @@ function preloadAssets(t, e, n, o = !0) {
|
|
|
1342
1344
|
},
|
|
1343
1345
|
needDeleteLink: !1
|
|
1344
1346
|
});
|
|
1345
|
-
|
|
1347
|
+
_ && document.head.appendChild(p);
|
|
1346
1348
|
});
|
|
1347
1349
|
}
|
|
1348
1350
|
if (o) {
|
|
1349
|
-
const
|
|
1351
|
+
const s = {
|
|
1350
1352
|
rel: "preload",
|
|
1351
1353
|
as: "script",
|
|
1352
1354
|
crossorigin: "anonymous"
|
|
1353
1355
|
};
|
|
1354
|
-
|
|
1355
|
-
const { link: p, needAttach:
|
|
1356
|
+
l.forEach((d) => {
|
|
1357
|
+
const { link: p, needAttach: _ } = createLink({
|
|
1356
1358
|
url: d,
|
|
1357
1359
|
cb: () => {
|
|
1358
1360
|
},
|
|
1359
|
-
attrs:
|
|
1360
|
-
createLinkHook: (
|
|
1361
|
+
attrs: s,
|
|
1362
|
+
createLinkHook: (y, m) => {
|
|
1361
1363
|
const b = e.loaderHook.lifecycle.createLink.emit({
|
|
1362
|
-
url:
|
|
1364
|
+
url: y,
|
|
1363
1365
|
attrs: m
|
|
1364
1366
|
});
|
|
1365
1367
|
if (b instanceof HTMLLinkElement)
|
|
1366
1368
|
return b;
|
|
1367
1369
|
}
|
|
1368
1370
|
});
|
|
1369
|
-
|
|
1371
|
+
_ && document.head.appendChild(p);
|
|
1370
1372
|
});
|
|
1371
1373
|
} else {
|
|
1372
|
-
const
|
|
1374
|
+
const s = {
|
|
1373
1375
|
fetchpriority: "high",
|
|
1374
1376
|
type: (t == null ? void 0 : t.type) === "module" ? "module" : "text/javascript"
|
|
1375
1377
|
};
|
|
1376
|
-
|
|
1377
|
-
const { script: p, needAttach:
|
|
1378
|
+
l.forEach((d) => {
|
|
1379
|
+
const { script: p, needAttach: _ } = createScript({
|
|
1378
1380
|
url: d,
|
|
1379
1381
|
cb: () => {
|
|
1380
1382
|
},
|
|
1381
|
-
attrs:
|
|
1382
|
-
createScriptHook: (
|
|
1383
|
+
attrs: s,
|
|
1384
|
+
createScriptHook: (y, m) => {
|
|
1383
1385
|
const b = e.loaderHook.lifecycle.createScript.emit({
|
|
1384
|
-
url:
|
|
1386
|
+
url: y,
|
|
1385
1387
|
attrs: m
|
|
1386
1388
|
});
|
|
1387
1389
|
if (b instanceof HTMLScriptElement)
|
|
@@ -1389,7 +1391,7 @@ function preloadAssets(t, e, n, o = !0) {
|
|
|
1389
1391
|
},
|
|
1390
1392
|
needDeleteScript: !0
|
|
1391
1393
|
});
|
|
1392
|
-
|
|
1394
|
+
_ && document.head.appendChild(p);
|
|
1393
1395
|
});
|
|
1394
1396
|
}
|
|
1395
1397
|
}
|
|
@@ -1404,10 +1406,10 @@ function snapshotPlugin() {
|
|
|
1404
1406
|
return {
|
|
1405
1407
|
name: "snapshot-plugin",
|
|
1406
1408
|
async afterResolve(t) {
|
|
1407
|
-
const { remote: e, pkgNameOrAlias: n, expose: o, origin: r, remoteInfo:
|
|
1409
|
+
const { remote: e, pkgNameOrAlias: n, expose: o, origin: r, remoteInfo: l } = t;
|
|
1408
1410
|
if (!isRemoteInfoWithEntry(e) || !isPureRemoteEntry(e)) {
|
|
1409
|
-
const { remoteSnapshot: u, globalSnapshot:
|
|
1410
|
-
assignRemoteInfo(
|
|
1411
|
+
const { remoteSnapshot: u, globalSnapshot: s } = await r.snapshotHandler.loadRemoteSnapshotInfo(e);
|
|
1412
|
+
assignRemoteInfo(l, u);
|
|
1411
1413
|
const d = {
|
|
1412
1414
|
remote: e,
|
|
1413
1415
|
preloadConfig: {
|
|
@@ -1422,12 +1424,12 @@ function snapshotPlugin() {
|
|
|
1422
1424
|
}, p = await r.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({
|
|
1423
1425
|
origin: r,
|
|
1424
1426
|
preloadOptions: d,
|
|
1425
|
-
remoteInfo:
|
|
1427
|
+
remoteInfo: l,
|
|
1426
1428
|
remote: e,
|
|
1427
1429
|
remoteSnapshot: u,
|
|
1428
|
-
globalSnapshot:
|
|
1430
|
+
globalSnapshot: s
|
|
1429
1431
|
});
|
|
1430
|
-
return p && preloadAssets(
|
|
1432
|
+
return p && preloadAssets(l, r, p, !1), _extends$1({}, t, {
|
|
1431
1433
|
remoteSnapshot: u
|
|
1432
1434
|
});
|
|
1433
1435
|
}
|
|
@@ -1448,39 +1450,39 @@ function splitId(t) {
|
|
|
1448
1450
|
version: e[2]
|
|
1449
1451
|
};
|
|
1450
1452
|
}
|
|
1451
|
-
function traverseModuleInfo(t, e, n, o, r = {},
|
|
1452
|
-
const u = getFMId(e), { value:
|
|
1453
|
+
function traverseModuleInfo(t, e, n, o, r = {}, l) {
|
|
1454
|
+
const u = getFMId(e), { value: s } = getInfoWithoutType(t, u), d = l || s;
|
|
1453
1455
|
if (d && !isManifestProvider(d) && (n(d, e, o), d.remotesInfo)) {
|
|
1454
1456
|
const p = Object.keys(d.remotesInfo);
|
|
1455
|
-
for (const
|
|
1456
|
-
if (r[
|
|
1457
|
+
for (const _ of p) {
|
|
1458
|
+
if (r[_])
|
|
1457
1459
|
continue;
|
|
1458
|
-
r[
|
|
1459
|
-
const
|
|
1460
|
+
r[_] = !0;
|
|
1461
|
+
const y = splitId(_), m = d.remotesInfo[_];
|
|
1460
1462
|
traverseModuleInfo(t, {
|
|
1461
|
-
name:
|
|
1463
|
+
name: y.name,
|
|
1462
1464
|
version: m.matchedVersion
|
|
1463
1465
|
}, n, !1, r, void 0);
|
|
1464
1466
|
}
|
|
1465
1467
|
}
|
|
1466
1468
|
}
|
|
1467
1469
|
function generatePreloadAssets(t, e, n, o, r) {
|
|
1468
|
-
const
|
|
1470
|
+
const l = [], u = [], s = [], d = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Set(), { options: _ } = t, { preloadConfig: y } = e, { depsRemote: m } = y;
|
|
1469
1471
|
if (traverseModuleInfo(o, n, (E, v, T) => {
|
|
1470
1472
|
let A;
|
|
1471
1473
|
if (T)
|
|
1472
|
-
A =
|
|
1474
|
+
A = y;
|
|
1473
1475
|
else if (Array.isArray(m)) {
|
|
1474
1476
|
const N = m.find((L) => L.nameOrAlias === v.name || L.nameOrAlias === v.alias);
|
|
1475
1477
|
if (!N)
|
|
1476
1478
|
return;
|
|
1477
1479
|
A = defaultPreloadArgs(N);
|
|
1478
1480
|
} else if (m === !0)
|
|
1479
|
-
A =
|
|
1481
|
+
A = y;
|
|
1480
1482
|
else
|
|
1481
1483
|
return;
|
|
1482
1484
|
const I = getResourceUrl(E, getRemoteEntryInfoFromSnapshot(E).url);
|
|
1483
|
-
I &&
|
|
1485
|
+
I && s.push({
|
|
1484
1486
|
name: v.name,
|
|
1485
1487
|
moduleInfo: {
|
|
1486
1488
|
name: v.name,
|
|
@@ -1513,7 +1515,7 @@ function generatePreloadAssets(t, e, n, o, r) {
|
|
|
1513
1515
|
preloadConfig: A,
|
|
1514
1516
|
remote: v,
|
|
1515
1517
|
origin: t
|
|
1516
|
-
}), !getPreloaded(H) && (A.resourceCategory === "all" ? (
|
|
1518
|
+
}), !getPreloaded(H) && (A.resourceCategory === "all" ? (l.push(...w(k.assets.css.async)), l.push(...w(k.assets.css.sync)), u.push(...w(k.assets.js.async)), u.push(...w(k.assets.js.sync))) : (A.resourceCategory = "sync") && (l.push(...w(k.assets.css.sync)), u.push(...w(k.assets.js.sync))), setPreloaded(H));
|
|
1517
1519
|
}
|
|
1518
1520
|
}
|
|
1519
1521
|
}, !0, {}, r), r.shared) {
|
|
@@ -1527,7 +1529,7 @@ function generatePreloadAssets(t, e, n, o, r) {
|
|
|
1527
1529
|
};
|
|
1528
1530
|
r.shared.forEach((v) => {
|
|
1529
1531
|
var T;
|
|
1530
|
-
const A = (T =
|
|
1532
|
+
const A = (T = _.shared) == null ? void 0 : T[v.sharedName];
|
|
1531
1533
|
if (!A)
|
|
1532
1534
|
return;
|
|
1533
1535
|
const I = v.version ? A.find((O) => O.version === v.version) : A;
|
|
@@ -1540,16 +1542,16 @@ function generatePreloadAssets(t, e, n, o, r) {
|
|
|
1540
1542
|
}
|
|
1541
1543
|
const S = u.filter((E) => !d.has(E));
|
|
1542
1544
|
return {
|
|
1543
|
-
cssAssets:
|
|
1545
|
+
cssAssets: l.filter((E) => !p.has(E)),
|
|
1544
1546
|
jsAssetsWithoutEntry: S,
|
|
1545
|
-
entryAssets:
|
|
1547
|
+
entryAssets: s
|
|
1546
1548
|
};
|
|
1547
1549
|
}
|
|
1548
1550
|
const generatePreloadAssetsPlugin = function() {
|
|
1549
1551
|
return {
|
|
1550
1552
|
name: "generate-preload-assets-plugin",
|
|
1551
1553
|
async generatePreloadAssets(t) {
|
|
1552
|
-
const { origin: e, preloadOptions: n, remoteInfo: o, remote: r, globalSnapshot:
|
|
1554
|
+
const { origin: e, preloadOptions: n, remoteInfo: o, remote: r, globalSnapshot: l, remoteSnapshot: u } = t;
|
|
1553
1555
|
return isRemoteInfoWithEntry(r) && isPureRemoteEntry(r) ? {
|
|
1554
1556
|
cssAssets: [],
|
|
1555
1557
|
jsAssetsWithoutEntry: [],
|
|
@@ -1566,7 +1568,7 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1566
1568
|
}
|
|
1567
1569
|
}
|
|
1568
1570
|
]
|
|
1569
|
-
} : (assignRemoteInfo(o, u), generatePreloadAssets(e, n, o,
|
|
1571
|
+
} : (assignRemoteInfo(o, u), generatePreloadAssets(e, n, o, l, u));
|
|
1570
1572
|
}
|
|
1571
1573
|
};
|
|
1572
1574
|
};
|
|
@@ -1593,16 +1595,16 @@ function getGlobalRemoteInfo(t, e) {
|
|
|
1593
1595
|
}
|
|
1594
1596
|
class SnapshotHandler {
|
|
1595
1597
|
async loadSnapshot(e) {
|
|
1596
|
-
const { options: n } = this.HostInstance, { hostGlobalSnapshot: o, remoteSnapshot: r, globalSnapshot:
|
|
1598
|
+
const { options: n } = this.HostInstance, { hostGlobalSnapshot: o, remoteSnapshot: r, globalSnapshot: l } = this.getGlobalRemoteInfo(e), { remoteSnapshot: u, globalSnapshot: s } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1597
1599
|
options: n,
|
|
1598
1600
|
moduleInfo: e,
|
|
1599
1601
|
hostGlobalSnapshot: o,
|
|
1600
1602
|
remoteSnapshot: r,
|
|
1601
|
-
globalSnapshot:
|
|
1603
|
+
globalSnapshot: l
|
|
1602
1604
|
});
|
|
1603
1605
|
return {
|
|
1604
1606
|
remoteSnapshot: u,
|
|
1605
|
-
globalSnapshot:
|
|
1607
|
+
globalSnapshot: s
|
|
1606
1608
|
};
|
|
1607
1609
|
}
|
|
1608
1610
|
// eslint-disable-next-line max-lines-per-function
|
|
@@ -1627,39 +1629,39 @@ class SnapshotHandler {
|
|
|
1627
1629
|
matchedVersion: "version" in e ? e.version : e.entry
|
|
1628
1630
|
}
|
|
1629
1631
|
}));
|
|
1630
|
-
const { hostGlobalSnapshot: r, remoteSnapshot:
|
|
1632
|
+
const { hostGlobalSnapshot: r, remoteSnapshot: l, globalSnapshot: u } = this.getGlobalRemoteInfo(e), { remoteSnapshot: s, globalSnapshot: d } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1631
1633
|
options: n,
|
|
1632
1634
|
moduleInfo: e,
|
|
1633
1635
|
hostGlobalSnapshot: r,
|
|
1634
|
-
remoteSnapshot:
|
|
1636
|
+
remoteSnapshot: l,
|
|
1635
1637
|
globalSnapshot: u
|
|
1636
1638
|
});
|
|
1637
|
-
let p,
|
|
1638
|
-
if (
|
|
1639
|
-
if (isManifestProvider(
|
|
1640
|
-
const
|
|
1639
|
+
let p, _;
|
|
1640
|
+
if (s)
|
|
1641
|
+
if (isManifestProvider(s)) {
|
|
1642
|
+
const y = isBrowserEnv() ? s.remoteEntry : s.ssrRemoteEntry || s.remoteEntry || "", m = await this.getManifestJson(y, e, {}), b = setGlobalSnapshotInfoByModuleInfo(_extends$1({}, e, {
|
|
1641
1643
|
// The global remote may be overridden
|
|
1642
1644
|
// Therefore, set the snapshot key to the global address of the actual request
|
|
1643
|
-
entry:
|
|
1645
|
+
entry: y
|
|
1644
1646
|
}), m);
|
|
1645
|
-
p = m,
|
|
1647
|
+
p = m, _ = b;
|
|
1646
1648
|
} else {
|
|
1647
|
-
const { remoteSnapshot:
|
|
1649
|
+
const { remoteSnapshot: y } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1648
1650
|
options: this.HostInstance.options,
|
|
1649
1651
|
moduleInfo: e,
|
|
1650
|
-
remoteSnapshot:
|
|
1652
|
+
remoteSnapshot: s,
|
|
1651
1653
|
from: "global"
|
|
1652
1654
|
});
|
|
1653
|
-
p =
|
|
1655
|
+
p = y, _ = d;
|
|
1654
1656
|
}
|
|
1655
1657
|
else if (isRemoteInfoWithEntry(e)) {
|
|
1656
|
-
const
|
|
1658
|
+
const y = await this.getManifestJson(e.entry, e, {}), m = setGlobalSnapshotInfoByModuleInfo(e, y), { remoteSnapshot: b } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1657
1659
|
options: this.HostInstance.options,
|
|
1658
1660
|
moduleInfo: e,
|
|
1659
|
-
remoteSnapshot:
|
|
1661
|
+
remoteSnapshot: y,
|
|
1660
1662
|
from: "global"
|
|
1661
1663
|
});
|
|
1662
|
-
p = b,
|
|
1664
|
+
p = b, _ = m;
|
|
1663
1665
|
} else
|
|
1664
1666
|
error(`
|
|
1665
1667
|
Cannot get remoteSnapshot with the name: '${e.name}', version: '${e.version}' from __FEDERATION__.moduleInfo. The following reasons may be causing the problem:
|
|
@@ -1676,7 +1678,7 @@ class SnapshotHandler {
|
|
|
1676
1678
|
remoteSnapshot: p
|
|
1677
1679
|
}), {
|
|
1678
1680
|
remoteSnapshot: p,
|
|
1679
|
-
globalSnapshot:
|
|
1681
|
+
globalSnapshot: _
|
|
1680
1682
|
};
|
|
1681
1683
|
}
|
|
1682
1684
|
getGlobalRemoteInfo(e) {
|
|
@@ -1688,29 +1690,29 @@ class SnapshotHandler {
|
|
|
1688
1690
|
if (u)
|
|
1689
1691
|
return u;
|
|
1690
1692
|
try {
|
|
1691
|
-
let
|
|
1692
|
-
return (!
|
|
1693
|
-
} catch (
|
|
1693
|
+
let s = await this.loaderHook.lifecycle.fetch.emit(e, {});
|
|
1694
|
+
return (!s || !(s instanceof Response)) && (s = await fetch(e, {})), u = await s.json(), assert(u.metaData && u.exposes && u.shared, `${e} is not a federation manifest`), this.manifestCache.set(e, u), u;
|
|
1695
|
+
} catch (s) {
|
|
1694
1696
|
delete this.manifestLoading[e], error(`Failed to get manifestJson for ${n.name}. The manifest URL is ${e}. Please ensure that the manifestUrl is accessible.
|
|
1695
1697
|
|
|
1696
1698
|
Error message:
|
|
1697
1699
|
|
|
1698
|
-
${
|
|
1700
|
+
${s}`);
|
|
1699
1701
|
}
|
|
1700
|
-
},
|
|
1701
|
-
const u = await r(),
|
|
1702
|
+
}, l = async () => {
|
|
1703
|
+
const u = await r(), s = generateSnapshotFromManifest(u, {
|
|
1702
1704
|
version: e
|
|
1703
1705
|
}), { remoteSnapshot: d } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1704
1706
|
options: this.HostInstance.options,
|
|
1705
1707
|
moduleInfo: n,
|
|
1706
1708
|
manifestJson: u,
|
|
1707
|
-
remoteSnapshot:
|
|
1709
|
+
remoteSnapshot: s,
|
|
1708
1710
|
manifestUrl: e,
|
|
1709
1711
|
from: "manifest"
|
|
1710
1712
|
});
|
|
1711
1713
|
return d;
|
|
1712
1714
|
};
|
|
1713
|
-
return this.manifestLoading[e] || (this.manifestLoading[e] =
|
|
1715
|
+
return this.manifestLoading[e] || (this.manifestLoading[e] = l().then((u) => u)), this.manifestLoading[e];
|
|
1714
1716
|
}
|
|
1715
1717
|
constructor(e) {
|
|
1716
1718
|
this.loadingHostSnapshot = null, this.manifestCache = /* @__PURE__ */ new Map(), this.hooks = new PluginSystem({
|
|
@@ -1752,44 +1754,44 @@ class SharedHandler {
|
|
|
1752
1754
|
strategy: r.strategy
|
|
1753
1755
|
}));
|
|
1754
1756
|
}));
|
|
1755
|
-
const
|
|
1757
|
+
const l = await this.hooks.lifecycle.beforeLoadShare.emit({
|
|
1756
1758
|
pkgName: e,
|
|
1757
1759
|
shareInfo: r,
|
|
1758
1760
|
shared: o.options.shared,
|
|
1759
1761
|
origin: o
|
|
1760
|
-
}), { shareInfo: u } =
|
|
1762
|
+
}), { shareInfo: u } = l;
|
|
1761
1763
|
assert(u, `Cannot find ${e} Share in the ${o.options.name}. Please ensure that the ${e} Share parameters have been injected`);
|
|
1762
|
-
const
|
|
1764
|
+
const s = getRegisteredShare(this.shareScopeMap, e, u, this.hooks.lifecycle.resolveShare), d = (p) => {
|
|
1763
1765
|
p.useIn || (p.useIn = []), addUniqueItem(p.useIn, o.options.name);
|
|
1764
1766
|
};
|
|
1765
|
-
if (
|
|
1766
|
-
return d(
|
|
1767
|
-
if (
|
|
1768
|
-
const p = await
|
|
1769
|
-
return
|
|
1770
|
-
} else if (
|
|
1771
|
-
const
|
|
1772
|
-
const
|
|
1773
|
-
u.lib =
|
|
1767
|
+
if (s && s.lib)
|
|
1768
|
+
return d(s), s.lib;
|
|
1769
|
+
if (s && s.loading && !s.loaded) {
|
|
1770
|
+
const p = await s.loading;
|
|
1771
|
+
return s.loaded = !0, s.lib || (s.lib = p), d(s), p;
|
|
1772
|
+
} else if (s) {
|
|
1773
|
+
const _ = (async () => {
|
|
1774
|
+
const y = await s.get();
|
|
1775
|
+
u.lib = y, u.loaded = !0, d(u);
|
|
1774
1776
|
const m = getRegisteredShare(this.shareScopeMap, e, u, this.hooks.lifecycle.resolveShare);
|
|
1775
|
-
return m && (m.lib =
|
|
1777
|
+
return m && (m.lib = y, m.loaded = !0), y;
|
|
1776
1778
|
})();
|
|
1777
1779
|
return this.setShared({
|
|
1778
1780
|
pkgName: e,
|
|
1779
1781
|
loaded: !1,
|
|
1780
|
-
shared:
|
|
1782
|
+
shared: s,
|
|
1781
1783
|
from: o.options.name,
|
|
1782
1784
|
lib: null,
|
|
1783
|
-
loading:
|
|
1784
|
-
}),
|
|
1785
|
+
loading: _
|
|
1786
|
+
}), _;
|
|
1785
1787
|
} else {
|
|
1786
1788
|
if (n != null && n.customShareInfo)
|
|
1787
1789
|
return !1;
|
|
1788
|
-
const
|
|
1789
|
-
const
|
|
1790
|
-
u.lib =
|
|
1790
|
+
const _ = (async () => {
|
|
1791
|
+
const y = await u.get();
|
|
1792
|
+
u.lib = y, u.loaded = !0, d(u);
|
|
1791
1793
|
const m = getRegisteredShare(this.shareScopeMap, e, u, this.hooks.lifecycle.resolveShare);
|
|
1792
|
-
return m && (m.lib =
|
|
1794
|
+
return m && (m.lib = y, m.loaded = !0), y;
|
|
1793
1795
|
})();
|
|
1794
1796
|
return this.setShared({
|
|
1795
1797
|
pkgName: e,
|
|
@@ -1797,8 +1799,8 @@ class SharedHandler {
|
|
|
1797
1799
|
shared: u,
|
|
1798
1800
|
from: o.options.name,
|
|
1799
1801
|
lib: null,
|
|
1800
|
-
loading:
|
|
1801
|
-
}),
|
|
1802
|
+
loading: _
|
|
1803
|
+
}), _;
|
|
1802
1804
|
}
|
|
1803
1805
|
}
|
|
1804
1806
|
/**
|
|
@@ -1808,9 +1810,9 @@ class SharedHandler {
|
|
|
1808
1810
|
*/
|
|
1809
1811
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
1810
1812
|
initializeSharing(e = DEFAULT_SCOPE, n) {
|
|
1811
|
-
const { host: o } = this, r = n == null ? void 0 : n.from,
|
|
1813
|
+
const { host: o } = this, r = n == null ? void 0 : n.from, l = n == null ? void 0 : n.strategy;
|
|
1812
1814
|
let u = n == null ? void 0 : n.initScope;
|
|
1813
|
-
const
|
|
1815
|
+
const s = [];
|
|
1814
1816
|
if (r !== "build") {
|
|
1815
1817
|
const { initTokens: S } = this;
|
|
1816
1818
|
u || (u = []);
|
|
@@ -1818,16 +1820,16 @@ class SharedHandler {
|
|
|
1818
1820
|
if ($ || ($ = S[e] = {
|
|
1819
1821
|
from: this.host.name
|
|
1820
1822
|
}), u.indexOf($) >= 0)
|
|
1821
|
-
return
|
|
1823
|
+
return s;
|
|
1822
1824
|
u.push($);
|
|
1823
1825
|
}
|
|
1824
1826
|
const d = this.shareScopeMap, p = o.options.name;
|
|
1825
1827
|
d[e] || (d[e] = {});
|
|
1826
|
-
const
|
|
1828
|
+
const _ = d[e], y = (S, $) => {
|
|
1827
1829
|
var E;
|
|
1828
1830
|
const { version: v, eager: T } = $;
|
|
1829
|
-
|
|
1830
|
-
const A =
|
|
1831
|
+
_[S] = _[S] || {};
|
|
1832
|
+
const A = _[S], I = A[v], R = !!(I && (I.eager || (E = I.shareConfig) != null && E.eager));
|
|
1831
1833
|
(!I || I.strategy !== "loaded-first" && !I.loaded && (!T != !R ? T : p > I.from)) && (A[v] = $);
|
|
1832
1834
|
}, m = (S) => S && S.init && S.init(d[e], u), b = async (S) => {
|
|
1833
1835
|
const { module: $ } = await o.remoteHandler.getRemoteModuleAndOptions({
|
|
@@ -1840,11 +1842,11 @@ class SharedHandler {
|
|
|
1840
1842
|
};
|
|
1841
1843
|
return Object.keys(o.options.shared).forEach((S) => {
|
|
1842
1844
|
o.options.shared[S].forEach((E) => {
|
|
1843
|
-
E.scope.includes(e) &&
|
|
1845
|
+
E.scope.includes(e) && y(S, E);
|
|
1844
1846
|
});
|
|
1845
|
-
}), (o.options.shareStrategy === "version-first" ||
|
|
1846
|
-
S.shareScope === e &&
|
|
1847
|
-
}),
|
|
1847
|
+
}), (o.options.shareStrategy === "version-first" || l === "version-first") && o.options.remotes.forEach((S) => {
|
|
1848
|
+
S.shareScope === e && s.push(b(S.name));
|
|
1849
|
+
}), s;
|
|
1848
1850
|
}
|
|
1849
1851
|
// The lib function will only be available if the shared set by eager or runtime init is set or the shared is successfully loaded.
|
|
1850
1852
|
// 1. If the loaded shared already exists globally, then it will be reused
|
|
@@ -1856,34 +1858,34 @@ class SharedHandler {
|
|
|
1856
1858
|
extraOptions: n,
|
|
1857
1859
|
shareInfos: o.options.shared
|
|
1858
1860
|
});
|
|
1859
|
-
r != null && r.scope && r.scope.forEach((
|
|
1860
|
-
this.initializeSharing(
|
|
1861
|
+
r != null && r.scope && r.scope.forEach((s) => {
|
|
1862
|
+
this.initializeSharing(s, {
|
|
1861
1863
|
strategy: r.strategy
|
|
1862
1864
|
});
|
|
1863
1865
|
});
|
|
1864
|
-
const
|
|
1865
|
-
|
|
1866
|
+
const l = getRegisteredShare(this.shareScopeMap, e, r, this.hooks.lifecycle.resolveShare), u = (s) => {
|
|
1867
|
+
s.useIn || (s.useIn = []), addUniqueItem(s.useIn, o.options.name);
|
|
1866
1868
|
};
|
|
1867
|
-
if (
|
|
1868
|
-
if (typeof
|
|
1869
|
-
return u(
|
|
1870
|
-
if (typeof
|
|
1871
|
-
const
|
|
1872
|
-
if (!(
|
|
1873
|
-
return u(
|
|
1869
|
+
if (l) {
|
|
1870
|
+
if (typeof l.lib == "function")
|
|
1871
|
+
return u(l), l.loaded || (l.loaded = !0, l.from === o.options.name && (r.loaded = !0)), l.lib;
|
|
1872
|
+
if (typeof l.get == "function") {
|
|
1873
|
+
const s = l.get();
|
|
1874
|
+
if (!(s instanceof Promise))
|
|
1875
|
+
return u(l), this.setShared({
|
|
1874
1876
|
pkgName: e,
|
|
1875
1877
|
loaded: !0,
|
|
1876
1878
|
from: o.options.name,
|
|
1877
|
-
lib:
|
|
1878
|
-
shared:
|
|
1879
|
-
}),
|
|
1879
|
+
lib: s,
|
|
1880
|
+
shared: l
|
|
1881
|
+
}), s;
|
|
1880
1882
|
}
|
|
1881
1883
|
}
|
|
1882
1884
|
if (r.lib)
|
|
1883
1885
|
return r.loaded || (r.loaded = !0), r.lib;
|
|
1884
1886
|
if (r.get) {
|
|
1885
|
-
const
|
|
1886
|
-
if (
|
|
1887
|
+
const s = r.get();
|
|
1888
|
+
if (s instanceof Promise)
|
|
1887
1889
|
throw new Error(`
|
|
1888
1890
|
The loadShareSync function was unable to load ${e}. The ${e} could not be found in ${o.options.name}.
|
|
1889
1891
|
Possible reasons for failure:
|
|
@@ -1893,7 +1895,7 @@ class SharedHandler {
|
|
|
1893
1895
|
2. The ${e} share was not registered with the 'lib' attribute.
|
|
1894
1896
|
|
|
1895
1897
|
`);
|
|
1896
|
-
return r.lib =
|
|
1898
|
+
return r.lib = s, this.setShared({
|
|
1897
1899
|
pkgName: e,
|
|
1898
1900
|
loaded: !0,
|
|
1899
1901
|
from: o.options.name,
|
|
@@ -1921,8 +1923,8 @@ class SharedHandler {
|
|
|
1921
1923
|
hostShareScopeMap: o.hostShareScopeMap
|
|
1922
1924
|
});
|
|
1923
1925
|
}
|
|
1924
|
-
setShared({ pkgName: e, shared: n, from: o, lib: r, loading:
|
|
1925
|
-
const { version: d, scope: p = "default" } = n,
|
|
1926
|
+
setShared({ pkgName: e, shared: n, from: o, lib: r, loading: l, loaded: u, get: s }) {
|
|
1927
|
+
const { version: d, scope: p = "default" } = n, _ = _object_without_properties_loose(n, [
|
|
1926
1928
|
"version",
|
|
1927
1929
|
"scope"
|
|
1928
1930
|
]);
|
|
@@ -1935,15 +1937,15 @@ class SharedHandler {
|
|
|
1935
1937
|
scope: [
|
|
1936
1938
|
"default"
|
|
1937
1939
|
]
|
|
1938
|
-
},
|
|
1940
|
+
}, _, {
|
|
1939
1941
|
lib: r,
|
|
1940
1942
|
loaded: u,
|
|
1941
|
-
loading:
|
|
1942
|
-
}),
|
|
1943
|
+
loading: l
|
|
1944
|
+
}), s && (this.shareScopeMap[m][e][d].get = s);
|
|
1943
1945
|
return;
|
|
1944
1946
|
}
|
|
1945
1947
|
const b = this.shareScopeMap[m][e][d];
|
|
1946
|
-
|
|
1948
|
+
l && !b.loading && (b.loading = l);
|
|
1947
1949
|
});
|
|
1948
1950
|
}
|
|
1949
1951
|
_setGlobalShareScopeMap(e) {
|
|
@@ -1964,26 +1966,26 @@ class SharedHandler {
|
|
|
1964
1966
|
}
|
|
1965
1967
|
class RemoteHandler {
|
|
1966
1968
|
formatAndRegisterRemote(e, n) {
|
|
1967
|
-
return (n.remotes || []).reduce((r,
|
|
1969
|
+
return (n.remotes || []).reduce((r, l) => (this.registerRemote(l, r, {
|
|
1968
1970
|
force: !1
|
|
1969
1971
|
}), r), e.remotes);
|
|
1970
1972
|
}
|
|
1971
1973
|
setIdToRemoteMap(e, n) {
|
|
1972
|
-
const { remote: o, expose: r } = n, { name:
|
|
1974
|
+
const { remote: o, expose: r } = n, { name: l, alias: u } = o;
|
|
1973
1975
|
if (this.idToRemoteMap[e] = {
|
|
1974
1976
|
name: o.name,
|
|
1975
1977
|
expose: r
|
|
1976
|
-
}, u && e.startsWith(
|
|
1977
|
-
const
|
|
1978
|
-
this.idToRemoteMap[
|
|
1978
|
+
}, u && e.startsWith(l)) {
|
|
1979
|
+
const s = e.replace(l, u);
|
|
1980
|
+
this.idToRemoteMap[s] = {
|
|
1979
1981
|
name: o.name,
|
|
1980
1982
|
expose: r
|
|
1981
1983
|
};
|
|
1982
1984
|
return;
|
|
1983
1985
|
}
|
|
1984
1986
|
if (u && e.startsWith(u)) {
|
|
1985
|
-
const
|
|
1986
|
-
this.idToRemoteMap[
|
|
1987
|
+
const s = e.replace(u, l);
|
|
1988
|
+
this.idToRemoteMap[s] = {
|
|
1987
1989
|
name: o.name,
|
|
1988
1990
|
expose: r
|
|
1989
1991
|
};
|
|
@@ -1996,27 +1998,27 @@ class RemoteHandler {
|
|
|
1996
1998
|
try {
|
|
1997
1999
|
const { loadFactory: r = !0 } = n || {
|
|
1998
2000
|
loadFactory: !0
|
|
1999
|
-
}, { module:
|
|
2001
|
+
}, { module: l, moduleOptions: u, remoteMatchInfo: s } = await this.getRemoteModuleAndOptions({
|
|
2000
2002
|
id: e
|
|
2001
|
-
}), { pkgNameOrAlias: d, remote: p, expose:
|
|
2002
|
-
id:
|
|
2003
|
+
}), { pkgNameOrAlias: d, remote: p, expose: _, id: y, remoteSnapshot: m } = s, b = await l.get(y, _, n, m), S = await this.hooks.lifecycle.onLoad.emit({
|
|
2004
|
+
id: y,
|
|
2003
2005
|
pkgNameOrAlias: d,
|
|
2004
|
-
expose:
|
|
2005
|
-
exposeModule: r ?
|
|
2006
|
-
exposeModuleFactory: r ? void 0 :
|
|
2006
|
+
expose: _,
|
|
2007
|
+
exposeModule: r ? b : void 0,
|
|
2008
|
+
exposeModuleFactory: r ? void 0 : b,
|
|
2007
2009
|
remote: p,
|
|
2008
2010
|
options: u,
|
|
2009
|
-
moduleInstance:
|
|
2011
|
+
moduleInstance: l,
|
|
2010
2012
|
origin: o
|
|
2011
2013
|
});
|
|
2012
|
-
return this.setIdToRemoteMap(e,
|
|
2014
|
+
return this.setIdToRemoteMap(e, s), typeof S == "function" ? S : b;
|
|
2013
2015
|
} catch (r) {
|
|
2014
|
-
const { from:
|
|
2016
|
+
const { from: l = "runtime" } = n || {
|
|
2015
2017
|
from: "runtime"
|
|
2016
2018
|
}, u = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
2017
2019
|
id: e,
|
|
2018
2020
|
error: r,
|
|
2019
|
-
from:
|
|
2021
|
+
from: l,
|
|
2020
2022
|
lifecycle: "onLoad",
|
|
2021
2023
|
origin: o
|
|
2022
2024
|
});
|
|
@@ -2035,12 +2037,12 @@ class RemoteHandler {
|
|
|
2035
2037
|
});
|
|
2036
2038
|
const o = formatPreloadArgs(n.options.remotes, e);
|
|
2037
2039
|
await Promise.all(o.map(async (r) => {
|
|
2038
|
-
const { remote:
|
|
2040
|
+
const { remote: l } = r, u = getRemoteInfo(l), { globalSnapshot: s, remoteSnapshot: d } = await n.snapshotHandler.loadRemoteSnapshotInfo(l), p = await this.hooks.lifecycle.generatePreloadAssets.emit({
|
|
2039
2041
|
origin: n,
|
|
2040
2042
|
preloadOptions: r,
|
|
2041
|
-
remote:
|
|
2043
|
+
remote: l,
|
|
2042
2044
|
remoteInfo: u,
|
|
2043
|
-
globalSnapshot:
|
|
2045
|
+
globalSnapshot: s,
|
|
2044
2046
|
remoteSnapshot: d
|
|
2045
2047
|
});
|
|
2046
2048
|
p && preloadAssets(u, n, p);
|
|
@@ -2074,44 +2076,44 @@ class RemoteHandler {
|
|
|
2074
2076
|
}), !r)
|
|
2075
2077
|
throw S;
|
|
2076
2078
|
}
|
|
2077
|
-
const { id:
|
|
2079
|
+
const { id: l } = r, u = matchRemoteWithNameAndExpose(n.options.remotes, l);
|
|
2078
2080
|
assert(u, `
|
|
2079
|
-
Unable to locate ${
|
|
2081
|
+
Unable to locate ${l} in ${n.options.name}. Potential reasons for failure include:
|
|
2080
2082
|
|
|
2081
|
-
1. ${
|
|
2083
|
+
1. ${l} was not included in the 'remotes' parameter of ${n.options.name || "the host"}.
|
|
2082
2084
|
|
|
2083
|
-
2. ${
|
|
2084
|
-
3. ${
|
|
2085
|
-
4. ${
|
|
2086
|
-
5. The 'beforeRequest' hook was provided but did not return the correct 'remoteInfo' when attempting to load ${
|
|
2085
|
+
2. ${l} could not be found in the 'remotes' of ${n.options.name} with either 'name' or 'alias' attributes.
|
|
2086
|
+
3. ${l} is not online, injected, or loaded.
|
|
2087
|
+
4. ${l} cannot be accessed on the expected.
|
|
2088
|
+
5. The 'beforeRequest' hook was provided but did not return the correct 'remoteInfo' when attempting to load ${l}.
|
|
2087
2089
|
`);
|
|
2088
|
-
const { remote:
|
|
2089
|
-
id:
|
|
2090
|
+
const { remote: s } = u, d = getRemoteInfo(s), p = await n.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({
|
|
2091
|
+
id: l
|
|
2090
2092
|
}, u, {
|
|
2091
2093
|
options: n.options,
|
|
2092
2094
|
origin: n,
|
|
2093
2095
|
remoteInfo: d
|
|
2094
|
-
})), { remote:
|
|
2095
|
-
assert(
|
|
2096
|
-
let m = n.moduleCache.get(
|
|
2096
|
+
})), { remote: _, expose: y } = p;
|
|
2097
|
+
assert(_ && y, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${l}.`);
|
|
2098
|
+
let m = n.moduleCache.get(_.name);
|
|
2097
2099
|
const b = {
|
|
2098
2100
|
host: n,
|
|
2099
2101
|
remoteInfo: d
|
|
2100
2102
|
};
|
|
2101
|
-
return m || (m = new Module(b), n.moduleCache.set(
|
|
2103
|
+
return m || (m = new Module(b), n.moduleCache.set(_.name, m)), {
|
|
2102
2104
|
module: m,
|
|
2103
2105
|
moduleOptions: b,
|
|
2104
2106
|
remoteMatchInfo: p
|
|
2105
2107
|
};
|
|
2106
2108
|
}
|
|
2107
2109
|
registerRemote(e, n, o) {
|
|
2108
|
-
const { host: r } = this,
|
|
2110
|
+
const { host: r } = this, l = () => {
|
|
2109
2111
|
if (e.alias) {
|
|
2110
|
-
const
|
|
2112
|
+
const s = n.find((d) => {
|
|
2111
2113
|
var p;
|
|
2112
2114
|
return e.alias && (d.name.startsWith(e.alias) || ((p = d.alias) == null ? void 0 : p.startsWith(e.alias)));
|
|
2113
2115
|
});
|
|
2114
|
-
assert(!
|
|
2116
|
+
assert(!s, `The alias ${e.alias} of remote ${e.name} is not allowed to be the prefix of ${s && s.name} name or alias`);
|
|
2115
2117
|
}
|
|
2116
2118
|
"entry" in e && isBrowserEnv() && !e.entry.startsWith("http") && (e.entry = new URL(e.entry, window.location.origin).href), e.shareScope || (e.shareScope = DEFAULT_SCOPE), e.type || (e.type = DEFAULT_REMOTE_TYPE);
|
|
2117
2119
|
};
|
|
@@ -2119,41 +2121,41 @@ class RemoteHandler {
|
|
|
2119
2121
|
remote: e,
|
|
2120
2122
|
origin: r
|
|
2121
2123
|
});
|
|
2122
|
-
const u = n.find((
|
|
2124
|
+
const u = n.find((s) => s.name === e.name);
|
|
2123
2125
|
if (!u)
|
|
2124
|
-
|
|
2126
|
+
l(), n.push(e), this.hooks.lifecycle.registerRemote.emit({
|
|
2125
2127
|
remote: e,
|
|
2126
2128
|
origin: r
|
|
2127
2129
|
});
|
|
2128
2130
|
else {
|
|
2129
|
-
const
|
|
2131
|
+
const s = [
|
|
2130
2132
|
`The remote "${e.name}" is already registered.`,
|
|
2131
2133
|
o != null && o.force ? "Hope you have known that OVERRIDE it may have some unexpected errors" : 'If you want to merge the remote, you can set "force: true".'
|
|
2132
2134
|
];
|
|
2133
|
-
o != null && o.force && (this.removeRemote(u),
|
|
2135
|
+
o != null && o.force && (this.removeRemote(u), l(), n.push(e), this.hooks.lifecycle.registerRemote.emit({
|
|
2134
2136
|
remote: e,
|
|
2135
2137
|
origin: r
|
|
2136
|
-
})), warn$1(
|
|
2138
|
+
})), warn$1(s.join(" "));
|
|
2137
2139
|
}
|
|
2138
2140
|
}
|
|
2139
2141
|
removeRemote(e) {
|
|
2140
2142
|
try {
|
|
2141
|
-
const { host: o } = this, { name: r } = e,
|
|
2142
|
-
|
|
2143
|
+
const { host: o } = this, { name: r } = e, l = o.options.remotes.findIndex((s) => s.name === r);
|
|
2144
|
+
l !== -1 && o.options.remotes.splice(l, 1);
|
|
2143
2145
|
const u = o.moduleCache.get(e.name);
|
|
2144
2146
|
if (u) {
|
|
2145
|
-
const
|
|
2147
|
+
const s = u.remoteInfo, d = s.entryGlobalName;
|
|
2146
2148
|
if (globalThis[d]) {
|
|
2147
2149
|
var n;
|
|
2148
2150
|
(n = Object.getOwnPropertyDescriptor(globalThis, d)) != null && n.configurable ? delete globalThis[d] : globalThis[d] = void 0;
|
|
2149
2151
|
}
|
|
2150
2152
|
const p = getRemoteEntryUniqueKey(u.remoteInfo);
|
|
2151
|
-
globalLoading[p] && delete globalLoading[p], o.snapshotHandler.manifestCache.delete(
|
|
2152
|
-
let
|
|
2153
|
-
const
|
|
2154
|
-
if (
|
|
2155
|
-
const b = globalThis.__FEDERATION__.__INSTANCES__[
|
|
2156
|
-
|
|
2153
|
+
globalLoading[p] && delete globalLoading[p], o.snapshotHandler.manifestCache.delete(s.entry);
|
|
2154
|
+
let _ = s.buildVersion ? composeKeyWithSeparator(s.name, s.buildVersion) : s.name;
|
|
2155
|
+
const y = globalThis.__FEDERATION__.__INSTANCES__.findIndex((b) => s.buildVersion ? b.options.id === _ : b.name === _);
|
|
2156
|
+
if (y !== -1) {
|
|
2157
|
+
const b = globalThis.__FEDERATION__.__INSTANCES__[y];
|
|
2158
|
+
_ = b.options.id || _;
|
|
2157
2159
|
const S = getGlobalShareScope();
|
|
2158
2160
|
let $ = !0;
|
|
2159
2161
|
const E = [];
|
|
@@ -2165,7 +2167,7 @@ class RemoteHandler {
|
|
|
2165
2167
|
const O = I[R];
|
|
2166
2168
|
O && Object.keys(O).forEach((P) => {
|
|
2167
2169
|
const w = O[P];
|
|
2168
|
-
w && typeof w == "object" && w.from ===
|
|
2170
|
+
w && typeof w == "object" && w.from === s.name && (w.loaded || w.loading ? (w.useIn = w.useIn.filter((N) => N !== s.name), w.useIn.length ? $ = !1 : E.push([
|
|
2169
2171
|
v,
|
|
2170
2172
|
A,
|
|
2171
2173
|
R,
|
|
@@ -2179,10 +2181,10 @@ class RemoteHandler {
|
|
|
2179
2181
|
});
|
|
2180
2182
|
});
|
|
2181
2183
|
});
|
|
2182
|
-
}), $ && (b.shareScopeMap = {}, delete S[
|
|
2184
|
+
}), $ && (b.shareScopeMap = {}, delete S[_]), E.forEach(([v, T, A, I]) => {
|
|
2183
2185
|
var R, O, P;
|
|
2184
2186
|
(P = S[v]) == null || (O = P[T]) == null || (R = O[A]) == null || delete R[I];
|
|
2185
|
-
}), globalThis.__FEDERATION__.__INSTANCES__.splice(
|
|
2187
|
+
}), globalThis.__FEDERATION__.__INSTANCES__.splice(y, 1);
|
|
2186
2188
|
}
|
|
2187
2189
|
const { hostGlobalSnapshot: m } = getGlobalRemoteInfo(e, o);
|
|
2188
2190
|
if (m) {
|
|
@@ -2234,11 +2236,11 @@ class FederationHost {
|
|
|
2234
2236
|
const r = getRemoteInfo({
|
|
2235
2237
|
name: e,
|
|
2236
2238
|
entry: n
|
|
2237
|
-
}),
|
|
2239
|
+
}), l = new Module({
|
|
2238
2240
|
host: this,
|
|
2239
2241
|
remoteInfo: r
|
|
2240
2242
|
});
|
|
2241
|
-
return
|
|
2243
|
+
return l.remoteEntryExports = o, this.moduleCache.set(e, l), l;
|
|
2242
2244
|
}
|
|
2243
2245
|
// eslint-disable-next-line max-lines-per-function
|
|
2244
2246
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
@@ -2253,21 +2255,21 @@ class FederationHost {
|
|
|
2253
2255
|
this.sharedHandler.initShareScopeMap(e, n, o);
|
|
2254
2256
|
}
|
|
2255
2257
|
formatOptions(e, n) {
|
|
2256
|
-
const { shared: o } = formatShareConfigs(e, n), { userOptions: r, options:
|
|
2258
|
+
const { shared: o } = formatShareConfigs(e, n), { userOptions: r, options: l } = this.hooks.lifecycle.beforeInit.emit({
|
|
2257
2259
|
origin: this,
|
|
2258
2260
|
userOptions: n,
|
|
2259
2261
|
options: e,
|
|
2260
2262
|
shareInfo: o
|
|
2261
|
-
}), u = this.remoteHandler.formatAndRegisterRemote(
|
|
2262
|
-
...
|
|
2263
|
+
}), u = this.remoteHandler.formatAndRegisterRemote(l, r), { shared: s } = this.sharedHandler.registerShared(l, r), d = [
|
|
2264
|
+
...l.plugins
|
|
2263
2265
|
];
|
|
2264
|
-
r.plugins && r.plugins.forEach((
|
|
2265
|
-
d.includes(
|
|
2266
|
+
r.plugins && r.plugins.forEach((_) => {
|
|
2267
|
+
d.includes(_) || d.push(_);
|
|
2266
2268
|
});
|
|
2267
2269
|
const p = _extends$1({}, e, n, {
|
|
2268
2270
|
plugins: d,
|
|
2269
2271
|
remotes: u,
|
|
2270
|
-
shared:
|
|
2272
|
+
shared: s
|
|
2271
2273
|
});
|
|
2272
2274
|
return this.hooks.lifecycle.init.emit({
|
|
2273
2275
|
origin: this,
|
|
@@ -2282,7 +2284,7 @@ class FederationHost {
|
|
|
2282
2284
|
this.snapshotHandler.hooks,
|
|
2283
2285
|
this.loaderHook
|
|
2284
2286
|
]);
|
|
2285
|
-
this.options.plugins = this.options.plugins.reduce((o, r) => (r && o && !o.find((
|
|
2287
|
+
this.options.plugins = this.options.plugins.reduce((o, r) => (r && o && !o.find((l) => l.name === r.name) && o.push(r), o), n || []);
|
|
2286
2288
|
}
|
|
2287
2289
|
registerRemotes(e, n) {
|
|
2288
2290
|
return this.remoteHandler.registerRemotes(e, n);
|
|
@@ -2295,7 +2297,7 @@ class FederationHost {
|
|
|
2295
2297
|
beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
|
|
2296
2298
|
// maybe will change, temporarily for internal use only
|
|
2297
2299
|
initContainer: new AsyncWaterfallHook("initContainer")
|
|
2298
|
-
}), this.version = "0.6.
|
|
2300
|
+
}), this.version = "0.6.6", this.moduleCache = /* @__PURE__ */ new Map(), this.loaderHook = new PluginSystem({
|
|
2299
2301
|
// FIXME: may not be suitable , not open to the public yet
|
|
2300
2302
|
getModuleInfo: new SyncHook(),
|
|
2301
2303
|
createScript: new SyncHook(),
|
|
@@ -2380,10 +2382,10 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2380
2382
|
providerInfo: Function
|
|
2381
2383
|
},
|
|
2382
2384
|
setup(t) {
|
|
2383
|
-
const e = ref(null), n = ref(null), o = ref(""), r = useRoute(),
|
|
2385
|
+
const e = ref(null), n = ref(null), o = ref(""), r = useRoute(), l = () => {
|
|
2384
2386
|
var p;
|
|
2385
|
-
const
|
|
2386
|
-
n.value =
|
|
2387
|
+
const s = (p = t.providerInfo) == null ? void 0 : p.call(t);
|
|
2388
|
+
n.value = s;
|
|
2387
2389
|
const d = {
|
|
2388
2390
|
name: t.moduleName,
|
|
2389
2391
|
dom: e.value,
|
|
@@ -2392,17 +2394,17 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2392
2394
|
};
|
|
2393
2395
|
LoggerInstance.log("createRemoteComponent LazyComponent render >>>", d), pluginSystem.lifecycle.beforeBridgeRender.emit({
|
|
2394
2396
|
...d
|
|
2395
|
-
}),
|
|
2396
|
-
}, u = watch(() => r.path, (
|
|
2397
|
-
|
|
2397
|
+
}), s.render(d);
|
|
2398
|
+
}, u = watch(() => r.path, (s) => {
|
|
2399
|
+
s !== r.path && l(), o.value !== "" && o.value !== s && (LoggerInstance.log("createRemoteComponent dispatchPopstateEnv >>>", {
|
|
2398
2400
|
...t,
|
|
2399
2401
|
pathname: r.path
|
|
2400
|
-
}), f()), o.value =
|
|
2402
|
+
}), f()), o.value = s;
|
|
2401
2403
|
});
|
|
2402
2404
|
return onMounted(() => {
|
|
2403
|
-
|
|
2405
|
+
l();
|
|
2404
2406
|
}), onBeforeUnmount(() => {
|
|
2405
|
-
var
|
|
2407
|
+
var s;
|
|
2406
2408
|
LoggerInstance.log("createRemoteComponent LazyComponent destroy >>>", {
|
|
2407
2409
|
...t
|
|
2408
2410
|
}), u(), pluginSystem.lifecycle.beforeBridgeDestroy.emit({
|
|
@@ -2410,7 +2412,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2410
2412
|
dom: e.value,
|
|
2411
2413
|
basename: t.basename,
|
|
2412
2414
|
memoryRoute: t.memoryRoute
|
|
2413
|
-
}), (
|
|
2415
|
+
}), (s = n.value) == null || s.destroy({
|
|
2414
2416
|
dom: e.value
|
|
2415
2417
|
});
|
|
2416
2418
|
}), () => createVNode("div", {
|
|
@@ -2420,7 +2422,7 @@ const RemoteApp = /* @__PURE__ */ defineComponent({
|
|
|
2420
2422
|
});
|
|
2421
2423
|
function createRemoteComponent(t) {
|
|
2422
2424
|
return defineAsyncComponent({
|
|
2423
|
-
__APP_VERSION__: "0.6.
|
|
2425
|
+
__APP_VERSION__: "0.6.6",
|
|
2424
2426
|
//@ts-ignore
|
|
2425
2427
|
loader: async () => {
|
|
2426
2428
|
var d;
|
|
@@ -2433,17 +2435,17 @@ function createRemoteComponent(t) {
|
|
|
2433
2435
|
basename: n,
|
|
2434
2436
|
info: t
|
|
2435
2437
|
});
|
|
2436
|
-
const
|
|
2438
|
+
const l = await t.loader(), u = l && l[Symbol.for("mf_module_id")], s = l[r];
|
|
2437
2439
|
if (LoggerInstance.log(
|
|
2438
2440
|
"createRemoteComponent LazyComponent loadRemote info >>>",
|
|
2439
|
-
{ name: u, module:
|
|
2440
|
-
), r in
|
|
2441
|
+
{ name: u, module: l, exportName: r, basename: n, route: e }
|
|
2442
|
+
), r in l && typeof s == "function")
|
|
2441
2443
|
return {
|
|
2442
2444
|
render() {
|
|
2443
2445
|
return h(RemoteApp, {
|
|
2444
2446
|
moduleName: u,
|
|
2445
2447
|
...t,
|
|
2446
|
-
providerInfo:
|
|
2448
|
+
providerInfo: s,
|
|
2447
2449
|
basename: n
|
|
2448
2450
|
});
|
|
2449
2451
|
}
|