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