@module-federation/bridge-vue3 0.0.0-fix-lazy-comile-20250925082726

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