@module-federation/bridge-vue3 0.0.0-next-20241101093646 → 0.0.0-next-20241104024700

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