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