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