@luzmo/embed 6.8.0-es2021 → 6.9.0-es2021
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 +5 -0
- package/index.cjs +1 -1
- package/index.js +1 -1
- package/luzmo-embed.min.js +4152 -152
- package/package.json +2 -2
package/luzmo-embed.min.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
(function(g,f){if(typeof define=="function"&&define.amd){define(f)}else if(typeof exports=="object" && typeof module<"u"){module.exports=f()}else{var m=f();for(var i in m) g[i]=m[i]}}(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : this,function(){var exports={};var __exports=exports;var module={exports};
|
|
2
2
|
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __commonJS = (cb2, mod) => function __require() {
|
|
10
|
+
return mod || (0, cb2[__getOwnPropNames(cb2)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
+
};
|
|
7
12
|
var __export = (target, all) => {
|
|
8
13
|
for (var name in all)
|
|
9
14
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -14,17 +19,4036 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
19
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
20
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
21
|
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
32
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
33
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
34
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
35
|
+
for (var i7 = decorators.length - 1, decorator; i7 >= 0; i7--)
|
|
36
|
+
if (decorator = decorators[i7])
|
|
37
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
38
|
+
if (kind && result) __defProp(target, key, result);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// node_modules/@module-federation/sdk/dist/index.cjs.cjs
|
|
43
|
+
var require_index_cjs = __commonJS({
|
|
44
|
+
"node_modules/@module-federation/sdk/dist/index.cjs.cjs"(exports, module) {
|
|
45
|
+
"use strict";
|
|
46
|
+
var FederationModuleManifest = "federation-manifest.json";
|
|
47
|
+
var MANIFEST_EXT = ".json";
|
|
48
|
+
var BROWSER_LOG_KEY = "FEDERATION_DEBUG";
|
|
49
|
+
var NameTransformSymbol = {
|
|
50
|
+
AT: "@",
|
|
51
|
+
HYPHEN: "-",
|
|
52
|
+
SLASH: "/"
|
|
53
|
+
};
|
|
54
|
+
var NameTransformMap = {
|
|
55
|
+
[NameTransformSymbol.AT]: "scope_",
|
|
56
|
+
[NameTransformSymbol.HYPHEN]: "_",
|
|
57
|
+
[NameTransformSymbol.SLASH]: "__"
|
|
58
|
+
};
|
|
59
|
+
var EncodedNameTransformMap = {
|
|
60
|
+
[NameTransformMap[NameTransformSymbol.AT]]: NameTransformSymbol.AT,
|
|
61
|
+
[NameTransformMap[NameTransformSymbol.HYPHEN]]: NameTransformSymbol.HYPHEN,
|
|
62
|
+
[NameTransformMap[NameTransformSymbol.SLASH]]: NameTransformSymbol.SLASH
|
|
63
|
+
};
|
|
64
|
+
var SEPARATOR = ":";
|
|
65
|
+
var ManifestFileName = "mf-manifest.json";
|
|
66
|
+
var StatsFileName = "mf-stats.json";
|
|
67
|
+
var MFModuleType = {
|
|
68
|
+
NPM: "npm",
|
|
69
|
+
APP: "app"
|
|
70
|
+
};
|
|
71
|
+
var MODULE_DEVTOOL_IDENTIFIER = "__MF_DEVTOOLS_MODULE_INFO__";
|
|
72
|
+
var ENCODE_NAME_PREFIX = "ENCODE_NAME_PREFIX";
|
|
73
|
+
var TEMP_DIR = ".federation";
|
|
74
|
+
var MFPrefetchCommon = {
|
|
75
|
+
identifier: "MFDataPrefetch",
|
|
76
|
+
globalKey: "__PREFETCH__",
|
|
77
|
+
library: "mf-data-prefetch",
|
|
78
|
+
exportsKey: "__PREFETCH_EXPORTS__",
|
|
79
|
+
fileName: "bootstrap.js"
|
|
80
|
+
};
|
|
81
|
+
var ContainerPlugin = /* @__PURE__ */ Object.freeze({
|
|
82
|
+
__proto__: null
|
|
83
|
+
});
|
|
84
|
+
var ContainerReferencePlugin = /* @__PURE__ */ Object.freeze({
|
|
85
|
+
__proto__: null
|
|
86
|
+
});
|
|
87
|
+
var ModuleFederationPlugin = /* @__PURE__ */ Object.freeze({
|
|
88
|
+
__proto__: null
|
|
89
|
+
});
|
|
90
|
+
var SharePlugin = /* @__PURE__ */ Object.freeze({
|
|
91
|
+
__proto__: null
|
|
92
|
+
});
|
|
93
|
+
function isBrowserEnv() {
|
|
94
|
+
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
95
|
+
}
|
|
96
|
+
function isReactNativeEnv() {
|
|
97
|
+
return typeof navigator !== "undefined" && navigator?.product === "ReactNative";
|
|
98
|
+
}
|
|
99
|
+
function isBrowserDebug() {
|
|
100
|
+
try {
|
|
101
|
+
if (isBrowserEnv() && window.localStorage) {
|
|
102
|
+
return Boolean(localStorage.getItem(BROWSER_LOG_KEY));
|
|
103
|
+
}
|
|
104
|
+
} catch (error2) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
function isDebugMode() {
|
|
110
|
+
if (typeof process !== "undefined" && process.env && process.env["FEDERATION_DEBUG"]) {
|
|
111
|
+
return Boolean(process.env["FEDERATION_DEBUG"]);
|
|
112
|
+
}
|
|
113
|
+
if (typeof FEDERATION_DEBUG !== "undefined" && Boolean(FEDERATION_DEBUG)) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
return isBrowserDebug();
|
|
117
|
+
}
|
|
118
|
+
var getProcessEnv = function() {
|
|
119
|
+
return typeof process !== "undefined" && process.env ? process.env : {};
|
|
120
|
+
};
|
|
121
|
+
var LOG_CATEGORY = "[ Federation Runtime ]";
|
|
122
|
+
var parseEntry = (str, devVerOrUrl, separator = SEPARATOR) => {
|
|
123
|
+
const strSplit = str.split(separator);
|
|
124
|
+
const devVersionOrUrl = getProcessEnv()["NODE_ENV"] === "development" && devVerOrUrl;
|
|
125
|
+
const defaultVersion = "*";
|
|
126
|
+
const isEntry = (s4) => s4.startsWith("http") || s4.includes(MANIFEST_EXT);
|
|
127
|
+
if (strSplit.length >= 2) {
|
|
128
|
+
let [name, ...versionOrEntryArr] = strSplit;
|
|
129
|
+
if (str.startsWith(separator)) {
|
|
130
|
+
name = strSplit.slice(0, 2).join(separator);
|
|
131
|
+
versionOrEntryArr = [
|
|
132
|
+
devVersionOrUrl || strSplit.slice(2).join(separator)
|
|
133
|
+
];
|
|
134
|
+
}
|
|
135
|
+
let versionOrEntry = devVersionOrUrl || versionOrEntryArr.join(separator);
|
|
136
|
+
if (isEntry(versionOrEntry)) {
|
|
137
|
+
return {
|
|
138
|
+
name,
|
|
139
|
+
entry: versionOrEntry
|
|
140
|
+
};
|
|
141
|
+
} else {
|
|
142
|
+
return {
|
|
143
|
+
name,
|
|
144
|
+
version: versionOrEntry || defaultVersion
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
} else if (strSplit.length === 1) {
|
|
148
|
+
const [name] = strSplit;
|
|
149
|
+
if (devVersionOrUrl && isEntry(devVersionOrUrl)) {
|
|
150
|
+
return {
|
|
151
|
+
name,
|
|
152
|
+
entry: devVersionOrUrl
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
name,
|
|
157
|
+
version: devVersionOrUrl || defaultVersion
|
|
158
|
+
};
|
|
159
|
+
} else {
|
|
160
|
+
throw `Invalid entry value: ${str}`;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
var composeKeyWithSeparator = function(...args) {
|
|
164
|
+
if (!args.length) {
|
|
165
|
+
return "";
|
|
166
|
+
}
|
|
167
|
+
return args.reduce((sum, cur) => {
|
|
168
|
+
if (!cur) {
|
|
169
|
+
return sum;
|
|
170
|
+
}
|
|
171
|
+
if (!sum) {
|
|
172
|
+
return cur;
|
|
173
|
+
}
|
|
174
|
+
return `${sum}${SEPARATOR}${cur}`;
|
|
175
|
+
}, "");
|
|
176
|
+
};
|
|
177
|
+
var encodeName = function(name, prefix = "", withExt = false) {
|
|
178
|
+
try {
|
|
179
|
+
const ext = withExt ? ".js" : "";
|
|
180
|
+
return `${prefix}${name.replace(new RegExp(`${NameTransformSymbol.AT}`, "g"), NameTransformMap[NameTransformSymbol.AT]).replace(new RegExp(`${NameTransformSymbol.HYPHEN}`, "g"), NameTransformMap[NameTransformSymbol.HYPHEN]).replace(new RegExp(`${NameTransformSymbol.SLASH}`, "g"), NameTransformMap[NameTransformSymbol.SLASH])}${ext}`;
|
|
181
|
+
} catch (err) {
|
|
182
|
+
throw err;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
var decodeName = function(name, prefix, withExt) {
|
|
186
|
+
try {
|
|
187
|
+
let decodedName = name;
|
|
188
|
+
if (prefix) {
|
|
189
|
+
if (!decodedName.startsWith(prefix)) {
|
|
190
|
+
return decodedName;
|
|
191
|
+
}
|
|
192
|
+
decodedName = decodedName.replace(new RegExp(prefix, "g"), "");
|
|
193
|
+
}
|
|
194
|
+
decodedName = decodedName.replace(new RegExp(`${NameTransformMap[NameTransformSymbol.AT]}`, "g"), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.AT]]).replace(new RegExp(`${NameTransformMap[NameTransformSymbol.SLASH]}`, "g"), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.SLASH]]).replace(new RegExp(`${NameTransformMap[NameTransformSymbol.HYPHEN]}`, "g"), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.HYPHEN]]);
|
|
195
|
+
if (withExt) {
|
|
196
|
+
decodedName = decodedName.replace(".js", "");
|
|
197
|
+
}
|
|
198
|
+
return decodedName;
|
|
199
|
+
} catch (err) {
|
|
200
|
+
throw err;
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
var generateExposeFilename = (exposeName, withExt) => {
|
|
204
|
+
if (!exposeName) {
|
|
205
|
+
return "";
|
|
206
|
+
}
|
|
207
|
+
let expose = exposeName;
|
|
208
|
+
if (expose === ".") {
|
|
209
|
+
expose = "default_export";
|
|
210
|
+
}
|
|
211
|
+
if (expose.startsWith("./")) {
|
|
212
|
+
expose = expose.replace("./", "");
|
|
213
|
+
}
|
|
214
|
+
return encodeName(expose, "__federation_expose_", withExt);
|
|
215
|
+
};
|
|
216
|
+
var generateShareFilename = (pkgName, withExt) => {
|
|
217
|
+
if (!pkgName) {
|
|
218
|
+
return "";
|
|
219
|
+
}
|
|
220
|
+
return encodeName(pkgName, "__federation_shared_", withExt);
|
|
221
|
+
};
|
|
222
|
+
var getResourceUrl = (module2, sourceUrl) => {
|
|
223
|
+
if ("getPublicPath" in module2) {
|
|
224
|
+
let publicPath;
|
|
225
|
+
if (!module2.getPublicPath.startsWith("function")) {
|
|
226
|
+
publicPath = new Function(module2.getPublicPath)();
|
|
227
|
+
} else {
|
|
228
|
+
publicPath = new Function("return " + module2.getPublicPath)()();
|
|
229
|
+
}
|
|
230
|
+
return `${publicPath}${sourceUrl}`;
|
|
231
|
+
} else if ("publicPath" in module2) {
|
|
232
|
+
if (!isBrowserEnv() && !isReactNativeEnv() && "ssrPublicPath" in module2) {
|
|
233
|
+
return `${module2.ssrPublicPath}${sourceUrl}`;
|
|
234
|
+
}
|
|
235
|
+
return `${module2.publicPath}${sourceUrl}`;
|
|
236
|
+
} else {
|
|
237
|
+
console.warn("Cannot get resource URL. If in debug mode, please ignore.", module2, sourceUrl);
|
|
238
|
+
return "";
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
var assert = (condition, msg) => {
|
|
242
|
+
if (!condition) {
|
|
243
|
+
error(msg);
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
var error = (msg) => {
|
|
247
|
+
throw new Error(`${LOG_CATEGORY}: ${msg}`);
|
|
248
|
+
};
|
|
249
|
+
var warn = (msg) => {
|
|
250
|
+
console.warn(`${LOG_CATEGORY}: ${msg}`);
|
|
251
|
+
};
|
|
252
|
+
function safeToString(info) {
|
|
253
|
+
try {
|
|
254
|
+
return JSON.stringify(info, null, 2);
|
|
255
|
+
} catch (e7) {
|
|
256
|
+
return "";
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
var VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
|
|
260
|
+
function isRequiredVersion(str) {
|
|
261
|
+
return VERSION_PATTERN_REGEXP.test(str);
|
|
262
|
+
}
|
|
263
|
+
var simpleJoinRemoteEntry = (rPath, rName) => {
|
|
264
|
+
if (!rPath) {
|
|
265
|
+
return rName;
|
|
266
|
+
}
|
|
267
|
+
const transformPath = (str) => {
|
|
268
|
+
if (str === ".") {
|
|
269
|
+
return "";
|
|
270
|
+
}
|
|
271
|
+
if (str.startsWith("./")) {
|
|
272
|
+
return str.replace("./", "");
|
|
273
|
+
}
|
|
274
|
+
if (str.startsWith("/")) {
|
|
275
|
+
const strWithoutSlash = str.slice(1);
|
|
276
|
+
if (strWithoutSlash.endsWith("/")) {
|
|
277
|
+
return strWithoutSlash.slice(0, -1);
|
|
278
|
+
}
|
|
279
|
+
return strWithoutSlash;
|
|
280
|
+
}
|
|
281
|
+
return str;
|
|
282
|
+
};
|
|
283
|
+
const transformedPath = transformPath(rPath);
|
|
284
|
+
if (!transformedPath) {
|
|
285
|
+
return rName;
|
|
286
|
+
}
|
|
287
|
+
if (transformedPath.endsWith("/")) {
|
|
288
|
+
return `${transformedPath}${rName}`;
|
|
289
|
+
}
|
|
290
|
+
return `${transformedPath}/${rName}`;
|
|
291
|
+
};
|
|
292
|
+
function inferAutoPublicPath(url2) {
|
|
293
|
+
return url2.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
|
|
294
|
+
}
|
|
295
|
+
function generateSnapshotFromManifest(manifest, options = {}) {
|
|
296
|
+
const { remotes = {}, overrides = {}, version: version2 } = options;
|
|
297
|
+
let remoteSnapshot;
|
|
298
|
+
const getPublicPath = () => {
|
|
299
|
+
if ("publicPath" in manifest.metaData) {
|
|
300
|
+
if (manifest.metaData.publicPath === "auto" && version2) {
|
|
301
|
+
return inferAutoPublicPath(version2);
|
|
302
|
+
}
|
|
303
|
+
return manifest.metaData.publicPath;
|
|
304
|
+
} else {
|
|
305
|
+
return manifest.metaData.getPublicPath;
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
const overridesKeys = Object.keys(overrides);
|
|
309
|
+
let remotesInfo = {};
|
|
310
|
+
if (!Object.keys(remotes).length) {
|
|
311
|
+
remotesInfo = manifest.remotes?.reduce((res2, next) => {
|
|
312
|
+
let matchedVersion;
|
|
313
|
+
const name = next.federationContainerName;
|
|
314
|
+
if (overridesKeys.includes(name)) {
|
|
315
|
+
matchedVersion = overrides[name];
|
|
316
|
+
} else {
|
|
317
|
+
if ("version" in next) {
|
|
318
|
+
matchedVersion = next.version;
|
|
319
|
+
} else {
|
|
320
|
+
matchedVersion = next.entry;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
res2[name] = {
|
|
324
|
+
matchedVersion
|
|
325
|
+
};
|
|
326
|
+
return res2;
|
|
327
|
+
}, {}) || {};
|
|
328
|
+
}
|
|
329
|
+
Object.keys(remotes).forEach((key) => remotesInfo[key] = {
|
|
330
|
+
// overrides will override dependencies
|
|
331
|
+
matchedVersion: overridesKeys.includes(key) ? overrides[key] : remotes[key]
|
|
332
|
+
});
|
|
333
|
+
const { remoteEntry: { path: remoteEntryPath, name: remoteEntryName, type: remoteEntryType }, types: remoteTypes = { path: "", name: "", zip: "", api: "" }, buildInfo: { buildVersion }, globalName, ssrRemoteEntry } = manifest.metaData;
|
|
334
|
+
const { exposes } = manifest;
|
|
335
|
+
let basicRemoteSnapshot = {
|
|
336
|
+
version: version2 ? version2 : "",
|
|
337
|
+
buildVersion,
|
|
338
|
+
globalName,
|
|
339
|
+
remoteEntry: simpleJoinRemoteEntry(remoteEntryPath, remoteEntryName),
|
|
340
|
+
remoteEntryType,
|
|
341
|
+
remoteTypes: simpleJoinRemoteEntry(remoteTypes.path, remoteTypes.name),
|
|
342
|
+
remoteTypesZip: remoteTypes.zip || "",
|
|
343
|
+
remoteTypesAPI: remoteTypes.api || "",
|
|
344
|
+
remotesInfo,
|
|
345
|
+
shared: manifest?.shared.map((item) => ({
|
|
346
|
+
assets: item.assets,
|
|
347
|
+
sharedName: item.name,
|
|
348
|
+
version: item.version
|
|
349
|
+
})),
|
|
350
|
+
modules: exposes?.map((expose) => ({
|
|
351
|
+
moduleName: expose.name,
|
|
352
|
+
modulePath: expose.path,
|
|
353
|
+
assets: expose.assets
|
|
354
|
+
}))
|
|
355
|
+
};
|
|
356
|
+
if (manifest.metaData?.prefetchInterface) {
|
|
357
|
+
const prefetchInterface = manifest.metaData.prefetchInterface;
|
|
358
|
+
basicRemoteSnapshot = {
|
|
359
|
+
...basicRemoteSnapshot,
|
|
360
|
+
prefetchInterface
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
if (manifest.metaData?.prefetchEntry) {
|
|
364
|
+
const { path: path2, name, type } = manifest.metaData.prefetchEntry;
|
|
365
|
+
basicRemoteSnapshot = {
|
|
366
|
+
...basicRemoteSnapshot,
|
|
367
|
+
prefetchEntry: simpleJoinRemoteEntry(path2, name),
|
|
368
|
+
prefetchEntryType: type
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
if ("publicPath" in manifest.metaData) {
|
|
372
|
+
remoteSnapshot = {
|
|
373
|
+
...basicRemoteSnapshot,
|
|
374
|
+
publicPath: getPublicPath(),
|
|
375
|
+
ssrPublicPath: manifest.metaData.ssrPublicPath
|
|
376
|
+
};
|
|
377
|
+
} else {
|
|
378
|
+
remoteSnapshot = {
|
|
379
|
+
...basicRemoteSnapshot,
|
|
380
|
+
getPublicPath: getPublicPath()
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
if (ssrRemoteEntry) {
|
|
384
|
+
const fullSSRRemoteEntry = simpleJoinRemoteEntry(ssrRemoteEntry.path, ssrRemoteEntry.name);
|
|
385
|
+
remoteSnapshot.ssrRemoteEntry = fullSSRRemoteEntry;
|
|
386
|
+
remoteSnapshot.ssrRemoteEntryType = ssrRemoteEntry.type || "commonjs-module";
|
|
387
|
+
}
|
|
388
|
+
return remoteSnapshot;
|
|
389
|
+
}
|
|
390
|
+
function isManifestProvider(moduleInfo) {
|
|
391
|
+
if ("remoteEntry" in moduleInfo && moduleInfo.remoteEntry.includes(MANIFEST_EXT)) {
|
|
392
|
+
return true;
|
|
393
|
+
} else {
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
function getManifestFileName(manifestOptions) {
|
|
398
|
+
if (!manifestOptions) {
|
|
399
|
+
return {
|
|
400
|
+
statsFileName: StatsFileName,
|
|
401
|
+
manifestFileName: ManifestFileName
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
let filePath = typeof manifestOptions === "boolean" ? "" : manifestOptions.filePath || "";
|
|
405
|
+
let fileName = typeof manifestOptions === "boolean" ? "" : manifestOptions.fileName || "";
|
|
406
|
+
const JSON_EXT = ".json";
|
|
407
|
+
const addExt = (name) => {
|
|
408
|
+
if (name.endsWith(JSON_EXT)) {
|
|
409
|
+
return name;
|
|
410
|
+
}
|
|
411
|
+
return `${name}${JSON_EXT}`;
|
|
412
|
+
};
|
|
413
|
+
const insertSuffix = (name, suffix) => {
|
|
414
|
+
return name.replace(JSON_EXT, `${suffix}${JSON_EXT}`);
|
|
415
|
+
};
|
|
416
|
+
const manifestFileName = fileName ? addExt(fileName) : ManifestFileName;
|
|
417
|
+
const statsFileName = fileName ? insertSuffix(manifestFileName, "-stats") : StatsFileName;
|
|
418
|
+
return {
|
|
419
|
+
statsFileName: simpleJoinRemoteEntry(filePath, statsFileName),
|
|
420
|
+
manifestFileName: simpleJoinRemoteEntry(filePath, manifestFileName)
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
var PREFIX = "[ Module Federation ]";
|
|
424
|
+
var DEFAULT_DELEGATE = console;
|
|
425
|
+
var LOGGER_STACK_SKIP_TOKENS = [
|
|
426
|
+
"logger.ts",
|
|
427
|
+
"logger.js",
|
|
428
|
+
"captureStackTrace",
|
|
429
|
+
"Logger.emit",
|
|
430
|
+
"Logger.log",
|
|
431
|
+
"Logger.info",
|
|
432
|
+
"Logger.warn",
|
|
433
|
+
"Logger.error",
|
|
434
|
+
"Logger.debug"
|
|
435
|
+
];
|
|
436
|
+
function captureStackTrace() {
|
|
437
|
+
try {
|
|
438
|
+
const stack = new Error().stack;
|
|
439
|
+
if (!stack) {
|
|
440
|
+
return void 0;
|
|
441
|
+
}
|
|
442
|
+
const [, ...rawLines] = stack.split("\n");
|
|
443
|
+
const filtered = rawLines.filter((line) => !LOGGER_STACK_SKIP_TOKENS.some((token) => line.includes(token)));
|
|
444
|
+
if (!filtered.length) {
|
|
445
|
+
return void 0;
|
|
446
|
+
}
|
|
447
|
+
const stackPreview = filtered.slice(0, 5).join("\n");
|
|
448
|
+
return `Stack trace:
|
|
449
|
+
${stackPreview}`;
|
|
450
|
+
} catch {
|
|
451
|
+
return void 0;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
var Logger = class {
|
|
455
|
+
constructor(prefix, delegate = DEFAULT_DELEGATE) {
|
|
456
|
+
this.prefix = prefix;
|
|
457
|
+
this.delegate = delegate ?? DEFAULT_DELEGATE;
|
|
458
|
+
}
|
|
459
|
+
setPrefix(prefix) {
|
|
460
|
+
this.prefix = prefix;
|
|
461
|
+
}
|
|
462
|
+
setDelegate(delegate) {
|
|
463
|
+
this.delegate = delegate ?? DEFAULT_DELEGATE;
|
|
464
|
+
}
|
|
465
|
+
emit(method, args) {
|
|
466
|
+
const delegate = this.delegate;
|
|
467
|
+
const debugMode = isDebugMode();
|
|
468
|
+
const stackTrace = debugMode ? captureStackTrace() : void 0;
|
|
469
|
+
const enrichedArgs = stackTrace ? [...args, stackTrace] : args;
|
|
470
|
+
const order = (() => {
|
|
471
|
+
switch (method) {
|
|
472
|
+
case "log":
|
|
473
|
+
return ["log", "info"];
|
|
474
|
+
case "info":
|
|
475
|
+
return ["info", "log"];
|
|
476
|
+
case "warn":
|
|
477
|
+
return ["warn", "info", "log"];
|
|
478
|
+
case "error":
|
|
479
|
+
return ["error", "warn", "log"];
|
|
480
|
+
case "debug":
|
|
481
|
+
default:
|
|
482
|
+
return ["debug", "log"];
|
|
483
|
+
}
|
|
484
|
+
})();
|
|
485
|
+
for (const candidate of order) {
|
|
486
|
+
const handler = delegate[candidate];
|
|
487
|
+
if (typeof handler === "function") {
|
|
488
|
+
handler.call(delegate, this.prefix, ...enrichedArgs);
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
for (const candidate of order) {
|
|
493
|
+
const handler = DEFAULT_DELEGATE[candidate];
|
|
494
|
+
if (typeof handler === "function") {
|
|
495
|
+
handler.call(DEFAULT_DELEGATE, this.prefix, ...enrichedArgs);
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
log(...args) {
|
|
501
|
+
this.emit("log", args);
|
|
502
|
+
}
|
|
503
|
+
warn(...args) {
|
|
504
|
+
this.emit("warn", args);
|
|
505
|
+
}
|
|
506
|
+
error(...args) {
|
|
507
|
+
this.emit("error", args);
|
|
508
|
+
}
|
|
509
|
+
success(...args) {
|
|
510
|
+
this.emit("info", args);
|
|
511
|
+
}
|
|
512
|
+
info(...args) {
|
|
513
|
+
this.emit("info", args);
|
|
514
|
+
}
|
|
515
|
+
ready(...args) {
|
|
516
|
+
this.emit("info", args);
|
|
517
|
+
}
|
|
518
|
+
debug(...args) {
|
|
519
|
+
if (isDebugMode()) {
|
|
520
|
+
this.emit("debug", args);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
function createLogger(prefix) {
|
|
525
|
+
return new Logger(prefix);
|
|
526
|
+
}
|
|
527
|
+
function createInfrastructureLogger(prefix) {
|
|
528
|
+
const infrastructureLogger2 = new Logger(prefix);
|
|
529
|
+
Object.defineProperty(infrastructureLogger2, "__mf_infrastructure_logger__", {
|
|
530
|
+
value: true,
|
|
531
|
+
enumerable: false,
|
|
532
|
+
configurable: false
|
|
533
|
+
});
|
|
534
|
+
return infrastructureLogger2;
|
|
535
|
+
}
|
|
536
|
+
function bindLoggerToCompiler(loggerInstance, compiler, name) {
|
|
537
|
+
if (!loggerInstance.__mf_infrastructure_logger__) {
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
if (!compiler?.getInfrastructureLogger) {
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
try {
|
|
544
|
+
const infrastructureLogger2 = compiler.getInfrastructureLogger(name);
|
|
545
|
+
if (infrastructureLogger2 && typeof infrastructureLogger2 === "object" && (typeof infrastructureLogger2.log === "function" || typeof infrastructureLogger2.info === "function" || typeof infrastructureLogger2.warn === "function" || typeof infrastructureLogger2.error === "function")) {
|
|
546
|
+
loggerInstance.setDelegate(infrastructureLogger2);
|
|
547
|
+
}
|
|
548
|
+
} catch {
|
|
549
|
+
loggerInstance.setDelegate(void 0);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
var logger = createLogger(PREFIX);
|
|
553
|
+
var infrastructureLogger = createInfrastructureLogger(PREFIX);
|
|
554
|
+
async function safeWrapper(callback, disableWarn) {
|
|
555
|
+
try {
|
|
556
|
+
const res2 = await callback();
|
|
557
|
+
return res2;
|
|
558
|
+
} catch (e7) {
|
|
559
|
+
!disableWarn && warn(e7);
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
function isStaticResourcesEqual(url1, url2) {
|
|
564
|
+
const REG_EXP = /^(https?:)?\/\//i;
|
|
565
|
+
const relativeUrl1 = url1.replace(REG_EXP, "").replace(/\/$/, "");
|
|
566
|
+
const relativeUrl2 = url2.replace(REG_EXP, "").replace(/\/$/, "");
|
|
567
|
+
return relativeUrl1 === relativeUrl2;
|
|
568
|
+
}
|
|
569
|
+
function createScript(info) {
|
|
570
|
+
let script2 = null;
|
|
571
|
+
let needAttach = true;
|
|
572
|
+
let timeout = 2e4;
|
|
573
|
+
let timeoutId;
|
|
574
|
+
const scripts = document.getElementsByTagName("script");
|
|
575
|
+
for (let i7 = 0; i7 < scripts.length; i7++) {
|
|
576
|
+
const s4 = scripts[i7];
|
|
577
|
+
const scriptSrc = s4.getAttribute("src");
|
|
578
|
+
if (scriptSrc && isStaticResourcesEqual(scriptSrc, info.url)) {
|
|
579
|
+
script2 = s4;
|
|
580
|
+
needAttach = false;
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
if (!script2) {
|
|
585
|
+
const attrs2 = info.attrs;
|
|
586
|
+
script2 = document.createElement("script");
|
|
587
|
+
script2.type = attrs2?.["type"] === "module" ? "module" : "text/javascript";
|
|
588
|
+
let createScriptRes = void 0;
|
|
589
|
+
if (info.createScriptHook) {
|
|
590
|
+
createScriptRes = info.createScriptHook(info.url, info.attrs);
|
|
591
|
+
if (createScriptRes instanceof HTMLScriptElement) {
|
|
592
|
+
script2 = createScriptRes;
|
|
593
|
+
} else if (typeof createScriptRes === "object") {
|
|
594
|
+
if ("script" in createScriptRes && createScriptRes.script) {
|
|
595
|
+
script2 = createScriptRes.script;
|
|
596
|
+
}
|
|
597
|
+
if ("timeout" in createScriptRes && createScriptRes.timeout) {
|
|
598
|
+
timeout = createScriptRes.timeout;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
if (!script2.src) {
|
|
603
|
+
script2.src = info.url;
|
|
604
|
+
}
|
|
605
|
+
if (attrs2 && !createScriptRes) {
|
|
606
|
+
Object.keys(attrs2).forEach((name) => {
|
|
607
|
+
if (script2) {
|
|
608
|
+
if (name === "async" || name === "defer") {
|
|
609
|
+
script2[name] = attrs2[name];
|
|
610
|
+
} else if (!script2.getAttribute(name)) {
|
|
611
|
+
script2.setAttribute(name, attrs2[name]);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
const onScriptComplete = async (prev, event) => {
|
|
618
|
+
clearTimeout(timeoutId);
|
|
619
|
+
const onScriptCompleteCallback = () => {
|
|
620
|
+
if (event?.type === "error") {
|
|
621
|
+
info?.onErrorCallback && info?.onErrorCallback(event);
|
|
622
|
+
} else {
|
|
623
|
+
info?.cb && info?.cb();
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
if (script2) {
|
|
627
|
+
script2.onerror = null;
|
|
628
|
+
script2.onload = null;
|
|
629
|
+
safeWrapper(() => {
|
|
630
|
+
const { needDeleteScript = true } = info;
|
|
631
|
+
if (needDeleteScript) {
|
|
632
|
+
script2?.parentNode && script2.parentNode.removeChild(script2);
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
if (prev && typeof prev === "function") {
|
|
636
|
+
const result = prev(event);
|
|
637
|
+
if (result instanceof Promise) {
|
|
638
|
+
const res2 = await result;
|
|
639
|
+
onScriptCompleteCallback();
|
|
640
|
+
return res2;
|
|
641
|
+
}
|
|
642
|
+
onScriptCompleteCallback();
|
|
643
|
+
return result;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
onScriptCompleteCallback();
|
|
647
|
+
};
|
|
648
|
+
script2.onerror = onScriptComplete.bind(null, script2.onerror);
|
|
649
|
+
script2.onload = onScriptComplete.bind(null, script2.onload);
|
|
650
|
+
timeoutId = setTimeout(() => {
|
|
651
|
+
onScriptComplete(null, new Error(`Remote script "${info.url}" time-outed.`));
|
|
652
|
+
}, timeout);
|
|
653
|
+
return { script: script2, needAttach };
|
|
654
|
+
}
|
|
655
|
+
function createLink(info) {
|
|
656
|
+
let link = null;
|
|
657
|
+
let needAttach = true;
|
|
658
|
+
const links = document.getElementsByTagName("link");
|
|
659
|
+
for (let i7 = 0; i7 < links.length; i7++) {
|
|
660
|
+
const l3 = links[i7];
|
|
661
|
+
const linkHref = l3.getAttribute("href");
|
|
662
|
+
const linkRel = l3.getAttribute("rel");
|
|
663
|
+
if (linkHref && isStaticResourcesEqual(linkHref, info.url) && linkRel === info.attrs["rel"]) {
|
|
664
|
+
link = l3;
|
|
665
|
+
needAttach = false;
|
|
666
|
+
break;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
if (!link) {
|
|
670
|
+
link = document.createElement("link");
|
|
671
|
+
link.setAttribute("href", info.url);
|
|
672
|
+
let createLinkRes = void 0;
|
|
673
|
+
const attrs2 = info.attrs;
|
|
674
|
+
if (info.createLinkHook) {
|
|
675
|
+
createLinkRes = info.createLinkHook(info.url, attrs2);
|
|
676
|
+
if (createLinkRes instanceof HTMLLinkElement) {
|
|
677
|
+
link = createLinkRes;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
if (attrs2 && !createLinkRes) {
|
|
681
|
+
Object.keys(attrs2).forEach((name) => {
|
|
682
|
+
if (link && !link.getAttribute(name)) {
|
|
683
|
+
link.setAttribute(name, attrs2[name]);
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
const onLinkComplete = (prev, event) => {
|
|
689
|
+
const onLinkCompleteCallback = () => {
|
|
690
|
+
if (event?.type === "error") {
|
|
691
|
+
info?.onErrorCallback && info?.onErrorCallback(event);
|
|
692
|
+
} else {
|
|
693
|
+
info?.cb && info?.cb();
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
if (link) {
|
|
697
|
+
link.onerror = null;
|
|
698
|
+
link.onload = null;
|
|
699
|
+
safeWrapper(() => {
|
|
700
|
+
const { needDeleteLink = true } = info;
|
|
701
|
+
if (needDeleteLink) {
|
|
702
|
+
link?.parentNode && link.parentNode.removeChild(link);
|
|
703
|
+
}
|
|
704
|
+
});
|
|
705
|
+
if (prev) {
|
|
706
|
+
const res2 = prev(event);
|
|
707
|
+
onLinkCompleteCallback();
|
|
708
|
+
return res2;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
onLinkCompleteCallback();
|
|
712
|
+
};
|
|
713
|
+
link.onerror = onLinkComplete.bind(null, link.onerror);
|
|
714
|
+
link.onload = onLinkComplete.bind(null, link.onload);
|
|
715
|
+
return { link, needAttach };
|
|
716
|
+
}
|
|
717
|
+
function loadScript(url2, info) {
|
|
718
|
+
const { attrs: attrs2 = {}, createScriptHook } = info;
|
|
719
|
+
return new Promise((resolve, reject) => {
|
|
720
|
+
const { script: script2, needAttach } = createScript({
|
|
721
|
+
url: url2,
|
|
722
|
+
cb: resolve,
|
|
723
|
+
onErrorCallback: reject,
|
|
724
|
+
attrs: {
|
|
725
|
+
fetchpriority: "high",
|
|
726
|
+
...attrs2
|
|
727
|
+
},
|
|
728
|
+
createScriptHook,
|
|
729
|
+
needDeleteScript: true
|
|
730
|
+
});
|
|
731
|
+
needAttach && document.head.appendChild(script2);
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
var sdkImportCache = /* @__PURE__ */ new Map();
|
|
735
|
+
function importNodeModule(name) {
|
|
736
|
+
if (!name) {
|
|
737
|
+
throw new Error("import specifier is required");
|
|
738
|
+
}
|
|
739
|
+
if (sdkImportCache.has(name)) {
|
|
740
|
+
return sdkImportCache.get(name);
|
|
741
|
+
}
|
|
742
|
+
const importModule = new Function("name", `return import(name)`);
|
|
743
|
+
const promise = importModule(name).then((res2) => res2).catch((error2) => {
|
|
744
|
+
console.error(`Error importing module ${name}:`, error2);
|
|
745
|
+
sdkImportCache.delete(name);
|
|
746
|
+
throw error2;
|
|
747
|
+
});
|
|
748
|
+
sdkImportCache.set(name, promise);
|
|
749
|
+
return promise;
|
|
750
|
+
}
|
|
751
|
+
var loadNodeFetch = async () => {
|
|
752
|
+
const fetchModule = await importNodeModule("node-fetch");
|
|
753
|
+
return fetchModule.default || fetchModule;
|
|
754
|
+
};
|
|
755
|
+
var lazyLoaderHookFetch = async (input, init, loaderHook2) => {
|
|
756
|
+
const hook = (url2, init2) => {
|
|
757
|
+
return loaderHook2.lifecycle.fetch.emit(url2, init2);
|
|
758
|
+
};
|
|
759
|
+
const res2 = await hook(input, init || {});
|
|
760
|
+
if (!res2 || !(res2 instanceof Response)) {
|
|
761
|
+
const fetchFunction = typeof fetch === "undefined" ? await loadNodeFetch() : fetch;
|
|
762
|
+
return fetchFunction(input, init || {});
|
|
763
|
+
}
|
|
764
|
+
return res2;
|
|
765
|
+
};
|
|
766
|
+
var createScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web" ? (url, cb, attrs, loaderHook) => {
|
|
767
|
+
if (loaderHook?.createScriptHook) {
|
|
768
|
+
const hookResult = loaderHook.createScriptHook(url);
|
|
769
|
+
if (hookResult && typeof hookResult === "object" && "url" in hookResult) {
|
|
770
|
+
url = hookResult.url;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
let urlObj;
|
|
774
|
+
try {
|
|
775
|
+
urlObj = new URL(url);
|
|
776
|
+
} catch (e7) {
|
|
777
|
+
console.error("Error constructing URL:", e7);
|
|
778
|
+
cb(new Error(`Invalid URL: ${e7}`));
|
|
779
|
+
return;
|
|
780
|
+
}
|
|
781
|
+
const getFetch = async () => {
|
|
782
|
+
if (loaderHook?.fetch) {
|
|
783
|
+
return (input, init) => lazyLoaderHookFetch(input, init, loaderHook);
|
|
784
|
+
}
|
|
785
|
+
return typeof fetch === "undefined" ? loadNodeFetch() : fetch;
|
|
786
|
+
};
|
|
787
|
+
const handleScriptFetch = async (f, urlObj) => {
|
|
788
|
+
try {
|
|
789
|
+
const res = await f(urlObj.href);
|
|
790
|
+
const data = await res.text();
|
|
791
|
+
const [path, vm] = await Promise.all([
|
|
792
|
+
importNodeModule("path"),
|
|
793
|
+
importNodeModule("vm")
|
|
794
|
+
]);
|
|
795
|
+
const scriptContext = { exports: {}, module: { exports: {} } };
|
|
796
|
+
const urlDirname = urlObj.pathname.split("/").slice(0, -1).join("/");
|
|
797
|
+
const filename = path.basename(urlObj.pathname);
|
|
798
|
+
const script = new vm.Script(`(function(exports, module, require, __dirname, __filename) {${data}
|
|
799
|
+
})`, {
|
|
800
|
+
filename,
|
|
801
|
+
importModuleDynamically: (
|
|
802
|
+
//@ts-ignore
|
|
803
|
+
vm.constants?.USE_MAIN_CONTEXT_DEFAULT_LOADER ?? importNodeModule
|
|
804
|
+
)
|
|
805
|
+
});
|
|
806
|
+
script.runInThisContext()(scriptContext.exports, scriptContext.module, eval("require"), urlDirname, filename);
|
|
807
|
+
const exportedInterface = scriptContext.module.exports || scriptContext.exports;
|
|
808
|
+
if (attrs && exportedInterface && attrs["globalName"]) {
|
|
809
|
+
const container = exportedInterface[attrs["globalName"]] || exportedInterface;
|
|
810
|
+
cb(void 0, container);
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
cb(void 0, exportedInterface);
|
|
814
|
+
} catch (e7) {
|
|
815
|
+
cb(e7 instanceof Error ? e7 : new Error(`Script execution error: ${e7}`));
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
getFetch().then(async (f4) => {
|
|
819
|
+
if (attrs?.["type"] === "esm" || attrs?.["type"] === "module") {
|
|
820
|
+
return loadModule(urlObj.href, {
|
|
821
|
+
fetch: f4,
|
|
822
|
+
vm: await importNodeModule("vm")
|
|
823
|
+
}).then(async (module2) => {
|
|
824
|
+
await module2.evaluate();
|
|
825
|
+
cb(void 0, module2.namespace);
|
|
826
|
+
}).catch((e7) => {
|
|
827
|
+
cb(e7 instanceof Error ? e7 : new Error(`Script execution error: ${e7}`));
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
handleScriptFetch(f4, urlObj);
|
|
831
|
+
}).catch((err) => {
|
|
832
|
+
cb(err);
|
|
833
|
+
});
|
|
834
|
+
} : (url2, cb2, attrs2, loaderHook2) => {
|
|
835
|
+
cb2(new Error("createScriptNode is disabled in non-Node.js environment"));
|
|
836
|
+
};
|
|
837
|
+
var loadScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web" ? (url2, info) => {
|
|
838
|
+
return new Promise((resolve, reject) => {
|
|
839
|
+
createScriptNode(url2, (error2, scriptContext2) => {
|
|
840
|
+
if (error2) {
|
|
841
|
+
reject(error2);
|
|
842
|
+
} else {
|
|
843
|
+
const remoteEntryKey = info?.attrs?.["globalName"] || `__FEDERATION_${info?.attrs?.["name"]}:custom__`;
|
|
844
|
+
const entryExports = globalThis[remoteEntryKey] = scriptContext2;
|
|
845
|
+
resolve(entryExports);
|
|
846
|
+
}
|
|
847
|
+
}, info.attrs, info.loaderHook);
|
|
848
|
+
});
|
|
849
|
+
} : (url2, info) => {
|
|
850
|
+
throw new Error("loadScriptNode is disabled in non-Node.js environment");
|
|
851
|
+
};
|
|
852
|
+
var esmModuleCache = /* @__PURE__ */ new Map();
|
|
853
|
+
async function loadModule(url2, options) {
|
|
854
|
+
if (esmModuleCache.has(url2)) {
|
|
855
|
+
return esmModuleCache.get(url2);
|
|
856
|
+
}
|
|
857
|
+
const { fetch: fetch2, vm: vm2 } = options;
|
|
858
|
+
const response = await fetch2(url2);
|
|
859
|
+
const code = await response.text();
|
|
860
|
+
const module2 = new vm2.SourceTextModule(code, {
|
|
861
|
+
// @ts-ignore
|
|
862
|
+
importModuleDynamically: async (specifier, script2) => {
|
|
863
|
+
const resolvedUrl = new URL(specifier, url2).href;
|
|
864
|
+
return loadModule(resolvedUrl, options);
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
esmModuleCache.set(url2, module2);
|
|
868
|
+
await module2.link(async (specifier) => {
|
|
869
|
+
const resolvedUrl = new URL(specifier, url2).href;
|
|
870
|
+
const module3 = await loadModule(resolvedUrl, options);
|
|
871
|
+
return module3;
|
|
872
|
+
});
|
|
873
|
+
return module2;
|
|
874
|
+
}
|
|
875
|
+
function normalizeOptions(enableDefault, defaultOptions, key) {
|
|
876
|
+
return function(options) {
|
|
877
|
+
if (options === false) {
|
|
878
|
+
return false;
|
|
879
|
+
}
|
|
880
|
+
if (typeof options === "undefined") {
|
|
881
|
+
if (enableDefault) {
|
|
882
|
+
return defaultOptions;
|
|
883
|
+
} else {
|
|
884
|
+
return false;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
if (options === true) {
|
|
888
|
+
return defaultOptions;
|
|
889
|
+
}
|
|
890
|
+
if (options && typeof options === "object") {
|
|
891
|
+
return {
|
|
892
|
+
...defaultOptions,
|
|
893
|
+
...options
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
throw new Error(`Unexpected type for \`${key}\`, expect boolean/undefined/object, got: ${typeof options}`);
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
var createModuleFederationConfig = (options) => {
|
|
900
|
+
return options;
|
|
901
|
+
};
|
|
902
|
+
exports.BROWSER_LOG_KEY = BROWSER_LOG_KEY;
|
|
903
|
+
exports.ENCODE_NAME_PREFIX = ENCODE_NAME_PREFIX;
|
|
904
|
+
exports.EncodedNameTransformMap = EncodedNameTransformMap;
|
|
905
|
+
exports.FederationModuleManifest = FederationModuleManifest;
|
|
906
|
+
exports.MANIFEST_EXT = MANIFEST_EXT;
|
|
907
|
+
exports.MFModuleType = MFModuleType;
|
|
908
|
+
exports.MFPrefetchCommon = MFPrefetchCommon;
|
|
909
|
+
exports.MODULE_DEVTOOL_IDENTIFIER = MODULE_DEVTOOL_IDENTIFIER;
|
|
910
|
+
exports.ManifestFileName = ManifestFileName;
|
|
911
|
+
exports.NameTransformMap = NameTransformMap;
|
|
912
|
+
exports.NameTransformSymbol = NameTransformSymbol;
|
|
913
|
+
exports.SEPARATOR = SEPARATOR;
|
|
914
|
+
exports.StatsFileName = StatsFileName;
|
|
915
|
+
exports.TEMP_DIR = TEMP_DIR;
|
|
916
|
+
exports.assert = assert;
|
|
917
|
+
exports.bindLoggerToCompiler = bindLoggerToCompiler;
|
|
918
|
+
exports.composeKeyWithSeparator = composeKeyWithSeparator;
|
|
919
|
+
exports.containerPlugin = ContainerPlugin;
|
|
920
|
+
exports.containerReferencePlugin = ContainerReferencePlugin;
|
|
921
|
+
exports.createInfrastructureLogger = createInfrastructureLogger;
|
|
922
|
+
exports.createLink = createLink;
|
|
923
|
+
exports.createLogger = createLogger;
|
|
924
|
+
exports.createModuleFederationConfig = createModuleFederationConfig;
|
|
925
|
+
exports.createScript = createScript;
|
|
926
|
+
exports.createScriptNode = createScriptNode;
|
|
927
|
+
exports.decodeName = decodeName;
|
|
928
|
+
exports.encodeName = encodeName;
|
|
929
|
+
exports.error = error;
|
|
930
|
+
exports.generateExposeFilename = generateExposeFilename;
|
|
931
|
+
exports.generateShareFilename = generateShareFilename;
|
|
932
|
+
exports.generateSnapshotFromManifest = generateSnapshotFromManifest;
|
|
933
|
+
exports.getManifestFileName = getManifestFileName;
|
|
934
|
+
exports.getProcessEnv = getProcessEnv;
|
|
935
|
+
exports.getResourceUrl = getResourceUrl;
|
|
936
|
+
exports.inferAutoPublicPath = inferAutoPublicPath;
|
|
937
|
+
exports.infrastructureLogger = infrastructureLogger;
|
|
938
|
+
exports.isBrowserEnv = isBrowserEnv;
|
|
939
|
+
exports.isDebugMode = isDebugMode;
|
|
940
|
+
exports.isManifestProvider = isManifestProvider;
|
|
941
|
+
exports.isReactNativeEnv = isReactNativeEnv;
|
|
942
|
+
exports.isRequiredVersion = isRequiredVersion;
|
|
943
|
+
exports.isStaticResourcesEqual = isStaticResourcesEqual;
|
|
944
|
+
exports.loadScript = loadScript;
|
|
945
|
+
exports.loadScriptNode = loadScriptNode;
|
|
946
|
+
exports.logger = logger;
|
|
947
|
+
exports.moduleFederationPlugin = ModuleFederationPlugin;
|
|
948
|
+
exports.normalizeOptions = normalizeOptions;
|
|
949
|
+
exports.parseEntry = parseEntry;
|
|
950
|
+
exports.safeToString = safeToString;
|
|
951
|
+
exports.safeWrapper = safeWrapper;
|
|
952
|
+
exports.sharePlugin = SharePlugin;
|
|
953
|
+
exports.simpleJoinRemoteEntry = simpleJoinRemoteEntry;
|
|
954
|
+
exports.warn = warn;
|
|
955
|
+
}
|
|
956
|
+
});
|
|
957
|
+
|
|
958
|
+
// node_modules/@module-federation/error-codes/dist/index.cjs.js
|
|
959
|
+
var require_index_cjs2 = __commonJS({
|
|
960
|
+
"node_modules/@module-federation/error-codes/dist/index.cjs.js"(exports2) {
|
|
961
|
+
"use strict";
|
|
962
|
+
var RUNTIME_001 = "RUNTIME-001";
|
|
963
|
+
var RUNTIME_002 = "RUNTIME-002";
|
|
964
|
+
var RUNTIME_003 = "RUNTIME-003";
|
|
965
|
+
var RUNTIME_004 = "RUNTIME-004";
|
|
966
|
+
var RUNTIME_005 = "RUNTIME-005";
|
|
967
|
+
var RUNTIME_006 = "RUNTIME-006";
|
|
968
|
+
var RUNTIME_007 = "RUNTIME-007";
|
|
969
|
+
var RUNTIME_008 = "RUNTIME-008";
|
|
970
|
+
var RUNTIME_009 = "RUNTIME-009";
|
|
971
|
+
var TYPE_001 = "TYPE-001";
|
|
972
|
+
var BUILD_001 = "BUILD-001";
|
|
973
|
+
var BUILD_002 = "BUILD-002";
|
|
974
|
+
var getDocsUrl = (errorCode) => {
|
|
975
|
+
const type = errorCode.split("-")[0].toLowerCase();
|
|
976
|
+
return `View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${type}/${errorCode}`;
|
|
977
|
+
};
|
|
978
|
+
var getShortErrorMsg = (errorCode, errorDescMap2, args, originalErrorMsg) => {
|
|
979
|
+
const msg = [`${[errorDescMap2[errorCode]]} #${errorCode}`];
|
|
980
|
+
args && msg.push(`args: ${JSON.stringify(args)}`);
|
|
981
|
+
msg.push(getDocsUrl(errorCode));
|
|
982
|
+
originalErrorMsg && msg.push(`Original Error Message:
|
|
983
|
+
${originalErrorMsg}`);
|
|
984
|
+
return msg.join("\n");
|
|
985
|
+
};
|
|
986
|
+
var runtimeDescMap = {
|
|
987
|
+
[RUNTIME_001]: "Failed to get remoteEntry exports.",
|
|
988
|
+
[RUNTIME_002]: 'The remote entry interface does not contain "init"',
|
|
989
|
+
[RUNTIME_003]: "Failed to get manifest.",
|
|
990
|
+
[RUNTIME_004]: "Failed to locate remote.",
|
|
991
|
+
[RUNTIME_005]: "Invalid loadShareSync function call from bundler runtime",
|
|
992
|
+
[RUNTIME_006]: "Invalid loadShareSync function call from runtime",
|
|
993
|
+
[RUNTIME_007]: "Failed to get remote snapshot.",
|
|
994
|
+
[RUNTIME_008]: "Failed to load script resources.",
|
|
995
|
+
[RUNTIME_009]: "Please call createInstance first."
|
|
996
|
+
};
|
|
997
|
+
var typeDescMap = {
|
|
998
|
+
[TYPE_001]: "Failed to generate type declaration. Execute the below cmd to reproduce and fix the error."
|
|
999
|
+
};
|
|
1000
|
+
var buildDescMap = {
|
|
1001
|
+
[BUILD_001]: "Failed to find expose module.",
|
|
1002
|
+
[BUILD_002]: "PublicPath is required in prod mode."
|
|
1003
|
+
};
|
|
1004
|
+
var errorDescMap = {
|
|
1005
|
+
...runtimeDescMap,
|
|
1006
|
+
...typeDescMap,
|
|
1007
|
+
...buildDescMap
|
|
1008
|
+
};
|
|
1009
|
+
exports2.BUILD_001 = BUILD_001;
|
|
1010
|
+
exports2.BUILD_002 = BUILD_002;
|
|
1011
|
+
exports2.RUNTIME_001 = RUNTIME_001;
|
|
1012
|
+
exports2.RUNTIME_002 = RUNTIME_002;
|
|
1013
|
+
exports2.RUNTIME_003 = RUNTIME_003;
|
|
1014
|
+
exports2.RUNTIME_004 = RUNTIME_004;
|
|
1015
|
+
exports2.RUNTIME_005 = RUNTIME_005;
|
|
1016
|
+
exports2.RUNTIME_006 = RUNTIME_006;
|
|
1017
|
+
exports2.RUNTIME_007 = RUNTIME_007;
|
|
1018
|
+
exports2.RUNTIME_008 = RUNTIME_008;
|
|
1019
|
+
exports2.RUNTIME_009 = RUNTIME_009;
|
|
1020
|
+
exports2.TYPE_001 = TYPE_001;
|
|
1021
|
+
exports2.buildDescMap = buildDescMap;
|
|
1022
|
+
exports2.errorDescMap = errorDescMap;
|
|
1023
|
+
exports2.getShortErrorMsg = getShortErrorMsg;
|
|
1024
|
+
exports2.runtimeDescMap = runtimeDescMap;
|
|
1025
|
+
exports2.typeDescMap = typeDescMap;
|
|
1026
|
+
}
|
|
1027
|
+
});
|
|
1028
|
+
|
|
1029
|
+
// node_modules/@module-federation/runtime-core/dist/index.cjs.cjs
|
|
1030
|
+
var require_index_cjs3 = __commonJS({
|
|
1031
|
+
"node_modules/@module-federation/runtime-core/dist/index.cjs.cjs"(exports2) {
|
|
1032
|
+
"use strict";
|
|
1033
|
+
var sdk = require_index_cjs();
|
|
1034
|
+
var errorCodes = require_index_cjs2();
|
|
1035
|
+
var LOG_CATEGORY2 = "[ Federation Runtime ]";
|
|
1036
|
+
var logger2 = sdk.createLogger(LOG_CATEGORY2);
|
|
1037
|
+
function assert2(condition, msg) {
|
|
1038
|
+
if (!condition) {
|
|
1039
|
+
error2(msg);
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
function error2(msg) {
|
|
1043
|
+
if (msg instanceof Error) {
|
|
1044
|
+
if (!msg.message.startsWith(LOG_CATEGORY2)) {
|
|
1045
|
+
msg.message = `${LOG_CATEGORY2}: ${msg.message}`;
|
|
1046
|
+
}
|
|
1047
|
+
throw msg;
|
|
1048
|
+
}
|
|
1049
|
+
throw new Error(`${LOG_CATEGORY2}: ${msg}`);
|
|
1050
|
+
}
|
|
1051
|
+
function warn2(msg) {
|
|
1052
|
+
if (msg instanceof Error) {
|
|
1053
|
+
if (!msg.message.startsWith(LOG_CATEGORY2)) {
|
|
1054
|
+
msg.message = `${LOG_CATEGORY2}: ${msg.message}`;
|
|
1055
|
+
}
|
|
1056
|
+
logger2.warn(msg);
|
|
1057
|
+
} else {
|
|
1058
|
+
logger2.warn(msg);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
function addUniqueItem(arr, item) {
|
|
1062
|
+
if (arr.findIndex((name) => name === item) === -1) {
|
|
1063
|
+
arr.push(item);
|
|
1064
|
+
}
|
|
1065
|
+
return arr;
|
|
1066
|
+
}
|
|
1067
|
+
function getFMId(remoteInfo) {
|
|
1068
|
+
if ("version" in remoteInfo && remoteInfo.version) {
|
|
1069
|
+
return `${remoteInfo.name}:${remoteInfo.version}`;
|
|
1070
|
+
} else if ("entry" in remoteInfo && remoteInfo.entry) {
|
|
1071
|
+
return `${remoteInfo.name}:${remoteInfo.entry}`;
|
|
1072
|
+
} else {
|
|
1073
|
+
return `${remoteInfo.name}`;
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
function isRemoteInfoWithEntry(remote) {
|
|
1077
|
+
return typeof remote.entry !== "undefined";
|
|
1078
|
+
}
|
|
1079
|
+
function isPureRemoteEntry(remote) {
|
|
1080
|
+
return !remote.entry.includes(".json");
|
|
1081
|
+
}
|
|
1082
|
+
async function safeWrapper2(callback, disableWarn) {
|
|
1083
|
+
try {
|
|
1084
|
+
const res2 = await callback();
|
|
1085
|
+
return res2;
|
|
1086
|
+
} catch (e7) {
|
|
1087
|
+
!disableWarn && warn2(e7);
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
function isObject2(val) {
|
|
1092
|
+
return val && typeof val === "object";
|
|
1093
|
+
}
|
|
1094
|
+
var objectToString = Object.prototype.toString;
|
|
1095
|
+
function isPlainObject(val) {
|
|
1096
|
+
return objectToString.call(val) === "[object Object]";
|
|
1097
|
+
}
|
|
1098
|
+
function isStaticResourcesEqual2(url1, url2) {
|
|
1099
|
+
const REG_EXP = /^(https?:)?\/\//i;
|
|
1100
|
+
const relativeUrl1 = url1.replace(REG_EXP, "").replace(/\/$/, "");
|
|
1101
|
+
const relativeUrl2 = url2.replace(REG_EXP, "").replace(/\/$/, "");
|
|
1102
|
+
return relativeUrl1 === relativeUrl2;
|
|
1103
|
+
}
|
|
1104
|
+
function arrayOptions(options) {
|
|
1105
|
+
return Array.isArray(options) ? options : [options];
|
|
1106
|
+
}
|
|
1107
|
+
function getRemoteEntryInfoFromSnapshot(snapshot) {
|
|
1108
|
+
const defaultRemoteEntryInfo = {
|
|
1109
|
+
url: "",
|
|
1110
|
+
type: "global",
|
|
1111
|
+
globalName: ""
|
|
1112
|
+
};
|
|
1113
|
+
if (sdk.isBrowserEnv() || sdk.isReactNativeEnv()) {
|
|
1114
|
+
return "remoteEntry" in snapshot ? {
|
|
1115
|
+
url: snapshot.remoteEntry,
|
|
1116
|
+
type: snapshot.remoteEntryType,
|
|
1117
|
+
globalName: snapshot.globalName
|
|
1118
|
+
} : defaultRemoteEntryInfo;
|
|
1119
|
+
}
|
|
1120
|
+
if ("ssrRemoteEntry" in snapshot) {
|
|
1121
|
+
return {
|
|
1122
|
+
url: snapshot.ssrRemoteEntry || defaultRemoteEntryInfo.url,
|
|
1123
|
+
type: snapshot.ssrRemoteEntryType || defaultRemoteEntryInfo.type,
|
|
1124
|
+
globalName: snapshot.globalName
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
1127
|
+
return defaultRemoteEntryInfo;
|
|
1128
|
+
}
|
|
1129
|
+
var processModuleAlias = (name, subPath) => {
|
|
1130
|
+
let moduleName;
|
|
1131
|
+
if (name.endsWith("/")) {
|
|
1132
|
+
moduleName = name.slice(0, -1);
|
|
1133
|
+
} else {
|
|
1134
|
+
moduleName = name;
|
|
1135
|
+
}
|
|
1136
|
+
if (subPath.startsWith(".")) {
|
|
1137
|
+
subPath = subPath.slice(1);
|
|
1138
|
+
}
|
|
1139
|
+
moduleName = moduleName + subPath;
|
|
1140
|
+
return moduleName;
|
|
1141
|
+
};
|
|
1142
|
+
var CurrentGlobal = typeof globalThis === "object" ? globalThis : window;
|
|
1143
|
+
var nativeGlobal = (() => {
|
|
1144
|
+
try {
|
|
1145
|
+
return document.defaultView;
|
|
1146
|
+
} catch {
|
|
1147
|
+
return CurrentGlobal;
|
|
1148
|
+
}
|
|
1149
|
+
})();
|
|
1150
|
+
var Global = nativeGlobal;
|
|
1151
|
+
function definePropertyGlobalVal(target, key, val) {
|
|
1152
|
+
Object.defineProperty(target, key, {
|
|
1153
|
+
value: val,
|
|
1154
|
+
configurable: false,
|
|
1155
|
+
writable: true
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
function includeOwnProperty(target, key) {
|
|
1159
|
+
return Object.hasOwnProperty.call(target, key);
|
|
1160
|
+
}
|
|
1161
|
+
if (!includeOwnProperty(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__")) {
|
|
1162
|
+
definePropertyGlobalVal(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});
|
|
1163
|
+
}
|
|
1164
|
+
var globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;
|
|
1165
|
+
function setGlobalDefaultVal(target) {
|
|
1166
|
+
if (includeOwnProperty(target, "__VMOK__") && !includeOwnProperty(target, "__FEDERATION__")) {
|
|
1167
|
+
definePropertyGlobalVal(target, "__FEDERATION__", target.__VMOK__);
|
|
1168
|
+
}
|
|
1169
|
+
if (!includeOwnProperty(target, "__FEDERATION__")) {
|
|
1170
|
+
definePropertyGlobalVal(target, "__FEDERATION__", {
|
|
1171
|
+
__GLOBAL_PLUGIN__: [],
|
|
1172
|
+
__INSTANCES__: [],
|
|
1173
|
+
moduleInfo: {},
|
|
1174
|
+
__SHARE__: {},
|
|
1175
|
+
__MANIFEST_LOADING__: {},
|
|
1176
|
+
__PRELOADED_MAP__: /* @__PURE__ */ new Map()
|
|
1177
|
+
});
|
|
1178
|
+
definePropertyGlobalVal(target, "__VMOK__", target.__FEDERATION__);
|
|
1179
|
+
}
|
|
1180
|
+
target.__FEDERATION__.__GLOBAL_PLUGIN__ ??= [];
|
|
1181
|
+
target.__FEDERATION__.__INSTANCES__ ??= [];
|
|
1182
|
+
target.__FEDERATION__.moduleInfo ??= {};
|
|
1183
|
+
target.__FEDERATION__.__SHARE__ ??= {};
|
|
1184
|
+
target.__FEDERATION__.__MANIFEST_LOADING__ ??= {};
|
|
1185
|
+
target.__FEDERATION__.__PRELOADED_MAP__ ??= /* @__PURE__ */ new Map();
|
|
1186
|
+
}
|
|
1187
|
+
setGlobalDefaultVal(CurrentGlobal);
|
|
1188
|
+
setGlobalDefaultVal(nativeGlobal);
|
|
1189
|
+
function resetFederationGlobalInfo() {
|
|
1190
|
+
CurrentGlobal.__FEDERATION__.__GLOBAL_PLUGIN__ = [];
|
|
1191
|
+
CurrentGlobal.__FEDERATION__.__INSTANCES__ = [];
|
|
1192
|
+
CurrentGlobal.__FEDERATION__.moduleInfo = {};
|
|
1193
|
+
CurrentGlobal.__FEDERATION__.__SHARE__ = {};
|
|
1194
|
+
CurrentGlobal.__FEDERATION__.__MANIFEST_LOADING__ = {};
|
|
1195
|
+
Object.keys(globalLoading).forEach((key) => {
|
|
1196
|
+
delete globalLoading[key];
|
|
1197
|
+
});
|
|
1198
|
+
}
|
|
1199
|
+
function setGlobalFederationInstance(FederationInstance) {
|
|
1200
|
+
CurrentGlobal.__FEDERATION__.__INSTANCES__.push(FederationInstance);
|
|
1201
|
+
}
|
|
1202
|
+
function getGlobalFederationConstructor() {
|
|
1203
|
+
return CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__;
|
|
1204
|
+
}
|
|
1205
|
+
function setGlobalFederationConstructor(FederationConstructor, isDebug = sdk.isDebugMode()) {
|
|
1206
|
+
if (isDebug) {
|
|
1207
|
+
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
1208
|
+
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.21.6";
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
function getInfoWithoutType(target, key) {
|
|
1212
|
+
if (typeof key === "string") {
|
|
1213
|
+
const keyRes = target[key];
|
|
1214
|
+
if (keyRes) {
|
|
1215
|
+
return {
|
|
1216
|
+
value: target[key],
|
|
1217
|
+
key
|
|
1218
|
+
};
|
|
1219
|
+
} else {
|
|
1220
|
+
const targetKeys = Object.keys(target);
|
|
1221
|
+
for (const targetKey of targetKeys) {
|
|
1222
|
+
const [targetTypeOrName, _2] = targetKey.split(":");
|
|
1223
|
+
const nKey = `${targetTypeOrName}:${key}`;
|
|
1224
|
+
const typeWithKeyRes = target[nKey];
|
|
1225
|
+
if (typeWithKeyRes) {
|
|
1226
|
+
return {
|
|
1227
|
+
value: typeWithKeyRes,
|
|
1228
|
+
key: nKey
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
return {
|
|
1233
|
+
value: void 0,
|
|
1234
|
+
key
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
} else {
|
|
1238
|
+
throw new Error("key must be string");
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
var getGlobalSnapshot = () => nativeGlobal.__FEDERATION__.moduleInfo;
|
|
1242
|
+
var getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot) => {
|
|
1243
|
+
const moduleKey = getFMId(moduleInfo);
|
|
1244
|
+
const getModuleInfo = getInfoWithoutType(snapshot, moduleKey).value;
|
|
1245
|
+
if (getModuleInfo && !getModuleInfo.version && "version" in moduleInfo && moduleInfo["version"]) {
|
|
1246
|
+
getModuleInfo.version = moduleInfo["version"];
|
|
1247
|
+
}
|
|
1248
|
+
if (getModuleInfo) {
|
|
1249
|
+
return getModuleInfo;
|
|
1250
|
+
}
|
|
1251
|
+
if ("version" in moduleInfo && moduleInfo["version"]) {
|
|
1252
|
+
const { version: version2, ...resModuleInfo } = moduleInfo;
|
|
1253
|
+
const moduleKeyWithoutVersion = getFMId(resModuleInfo);
|
|
1254
|
+
const getModuleInfoWithoutVersion = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion).value;
|
|
1255
|
+
if (getModuleInfoWithoutVersion?.version === version2) {
|
|
1256
|
+
return getModuleInfoWithoutVersion;
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
return;
|
|
1260
|
+
};
|
|
1261
|
+
var getGlobalSnapshotInfoByModuleInfo = (moduleInfo) => getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo);
|
|
1262
|
+
var setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo) => {
|
|
1263
|
+
const moduleKey = getFMId(remoteInfo);
|
|
1264
|
+
nativeGlobal.__FEDERATION__.moduleInfo[moduleKey] = moduleDetailInfo;
|
|
1265
|
+
return nativeGlobal.__FEDERATION__.moduleInfo;
|
|
1266
|
+
};
|
|
1267
|
+
var addGlobalSnapshot = (moduleInfos) => {
|
|
1268
|
+
nativeGlobal.__FEDERATION__.moduleInfo = {
|
|
1269
|
+
...nativeGlobal.__FEDERATION__.moduleInfo,
|
|
1270
|
+
...moduleInfos
|
|
1271
|
+
};
|
|
1272
|
+
return () => {
|
|
1273
|
+
const keys = Object.keys(moduleInfos);
|
|
1274
|
+
for (const key of keys) {
|
|
1275
|
+
delete nativeGlobal.__FEDERATION__.moduleInfo[key];
|
|
1276
|
+
}
|
|
1277
|
+
};
|
|
1278
|
+
};
|
|
1279
|
+
var getRemoteEntryExports = (name, globalName) => {
|
|
1280
|
+
const remoteEntryKey = globalName || `__FEDERATION_${name}:custom__`;
|
|
1281
|
+
const entryExports = CurrentGlobal[remoteEntryKey];
|
|
1282
|
+
return {
|
|
1283
|
+
remoteEntryKey,
|
|
1284
|
+
entryExports
|
|
1285
|
+
};
|
|
1286
|
+
};
|
|
1287
|
+
var registerGlobalPlugins = (plugins) => {
|
|
1288
|
+
const { __GLOBAL_PLUGIN__ } = nativeGlobal.__FEDERATION__;
|
|
1289
|
+
plugins.forEach((plugin) => {
|
|
1290
|
+
if (__GLOBAL_PLUGIN__.findIndex((p3) => p3.name === plugin.name) === -1) {
|
|
1291
|
+
__GLOBAL_PLUGIN__.push(plugin);
|
|
1292
|
+
} else {
|
|
1293
|
+
warn2(`The plugin ${plugin.name} has been registered.`);
|
|
1294
|
+
}
|
|
1295
|
+
});
|
|
1296
|
+
};
|
|
1297
|
+
var getGlobalHostPlugins = () => nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__;
|
|
1298
|
+
var getPreloaded = (id) => CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.get(id);
|
|
1299
|
+
var setPreloaded = (id) => CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.set(id, true);
|
|
1300
|
+
var DEFAULT_SCOPE = "default";
|
|
1301
|
+
var DEFAULT_REMOTE_TYPE = "global";
|
|
1302
|
+
var buildIdentifier = "[0-9A-Za-z-]+";
|
|
1303
|
+
var build = `(?:\\+(${buildIdentifier}(?:\\.${buildIdentifier})*))`;
|
|
1304
|
+
var numericIdentifier = "0|[1-9]\\d*";
|
|
1305
|
+
var numericIdentifierLoose = "[0-9]+";
|
|
1306
|
+
var nonNumericIdentifier = "\\d*[a-zA-Z-][a-zA-Z0-9-]*";
|
|
1307
|
+
var preReleaseIdentifierLoose = `(?:${numericIdentifierLoose}|${nonNumericIdentifier})`;
|
|
1308
|
+
var preReleaseLoose = `(?:-?(${preReleaseIdentifierLoose}(?:\\.${preReleaseIdentifierLoose})*))`;
|
|
1309
|
+
var preReleaseIdentifier = `(?:${numericIdentifier}|${nonNumericIdentifier})`;
|
|
1310
|
+
var preRelease = `(?:-(${preReleaseIdentifier}(?:\\.${preReleaseIdentifier})*))`;
|
|
1311
|
+
var xRangeIdentifier = `${numericIdentifier}|x|X|\\*`;
|
|
1312
|
+
var xRangePlain = `[v=\\s]*(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:${preRelease})?${build}?)?)?`;
|
|
1313
|
+
var hyphenRange = `^\\s*(${xRangePlain})\\s+-\\s+(${xRangePlain})\\s*$`;
|
|
1314
|
+
var mainVersionLoose = `(${numericIdentifierLoose})\\.(${numericIdentifierLoose})\\.(${numericIdentifierLoose})`;
|
|
1315
|
+
var loosePlain = `[v=\\s]*${mainVersionLoose}${preReleaseLoose}?${build}?`;
|
|
1316
|
+
var gtlt = "((?:<|>)?=?)";
|
|
1317
|
+
var comparatorTrim = `(\\s*)${gtlt}\\s*(${loosePlain}|${xRangePlain})`;
|
|
1318
|
+
var loneTilde = "(?:~>?)";
|
|
1319
|
+
var tildeTrim = `(\\s*)${loneTilde}\\s+`;
|
|
1320
|
+
var loneCaret = "(?:\\^)";
|
|
1321
|
+
var caretTrim = `(\\s*)${loneCaret}\\s+`;
|
|
1322
|
+
var star = "(<|>)?=?\\s*\\*";
|
|
1323
|
+
var caret = `^${loneCaret}${xRangePlain}$`;
|
|
1324
|
+
var mainVersion = `(${numericIdentifier})\\.(${numericIdentifier})\\.(${numericIdentifier})`;
|
|
1325
|
+
var fullPlain = `v?${mainVersion}${preRelease}?${build}?`;
|
|
1326
|
+
var tilde = `^${loneTilde}${xRangePlain}$`;
|
|
1327
|
+
var xRange = `^${gtlt}\\s*${xRangePlain}$`;
|
|
1328
|
+
var comparator = `^${gtlt}\\s*(${fullPlain})$|^$`;
|
|
1329
|
+
var gte0 = "^\\s*>=\\s*0.0.0\\s*$";
|
|
1330
|
+
function parseRegex(source) {
|
|
1331
|
+
return new RegExp(source);
|
|
1332
|
+
}
|
|
1333
|
+
function isXVersion(version2) {
|
|
1334
|
+
return !version2 || version2.toLowerCase() === "x" || version2 === "*";
|
|
1335
|
+
}
|
|
1336
|
+
function pipe(...fns) {
|
|
1337
|
+
return (x2) => fns.reduce((v2, f4) => f4(v2), x2);
|
|
1338
|
+
}
|
|
1339
|
+
function extractComparator(comparatorString) {
|
|
1340
|
+
return comparatorString.match(parseRegex(comparator));
|
|
1341
|
+
}
|
|
1342
|
+
function combineVersion(major, minor, patch, preRelease2) {
|
|
1343
|
+
const mainVersion2 = `${major}.${minor}.${patch}`;
|
|
1344
|
+
if (preRelease2) {
|
|
1345
|
+
return `${mainVersion2}-${preRelease2}`;
|
|
1346
|
+
}
|
|
1347
|
+
return mainVersion2;
|
|
1348
|
+
}
|
|
1349
|
+
function parseHyphen(range) {
|
|
1350
|
+
return range.replace(parseRegex(hyphenRange), (_range, from, fromMajor, fromMinor, fromPatch, _fromPreRelease, _fromBuild, to, toMajor, toMinor, toPatch, toPreRelease) => {
|
|
1351
|
+
if (isXVersion(fromMajor)) {
|
|
1352
|
+
from = "";
|
|
1353
|
+
} else if (isXVersion(fromMinor)) {
|
|
1354
|
+
from = `>=${fromMajor}.0.0`;
|
|
1355
|
+
} else if (isXVersion(fromPatch)) {
|
|
1356
|
+
from = `>=${fromMajor}.${fromMinor}.0`;
|
|
1357
|
+
} else {
|
|
1358
|
+
from = `>=${from}`;
|
|
1359
|
+
}
|
|
1360
|
+
if (isXVersion(toMajor)) {
|
|
1361
|
+
to = "";
|
|
1362
|
+
} else if (isXVersion(toMinor)) {
|
|
1363
|
+
to = `<${Number(toMajor) + 1}.0.0-0`;
|
|
1364
|
+
} else if (isXVersion(toPatch)) {
|
|
1365
|
+
to = `<${toMajor}.${Number(toMinor) + 1}.0-0`;
|
|
1366
|
+
} else if (toPreRelease) {
|
|
1367
|
+
to = `<=${toMajor}.${toMinor}.${toPatch}-${toPreRelease}`;
|
|
1368
|
+
} else {
|
|
1369
|
+
to = `<=${to}`;
|
|
1370
|
+
}
|
|
1371
|
+
return `${from} ${to}`.trim();
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
function parseComparatorTrim(range) {
|
|
1375
|
+
return range.replace(parseRegex(comparatorTrim), "$1$2$3");
|
|
1376
|
+
}
|
|
1377
|
+
function parseTildeTrim(range) {
|
|
1378
|
+
return range.replace(parseRegex(tildeTrim), "$1~");
|
|
1379
|
+
}
|
|
1380
|
+
function parseCaretTrim(range) {
|
|
1381
|
+
return range.replace(parseRegex(caretTrim), "$1^");
|
|
1382
|
+
}
|
|
1383
|
+
function parseCarets(range) {
|
|
1384
|
+
return range.trim().split(/\s+/).map((rangeVersion) => rangeVersion.replace(parseRegex(caret), (_2, major, minor, patch, preRelease2) => {
|
|
1385
|
+
if (isXVersion(major)) {
|
|
1386
|
+
return "";
|
|
1387
|
+
} else if (isXVersion(minor)) {
|
|
1388
|
+
return `>=${major}.0.0 <${Number(major) + 1}.0.0-0`;
|
|
1389
|
+
} else if (isXVersion(patch)) {
|
|
1390
|
+
if (major === "0") {
|
|
1391
|
+
return `>=${major}.${minor}.0 <${major}.${Number(minor) + 1}.0-0`;
|
|
1392
|
+
} else {
|
|
1393
|
+
return `>=${major}.${minor}.0 <${Number(major) + 1}.0.0-0`;
|
|
1394
|
+
}
|
|
1395
|
+
} else if (preRelease2) {
|
|
1396
|
+
if (major === "0") {
|
|
1397
|
+
if (minor === "0") {
|
|
1398
|
+
return `>=${major}.${minor}.${patch}-${preRelease2} <${major}.${minor}.${Number(patch) + 1}-0`;
|
|
1399
|
+
} else {
|
|
1400
|
+
return `>=${major}.${minor}.${patch}-${preRelease2} <${major}.${Number(minor) + 1}.0-0`;
|
|
1401
|
+
}
|
|
1402
|
+
} else {
|
|
1403
|
+
return `>=${major}.${minor}.${patch}-${preRelease2} <${Number(major) + 1}.0.0-0`;
|
|
1404
|
+
}
|
|
1405
|
+
} else {
|
|
1406
|
+
if (major === "0") {
|
|
1407
|
+
if (minor === "0") {
|
|
1408
|
+
return `>=${major}.${minor}.${patch} <${major}.${minor}.${Number(patch) + 1}-0`;
|
|
1409
|
+
} else {
|
|
1410
|
+
return `>=${major}.${minor}.${patch} <${major}.${Number(minor) + 1}.0-0`;
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
return `>=${major}.${minor}.${patch} <${Number(major) + 1}.0.0-0`;
|
|
1414
|
+
}
|
|
1415
|
+
})).join(" ");
|
|
1416
|
+
}
|
|
1417
|
+
function parseTildes(range) {
|
|
1418
|
+
return range.trim().split(/\s+/).map((rangeVersion) => rangeVersion.replace(parseRegex(tilde), (_2, major, minor, patch, preRelease2) => {
|
|
1419
|
+
if (isXVersion(major)) {
|
|
1420
|
+
return "";
|
|
1421
|
+
} else if (isXVersion(minor)) {
|
|
1422
|
+
return `>=${major}.0.0 <${Number(major) + 1}.0.0-0`;
|
|
1423
|
+
} else if (isXVersion(patch)) {
|
|
1424
|
+
return `>=${major}.${minor}.0 <${major}.${Number(minor) + 1}.0-0`;
|
|
1425
|
+
} else if (preRelease2) {
|
|
1426
|
+
return `>=${major}.${minor}.${patch}-${preRelease2} <${major}.${Number(minor) + 1}.0-0`;
|
|
1427
|
+
}
|
|
1428
|
+
return `>=${major}.${minor}.${patch} <${major}.${Number(minor) + 1}.0-0`;
|
|
1429
|
+
})).join(" ");
|
|
1430
|
+
}
|
|
1431
|
+
function parseXRanges(range) {
|
|
1432
|
+
return range.split(/\s+/).map((rangeVersion) => rangeVersion.trim().replace(parseRegex(xRange), (ret, gtlt2, major, minor, patch, preRelease2) => {
|
|
1433
|
+
const isXMajor = isXVersion(major);
|
|
1434
|
+
const isXMinor = isXMajor || isXVersion(minor);
|
|
1435
|
+
const isXPatch = isXMinor || isXVersion(patch);
|
|
1436
|
+
if (gtlt2 === "=" && isXPatch) {
|
|
1437
|
+
gtlt2 = "";
|
|
1438
|
+
}
|
|
1439
|
+
preRelease2 = "";
|
|
1440
|
+
if (isXMajor) {
|
|
1441
|
+
if (gtlt2 === ">" || gtlt2 === "<") {
|
|
1442
|
+
return "<0.0.0-0";
|
|
1443
|
+
} else {
|
|
1444
|
+
return "*";
|
|
1445
|
+
}
|
|
1446
|
+
} else if (gtlt2 && isXPatch) {
|
|
1447
|
+
if (isXMinor) {
|
|
1448
|
+
minor = 0;
|
|
1449
|
+
}
|
|
1450
|
+
patch = 0;
|
|
1451
|
+
if (gtlt2 === ">") {
|
|
1452
|
+
gtlt2 = ">=";
|
|
1453
|
+
if (isXMinor) {
|
|
1454
|
+
major = Number(major) + 1;
|
|
1455
|
+
minor = 0;
|
|
1456
|
+
patch = 0;
|
|
1457
|
+
} else {
|
|
1458
|
+
minor = Number(minor) + 1;
|
|
1459
|
+
patch = 0;
|
|
1460
|
+
}
|
|
1461
|
+
} else if (gtlt2 === "<=") {
|
|
1462
|
+
gtlt2 = "<";
|
|
1463
|
+
if (isXMinor) {
|
|
1464
|
+
major = Number(major) + 1;
|
|
1465
|
+
} else {
|
|
1466
|
+
minor = Number(minor) + 1;
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
if (gtlt2 === "<") {
|
|
1470
|
+
preRelease2 = "-0";
|
|
1471
|
+
}
|
|
1472
|
+
return `${gtlt2 + major}.${minor}.${patch}${preRelease2}`;
|
|
1473
|
+
} else if (isXMinor) {
|
|
1474
|
+
return `>=${major}.0.0${preRelease2} <${Number(major) + 1}.0.0-0`;
|
|
1475
|
+
} else if (isXPatch) {
|
|
1476
|
+
return `>=${major}.${minor}.0${preRelease2} <${major}.${Number(minor) + 1}.0-0`;
|
|
1477
|
+
}
|
|
1478
|
+
return ret;
|
|
1479
|
+
})).join(" ");
|
|
1480
|
+
}
|
|
1481
|
+
function parseStar(range) {
|
|
1482
|
+
return range.trim().replace(parseRegex(star), "");
|
|
1483
|
+
}
|
|
1484
|
+
function parseGTE0(comparatorString) {
|
|
1485
|
+
return comparatorString.trim().replace(parseRegex(gte0), "");
|
|
1486
|
+
}
|
|
1487
|
+
function compareAtom(rangeAtom, versionAtom) {
|
|
1488
|
+
rangeAtom = Number(rangeAtom) || rangeAtom;
|
|
1489
|
+
versionAtom = Number(versionAtom) || versionAtom;
|
|
1490
|
+
if (rangeAtom > versionAtom) {
|
|
1491
|
+
return 1;
|
|
1492
|
+
}
|
|
1493
|
+
if (rangeAtom === versionAtom) {
|
|
1494
|
+
return 0;
|
|
1495
|
+
}
|
|
1496
|
+
return -1;
|
|
1497
|
+
}
|
|
1498
|
+
function comparePreRelease(rangeAtom, versionAtom) {
|
|
1499
|
+
const { preRelease: rangePreRelease } = rangeAtom;
|
|
1500
|
+
const { preRelease: versionPreRelease } = versionAtom;
|
|
1501
|
+
if (rangePreRelease === void 0 && Boolean(versionPreRelease)) {
|
|
1502
|
+
return 1;
|
|
1503
|
+
}
|
|
1504
|
+
if (Boolean(rangePreRelease) && versionPreRelease === void 0) {
|
|
1505
|
+
return -1;
|
|
1506
|
+
}
|
|
1507
|
+
if (rangePreRelease === void 0 && versionPreRelease === void 0) {
|
|
1508
|
+
return 0;
|
|
1509
|
+
}
|
|
1510
|
+
for (let i7 = 0, n6 = rangePreRelease.length; i7 <= n6; i7++) {
|
|
1511
|
+
const rangeElement = rangePreRelease[i7];
|
|
1512
|
+
const versionElement = versionPreRelease[i7];
|
|
1513
|
+
if (rangeElement === versionElement) {
|
|
1514
|
+
continue;
|
|
1515
|
+
}
|
|
1516
|
+
if (rangeElement === void 0 && versionElement === void 0) {
|
|
1517
|
+
return 0;
|
|
1518
|
+
}
|
|
1519
|
+
if (!rangeElement) {
|
|
1520
|
+
return 1;
|
|
1521
|
+
}
|
|
1522
|
+
if (!versionElement) {
|
|
1523
|
+
return -1;
|
|
1524
|
+
}
|
|
1525
|
+
return compareAtom(rangeElement, versionElement);
|
|
1526
|
+
}
|
|
1527
|
+
return 0;
|
|
1528
|
+
}
|
|
1529
|
+
function compareVersion(rangeAtom, versionAtom) {
|
|
1530
|
+
return compareAtom(rangeAtom.major, versionAtom.major) || compareAtom(rangeAtom.minor, versionAtom.minor) || compareAtom(rangeAtom.patch, versionAtom.patch) || comparePreRelease(rangeAtom, versionAtom);
|
|
1531
|
+
}
|
|
1532
|
+
function eq(rangeAtom, versionAtom) {
|
|
1533
|
+
return rangeAtom.version === versionAtom.version;
|
|
1534
|
+
}
|
|
1535
|
+
function compare(rangeAtom, versionAtom) {
|
|
1536
|
+
switch (rangeAtom.operator) {
|
|
1537
|
+
case "":
|
|
1538
|
+
case "=":
|
|
1539
|
+
return eq(rangeAtom, versionAtom);
|
|
1540
|
+
case ">":
|
|
1541
|
+
return compareVersion(rangeAtom, versionAtom) < 0;
|
|
1542
|
+
case ">=":
|
|
1543
|
+
return eq(rangeAtom, versionAtom) || compareVersion(rangeAtom, versionAtom) < 0;
|
|
1544
|
+
case "<":
|
|
1545
|
+
return compareVersion(rangeAtom, versionAtom) > 0;
|
|
1546
|
+
case "<=":
|
|
1547
|
+
return eq(rangeAtom, versionAtom) || compareVersion(rangeAtom, versionAtom) > 0;
|
|
1548
|
+
case void 0: {
|
|
1549
|
+
return true;
|
|
1550
|
+
}
|
|
1551
|
+
default:
|
|
1552
|
+
return false;
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
function parseComparatorString(range) {
|
|
1556
|
+
return pipe(
|
|
1557
|
+
// handle caret
|
|
1558
|
+
// ^ --> * (any, kinda silly)
|
|
1559
|
+
// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
|
|
1560
|
+
// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
|
|
1561
|
+
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
|
|
1562
|
+
// ^1.2.3 --> >=1.2.3 <2.0.0-0
|
|
1563
|
+
// ^1.2.0 --> >=1.2.0 <2.0.0-0
|
|
1564
|
+
parseCarets,
|
|
1565
|
+
// handle tilde
|
|
1566
|
+
// ~, ~> --> * (any, kinda silly)
|
|
1567
|
+
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
|
|
1568
|
+
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
|
|
1569
|
+
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
|
|
1570
|
+
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
|
|
1571
|
+
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
|
|
1572
|
+
parseTildes,
|
|
1573
|
+
parseXRanges,
|
|
1574
|
+
parseStar
|
|
1575
|
+
)(range);
|
|
1576
|
+
}
|
|
1577
|
+
function parseRange(range) {
|
|
1578
|
+
return pipe(
|
|
1579
|
+
// handle hyphenRange
|
|
1580
|
+
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
|
1581
|
+
parseHyphen,
|
|
1582
|
+
// handle trim comparator
|
|
1583
|
+
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
|
1584
|
+
parseComparatorTrim,
|
|
1585
|
+
// handle trim tilde
|
|
1586
|
+
// `~ 1.2.3` => `~1.2.3`
|
|
1587
|
+
parseTildeTrim,
|
|
1588
|
+
// handle trim caret
|
|
1589
|
+
// `^ 1.2.3` => `^1.2.3`
|
|
1590
|
+
parseCaretTrim
|
|
1591
|
+
)(range.trim()).split(/\s+/).join(" ");
|
|
1592
|
+
}
|
|
1593
|
+
function satisfy(version2, range) {
|
|
1594
|
+
if (!version2) {
|
|
1595
|
+
return false;
|
|
1596
|
+
}
|
|
1597
|
+
const extractedVersion = extractComparator(version2);
|
|
1598
|
+
if (!extractedVersion) {
|
|
1599
|
+
return false;
|
|
1600
|
+
}
|
|
1601
|
+
const [, versionOperator, , versionMajor, versionMinor, versionPatch, versionPreRelease] = extractedVersion;
|
|
1602
|
+
const versionAtom = {
|
|
1603
|
+
operator: versionOperator,
|
|
1604
|
+
version: combineVersion(versionMajor, versionMinor, versionPatch, versionPreRelease),
|
|
1605
|
+
// exclude build atom
|
|
1606
|
+
major: versionMajor,
|
|
1607
|
+
minor: versionMinor,
|
|
1608
|
+
patch: versionPatch,
|
|
1609
|
+
preRelease: versionPreRelease?.split(".")
|
|
1610
|
+
};
|
|
1611
|
+
const orRanges = range.split("||");
|
|
1612
|
+
for (const orRange of orRanges) {
|
|
1613
|
+
const trimmedOrRange = orRange.trim();
|
|
1614
|
+
if (!trimmedOrRange) {
|
|
1615
|
+
return true;
|
|
1616
|
+
}
|
|
1617
|
+
if (trimmedOrRange === "*" || trimmedOrRange === "x") {
|
|
1618
|
+
return true;
|
|
1619
|
+
}
|
|
1620
|
+
try {
|
|
1621
|
+
const parsedSubRange = parseRange(trimmedOrRange);
|
|
1622
|
+
if (!parsedSubRange.trim()) {
|
|
1623
|
+
return true;
|
|
1624
|
+
}
|
|
1625
|
+
const parsedComparatorString = parsedSubRange.split(" ").map((rangeVersion) => parseComparatorString(rangeVersion)).join(" ");
|
|
1626
|
+
if (!parsedComparatorString.trim()) {
|
|
1627
|
+
return true;
|
|
1628
|
+
}
|
|
1629
|
+
const comparators = parsedComparatorString.split(/\s+/).map((comparator2) => parseGTE0(comparator2)).filter(Boolean);
|
|
1630
|
+
if (comparators.length === 0) {
|
|
1631
|
+
continue;
|
|
1632
|
+
}
|
|
1633
|
+
let subRangeSatisfied = true;
|
|
1634
|
+
for (const comparator2 of comparators) {
|
|
1635
|
+
const extractedComparator = extractComparator(comparator2);
|
|
1636
|
+
if (!extractedComparator) {
|
|
1637
|
+
subRangeSatisfied = false;
|
|
1638
|
+
break;
|
|
1639
|
+
}
|
|
1640
|
+
const [, rangeOperator, , rangeMajor, rangeMinor, rangePatch, rangePreRelease] = extractedComparator;
|
|
1641
|
+
const rangeAtom = {
|
|
1642
|
+
operator: rangeOperator,
|
|
1643
|
+
version: combineVersion(rangeMajor, rangeMinor, rangePatch, rangePreRelease),
|
|
1644
|
+
major: rangeMajor,
|
|
1645
|
+
minor: rangeMinor,
|
|
1646
|
+
patch: rangePatch,
|
|
1647
|
+
preRelease: rangePreRelease?.split(".")
|
|
1648
|
+
};
|
|
1649
|
+
if (!compare(rangeAtom, versionAtom)) {
|
|
1650
|
+
subRangeSatisfied = false;
|
|
1651
|
+
break;
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
if (subRangeSatisfied) {
|
|
1655
|
+
return true;
|
|
1656
|
+
}
|
|
1657
|
+
} catch (e7) {
|
|
1658
|
+
console.error(`[semver] Error processing range part "${trimmedOrRange}":`, e7);
|
|
1659
|
+
continue;
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
return false;
|
|
1663
|
+
}
|
|
1664
|
+
function formatShare(shareArgs, from, name, shareStrategy) {
|
|
1665
|
+
let get;
|
|
1666
|
+
if ("get" in shareArgs) {
|
|
1667
|
+
get = shareArgs.get;
|
|
1668
|
+
} else if ("lib" in shareArgs) {
|
|
1669
|
+
get = () => Promise.resolve(shareArgs.lib);
|
|
1670
|
+
} else {
|
|
1671
|
+
get = () => Promise.resolve(() => {
|
|
1672
|
+
throw new Error(`Can not get shared '${name}'!`);
|
|
1673
|
+
});
|
|
1674
|
+
}
|
|
1675
|
+
return {
|
|
1676
|
+
deps: [],
|
|
1677
|
+
useIn: [],
|
|
1678
|
+
from,
|
|
1679
|
+
loading: null,
|
|
1680
|
+
...shareArgs,
|
|
1681
|
+
shareConfig: {
|
|
1682
|
+
requiredVersion: `^${shareArgs.version}`,
|
|
1683
|
+
singleton: false,
|
|
1684
|
+
eager: false,
|
|
1685
|
+
strictVersion: false,
|
|
1686
|
+
...shareArgs.shareConfig
|
|
1687
|
+
},
|
|
1688
|
+
get,
|
|
1689
|
+
loaded: shareArgs?.loaded || "lib" in shareArgs ? true : void 0,
|
|
1690
|
+
version: shareArgs.version ?? "0",
|
|
1691
|
+
scope: Array.isArray(shareArgs.scope) ? shareArgs.scope : [shareArgs.scope ?? "default"],
|
|
1692
|
+
strategy: (shareArgs.strategy ?? shareStrategy) || "version-first"
|
|
1693
|
+
};
|
|
1694
|
+
}
|
|
1695
|
+
function formatShareConfigs(globalOptions, userOptions) {
|
|
1696
|
+
const shareArgs = userOptions.shared || {};
|
|
1697
|
+
const from = userOptions.name;
|
|
1698
|
+
const shareInfos = Object.keys(shareArgs).reduce((res2, pkgName) => {
|
|
1699
|
+
const arrayShareArgs = arrayOptions(shareArgs[pkgName]);
|
|
1700
|
+
res2[pkgName] = res2[pkgName] || [];
|
|
1701
|
+
arrayShareArgs.forEach((shareConfig) => {
|
|
1702
|
+
res2[pkgName].push(formatShare(shareConfig, from, pkgName, userOptions.shareStrategy));
|
|
1703
|
+
});
|
|
1704
|
+
return res2;
|
|
1705
|
+
}, {});
|
|
1706
|
+
const shared = {
|
|
1707
|
+
...globalOptions.shared
|
|
1708
|
+
};
|
|
1709
|
+
Object.keys(shareInfos).forEach((shareKey) => {
|
|
1710
|
+
if (!shared[shareKey]) {
|
|
1711
|
+
shared[shareKey] = shareInfos[shareKey];
|
|
1712
|
+
} else {
|
|
1713
|
+
shareInfos[shareKey].forEach((newUserSharedOptions) => {
|
|
1714
|
+
const isSameVersion = shared[shareKey].find((sharedVal) => sharedVal.version === newUserSharedOptions.version);
|
|
1715
|
+
if (!isSameVersion) {
|
|
1716
|
+
shared[shareKey].push(newUserSharedOptions);
|
|
1717
|
+
}
|
|
1718
|
+
});
|
|
1719
|
+
}
|
|
1720
|
+
});
|
|
1721
|
+
return { shared, shareInfos };
|
|
1722
|
+
}
|
|
1723
|
+
function versionLt(a3, b3) {
|
|
1724
|
+
const transformInvalidVersion = (version2) => {
|
|
1725
|
+
const isNumberVersion = !Number.isNaN(Number(version2));
|
|
1726
|
+
if (isNumberVersion) {
|
|
1727
|
+
const splitArr = version2.split(".");
|
|
1728
|
+
let validVersion = version2;
|
|
1729
|
+
for (let i7 = 0; i7 < 3 - splitArr.length; i7++) {
|
|
1730
|
+
validVersion += ".0";
|
|
1731
|
+
}
|
|
1732
|
+
return validVersion;
|
|
1733
|
+
}
|
|
1734
|
+
return version2;
|
|
1735
|
+
};
|
|
1736
|
+
if (satisfy(transformInvalidVersion(a3), `<=${transformInvalidVersion(b3)}`)) {
|
|
1737
|
+
return true;
|
|
1738
|
+
} else {
|
|
1739
|
+
return false;
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
var findVersion = (shareVersionMap, cb2) => {
|
|
1743
|
+
const callback = cb2 || function(prev, cur) {
|
|
1744
|
+
return versionLt(prev, cur);
|
|
1745
|
+
};
|
|
1746
|
+
return Object.keys(shareVersionMap).reduce((prev, cur) => {
|
|
1747
|
+
if (!prev) {
|
|
1748
|
+
return cur;
|
|
1749
|
+
}
|
|
1750
|
+
if (callback(prev, cur)) {
|
|
1751
|
+
return cur;
|
|
1752
|
+
}
|
|
1753
|
+
if (prev === "0") {
|
|
1754
|
+
return cur;
|
|
1755
|
+
}
|
|
1756
|
+
return prev;
|
|
1757
|
+
}, 0);
|
|
1758
|
+
};
|
|
1759
|
+
var isLoaded = (shared) => {
|
|
1760
|
+
return Boolean(shared.loaded) || typeof shared.lib === "function";
|
|
1761
|
+
};
|
|
1762
|
+
var isLoading = (shared) => {
|
|
1763
|
+
return Boolean(shared.loading);
|
|
1764
|
+
};
|
|
1765
|
+
function findSingletonVersionOrderByVersion(shareScopeMap, scope, pkgName) {
|
|
1766
|
+
const versions = shareScopeMap[scope][pkgName];
|
|
1767
|
+
const callback = function(prev, cur) {
|
|
1768
|
+
return !isLoaded(versions[prev]) && versionLt(prev, cur);
|
|
1769
|
+
};
|
|
1770
|
+
return findVersion(shareScopeMap[scope][pkgName], callback);
|
|
1771
|
+
}
|
|
1772
|
+
function findSingletonVersionOrderByLoaded(shareScopeMap, scope, pkgName) {
|
|
1773
|
+
const versions = shareScopeMap[scope][pkgName];
|
|
1774
|
+
const callback = function(prev, cur) {
|
|
1775
|
+
const isLoadingOrLoaded = (shared) => {
|
|
1776
|
+
return isLoaded(shared) || isLoading(shared);
|
|
1777
|
+
};
|
|
1778
|
+
if (isLoadingOrLoaded(versions[cur])) {
|
|
1779
|
+
if (isLoadingOrLoaded(versions[prev])) {
|
|
1780
|
+
return Boolean(versionLt(prev, cur));
|
|
1781
|
+
} else {
|
|
1782
|
+
return true;
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
if (isLoadingOrLoaded(versions[prev])) {
|
|
1786
|
+
return false;
|
|
1787
|
+
}
|
|
1788
|
+
return versionLt(prev, cur);
|
|
1789
|
+
};
|
|
1790
|
+
return findVersion(shareScopeMap[scope][pkgName], callback);
|
|
1791
|
+
}
|
|
1792
|
+
function getFindShareFunction(strategy) {
|
|
1793
|
+
if (strategy === "loaded-first") {
|
|
1794
|
+
return findSingletonVersionOrderByLoaded;
|
|
1795
|
+
}
|
|
1796
|
+
return findSingletonVersionOrderByVersion;
|
|
1797
|
+
}
|
|
1798
|
+
function getRegisteredShare(localShareScopeMap, pkgName, shareInfo, resolveShare) {
|
|
1799
|
+
if (!localShareScopeMap) {
|
|
1800
|
+
return;
|
|
1801
|
+
}
|
|
1802
|
+
const { shareConfig, scope = DEFAULT_SCOPE, strategy } = shareInfo;
|
|
1803
|
+
const scopes = Array.isArray(scope) ? scope : [scope];
|
|
1804
|
+
for (const sc of scopes) {
|
|
1805
|
+
if (shareConfig && localShareScopeMap[sc] && localShareScopeMap[sc][pkgName]) {
|
|
1806
|
+
const { requiredVersion } = shareConfig;
|
|
1807
|
+
const findShareFunction = getFindShareFunction(strategy);
|
|
1808
|
+
const maxOrSingletonVersion = findShareFunction(localShareScopeMap, sc, pkgName);
|
|
1809
|
+
const defaultResolver = () => {
|
|
1810
|
+
if (shareConfig.singleton) {
|
|
1811
|
+
if (typeof requiredVersion === "string" && !satisfy(maxOrSingletonVersion, requiredVersion)) {
|
|
1812
|
+
const msg = `Version ${maxOrSingletonVersion} from ${maxOrSingletonVersion && localShareScopeMap[sc][pkgName][maxOrSingletonVersion].from} of shared singleton module ${pkgName} does not satisfy the requirement of ${shareInfo.from} which needs ${requiredVersion})`;
|
|
1813
|
+
if (shareConfig.strictVersion) {
|
|
1814
|
+
error2(msg);
|
|
1815
|
+
} else {
|
|
1816
|
+
warn2(msg);
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
return localShareScopeMap[sc][pkgName][maxOrSingletonVersion];
|
|
1820
|
+
} else {
|
|
1821
|
+
if (requiredVersion === false || requiredVersion === "*") {
|
|
1822
|
+
return localShareScopeMap[sc][pkgName][maxOrSingletonVersion];
|
|
1823
|
+
}
|
|
1824
|
+
if (satisfy(maxOrSingletonVersion, requiredVersion)) {
|
|
1825
|
+
return localShareScopeMap[sc][pkgName][maxOrSingletonVersion];
|
|
1826
|
+
}
|
|
1827
|
+
for (const [versionKey, versionValue] of Object.entries(localShareScopeMap[sc][pkgName])) {
|
|
1828
|
+
if (satisfy(versionKey, requiredVersion)) {
|
|
1829
|
+
return versionValue;
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
};
|
|
1834
|
+
const params = {
|
|
1835
|
+
shareScopeMap: localShareScopeMap,
|
|
1836
|
+
scope: sc,
|
|
1837
|
+
pkgName,
|
|
1838
|
+
version: maxOrSingletonVersion,
|
|
1839
|
+
GlobalFederation: Global.__FEDERATION__,
|
|
1840
|
+
resolver: defaultResolver
|
|
1841
|
+
};
|
|
1842
|
+
const resolveShared = resolveShare.emit(params) || params;
|
|
1843
|
+
return resolveShared.resolver();
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
function getGlobalShareScope() {
|
|
1848
|
+
return Global.__FEDERATION__.__SHARE__;
|
|
1849
|
+
}
|
|
1850
|
+
function getTargetSharedOptions(options) {
|
|
1851
|
+
const { pkgName, extraOptions, shareInfos } = options;
|
|
1852
|
+
const defaultResolver = (sharedOptions) => {
|
|
1853
|
+
if (!sharedOptions) {
|
|
1854
|
+
return void 0;
|
|
1855
|
+
}
|
|
1856
|
+
const shareVersionMap = {};
|
|
1857
|
+
sharedOptions.forEach((shared) => {
|
|
1858
|
+
shareVersionMap[shared.version] = shared;
|
|
1859
|
+
});
|
|
1860
|
+
const callback = function(prev, cur) {
|
|
1861
|
+
return !isLoaded(shareVersionMap[prev]) && versionLt(prev, cur);
|
|
1862
|
+
};
|
|
1863
|
+
const maxVersion = findVersion(shareVersionMap, callback);
|
|
1864
|
+
return shareVersionMap[maxVersion];
|
|
1865
|
+
};
|
|
1866
|
+
const resolver = extraOptions?.resolver ?? defaultResolver;
|
|
1867
|
+
return Object.assign({}, resolver(shareInfos[pkgName]), extraOptions?.customShareInfo);
|
|
1868
|
+
}
|
|
1869
|
+
function getBuilderId() {
|
|
1870
|
+
return typeof FEDERATION_BUILD_IDENTIFIER !== "undefined" ? (
|
|
1871
|
+
//@ts-ignore
|
|
1872
|
+
FEDERATION_BUILD_IDENTIFIER
|
|
1873
|
+
) : "";
|
|
1874
|
+
}
|
|
1875
|
+
function matchRemoteWithNameAndExpose(remotes, id) {
|
|
1876
|
+
for (const remote of remotes) {
|
|
1877
|
+
const isNameMatched = id.startsWith(remote.name);
|
|
1878
|
+
let expose = id.replace(remote.name, "");
|
|
1879
|
+
if (isNameMatched) {
|
|
1880
|
+
if (expose.startsWith("/")) {
|
|
1881
|
+
const pkgNameOrAlias = remote.name;
|
|
1882
|
+
expose = `.${expose}`;
|
|
1883
|
+
return {
|
|
1884
|
+
pkgNameOrAlias,
|
|
1885
|
+
expose,
|
|
1886
|
+
remote
|
|
1887
|
+
};
|
|
1888
|
+
} else if (expose === "") {
|
|
1889
|
+
return {
|
|
1890
|
+
pkgNameOrAlias: remote.name,
|
|
1891
|
+
expose: ".",
|
|
1892
|
+
remote
|
|
1893
|
+
};
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
const isAliasMatched = remote.alias && id.startsWith(remote.alias);
|
|
1897
|
+
let exposeWithAlias = remote.alias && id.replace(remote.alias, "");
|
|
1898
|
+
if (remote.alias && isAliasMatched) {
|
|
1899
|
+
if (exposeWithAlias && exposeWithAlias.startsWith("/")) {
|
|
1900
|
+
const pkgNameOrAlias = remote.alias;
|
|
1901
|
+
exposeWithAlias = `.${exposeWithAlias}`;
|
|
1902
|
+
return {
|
|
1903
|
+
pkgNameOrAlias,
|
|
1904
|
+
expose: exposeWithAlias,
|
|
1905
|
+
remote
|
|
1906
|
+
};
|
|
1907
|
+
} else if (exposeWithAlias === "") {
|
|
1908
|
+
return {
|
|
1909
|
+
pkgNameOrAlias: remote.alias,
|
|
1910
|
+
expose: ".",
|
|
1911
|
+
remote
|
|
1912
|
+
};
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
return;
|
|
1917
|
+
}
|
|
1918
|
+
function matchRemote(remotes, nameOrAlias) {
|
|
1919
|
+
for (const remote of remotes) {
|
|
1920
|
+
const isNameMatched = nameOrAlias === remote.name;
|
|
1921
|
+
if (isNameMatched) {
|
|
1922
|
+
return remote;
|
|
1923
|
+
}
|
|
1924
|
+
const isAliasMatched = remote.alias && nameOrAlias === remote.alias;
|
|
1925
|
+
if (isAliasMatched) {
|
|
1926
|
+
return remote;
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
return;
|
|
1930
|
+
}
|
|
1931
|
+
function registerPlugins(plugins, instance) {
|
|
1932
|
+
const globalPlugins = getGlobalHostPlugins();
|
|
1933
|
+
const hookInstances = [
|
|
1934
|
+
instance.hooks,
|
|
1935
|
+
instance.remoteHandler.hooks,
|
|
1936
|
+
instance.sharedHandler.hooks,
|
|
1937
|
+
instance.snapshotHandler.hooks,
|
|
1938
|
+
instance.loaderHook,
|
|
1939
|
+
instance.bridgeHook
|
|
1940
|
+
];
|
|
1941
|
+
if (globalPlugins.length > 0) {
|
|
1942
|
+
globalPlugins.forEach((plugin) => {
|
|
1943
|
+
if (plugins?.find((item) => item.name !== plugin.name)) {
|
|
1944
|
+
plugins.push(plugin);
|
|
1945
|
+
}
|
|
1946
|
+
});
|
|
1947
|
+
}
|
|
1948
|
+
if (plugins && plugins.length > 0) {
|
|
1949
|
+
plugins.forEach((plugin) => {
|
|
1950
|
+
hookInstances.forEach((hookInstance) => {
|
|
1951
|
+
hookInstance.applyPlugin(plugin, instance);
|
|
1952
|
+
});
|
|
1953
|
+
});
|
|
1954
|
+
}
|
|
1955
|
+
return plugins;
|
|
1956
|
+
}
|
|
1957
|
+
var importCallback = ".then(callbacks[0]).catch(callbacks[1])";
|
|
1958
|
+
async function loadEsmEntry({ entry, remoteEntryExports }) {
|
|
1959
|
+
return new Promise((resolve, reject) => {
|
|
1960
|
+
try {
|
|
1961
|
+
if (!remoteEntryExports) {
|
|
1962
|
+
if (typeof FEDERATION_ALLOW_NEW_FUNCTION !== "undefined") {
|
|
1963
|
+
new Function("callbacks", `import("${entry}")${importCallback}`)([
|
|
1964
|
+
resolve,
|
|
1965
|
+
reject
|
|
1966
|
+
]);
|
|
1967
|
+
} else {
|
|
1968
|
+
import(
|
|
1969
|
+
/* webpackIgnore: true */
|
|
1970
|
+
/* @vite-ignore */
|
|
1971
|
+
entry
|
|
1972
|
+
).then(resolve).catch(reject);
|
|
1973
|
+
}
|
|
1974
|
+
} else {
|
|
1975
|
+
resolve(remoteEntryExports);
|
|
1976
|
+
}
|
|
1977
|
+
} catch (e7) {
|
|
1978
|
+
reject(e7);
|
|
1979
|
+
}
|
|
1980
|
+
});
|
|
1981
|
+
}
|
|
1982
|
+
async function loadSystemJsEntry({ entry, remoteEntryExports }) {
|
|
1983
|
+
return new Promise((resolve, reject) => {
|
|
1984
|
+
try {
|
|
1985
|
+
if (!remoteEntryExports) {
|
|
1986
|
+
if (typeof __system_context__ === "undefined") {
|
|
1987
|
+
System.import(entry).then(resolve).catch(reject);
|
|
1988
|
+
} else {
|
|
1989
|
+
new Function("callbacks", `System.import("${entry}")${importCallback}`)([resolve, reject]);
|
|
1990
|
+
}
|
|
1991
|
+
} else {
|
|
1992
|
+
resolve(remoteEntryExports);
|
|
1993
|
+
}
|
|
1994
|
+
} catch (e7) {
|
|
1995
|
+
reject(e7);
|
|
1996
|
+
}
|
|
1997
|
+
});
|
|
1998
|
+
}
|
|
1999
|
+
function handleRemoteEntryLoaded(name, globalName, entry) {
|
|
2000
|
+
const { remoteEntryKey, entryExports } = getRemoteEntryExports(name, globalName);
|
|
2001
|
+
assert2(entryExports, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_001, errorCodes.runtimeDescMap, {
|
|
2002
|
+
remoteName: name,
|
|
2003
|
+
remoteEntryUrl: entry,
|
|
2004
|
+
remoteEntryKey
|
|
2005
|
+
}));
|
|
2006
|
+
return entryExports;
|
|
2007
|
+
}
|
|
2008
|
+
async function loadEntryScript({ name, globalName, entry, loaderHook: loaderHook2, getEntryUrl }) {
|
|
2009
|
+
const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);
|
|
2010
|
+
if (remoteEntryExports) {
|
|
2011
|
+
return remoteEntryExports;
|
|
2012
|
+
}
|
|
2013
|
+
const url2 = getEntryUrl ? getEntryUrl(entry) : entry;
|
|
2014
|
+
return sdk.loadScript(url2, {
|
|
2015
|
+
attrs: {},
|
|
2016
|
+
createScriptHook: (url3, attrs2) => {
|
|
2017
|
+
const res2 = loaderHook2.lifecycle.createScript.emit({ url: url3, attrs: attrs2 });
|
|
2018
|
+
if (!res2)
|
|
2019
|
+
return;
|
|
2020
|
+
if (res2 instanceof HTMLScriptElement) {
|
|
2021
|
+
return res2;
|
|
2022
|
+
}
|
|
2023
|
+
if ("script" in res2 || "timeout" in res2) {
|
|
2024
|
+
return res2;
|
|
2025
|
+
}
|
|
2026
|
+
return;
|
|
2027
|
+
}
|
|
2028
|
+
}).then(() => {
|
|
2029
|
+
return handleRemoteEntryLoaded(name, globalName, entry);
|
|
2030
|
+
}).catch((e7) => {
|
|
2031
|
+
assert2(void 0, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_008, errorCodes.runtimeDescMap, {
|
|
2032
|
+
remoteName: name,
|
|
2033
|
+
resourceUrl: entry
|
|
2034
|
+
}));
|
|
2035
|
+
throw e7;
|
|
2036
|
+
});
|
|
2037
|
+
}
|
|
2038
|
+
async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook: loaderHook2, getEntryUrl }) {
|
|
2039
|
+
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
2040
|
+
switch (type) {
|
|
2041
|
+
case "esm":
|
|
2042
|
+
case "module":
|
|
2043
|
+
return loadEsmEntry({ entry, remoteEntryExports });
|
|
2044
|
+
case "system":
|
|
2045
|
+
return loadSystemJsEntry({ entry, remoteEntryExports });
|
|
2046
|
+
default:
|
|
2047
|
+
return loadEntryScript({
|
|
2048
|
+
entry,
|
|
2049
|
+
globalName,
|
|
2050
|
+
name,
|
|
2051
|
+
loaderHook: loaderHook2,
|
|
2052
|
+
getEntryUrl
|
|
2053
|
+
});
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
async function loadEntryNode({ remoteInfo, loaderHook: loaderHook2 }) {
|
|
2057
|
+
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
2058
|
+
const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);
|
|
2059
|
+
if (remoteEntryExports) {
|
|
2060
|
+
return remoteEntryExports;
|
|
2061
|
+
}
|
|
2062
|
+
return sdk.loadScriptNode(entry, {
|
|
2063
|
+
attrs: { name, globalName, type },
|
|
2064
|
+
loaderHook: {
|
|
2065
|
+
createScriptHook: (url2, attrs2 = {}) => {
|
|
2066
|
+
const res2 = loaderHook2.lifecycle.createScript.emit({ url: url2, attrs: attrs2 });
|
|
2067
|
+
if (!res2)
|
|
2068
|
+
return;
|
|
2069
|
+
if ("url" in res2) {
|
|
2070
|
+
return res2;
|
|
2071
|
+
}
|
|
2072
|
+
return;
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
}).then(() => {
|
|
2076
|
+
return handleRemoteEntryLoaded(name, globalName, entry);
|
|
2077
|
+
}).catch((e7) => {
|
|
2078
|
+
throw e7;
|
|
2079
|
+
});
|
|
2080
|
+
}
|
|
2081
|
+
function getRemoteEntryUniqueKey(remoteInfo) {
|
|
2082
|
+
const { entry, name } = remoteInfo;
|
|
2083
|
+
return sdk.composeKeyWithSeparator(name, entry);
|
|
2084
|
+
}
|
|
2085
|
+
async function getRemoteEntry(params) {
|
|
2086
|
+
const { origin, remoteEntryExports, remoteInfo, getEntryUrl, _inErrorHandling = false } = params;
|
|
2087
|
+
const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);
|
|
2088
|
+
if (remoteEntryExports) {
|
|
2089
|
+
return remoteEntryExports;
|
|
2090
|
+
}
|
|
2091
|
+
if (!globalLoading[uniqueKey]) {
|
|
2092
|
+
const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;
|
|
2093
|
+
const loaderHook2 = origin.loaderHook;
|
|
2094
|
+
globalLoading[uniqueKey] = loadEntryHook.emit({
|
|
2095
|
+
loaderHook: loaderHook2,
|
|
2096
|
+
remoteInfo,
|
|
2097
|
+
remoteEntryExports
|
|
2098
|
+
}).then((res2) => {
|
|
2099
|
+
if (res2) {
|
|
2100
|
+
return res2;
|
|
2101
|
+
}
|
|
2102
|
+
const isWebEnvironment = typeof ENV_TARGET !== "undefined" ? ENV_TARGET === "web" : sdk.isBrowserEnv();
|
|
2103
|
+
return isWebEnvironment ? loadEntryDom({
|
|
2104
|
+
remoteInfo,
|
|
2105
|
+
remoteEntryExports,
|
|
2106
|
+
loaderHook: loaderHook2,
|
|
2107
|
+
getEntryUrl
|
|
2108
|
+
}) : loadEntryNode({ remoteInfo, loaderHook: loaderHook2 });
|
|
2109
|
+
}).catch(async (err) => {
|
|
2110
|
+
const uniqueKey2 = getRemoteEntryUniqueKey(remoteInfo);
|
|
2111
|
+
const isScriptLoadError = err instanceof Error && err.message.includes(errorCodes.RUNTIME_008);
|
|
2112
|
+
if (isScriptLoadError && !_inErrorHandling) {
|
|
2113
|
+
const wrappedGetRemoteEntry = (params2) => {
|
|
2114
|
+
return getRemoteEntry({ ...params2, _inErrorHandling: true });
|
|
2115
|
+
};
|
|
2116
|
+
const RemoteEntryExports = await origin.loaderHook.lifecycle.loadEntryError.emit({
|
|
2117
|
+
getRemoteEntry: wrappedGetRemoteEntry,
|
|
2118
|
+
origin,
|
|
2119
|
+
remoteInfo,
|
|
2120
|
+
remoteEntryExports,
|
|
2121
|
+
globalLoading,
|
|
2122
|
+
uniqueKey: uniqueKey2
|
|
2123
|
+
});
|
|
2124
|
+
if (RemoteEntryExports) {
|
|
2125
|
+
return RemoteEntryExports;
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
throw err;
|
|
2129
|
+
});
|
|
2130
|
+
}
|
|
2131
|
+
return globalLoading[uniqueKey];
|
|
2132
|
+
}
|
|
2133
|
+
function getRemoteInfo(remote) {
|
|
2134
|
+
return {
|
|
2135
|
+
...remote,
|
|
2136
|
+
entry: "entry" in remote ? remote.entry : "",
|
|
2137
|
+
type: remote.type || DEFAULT_REMOTE_TYPE,
|
|
2138
|
+
entryGlobalName: remote.entryGlobalName || remote.name,
|
|
2139
|
+
shareScope: remote.shareScope || DEFAULT_SCOPE
|
|
2140
|
+
};
|
|
2141
|
+
}
|
|
2142
|
+
function defaultPreloadArgs(preloadConfig) {
|
|
2143
|
+
return {
|
|
2144
|
+
resourceCategory: "sync",
|
|
2145
|
+
share: true,
|
|
2146
|
+
depsRemote: true,
|
|
2147
|
+
prefetchInterface: false,
|
|
2148
|
+
...preloadConfig
|
|
2149
|
+
};
|
|
2150
|
+
}
|
|
2151
|
+
function formatPreloadArgs(remotes, preloadArgs) {
|
|
2152
|
+
return preloadArgs.map((args) => {
|
|
2153
|
+
const remoteInfo = matchRemote(remotes, args.nameOrAlias);
|
|
2154
|
+
assert2(remoteInfo, `Unable to preload ${args.nameOrAlias} as it is not included in ${!remoteInfo && sdk.safeToString({
|
|
2155
|
+
remoteInfo,
|
|
2156
|
+
remotes
|
|
2157
|
+
})}`);
|
|
2158
|
+
return {
|
|
2159
|
+
remote: remoteInfo,
|
|
2160
|
+
preloadConfig: defaultPreloadArgs(args)
|
|
2161
|
+
};
|
|
2162
|
+
});
|
|
2163
|
+
}
|
|
2164
|
+
function normalizePreloadExposes(exposes) {
|
|
2165
|
+
if (!exposes) {
|
|
2166
|
+
return [];
|
|
2167
|
+
}
|
|
2168
|
+
return exposes.map((expose) => {
|
|
2169
|
+
if (expose === ".") {
|
|
2170
|
+
return expose;
|
|
2171
|
+
}
|
|
2172
|
+
if (expose.startsWith("./")) {
|
|
2173
|
+
return expose.replace("./", "");
|
|
2174
|
+
}
|
|
2175
|
+
return expose;
|
|
2176
|
+
});
|
|
2177
|
+
}
|
|
2178
|
+
function preloadAssets(remoteInfo, host, assets, useLinkPreload = true) {
|
|
2179
|
+
const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;
|
|
2180
|
+
if (host.options.inBrowser) {
|
|
2181
|
+
entryAssets.forEach((asset) => {
|
|
2182
|
+
const { moduleInfo } = asset;
|
|
2183
|
+
const module3 = host.moduleCache.get(remoteInfo.name);
|
|
2184
|
+
if (module3) {
|
|
2185
|
+
getRemoteEntry({
|
|
2186
|
+
origin: host,
|
|
2187
|
+
remoteInfo: moduleInfo,
|
|
2188
|
+
remoteEntryExports: module3.remoteEntryExports
|
|
2189
|
+
});
|
|
2190
|
+
} else {
|
|
2191
|
+
getRemoteEntry({
|
|
2192
|
+
origin: host,
|
|
2193
|
+
remoteInfo: moduleInfo,
|
|
2194
|
+
remoteEntryExports: void 0
|
|
2195
|
+
});
|
|
2196
|
+
}
|
|
2197
|
+
});
|
|
2198
|
+
if (useLinkPreload) {
|
|
2199
|
+
const defaultAttrs = {
|
|
2200
|
+
rel: "preload",
|
|
2201
|
+
as: "style"
|
|
2202
|
+
};
|
|
2203
|
+
cssAssets.forEach((cssUrl) => {
|
|
2204
|
+
const { link: cssEl, needAttach } = sdk.createLink({
|
|
2205
|
+
url: cssUrl,
|
|
2206
|
+
cb: () => {
|
|
2207
|
+
},
|
|
2208
|
+
attrs: defaultAttrs,
|
|
2209
|
+
createLinkHook: (url2, attrs2) => {
|
|
2210
|
+
const res2 = host.loaderHook.lifecycle.createLink.emit({
|
|
2211
|
+
url: url2,
|
|
2212
|
+
attrs: attrs2
|
|
2213
|
+
});
|
|
2214
|
+
if (res2 instanceof HTMLLinkElement) {
|
|
2215
|
+
return res2;
|
|
2216
|
+
}
|
|
2217
|
+
return;
|
|
2218
|
+
}
|
|
2219
|
+
});
|
|
2220
|
+
needAttach && document.head.appendChild(cssEl);
|
|
2221
|
+
});
|
|
2222
|
+
} else {
|
|
2223
|
+
const defaultAttrs = {
|
|
2224
|
+
rel: "stylesheet",
|
|
2225
|
+
type: "text/css"
|
|
2226
|
+
};
|
|
2227
|
+
cssAssets.forEach((cssUrl) => {
|
|
2228
|
+
const { link: cssEl, needAttach } = sdk.createLink({
|
|
2229
|
+
url: cssUrl,
|
|
2230
|
+
cb: () => {
|
|
2231
|
+
},
|
|
2232
|
+
attrs: defaultAttrs,
|
|
2233
|
+
createLinkHook: (url2, attrs2) => {
|
|
2234
|
+
const res2 = host.loaderHook.lifecycle.createLink.emit({
|
|
2235
|
+
url: url2,
|
|
2236
|
+
attrs: attrs2
|
|
2237
|
+
});
|
|
2238
|
+
if (res2 instanceof HTMLLinkElement) {
|
|
2239
|
+
return res2;
|
|
2240
|
+
}
|
|
2241
|
+
return;
|
|
2242
|
+
},
|
|
2243
|
+
needDeleteLink: false
|
|
2244
|
+
});
|
|
2245
|
+
needAttach && document.head.appendChild(cssEl);
|
|
2246
|
+
});
|
|
2247
|
+
}
|
|
2248
|
+
if (useLinkPreload) {
|
|
2249
|
+
const defaultAttrs = {
|
|
2250
|
+
rel: "preload",
|
|
2251
|
+
as: "script"
|
|
2252
|
+
};
|
|
2253
|
+
jsAssetsWithoutEntry.forEach((jsUrl) => {
|
|
2254
|
+
const { link: linkEl, needAttach } = sdk.createLink({
|
|
2255
|
+
url: jsUrl,
|
|
2256
|
+
cb: () => {
|
|
2257
|
+
},
|
|
2258
|
+
attrs: defaultAttrs,
|
|
2259
|
+
createLinkHook: (url2, attrs2) => {
|
|
2260
|
+
const res2 = host.loaderHook.lifecycle.createLink.emit({
|
|
2261
|
+
url: url2,
|
|
2262
|
+
attrs: attrs2
|
|
2263
|
+
});
|
|
2264
|
+
if (res2 instanceof HTMLLinkElement) {
|
|
2265
|
+
return res2;
|
|
2266
|
+
}
|
|
2267
|
+
return;
|
|
2268
|
+
}
|
|
2269
|
+
});
|
|
2270
|
+
needAttach && document.head.appendChild(linkEl);
|
|
2271
|
+
});
|
|
2272
|
+
} else {
|
|
2273
|
+
const defaultAttrs = {
|
|
2274
|
+
fetchpriority: "high",
|
|
2275
|
+
type: remoteInfo?.type === "module" ? "module" : "text/javascript"
|
|
2276
|
+
};
|
|
2277
|
+
jsAssetsWithoutEntry.forEach((jsUrl) => {
|
|
2278
|
+
const { script: scriptEl, needAttach } = sdk.createScript({
|
|
2279
|
+
url: jsUrl,
|
|
2280
|
+
cb: () => {
|
|
2281
|
+
},
|
|
2282
|
+
attrs: defaultAttrs,
|
|
2283
|
+
createScriptHook: (url2, attrs2) => {
|
|
2284
|
+
const res2 = host.loaderHook.lifecycle.createScript.emit({
|
|
2285
|
+
url: url2,
|
|
2286
|
+
attrs: attrs2
|
|
2287
|
+
});
|
|
2288
|
+
if (res2 instanceof HTMLScriptElement) {
|
|
2289
|
+
return res2;
|
|
2290
|
+
}
|
|
2291
|
+
return;
|
|
2292
|
+
},
|
|
2293
|
+
needDeleteScript: true
|
|
2294
|
+
});
|
|
2295
|
+
needAttach && document.head.appendChild(scriptEl);
|
|
2296
|
+
});
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
var ShareUtils = {
|
|
2301
|
+
getRegisteredShare,
|
|
2302
|
+
getGlobalShareScope
|
|
2303
|
+
};
|
|
2304
|
+
var GlobalUtils = {
|
|
2305
|
+
Global,
|
|
2306
|
+
nativeGlobal,
|
|
2307
|
+
resetFederationGlobalInfo,
|
|
2308
|
+
setGlobalFederationInstance,
|
|
2309
|
+
getGlobalFederationConstructor,
|
|
2310
|
+
setGlobalFederationConstructor,
|
|
2311
|
+
getInfoWithoutType,
|
|
2312
|
+
getGlobalSnapshot,
|
|
2313
|
+
getTargetSnapshotInfoByModuleInfo,
|
|
2314
|
+
getGlobalSnapshotInfoByModuleInfo,
|
|
2315
|
+
setGlobalSnapshotInfoByModuleInfo,
|
|
2316
|
+
addGlobalSnapshot,
|
|
2317
|
+
getRemoteEntryExports,
|
|
2318
|
+
registerGlobalPlugins,
|
|
2319
|
+
getGlobalHostPlugins,
|
|
2320
|
+
getPreloaded,
|
|
2321
|
+
setPreloaded
|
|
2322
|
+
};
|
|
2323
|
+
var helpers = {
|
|
2324
|
+
global: GlobalUtils,
|
|
2325
|
+
share: ShareUtils,
|
|
2326
|
+
utils: {
|
|
2327
|
+
matchRemoteWithNameAndExpose,
|
|
2328
|
+
preloadAssets,
|
|
2329
|
+
getRemoteInfo
|
|
2330
|
+
}
|
|
2331
|
+
};
|
|
2332
|
+
var Module = class {
|
|
2333
|
+
constructor({ remoteInfo, host }) {
|
|
2334
|
+
this.inited = false;
|
|
2335
|
+
this.lib = void 0;
|
|
2336
|
+
this.remoteInfo = remoteInfo;
|
|
2337
|
+
this.host = host;
|
|
2338
|
+
}
|
|
2339
|
+
async getEntry() {
|
|
2340
|
+
if (this.remoteEntryExports) {
|
|
2341
|
+
return this.remoteEntryExports;
|
|
2342
|
+
}
|
|
2343
|
+
let remoteEntryExports;
|
|
2344
|
+
remoteEntryExports = await getRemoteEntry({
|
|
2345
|
+
origin: this.host,
|
|
2346
|
+
remoteInfo: this.remoteInfo,
|
|
2347
|
+
remoteEntryExports: this.remoteEntryExports
|
|
2348
|
+
});
|
|
2349
|
+
assert2(remoteEntryExports, `remoteEntryExports is undefined
|
|
2350
|
+
${sdk.safeToString(this.remoteInfo)}`);
|
|
2351
|
+
this.remoteEntryExports = remoteEntryExports;
|
|
2352
|
+
return this.remoteEntryExports;
|
|
2353
|
+
}
|
|
2354
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
2355
|
+
async get(id, expose, options, remoteSnapshot) {
|
|
2356
|
+
const { loadFactory = true } = options || { loadFactory: true };
|
|
2357
|
+
const remoteEntryExports = await this.getEntry();
|
|
2358
|
+
if (!this.inited) {
|
|
2359
|
+
const localShareScopeMap = this.host.shareScopeMap;
|
|
2360
|
+
const shareScopeKeys = Array.isArray(this.remoteInfo.shareScope) ? this.remoteInfo.shareScope : [this.remoteInfo.shareScope];
|
|
2361
|
+
if (!shareScopeKeys.length) {
|
|
2362
|
+
shareScopeKeys.push("default");
|
|
2363
|
+
}
|
|
2364
|
+
shareScopeKeys.forEach((shareScopeKey) => {
|
|
2365
|
+
if (!localShareScopeMap[shareScopeKey]) {
|
|
2366
|
+
localShareScopeMap[shareScopeKey] = {};
|
|
2367
|
+
}
|
|
2368
|
+
});
|
|
2369
|
+
const shareScope = localShareScopeMap[shareScopeKeys[0]];
|
|
2370
|
+
const initScope = [];
|
|
2371
|
+
const remoteEntryInitOptions = {
|
|
2372
|
+
version: this.remoteInfo.version || "",
|
|
2373
|
+
shareScopeKeys: Array.isArray(this.remoteInfo.shareScope) ? shareScopeKeys : this.remoteInfo.shareScope || "default"
|
|
2374
|
+
};
|
|
2375
|
+
Object.defineProperty(remoteEntryInitOptions, "shareScopeMap", {
|
|
2376
|
+
value: localShareScopeMap,
|
|
2377
|
+
// remoteEntryInitOptions will be traversed and assigned during container init, ,so this attribute is not allowed to be traversed
|
|
2378
|
+
enumerable: false
|
|
2379
|
+
});
|
|
2380
|
+
const initContainerOptions = await this.host.hooks.lifecycle.beforeInitContainer.emit({
|
|
2381
|
+
shareScope,
|
|
2382
|
+
// @ts-ignore shareScopeMap will be set by Object.defineProperty
|
|
2383
|
+
remoteEntryInitOptions,
|
|
2384
|
+
initScope,
|
|
2385
|
+
remoteInfo: this.remoteInfo,
|
|
2386
|
+
origin: this.host
|
|
2387
|
+
});
|
|
2388
|
+
if (typeof remoteEntryExports?.init === "undefined") {
|
|
2389
|
+
error2(errorCodes.getShortErrorMsg(errorCodes.RUNTIME_002, errorCodes.runtimeDescMap, {
|
|
2390
|
+
hostName: this.host.name,
|
|
2391
|
+
remoteName: this.remoteInfo.name,
|
|
2392
|
+
remoteEntryUrl: this.remoteInfo.entry,
|
|
2393
|
+
remoteEntryKey: this.remoteInfo.entryGlobalName
|
|
2394
|
+
}));
|
|
2395
|
+
}
|
|
2396
|
+
await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
|
|
2397
|
+
await this.host.hooks.lifecycle.initContainer.emit({
|
|
2398
|
+
...initContainerOptions,
|
|
2399
|
+
id,
|
|
2400
|
+
remoteSnapshot,
|
|
2401
|
+
remoteEntryExports
|
|
2402
|
+
});
|
|
2403
|
+
}
|
|
2404
|
+
this.lib = remoteEntryExports;
|
|
2405
|
+
this.inited = true;
|
|
2406
|
+
let moduleFactory;
|
|
2407
|
+
moduleFactory = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
|
|
2408
|
+
remoteEntryExports,
|
|
2409
|
+
expose,
|
|
2410
|
+
moduleInfo: this.remoteInfo
|
|
2411
|
+
});
|
|
2412
|
+
if (!moduleFactory) {
|
|
2413
|
+
moduleFactory = await remoteEntryExports.get(expose);
|
|
2414
|
+
}
|
|
2415
|
+
assert2(moduleFactory, `${getFMId(this.remoteInfo)} remote don't export ${expose}.`);
|
|
2416
|
+
const symbolName = processModuleAlias(this.remoteInfo.name, expose);
|
|
2417
|
+
const wrapModuleFactory = this.wraperFactory(moduleFactory, symbolName);
|
|
2418
|
+
if (!loadFactory) {
|
|
2419
|
+
return wrapModuleFactory;
|
|
2420
|
+
}
|
|
2421
|
+
const exposeContent = await wrapModuleFactory();
|
|
2422
|
+
return exposeContent;
|
|
2423
|
+
}
|
|
2424
|
+
wraperFactory(moduleFactory, id) {
|
|
2425
|
+
function defineModuleId(res2, id2) {
|
|
2426
|
+
if (res2 && typeof res2 === "object" && Object.isExtensible(res2) && !Object.getOwnPropertyDescriptor(res2, /* @__PURE__ */ Symbol.for("mf_module_id"))) {
|
|
2427
|
+
Object.defineProperty(res2, /* @__PURE__ */ Symbol.for("mf_module_id"), {
|
|
2428
|
+
value: id2,
|
|
2429
|
+
enumerable: false
|
|
2430
|
+
});
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
if (moduleFactory instanceof Promise) {
|
|
2434
|
+
return async () => {
|
|
2435
|
+
const res2 = await moduleFactory();
|
|
2436
|
+
defineModuleId(res2, id);
|
|
2437
|
+
return res2;
|
|
2438
|
+
};
|
|
2439
|
+
} else {
|
|
2440
|
+
return () => {
|
|
2441
|
+
const res2 = moduleFactory();
|
|
2442
|
+
defineModuleId(res2, id);
|
|
2443
|
+
return res2;
|
|
2444
|
+
};
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
};
|
|
2448
|
+
var SyncHook = class {
|
|
2449
|
+
constructor(type) {
|
|
2450
|
+
this.type = "";
|
|
2451
|
+
this.listeners = /* @__PURE__ */ new Set();
|
|
2452
|
+
if (type) {
|
|
2453
|
+
this.type = type;
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
on(fn) {
|
|
2457
|
+
if (typeof fn === "function") {
|
|
2458
|
+
this.listeners.add(fn);
|
|
2459
|
+
}
|
|
2460
|
+
}
|
|
2461
|
+
once(fn) {
|
|
2462
|
+
const self = this;
|
|
2463
|
+
this.on(function wrapper(...args) {
|
|
2464
|
+
self.remove(wrapper);
|
|
2465
|
+
return fn.apply(null, args);
|
|
2466
|
+
});
|
|
2467
|
+
}
|
|
2468
|
+
emit(...data2) {
|
|
2469
|
+
let result;
|
|
2470
|
+
if (this.listeners.size > 0) {
|
|
2471
|
+
this.listeners.forEach((fn) => {
|
|
2472
|
+
result = fn(...data2);
|
|
2473
|
+
});
|
|
2474
|
+
}
|
|
2475
|
+
return result;
|
|
2476
|
+
}
|
|
2477
|
+
remove(fn) {
|
|
2478
|
+
this.listeners.delete(fn);
|
|
2479
|
+
}
|
|
2480
|
+
removeAll() {
|
|
2481
|
+
this.listeners.clear();
|
|
2482
|
+
}
|
|
2483
|
+
};
|
|
2484
|
+
var AsyncHook = class extends SyncHook {
|
|
2485
|
+
emit(...data2) {
|
|
2486
|
+
let result;
|
|
2487
|
+
const ls = Array.from(this.listeners);
|
|
2488
|
+
if (ls.length > 0) {
|
|
2489
|
+
let i7 = 0;
|
|
2490
|
+
const call = (prev) => {
|
|
2491
|
+
if (prev === false) {
|
|
2492
|
+
return false;
|
|
2493
|
+
} else if (i7 < ls.length) {
|
|
2494
|
+
return Promise.resolve(ls[i7++].apply(null, data2)).then(call);
|
|
2495
|
+
} else {
|
|
2496
|
+
return prev;
|
|
2497
|
+
}
|
|
2498
|
+
};
|
|
2499
|
+
result = call();
|
|
2500
|
+
}
|
|
2501
|
+
return Promise.resolve(result);
|
|
2502
|
+
}
|
|
2503
|
+
};
|
|
2504
|
+
function checkReturnData(originalData, returnedData) {
|
|
2505
|
+
if (!isObject2(returnedData)) {
|
|
2506
|
+
return false;
|
|
2507
|
+
}
|
|
2508
|
+
if (originalData !== returnedData) {
|
|
2509
|
+
for (const key in originalData) {
|
|
2510
|
+
if (!(key in returnedData)) {
|
|
2511
|
+
return false;
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
return true;
|
|
2516
|
+
}
|
|
2517
|
+
var SyncWaterfallHook = class extends SyncHook {
|
|
2518
|
+
constructor(type) {
|
|
2519
|
+
super();
|
|
2520
|
+
this.onerror = error2;
|
|
2521
|
+
this.type = type;
|
|
2522
|
+
}
|
|
2523
|
+
emit(data2) {
|
|
2524
|
+
if (!isObject2(data2)) {
|
|
2525
|
+
error2(`The data for the "${this.type}" hook should be an object.`);
|
|
2526
|
+
}
|
|
2527
|
+
for (const fn of this.listeners) {
|
|
2528
|
+
try {
|
|
2529
|
+
const tempData = fn(data2);
|
|
2530
|
+
if (checkReturnData(data2, tempData)) {
|
|
2531
|
+
data2 = tempData;
|
|
2532
|
+
} else {
|
|
2533
|
+
this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);
|
|
2534
|
+
break;
|
|
2535
|
+
}
|
|
2536
|
+
} catch (e7) {
|
|
2537
|
+
warn2(e7);
|
|
2538
|
+
this.onerror(e7);
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
return data2;
|
|
2542
|
+
}
|
|
2543
|
+
};
|
|
2544
|
+
var AsyncWaterfallHook = class extends SyncHook {
|
|
2545
|
+
constructor(type) {
|
|
2546
|
+
super();
|
|
2547
|
+
this.onerror = error2;
|
|
2548
|
+
this.type = type;
|
|
2549
|
+
}
|
|
2550
|
+
emit(data2) {
|
|
2551
|
+
if (!isObject2(data2)) {
|
|
2552
|
+
error2(`The response data for the "${this.type}" hook must be an object.`);
|
|
2553
|
+
}
|
|
2554
|
+
const ls = Array.from(this.listeners);
|
|
2555
|
+
if (ls.length > 0) {
|
|
2556
|
+
let i7 = 0;
|
|
2557
|
+
const processError = (e7) => {
|
|
2558
|
+
warn2(e7);
|
|
2559
|
+
this.onerror(e7);
|
|
2560
|
+
return data2;
|
|
2561
|
+
};
|
|
2562
|
+
const call = (prevData) => {
|
|
2563
|
+
if (checkReturnData(data2, prevData)) {
|
|
2564
|
+
data2 = prevData;
|
|
2565
|
+
if (i7 < ls.length) {
|
|
2566
|
+
try {
|
|
2567
|
+
return Promise.resolve(ls[i7++](data2)).then(call, processError);
|
|
2568
|
+
} catch (e7) {
|
|
2569
|
+
return processError(e7);
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
} else {
|
|
2573
|
+
this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
|
|
2574
|
+
}
|
|
2575
|
+
return data2;
|
|
2576
|
+
};
|
|
2577
|
+
return Promise.resolve(call(data2));
|
|
2578
|
+
}
|
|
2579
|
+
return Promise.resolve(data2);
|
|
2580
|
+
}
|
|
2581
|
+
};
|
|
2582
|
+
var PluginSystem = class {
|
|
2583
|
+
constructor(lifecycle) {
|
|
2584
|
+
this.registerPlugins = {};
|
|
2585
|
+
this.lifecycle = lifecycle;
|
|
2586
|
+
this.lifecycleKeys = Object.keys(lifecycle);
|
|
2587
|
+
}
|
|
2588
|
+
applyPlugin(plugin, instance) {
|
|
2589
|
+
assert2(isPlainObject(plugin), "Plugin configuration is invalid.");
|
|
2590
|
+
const pluginName = plugin.name;
|
|
2591
|
+
assert2(pluginName, "A name must be provided by the plugin.");
|
|
2592
|
+
if (!this.registerPlugins[pluginName]) {
|
|
2593
|
+
this.registerPlugins[pluginName] = plugin;
|
|
2594
|
+
plugin.apply?.(instance);
|
|
2595
|
+
Object.keys(this.lifecycle).forEach((key) => {
|
|
2596
|
+
const pluginLife = plugin[key];
|
|
2597
|
+
if (pluginLife) {
|
|
2598
|
+
this.lifecycle[key].on(pluginLife);
|
|
2599
|
+
}
|
|
2600
|
+
});
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2603
|
+
removePlugin(pluginName) {
|
|
2604
|
+
assert2(pluginName, "A name is required.");
|
|
2605
|
+
const plugin = this.registerPlugins[pluginName];
|
|
2606
|
+
assert2(plugin, `The plugin "${pluginName}" is not registered.`);
|
|
2607
|
+
Object.keys(plugin).forEach((key) => {
|
|
2608
|
+
if (key !== "name") {
|
|
2609
|
+
this.lifecycle[key].remove(plugin[key]);
|
|
2610
|
+
}
|
|
2611
|
+
});
|
|
2612
|
+
}
|
|
2613
|
+
};
|
|
2614
|
+
function assignRemoteInfo(remoteInfo, remoteSnapshot) {
|
|
2615
|
+
const remoteEntryInfo = getRemoteEntryInfoFromSnapshot(remoteSnapshot);
|
|
2616
|
+
if (!remoteEntryInfo.url) {
|
|
2617
|
+
error2(`The attribute remoteEntry of ${remoteInfo.name} must not be undefined.`);
|
|
2618
|
+
}
|
|
2619
|
+
let entryUrl = sdk.getResourceUrl(remoteSnapshot, remoteEntryInfo.url);
|
|
2620
|
+
if (!sdk.isBrowserEnv() && !entryUrl.startsWith("http")) {
|
|
2621
|
+
entryUrl = `https:${entryUrl}`;
|
|
2622
|
+
}
|
|
2623
|
+
remoteInfo.type = remoteEntryInfo.type;
|
|
2624
|
+
remoteInfo.entryGlobalName = remoteEntryInfo.globalName;
|
|
2625
|
+
remoteInfo.entry = entryUrl;
|
|
2626
|
+
remoteInfo.version = remoteSnapshot.version;
|
|
2627
|
+
remoteInfo.buildVersion = remoteSnapshot.buildVersion;
|
|
2628
|
+
}
|
|
2629
|
+
function snapshotPlugin() {
|
|
2630
|
+
return {
|
|
2631
|
+
name: "snapshot-plugin",
|
|
2632
|
+
async afterResolve(args) {
|
|
2633
|
+
const { remote, pkgNameOrAlias, expose, origin, remoteInfo, id } = args;
|
|
2634
|
+
if (!isRemoteInfoWithEntry(remote) || !isPureRemoteEntry(remote)) {
|
|
2635
|
+
const { remoteSnapshot, globalSnapshot } = await origin.snapshotHandler.loadRemoteSnapshotInfo({
|
|
2636
|
+
moduleInfo: remote,
|
|
2637
|
+
id
|
|
2638
|
+
});
|
|
2639
|
+
assignRemoteInfo(remoteInfo, remoteSnapshot);
|
|
2640
|
+
const preloadOptions = {
|
|
2641
|
+
remote,
|
|
2642
|
+
preloadConfig: {
|
|
2643
|
+
nameOrAlias: pkgNameOrAlias,
|
|
2644
|
+
exposes: [expose],
|
|
2645
|
+
resourceCategory: "sync",
|
|
2646
|
+
share: false,
|
|
2647
|
+
depsRemote: false
|
|
2648
|
+
}
|
|
2649
|
+
};
|
|
2650
|
+
const assets = await origin.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({
|
|
2651
|
+
origin,
|
|
2652
|
+
preloadOptions,
|
|
2653
|
+
remoteInfo,
|
|
2654
|
+
remote,
|
|
2655
|
+
remoteSnapshot,
|
|
2656
|
+
globalSnapshot
|
|
2657
|
+
});
|
|
2658
|
+
if (assets) {
|
|
2659
|
+
preloadAssets(remoteInfo, origin, assets, false);
|
|
2660
|
+
}
|
|
2661
|
+
return {
|
|
2662
|
+
...args,
|
|
2663
|
+
remoteSnapshot
|
|
2664
|
+
};
|
|
2665
|
+
}
|
|
2666
|
+
return args;
|
|
2667
|
+
}
|
|
2668
|
+
};
|
|
2669
|
+
}
|
|
2670
|
+
function splitId(id) {
|
|
2671
|
+
const splitInfo = id.split(":");
|
|
2672
|
+
if (splitInfo.length === 1) {
|
|
2673
|
+
return {
|
|
2674
|
+
name: splitInfo[0],
|
|
2675
|
+
version: void 0
|
|
2676
|
+
};
|
|
2677
|
+
} else if (splitInfo.length === 2) {
|
|
2678
|
+
return {
|
|
2679
|
+
name: splitInfo[0],
|
|
2680
|
+
version: splitInfo[1]
|
|
2681
|
+
};
|
|
2682
|
+
} else {
|
|
2683
|
+
return {
|
|
2684
|
+
name: splitInfo[1],
|
|
2685
|
+
version: splitInfo[2]
|
|
2686
|
+
};
|
|
2687
|
+
}
|
|
2688
|
+
}
|
|
2689
|
+
function traverseModuleInfo(globalSnapshot, remoteInfo, traverse, isRoot, memo = {}, remoteSnapshot) {
|
|
2690
|
+
const id = getFMId(remoteInfo);
|
|
2691
|
+
const { value: snapshotValue } = getInfoWithoutType(globalSnapshot, id);
|
|
2692
|
+
const effectiveRemoteSnapshot = remoteSnapshot || snapshotValue;
|
|
2693
|
+
if (effectiveRemoteSnapshot && !sdk.isManifestProvider(effectiveRemoteSnapshot)) {
|
|
2694
|
+
traverse(effectiveRemoteSnapshot, remoteInfo, isRoot);
|
|
2695
|
+
if (effectiveRemoteSnapshot.remotesInfo) {
|
|
2696
|
+
const remoteKeys = Object.keys(effectiveRemoteSnapshot.remotesInfo);
|
|
2697
|
+
for (const key of remoteKeys) {
|
|
2698
|
+
if (memo[key]) {
|
|
2699
|
+
continue;
|
|
2700
|
+
}
|
|
2701
|
+
memo[key] = true;
|
|
2702
|
+
const subRemoteInfo = splitId(key);
|
|
2703
|
+
const remoteValue = effectiveRemoteSnapshot.remotesInfo[key];
|
|
2704
|
+
traverseModuleInfo(globalSnapshot, {
|
|
2705
|
+
name: subRemoteInfo.name,
|
|
2706
|
+
version: remoteValue.matchedVersion
|
|
2707
|
+
}, traverse, false, memo, void 0);
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
var isExisted = (type, url2) => {
|
|
2713
|
+
return document.querySelector(`${type}[${type === "link" ? "href" : "src"}="${url2}"]`);
|
|
2714
|
+
};
|
|
2715
|
+
function generatePreloadAssets(origin, preloadOptions, remote, globalSnapshot, remoteSnapshot) {
|
|
2716
|
+
const cssAssets = [];
|
|
2717
|
+
const jsAssets = [];
|
|
2718
|
+
const entryAssets = [];
|
|
2719
|
+
const loadedSharedJsAssets = /* @__PURE__ */ new Set();
|
|
2720
|
+
const loadedSharedCssAssets = /* @__PURE__ */ new Set();
|
|
2721
|
+
const { options } = origin;
|
|
2722
|
+
const { preloadConfig: rootPreloadConfig } = preloadOptions;
|
|
2723
|
+
const { depsRemote } = rootPreloadConfig;
|
|
2724
|
+
const memo = {};
|
|
2725
|
+
traverseModuleInfo(globalSnapshot, remote, (moduleInfoSnapshot, remoteInfo, isRoot) => {
|
|
2726
|
+
let preloadConfig;
|
|
2727
|
+
if (isRoot) {
|
|
2728
|
+
preloadConfig = rootPreloadConfig;
|
|
2729
|
+
} else {
|
|
2730
|
+
if (Array.isArray(depsRemote)) {
|
|
2731
|
+
const findPreloadConfig = depsRemote.find((remoteConfig) => {
|
|
2732
|
+
if (remoteConfig.nameOrAlias === remoteInfo.name || remoteConfig.nameOrAlias === remoteInfo.alias) {
|
|
2733
|
+
return true;
|
|
2734
|
+
}
|
|
2735
|
+
return false;
|
|
2736
|
+
});
|
|
2737
|
+
if (!findPreloadConfig) {
|
|
2738
|
+
return;
|
|
2739
|
+
}
|
|
2740
|
+
preloadConfig = defaultPreloadArgs(findPreloadConfig);
|
|
2741
|
+
} else if (depsRemote === true) {
|
|
2742
|
+
preloadConfig = rootPreloadConfig;
|
|
2743
|
+
} else {
|
|
2744
|
+
return;
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2747
|
+
const remoteEntryUrl = sdk.getResourceUrl(moduleInfoSnapshot, getRemoteEntryInfoFromSnapshot(moduleInfoSnapshot).url);
|
|
2748
|
+
if (remoteEntryUrl) {
|
|
2749
|
+
entryAssets.push({
|
|
2750
|
+
name: remoteInfo.name,
|
|
2751
|
+
moduleInfo: {
|
|
2752
|
+
name: remoteInfo.name,
|
|
2753
|
+
entry: remoteEntryUrl,
|
|
2754
|
+
type: "remoteEntryType" in moduleInfoSnapshot ? moduleInfoSnapshot.remoteEntryType : "global",
|
|
2755
|
+
entryGlobalName: "globalName" in moduleInfoSnapshot ? moduleInfoSnapshot.globalName : remoteInfo.name,
|
|
2756
|
+
shareScope: "",
|
|
2757
|
+
version: "version" in moduleInfoSnapshot ? moduleInfoSnapshot.version : void 0
|
|
2758
|
+
},
|
|
2759
|
+
url: remoteEntryUrl
|
|
2760
|
+
});
|
|
2761
|
+
}
|
|
2762
|
+
let moduleAssetsInfo = "modules" in moduleInfoSnapshot ? moduleInfoSnapshot.modules : [];
|
|
2763
|
+
const normalizedPreloadExposes = normalizePreloadExposes(preloadConfig.exposes);
|
|
2764
|
+
if (normalizedPreloadExposes.length && "modules" in moduleInfoSnapshot) {
|
|
2765
|
+
moduleAssetsInfo = moduleInfoSnapshot?.modules?.reduce((assets, moduleAssetInfo) => {
|
|
2766
|
+
if (normalizedPreloadExposes?.indexOf(moduleAssetInfo.moduleName) !== -1) {
|
|
2767
|
+
assets.push(moduleAssetInfo);
|
|
2768
|
+
}
|
|
2769
|
+
return assets;
|
|
2770
|
+
}, []);
|
|
2771
|
+
}
|
|
2772
|
+
function handleAssets(assets) {
|
|
2773
|
+
const assetsRes = assets.map((asset) => sdk.getResourceUrl(moduleInfoSnapshot, asset));
|
|
2774
|
+
if (preloadConfig.filter) {
|
|
2775
|
+
return assetsRes.filter(preloadConfig.filter);
|
|
2776
|
+
}
|
|
2777
|
+
return assetsRes;
|
|
2778
|
+
}
|
|
2779
|
+
if (moduleAssetsInfo) {
|
|
2780
|
+
const assetsLength = moduleAssetsInfo.length;
|
|
2781
|
+
for (let index2 = 0; index2 < assetsLength; index2++) {
|
|
2782
|
+
const assetsInfo = moduleAssetsInfo[index2];
|
|
2783
|
+
const exposeFullPath = `${remoteInfo.name}/${assetsInfo.moduleName}`;
|
|
2784
|
+
origin.remoteHandler.hooks.lifecycle.handlePreloadModule.emit({
|
|
2785
|
+
id: assetsInfo.moduleName === "." ? remoteInfo.name : exposeFullPath,
|
|
2786
|
+
name: remoteInfo.name,
|
|
2787
|
+
remoteSnapshot: moduleInfoSnapshot,
|
|
2788
|
+
preloadConfig,
|
|
2789
|
+
remote: remoteInfo,
|
|
2790
|
+
origin
|
|
2791
|
+
});
|
|
2792
|
+
const preloaded = getPreloaded(exposeFullPath);
|
|
2793
|
+
if (preloaded) {
|
|
2794
|
+
continue;
|
|
2795
|
+
}
|
|
2796
|
+
if (preloadConfig.resourceCategory === "all") {
|
|
2797
|
+
cssAssets.push(...handleAssets(assetsInfo.assets.css.async));
|
|
2798
|
+
cssAssets.push(...handleAssets(assetsInfo.assets.css.sync));
|
|
2799
|
+
jsAssets.push(...handleAssets(assetsInfo.assets.js.async));
|
|
2800
|
+
jsAssets.push(...handleAssets(assetsInfo.assets.js.sync));
|
|
2801
|
+
} else if (preloadConfig.resourceCategory = "sync") {
|
|
2802
|
+
cssAssets.push(...handleAssets(assetsInfo.assets.css.sync));
|
|
2803
|
+
jsAssets.push(...handleAssets(assetsInfo.assets.js.sync));
|
|
2804
|
+
}
|
|
2805
|
+
setPreloaded(exposeFullPath);
|
|
2806
|
+
}
|
|
2807
|
+
}
|
|
2808
|
+
}, true, memo, remoteSnapshot);
|
|
2809
|
+
if (remoteSnapshot.shared && remoteSnapshot.shared.length > 0) {
|
|
2810
|
+
const collectSharedAssets = (shareInfo, snapshotShared) => {
|
|
2811
|
+
const registeredShared = getRegisteredShare(origin.shareScopeMap, snapshotShared.sharedName, shareInfo, origin.sharedHandler.hooks.lifecycle.resolveShare);
|
|
2812
|
+
if (registeredShared && typeof registeredShared.lib === "function") {
|
|
2813
|
+
snapshotShared.assets.js.sync.forEach((asset) => {
|
|
2814
|
+
loadedSharedJsAssets.add(asset);
|
|
2815
|
+
});
|
|
2816
|
+
snapshotShared.assets.css.sync.forEach((asset) => {
|
|
2817
|
+
loadedSharedCssAssets.add(asset);
|
|
2818
|
+
});
|
|
2819
|
+
}
|
|
2820
|
+
};
|
|
2821
|
+
remoteSnapshot.shared.forEach((shared) => {
|
|
2822
|
+
const shareInfos = options.shared?.[shared.sharedName];
|
|
2823
|
+
if (!shareInfos) {
|
|
2824
|
+
return;
|
|
2825
|
+
}
|
|
2826
|
+
const sharedOptions = shared.version ? shareInfos.find((s4) => s4.version === shared.version) : shareInfos;
|
|
2827
|
+
if (!sharedOptions) {
|
|
2828
|
+
return;
|
|
2829
|
+
}
|
|
2830
|
+
const arrayShareInfo = arrayOptions(sharedOptions);
|
|
2831
|
+
arrayShareInfo.forEach((s4) => {
|
|
2832
|
+
collectSharedAssets(s4, shared);
|
|
2833
|
+
});
|
|
2834
|
+
});
|
|
2835
|
+
}
|
|
2836
|
+
const needPreloadJsAssets = jsAssets.filter((asset) => !loadedSharedJsAssets.has(asset) && !isExisted("script", asset));
|
|
2837
|
+
const needPreloadCssAssets = cssAssets.filter((asset) => !loadedSharedCssAssets.has(asset) && !isExisted("link", asset));
|
|
2838
|
+
return {
|
|
2839
|
+
cssAssets: needPreloadCssAssets,
|
|
2840
|
+
jsAssetsWithoutEntry: needPreloadJsAssets,
|
|
2841
|
+
entryAssets: entryAssets.filter((entry) => !isExisted("script", entry.url))
|
|
2842
|
+
};
|
|
2843
|
+
}
|
|
2844
|
+
var generatePreloadAssetsPlugin = function() {
|
|
2845
|
+
return {
|
|
2846
|
+
name: "generate-preload-assets-plugin",
|
|
2847
|
+
async generatePreloadAssets(args) {
|
|
2848
|
+
const { origin, preloadOptions, remoteInfo, remote, globalSnapshot, remoteSnapshot } = args;
|
|
2849
|
+
if (!sdk.isBrowserEnv()) {
|
|
2850
|
+
return {
|
|
2851
|
+
cssAssets: [],
|
|
2852
|
+
jsAssetsWithoutEntry: [],
|
|
2853
|
+
entryAssets: []
|
|
2854
|
+
};
|
|
2855
|
+
}
|
|
2856
|
+
if (isRemoteInfoWithEntry(remote) && isPureRemoteEntry(remote)) {
|
|
2857
|
+
return {
|
|
2858
|
+
cssAssets: [],
|
|
2859
|
+
jsAssetsWithoutEntry: [],
|
|
2860
|
+
entryAssets: [
|
|
2861
|
+
{
|
|
2862
|
+
name: remote.name,
|
|
2863
|
+
url: remote.entry,
|
|
2864
|
+
moduleInfo: {
|
|
2865
|
+
name: remoteInfo.name,
|
|
2866
|
+
entry: remote.entry,
|
|
2867
|
+
type: remoteInfo.type || "global",
|
|
2868
|
+
entryGlobalName: "",
|
|
2869
|
+
shareScope: ""
|
|
2870
|
+
}
|
|
2871
|
+
}
|
|
2872
|
+
]
|
|
2873
|
+
};
|
|
2874
|
+
}
|
|
2875
|
+
assignRemoteInfo(remoteInfo, remoteSnapshot);
|
|
2876
|
+
const assets = generatePreloadAssets(origin, preloadOptions, remoteInfo, globalSnapshot, remoteSnapshot);
|
|
2877
|
+
return assets;
|
|
2878
|
+
}
|
|
2879
|
+
};
|
|
2880
|
+
};
|
|
2881
|
+
function getGlobalRemoteInfo(moduleInfo, origin) {
|
|
2882
|
+
const hostGlobalSnapshot = getGlobalSnapshotInfoByModuleInfo({
|
|
2883
|
+
name: origin.name,
|
|
2884
|
+
version: origin.options.version
|
|
2885
|
+
});
|
|
2886
|
+
const globalRemoteInfo = hostGlobalSnapshot && "remotesInfo" in hostGlobalSnapshot && hostGlobalSnapshot.remotesInfo && getInfoWithoutType(hostGlobalSnapshot.remotesInfo, moduleInfo.name).value;
|
|
2887
|
+
if (globalRemoteInfo && globalRemoteInfo.matchedVersion) {
|
|
2888
|
+
return {
|
|
2889
|
+
hostGlobalSnapshot,
|
|
2890
|
+
globalSnapshot: getGlobalSnapshot(),
|
|
2891
|
+
remoteSnapshot: getGlobalSnapshotInfoByModuleInfo({
|
|
2892
|
+
name: moduleInfo.name,
|
|
2893
|
+
version: globalRemoteInfo.matchedVersion
|
|
2894
|
+
})
|
|
2895
|
+
};
|
|
2896
|
+
}
|
|
2897
|
+
return {
|
|
2898
|
+
hostGlobalSnapshot: void 0,
|
|
2899
|
+
globalSnapshot: getGlobalSnapshot(),
|
|
2900
|
+
remoteSnapshot: getGlobalSnapshotInfoByModuleInfo({
|
|
2901
|
+
name: moduleInfo.name,
|
|
2902
|
+
version: "version" in moduleInfo ? moduleInfo.version : void 0
|
|
2903
|
+
})
|
|
2904
|
+
};
|
|
2905
|
+
}
|
|
2906
|
+
var SnapshotHandler = class {
|
|
2907
|
+
constructor(HostInstance) {
|
|
2908
|
+
this.loadingHostSnapshot = null;
|
|
2909
|
+
this.manifestCache = /* @__PURE__ */ new Map();
|
|
2910
|
+
this.hooks = new PluginSystem({
|
|
2911
|
+
beforeLoadRemoteSnapshot: new AsyncHook("beforeLoadRemoteSnapshot"),
|
|
2912
|
+
loadSnapshot: new AsyncWaterfallHook("loadGlobalSnapshot"),
|
|
2913
|
+
loadRemoteSnapshot: new AsyncWaterfallHook("loadRemoteSnapshot"),
|
|
2914
|
+
afterLoadSnapshot: new AsyncWaterfallHook("afterLoadSnapshot")
|
|
2915
|
+
});
|
|
2916
|
+
this.manifestLoading = Global.__FEDERATION__.__MANIFEST_LOADING__;
|
|
2917
|
+
this.HostInstance = HostInstance;
|
|
2918
|
+
this.loaderHook = HostInstance.loaderHook;
|
|
2919
|
+
}
|
|
2920
|
+
// eslint-disable-next-line max-lines-per-function
|
|
2921
|
+
async loadRemoteSnapshotInfo({ moduleInfo, id, expose }) {
|
|
2922
|
+
const { options } = this.HostInstance;
|
|
2923
|
+
await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({
|
|
2924
|
+
options,
|
|
2925
|
+
moduleInfo
|
|
2926
|
+
});
|
|
2927
|
+
let hostSnapshot = getGlobalSnapshotInfoByModuleInfo({
|
|
2928
|
+
name: this.HostInstance.options.name,
|
|
2929
|
+
version: this.HostInstance.options.version
|
|
2930
|
+
});
|
|
2931
|
+
if (!hostSnapshot) {
|
|
2932
|
+
hostSnapshot = {
|
|
2933
|
+
version: this.HostInstance.options.version || "",
|
|
2934
|
+
remoteEntry: "",
|
|
2935
|
+
remotesInfo: {}
|
|
2936
|
+
};
|
|
2937
|
+
addGlobalSnapshot({
|
|
2938
|
+
[this.HostInstance.options.name]: hostSnapshot
|
|
2939
|
+
});
|
|
2940
|
+
}
|
|
2941
|
+
if (hostSnapshot && "remotesInfo" in hostSnapshot && !getInfoWithoutType(hostSnapshot.remotesInfo, moduleInfo.name).value) {
|
|
2942
|
+
if ("version" in moduleInfo || "entry" in moduleInfo) {
|
|
2943
|
+
hostSnapshot.remotesInfo = {
|
|
2944
|
+
...hostSnapshot?.remotesInfo,
|
|
2945
|
+
[moduleInfo.name]: {
|
|
2946
|
+
matchedVersion: "version" in moduleInfo ? moduleInfo.version : moduleInfo.entry
|
|
2947
|
+
}
|
|
2948
|
+
};
|
|
2949
|
+
}
|
|
2950
|
+
}
|
|
2951
|
+
const { hostGlobalSnapshot, remoteSnapshot, globalSnapshot } = this.getGlobalRemoteInfo(moduleInfo);
|
|
2952
|
+
const { remoteSnapshot: globalRemoteSnapshot, globalSnapshot: globalSnapshotRes } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
2953
|
+
options,
|
|
2954
|
+
moduleInfo,
|
|
2955
|
+
hostGlobalSnapshot,
|
|
2956
|
+
remoteSnapshot,
|
|
2957
|
+
globalSnapshot
|
|
2958
|
+
});
|
|
2959
|
+
let mSnapshot;
|
|
2960
|
+
let gSnapshot;
|
|
2961
|
+
if (globalRemoteSnapshot) {
|
|
2962
|
+
if (sdk.isManifestProvider(globalRemoteSnapshot)) {
|
|
2963
|
+
const remoteEntry = sdk.isBrowserEnv() ? globalRemoteSnapshot.remoteEntry : globalRemoteSnapshot.ssrRemoteEntry || globalRemoteSnapshot.remoteEntry || "";
|
|
2964
|
+
const moduleSnapshot = await this.getManifestJson(remoteEntry, moduleInfo, {});
|
|
2965
|
+
const globalSnapshotRes2 = setGlobalSnapshotInfoByModuleInfo({
|
|
2966
|
+
...moduleInfo,
|
|
2967
|
+
// The global remote may be overridden
|
|
2968
|
+
// Therefore, set the snapshot key to the global address of the actual request
|
|
2969
|
+
entry: remoteEntry
|
|
2970
|
+
}, moduleSnapshot);
|
|
2971
|
+
mSnapshot = moduleSnapshot;
|
|
2972
|
+
gSnapshot = globalSnapshotRes2;
|
|
2973
|
+
} else {
|
|
2974
|
+
const { remoteSnapshot: remoteSnapshotRes } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
2975
|
+
options: this.HostInstance.options,
|
|
2976
|
+
moduleInfo,
|
|
2977
|
+
remoteSnapshot: globalRemoteSnapshot,
|
|
2978
|
+
from: "global"
|
|
2979
|
+
});
|
|
2980
|
+
mSnapshot = remoteSnapshotRes;
|
|
2981
|
+
gSnapshot = globalSnapshotRes;
|
|
2982
|
+
}
|
|
2983
|
+
} else {
|
|
2984
|
+
if (isRemoteInfoWithEntry(moduleInfo)) {
|
|
2985
|
+
const moduleSnapshot = await this.getManifestJson(moduleInfo.entry, moduleInfo, {});
|
|
2986
|
+
const globalSnapshotRes2 = setGlobalSnapshotInfoByModuleInfo(moduleInfo, moduleSnapshot);
|
|
2987
|
+
const { remoteSnapshot: remoteSnapshotRes } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
2988
|
+
options: this.HostInstance.options,
|
|
2989
|
+
moduleInfo,
|
|
2990
|
+
remoteSnapshot: moduleSnapshot,
|
|
2991
|
+
from: "global"
|
|
2992
|
+
});
|
|
2993
|
+
mSnapshot = remoteSnapshotRes;
|
|
2994
|
+
gSnapshot = globalSnapshotRes2;
|
|
2995
|
+
} else {
|
|
2996
|
+
error2(errorCodes.getShortErrorMsg(errorCodes.RUNTIME_007, errorCodes.runtimeDescMap, {
|
|
2997
|
+
hostName: moduleInfo.name,
|
|
2998
|
+
hostVersion: moduleInfo.version,
|
|
2999
|
+
globalSnapshot: JSON.stringify(globalSnapshotRes)
|
|
3000
|
+
}));
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
await this.hooks.lifecycle.afterLoadSnapshot.emit({
|
|
3004
|
+
id,
|
|
3005
|
+
host: this.HostInstance,
|
|
3006
|
+
options,
|
|
3007
|
+
moduleInfo,
|
|
3008
|
+
remoteSnapshot: mSnapshot
|
|
3009
|
+
});
|
|
3010
|
+
return {
|
|
3011
|
+
remoteSnapshot: mSnapshot,
|
|
3012
|
+
globalSnapshot: gSnapshot
|
|
3013
|
+
};
|
|
3014
|
+
}
|
|
3015
|
+
getGlobalRemoteInfo(moduleInfo) {
|
|
3016
|
+
return getGlobalRemoteInfo(moduleInfo, this.HostInstance);
|
|
3017
|
+
}
|
|
3018
|
+
async getManifestJson(manifestUrl, moduleInfo, extraOptions) {
|
|
3019
|
+
const getManifest = async () => {
|
|
3020
|
+
let manifestJson = this.manifestCache.get(manifestUrl);
|
|
3021
|
+
if (manifestJson) {
|
|
3022
|
+
return manifestJson;
|
|
3023
|
+
}
|
|
3024
|
+
try {
|
|
3025
|
+
let res2 = await this.loaderHook.lifecycle.fetch.emit(manifestUrl, {});
|
|
3026
|
+
if (!res2 || !(res2 instanceof Response)) {
|
|
3027
|
+
res2 = await fetch(manifestUrl, {});
|
|
3028
|
+
}
|
|
3029
|
+
manifestJson = await res2.json();
|
|
3030
|
+
} catch (err) {
|
|
3031
|
+
manifestJson = await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
3032
|
+
id: manifestUrl,
|
|
3033
|
+
error: err,
|
|
3034
|
+
from: "runtime",
|
|
3035
|
+
lifecycle: "afterResolve",
|
|
3036
|
+
origin: this.HostInstance
|
|
3037
|
+
});
|
|
3038
|
+
if (!manifestJson) {
|
|
3039
|
+
delete this.manifestLoading[manifestUrl];
|
|
3040
|
+
error2(errorCodes.getShortErrorMsg(errorCodes.RUNTIME_003, errorCodes.runtimeDescMap, {
|
|
3041
|
+
manifestUrl,
|
|
3042
|
+
moduleName: moduleInfo.name,
|
|
3043
|
+
hostName: this.HostInstance.options.name
|
|
3044
|
+
}, `${err}`));
|
|
3045
|
+
}
|
|
3046
|
+
}
|
|
3047
|
+
assert2(manifestJson.metaData && manifestJson.exposes && manifestJson.shared, `${manifestUrl} is not a federation manifest`);
|
|
3048
|
+
this.manifestCache.set(manifestUrl, manifestJson);
|
|
3049
|
+
return manifestJson;
|
|
3050
|
+
};
|
|
3051
|
+
const asyncLoadProcess = async () => {
|
|
3052
|
+
const manifestJson = await getManifest();
|
|
3053
|
+
const remoteSnapshot = sdk.generateSnapshotFromManifest(manifestJson, {
|
|
3054
|
+
version: manifestUrl
|
|
3055
|
+
});
|
|
3056
|
+
const { remoteSnapshot: remoteSnapshotRes } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
3057
|
+
options: this.HostInstance.options,
|
|
3058
|
+
moduleInfo,
|
|
3059
|
+
manifestJson,
|
|
3060
|
+
remoteSnapshot,
|
|
3061
|
+
manifestUrl,
|
|
3062
|
+
from: "manifest"
|
|
3063
|
+
});
|
|
3064
|
+
return remoteSnapshotRes;
|
|
3065
|
+
};
|
|
3066
|
+
if (!this.manifestLoading[manifestUrl]) {
|
|
3067
|
+
this.manifestLoading[manifestUrl] = asyncLoadProcess().then((res2) => res2);
|
|
3068
|
+
}
|
|
3069
|
+
return this.manifestLoading[manifestUrl];
|
|
3070
|
+
}
|
|
3071
|
+
};
|
|
3072
|
+
var SharedHandler = class {
|
|
3073
|
+
constructor(host) {
|
|
3074
|
+
this.hooks = new PluginSystem({
|
|
3075
|
+
afterResolve: new AsyncWaterfallHook("afterResolve"),
|
|
3076
|
+
beforeLoadShare: new AsyncWaterfallHook("beforeLoadShare"),
|
|
3077
|
+
// not used yet
|
|
3078
|
+
loadShare: new AsyncHook(),
|
|
3079
|
+
resolveShare: new SyncWaterfallHook("resolveShare"),
|
|
3080
|
+
// maybe will change, temporarily for internal use only
|
|
3081
|
+
initContainerShareScopeMap: new SyncWaterfallHook("initContainerShareScopeMap")
|
|
3082
|
+
});
|
|
3083
|
+
this.host = host;
|
|
3084
|
+
this.shareScopeMap = {};
|
|
3085
|
+
this.initTokens = {};
|
|
3086
|
+
this._setGlobalShareScopeMap(host.options);
|
|
3087
|
+
}
|
|
3088
|
+
// register shared in shareScopeMap
|
|
3089
|
+
registerShared(globalOptions, userOptions) {
|
|
3090
|
+
const { shareInfos, shared } = formatShareConfigs(globalOptions, userOptions);
|
|
3091
|
+
const sharedKeys = Object.keys(shareInfos);
|
|
3092
|
+
sharedKeys.forEach((sharedKey) => {
|
|
3093
|
+
const sharedVals = shareInfos[sharedKey];
|
|
3094
|
+
sharedVals.forEach((sharedVal) => {
|
|
3095
|
+
sharedVal.scope.forEach((sc) => {
|
|
3096
|
+
const registeredShared = this.shareScopeMap[sc]?.[sharedKey];
|
|
3097
|
+
if (!registeredShared) {
|
|
3098
|
+
this.setShared({
|
|
3099
|
+
pkgName: sharedKey,
|
|
3100
|
+
lib: sharedVal.lib,
|
|
3101
|
+
get: sharedVal.get,
|
|
3102
|
+
loaded: sharedVal.loaded || Boolean(sharedVal.lib),
|
|
3103
|
+
shared: sharedVal,
|
|
3104
|
+
from: userOptions.name
|
|
3105
|
+
});
|
|
3106
|
+
}
|
|
3107
|
+
});
|
|
3108
|
+
});
|
|
3109
|
+
});
|
|
3110
|
+
return {
|
|
3111
|
+
shareInfos,
|
|
3112
|
+
shared
|
|
3113
|
+
};
|
|
3114
|
+
}
|
|
3115
|
+
async loadShare(pkgName, extraOptions) {
|
|
3116
|
+
const { host } = this;
|
|
3117
|
+
const shareOptions = getTargetSharedOptions({
|
|
3118
|
+
pkgName,
|
|
3119
|
+
extraOptions,
|
|
3120
|
+
shareInfos: host.options.shared
|
|
3121
|
+
});
|
|
3122
|
+
if (shareOptions?.scope) {
|
|
3123
|
+
await Promise.all(shareOptions.scope.map(async (shareScope) => {
|
|
3124
|
+
await Promise.all(this.initializeSharing(shareScope, {
|
|
3125
|
+
strategy: shareOptions.strategy
|
|
3126
|
+
}));
|
|
3127
|
+
return;
|
|
3128
|
+
}));
|
|
3129
|
+
}
|
|
3130
|
+
const loadShareRes = await this.hooks.lifecycle.beforeLoadShare.emit({
|
|
3131
|
+
pkgName,
|
|
3132
|
+
shareInfo: shareOptions,
|
|
3133
|
+
shared: host.options.shared,
|
|
3134
|
+
origin: host
|
|
3135
|
+
});
|
|
3136
|
+
const { shareInfo: shareOptionsRes } = loadShareRes;
|
|
3137
|
+
assert2(shareOptionsRes, `Cannot find ${pkgName} Share in the ${host.options.name}. Please ensure that the ${pkgName} Share parameters have been injected`);
|
|
3138
|
+
const registeredShared = getRegisteredShare(this.shareScopeMap, pkgName, shareOptionsRes, this.hooks.lifecycle.resolveShare);
|
|
3139
|
+
const addUseIn = (shared) => {
|
|
3140
|
+
if (!shared.useIn) {
|
|
3141
|
+
shared.useIn = [];
|
|
3142
|
+
}
|
|
3143
|
+
addUniqueItem(shared.useIn, host.options.name);
|
|
3144
|
+
};
|
|
3145
|
+
if (registeredShared && registeredShared.lib) {
|
|
3146
|
+
addUseIn(registeredShared);
|
|
3147
|
+
return registeredShared.lib;
|
|
3148
|
+
} else if (registeredShared && registeredShared.loading && !registeredShared.loaded) {
|
|
3149
|
+
const factory = await registeredShared.loading;
|
|
3150
|
+
registeredShared.loaded = true;
|
|
3151
|
+
if (!registeredShared.lib) {
|
|
3152
|
+
registeredShared.lib = factory;
|
|
3153
|
+
}
|
|
3154
|
+
addUseIn(registeredShared);
|
|
3155
|
+
return factory;
|
|
3156
|
+
} else if (registeredShared) {
|
|
3157
|
+
const asyncLoadProcess = async () => {
|
|
3158
|
+
const factory = await registeredShared.get();
|
|
3159
|
+
addUseIn(registeredShared);
|
|
3160
|
+
registeredShared.loaded = true;
|
|
3161
|
+
registeredShared.lib = factory;
|
|
3162
|
+
return factory;
|
|
3163
|
+
};
|
|
3164
|
+
const loading = asyncLoadProcess();
|
|
3165
|
+
this.setShared({
|
|
3166
|
+
pkgName,
|
|
3167
|
+
loaded: false,
|
|
3168
|
+
shared: registeredShared,
|
|
3169
|
+
from: host.options.name,
|
|
3170
|
+
lib: null,
|
|
3171
|
+
loading
|
|
3172
|
+
});
|
|
3173
|
+
return loading;
|
|
3174
|
+
} else {
|
|
3175
|
+
if (extraOptions?.customShareInfo) {
|
|
3176
|
+
return false;
|
|
3177
|
+
}
|
|
3178
|
+
const asyncLoadProcess = async () => {
|
|
3179
|
+
const factory = await shareOptionsRes.get();
|
|
3180
|
+
shareOptionsRes.lib = factory;
|
|
3181
|
+
shareOptionsRes.loaded = true;
|
|
3182
|
+
addUseIn(shareOptionsRes);
|
|
3183
|
+
const gShared = getRegisteredShare(this.shareScopeMap, pkgName, shareOptionsRes, this.hooks.lifecycle.resolveShare);
|
|
3184
|
+
if (gShared) {
|
|
3185
|
+
gShared.lib = factory;
|
|
3186
|
+
gShared.loaded = true;
|
|
3187
|
+
gShared.from = shareOptionsRes.from;
|
|
3188
|
+
}
|
|
3189
|
+
return factory;
|
|
3190
|
+
};
|
|
3191
|
+
const loading = asyncLoadProcess();
|
|
3192
|
+
this.setShared({
|
|
3193
|
+
pkgName,
|
|
3194
|
+
loaded: false,
|
|
3195
|
+
shared: shareOptionsRes,
|
|
3196
|
+
from: host.options.name,
|
|
3197
|
+
lib: null,
|
|
3198
|
+
loading
|
|
3199
|
+
});
|
|
3200
|
+
return loading;
|
|
3201
|
+
}
|
|
3202
|
+
}
|
|
3203
|
+
/**
|
|
3204
|
+
* This function initializes the sharing sequence (executed only once per share scope).
|
|
3205
|
+
* It accepts one argument, the name of the share scope.
|
|
3206
|
+
* If the share scope does not exist, it creates one.
|
|
3207
|
+
*/
|
|
3208
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
3209
|
+
initializeSharing(shareScopeName = DEFAULT_SCOPE, extraOptions) {
|
|
3210
|
+
const { host } = this;
|
|
3211
|
+
const from = extraOptions?.from;
|
|
3212
|
+
const strategy = extraOptions?.strategy;
|
|
3213
|
+
let initScope = extraOptions?.initScope;
|
|
3214
|
+
const promises = [];
|
|
3215
|
+
if (from !== "build") {
|
|
3216
|
+
const { initTokens } = this;
|
|
3217
|
+
if (!initScope)
|
|
3218
|
+
initScope = [];
|
|
3219
|
+
let initToken = initTokens[shareScopeName];
|
|
3220
|
+
if (!initToken)
|
|
3221
|
+
initToken = initTokens[shareScopeName] = { from: this.host.name };
|
|
3222
|
+
if (initScope.indexOf(initToken) >= 0)
|
|
3223
|
+
return promises;
|
|
3224
|
+
initScope.push(initToken);
|
|
3225
|
+
}
|
|
3226
|
+
const shareScope = this.shareScopeMap;
|
|
3227
|
+
const hostName = host.options.name;
|
|
3228
|
+
if (!shareScope[shareScopeName]) {
|
|
3229
|
+
shareScope[shareScopeName] = {};
|
|
3230
|
+
}
|
|
3231
|
+
const scope = shareScope[shareScopeName];
|
|
3232
|
+
const register = (name, shared) => {
|
|
3233
|
+
const { version: version2, eager } = shared;
|
|
3234
|
+
scope[name] = scope[name] || {};
|
|
3235
|
+
const versions = scope[name];
|
|
3236
|
+
const activeVersion = versions[version2];
|
|
3237
|
+
const activeVersionEager = Boolean(activeVersion && (activeVersion.eager || activeVersion.shareConfig?.eager));
|
|
3238
|
+
if (!activeVersion || activeVersion.strategy !== "loaded-first" && !activeVersion.loaded && (Boolean(!eager) !== !activeVersionEager ? eager : hostName > activeVersion.from)) {
|
|
3239
|
+
versions[version2] = shared;
|
|
3240
|
+
}
|
|
3241
|
+
};
|
|
3242
|
+
const initFn = (mod) => mod && mod.init && mod.init(shareScope[shareScopeName], initScope);
|
|
3243
|
+
const initRemoteModule = async (key) => {
|
|
3244
|
+
const { module: module3 } = await host.remoteHandler.getRemoteModuleAndOptions({
|
|
3245
|
+
id: key
|
|
3246
|
+
});
|
|
3247
|
+
if (module3.getEntry) {
|
|
3248
|
+
let remoteEntryExports;
|
|
3249
|
+
try {
|
|
3250
|
+
remoteEntryExports = await module3.getEntry();
|
|
3251
|
+
} catch (error3) {
|
|
3252
|
+
remoteEntryExports = await host.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
3253
|
+
id: key,
|
|
3254
|
+
error: error3,
|
|
3255
|
+
from: "runtime",
|
|
3256
|
+
lifecycle: "beforeLoadShare",
|
|
3257
|
+
origin: host
|
|
3258
|
+
});
|
|
3259
|
+
}
|
|
3260
|
+
if (!module3.inited) {
|
|
3261
|
+
await initFn(remoteEntryExports);
|
|
3262
|
+
module3.inited = true;
|
|
3263
|
+
}
|
|
3264
|
+
}
|
|
3265
|
+
};
|
|
3266
|
+
Object.keys(host.options.shared).forEach((shareName) => {
|
|
3267
|
+
const sharedArr = host.options.shared[shareName];
|
|
3268
|
+
sharedArr.forEach((shared) => {
|
|
3269
|
+
if (shared.scope.includes(shareScopeName)) {
|
|
3270
|
+
register(shareName, shared);
|
|
3271
|
+
}
|
|
3272
|
+
});
|
|
3273
|
+
});
|
|
3274
|
+
if (host.options.shareStrategy === "version-first" || strategy === "version-first") {
|
|
3275
|
+
host.options.remotes.forEach((remote) => {
|
|
3276
|
+
if (remote.shareScope === shareScopeName) {
|
|
3277
|
+
promises.push(initRemoteModule(remote.name));
|
|
3278
|
+
}
|
|
3279
|
+
});
|
|
3280
|
+
}
|
|
3281
|
+
return promises;
|
|
3282
|
+
}
|
|
3283
|
+
// The lib function will only be available if the shared set by eager or runtime init is set or the shared is successfully loaded.
|
|
3284
|
+
// 1. If the loaded shared already exists globally, then it will be reused
|
|
3285
|
+
// 2. If lib exists in local shared, it will be used directly
|
|
3286
|
+
// 3. If the local get returns something other than Promise, then it will be used directly
|
|
3287
|
+
loadShareSync(pkgName, extraOptions) {
|
|
3288
|
+
const { host } = this;
|
|
3289
|
+
const shareOptions = getTargetSharedOptions({
|
|
3290
|
+
pkgName,
|
|
3291
|
+
extraOptions,
|
|
3292
|
+
shareInfos: host.options.shared
|
|
3293
|
+
});
|
|
3294
|
+
if (shareOptions?.scope) {
|
|
3295
|
+
shareOptions.scope.forEach((shareScope) => {
|
|
3296
|
+
this.initializeSharing(shareScope, { strategy: shareOptions.strategy });
|
|
3297
|
+
});
|
|
3298
|
+
}
|
|
3299
|
+
const registeredShared = getRegisteredShare(this.shareScopeMap, pkgName, shareOptions, this.hooks.lifecycle.resolveShare);
|
|
3300
|
+
const addUseIn = (shared) => {
|
|
3301
|
+
if (!shared.useIn) {
|
|
3302
|
+
shared.useIn = [];
|
|
3303
|
+
}
|
|
3304
|
+
addUniqueItem(shared.useIn, host.options.name);
|
|
3305
|
+
};
|
|
3306
|
+
if (registeredShared) {
|
|
3307
|
+
if (typeof registeredShared.lib === "function") {
|
|
3308
|
+
addUseIn(registeredShared);
|
|
3309
|
+
if (!registeredShared.loaded) {
|
|
3310
|
+
registeredShared.loaded = true;
|
|
3311
|
+
if (registeredShared.from === host.options.name) {
|
|
3312
|
+
shareOptions.loaded = true;
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
return registeredShared.lib;
|
|
3316
|
+
}
|
|
3317
|
+
if (typeof registeredShared.get === "function") {
|
|
3318
|
+
const module3 = registeredShared.get();
|
|
3319
|
+
if (!(module3 instanceof Promise)) {
|
|
3320
|
+
addUseIn(registeredShared);
|
|
3321
|
+
this.setShared({
|
|
3322
|
+
pkgName,
|
|
3323
|
+
loaded: true,
|
|
3324
|
+
from: host.options.name,
|
|
3325
|
+
lib: module3,
|
|
3326
|
+
shared: registeredShared
|
|
3327
|
+
});
|
|
3328
|
+
return module3;
|
|
3329
|
+
}
|
|
3330
|
+
}
|
|
3331
|
+
}
|
|
3332
|
+
if (shareOptions.lib) {
|
|
3333
|
+
if (!shareOptions.loaded) {
|
|
3334
|
+
shareOptions.loaded = true;
|
|
3335
|
+
}
|
|
3336
|
+
return shareOptions.lib;
|
|
3337
|
+
}
|
|
3338
|
+
if (shareOptions.get) {
|
|
3339
|
+
const module3 = shareOptions.get();
|
|
3340
|
+
if (module3 instanceof Promise) {
|
|
3341
|
+
const errorCode = extraOptions?.from === "build" ? errorCodes.RUNTIME_005 : errorCodes.RUNTIME_006;
|
|
3342
|
+
throw new Error(errorCodes.getShortErrorMsg(errorCode, errorCodes.runtimeDescMap, {
|
|
3343
|
+
hostName: host.options.name,
|
|
3344
|
+
sharedPkgName: pkgName
|
|
3345
|
+
}));
|
|
3346
|
+
}
|
|
3347
|
+
shareOptions.lib = module3;
|
|
3348
|
+
this.setShared({
|
|
3349
|
+
pkgName,
|
|
3350
|
+
loaded: true,
|
|
3351
|
+
from: host.options.name,
|
|
3352
|
+
lib: shareOptions.lib,
|
|
3353
|
+
shared: shareOptions
|
|
3354
|
+
});
|
|
3355
|
+
return shareOptions.lib;
|
|
3356
|
+
}
|
|
3357
|
+
throw new Error(errorCodes.getShortErrorMsg(errorCodes.RUNTIME_006, errorCodes.runtimeDescMap, {
|
|
3358
|
+
hostName: host.options.name,
|
|
3359
|
+
sharedPkgName: pkgName
|
|
3360
|
+
}));
|
|
3361
|
+
}
|
|
3362
|
+
initShareScopeMap(scopeName, shareScope, extraOptions = {}) {
|
|
3363
|
+
const { host } = this;
|
|
3364
|
+
this.shareScopeMap[scopeName] = shareScope;
|
|
3365
|
+
this.hooks.lifecycle.initContainerShareScopeMap.emit({
|
|
3366
|
+
shareScope,
|
|
3367
|
+
options: host.options,
|
|
3368
|
+
origin: host,
|
|
3369
|
+
scopeName,
|
|
3370
|
+
hostShareScopeMap: extraOptions.hostShareScopeMap
|
|
3371
|
+
});
|
|
3372
|
+
}
|
|
3373
|
+
setShared({ pkgName, shared, from, lib, loading, loaded, get }) {
|
|
3374
|
+
const { version: version2, scope = "default", ...shareInfo } = shared;
|
|
3375
|
+
const scopes = Array.isArray(scope) ? scope : [scope];
|
|
3376
|
+
scopes.forEach((sc) => {
|
|
3377
|
+
if (!this.shareScopeMap[sc]) {
|
|
3378
|
+
this.shareScopeMap[sc] = {};
|
|
3379
|
+
}
|
|
3380
|
+
if (!this.shareScopeMap[sc][pkgName]) {
|
|
3381
|
+
this.shareScopeMap[sc][pkgName] = {};
|
|
3382
|
+
}
|
|
3383
|
+
if (!this.shareScopeMap[sc][pkgName][version2]) {
|
|
3384
|
+
this.shareScopeMap[sc][pkgName][version2] = {
|
|
3385
|
+
version: version2,
|
|
3386
|
+
scope: [sc],
|
|
3387
|
+
...shareInfo,
|
|
3388
|
+
lib,
|
|
3389
|
+
loaded,
|
|
3390
|
+
loading
|
|
3391
|
+
};
|
|
3392
|
+
if (get) {
|
|
3393
|
+
this.shareScopeMap[sc][pkgName][version2].get = get;
|
|
3394
|
+
}
|
|
3395
|
+
return;
|
|
3396
|
+
}
|
|
3397
|
+
const registeredShared = this.shareScopeMap[sc][pkgName][version2];
|
|
3398
|
+
if (loading && !registeredShared.loading) {
|
|
3399
|
+
registeredShared.loading = loading;
|
|
3400
|
+
}
|
|
3401
|
+
if (loaded && !registeredShared.loaded) {
|
|
3402
|
+
registeredShared.loaded = loaded;
|
|
3403
|
+
}
|
|
3404
|
+
if (from && registeredShared.from !== from) {
|
|
3405
|
+
registeredShared.from = from;
|
|
3406
|
+
}
|
|
3407
|
+
});
|
|
3408
|
+
}
|
|
3409
|
+
_setGlobalShareScopeMap(hostOptions) {
|
|
3410
|
+
const globalShareScopeMap = getGlobalShareScope();
|
|
3411
|
+
const identifier = hostOptions.id || hostOptions.name;
|
|
3412
|
+
if (identifier && !globalShareScopeMap[identifier]) {
|
|
3413
|
+
globalShareScopeMap[identifier] = this.shareScopeMap;
|
|
3414
|
+
}
|
|
3415
|
+
}
|
|
3416
|
+
};
|
|
3417
|
+
var RemoteHandler = class {
|
|
3418
|
+
constructor(host) {
|
|
3419
|
+
this.hooks = new PluginSystem({
|
|
3420
|
+
beforeRegisterRemote: new SyncWaterfallHook("beforeRegisterRemote"),
|
|
3421
|
+
registerRemote: new SyncWaterfallHook("registerRemote"),
|
|
3422
|
+
beforeRequest: new AsyncWaterfallHook("beforeRequest"),
|
|
3423
|
+
onLoad: new AsyncHook("onLoad"),
|
|
3424
|
+
handlePreloadModule: new SyncHook("handlePreloadModule"),
|
|
3425
|
+
errorLoadRemote: new AsyncHook("errorLoadRemote"),
|
|
3426
|
+
beforePreloadRemote: new AsyncHook("beforePreloadRemote"),
|
|
3427
|
+
generatePreloadAssets: new AsyncHook("generatePreloadAssets"),
|
|
3428
|
+
// not used yet
|
|
3429
|
+
afterPreloadRemote: new AsyncHook(),
|
|
3430
|
+
loadEntry: new AsyncHook()
|
|
3431
|
+
});
|
|
3432
|
+
this.host = host;
|
|
3433
|
+
this.idToRemoteMap = {};
|
|
3434
|
+
}
|
|
3435
|
+
formatAndRegisterRemote(globalOptions, userOptions) {
|
|
3436
|
+
const userRemotes = userOptions.remotes || [];
|
|
3437
|
+
return userRemotes.reduce((res2, remote) => {
|
|
3438
|
+
this.registerRemote(remote, res2, { force: false });
|
|
3439
|
+
return res2;
|
|
3440
|
+
}, globalOptions.remotes);
|
|
3441
|
+
}
|
|
3442
|
+
setIdToRemoteMap(id, remoteMatchInfo) {
|
|
3443
|
+
const { remote, expose } = remoteMatchInfo;
|
|
3444
|
+
const { name, alias } = remote;
|
|
3445
|
+
this.idToRemoteMap[id] = { name: remote.name, expose };
|
|
3446
|
+
if (alias && id.startsWith(name)) {
|
|
3447
|
+
const idWithAlias = id.replace(name, alias);
|
|
3448
|
+
this.idToRemoteMap[idWithAlias] = { name: remote.name, expose };
|
|
3449
|
+
return;
|
|
3450
|
+
}
|
|
3451
|
+
if (alias && id.startsWith(alias)) {
|
|
3452
|
+
const idWithName = id.replace(alias, name);
|
|
3453
|
+
this.idToRemoteMap[idWithName] = { name: remote.name, expose };
|
|
3454
|
+
}
|
|
3455
|
+
}
|
|
3456
|
+
// eslint-disable-next-line max-lines-per-function
|
|
3457
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
3458
|
+
async loadRemote(id, options) {
|
|
3459
|
+
const { host } = this;
|
|
3460
|
+
try {
|
|
3461
|
+
const { loadFactory = true } = options || {
|
|
3462
|
+
loadFactory: true
|
|
3463
|
+
};
|
|
3464
|
+
const { module: module3, moduleOptions, remoteMatchInfo } = await this.getRemoteModuleAndOptions({
|
|
3465
|
+
id
|
|
3466
|
+
});
|
|
3467
|
+
const { pkgNameOrAlias, remote, expose, id: idRes, remoteSnapshot } = remoteMatchInfo;
|
|
3468
|
+
const moduleOrFactory = await module3.get(idRes, expose, options, remoteSnapshot);
|
|
3469
|
+
const moduleWrapper = await this.hooks.lifecycle.onLoad.emit({
|
|
3470
|
+
id: idRes,
|
|
3471
|
+
pkgNameOrAlias,
|
|
3472
|
+
expose,
|
|
3473
|
+
exposeModule: loadFactory ? moduleOrFactory : void 0,
|
|
3474
|
+
exposeModuleFactory: loadFactory ? void 0 : moduleOrFactory,
|
|
3475
|
+
remote,
|
|
3476
|
+
options: moduleOptions,
|
|
3477
|
+
moduleInstance: module3,
|
|
3478
|
+
origin: host
|
|
3479
|
+
});
|
|
3480
|
+
this.setIdToRemoteMap(id, remoteMatchInfo);
|
|
3481
|
+
if (typeof moduleWrapper === "function") {
|
|
3482
|
+
return moduleWrapper;
|
|
3483
|
+
}
|
|
3484
|
+
return moduleOrFactory;
|
|
3485
|
+
} catch (error3) {
|
|
3486
|
+
const { from = "runtime" } = options || { from: "runtime" };
|
|
3487
|
+
const failOver = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
3488
|
+
id,
|
|
3489
|
+
error: error3,
|
|
3490
|
+
from,
|
|
3491
|
+
lifecycle: "onLoad",
|
|
3492
|
+
origin: host
|
|
3493
|
+
});
|
|
3494
|
+
if (!failOver) {
|
|
3495
|
+
throw error3;
|
|
3496
|
+
}
|
|
3497
|
+
return failOver;
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3500
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
3501
|
+
async preloadRemote(preloadOptions) {
|
|
3502
|
+
const { host } = this;
|
|
3503
|
+
await this.hooks.lifecycle.beforePreloadRemote.emit({
|
|
3504
|
+
preloadOps: preloadOptions,
|
|
3505
|
+
options: host.options,
|
|
3506
|
+
origin: host
|
|
3507
|
+
});
|
|
3508
|
+
const preloadOps = formatPreloadArgs(host.options.remotes, preloadOptions);
|
|
3509
|
+
await Promise.all(preloadOps.map(async (ops) => {
|
|
3510
|
+
const { remote } = ops;
|
|
3511
|
+
const remoteInfo = getRemoteInfo(remote);
|
|
3512
|
+
const { globalSnapshot, remoteSnapshot } = await host.snapshotHandler.loadRemoteSnapshotInfo({
|
|
3513
|
+
moduleInfo: remote
|
|
3514
|
+
});
|
|
3515
|
+
const assets = await this.hooks.lifecycle.generatePreloadAssets.emit({
|
|
3516
|
+
origin: host,
|
|
3517
|
+
preloadOptions: ops,
|
|
3518
|
+
remote,
|
|
3519
|
+
remoteInfo,
|
|
3520
|
+
globalSnapshot,
|
|
3521
|
+
remoteSnapshot
|
|
3522
|
+
});
|
|
3523
|
+
if (!assets) {
|
|
3524
|
+
return;
|
|
3525
|
+
}
|
|
3526
|
+
preloadAssets(remoteInfo, host, assets);
|
|
3527
|
+
}));
|
|
3528
|
+
}
|
|
3529
|
+
registerRemotes(remotes, options) {
|
|
3530
|
+
const { host } = this;
|
|
3531
|
+
remotes.forEach((remote) => {
|
|
3532
|
+
this.registerRemote(remote, host.options.remotes, {
|
|
3533
|
+
force: options?.force
|
|
3534
|
+
});
|
|
3535
|
+
});
|
|
3536
|
+
}
|
|
3537
|
+
async getRemoteModuleAndOptions(options) {
|
|
3538
|
+
const { host } = this;
|
|
3539
|
+
const { id } = options;
|
|
3540
|
+
let loadRemoteArgs;
|
|
3541
|
+
try {
|
|
3542
|
+
loadRemoteArgs = await this.hooks.lifecycle.beforeRequest.emit({
|
|
3543
|
+
id,
|
|
3544
|
+
options: host.options,
|
|
3545
|
+
origin: host
|
|
3546
|
+
});
|
|
3547
|
+
} catch (error3) {
|
|
3548
|
+
loadRemoteArgs = await this.hooks.lifecycle.errorLoadRemote.emit({
|
|
3549
|
+
id,
|
|
3550
|
+
options: host.options,
|
|
3551
|
+
origin: host,
|
|
3552
|
+
from: "runtime",
|
|
3553
|
+
error: error3,
|
|
3554
|
+
lifecycle: "beforeRequest"
|
|
3555
|
+
});
|
|
3556
|
+
if (!loadRemoteArgs) {
|
|
3557
|
+
throw error3;
|
|
3558
|
+
}
|
|
3559
|
+
}
|
|
3560
|
+
const { id: idRes } = loadRemoteArgs;
|
|
3561
|
+
const remoteSplitInfo = matchRemoteWithNameAndExpose(host.options.remotes, idRes);
|
|
3562
|
+
assert2(remoteSplitInfo, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_004, errorCodes.runtimeDescMap, {
|
|
3563
|
+
hostName: host.options.name,
|
|
3564
|
+
requestId: idRes
|
|
3565
|
+
}));
|
|
3566
|
+
const { remote: rawRemote } = remoteSplitInfo;
|
|
3567
|
+
const remoteInfo = getRemoteInfo(rawRemote);
|
|
3568
|
+
const matchInfo = await host.sharedHandler.hooks.lifecycle.afterResolve.emit({
|
|
3569
|
+
id: idRes,
|
|
3570
|
+
...remoteSplitInfo,
|
|
3571
|
+
options: host.options,
|
|
3572
|
+
origin: host,
|
|
3573
|
+
remoteInfo
|
|
3574
|
+
});
|
|
3575
|
+
const { remote, expose } = matchInfo;
|
|
3576
|
+
assert2(remote && expose, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${idRes}.`);
|
|
3577
|
+
let module3 = host.moduleCache.get(remote.name);
|
|
3578
|
+
const moduleOptions = {
|
|
3579
|
+
host,
|
|
3580
|
+
remoteInfo
|
|
3581
|
+
};
|
|
3582
|
+
if (!module3) {
|
|
3583
|
+
module3 = new Module(moduleOptions);
|
|
3584
|
+
host.moduleCache.set(remote.name, module3);
|
|
3585
|
+
}
|
|
3586
|
+
return {
|
|
3587
|
+
module: module3,
|
|
3588
|
+
moduleOptions,
|
|
3589
|
+
remoteMatchInfo: matchInfo
|
|
3590
|
+
};
|
|
3591
|
+
}
|
|
3592
|
+
registerRemote(remote, targetRemotes, options) {
|
|
3593
|
+
const { host } = this;
|
|
3594
|
+
const normalizeRemote = () => {
|
|
3595
|
+
if (remote.alias) {
|
|
3596
|
+
const findEqual = targetRemotes.find((item) => remote.alias && (item.name.startsWith(remote.alias) || item.alias?.startsWith(remote.alias)));
|
|
3597
|
+
assert2(!findEqual, `The alias ${remote.alias} of remote ${remote.name} is not allowed to be the prefix of ${findEqual && findEqual.name} name or alias`);
|
|
3598
|
+
}
|
|
3599
|
+
if ("entry" in remote) {
|
|
3600
|
+
if (sdk.isBrowserEnv() && !remote.entry.startsWith("http")) {
|
|
3601
|
+
remote.entry = new URL(remote.entry, window.location.origin).href;
|
|
3602
|
+
}
|
|
3603
|
+
}
|
|
3604
|
+
if (!remote.shareScope) {
|
|
3605
|
+
remote.shareScope = DEFAULT_SCOPE;
|
|
3606
|
+
}
|
|
3607
|
+
if (!remote.type) {
|
|
3608
|
+
remote.type = DEFAULT_REMOTE_TYPE;
|
|
3609
|
+
}
|
|
3610
|
+
};
|
|
3611
|
+
this.hooks.lifecycle.beforeRegisterRemote.emit({ remote, origin: host });
|
|
3612
|
+
const registeredRemote = targetRemotes.find((item) => item.name === remote.name);
|
|
3613
|
+
if (!registeredRemote) {
|
|
3614
|
+
normalizeRemote();
|
|
3615
|
+
targetRemotes.push(remote);
|
|
3616
|
+
this.hooks.lifecycle.registerRemote.emit({ remote, origin: host });
|
|
3617
|
+
} else {
|
|
3618
|
+
const messages = [
|
|
3619
|
+
`The remote "${remote.name}" is already registered.`,
|
|
3620
|
+
"Please note that overriding it may cause unexpected errors."
|
|
3621
|
+
];
|
|
3622
|
+
if (options?.force) {
|
|
3623
|
+
this.removeRemote(registeredRemote);
|
|
3624
|
+
normalizeRemote();
|
|
3625
|
+
targetRemotes.push(remote);
|
|
3626
|
+
this.hooks.lifecycle.registerRemote.emit({ remote, origin: host });
|
|
3627
|
+
sdk.warn(messages.join(" "));
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3630
|
+
}
|
|
3631
|
+
removeRemote(remote) {
|
|
3632
|
+
try {
|
|
3633
|
+
const { host } = this;
|
|
3634
|
+
const { name } = remote;
|
|
3635
|
+
const remoteIndex = host.options.remotes.findIndex((item) => item.name === name);
|
|
3636
|
+
if (remoteIndex !== -1) {
|
|
3637
|
+
host.options.remotes.splice(remoteIndex, 1);
|
|
3638
|
+
}
|
|
3639
|
+
const loadedModule = host.moduleCache.get(remote.name);
|
|
3640
|
+
if (loadedModule) {
|
|
3641
|
+
const remoteInfo = loadedModule.remoteInfo;
|
|
3642
|
+
const key = remoteInfo.entryGlobalName;
|
|
3643
|
+
if (CurrentGlobal[key]) {
|
|
3644
|
+
if (Object.getOwnPropertyDescriptor(CurrentGlobal, key)?.configurable) {
|
|
3645
|
+
delete CurrentGlobal[key];
|
|
3646
|
+
} else {
|
|
3647
|
+
CurrentGlobal[key] = void 0;
|
|
3648
|
+
}
|
|
3649
|
+
}
|
|
3650
|
+
const remoteEntryUniqueKey = getRemoteEntryUniqueKey(loadedModule.remoteInfo);
|
|
3651
|
+
if (globalLoading[remoteEntryUniqueKey]) {
|
|
3652
|
+
delete globalLoading[remoteEntryUniqueKey];
|
|
3653
|
+
}
|
|
3654
|
+
host.snapshotHandler.manifestCache.delete(remoteInfo.entry);
|
|
3655
|
+
let remoteInsId = remoteInfo.buildVersion ? sdk.composeKeyWithSeparator(remoteInfo.name, remoteInfo.buildVersion) : remoteInfo.name;
|
|
3656
|
+
const remoteInsIndex = CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex((ins) => {
|
|
3657
|
+
if (remoteInfo.buildVersion) {
|
|
3658
|
+
return ins.options.id === remoteInsId;
|
|
3659
|
+
} else {
|
|
3660
|
+
return ins.name === remoteInsId;
|
|
3661
|
+
}
|
|
3662
|
+
});
|
|
3663
|
+
if (remoteInsIndex !== -1) {
|
|
3664
|
+
const remoteIns = CurrentGlobal.__FEDERATION__.__INSTANCES__[remoteInsIndex];
|
|
3665
|
+
remoteInsId = remoteIns.options.id || remoteInsId;
|
|
3666
|
+
const globalShareScopeMap = getGlobalShareScope();
|
|
3667
|
+
let isAllSharedNotUsed = true;
|
|
3668
|
+
const needDeleteKeys = [];
|
|
3669
|
+
Object.keys(globalShareScopeMap).forEach((instId) => {
|
|
3670
|
+
const shareScopeMap = globalShareScopeMap[instId];
|
|
3671
|
+
shareScopeMap && Object.keys(shareScopeMap).forEach((shareScope) => {
|
|
3672
|
+
const shareScopeVal = shareScopeMap[shareScope];
|
|
3673
|
+
shareScopeVal && Object.keys(shareScopeVal).forEach((shareName) => {
|
|
3674
|
+
const sharedPkgs = shareScopeVal[shareName];
|
|
3675
|
+
sharedPkgs && Object.keys(sharedPkgs).forEach((shareVersion) => {
|
|
3676
|
+
const shared = sharedPkgs[shareVersion];
|
|
3677
|
+
if (shared && typeof shared === "object" && shared.from === remoteInfo.name) {
|
|
3678
|
+
if (shared.loaded || shared.loading) {
|
|
3679
|
+
shared.useIn = shared.useIn.filter((usedHostName) => usedHostName !== remoteInfo.name);
|
|
3680
|
+
if (shared.useIn.length) {
|
|
3681
|
+
isAllSharedNotUsed = false;
|
|
3682
|
+
} else {
|
|
3683
|
+
needDeleteKeys.push([
|
|
3684
|
+
instId,
|
|
3685
|
+
shareScope,
|
|
3686
|
+
shareName,
|
|
3687
|
+
shareVersion
|
|
3688
|
+
]);
|
|
3689
|
+
}
|
|
3690
|
+
} else {
|
|
3691
|
+
needDeleteKeys.push([
|
|
3692
|
+
instId,
|
|
3693
|
+
shareScope,
|
|
3694
|
+
shareName,
|
|
3695
|
+
shareVersion
|
|
3696
|
+
]);
|
|
3697
|
+
}
|
|
3698
|
+
}
|
|
3699
|
+
});
|
|
3700
|
+
});
|
|
3701
|
+
});
|
|
3702
|
+
});
|
|
3703
|
+
if (isAllSharedNotUsed) {
|
|
3704
|
+
remoteIns.shareScopeMap = {};
|
|
3705
|
+
delete globalShareScopeMap[remoteInsId];
|
|
3706
|
+
}
|
|
3707
|
+
needDeleteKeys.forEach(([insId, shareScope, shareName, shareVersion]) => {
|
|
3708
|
+
delete globalShareScopeMap[insId]?.[shareScope]?.[shareName]?.[shareVersion];
|
|
3709
|
+
});
|
|
3710
|
+
CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(remoteInsIndex, 1);
|
|
3711
|
+
}
|
|
3712
|
+
const { hostGlobalSnapshot } = getGlobalRemoteInfo(remote, host);
|
|
3713
|
+
if (hostGlobalSnapshot) {
|
|
3714
|
+
const remoteKey = hostGlobalSnapshot && "remotesInfo" in hostGlobalSnapshot && hostGlobalSnapshot.remotesInfo && getInfoWithoutType(hostGlobalSnapshot.remotesInfo, remote.name).key;
|
|
3715
|
+
if (remoteKey) {
|
|
3716
|
+
delete hostGlobalSnapshot.remotesInfo[remoteKey];
|
|
3717
|
+
if (
|
|
3718
|
+
//eslint-disable-next-line no-extra-boolean-cast
|
|
3719
|
+
Boolean(Global.__FEDERATION__.__MANIFEST_LOADING__[remoteKey])
|
|
3720
|
+
) {
|
|
3721
|
+
delete Global.__FEDERATION__.__MANIFEST_LOADING__[remoteKey];
|
|
3722
|
+
}
|
|
3723
|
+
}
|
|
3724
|
+
}
|
|
3725
|
+
host.moduleCache.delete(remote.name);
|
|
3726
|
+
}
|
|
3727
|
+
} catch (err) {
|
|
3728
|
+
logger2.log("removeRemote fail: ", err);
|
|
3729
|
+
}
|
|
3730
|
+
}
|
|
3731
|
+
};
|
|
3732
|
+
var USE_SNAPSHOT = typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN === "boolean" ? !FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN : true;
|
|
3733
|
+
var ModuleFederation = class {
|
|
3734
|
+
constructor(userOptions) {
|
|
3735
|
+
this.hooks = new PluginSystem({
|
|
3736
|
+
beforeInit: new SyncWaterfallHook("beforeInit"),
|
|
3737
|
+
init: new SyncHook(),
|
|
3738
|
+
// maybe will change, temporarily for internal use only
|
|
3739
|
+
beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
|
|
3740
|
+
// maybe will change, temporarily for internal use only
|
|
3741
|
+
initContainer: new AsyncWaterfallHook("initContainer")
|
|
3742
|
+
});
|
|
3743
|
+
this.version = "0.21.6";
|
|
3744
|
+
this.moduleCache = /* @__PURE__ */ new Map();
|
|
3745
|
+
this.loaderHook = new PluginSystem({
|
|
3746
|
+
// FIXME: may not be suitable , not open to the public yet
|
|
3747
|
+
getModuleInfo: new SyncHook(),
|
|
3748
|
+
createScript: new SyncHook(),
|
|
3749
|
+
createLink: new SyncHook(),
|
|
3750
|
+
fetch: new AsyncHook(),
|
|
3751
|
+
loadEntryError: new AsyncHook(),
|
|
3752
|
+
getModuleFactory: new AsyncHook()
|
|
3753
|
+
});
|
|
3754
|
+
this.bridgeHook = new PluginSystem({
|
|
3755
|
+
beforeBridgeRender: new SyncHook(),
|
|
3756
|
+
afterBridgeRender: new SyncHook(),
|
|
3757
|
+
beforeBridgeDestroy: new SyncHook(),
|
|
3758
|
+
afterBridgeDestroy: new SyncHook()
|
|
3759
|
+
});
|
|
3760
|
+
const plugins = USE_SNAPSHOT ? [snapshotPlugin(), generatePreloadAssetsPlugin()] : [];
|
|
3761
|
+
const defaultOptions = {
|
|
3762
|
+
id: getBuilderId(),
|
|
3763
|
+
name: userOptions.name,
|
|
3764
|
+
plugins,
|
|
3765
|
+
remotes: [],
|
|
3766
|
+
shared: {},
|
|
3767
|
+
inBrowser: sdk.isBrowserEnv()
|
|
3768
|
+
};
|
|
3769
|
+
this.name = userOptions.name;
|
|
3770
|
+
this.options = defaultOptions;
|
|
3771
|
+
this.snapshotHandler = new SnapshotHandler(this);
|
|
3772
|
+
this.sharedHandler = new SharedHandler(this);
|
|
3773
|
+
this.remoteHandler = new RemoteHandler(this);
|
|
3774
|
+
this.shareScopeMap = this.sharedHandler.shareScopeMap;
|
|
3775
|
+
this.registerPlugins([
|
|
3776
|
+
...defaultOptions.plugins,
|
|
3777
|
+
...userOptions.plugins || []
|
|
3778
|
+
]);
|
|
3779
|
+
this.options = this.formatOptions(defaultOptions, userOptions);
|
|
3780
|
+
}
|
|
3781
|
+
initOptions(userOptions) {
|
|
3782
|
+
this.registerPlugins(userOptions.plugins);
|
|
3783
|
+
const options = this.formatOptions(this.options, userOptions);
|
|
3784
|
+
this.options = options;
|
|
3785
|
+
return options;
|
|
3786
|
+
}
|
|
3787
|
+
async loadShare(pkgName, extraOptions) {
|
|
3788
|
+
return this.sharedHandler.loadShare(pkgName, extraOptions);
|
|
3789
|
+
}
|
|
3790
|
+
// The lib function will only be available if the shared set by eager or runtime init is set or the shared is successfully loaded.
|
|
3791
|
+
// 1. If the loaded shared already exists globally, then it will be reused
|
|
3792
|
+
// 2. If lib exists in local shared, it will be used directly
|
|
3793
|
+
// 3. If the local get returns something other than Promise, then it will be used directly
|
|
3794
|
+
loadShareSync(pkgName, extraOptions) {
|
|
3795
|
+
return this.sharedHandler.loadShareSync(pkgName, extraOptions);
|
|
3796
|
+
}
|
|
3797
|
+
initializeSharing(shareScopeName = DEFAULT_SCOPE, extraOptions) {
|
|
3798
|
+
return this.sharedHandler.initializeSharing(shareScopeName, extraOptions);
|
|
3799
|
+
}
|
|
3800
|
+
initRawContainer(name, url2, container) {
|
|
3801
|
+
const remoteInfo = getRemoteInfo({ name, entry: url2 });
|
|
3802
|
+
const module3 = new Module({ host: this, remoteInfo });
|
|
3803
|
+
module3.remoteEntryExports = container;
|
|
3804
|
+
this.moduleCache.set(name, module3);
|
|
3805
|
+
return module3;
|
|
3806
|
+
}
|
|
3807
|
+
// eslint-disable-next-line max-lines-per-function
|
|
3808
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
3809
|
+
async loadRemote(id, options) {
|
|
3810
|
+
return this.remoteHandler.loadRemote(id, options);
|
|
3811
|
+
}
|
|
3812
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
3813
|
+
async preloadRemote(preloadOptions) {
|
|
3814
|
+
return this.remoteHandler.preloadRemote(preloadOptions);
|
|
3815
|
+
}
|
|
3816
|
+
initShareScopeMap(scopeName, shareScope, extraOptions = {}) {
|
|
3817
|
+
this.sharedHandler.initShareScopeMap(scopeName, shareScope, extraOptions);
|
|
3818
|
+
}
|
|
3819
|
+
formatOptions(globalOptions, userOptions) {
|
|
3820
|
+
const { shared } = formatShareConfigs(globalOptions, userOptions);
|
|
3821
|
+
const { userOptions: userOptionsRes, options: globalOptionsRes } = this.hooks.lifecycle.beforeInit.emit({
|
|
3822
|
+
origin: this,
|
|
3823
|
+
userOptions,
|
|
3824
|
+
options: globalOptions,
|
|
3825
|
+
shareInfo: shared
|
|
3826
|
+
});
|
|
3827
|
+
const remotes = this.remoteHandler.formatAndRegisterRemote(globalOptionsRes, userOptionsRes);
|
|
3828
|
+
const { shared: handledShared } = this.sharedHandler.registerShared(globalOptionsRes, userOptionsRes);
|
|
3829
|
+
const plugins = [...globalOptionsRes.plugins];
|
|
3830
|
+
if (userOptionsRes.plugins) {
|
|
3831
|
+
userOptionsRes.plugins.forEach((plugin) => {
|
|
3832
|
+
if (!plugins.includes(plugin)) {
|
|
3833
|
+
plugins.push(plugin);
|
|
3834
|
+
}
|
|
3835
|
+
});
|
|
3836
|
+
}
|
|
3837
|
+
const optionsRes = {
|
|
3838
|
+
...globalOptions,
|
|
3839
|
+
...userOptions,
|
|
3840
|
+
plugins,
|
|
3841
|
+
remotes,
|
|
3842
|
+
shared: handledShared
|
|
3843
|
+
};
|
|
3844
|
+
this.hooks.lifecycle.init.emit({
|
|
3845
|
+
origin: this,
|
|
3846
|
+
options: optionsRes
|
|
3847
|
+
});
|
|
3848
|
+
return optionsRes;
|
|
3849
|
+
}
|
|
3850
|
+
registerPlugins(plugins) {
|
|
3851
|
+
const pluginRes = registerPlugins(plugins, this);
|
|
3852
|
+
this.options.plugins = this.options.plugins.reduce((res2, plugin) => {
|
|
3853
|
+
if (!plugin)
|
|
3854
|
+
return res2;
|
|
3855
|
+
if (res2 && !res2.find((item) => item.name === plugin.name)) {
|
|
3856
|
+
res2.push(plugin);
|
|
3857
|
+
}
|
|
3858
|
+
return res2;
|
|
3859
|
+
}, pluginRes || []);
|
|
3860
|
+
}
|
|
3861
|
+
registerRemotes(remotes, options) {
|
|
3862
|
+
return this.remoteHandler.registerRemotes(remotes, options);
|
|
3863
|
+
}
|
|
3864
|
+
registerShared(shared) {
|
|
3865
|
+
this.sharedHandler.registerShared(this.options, {
|
|
3866
|
+
...this.options,
|
|
3867
|
+
shared
|
|
3868
|
+
});
|
|
3869
|
+
}
|
|
3870
|
+
};
|
|
3871
|
+
var index = /* @__PURE__ */ Object.freeze({
|
|
3872
|
+
__proto__: null
|
|
3873
|
+
});
|
|
3874
|
+
exports2.loadScript = sdk.loadScript;
|
|
3875
|
+
exports2.loadScriptNode = sdk.loadScriptNode;
|
|
3876
|
+
exports2.CurrentGlobal = CurrentGlobal;
|
|
3877
|
+
exports2.Global = Global;
|
|
3878
|
+
exports2.Module = Module;
|
|
3879
|
+
exports2.ModuleFederation = ModuleFederation;
|
|
3880
|
+
exports2.addGlobalSnapshot = addGlobalSnapshot;
|
|
3881
|
+
exports2.assert = assert2;
|
|
3882
|
+
exports2.getGlobalFederationConstructor = getGlobalFederationConstructor;
|
|
3883
|
+
exports2.getGlobalSnapshot = getGlobalSnapshot;
|
|
3884
|
+
exports2.getInfoWithoutType = getInfoWithoutType;
|
|
3885
|
+
exports2.getRegisteredShare = getRegisteredShare;
|
|
3886
|
+
exports2.getRemoteEntry = getRemoteEntry;
|
|
3887
|
+
exports2.getRemoteInfo = getRemoteInfo;
|
|
3888
|
+
exports2.helpers = helpers;
|
|
3889
|
+
exports2.isStaticResourcesEqual = isStaticResourcesEqual2;
|
|
3890
|
+
exports2.matchRemoteWithNameAndExpose = matchRemoteWithNameAndExpose;
|
|
3891
|
+
exports2.registerGlobalPlugins = registerGlobalPlugins;
|
|
3892
|
+
exports2.resetFederationGlobalInfo = resetFederationGlobalInfo;
|
|
3893
|
+
exports2.safeWrapper = safeWrapper2;
|
|
3894
|
+
exports2.satisfy = satisfy;
|
|
3895
|
+
exports2.setGlobalFederationConstructor = setGlobalFederationConstructor;
|
|
3896
|
+
exports2.setGlobalFederationInstance = setGlobalFederationInstance;
|
|
3897
|
+
exports2.types = index;
|
|
3898
|
+
}
|
|
3899
|
+
});
|
|
3900
|
+
|
|
3901
|
+
// node_modules/@module-federation/runtime/dist/utils.cjs.cjs
|
|
3902
|
+
var require_utils_cjs = __commonJS({
|
|
3903
|
+
"node_modules/@module-federation/runtime/dist/utils.cjs.cjs"(exports2) {
|
|
3904
|
+
"use strict";
|
|
3905
|
+
var runtimeCore = require_index_cjs3();
|
|
3906
|
+
function getBuilderId() {
|
|
3907
|
+
return typeof FEDERATION_BUILD_IDENTIFIER !== "undefined" ? (
|
|
3908
|
+
//@ts-ignore
|
|
3909
|
+
FEDERATION_BUILD_IDENTIFIER
|
|
3910
|
+
) : "";
|
|
3911
|
+
}
|
|
3912
|
+
function getGlobalFederationInstance(name, version2) {
|
|
3913
|
+
const buildId = getBuilderId();
|
|
3914
|
+
return runtimeCore.CurrentGlobal.__FEDERATION__.__INSTANCES__.find((GMInstance) => {
|
|
3915
|
+
if (buildId && GMInstance.options.id === buildId) {
|
|
3916
|
+
return true;
|
|
3917
|
+
}
|
|
3918
|
+
if (GMInstance.options.name === name && !GMInstance.options.version && !version2) {
|
|
3919
|
+
return true;
|
|
3920
|
+
}
|
|
3921
|
+
if (GMInstance.options.name === name && version2 && GMInstance.options.version === version2) {
|
|
3922
|
+
return true;
|
|
3923
|
+
}
|
|
3924
|
+
return false;
|
|
3925
|
+
});
|
|
3926
|
+
}
|
|
3927
|
+
exports2.getGlobalFederationInstance = getGlobalFederationInstance;
|
|
3928
|
+
}
|
|
3929
|
+
});
|
|
3930
|
+
|
|
3931
|
+
// node_modules/@module-federation/runtime/dist/index.cjs.cjs
|
|
3932
|
+
var require_index_cjs4 = __commonJS({
|
|
3933
|
+
"node_modules/@module-federation/runtime/dist/index.cjs.cjs"(exports2) {
|
|
3934
|
+
"use strict";
|
|
3935
|
+
var runtimeCore = require_index_cjs3();
|
|
3936
|
+
var errorCodes = require_index_cjs2();
|
|
3937
|
+
var utils = require_utils_cjs();
|
|
3938
|
+
function createInstance2(options) {
|
|
3939
|
+
const ModuleFederationConstructor = runtimeCore.getGlobalFederationConstructor() || runtimeCore.ModuleFederation;
|
|
3940
|
+
const instance = new ModuleFederationConstructor(options);
|
|
3941
|
+
runtimeCore.setGlobalFederationInstance(instance);
|
|
3942
|
+
return instance;
|
|
3943
|
+
}
|
|
3944
|
+
var FederationInstance = null;
|
|
3945
|
+
function init(options) {
|
|
3946
|
+
const instance = utils.getGlobalFederationInstance(options.name, options.version);
|
|
3947
|
+
if (!instance) {
|
|
3948
|
+
FederationInstance = createInstance2(options);
|
|
3949
|
+
return FederationInstance;
|
|
3950
|
+
} else {
|
|
3951
|
+
instance.initOptions(options);
|
|
3952
|
+
if (!FederationInstance) {
|
|
3953
|
+
FederationInstance = instance;
|
|
3954
|
+
}
|
|
3955
|
+
return instance;
|
|
3956
|
+
}
|
|
3957
|
+
}
|
|
3958
|
+
function loadRemote(...args) {
|
|
3959
|
+
runtimeCore.assert(FederationInstance, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_009, errorCodes.runtimeDescMap));
|
|
3960
|
+
const loadRemote2 = FederationInstance.loadRemote;
|
|
3961
|
+
return loadRemote2.apply(FederationInstance, args);
|
|
3962
|
+
}
|
|
3963
|
+
function loadShare(...args) {
|
|
3964
|
+
runtimeCore.assert(FederationInstance, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_009, errorCodes.runtimeDescMap));
|
|
3965
|
+
const loadShare2 = FederationInstance.loadShare;
|
|
3966
|
+
return loadShare2.apply(FederationInstance, args);
|
|
3967
|
+
}
|
|
3968
|
+
function loadShareSync(...args) {
|
|
3969
|
+
runtimeCore.assert(FederationInstance, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_009, errorCodes.runtimeDescMap));
|
|
3970
|
+
const loadShareSync2 = FederationInstance.loadShareSync;
|
|
3971
|
+
return loadShareSync2.apply(FederationInstance, args);
|
|
3972
|
+
}
|
|
3973
|
+
function preloadRemote(...args) {
|
|
3974
|
+
runtimeCore.assert(FederationInstance, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_009, errorCodes.runtimeDescMap));
|
|
3975
|
+
return FederationInstance.preloadRemote.apply(FederationInstance, args);
|
|
3976
|
+
}
|
|
3977
|
+
function registerRemotes(...args) {
|
|
3978
|
+
runtimeCore.assert(FederationInstance, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_009, errorCodes.runtimeDescMap));
|
|
3979
|
+
return FederationInstance.registerRemotes.apply(FederationInstance, args);
|
|
3980
|
+
}
|
|
3981
|
+
function registerPlugins(...args) {
|
|
3982
|
+
runtimeCore.assert(FederationInstance, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_009, errorCodes.runtimeDescMap));
|
|
3983
|
+
return FederationInstance.registerPlugins.apply(FederationInstance, args);
|
|
3984
|
+
}
|
|
3985
|
+
function getInstance() {
|
|
3986
|
+
return FederationInstance;
|
|
3987
|
+
}
|
|
3988
|
+
function registerShared(...args) {
|
|
3989
|
+
runtimeCore.assert(FederationInstance, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_009, errorCodes.runtimeDescMap));
|
|
3990
|
+
return FederationInstance.registerShared.apply(FederationInstance, args);
|
|
3991
|
+
}
|
|
3992
|
+
runtimeCore.setGlobalFederationConstructor(runtimeCore.ModuleFederation);
|
|
3993
|
+
exports2.Module = runtimeCore.Module;
|
|
3994
|
+
exports2.ModuleFederation = runtimeCore.ModuleFederation;
|
|
3995
|
+
exports2.getRemoteEntry = runtimeCore.getRemoteEntry;
|
|
3996
|
+
exports2.getRemoteInfo = runtimeCore.getRemoteInfo;
|
|
3997
|
+
exports2.loadScript = runtimeCore.loadScript;
|
|
3998
|
+
exports2.loadScriptNode = runtimeCore.loadScriptNode;
|
|
3999
|
+
exports2.registerGlobalPlugins = runtimeCore.registerGlobalPlugins;
|
|
4000
|
+
exports2.createInstance = createInstance2;
|
|
4001
|
+
exports2.getInstance = getInstance;
|
|
4002
|
+
exports2.init = init;
|
|
4003
|
+
exports2.loadRemote = loadRemote;
|
|
4004
|
+
exports2.loadShare = loadShare;
|
|
4005
|
+
exports2.loadShareSync = loadShareSync;
|
|
4006
|
+
exports2.preloadRemote = preloadRemote;
|
|
4007
|
+
exports2.registerPlugins = registerPlugins;
|
|
4008
|
+
exports2.registerRemotes = registerRemotes;
|
|
4009
|
+
exports2.registerShared = registerShared;
|
|
4010
|
+
}
|
|
4011
|
+
});
|
|
4012
|
+
|
|
4013
|
+
// node_modules/@module-federation/runtime-tools/dist/runtime.cjs.cjs
|
|
4014
|
+
var require_runtime_cjs = __commonJS({
|
|
4015
|
+
"node_modules/@module-federation/runtime-tools/dist/runtime.cjs.cjs"(exports2) {
|
|
4016
|
+
"use strict";
|
|
4017
|
+
var runtime = require_index_cjs4();
|
|
4018
|
+
Object.prototype.hasOwnProperty.call(runtime, "__proto__") && !Object.prototype.hasOwnProperty.call(exports2, "__proto__") && Object.defineProperty(exports2, "__proto__", {
|
|
4019
|
+
enumerable: true,
|
|
4020
|
+
value: runtime["__proto__"]
|
|
4021
|
+
});
|
|
4022
|
+
Object.keys(runtime).forEach(function(k2) {
|
|
4023
|
+
if (k2 !== "default" && !Object.prototype.hasOwnProperty.call(exports2, k2)) exports2[k2] = runtime[k2];
|
|
4024
|
+
});
|
|
4025
|
+
}
|
|
4026
|
+
});
|
|
4027
|
+
|
|
4028
|
+
// node_modules/@module-federation/enhanced/dist/src/runtime.js
|
|
4029
|
+
var require_runtime = __commonJS({
|
|
4030
|
+
"node_modules/@module-federation/enhanced/dist/src/runtime.js"(exports2) {
|
|
4031
|
+
"use strict";
|
|
4032
|
+
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o7, m2, k2, k22) {
|
|
4033
|
+
if (k22 === void 0) k22 = k2;
|
|
4034
|
+
var desc = Object.getOwnPropertyDescriptor(m2, k2);
|
|
4035
|
+
if (!desc || ("get" in desc ? !m2.__esModule : desc.writable || desc.configurable)) {
|
|
4036
|
+
desc = { enumerable: true, get: function() {
|
|
4037
|
+
return m2[k2];
|
|
4038
|
+
} };
|
|
4039
|
+
}
|
|
4040
|
+
Object.defineProperty(o7, k22, desc);
|
|
4041
|
+
}) : (function(o7, m2, k2, k22) {
|
|
4042
|
+
if (k22 === void 0) k22 = k2;
|
|
4043
|
+
o7[k22] = m2[k2];
|
|
4044
|
+
}));
|
|
4045
|
+
var __exportStar = exports2 && exports2.__exportStar || function(m2, exports3) {
|
|
4046
|
+
for (var p3 in m2) if (p3 !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p3)) __createBinding(exports3, m2, p3);
|
|
4047
|
+
};
|
|
4048
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
4049
|
+
__exportStar(require_runtime_cjs(), exports2);
|
|
4050
|
+
}
|
|
4051
|
+
});
|
|
28
4052
|
|
|
29
4053
|
// libs/embed-libs/embed/src/index.ts
|
|
30
4054
|
var index_exports = {};
|
|
@@ -283,16 +4307,16 @@ var formatDashboardList = (dashboards, integrationId, user, dashboardComponent)
|
|
|
283
4307
|
return treatedDashboards;
|
|
284
4308
|
};
|
|
285
4309
|
var VERSION = "0.0.0-unknown-luzmo";
|
|
286
|
-
var sanitizeUrl = (
|
|
4310
|
+
var sanitizeUrl = (url2) => {
|
|
287
4311
|
const invalidPrototcolRegex = /^(%20|\s)*(javascript|data)/im;
|
|
288
4312
|
const ctrlCharactersRegex = /[^\u0020-\u007E]/gim;
|
|
289
4313
|
const urlSchemeRegex = /^([^:]+):/gm;
|
|
290
4314
|
const relativeFirstCharacters = /* @__PURE__ */ new Set([".", "/"]);
|
|
291
4315
|
const isRelativeUrlWithoutProtocol = (relativeUrl) => relativeFirstCharacters.has(relativeUrl[0]);
|
|
292
|
-
if (!
|
|
4316
|
+
if (!url2) {
|
|
293
4317
|
return "about:blank";
|
|
294
4318
|
}
|
|
295
|
-
const sanitizedUrl =
|
|
4319
|
+
const sanitizedUrl = url2.replaceAll(ctrlCharactersRegex, "").trim();
|
|
296
4320
|
if (isRelativeUrlWithoutProtocol(sanitizedUrl)) {
|
|
297
4321
|
return sanitizedUrl;
|
|
298
4322
|
}
|
|
@@ -426,15 +4450,15 @@ var getLoader = (dashboardComponent) => {
|
|
|
426
4450
|
};
|
|
427
4451
|
|
|
428
4452
|
// libs/embed-libs/shared-embed/src/lib/helpers/promise-dispatch.ts
|
|
429
|
-
function resolvePromise(dashboardComponent, requestId,
|
|
4453
|
+
function resolvePromise(dashboardComponent, requestId, data2) {
|
|
430
4454
|
if (dashboardComponent.promises[requestId]) {
|
|
431
|
-
dashboardComponent.promises[requestId].resolve(
|
|
4455
|
+
dashboardComponent.promises[requestId].resolve(data2);
|
|
432
4456
|
delete dashboardComponent.promises[requestId];
|
|
433
4457
|
}
|
|
434
4458
|
}
|
|
435
|
-
function rejectPromise(dashboardComponent, requestId,
|
|
4459
|
+
function rejectPromise(dashboardComponent, requestId, data2) {
|
|
436
4460
|
if (dashboardComponent.promises[requestId]) {
|
|
437
|
-
dashboardComponent.promises[requestId].reject(
|
|
4461
|
+
dashboardComponent.promises[requestId].reject(data2);
|
|
438
4462
|
delete dashboardComponent.promises[requestId];
|
|
439
4463
|
}
|
|
440
4464
|
}
|
|
@@ -677,22 +4701,22 @@ var getAccessibleDashboards = async (dashboardComponent) => {
|
|
|
677
4701
|
})
|
|
678
4702
|
}
|
|
679
4703
|
);
|
|
680
|
-
responsePromise.then((response) => response.json()).then((
|
|
681
|
-
if (!
|
|
4704
|
+
responsePromise.then((response) => response.json()).then((data2) => {
|
|
4705
|
+
if (!data2 || !data2.rows || data2.rows.length === 0 || !data2.rows[0].user) {
|
|
682
4706
|
reject("Authorization failed, please check authKey and authToken. If the problem persists, please contact support@luzmo.com.");
|
|
683
4707
|
} else {
|
|
684
|
-
|
|
4708
|
+
data2.rows[0].user.userGroups = data2.rows[0].user.groups.map(
|
|
685
4709
|
(group) => group.id
|
|
686
4710
|
);
|
|
687
|
-
delete
|
|
4711
|
+
delete data2.rows[0].user.groups;
|
|
688
4712
|
resolve({
|
|
689
|
-
integrationId:
|
|
690
|
-
user:
|
|
4713
|
+
integrationId: data2.rows[0].integration_id,
|
|
4714
|
+
user: data2.rows[0].user
|
|
691
4715
|
});
|
|
692
4716
|
}
|
|
693
4717
|
});
|
|
694
|
-
} catch (
|
|
695
|
-
reject(
|
|
4718
|
+
} catch (error2) {
|
|
4719
|
+
reject(error2);
|
|
696
4720
|
}
|
|
697
4721
|
})();
|
|
698
4722
|
});
|
|
@@ -731,20 +4755,20 @@ var getAccessibleDashboards = async (dashboardComponent) => {
|
|
|
731
4755
|
})
|
|
732
4756
|
}
|
|
733
4757
|
);
|
|
734
|
-
responsePromise.then((response) => response.json()).then((
|
|
735
|
-
const dashboardList =
|
|
736
|
-
|
|
4758
|
+
responsePromise.then((response) => response.json()).then((data2) => {
|
|
4759
|
+
const dashboardList = data2.rows.length > 0 ? formatDashboardList(
|
|
4760
|
+
data2.rows,
|
|
737
4761
|
authorizationData.integrationId,
|
|
738
4762
|
authorizationData.user,
|
|
739
4763
|
dashboardComponent
|
|
740
4764
|
) : [];
|
|
741
4765
|
resolve(dashboardList);
|
|
742
4766
|
});
|
|
743
|
-
}).catch((
|
|
744
|
-
reject(
|
|
4767
|
+
}).catch((error2) => {
|
|
4768
|
+
reject(error2);
|
|
745
4769
|
});
|
|
746
|
-
} catch (
|
|
747
|
-
reject(
|
|
4770
|
+
} catch (error2) {
|
|
4771
|
+
reject(error2);
|
|
748
4772
|
}
|
|
749
4773
|
})());
|
|
750
4774
|
}
|
|
@@ -1260,104 +5284,78 @@ var libraryTypeToWebComponentTypeMapping = {
|
|
|
1260
5284
|
var luzmoEmbedContainerClass = "luzmo-embed-container";
|
|
1261
5285
|
|
|
1262
5286
|
// libs/embed-libs/shared-embed/src/lib/helpers/remote-federation.ts
|
|
1263
|
-
var
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
if (!remote.inited) {
|
|
1284
|
-
remote.lib = window[remoteId];
|
|
1285
|
-
remote.lib.init(wrapShareModule(remote.from));
|
|
1286
|
-
remote.inited = true;
|
|
1287
|
-
}
|
|
1288
|
-
resolve(remote.lib);
|
|
1289
|
-
};
|
|
1290
|
-
return loadJS(remote.url, callback);
|
|
1291
|
-
});
|
|
1292
|
-
} else if (["esm", "systemjs"].includes(remote.format)) {
|
|
1293
|
-
return new Promise((resolve, reject) => {
|
|
1294
|
-
const getUrl = typeof remote.url === "function" ? remote.url : () => Promise.resolve(remote.url);
|
|
1295
|
-
getUrl().then((url) => {
|
|
1296
|
-
import(
|
|
1297
|
-
/* @vite-ignore */
|
|
1298
|
-
/* webpackIgnore: true */
|
|
1299
|
-
url
|
|
1300
|
-
).then((lib) => {
|
|
1301
|
-
if (!remote.inited) {
|
|
1302
|
-
const shareScope = wrapShareModule(remote.from);
|
|
1303
|
-
lib.init(shareScope);
|
|
1304
|
-
remote.lib = lib;
|
|
1305
|
-
remote.lib.init(shareScope);
|
|
1306
|
-
remote.inited = true;
|
|
1307
|
-
}
|
|
1308
|
-
resolve(remote.lib);
|
|
1309
|
-
}).catch(reject);
|
|
1310
|
-
});
|
|
1311
|
-
});
|
|
5287
|
+
var import_runtime = __toESM(require_runtime());
|
|
5288
|
+
var federationRuntime = (0, import_runtime.createInstance)({
|
|
5289
|
+
name: "luzmo-embed-runtime",
|
|
5290
|
+
remotes: []
|
|
5291
|
+
});
|
|
5292
|
+
var remoteCache = /* @__PURE__ */ new Map();
|
|
5293
|
+
var remoteCounter = 0;
|
|
5294
|
+
function getManifestEntry(appServer, componentName) {
|
|
5295
|
+
const baseUrl = removeTrailingSlash(appServer);
|
|
5296
|
+
if (appServer.startsWith("http://localhost")) {
|
|
5297
|
+
return `${baseUrl}/mf-manifest.json`;
|
|
5298
|
+
}
|
|
5299
|
+
switch (componentName) {
|
|
5300
|
+
case "DashboardApp":
|
|
5301
|
+
case "VizItemApp": {
|
|
5302
|
+
return `${baseUrl}/dashboard-app/mf-manifest.json`;
|
|
5303
|
+
}
|
|
5304
|
+
case "IQApp": {
|
|
5305
|
+
return `${baseUrl}/iq-components/mf-manifest.json`;
|
|
5306
|
+
}
|
|
1312
5307
|
}
|
|
1313
5308
|
}
|
|
1314
|
-
function
|
|
1315
|
-
|
|
1316
|
-
const obj = /* @__PURE__ */ Object.create(null);
|
|
1317
|
-
obj.default = module2;
|
|
1318
|
-
obj.__esModule = true;
|
|
1319
|
-
return obj;
|
|
1320
|
-
}
|
|
1321
|
-
return module2;
|
|
5309
|
+
function getCacheKey(appServer, componentName) {
|
|
5310
|
+
return `${appServer}|${componentName}`;
|
|
1322
5311
|
}
|
|
1323
|
-
|
|
1324
|
-
|
|
5312
|
+
function getOrCreateRemote(appServer, componentName) {
|
|
5313
|
+
const cacheKey = getCacheKey(appServer, componentName);
|
|
5314
|
+
const cachedRemote = remoteCache.get(cacheKey);
|
|
5315
|
+
if (cachedRemote) {
|
|
5316
|
+
return cachedRemote;
|
|
5317
|
+
}
|
|
5318
|
+
const remote = {
|
|
5319
|
+
entry: getManifestEntry(appServer, componentName),
|
|
5320
|
+
registered: false,
|
|
5321
|
+
remoteName: `luzmo_embed_${remoteCounter++}`
|
|
5322
|
+
};
|
|
5323
|
+
remoteCache.set(cacheKey, remote);
|
|
5324
|
+
return remote;
|
|
1325
5325
|
}
|
|
1326
|
-
|
|
1327
|
-
const
|
|
1328
|
-
if (
|
|
1329
|
-
return
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
case "IQApp": {
|
|
1340
|
-
url = `${removeTrailingSlash(appServer)}/iq-components/remoteEntry.mjs`;
|
|
1341
|
-
break;
|
|
5326
|
+
function loadLibrary(appServer, componentName = "DashboardApp") {
|
|
5327
|
+
const remote = getOrCreateRemote(appServer, componentName);
|
|
5328
|
+
if (remote.module) {
|
|
5329
|
+
return Promise.resolve(remote.module);
|
|
5330
|
+
}
|
|
5331
|
+
if (remote.loadPromise) {
|
|
5332
|
+
return remote.loadPromise;
|
|
5333
|
+
}
|
|
5334
|
+
if (!remote.registered) {
|
|
5335
|
+
federationRuntime.registerRemotes([
|
|
5336
|
+
{
|
|
5337
|
+
name: remote.remoteName,
|
|
5338
|
+
entry: remote.entry
|
|
1342
5339
|
}
|
|
1343
|
-
|
|
5340
|
+
]);
|
|
5341
|
+
remote.registered = true;
|
|
1344
5342
|
}
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
module
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
return
|
|
5343
|
+
remote.loadPromise = federationRuntime.loadRemote(`${remote.remoteName}/${componentName}`).then((module2) => {
|
|
5344
|
+
if (!module2) {
|
|
5345
|
+
throw new Error(`Failed to load "${componentName}" from "${remote.entry}".`);
|
|
5346
|
+
}
|
|
5347
|
+
remote.module = module2;
|
|
5348
|
+
return module2;
|
|
5349
|
+
}).finally(() => {
|
|
5350
|
+
remote.loadPromise = void 0;
|
|
5351
|
+
});
|
|
5352
|
+
return remote.loadPromise;
|
|
1355
5353
|
}
|
|
1356
5354
|
|
|
1357
5355
|
// node_modules/@lit/reactive-element/css-tag.js
|
|
1358
5356
|
var t = globalThis;
|
|
1359
5357
|
var e = t.ShadowRoot && (void 0 === t.ShadyCSS || t.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype;
|
|
1360
|
-
var s = Symbol();
|
|
5358
|
+
var s = /* @__PURE__ */ Symbol();
|
|
1361
5359
|
var o = /* @__PURE__ */ new WeakMap();
|
|
1362
5360
|
var n = class {
|
|
1363
5361
|
constructor(t4, e7, o7) {
|
|
@@ -1435,9 +5433,9 @@ var u = { toAttribute(t4, s4) {
|
|
|
1435
5433
|
}
|
|
1436
5434
|
return i7;
|
|
1437
5435
|
} };
|
|
1438
|
-
var
|
|
1439
|
-
var b = { attribute: true, type: String, converter: u, reflect: false, useDefault: false, hasChanged:
|
|
1440
|
-
Symbol.metadata ??= Symbol("metadata"), a.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
|
|
5436
|
+
var f2 = (t4, s4) => !i2(t4, s4);
|
|
5437
|
+
var b = { attribute: true, type: String, converter: u, reflect: false, useDefault: false, hasChanged: f2 };
|
|
5438
|
+
Symbol.metadata ??= /* @__PURE__ */ Symbol("metadata"), a.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
|
|
1441
5439
|
var y = class extends HTMLElement {
|
|
1442
5440
|
static addInitializer(t4) {
|
|
1443
5441
|
this._$Ei(), (this.l ??= []).push(t4);
|
|
@@ -1447,7 +5445,7 @@ var y = class extends HTMLElement {
|
|
|
1447
5445
|
}
|
|
1448
5446
|
static createProperty(t4, s4 = b) {
|
|
1449
5447
|
if (s4.state && (s4.attribute = false), this._$Ei(), this.prototype.hasOwnProperty(t4) && ((s4 = Object.create(s4)).wrapped = true), this.elementProperties.set(t4, s4), !s4.noAccessor) {
|
|
1450
|
-
const i7 = Symbol(), h3 = this.getPropertyDescriptor(t4, i7, s4);
|
|
5448
|
+
const i7 = /* @__PURE__ */ Symbol(), h3 = this.getPropertyDescriptor(t4, i7, s4);
|
|
1451
5449
|
void 0 !== h3 && e2(this.prototype, t4, h3);
|
|
1452
5450
|
}
|
|
1453
5451
|
}
|
|
@@ -1543,13 +5541,15 @@ var y = class extends HTMLElement {
|
|
|
1543
5541
|
const i7 = this.constructor, e7 = i7._$Eh.get(t4);
|
|
1544
5542
|
if (void 0 !== e7 && this._$Em !== e7) {
|
|
1545
5543
|
const t5 = i7.getPropertyOptions(e7), h3 = "function" == typeof t5.converter ? { fromAttribute: t5.converter } : void 0 !== t5.converter?.fromAttribute ? t5.converter : u;
|
|
1546
|
-
this._$Em = e7
|
|
5544
|
+
this._$Em = e7;
|
|
5545
|
+
const r6 = h3.fromAttribute(s4, t5.type);
|
|
5546
|
+
this[e7] = r6 ?? this._$Ej?.get(e7) ?? r6, this._$Em = null;
|
|
1547
5547
|
}
|
|
1548
5548
|
}
|
|
1549
|
-
requestUpdate(t4, s4, i7) {
|
|
5549
|
+
requestUpdate(t4, s4, i7, e7 = false, h3) {
|
|
1550
5550
|
if (void 0 !== t4) {
|
|
1551
|
-
const
|
|
1552
|
-
if (i7 ??=
|
|
5551
|
+
const r6 = this.constructor;
|
|
5552
|
+
if (false === e7 && (h3 = this[t4]), i7 ??= r6.getPropertyOptions(t4), !((i7.hasChanged ?? f2)(h3, s4) || i7.useDefault && i7.reflect && h3 === this._$Ej?.get(t4) && !this.hasAttribute(r6._$Eu(t4, i7)))) return;
|
|
1553
5553
|
this.C(t4, s4, i7);
|
|
1554
5554
|
}
|
|
1555
5555
|
false === this.isUpdatePending && (this._$ES = this._$EP());
|
|
@@ -1617,7 +5617,7 @@ var y = class extends HTMLElement {
|
|
|
1617
5617
|
firstUpdated(t4) {
|
|
1618
5618
|
}
|
|
1619
5619
|
};
|
|
1620
|
-
y.elementStyles = [], y.shadowRootOptions = { mode: "open" }, y[d("elementProperties")] = /* @__PURE__ */ new Map(), y[d("finalized")] = /* @__PURE__ */ new Map(), p?.({ ReactiveElement: y }), (a.reactiveElementVersions ??= []).push("2.1.
|
|
5620
|
+
y.elementStyles = [], y.shadowRootOptions = { mode: "open" }, y[d("elementProperties")] = /* @__PURE__ */ new Map(), y[d("finalized")] = /* @__PURE__ */ new Map(), p?.({ ReactiveElement: y }), (a.reactiveElementVersions ??= []).push("2.1.2");
|
|
1621
5621
|
|
|
1622
5622
|
// node_modules/lit-html/lit-html.js
|
|
1623
5623
|
var t2 = globalThis;
|
|
@@ -1633,7 +5633,7 @@ var c3 = (t4) => null === t4 || "object" != typeof t4 && "function" != typeof t4
|
|
|
1633
5633
|
var a2 = Array.isArray;
|
|
1634
5634
|
var u2 = (t4) => a2(t4) || "function" == typeof t4?.[Symbol.iterator];
|
|
1635
5635
|
var d2 = "[ \n\f\r]";
|
|
1636
|
-
var
|
|
5636
|
+
var f3 = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g;
|
|
1637
5637
|
var v = /-->/g;
|
|
1638
5638
|
var _ = />/g;
|
|
1639
5639
|
var m = RegExp(`>|${d2}(?:([^\\s"'>=/]+)(${d2}*=${d2}*(?:[^
|
|
@@ -1645,8 +5645,8 @@ var y2 = (t4) => (i7, ...s4) => ({ _$litType$: t4, strings: i7, values: s4 });
|
|
|
1645
5645
|
var x = y2(1);
|
|
1646
5646
|
var b2 = y2(2);
|
|
1647
5647
|
var w = y2(3);
|
|
1648
|
-
var T = Symbol.for("lit-noChange");
|
|
1649
|
-
var E = Symbol.for("lit-nothing");
|
|
5648
|
+
var T = /* @__PURE__ */ Symbol.for("lit-noChange");
|
|
5649
|
+
var E = /* @__PURE__ */ Symbol.for("lit-nothing");
|
|
1650
5650
|
var A = /* @__PURE__ */ new WeakMap();
|
|
1651
5651
|
var C = r3.createTreeWalker(r3, 129);
|
|
1652
5652
|
function P(t4, i7) {
|
|
@@ -1655,13 +5655,13 @@ function P(t4, i7) {
|
|
|
1655
5655
|
}
|
|
1656
5656
|
var V = (t4, i7) => {
|
|
1657
5657
|
const s4 = t4.length - 1, o7 = [];
|
|
1658
|
-
let r6, l3 = 2 === i7 ? "<svg>" : 3 === i7 ? "<math>" : "", c4 =
|
|
5658
|
+
let r6, l3 = 2 === i7 ? "<svg>" : 3 === i7 ? "<math>" : "", c4 = f3;
|
|
1659
5659
|
for (let i8 = 0; i8 < s4; i8++) {
|
|
1660
5660
|
const s5 = t4[i8];
|
|
1661
5661
|
let a3, u3, d3 = -1, y3 = 0;
|
|
1662
|
-
for (; y3 < s5.length && (c4.lastIndex = y3, u3 = c4.exec(s5), null !== u3); ) y3 = c4.lastIndex, c4 ===
|
|
5662
|
+
for (; y3 < s5.length && (c4.lastIndex = y3, u3 = c4.exec(s5), null !== u3); ) y3 = c4.lastIndex, c4 === f3 ? "!--" === u3[1] ? c4 = v : void 0 !== u3[1] ? c4 = _ : void 0 !== u3[2] ? ($.test(u3[2]) && (r6 = RegExp("</" + u3[2], "g")), c4 = m) : void 0 !== u3[3] && (c4 = m) : c4 === m ? ">" === u3[0] ? (c4 = r6 ?? f3, d3 = -1) : void 0 === u3[1] ? d3 = -2 : (d3 = c4.lastIndex - u3[2].length, a3 = u3[1], c4 = void 0 === u3[3] ? m : '"' === u3[3] ? g : p2) : c4 === g || c4 === p2 ? c4 = m : c4 === v || c4 === _ ? c4 = f3 : (c4 = m, r6 = void 0);
|
|
1663
5663
|
const x2 = c4 === m && t4[i8 + 1].startsWith("/>") ? " " : "";
|
|
1664
|
-
l3 += c4 ===
|
|
5664
|
+
l3 += c4 === f3 ? s5 + n3 : d3 >= 0 ? (o7.push(a3), s5.slice(0, d3) + e3 + s5.slice(d3) + h2 + x2) : s5 + h2 + (-2 === d3 ? i8 : x2);
|
|
1665
5665
|
}
|
|
1666
5666
|
return [P(t4, l3 + (t4[s4] || "<?>") + (2 === i7 ? "</svg>" : 3 === i7 ? "</math>" : "")), o7];
|
|
1667
5667
|
};
|
|
@@ -1670,8 +5670,8 @@ var N = class _N {
|
|
|
1670
5670
|
let r6;
|
|
1671
5671
|
this.parts = [];
|
|
1672
5672
|
let c4 = 0, a3 = 0;
|
|
1673
|
-
const u3 = t4.length - 1, d3 = this.parts, [
|
|
1674
|
-
if (this.el = _N.createElement(
|
|
5673
|
+
const u3 = t4.length - 1, d3 = this.parts, [f4, v2] = V(t4, s4);
|
|
5674
|
+
if (this.el = _N.createElement(f4, n6), C.currentNode = this.el.content, 2 === s4 || 3 === s4) {
|
|
1675
5675
|
const t5 = this.el.content.firstChild;
|
|
1676
5676
|
t5.replaceWith(...t5.childNodes);
|
|
1677
5677
|
}
|
|
@@ -1899,10 +5899,10 @@ var i4 = class extends y {
|
|
|
1899
5899
|
i4._$litElement$ = true, i4["finalized"] = true, s3.litElementHydrateSupport?.({ LitElement: i4 });
|
|
1900
5900
|
var o4 = s3.litElementPolyfillSupport;
|
|
1901
5901
|
o4?.({ LitElement: i4 });
|
|
1902
|
-
(s3.litElementVersions ??= []).push("4.2.
|
|
5902
|
+
(s3.litElementVersions ??= []).push("4.2.2");
|
|
1903
5903
|
|
|
1904
5904
|
// node_modules/@lit/reactive-element/decorators/property.js
|
|
1905
|
-
var o5 = { attribute: true, type: String, converter: u, reflect: false, hasChanged:
|
|
5905
|
+
var o5 = { attribute: true, type: String, converter: u, reflect: false, hasChanged: f2 };
|
|
1906
5906
|
var r4 = (t4 = o5, e7, r6) => {
|
|
1907
5907
|
const { kind: n6, metadata: i7 } = r6;
|
|
1908
5908
|
let s4 = globalThis.litPropertyMetadata.get(i7);
|
|
@@ -1910,7 +5910,7 @@ var r4 = (t4 = o5, e7, r6) => {
|
|
|
1910
5910
|
const { name: o7 } = r6;
|
|
1911
5911
|
return { set(r7) {
|
|
1912
5912
|
const n7 = e7.get.call(this);
|
|
1913
|
-
e7.set.call(this, r7), this.requestUpdate(o7, n7, t4);
|
|
5913
|
+
e7.set.call(this, r7), this.requestUpdate(o7, n7, t4, true, r7);
|
|
1914
5914
|
}, init(e8) {
|
|
1915
5915
|
return void 0 !== e8 && this.C(o7, void 0, t4, e8), e8;
|
|
1916
5916
|
} };
|
|
@@ -1919,7 +5919,7 @@ var r4 = (t4 = o5, e7, r6) => {
|
|
|
1919
5919
|
const { name: o7 } = r6;
|
|
1920
5920
|
return function(r7) {
|
|
1921
5921
|
const n7 = this[o7];
|
|
1922
|
-
e7.call(this, r7), this.requestUpdate(o7, n7, t4);
|
|
5922
|
+
e7.call(this, r7), this.requestUpdate(o7, n7, t4, true, r7);
|
|
1923
5923
|
};
|
|
1924
5924
|
}
|
|
1925
5925
|
throw Error("Unsupported decorator location: " + n6);
|
|
@@ -1944,8 +5944,8 @@ function e5(e7, r6) {
|
|
|
1944
5944
|
return (n6, s4, i7) => {
|
|
1945
5945
|
const o7 = (t4) => t4.renderRoot?.querySelector(e7) ?? null;
|
|
1946
5946
|
if (r6) {
|
|
1947
|
-
const { get: e8, set: r7 } = "object" == typeof s4 ? n6 : i7 ?? (() => {
|
|
1948
|
-
const t4 = Symbol();
|
|
5947
|
+
const { get: e8, set: r7 } = "object" == typeof s4 ? n6 : i7 ?? /* @__PURE__ */ (() => {
|
|
5948
|
+
const t4 = /* @__PURE__ */ Symbol();
|
|
1949
5949
|
return { get() {
|
|
1950
5950
|
return this[t4];
|
|
1951
5951
|
}, set(e9) {
|
|
@@ -1991,10 +5991,10 @@ var o6 = e6(class extends i5 {
|
|
|
1991
5991
|
if (super(t4), t4.type !== t3.ATTRIBUTE || "style" !== t4.name || t4.strings?.length > 2) throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.");
|
|
1992
5992
|
}
|
|
1993
5993
|
render(t4) {
|
|
1994
|
-
return Object.keys(t4).reduce((e7, r6) => {
|
|
5994
|
+
return Object.keys(t4).reduce(((e7, r6) => {
|
|
1995
5995
|
const s4 = t4[r6];
|
|
1996
5996
|
return null == s4 ? e7 : e7 + `${r6 = r6.includes("-") ? r6 : r6.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g, "-$&").toLowerCase()}:${s4};`;
|
|
1997
|
-
}, "");
|
|
5997
|
+
}), "");
|
|
1998
5998
|
}
|
|
1999
5999
|
update(e7, [r6]) {
|
|
2000
6000
|
const { style: s4 } = e7.element;
|
|
@@ -2013,7 +6013,7 @@ var o6 = e6(class extends i5 {
|
|
|
2013
6013
|
});
|
|
2014
6014
|
|
|
2015
6015
|
// libs/embed-libs/embed/package.json
|
|
2016
|
-
var version = "6.
|
|
6016
|
+
var version = "6.9.0";
|
|
2017
6017
|
|
|
2018
6018
|
// libs/embed-libs/embed/src/lib/luzmo-service.ts
|
|
2019
6019
|
var LuzmoDashboardService = class {
|
|
@@ -2642,11 +6642,11 @@ var LuzmoDashboard = class extends i4 {
|
|
|
2642
6642
|
}
|
|
2643
6643
|
// Setup loader / browser error
|
|
2644
6644
|
_setupLoader() {
|
|
2645
|
-
const
|
|
2646
|
-
this._loaderMsg =
|
|
2647
|
-
if (
|
|
6645
|
+
const data2 = getLoader(this);
|
|
6646
|
+
this._loaderMsg = data2.loadingMsg;
|
|
6647
|
+
if (data2.errorMsg) {
|
|
2648
6648
|
this.browserError = true;
|
|
2649
|
-
this.browserErrorMsg =
|
|
6649
|
+
this.browserErrorMsg = data2.errorMsg;
|
|
2650
6650
|
this._displayError();
|
|
2651
6651
|
}
|
|
2652
6652
|
}
|
|
@@ -3542,8 +7542,8 @@ async function fetchJSONSchema(schemaName) {
|
|
|
3542
7542
|
const schema = await response.json();
|
|
3543
7543
|
addJSONSchemas([schema]);
|
|
3544
7544
|
return schema;
|
|
3545
|
-
} catch (
|
|
3546
|
-
console.error(
|
|
7545
|
+
} catch (error2) {
|
|
7546
|
+
console.error(error2);
|
|
3547
7547
|
}
|
|
3548
7548
|
}
|
|
3549
7549
|
var luzmoRefParserResolver = {
|