@xingtukeji/micro 1.1.12 → 1.1.13

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 CHANGED
@@ -1,35 +1,35 @@
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 v = Object.defineProperty, L = Object.defineProperties;
3
- var T = Object.getOwnPropertyDescriptors;
4
- var M = Object.getOwnPropertySymbols;
5
- var b = Object.prototype.hasOwnProperty, x = Object.prototype.propertyIsEnumerable;
6
- var y = (e, t, n) => t in e ? v(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, l = (e, t) => {
2
+ var T = Object.defineProperty, v = Object.defineProperties;
3
+ var b = Object.getOwnPropertyDescriptors;
4
+ var O = Object.getOwnPropertySymbols;
5
+ var x = Object.prototype.hasOwnProperty, $ = Object.prototype.propertyIsEnumerable;
6
+ var g = (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
- b.call(t, n) && y(e, n, t[n]);
9
- if (M)
10
- for (var n of M(t))
11
- x.call(t, n) && y(e, n, t[n]);
8
+ x.call(t, n) && g(e, n, t[n]);
9
+ if (O)
10
+ for (var n of O(t))
11
+ $.call(t, n) && g(e, n, t[n]);
12
12
  return e;
13
- }, f = (e, t) => L(e, T(t));
14
- var m = (e, t, n) => (y(e, typeof t != "symbol" ? t + "" : t, n), n);
15
- var g = (e, t, n) => new Promise((r, o) => {
16
- var a = (d) => {
13
+ }, w = (e, t) => v(e, b(t));
14
+ var m = (e, t, n) => (g(e, typeof t != "symbol" ? t + "" : t, n), n);
15
+ var u = (e, t, n) => new Promise((o, r) => {
16
+ var a = (i) => {
17
17
  try {
18
- s(n.next(d));
19
- } catch (h) {
20
- o(h);
18
+ l(n.next(i));
19
+ } catch (p) {
20
+ r(p);
21
21
  }
22
- }, c = (d) => {
22
+ }, c = (i) => {
23
23
  try {
24
- s(n.throw(d));
25
- } catch (h) {
26
- o(h);
24
+ l(n.throw(i));
25
+ } catch (p) {
26
+ r(p);
27
27
  }
28
- }, s = (d) => d.done ? r(d.value) : Promise.resolve(d.value).then(a, c);
29
- s((n = n.apply(e, t)).next());
28
+ }, l = (i) => i.done ? o(i.value) : Promise.resolve(i.value).then(a, c);
29
+ l((n = n.apply(e, t)).next());
30
30
  });
31
- import { ref as P, defineComponent as $, watch as X, onMounted as k, onUnmounted as H, openBlock as N, createElementBlock as j, mergeProps as B } from "vue";
32
- const i = {
31
+ import { ref as E, defineComponent as X, watch as k, onMounted as H, onUnmounted as N, openBlock as j, createElementBlock as V, mergeProps as B } from "vue";
32
+ const s = {
33
33
  KEY: "$xtm",
34
34
  // 父应用注入子应用实例的key
35
35
  IS_MICRO: "__XT_MICRO",
@@ -48,45 +48,45 @@ const i = {
48
48
  // 微应用在 url 参数中的前缀
49
49
  MICRO_VERSION: "__XT_MICRO_VERSION"
50
50
  // 微应用版本
51
- }, u = "1.1.11";
52
- function p(e, t = window.location.href) {
51
+ }, h = "1.1.12";
52
+ function f(e, t = window.location.href) {
53
53
  e = e.replace(/[\[\]]/g, "\\$&");
54
- var n = new RegExp("[?&]" + e + "(=([^&#]*)|&|#|$)"), r = n.exec(t);
55
- return r ? r[2] ? decodeURIComponent(r[2].replace(/\+/g, " ")).trim() : "" : null;
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
- function E(e, t, n) {
57
+ function C(e, t, n) {
58
58
  try {
59
59
  return e && (n && e.startsWith("#") ? e : new URL(e, t).href);
60
- } catch (r) {
60
+ } catch (o) {
61
61
  return e;
62
62
  }
63
63
  }
64
- function V(e) {
64
+ function D(e) {
65
65
  const t = window.document.createElement("a");
66
66
  return t.href = e, t.href = t.href, t;
67
67
  }
68
68
  function F(e) {
69
69
  const t = e.search || "";
70
- return [...new URLSearchParams(t).entries()].reduce((n, r) => (n[r[0]] = r[1], n), {});
70
+ return [...new URLSearchParams(t).entries()].reduce((n, o) => (n[o[0]] = o[1], n), {});
71
71
  }
72
72
  function K(e, t) {
73
73
  let n = null;
74
- return function(...r) {
75
- const o = this;
74
+ return function(...o) {
75
+ const r = this;
76
76
  n && clearTimeout(n), n = setTimeout(() => {
77
- e.apply(o, r);
77
+ e.apply(r, o);
78
78
  }, t);
79
79
  };
80
80
  }
81
- function C(e, t, n) {
82
- const [r, o] = e.split("#"), a = new URL(r), c = a.searchParams;
83
- return t = i.URL_PARAM_PREFIX + t, c.has(t) ? c.set(t, n) : c.append(t, n), o && (a.hash = o), a.search = c.toString(), a.toString();
81
+ function S(e, 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 S = (e) => g(void 0, null, function* () {
85
+ const M = (e) => u(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 !== u && console.warn(
89
- `子应用版本与主应用版本不一致,${e}子应用版本:${u},主应用版本:${n.data.data.mainMicroVersion}`
88
+ console.debug("child ipcSyncAppInfo receive message", n.data), n.data.cmd === "$xt/micro/info" && (n.data.data.mainMicroVersion !== h && console.warn(
89
+ `子应用版本与主应用版本不一致,${e}子应用版本:${h},主应用版本:${n.data.data.mainMicroVersion}`
90
90
  ), t(n.data.data));
91
91
  }), console.debug("child ipcSyncAppInfo send message", e), window.parent.postMessage(
92
92
  {
@@ -96,69 +96,69 @@ const S = (e) => g(void 0, null, function* () {
96
96
  "*"
97
97
  );
98
98
  });
99
- }), se = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
99
+ }), ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
100
100
  __proto__: null,
101
- addOrReplaceUrlParam: C,
102
- anchorElementGenerator: V,
101
+ addOrReplaceUrlParam: S,
102
+ anchorElementGenerator: D,
103
103
  debounce: K,
104
- getAbsolutePath: E,
104
+ getAbsolutePath: C,
105
105
  getAnchorElementQueryMap: F,
106
- getQueryParameter: p,
107
- ipcSyncAppInfo: S
108
- }, Symbol.toStringTag, { value: "Module" })), O = P(!1);
109
- Object.defineProperty(window, i.IS_MICRO, {
106
+ getQueryParameter: f,
107
+ ipcSyncAppInfo: M
108
+ }, Symbol.toStringTag, { value: "Module" })), P = E(!1);
109
+ Object.defineProperty(window, s.IS_MICRO, {
110
110
  get: function() {
111
- return O.value;
111
+ return P.value;
112
112
  },
113
113
  set: function(e) {
114
- O.value = e;
114
+ P.value = e;
115
115
  }
116
116
  });
117
- const I = (e) => `${i.DOM_ID_PREFIX}${e}`, D = (e) => {
118
- function t(s) {
119
- return s !== null && typeof s == "object" && !Array.isArray(s);
117
+ const I = (e) => `${s.DOM_ID_PREFIX}${e}`, A = (e, t = !1) => {
118
+ function n(i) {
119
+ return i !== null && typeof i == "object" && !Array.isArray(i);
120
120
  }
121
- 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(
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
- ), a = p(i.URL_PARAM_PREFIX + e.name);
124
- if (a) {
125
- const s = E(a, e.url, !0);
126
- if (s) {
127
- const d = new URL(s);
128
- d.searchParams.forEach((A, U) => {
129
- o.searchParams.set(U, A);
130
- }), o.hash = d.hash;
123
+ ), c = f(s.URL_PARAM_PREFIX + e.name);
124
+ if (!t && c) {
125
+ const i = C(c, e.url, !0);
126
+ if (i) {
127
+ const p = new URL(i);
128
+ p.searchParams.forEach((U, L) => {
129
+ a.searchParams.set(L, U);
130
+ }), a.hash = p.hash;
131
131
  }
132
132
  }
133
- if (o.searchParams.set(i.IS_MICRO, !0 + ""), o.searchParams.set(i.MICRO_NAME, e.name), r && o.searchParams.set(i.MICRO_TOKEN, r), n)
134
- for (let s of Object.keys(n))
135
- o.searchParams.set(s, n[s]);
136
- const c = new URL(window.location.href);
137
- return c.searchParams.delete(e.name), window.history.replaceState({}, "", c.href), o.href;
138
- }, Y = () => {
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
+ const l = new URL(window.location.href);
137
+ return l.searchParams.delete(e.name), window.history.replaceState({}, "", l.href), a.href;
138
+ }, W = () => {
139
139
  const e = document.createElement("div");
140
140
  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;
141
- }, W = (e) => {
141
+ }, Y = (e) => {
142
142
  e.style.opacity = "0", setTimeout(() => {
143
143
  e.remove();
144
144
  }, 500);
145
145
  }, q = (e) => {
146
146
  const t = document.createElement("iframe");
147
147
  t.id = I(e.app.name);
148
- const n = D(e.app);
149
- 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", (o) => (t.style.visibility = "visible", e.onLoad.call(e, o))), t.addEventListener(
148
+ const n = A(e.app);
149
+ 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(
150
150
  "error",
151
- (o) => e.onError.call(e, o)
151
+ (r) => e.onError.call(e, r)
152
152
  ), t.addEventListener(
153
153
  "unload",
154
- (o) => e.onUnload.call(e, o)
154
+ (r) => e.onUnload.call(e, r)
155
155
  );
156
- const r = new MutationObserver((o) => {
157
- o.forEach((a) => {
158
- Array.from(a.removedNodes).includes(t) && (e.onUnload(new Event("unload")), r.disconnect());
156
+ const o = new MutationObserver((r) => {
157
+ r.forEach((a) => {
158
+ Array.from(a.removedNodes).includes(t) && (e.onUnload(new Event("unload")), o.disconnect());
159
159
  });
160
160
  });
161
- return r.observe(e.panel, { childList: !0 }), t;
161
+ return o.observe(e.panel, { childList: !0 }), t;
162
162
  };
163
163
  class z {
164
164
  constructor(t) {
@@ -170,15 +170,15 @@ class z {
170
170
  return this.app = t, this.dom = void 0, this.panel = void 0, t.preload && this.preload(), this;
171
171
  }
172
172
  mount(t, n = !1) {
173
- let r;
174
- if (t ? (typeof t == "string" ? r = document.querySelector(t) : r = t, r.innerHTML = "") : r = document.body, r) {
175
- this.panel = r;
176
- let o = document.getElementById(I(this.app.name));
177
- o || (o = q(this), this.dom = o), n ? o.style.display = "none" : o.style.removeProperty("display");
178
- const a = Y();
173
+ let o;
174
+ if (t ? (typeof t == "string" ? o = document.querySelector(t) : o = t, o.innerHTML = "") : o = document.body, o) {
175
+ this.panel = o;
176
+ let r = document.getElementById(I(this.app.name));
177
+ r || (r = q(this), this.dom = r), n ? r.style.display = "none" : r.style.removeProperty("display");
178
+ const a = W();
179
179
  this.loadingTimer = setTimeout(() => {
180
- this.loading = a, r.appendChild(a);
181
- }, 1e3), r.appendChild(o);
180
+ this.loading = a, o.appendChild(a);
181
+ }, 1e3), o.appendChild(r);
182
182
  } else
183
183
  throw new Error("el not found");
184
184
  }
@@ -204,15 +204,17 @@ class z {
204
204
  preload() {
205
205
  this.mount(void 0, !0);
206
206
  }
207
- reload() {
208
- const t = this.dom.src;
209
- this.dom.src = t;
207
+ reload(t = !1) {
208
+ let n = this.dom.src;
209
+ t && (n = A(this.app, !0), console.log("go home", n)), console.log("reload app", this.app, n);
210
+ const o = new URL(n);
211
+ o.searchParams.set("__t", Date.now().toString()), this.dom.src = o.toString();
210
212
  }
211
213
  changeOptions(t) {
212
- this.app = l(l({}, this.app), t);
214
+ this.app = d(d({}, this.app), t);
213
215
  }
214
216
  onLoad(t) {
215
- console.debug("app onLoad", this.app.name), this.loadingTimer && clearTimeout(this.loadingTimer), this.loading && W(this.loading), G(this), this.app.onLoad && this.app.onLoad(t, this);
217
+ console.debug("app onLoad", this.app.name), this.loadingTimer && clearTimeout(this.loadingTimer), this.loading && Y(this.loading), G(this), this.app.onLoad && this.app.onLoad(t, this);
216
218
  }
217
219
  onUnload(t) {
218
220
  console.debug("app onUnload", this.app.name), this.app.onUnload && this.app.onUnload(t, this);
@@ -237,31 +239,32 @@ const G = (e) => {
237
239
  "*"
238
240
  );
239
241
  }, Q = () => {
240
- window[i.MICRO_TYPE] = "parent", window.addEventListener("message", (e) => {
242
+ window[s.MICRO_TYPE] = "parent", window.addEventListener("message", (e) => {
241
243
  if (e.data.cmd === "$xt/micro/sync") {
244
+ console.log("父页面接受子应用同步路由信息", e.data);
242
245
  const t = [
243
- i.IS_MICRO,
244
- i.MICRO_NAME,
245
- i.MICRO_TOKEN
246
+ s.IS_MICRO,
247
+ s.MICRO_NAME,
248
+ s.MICRO_TOKEN
246
249
  ], n = new URL(
247
250
  window.decodeURIComponent(e.data.data.url),
248
251
  e.origin
249
252
  );
250
253
  for (let a of t)
251
254
  n.searchParams.delete(a);
252
- const r = new URL(window.location.href);
253
- r.searchParams.forEach((a, c) => {
254
- c.startsWith(i.URL_PARAM_PREFIX) && r.searchParams.delete(c);
255
+ const o = new URL(window.location.href);
256
+ o.searchParams.forEach((a, c) => {
257
+ c.startsWith(s.URL_PARAM_PREFIX) && o.searchParams.delete(c);
255
258
  });
256
- const o = C(
257
- r.href,
259
+ const r = S(
260
+ o.href,
258
261
  e.data.data.name,
259
262
  n.href
260
263
  );
261
- window.history.replaceState(null, "", o);
264
+ window.history.replaceState(null, "", r);
262
265
  } else if (e.data.cmd === "$xt/micro/info") {
263
266
  console.debug("parent 「$xt/micro/info」 receive message", e.data);
264
- const t = _(e.data.data);
267
+ const t = y(e.data.data);
265
268
  e.source.postMessage(
266
269
  {
267
270
  cmd: "$xt/micro/info",
@@ -277,7 +280,7 @@ const G = (e) => {
277
280
  port: window.location.port,
278
281
  protocol: window.location.protocol
279
282
  },
280
- mainMicroVersion: u,
283
+ mainMicroVersion: h,
281
284
  name: t.name,
282
285
  url: t.url,
283
286
  params: t.params,
@@ -289,129 +292,134 @@ const G = (e) => {
289
292
  );
290
293
  }
291
294
  });
292
- }, ie = (...t) => g(void 0, [...t], function* (e = {}) {
293
- window[i.MICRO_TYPE] = "child";
294
- const n = p(i.IS_MICRO), r = p(i.MICRO_NAME);
295
- if (console.debug("child microInit", n, r), n && (window[i.IS_MICRO] = n === "true"), r && S(r).then((o) => {
296
- window[i.MICRO_APP] = l({
297
- microVersion: u
298
- }, o);
299
- }), window[i.IS_MICRO]) {
300
- let o = function(c) {
301
- var s = document.styleSheets[0];
302
- if (!s) {
303
- var d = document.createElement("style");
304
- document.head.appendChild(d), s = d.sheet;
295
+ }, ce = (...t) => u(void 0, [...t], function* (e = {}) {
296
+ window[s.MICRO_TYPE] = "child";
297
+ const n = f(s.IS_MICRO), o = f(s.MICRO_NAME);
298
+ if (console.debug("child microInit", n, o), n && (window[s.IS_MICRO] = n === "true"), o && M(o).then((r) => {
299
+ window[s.MICRO_APP] = d({
300
+ microVersion: h
301
+ }, r);
302
+ }), window[s.IS_MICRO]) {
303
+ let r = function(c) {
304
+ var l = document.styleSheets[0];
305
+ if (!l) {
306
+ var i = document.createElement("style");
307
+ document.head.appendChild(i), l = i.sheet;
305
308
  }
306
- s.insertRule(c, s.cssRules.length);
309
+ l.insertRule(c, l.cssRules.length);
307
310
  };
308
- window[i.IS_MICRO] && e.hideHeaderCssSelector && (Array.isArray(e.hideHeaderCssSelector) ? e.hideHeaderCssSelector.forEach((c) => {
309
- o(`${c} { display: none !important; }`);
310
- }) : o(
311
+ window[s.IS_MICRO] && e.hideHeaderCssSelector && (Array.isArray(e.hideHeaderCssSelector) ? e.hideHeaderCssSelector.forEach((c) => {
312
+ r(`${c} { display: none !important; }`);
313
+ }) : r(
311
314
  `${e.hideHeaderCssSelector} { display: none !important; }`
312
- )), window.addEventListener("message", (c) => {
313
- c.data.cmd === `$xt/micro/${r}` && R();
314
- }), J(window);
315
- const a = p(i.MICRO_TOKEN);
315
+ )), yield J(o, window), window.addEventListener("message", (c) => u(void 0, null, function* () {
316
+ c.data.cmd === `$xt/micro/${o}` && R(o);
317
+ }));
318
+ const a = f(s.MICRO_TOKEN);
316
319
  e.authHandler && a && (yield e.authHandler(a));
317
320
  } else
318
321
  console.warn("当前环境非微应用环境");
319
322
  });
320
- function J(e) {
321
- const t = e.history, n = t.pushState, r = t.replaceState;
322
- t.pushState = function(o, a, c) {
323
- const s = f(l(l({}, t.state || {}), o), {
323
+ function J(e, t) {
324
+ const n = t.history, o = n.pushState, r = n.replaceState;
325
+ n.pushState = function(a, c, l) {
326
+ const i = w(d(d({}, n.state || {}), a), {
324
327
  // 添加新数据
325
328
  _patchedByParent: !0
326
329
  // 可选:标记这是被父窗口修改的状态
327
330
  });
328
- n.call(t, s, a, c), R();
329
- }, t.replaceState = function(o, a, c) {
330
- const s = f(l(l({}, t.state || {}), o), {
331
+ o.call(n, i, c, l), R(e);
332
+ }, n.replaceState = function(a, c, l) {
333
+ const i = w(d(d({}, n.state || {}), a), {
331
334
  // 添加新数据
332
335
  _patchedByParent: !0
333
336
  // 可选:标记这是被父窗口修改的状态
334
337
  });
335
- r.call(t, s, a, c), R();
338
+ r.call(n, i, c, l), R(e);
336
339
  };
337
340
  }
338
- function R() {
339
- if (!window[i.MICRO_APP])
340
- return;
341
- const { name: e, sync: t, mainBaseURL: n } = window[i.MICRO_APP], r = window.location.pathname + window.location.search + window.location.hash;
342
- window.parent.postMessage(
343
- {
344
- cmd: "$xt/micro/sync",
345
- data: {
346
- name: e,
347
- url: window.encodeURIComponent(r)
348
- }
349
- },
350
- n
351
- );
341
+ function R(e) {
342
+ return u(this, null, function* () {
343
+ console.log("syncUrlToWindow", e, window[s.MICRO_APP]), window[s.MICRO_APP] || (yield M(e).then((a) => {
344
+ window[s.MICRO_APP] = d({
345
+ microVersion: h
346
+ }, a);
347
+ }));
348
+ const { name: t, sync: n, mainLocation: o } = window[s.MICRO_APP], r = window.location.pathname + window.location.search + window.location.hash;
349
+ window.parent.postMessage(
350
+ {
351
+ cmd: "$xt/micro/sync",
352
+ data: {
353
+ name: t,
354
+ url: window.encodeURIComponent(r)
355
+ }
356
+ },
357
+ o.origin
358
+ );
359
+ });
352
360
  }
353
- let w = {};
361
+ let _ = {};
354
362
  const Z = {
355
363
  url: "",
356
364
  name: "",
357
365
  sync: !0
358
- }, ce = (e) => {
366
+ }, le = (e) => {
359
367
  if (!e.url || e.url === "" || e.url === "undefined") {
360
368
  console.error("app url is required", e);
361
369
  return;
362
370
  }
363
371
  const t = Object.assign({}, Z, e);
364
- return w[e.name] = f(l({}, t), {
372
+ return _[e.name] = w(d({}, t), {
365
373
  instance: new z(e)
366
- }), w[e.name];
367
- }, _ = (e) => w[e], ee = (e, t) => w[e.name] = l(l({}, e), t), te = (e, t) => new Promise((n, r) => {
368
- let o = _(e);
369
- o ? (t && (o.instance.changeOptions(t), o = ee(o, t)), o.preload ? o.instance.preloadRender(o.el) : o.instance.mount(o.el), n(o)) : r("app not found");
374
+ }), _[e.name];
375
+ }, y = (e) => _[e], ee = (e, t) => _[e.name] = d(d({}, e), t), te = (e, t) => new Promise((n, o) => {
376
+ let r = y(e);
377
+ r ? (t && (r.instance.changeOptions(t), r = ee(r, t)), r.preload ? r.instance.preloadRender(r.el) : r.instance.mount(r.el), n(r)) : o("app not found");
370
378
  }), ne = (e) => {
371
- let t = _(e);
379
+ let t = y(e);
372
380
  t && t.instance.unmount();
373
- }, de = (e) => {
374
- let t = _(e);
375
- t && t.instance.reload();
376
- }, oe = /* @__PURE__ */ $({
381
+ }, de = (e, t = !1) => {
382
+ let n = y(e);
383
+ n && n.instance.reload(t);
384
+ }, oe = /* @__PURE__ */ X({
377
385
  __name: "XTMicroView",
378
386
  props: {
379
387
  appId: String
380
388
  },
381
389
  setup(e) {
382
- const t = e, n = P(), r = () => {
390
+ const t = e, n = E(), o = () => {
383
391
  t.appId && te(t.appId, {
384
392
  el: n.value
385
- }).then((o) => {
393
+ }).then((r) => {
386
394
  console.debug("app mounted", t.appId);
387
395
  });
388
396
  };
389
- return X(() => t.appId, (o, a) => {
390
- o !== a && a && ne(a), r();
391
- }), k(() => {
392
- r();
397
+ return k(() => t.appId, (r, a) => {
398
+ r !== a && a && ne(a), o();
393
399
  }), H(() => {
400
+ o();
401
+ }), N(() => {
394
402
  console.debug("app unmount", t.appId);
395
- }), (o, a) => (N(), j("div", B({
403
+ }), (r, a) => (j(), V("div", B({
396
404
  ref_key: "refPanel",
397
405
  ref: n
398
- }, o.$attrs, { class: "xt-micro" }), null, 16));
406
+ }, r.$attrs, { class: "xt-micro" }), null, 16));
399
407
  }
400
408
  });
401
- window[i.MICRO_VERSION] = u;
402
- const le = {
409
+ window[s.MICRO_VERSION] = h;
410
+ const pe = {
403
411
  install: (e, t = {}) => {
404
412
  e.component("xt-micro-view", oe), Q();
405
413
  }
406
414
  };
407
415
  export {
408
416
  oe as XTMicroView,
409
- le as default,
410
- _ as getApp,
411
- ie as microInit,
417
+ pe as default,
418
+ y as getApp,
419
+ ce as microInit,
412
420
  de as reloadApp,
413
- ce as setupApp,
421
+ le as setupApp,
414
422
  te as startApp,
415
423
  ne as stopApp,
416
- se as utils
424
+ ie as utils
417
425
  };
@@ -18,5 +18,5 @@ export declare const startApp: (name: string, options?: Partial<AppOption>) => P
18
18
  * @param {string} name - 应用程序的名称
19
19
  */
20
20
  export declare const stopApp: (name: string) => void;
21
- export declare const reloadApp: (name: string) => void;
21
+ export declare const reloadApp: (name: string, isGoHome?: boolean) => void;
22
22
  export { microInit };
@@ -9,7 +9,7 @@ export declare const microInit: (options?: MicroInitOptions) => Promise<void>;
9
9
  /**
10
10
  * 同步子应用路由到主应用路由
11
11
  */
12
- export declare function syncUrlToWindow(): void;
12
+ export declare function syncUrlToWindow(microName: string): Promise<void>;
13
13
  /**
14
14
  * 同步主应用路由到子应用
15
15
  */
@@ -19,7 +19,7 @@ export declare class MicroApp {
19
19
  * 预加载app,先放到body,待启动时,挪过来
20
20
  */
21
21
  preload(): void;
22
- reload(): void;
22
+ reload(isGoHome?: boolean): void;
23
23
  changeOptions(options: Partial<AppOption>): void;
24
24
  onLoad(_event: Event): void;
25
25
  onUnload(_event: Event): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xingtukeji/micro",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "main": "dist/index.js",