@xingtukeji/micro 1.1.17 → 1.1.18

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,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 T = Object.defineProperty, A = Object.defineProperties;
3
- var x = Object.getOwnPropertyDescriptors;
4
- var E = Object.getOwnPropertySymbols;
5
- var $ = Object.prototype.hasOwnProperty, X = Object.prototype.propertyIsEnumerable;
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) => {
2
+ var x = Object.defineProperty, X = Object.defineProperties;
3
+ var k = Object.getOwnPropertyDescriptors;
4
+ var M = Object.getOwnPropertySymbols;
5
+ var H = Object.prototype.hasOwnProperty, j = Object.prototype.propertyIsEnumerable;
6
+ var R = (e, t, n) => t in e ? x(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
- $.call(t, n) && R(e, n, t[n]);
9
- if (E)
10
- for (var n of E(t))
11
- X.call(t, n) && R(e, n, t[n]);
8
+ H.call(t, n) && R(e, n, t[n]);
9
+ if (M)
10
+ for (var n of M(t))
11
+ j.call(t, n) && R(e, n, t[n]);
12
12
  return e;
13
- }, y = (e, t) => A(e, x(t));
13
+ }, y = (e, t) => X(e, k(t));
14
14
  var p = (e, t, n) => (R(e, typeof t != "symbol" ? t + "" : t, n), n);
15
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
- r(_);
19
+ } catch (g) {
20
+ r(g);
21
21
  }
22
22
  }, c = (l) => {
23
23
  try {
24
24
  i(n.throw(l));
25
- } catch (_) {
26
- r(_);
25
+ } catch (g) {
26
+ r(g);
27
27
  }
28
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 N, openBlock as V, createElementBlock as B, mergeProps as F } from "vue";
31
+ import { ref as O, defineComponent as N, watch as F, onMounted as B, onUnmounted as V, openBlock as D, createElementBlock as K, mergeProps as Y } from "vue";
32
32
  const s = {
33
33
  KEY: "$xtm",
34
34
  // 父应用注入子应用实例的key
@@ -48,28 +48,28 @@ const s = {
48
48
  // 微应用在 url 参数中的前缀
49
49
  MICRO_VERSION: "__XT_MICRO_VERSION"
50
50
  // 微应用版本
51
- }, u = "1.1.17";
51
+ }, w = "1.1.17";
52
52
  function f(e, t = window.location.href) {
53
53
  e = e.replace(/[\[\]]/g, "\\$&");
54
54
  var n = new RegExp("[?&]" + e + "(=([^&#]*)|&|#|$)"), o = n.exec(t);
55
55
  return o ? o[2] ? decodeURIComponent(o[2].replace(/\+/g, " ")).trim() : "" : null;
56
56
  }
57
- function S(e, t, n) {
57
+ function E(e, t, n) {
58
58
  try {
59
59
  return e && (n && e.startsWith("#") ? e : new URL(e, t).href);
60
60
  } catch (o) {
61
61
  return e;
62
62
  }
63
63
  }
64
- function D(e) {
64
+ function W(e) {
65
65
  const t = window.document.createElement("a");
66
66
  return t.href = e, t.href = t.href, t;
67
67
  }
68
- function K(e) {
68
+ function z(e) {
69
69
  const t = e.search || "";
70
70
  return [...new URLSearchParams(t).entries()].reduce((n, o) => (n[o[0]] = o[1], n), {});
71
71
  }
72
- function Y(e, t) {
72
+ function q(e, t) {
73
73
  let n = null;
74
74
  return function(...o) {
75
75
  const r = this;
@@ -78,15 +78,15 @@ function Y(e, t) {
78
78
  }, t);
79
79
  };
80
80
  }
81
- function U(e, t, n) {
81
+ function C(e, t, n) {
82
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();
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(), console.trace("urlObj", a), a.origin + a.pathname + a.search + a.hash;
84
84
  }
85
- const P = (e) => h(void 0, null, function* () {
85
+ const S = (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 !== 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 !== w && console.warn(
89
+ `子应用版本与主应用版本不一致,${e}子应用版本:${w},主应用版本:${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,25 +96,25 @@ const P = (e) => h(void 0, null, function* () {
96
96
  "*"
97
97
  );
98
98
  });
99
- }), ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
99
+ }), he = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
100
100
  __proto__: null,
101
- addOrReplaceUrlParam: U,
102
- anchorElementGenerator: D,
103
- debounce: Y,
104
- getAbsolutePath: S,
105
- getAnchorElementQueryMap: K,
101
+ addOrReplaceUrlParam: C,
102
+ anchorElementGenerator: W,
103
+ debounce: q,
104
+ getAbsolutePath: E,
105
+ getAnchorElementQueryMap: z,
106
106
  getQueryParameter: f,
107
- ipcSyncAppInfo: P
108
- }, Symbol.toStringTag, { value: "Module" })), O = C(!1);
107
+ ipcSyncAppInfo: S
108
+ }, Symbol.toStringTag, { value: "Module" })), P = O(!1);
109
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) => `${s.DOM_ID_PREFIX}${e}`, b = (e, t = !1) => {
117
+ const I = (e) => `${s.DOM_ID_PREFIX}${e}`, U = (e, t = !1) => {
118
118
  function n(i) {
119
119
  return i !== null && typeof i == "object" && !Array.isArray(i);
120
120
  }
@@ -122,29 +122,30 @@ const I = (e) => `${s.DOM_ID_PREFIX}${e}`, b = (e, t = !1) => {
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
- const i = S(c, e.url, !0);
125
+ const i = E(c, e.url, !0);
126
126
  if (i) {
127
- const l = new URL(i);
128
- l.searchParams.forEach((v, L) => {
129
- a.searchParams.set(L, v);
127
+ const l = new URL(i, e.url);
128
+ l.searchParams.forEach((A, $) => {
129
+ a.searchParams.set($, A);
130
130
  }), a.hash = l.hash;
131
131
  }
132
+ m(e.name);
132
133
  }
133
134
  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
135
  for (let i of Object.keys(o))
135
136
  a.searchParams.set(i, o[i]);
136
- return w(e.name), a.href;
137
- }, W = () => {
137
+ return m(e.name), a.href;
138
+ }, G = () => {
138
139
  const e = document.createElement("div");
139
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;
140
- }, q = (e) => {
141
+ }, Q = (e) => {
141
142
  e.style.opacity = "0", setTimeout(() => {
142
143
  e.remove();
143
144
  }, 500);
144
- }, z = (e) => {
145
+ }, J = (e) => {
145
146
  const t = document.createElement("iframe");
146
147
  t.id = I(e.app.name);
147
- const n = b(e.app);
148
+ const n = U(e.app);
148
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(
149
150
  "error",
150
151
  (r) => e.onError.call(e, r)
@@ -162,7 +163,7 @@ const I = (e) => `${s.DOM_ID_PREFIX}${e}`, b = (e, t = !1) => {
162
163
  subtree: !1
163
164
  }), t;
164
165
  };
165
- class G {
166
+ class Z {
166
167
  constructor(t) {
167
168
  p(this, "app");
168
169
  p(this, "dom");
@@ -176,8 +177,8 @@ class G {
176
177
  if (t ? (typeof t == "string" ? o = document.querySelector(t) : o = t, o.innerHTML = "") : o = document.body, o) {
177
178
  this.panel = o;
178
179
  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();
180
+ r || (r = J(this), this.dom = r), n ? r.style.display = "none" : r.style.removeProperty("display");
181
+ const a = G();
181
182
  this.loadingTimer = setTimeout(() => {
182
183
  this.loading = a, o.appendChild(a);
183
184
  }, 1e3), o.appendChild(r);
@@ -209,7 +210,7 @@ class G {
209
210
  }
210
211
  reload(t = !1) {
211
212
  let n = this.dom.src;
212
- t && (n = b(this.app, !0), console.log("go home", n)), console.log("reload app", this.app, n);
213
+ t && (n = U(this.app, !0), console.log("go home", n)), console.log("reload app", this.app, n);
213
214
  const o = new URL(n);
214
215
  o.searchParams.set("__t", Date.now().toString()), this.dom.style.visibility = "hidden", this.dom.src = o.toString();
215
216
  }
@@ -217,16 +218,16 @@ class G {
217
218
  console.log("changeOptions", this.app, t), this.app = d(d({}, this.app), t);
218
219
  }
219
220
  onLoad(t) {
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
+ console.debug("app onLoad", this.app.name), this.loadingTimer && clearTimeout(this.loadingTimer), this.loading && Q(this.loading), ee(this), console.log("this.app.onLoad", this.app.onLoad), this.app.onLoad && this.app.onLoad(t, this);
221
222
  }
222
223
  onUnload(t) {
223
- console.debug("app onUnload", this.app.name), w(this.app.name), this.app.onUnload && this.app.onUnload(t, this);
224
+ console.debug("app onUnload", this.app.name), m(this.app.name), this.app.onUnload && this.app.onUnload(t, this);
224
225
  }
225
226
  onError(t) {
226
227
  console.error("app onError", this.app.name), this.app.onError && this.app.onError(t, this);
227
228
  }
228
229
  }
229
- const Q = (e) => {
230
+ const ee = (e) => {
230
231
  var t, n;
231
232
  (n = (t = e.dom) == null ? void 0 : t.contentWindow) == null || n.postMessage(
232
233
  {
@@ -241,7 +242,7 @@ const Q = (e) => {
241
242
  },
242
243
  "*"
243
244
  );
244
- }, J = () => {
245
+ }, te = () => {
245
246
  window[s.MICRO_TYPE] = "parent", window.addEventListener("message", (e) => {
246
247
  if (e.data.cmd === "$xt/micro/sync") {
247
248
  console.log("父页面接受子应用同步路由信息", e.data);
@@ -253,17 +254,23 @@ const Q = (e) => {
253
254
  window.decodeURIComponent(e.data.data.url),
254
255
  e.origin
255
256
  );
256
- for (let a of t)
257
- n.searchParams.delete(a);
258
- const o = w(e.data.data.name), r = U(
259
- o,
257
+ for (let c of t)
258
+ n.searchParams.delete(c);
259
+ console.log("tempUrl", n);
260
+ const o = m(e.data.data.name), r = new URL(o);
261
+ r.searchParams.forEach((c, i) => {
262
+ i.startsWith(s.URL_PARAM_PREFIX) && r.searchParams.delete(i);
263
+ }), console.log("mainURL.href", r.href);
264
+ const a = C(
265
+ r.href,
260
266
  e.data.data.name,
261
267
  n.href
268
+ // tempUrl.pathname + tempUrl.search + tempUrl.hash
262
269
  );
263
- window.history.replaceState(null, "", r);
270
+ console.log("curUrl", a), window.history.replaceState(null, "", a);
264
271
  } else if (e.data.cmd === "$xt/micro/info") {
265
272
  console.debug("parent 「$xt/micro/info」 receive message", e.data);
266
- const t = g(e.data.data);
273
+ const t = _(e.data.data);
267
274
  e.source.postMessage(
268
275
  {
269
276
  cmd: "$xt/micro/info",
@@ -279,7 +286,7 @@ const Q = (e) => {
279
286
  port: window.location.port,
280
287
  protocol: window.location.protocol
281
288
  },
282
- mainMicroVersion: u,
289
+ mainMicroVersion: w,
283
290
  name: t.name,
284
291
  url: t.url,
285
292
  params: t.params,
@@ -291,12 +298,12 @@ const Q = (e) => {
291
298
  );
292
299
  }
293
300
  });
294
- }, ce = (...t) => h(void 0, [...t], function* (e = {}) {
301
+ }, ne = (...t) => h(void 0, [...t], function* (e = {}) {
295
302
  window[s.MICRO_TYPE] = "child";
296
303
  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) => {
304
+ if (console.debug("child microInit", n, o), n && (window[s.IS_MICRO] = n === "true"), o && S(o).then((r) => {
298
305
  window[s.MICRO_APP] = d({
299
- microVersion: u
306
+ microVersion: w
300
307
  }, r);
301
308
  }), window[s.IS_MICRO]) {
302
309
  let r = function(c) {
@@ -311,15 +318,15 @@ const Q = (e) => {
311
318
  r(`${c} { display: none !important; }`);
312
319
  }) : r(
313
320
  `${e.hideHeaderCssSelector} { display: none !important; }`
314
- )), yield Z(o, window), window.addEventListener("message", (c) => h(void 0, null, function* () {
315
- c.data.cmd === `$xt/micro/${o}` && M(o);
321
+ )), yield oe(o, window), window.addEventListener("message", (c) => h(void 0, null, function* () {
322
+ c.data.cmd === `$xt/micro/${o}` && L(o);
316
323
  }));
317
324
  const a = f(s.MICRO_TOKEN);
318
325
  e.authHandler && a && (yield e.authHandler(a));
319
326
  } else
320
327
  console.warn("当前环境非微应用环境");
321
328
  });
322
- function Z(e, t) {
329
+ function oe(e, t) {
323
330
  const n = t.history, o = n.pushState, r = n.replaceState;
324
331
  n.pushState = function(a, c, i) {
325
332
  const l = y(d(d({}, n.state || {}), a), {
@@ -327,25 +334,22 @@ function Z(e, t) {
327
334
  _patchedByParent: !0
328
335
  // 可选:标记这是被父窗口修改的状态
329
336
  });
330
- o.call(n, l, c, i), M(e);
337
+ o.call(n, l, c, i), L(e);
331
338
  }, n.replaceState = function(a, c, i) {
332
339
  const l = y(d(d({}, n.state || {}), a), {
333
340
  // 添加新数据
334
341
  _patchedByParent: !0
335
342
  // 可选:标记这是被父窗口修改的状态
336
343
  });
337
- r.call(n, l, c, i), M(e);
344
+ r.call(n, l, c, i);
338
345
  };
339
346
  }
340
- function M(e) {
347
+ function L(e) {
341
348
  return h(this, null, function* () {
342
- console.log("syncUrlToWindow", e, window[s.MICRO_APP]), window[s.MICRO_APP] || (yield P(e).then((a) => {
343
- window[s.MICRO_APP] = d({
344
- microVersion: u
345
- }, a);
346
- }));
349
+ if (console.log("syncUrlToWindow", e, window[s.MICRO_APP]), !window[s.MICRO_APP])
350
+ return;
347
351
  const { name: t, sync: n, mainLocation: o } = window[s.MICRO_APP], r = window.location.pathname + window.location.search + window.location.hash;
348
- window.parent.postMessage(
352
+ console.log("curUrl", r), window.parent.postMessage(
349
353
  {
350
354
  cmd: "$xt/micro/sync",
351
355
  data: {
@@ -357,80 +361,105 @@ function M(e) {
357
361
  );
358
362
  });
359
363
  }
360
- let m = {};
361
- const ee = {
364
+ let u = {};
365
+ const re = {
362
366
  url: "",
363
367
  name: "",
364
368
  sync: !0
365
- }, le = (e) => {
369
+ }, ae = (e) => {
366
370
  if (!e.url || e.url === "" || e.url === "undefined") {
367
371
  console.error("app url is required", e);
368
372
  return;
369
373
  }
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), {
372
- instance: new G(e)
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");
377
- }), oe = (e) => {
378
- let t = g(e);
374
+ const t = Object.assign({}, re, e), n = u[e.name];
375
+ return n ? u[e.name] = d(d({}, n), t) : u[e.name] = y(d({}, t), {
376
+ instance: new Z(e)
377
+ }), u[e.name];
378
+ }, _ = (e) => u[e], se = (e, t) => u[e.name] = d(d({}, e), t), b = (e, t) => new Promise((n, o) => {
379
+ let r = _(e);
380
+ r ? (t && (r.instance.changeOptions(t), r = se(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
+ }), T = (e) => {
382
+ let t = _(e);
379
383
  t && t.instance.unmount();
380
- }, de = (e, t = !1) => {
381
- let n = g(e);
384
+ }, ie = (e, t = !1) => {
385
+ let n = _(e);
382
386
  n && n.instance.reload(t);
383
- }, w = (e) => {
387
+ }, m = (e) => {
384
388
  console.log("clearParentUrl", e, s.URL_PARAM_PREFIX + e);
385
389
  const t = window.location.href.split("#");
386
390
  console.log("url", t);
387
- const n = new URL(t[0]);
388
- console.log("mainURL", n), n.searchParams.delete(s.URL_PARAM_PREFIX + e);
391
+ let n = new URL(t[0]);
392
+ n.searchParams.delete(s.URL_PARAM_PREFIX + e);
389
393
  const o = t.length > 1 ? n.href + "#" + t[1] : n.href;
390
394
  return window.history.replaceState({}, "", o), o;
391
- }, re = /* @__PURE__ */ k({
395
+ }, v = () => window[s.IS_MICRO] === !0, ce = () => window[s.MICRO_TYPE] === "parent", le = (e, t = ((n) => (n = window.__XT_MICRO_APP) == null ? void 0 : n.name)()) => {
396
+ let o = window.location;
397
+ if (v())
398
+ o = window.__XT_MICRO_APP.mainLocation;
399
+ else if (!t) {
400
+ console.error("在主应用中需要传入应用名称");
401
+ return;
402
+ }
403
+ return `${o.origin}${o.pathname}?__XT_MICRO_${t}=${encodeURIComponent(e)}${o.hash}`;
404
+ }, de = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
405
+ __proto__: null,
406
+ clearParentUrl: m,
407
+ createAppUrl: le,
408
+ getApp: _,
409
+ isMicro: v,
410
+ isParent: ce,
411
+ microInit: ne,
412
+ reloadApp: ie,
413
+ setupApp: ae,
414
+ startApp: b,
415
+ stopApp: T
416
+ }, Symbol.toStringTag, { value: "Module" })), me = /* @__PURE__ */ N({
392
417
  __name: "XTMicroView",
393
418
  props: {
394
419
  appId: String
395
420
  },
396
421
  setup(e) {
397
- const t = e, n = C(), o = () => {
398
- t.appId && ne(t.appId, {
422
+ const t = e, n = O(), o = () => {
423
+ t.appId && b(t.appId, {
399
424
  el: n.value,
400
425
  onUnload(r, a) {
401
- console.log("on unload", a.app.name), w(a.app.name);
426
+ console.log("on unload", a.app.name), m(a.app.name);
402
427
  }
403
428
  }).then((r) => {
404
429
  console.debug("app mounted", t.appId);
405
430
  });
406
431
  };
407
- return H(() => t.appId, (r, a) => {
408
- r !== a && a && oe(a), o();
409
- }), j(() => {
432
+ return F(() => t.appId, (r, a) => {
433
+ r !== a && a && T(a), o();
434
+ }), B(() => {
410
435
  o();
411
- }), N(() => {
412
- console.debug("「micro」", "app unmount", t.appId), w(t.appId);
413
- }), (r, a) => (V(), B("div", F({
436
+ }), V(() => {
437
+ console.debug("「micro」", "app unmount", t.appId), m(t.appId);
438
+ }), (r, a) => (D(), K("div", Y({
414
439
  ref_key: "refPanel",
415
440
  ref: n
416
441
  }, r.$attrs, { class: "xt-micro" }), null, 16));
417
442
  }
418
443
  });
419
- window[s.MICRO_VERSION] = u;
420
- const pe = {
444
+ window[s.MICRO_VERSION] = w;
445
+ window.api = de;
446
+ const fe = {
421
447
  install: (e, t = {}) => {
422
- e.component("xt-micro-view", re), J();
448
+ e.component("xt-micro-view", me), te();
423
449
  }
424
450
  };
425
451
  export {
426
- re as XTMicroView,
427
- w as clearParentUrl,
428
- pe as default,
429
- g as getApp,
430
- ce as microInit,
431
- de as reloadApp,
432
- le as setupApp,
433
- ne as startApp,
434
- oe as stopApp,
435
- ie as utils
452
+ me as XTMicroView,
453
+ m as clearParentUrl,
454
+ le as createAppUrl,
455
+ fe as default,
456
+ _ as getApp,
457
+ v as isMicro,
458
+ ce as isParent,
459
+ ne as microInit,
460
+ ie as reloadApp,
461
+ ae as setupApp,
462
+ b as startApp,
463
+ T as stopApp,
464
+ he as utils
436
465
  };
@@ -20,4 +20,13 @@ export declare const startApp: (name: string, options?: Partial<AppOption>) => P
20
20
  export declare const stopApp: (name: string) => void;
21
21
  export declare const reloadApp: (name: string, isGoHome?: boolean) => void;
22
22
  export declare const clearParentUrl: (appName: string) => string;
23
+ export declare const isMicro: () => boolean;
24
+ export declare const isParent: () => boolean;
25
+ /**
26
+ * 创建基于主应用路由的某个子应用的 url
27
+ * @param appName 应用名称
28
+ * @param targetUrlHash 应用地址
29
+ * @returns
30
+ */
31
+ export declare const createAppUrl: (targetUrlHash: string, appName?: string) => string;
23
32
  export { microInit };
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@xingtukeji/micro",
3
- "version": "1.1.17",
3
+ "version": "1.1.18",
4
4
  "private": false,
5
5
  "description": "",
6
- "main": "dist/index.js",
6
+ "main": "src/index.ts",
7
7
  "types": "dist/types/index.d.ts",
8
8
  "files": [
9
9
  "dist"
package/src/index.ts ADDED
@@ -0,0 +1,21 @@
1
+ import type { App } from "vue";
2
+ import XTMicroView from "./components/XTMicroView.vue";
3
+
4
+ import { mainMicroInit } from "./parent";
5
+ export * from "./api";
6
+ import * as utils from "./utils";
7
+
8
+ export { XTMicroView, utils };
9
+ import { version } from "../package.json";
10
+ import { CONSTANT } from "./types";
11
+ window[CONSTANT.MICRO_VERSION] = version;
12
+ //temp test
13
+ import * as api from "./api";
14
+ window["api"] = api;
15
+
16
+ export default {
17
+ install: (app: App, _options: any = {}) => {
18
+ app.component("xt-micro-view", XTMicroView);
19
+ mainMicroInit();
20
+ },
21
+ };