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