@xingtukeji/micro 1.1.15 → 1.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +110 -116
- package/dist/types/api.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document!="undefined"){var e=document.createElement("style");e.appendChild(document.createTextNode('.xt-micro{width:100%;height:100%;overflow:hidden;background-color:transparent}.xt-micro:before{content:"加载中";position:absolute;inset:0;display:flex;justify-content:center;align-items:center;z-index:-1}.micro-iframe{width:100%;height:100%;border:none;margin:0;padding:0}.micro-iframe:after{content:"加载中";position:absolute;inset:0;display:flex;justify-content:center;align-items:center;background:#fff}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
|
-
var
|
|
2
|
+
var T = Object.defineProperty, A = Object.defineProperties;
|
|
3
3
|
var x = Object.getOwnPropertyDescriptors;
|
|
4
4
|
var E = Object.getOwnPropertySymbols;
|
|
5
5
|
var $ = Object.prototype.hasOwnProperty, X = Object.prototype.propertyIsEnumerable;
|
|
6
|
-
var R = (e, t, n) => t in e ?
|
|
6
|
+
var R = (e, t, n) => t in e ? T(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, d = (e, t) => {
|
|
7
7
|
for (var n in t || (t = {}))
|
|
8
8
|
$.call(t, n) && R(e, n, t[n]);
|
|
9
9
|
if (E)
|
|
10
10
|
for (var n of E(t))
|
|
11
11
|
X.call(t, n) && R(e, n, t[n]);
|
|
12
12
|
return e;
|
|
13
|
-
},
|
|
14
|
-
var
|
|
15
|
-
var
|
|
13
|
+
}, y = (e, t) => A(e, x(t));
|
|
14
|
+
var p = (e, t, n) => (R(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
15
|
+
var h = (e, t, n) => new Promise((o, r) => {
|
|
16
16
|
var a = (l) => {
|
|
17
17
|
try {
|
|
18
18
|
i(n.next(l));
|
|
19
|
-
} catch (
|
|
20
|
-
|
|
19
|
+
} catch (_) {
|
|
20
|
+
r(_);
|
|
21
21
|
}
|
|
22
22
|
}, c = (l) => {
|
|
23
23
|
try {
|
|
24
24
|
i(n.throw(l));
|
|
25
|
-
} catch (
|
|
26
|
-
|
|
25
|
+
} catch (_) {
|
|
26
|
+
r(_);
|
|
27
27
|
}
|
|
28
|
-
}, i = (l) => l.done ?
|
|
28
|
+
}, i = (l) => l.done ? o(l.value) : Promise.resolve(l.value).then(a, c);
|
|
29
29
|
i((n = n.apply(e, t)).next());
|
|
30
30
|
});
|
|
31
|
-
import { ref as C, defineComponent as k, watch as H, onMounted as j, onUnmounted as
|
|
31
|
+
import { ref as C, defineComponent as k, watch as H, onMounted as j, onUnmounted as N, openBlock as V, createElementBlock as B, mergeProps as F } from "vue";
|
|
32
32
|
const s = {
|
|
33
33
|
KEY: "$xtm",
|
|
34
34
|
// 父应用注入子应用实例的key
|
|
@@ -48,16 +48,16 @@ const s = {
|
|
|
48
48
|
// 微应用在 url 参数中的前缀
|
|
49
49
|
MICRO_VERSION: "__XT_MICRO_VERSION"
|
|
50
50
|
// 微应用版本
|
|
51
|
-
},
|
|
51
|
+
}, u = "1.1.17";
|
|
52
52
|
function f(e, t = window.location.href) {
|
|
53
53
|
e = e.replace(/[\[\]]/g, "\\$&");
|
|
54
|
-
var n = new RegExp("[?&]" + e + "(=([^&#]*)|&|#|$)"),
|
|
55
|
-
return
|
|
54
|
+
var n = new RegExp("[?&]" + e + "(=([^&#]*)|&|#|$)"), o = n.exec(t);
|
|
55
|
+
return o ? o[2] ? decodeURIComponent(o[2].replace(/\+/g, " ")).trim() : "" : null;
|
|
56
56
|
}
|
|
57
57
|
function S(e, t, n) {
|
|
58
58
|
try {
|
|
59
59
|
return e && (n && e.startsWith("#") ? e : new URL(e, t).href);
|
|
60
|
-
} catch (
|
|
60
|
+
} catch (o) {
|
|
61
61
|
return e;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -67,26 +67,26 @@ function D(e) {
|
|
|
67
67
|
}
|
|
68
68
|
function K(e) {
|
|
69
69
|
const t = e.search || "";
|
|
70
|
-
return [...new URLSearchParams(t).entries()].reduce((n,
|
|
70
|
+
return [...new URLSearchParams(t).entries()].reduce((n, o) => (n[o[0]] = o[1], n), {});
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function Y(e, t) {
|
|
73
73
|
let n = null;
|
|
74
|
-
return function(...
|
|
75
|
-
const
|
|
74
|
+
return function(...o) {
|
|
75
|
+
const r = this;
|
|
76
76
|
n && clearTimeout(n), n = setTimeout(() => {
|
|
77
|
-
e.apply(
|
|
77
|
+
e.apply(r, o);
|
|
78
78
|
}, t);
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
function U(e, t, n) {
|
|
82
|
-
const [
|
|
83
|
-
return t = s.URL_PARAM_PREFIX + t, c.has(t) ? c.set(t, n) : c.append(t, n),
|
|
82
|
+
const [o, r] = e.split("#"), a = new URL(o), c = a.searchParams;
|
|
83
|
+
return t = s.URL_PARAM_PREFIX + t, c.has(t) ? c.set(t, n) : c.append(t, n), r && (a.hash = r), a.search = c.toString(), a.toString();
|
|
84
84
|
}
|
|
85
|
-
const P = (e) =>
|
|
85
|
+
const P = (e) => h(void 0, null, function* () {
|
|
86
86
|
return new Promise((t) => {
|
|
87
87
|
window.addEventListener("message", (n) => {
|
|
88
|
-
console.debug("child ipcSyncAppInfo receive message", n.data), n.data.cmd === "$xt/micro/info" && (n.data.data.mainMicroVersion !==
|
|
89
|
-
`子应用版本与主应用版本不一致,${e}子应用版本:${
|
|
88
|
+
console.debug("child ipcSyncAppInfo receive message", n.data), n.data.cmd === "$xt/micro/info" && (n.data.data.mainMicroVersion !== u && console.warn(
|
|
89
|
+
`子应用版本与主应用版本不一致,${e}子应用版本:${u},主应用版本:${n.data.data.mainMicroVersion}`
|
|
90
90
|
), t(n.data.data));
|
|
91
91
|
}), console.debug("child ipcSyncAppInfo send message", e), window.parent.postMessage(
|
|
92
92
|
{
|
|
@@ -100,7 +100,7 @@ const P = (e) => u(void 0, null, function* () {
|
|
|
100
100
|
__proto__: null,
|
|
101
101
|
addOrReplaceUrlParam: U,
|
|
102
102
|
anchorElementGenerator: D,
|
|
103
|
-
debounce:
|
|
103
|
+
debounce: Y,
|
|
104
104
|
getAbsolutePath: S,
|
|
105
105
|
getAnchorElementQueryMap: K,
|
|
106
106
|
getQueryParameter: f,
|
|
@@ -114,27 +114,27 @@ Object.defineProperty(window, s.IS_MICRO, {
|
|
|
114
114
|
O.value = e;
|
|
115
115
|
}
|
|
116
116
|
});
|
|
117
|
-
const I = (e) => `${s.DOM_ID_PREFIX}${e}`,
|
|
117
|
+
const I = (e) => `${s.DOM_ID_PREFIX}${e}`, b = (e, t = !1) => {
|
|
118
118
|
function n(i) {
|
|
119
119
|
return i !== null && typeof i == "object" && !Array.isArray(i);
|
|
120
120
|
}
|
|
121
|
-
const
|
|
121
|
+
const o = typeof e.params == "function" ? e.params() : n(e.params) ? e.params : {}, r = typeof e.token == "function" ? e.token() : n(e.token) ? e.token : "", a = new URL(
|
|
122
122
|
e.url.indexOf("http") > -1 ? e.url : window.location.origin + e.url
|
|
123
123
|
), c = f(s.URL_PARAM_PREFIX + e.name);
|
|
124
124
|
if (!t && c) {
|
|
125
125
|
const i = S(c, e.url, !0);
|
|
126
126
|
if (i) {
|
|
127
127
|
const l = new URL(i);
|
|
128
|
-
l.searchParams.forEach((
|
|
129
|
-
a.searchParams.set(
|
|
128
|
+
l.searchParams.forEach((v, L) => {
|
|
129
|
+
a.searchParams.set(L, v);
|
|
130
130
|
}), a.hash = l.hash;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
if (a.searchParams.set(s.IS_MICRO, !0 + ""), a.searchParams.set(s.MICRO_NAME, e.name),
|
|
134
|
-
for (let i of Object.keys(
|
|
135
|
-
a.searchParams.set(i,
|
|
136
|
-
return
|
|
137
|
-
},
|
|
133
|
+
if (a.searchParams.set(s.IS_MICRO, !0 + ""), a.searchParams.set(s.MICRO_NAME, e.name), r && a.searchParams.set(s.MICRO_TOKEN, r), o)
|
|
134
|
+
for (let i of Object.keys(o))
|
|
135
|
+
a.searchParams.set(i, o[i]);
|
|
136
|
+
return w(e.name), a.href;
|
|
137
|
+
}, W = () => {
|
|
138
138
|
const e = document.createElement("div");
|
|
139
139
|
return e.innerHTML = "应用加载中...", e.style.textAlign = "center", e.style.lineHeight = "100px", e.style.fontSize = "20px", e.style.color = "#999", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.right = "0", e.style.bottom = "0", e.style.zIndex = "999", e.style.background = "transparent", e.style["mix-blend-mode"] = "difference", e;
|
|
140
140
|
}, q = (e) => {
|
|
@@ -144,43 +144,43 @@ const I = (e) => `${s.DOM_ID_PREFIX}${e}`, L = (e, t = !1) => {
|
|
|
144
144
|
}, z = (e) => {
|
|
145
145
|
const t = document.createElement("iframe");
|
|
146
146
|
t.id = I(e.app.name);
|
|
147
|
-
const n =
|
|
148
|
-
t.src = n, t.style.width = "100%", t.style.height = "100%", t.style.border = "none", t.style.margin = "0", t.style.padding = "0", t.style.backgroundColor = "transparent", t.style["color-scheme"] = "unset", t.style.visibility = "hidden", t.addEventListener("load", (
|
|
147
|
+
const n = b(e.app);
|
|
148
|
+
t.src = n, t.style.width = "100%", t.style.height = "100%", t.style.border = "none", t.style.margin = "0", t.style.padding = "0", t.style.backgroundColor = "transparent", t.style["color-scheme"] = "unset", t.style.visibility = "hidden", t.addEventListener("load", (r) => (t.style.visibility = "visible", e.onLoad.call(e, r))), t.addEventListener(
|
|
149
149
|
"error",
|
|
150
|
-
(
|
|
150
|
+
(r) => e.onError.call(e, r)
|
|
151
151
|
), t.addEventListener(
|
|
152
152
|
"unload",
|
|
153
|
-
(
|
|
153
|
+
(r) => e.onUnload.call(e, r)
|
|
154
154
|
);
|
|
155
|
-
const
|
|
156
|
-
console.log("监听 body 中子节点的变化2", e.panel),
|
|
157
|
-
Array.from(a.removedNodes).includes(t) && (e.onUnload(new Event("unload")),
|
|
155
|
+
const o = new MutationObserver((r) => {
|
|
156
|
+
console.log("监听 body 中子节点的变化2", e.panel), r.forEach((a) => {
|
|
157
|
+
Array.from(a.removedNodes).includes(t) && (e.onUnload(new Event("unload")), o.disconnect());
|
|
158
158
|
});
|
|
159
159
|
});
|
|
160
|
-
return
|
|
160
|
+
return o.observe(e.panel.parentNode, {
|
|
161
161
|
childList: !0,
|
|
162
162
|
subtree: !1
|
|
163
163
|
}), t;
|
|
164
164
|
};
|
|
165
165
|
class G {
|
|
166
166
|
constructor(t) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
167
|
+
p(this, "app");
|
|
168
|
+
p(this, "dom");
|
|
169
|
+
p(this, "panel");
|
|
170
|
+
p(this, "loading");
|
|
171
|
+
p(this, "loadingTimer");
|
|
172
172
|
return this.app = t, this.dom = void 0, this.panel = void 0, t.preload && this.preload(), this;
|
|
173
173
|
}
|
|
174
174
|
mount(t, n = !1) {
|
|
175
|
-
let
|
|
176
|
-
if (t ? (typeof t == "string" ?
|
|
177
|
-
this.panel =
|
|
178
|
-
let
|
|
179
|
-
|
|
180
|
-
const a =
|
|
175
|
+
let o;
|
|
176
|
+
if (t ? (typeof t == "string" ? o = document.querySelector(t) : o = t, o.innerHTML = "") : o = document.body, o) {
|
|
177
|
+
this.panel = o;
|
|
178
|
+
let r = document.getElementById(I(this.app.name));
|
|
179
|
+
r || (r = z(this), this.dom = r), n ? r.style.display = "none" : r.style.removeProperty("display");
|
|
180
|
+
const a = W();
|
|
181
181
|
this.loadingTimer = setTimeout(() => {
|
|
182
|
-
this.loading = a,
|
|
183
|
-
}, 1e3),
|
|
182
|
+
this.loading = a, o.appendChild(a);
|
|
183
|
+
}, 1e3), o.appendChild(r);
|
|
184
184
|
} else
|
|
185
185
|
throw new Error("el not found");
|
|
186
186
|
}
|
|
@@ -209,9 +209,9 @@ class G {
|
|
|
209
209
|
}
|
|
210
210
|
reload(t = !1) {
|
|
211
211
|
let n = this.dom.src;
|
|
212
|
-
t && (n =
|
|
213
|
-
const
|
|
214
|
-
|
|
212
|
+
t && (n = b(this.app, !0), console.log("go home", n)), console.log("reload app", this.app, n);
|
|
213
|
+
const o = new URL(n);
|
|
214
|
+
o.searchParams.set("__t", Date.now().toString()), this.dom.style.visibility = "hidden", this.dom.src = o.toString();
|
|
215
215
|
}
|
|
216
216
|
changeOptions(t) {
|
|
217
217
|
console.log("changeOptions", this.app, t), this.app = d(d({}, this.app), t);
|
|
@@ -220,7 +220,7 @@ class G {
|
|
|
220
220
|
console.debug("app onLoad", this.app.name), this.loadingTimer && clearTimeout(this.loadingTimer), this.loading && q(this.loading), Q(this), this.app.onLoad && this.app.onLoad(t, this);
|
|
221
221
|
}
|
|
222
222
|
onUnload(t) {
|
|
223
|
-
console.debug("app onUnload", this.app.name),
|
|
223
|
+
console.debug("app onUnload", this.app.name), w(this.app.name), this.app.onUnload && this.app.onUnload(t, this);
|
|
224
224
|
}
|
|
225
225
|
onError(t) {
|
|
226
226
|
console.error("app onError", this.app.name), this.app.onError && this.app.onError(t, this);
|
|
@@ -255,16 +255,12 @@ const Q = (e) => {
|
|
|
255
255
|
);
|
|
256
256
|
for (let a of t)
|
|
257
257
|
n.searchParams.delete(a);
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
c.startsWith(s.URL_PARAM_PREFIX) && r.searchParams.delete(c);
|
|
261
|
-
});
|
|
262
|
-
const o = U(
|
|
263
|
-
r.href,
|
|
258
|
+
const o = w(e.data.data.name), r = U(
|
|
259
|
+
o,
|
|
264
260
|
e.data.data.name,
|
|
265
261
|
n.href
|
|
266
262
|
);
|
|
267
|
-
window.history.replaceState(null, "",
|
|
263
|
+
window.history.replaceState(null, "", r);
|
|
268
264
|
} else if (e.data.cmd === "$xt/micro/info") {
|
|
269
265
|
console.debug("parent 「$xt/micro/info」 receive message", e.data);
|
|
270
266
|
const t = g(e.data.data);
|
|
@@ -283,7 +279,7 @@ const Q = (e) => {
|
|
|
283
279
|
port: window.location.port,
|
|
284
280
|
protocol: window.location.protocol
|
|
285
281
|
},
|
|
286
|
-
mainMicroVersion:
|
|
282
|
+
mainMicroVersion: u,
|
|
287
283
|
name: t.name,
|
|
288
284
|
url: t.url,
|
|
289
285
|
params: t.params,
|
|
@@ -295,15 +291,15 @@ const Q = (e) => {
|
|
|
295
291
|
);
|
|
296
292
|
}
|
|
297
293
|
});
|
|
298
|
-
}, ce = (...t) =>
|
|
294
|
+
}, ce = (...t) => h(void 0, [...t], function* (e = {}) {
|
|
299
295
|
window[s.MICRO_TYPE] = "child";
|
|
300
|
-
const n = f(s.IS_MICRO),
|
|
301
|
-
if (console.debug("child microInit", n,
|
|
296
|
+
const n = f(s.IS_MICRO), o = f(s.MICRO_NAME);
|
|
297
|
+
if (console.debug("child microInit", n, o), n && (window[s.IS_MICRO] = n === "true"), o && P(o).then((r) => {
|
|
302
298
|
window[s.MICRO_APP] = d({
|
|
303
|
-
microVersion:
|
|
304
|
-
},
|
|
299
|
+
microVersion: u
|
|
300
|
+
}, r);
|
|
305
301
|
}), window[s.IS_MICRO]) {
|
|
306
|
-
let
|
|
302
|
+
let r = function(c) {
|
|
307
303
|
var i = document.styleSheets[0];
|
|
308
304
|
if (!i) {
|
|
309
305
|
var l = document.createElement("style");
|
|
@@ -312,11 +308,11 @@ const Q = (e) => {
|
|
|
312
308
|
i.insertRule(c, i.cssRules.length);
|
|
313
309
|
};
|
|
314
310
|
window[s.IS_MICRO] && e.hideHeaderCssSelector && (Array.isArray(e.hideHeaderCssSelector) ? e.hideHeaderCssSelector.forEach((c) => {
|
|
315
|
-
|
|
316
|
-
}) :
|
|
311
|
+
r(`${c} { display: none !important; }`);
|
|
312
|
+
}) : r(
|
|
317
313
|
`${e.hideHeaderCssSelector} { display: none !important; }`
|
|
318
|
-
)), yield Z(
|
|
319
|
-
c.data.cmd === `$xt/micro/${
|
|
314
|
+
)), yield Z(o, window), window.addEventListener("message", (c) => h(void 0, null, function* () {
|
|
315
|
+
c.data.cmd === `$xt/micro/${o}` && M(o);
|
|
320
316
|
}));
|
|
321
317
|
const a = f(s.MICRO_TOKEN);
|
|
322
318
|
e.authHandler && a && (yield e.authHandler(a));
|
|
@@ -324,44 +320,44 @@ const Q = (e) => {
|
|
|
324
320
|
console.warn("当前环境非微应用环境");
|
|
325
321
|
});
|
|
326
322
|
function Z(e, t) {
|
|
327
|
-
const n = t.history,
|
|
323
|
+
const n = t.history, o = n.pushState, r = n.replaceState;
|
|
328
324
|
n.pushState = function(a, c, i) {
|
|
329
|
-
const l =
|
|
325
|
+
const l = y(d(d({}, n.state || {}), a), {
|
|
330
326
|
// 添加新数据
|
|
331
327
|
_patchedByParent: !0
|
|
332
328
|
// 可选:标记这是被父窗口修改的状态
|
|
333
329
|
});
|
|
334
|
-
|
|
330
|
+
o.call(n, l, c, i), M(e);
|
|
335
331
|
}, n.replaceState = function(a, c, i) {
|
|
336
|
-
const l =
|
|
332
|
+
const l = y(d(d({}, n.state || {}), a), {
|
|
337
333
|
// 添加新数据
|
|
338
334
|
_patchedByParent: !0
|
|
339
335
|
// 可选:标记这是被父窗口修改的状态
|
|
340
336
|
});
|
|
341
|
-
|
|
337
|
+
r.call(n, l, c, i), M(e);
|
|
342
338
|
};
|
|
343
339
|
}
|
|
344
340
|
function M(e) {
|
|
345
|
-
return
|
|
341
|
+
return h(this, null, function* () {
|
|
346
342
|
console.log("syncUrlToWindow", e, window[s.MICRO_APP]), window[s.MICRO_APP] || (yield P(e).then((a) => {
|
|
347
343
|
window[s.MICRO_APP] = d({
|
|
348
|
-
microVersion:
|
|
344
|
+
microVersion: u
|
|
349
345
|
}, a);
|
|
350
346
|
}));
|
|
351
|
-
const { name: t, sync: n, mainLocation:
|
|
347
|
+
const { name: t, sync: n, mainLocation: o } = window[s.MICRO_APP], r = window.location.pathname + window.location.search + window.location.hash;
|
|
352
348
|
window.parent.postMessage(
|
|
353
349
|
{
|
|
354
350
|
cmd: "$xt/micro/sync",
|
|
355
351
|
data: {
|
|
356
352
|
name: t,
|
|
357
|
-
url: window.encodeURIComponent(
|
|
353
|
+
url: window.encodeURIComponent(r)
|
|
358
354
|
}
|
|
359
355
|
},
|
|
360
|
-
|
|
356
|
+
o.origin
|
|
361
357
|
);
|
|
362
358
|
});
|
|
363
359
|
}
|
|
364
|
-
let
|
|
360
|
+
let m = {};
|
|
365
361
|
const ee = {
|
|
366
362
|
url: "",
|
|
367
363
|
name: "",
|
|
@@ -371,67 +367,65 @@ const ee = {
|
|
|
371
367
|
console.error("app url is required", e);
|
|
372
368
|
return;
|
|
373
369
|
}
|
|
374
|
-
const t = Object.assign({}, ee, e), n =
|
|
375
|
-
return n ?
|
|
370
|
+
const t = Object.assign({}, ee, e), n = m[e.name];
|
|
371
|
+
return n ? m[e.name] = d(d({}, n), t) : m[e.name] = y(d({}, t), {
|
|
376
372
|
instance: new G(e)
|
|
377
|
-
}),
|
|
378
|
-
}, g = (e) =>
|
|
379
|
-
let
|
|
380
|
-
|
|
373
|
+
}), m[e.name];
|
|
374
|
+
}, g = (e) => m[e], te = (e, t) => m[e.name] = d(d({}, e), t), ne = (e, t) => new Promise((n, o) => {
|
|
375
|
+
let r = g(e);
|
|
376
|
+
r ? (t && (r.instance.changeOptions(t), r = te(r, t)), r.preload ? r.instance.preloadRender(r.el) : r.instance.mount(r.el), n(r)) : o("app not found, please setup app first");
|
|
381
377
|
}), oe = (e) => {
|
|
382
378
|
let t = g(e);
|
|
383
379
|
t && t.instance.unmount();
|
|
384
380
|
}, de = (e, t = !1) => {
|
|
385
381
|
let n = g(e);
|
|
386
382
|
n && n.instance.reload(t);
|
|
387
|
-
},
|
|
383
|
+
}, w = (e) => {
|
|
388
384
|
console.log("clearParentUrl", e, s.URL_PARAM_PREFIX + e);
|
|
389
385
|
const t = window.location.href.split("#");
|
|
390
386
|
console.log("url", t);
|
|
391
387
|
const n = new URL(t[0]);
|
|
392
|
-
console.log("mainURL", n), n.searchParams.delete(s.URL_PARAM_PREFIX + e)
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
t.length > 1 ? n.href + "#" + t[1] : n.href
|
|
396
|
-
);
|
|
388
|
+
console.log("mainURL", n), n.searchParams.delete(s.URL_PARAM_PREFIX + e);
|
|
389
|
+
const o = t.length > 1 ? n.href + "#" + t[1] : n.href;
|
|
390
|
+
return window.history.replaceState({}, "", o), o;
|
|
397
391
|
}, re = /* @__PURE__ */ k({
|
|
398
392
|
__name: "XTMicroView",
|
|
399
393
|
props: {
|
|
400
394
|
appId: String
|
|
401
395
|
},
|
|
402
396
|
setup(e) {
|
|
403
|
-
const t = e, n = C(),
|
|
397
|
+
const t = e, n = C(), o = () => {
|
|
404
398
|
t.appId && ne(t.appId, {
|
|
405
399
|
el: n.value,
|
|
406
|
-
onUnload(
|
|
407
|
-
console.log("on unload", a.app.name),
|
|
400
|
+
onUnload(r, a) {
|
|
401
|
+
console.log("on unload", a.app.name), w(a.app.name);
|
|
408
402
|
}
|
|
409
|
-
}).then((
|
|
403
|
+
}).then((r) => {
|
|
410
404
|
console.debug("app mounted", t.appId);
|
|
411
405
|
});
|
|
412
406
|
};
|
|
413
|
-
return H(() => t.appId, (
|
|
414
|
-
|
|
407
|
+
return H(() => t.appId, (r, a) => {
|
|
408
|
+
r !== a && a && oe(a), o();
|
|
415
409
|
}), j(() => {
|
|
416
|
-
|
|
417
|
-
}),
|
|
418
|
-
console.debug("「micro」", "app unmount", t.appId),
|
|
419
|
-
}), (
|
|
410
|
+
o();
|
|
411
|
+
}), N(() => {
|
|
412
|
+
console.debug("「micro」", "app unmount", t.appId), w(t.appId);
|
|
413
|
+
}), (r, a) => (V(), B("div", F({
|
|
420
414
|
ref_key: "refPanel",
|
|
421
415
|
ref: n
|
|
422
|
-
},
|
|
416
|
+
}, r.$attrs, { class: "xt-micro" }), null, 16));
|
|
423
417
|
}
|
|
424
418
|
});
|
|
425
|
-
window[s.MICRO_VERSION] =
|
|
426
|
-
const
|
|
419
|
+
window[s.MICRO_VERSION] = u;
|
|
420
|
+
const pe = {
|
|
427
421
|
install: (e, t = {}) => {
|
|
428
422
|
e.component("xt-micro-view", re), J();
|
|
429
423
|
}
|
|
430
424
|
};
|
|
431
425
|
export {
|
|
432
426
|
re as XTMicroView,
|
|
433
|
-
|
|
434
|
-
|
|
427
|
+
w as clearParentUrl,
|
|
428
|
+
pe as default,
|
|
435
429
|
g as getApp,
|
|
436
430
|
ce as microInit,
|
|
437
431
|
de as reloadApp,
|
package/dist/types/api.d.ts
CHANGED
|
@@ -19,5 +19,5 @@ export declare const startApp: (name: string, options?: Partial<AppOption>) => P
|
|
|
19
19
|
*/
|
|
20
20
|
export declare const stopApp: (name: string) => void;
|
|
21
21
|
export declare const reloadApp: (name: string, isGoHome?: boolean) => void;
|
|
22
|
-
export declare const clearParentUrl: (appName: string) =>
|
|
22
|
+
export declare const clearParentUrl: (appName: string) => string;
|
|
23
23
|
export { microInit };
|