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