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