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