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