@xingtukeji/micro 1.1.7 → 1.1.9
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 +41 -44
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,30 +2,30 @@
|
|
|
2
2
|
var U = Object.defineProperty, A = Object.defineProperties;
|
|
3
3
|
var L = Object.getOwnPropertyDescriptors;
|
|
4
4
|
var g = Object.getOwnPropertySymbols;
|
|
5
|
-
var
|
|
5
|
+
var b = Object.prototype.hasOwnProperty, T = Object.prototype.propertyIsEnumerable;
|
|
6
6
|
var y = (e, t, n) => t in e ? U(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
|
+
b.call(t, n) && y(e, n, t[n]);
|
|
9
9
|
if (g)
|
|
10
10
|
for (var n of g(t))
|
|
11
|
-
|
|
11
|
+
T.call(t, n) && y(e, n, t[n]);
|
|
12
12
|
return e;
|
|
13
13
|
}, m = (e, t) => A(e, L(t));
|
|
14
14
|
var u = (e, t, n) => (y(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
15
15
|
var I = (e, t, n) => new Promise((r, o) => {
|
|
16
|
-
var
|
|
16
|
+
var s = (l) => {
|
|
17
17
|
try {
|
|
18
18
|
i(n.next(l));
|
|
19
19
|
} catch (h) {
|
|
20
20
|
o(h);
|
|
21
21
|
}
|
|
22
|
-
},
|
|
22
|
+
}, a = (l) => {
|
|
23
23
|
try {
|
|
24
24
|
i(n.throw(l));
|
|
25
25
|
} catch (h) {
|
|
26
26
|
o(h);
|
|
27
27
|
}
|
|
28
|
-
}, i = (l) => l.done ? r(l.value) : Promise.resolve(l.value).then(
|
|
28
|
+
}, i = (l) => l.done ? r(l.value) : Promise.resolve(l.value).then(s, a);
|
|
29
29
|
i((n = n.apply(e, t)).next());
|
|
30
30
|
});
|
|
31
31
|
import { ref as P, defineComponent as v, watch as x, onMounted as k, onUnmounted as X, openBlock as $, createElementBlock as H, mergeProps as N } from "vue";
|
|
@@ -75,8 +75,8 @@ function F(e, t) {
|
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
function E(e, t, n) {
|
|
78
|
-
const [r, o] = e.split("#"),
|
|
79
|
-
return t = c.URL_PARAM_PREFIX + t,
|
|
78
|
+
const [r, o] = e.split("#"), s = new URL(r), a = s.searchParams;
|
|
79
|
+
return t = c.URL_PARAM_PREFIX + t, a.has(t) ? a.set(t, n) : a.append(t, n), o && (s.hash = o), s.search = a.toString(), s.toString();
|
|
80
80
|
}
|
|
81
81
|
const re = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
82
82
|
__proto__: null,
|
|
@@ -101,9 +101,9 @@ const w = (e) => `${c.DOM_ID_PREFIX}${e}`, K = (e) => {
|
|
|
101
101
|
}
|
|
102
102
|
const n = typeof e.params == "function" ? e.params() : t(e.params) ? e.params : {}, r = typeof e.token == "function" ? e.token() : t(e.token) ? e.token : "", o = new URL(
|
|
103
103
|
e.url.indexOf("http") > -1 ? e.url : window.location.origin + e.url
|
|
104
|
-
),
|
|
105
|
-
if (
|
|
106
|
-
const i = O(
|
|
104
|
+
), s = p(c.URL_PARAM_PREFIX + e.name);
|
|
105
|
+
if (s) {
|
|
106
|
+
const i = O(s, e.url, !0);
|
|
107
107
|
if (i) {
|
|
108
108
|
const l = new URL(i);
|
|
109
109
|
l.searchParams.forEach((C, S) => {
|
|
@@ -114,8 +114,8 @@ const w = (e) => `${c.DOM_ID_PREFIX}${e}`, K = (e) => {
|
|
|
114
114
|
if (o.searchParams.set(c.IS_MICRO, !0 + ""), o.searchParams.set(c.MICRO_NAME, e.name), r && o.searchParams.set(c.MICRO_TOKEN, r), n)
|
|
115
115
|
for (let i of Object.keys(n))
|
|
116
116
|
o.searchParams.set(i, n[i]);
|
|
117
|
-
const
|
|
118
|
-
return
|
|
117
|
+
const a = new URL(window.location.href);
|
|
118
|
+
return a.searchParams.delete(e.name), window.history.replaceState({}, "", a.href), o.href;
|
|
119
119
|
}, D = () => {
|
|
120
120
|
const e = document.createElement("div");
|
|
121
121
|
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;
|
|
@@ -127,10 +127,7 @@ const w = (e) => `${c.DOM_ID_PREFIX}${e}`, K = (e) => {
|
|
|
127
127
|
const t = document.createElement("iframe");
|
|
128
128
|
t.id = w(e.app.name);
|
|
129
129
|
const n = K(e.app);
|
|
130
|
-
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.addEventListener(
|
|
131
|
-
"load",
|
|
132
|
-
(o) => e.onLoad.call(e, o)
|
|
133
|
-
), t.addEventListener(
|
|
130
|
+
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"] = "none", t.style.visibility = "hidden", t.addEventListener("load", (o) => (t.style.visibility = "visible", e.onLoad.call(e, o))), t.addEventListener(
|
|
134
131
|
"error",
|
|
135
132
|
(o) => e.onError.call(e, o)
|
|
136
133
|
), t.addEventListener(
|
|
@@ -138,8 +135,8 @@ const w = (e) => `${c.DOM_ID_PREFIX}${e}`, K = (e) => {
|
|
|
138
135
|
(o) => e.onUnload.call(e, o)
|
|
139
136
|
);
|
|
140
137
|
const r = new MutationObserver((o) => {
|
|
141
|
-
o.forEach((
|
|
142
|
-
Array.from(
|
|
138
|
+
o.forEach((s) => {
|
|
139
|
+
Array.from(s.removedNodes).includes(t) && (e.onUnload(new Event("unload")), r.disconnect());
|
|
143
140
|
});
|
|
144
141
|
});
|
|
145
142
|
return r.observe(e.panel, { childList: !0 }), t;
|
|
@@ -159,9 +156,9 @@ class z {
|
|
|
159
156
|
this.panel = r;
|
|
160
157
|
let o = document.getElementById(w(this.app.name));
|
|
161
158
|
o || (o = q(this), this.dom = o), n ? o.style.display = "none" : o.style.removeProperty("display");
|
|
162
|
-
const
|
|
159
|
+
const s = D();
|
|
163
160
|
this.loadingTimer = setTimeout(() => {
|
|
164
|
-
this.loading =
|
|
161
|
+
this.loading = s, r.appendChild(s);
|
|
165
162
|
}, 1e3), r.appendChild(o);
|
|
166
163
|
} else
|
|
167
164
|
throw new Error("el not found");
|
|
@@ -231,11 +228,11 @@ const G = (e) => {
|
|
|
231
228
|
window.decodeURIComponent(e.data.data.url),
|
|
232
229
|
e.origin
|
|
233
230
|
);
|
|
234
|
-
for (let
|
|
235
|
-
n.searchParams.delete(
|
|
231
|
+
for (let s of t)
|
|
232
|
+
n.searchParams.delete(s);
|
|
236
233
|
const r = new URL(window.location.href);
|
|
237
|
-
r.searchParams.forEach((
|
|
238
|
-
|
|
234
|
+
r.searchParams.forEach((s, a) => {
|
|
235
|
+
a.startsWith(c.URL_PARAM_PREFIX) && r.searchParams.delete(a);
|
|
239
236
|
});
|
|
240
237
|
const o = E(
|
|
241
238
|
r.href,
|
|
@@ -245,41 +242,41 @@ const G = (e) => {
|
|
|
245
242
|
window.history.replaceState(null, "", o);
|
|
246
243
|
}
|
|
247
244
|
});
|
|
248
|
-
},
|
|
245
|
+
}, se = (...t) => I(void 0, [...t], function* (e = {}) {
|
|
249
246
|
const n = p(c.IS_MICRO), r = p(c.MICRO_NAME);
|
|
250
247
|
n && (window[c.IS_MICRO] = !0);
|
|
251
|
-
function o(
|
|
248
|
+
function o(a) {
|
|
252
249
|
var i = document.styleSheets[0];
|
|
253
250
|
if (!i) {
|
|
254
251
|
var l = document.createElement("style");
|
|
255
252
|
document.head.appendChild(l), i = l.sheet;
|
|
256
253
|
}
|
|
257
|
-
i.insertRule(
|
|
254
|
+
i.insertRule(a, i.cssRules.length);
|
|
258
255
|
}
|
|
259
|
-
window[c.IS_MICRO] && e.hideHeaderCssSelector && (Array.isArray(e.hideHeaderCssSelector) ? e.hideHeaderCssSelector.forEach((
|
|
260
|
-
o(`${
|
|
261
|
-
}) : o(`${e.hideHeaderCssSelector} { display: none !important; }`)), window.addEventListener("message", (
|
|
262
|
-
|
|
256
|
+
window[c.IS_MICRO] && e.hideHeaderCssSelector && (Array.isArray(e.hideHeaderCssSelector) ? e.hideHeaderCssSelector.forEach((a) => {
|
|
257
|
+
o(`${a} { display: none !important; }`);
|
|
258
|
+
}) : o(`${e.hideHeaderCssSelector} { display: none !important; }`)), window.addEventListener("message", (a) => {
|
|
259
|
+
a.data.cmd === `$xt/micro/${r}` && (window[c.MICRO_APP] = m(d({}, a.data.data), { mainBaseURL: a.origin }), _());
|
|
263
260
|
}), Y(window);
|
|
264
|
-
const
|
|
265
|
-
e.authHandler &&
|
|
261
|
+
const s = p(c.MICRO_TOKEN);
|
|
262
|
+
e.authHandler && s && (yield e.authHandler(s));
|
|
266
263
|
});
|
|
267
264
|
function Y(e) {
|
|
268
265
|
const t = e.history, n = t.pushState, r = t.replaceState;
|
|
269
|
-
t.pushState = function(o,
|
|
266
|
+
t.pushState = function(o, s, a) {
|
|
270
267
|
const i = m(d(d({}, t.state || {}), o), {
|
|
271
268
|
// 添加新数据
|
|
272
269
|
_patchedByParent: !0
|
|
273
270
|
// 可选:标记这是被父窗口修改的状态
|
|
274
271
|
});
|
|
275
|
-
n.call(t, i,
|
|
276
|
-
}, t.replaceState = function(o,
|
|
272
|
+
n.call(t, i, s, a), _();
|
|
273
|
+
}, t.replaceState = function(o, s, a) {
|
|
277
274
|
const i = m(d(d({}, t.state || {}), o), {
|
|
278
275
|
// 添加新数据
|
|
279
276
|
_patchedByParent: !0
|
|
280
277
|
// 可选:标记这是被父窗口修改的状态
|
|
281
278
|
});
|
|
282
|
-
r.call(t, i,
|
|
279
|
+
r.call(t, i, s, a), _();
|
|
283
280
|
};
|
|
284
281
|
}
|
|
285
282
|
function _() {
|
|
@@ -299,7 +296,7 @@ const J = {
|
|
|
299
296
|
url: "",
|
|
300
297
|
name: "",
|
|
301
298
|
sync: !0
|
|
302
|
-
},
|
|
299
|
+
}, ae = (e) => {
|
|
303
300
|
if (!e.url || e.url === "" || e.url === "undefined") {
|
|
304
301
|
console.error("app url is required", e);
|
|
305
302
|
return;
|
|
@@ -330,13 +327,13 @@ const J = {
|
|
|
330
327
|
console.debug("app mounted", t.appId);
|
|
331
328
|
});
|
|
332
329
|
};
|
|
333
|
-
return x(() => t.appId, (o,
|
|
334
|
-
o !==
|
|
330
|
+
return x(() => t.appId, (o, s) => {
|
|
331
|
+
o !== s && s && ee(s), r();
|
|
335
332
|
}), k(() => {
|
|
336
333
|
r();
|
|
337
334
|
}), X(() => {
|
|
338
335
|
console.debug("app unmount", t.appId);
|
|
339
|
-
}), (o,
|
|
336
|
+
}), (o, s) => ($(), H("div", N({
|
|
340
337
|
ref_key: "refPanel",
|
|
341
338
|
ref: n
|
|
342
339
|
}, o.$attrs, { class: "xt-micro" }), null, 16));
|
|
@@ -351,9 +348,9 @@ export {
|
|
|
351
348
|
te as XTMicroView,
|
|
352
349
|
ce as default,
|
|
353
350
|
R as getApp,
|
|
354
|
-
|
|
351
|
+
se as microInit,
|
|
355
352
|
ie as reloadApp,
|
|
356
|
-
|
|
353
|
+
ae as setupApp,
|
|
357
354
|
Z as startApp,
|
|
358
355
|
ee as stopApp,
|
|
359
356
|
re as utils
|