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