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