@xingtukeji/micro 1.1.14 → 1.1.15

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.
Files changed (2) hide show
  1. package/dist/index.js +37 -37
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -11,8 +11,8 @@ var R = (e, t, n) => t in e ? A(e, t, { enumerable: !0, configurable: !0, writab
11
11
  X.call(t, n) && R(e, n, t[n]);
12
12
  return e;
13
13
  }, _ = (e, t) => T(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((r, o) => {
14
+ var m = (e, t, n) => (R(e, typeof t != "symbol" ? t + "" : t, n), n);
15
+ var u = (e, t, n) => new Promise((r, o) => {
16
16
  var a = (l) => {
17
17
  try {
18
18
  i(n.next(l));
@@ -48,7 +48,7 @@ const s = {
48
48
  // 微应用在 url 参数中的前缀
49
49
  MICRO_VERSION: "__XT_MICRO_VERSION"
50
50
  // 微应用版本
51
- }, u = "1.1.13";
51
+ }, h = "1.1.14";
52
52
  function f(e, t = window.location.href) {
53
53
  e = e.replace(/[\[\]]/g, "\\$&");
54
54
  var n = new RegExp("[?&]" + e + "(=([^&#]*)|&|#|$)"), r = n.exec(t);
@@ -82,11 +82,11 @@ function U(e, t, n) {
82
82
  const [r, o] = e.split("#"), a = new URL(r), c = a.searchParams;
83
83
  return t = s.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();
84
84
  }
85
- const P = (e) => h(void 0, null, function* () {
85
+ const P = (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
  {
@@ -133,7 +133,7 @@ const I = (e) => `${s.DOM_ID_PREFIX}${e}`, L = (e, t = !1) => {
133
133
  if (a.searchParams.set(s.IS_MICRO, !0 + ""), a.searchParams.set(s.MICRO_NAME, e.name), o && a.searchParams.set(s.MICRO_TOKEN, o), r)
134
134
  for (let i of Object.keys(r))
135
135
  a.searchParams.set(i, r[i]);
136
- return g(e.name), a.href;
136
+ return y(e.name), a.href;
137
137
  }, Y = () => {
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;
@@ -164,11 +164,11 @@ const I = (e) => `${s.DOM_ID_PREFIX}${e}`, L = (e, t = !1) => {
164
164
  };
165
165
  class G {
166
166
  constructor(t) {
167
- p(this, "app");
168
- p(this, "dom");
169
- p(this, "panel");
170
- p(this, "loading");
171
- p(this, "loadingTimer");
167
+ m(this, "app");
168
+ m(this, "dom");
169
+ m(this, "panel");
170
+ m(this, "loading");
171
+ m(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) {
@@ -211,7 +211,7 @@ class G {
211
211
  let n = this.dom.src;
212
212
  t && (n = L(this.app, !0), console.log("go home", n)), console.log("reload app", this.app, n);
213
213
  const r = new URL(n);
214
- r.searchParams.set("__t", Date.now().toString()), this.dom.src = r.toString();
214
+ r.searchParams.set("__t", Date.now().toString()), this.dom.style.visibility = "hidden", this.dom.src = r.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), g(this.app.name), this.app.onUnload && this.app.onUnload(t, this);
223
+ console.debug("app onUnload", this.app.name), y(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);
@@ -267,7 +267,7 @@ const Q = (e) => {
267
267
  window.history.replaceState(null, "", o);
268
268
  } else if (e.data.cmd === "$xt/micro/info") {
269
269
  console.debug("parent 「$xt/micro/info」 receive message", e.data);
270
- const t = y(e.data.data);
270
+ const t = g(e.data.data);
271
271
  e.source.postMessage(
272
272
  {
273
273
  cmd: "$xt/micro/info",
@@ -283,7 +283,7 @@ const Q = (e) => {
283
283
  port: window.location.port,
284
284
  protocol: window.location.protocol
285
285
  },
286
- mainMicroVersion: u,
286
+ mainMicroVersion: h,
287
287
  name: t.name,
288
288
  url: t.url,
289
289
  params: t.params,
@@ -295,12 +295,12 @@ const Q = (e) => {
295
295
  );
296
296
  }
297
297
  });
298
- }, ce = (...t) => h(void 0, [...t], function* (e = {}) {
298
+ }, ce = (...t) => u(void 0, [...t], function* (e = {}) {
299
299
  window[s.MICRO_TYPE] = "child";
300
300
  const n = f(s.IS_MICRO), r = f(s.MICRO_NAME);
301
301
  if (console.debug("child microInit", n, r), n && (window[s.IS_MICRO] = n === "true"), r && P(r).then((o) => {
302
302
  window[s.MICRO_APP] = d({
303
- microVersion: u
303
+ microVersion: h
304
304
  }, o);
305
305
  }), window[s.IS_MICRO]) {
306
306
  let o = function(c) {
@@ -315,7 +315,7 @@ const Q = (e) => {
315
315
  o(`${c} { display: none !important; }`);
316
316
  }) : o(
317
317
  `${e.hideHeaderCssSelector} { display: none !important; }`
318
- )), yield Z(r, window), window.addEventListener("message", (c) => h(void 0, null, function* () {
318
+ )), yield Z(r, window), window.addEventListener("message", (c) => u(void 0, null, function* () {
319
319
  c.data.cmd === `$xt/micro/${r}` && M(r);
320
320
  }));
321
321
  const a = f(s.MICRO_TOKEN);
@@ -342,10 +342,10 @@ function Z(e, t) {
342
342
  };
343
343
  }
344
344
  function M(e) {
345
- return h(this, null, function* () {
345
+ return u(this, null, function* () {
346
346
  console.log("syncUrlToWindow", e, window[s.MICRO_APP]), window[s.MICRO_APP] || (yield P(e).then((a) => {
347
347
  window[s.MICRO_APP] = d({
348
- microVersion: u
348
+ microVersion: h
349
349
  }, a);
350
350
  }));
351
351
  const { name: t, sync: n, mainLocation: r } = window[s.MICRO_APP], o = window.location.pathname + window.location.search + window.location.hash;
@@ -361,7 +361,7 @@ function M(e) {
361
361
  );
362
362
  });
363
363
  }
364
- let m = {};
364
+ let p = {};
365
365
  const ee = {
366
366
  url: "",
367
367
  name: "",
@@ -371,20 +371,20 @@ const ee = {
371
371
  console.error("app url is required", e);
372
372
  return;
373
373
  }
374
- const t = Object.assign({}, ee, e), n = m[e.name];
375
- return n ? m[e.name] = d(d({}, n), t) : m[e.name] = _(d({}, t), {
374
+ const t = Object.assign({}, ee, e), n = p[e.name];
375
+ return n ? p[e.name] = d(d({}, n), t) : p[e.name] = _(d({}, t), {
376
376
  instance: new G(e)
377
- }), m[e.name];
378
- }, y = (e) => m[e], te = (e, t) => m[e.name] = d(d({}, e), t), ne = (e, t) => new Promise((n, r) => {
379
- let o = y(e);
377
+ }), p[e.name];
378
+ }, g = (e) => p[e], te = (e, t) => p[e.name] = d(d({}, e), t), ne = (e, t) => new Promise((n, r) => {
379
+ let o = g(e);
380
380
  o ? (t && (o.instance.changeOptions(t), o = te(o, t)), o.preload ? o.instance.preloadRender(o.el) : o.instance.mount(o.el), n(o)) : r("app not found, please setup app first");
381
381
  }), oe = (e) => {
382
- let t = y(e);
382
+ let t = g(e);
383
383
  t && t.instance.unmount();
384
384
  }, de = (e, t = !1) => {
385
- let n = y(e);
385
+ let n = g(e);
386
386
  n && n.instance.reload(t);
387
- }, g = (e) => {
387
+ }, y = (e) => {
388
388
  console.log("clearParentUrl", e, s.URL_PARAM_PREFIX + e);
389
389
  const t = window.location.href.split("#");
390
390
  console.log("url", t);
@@ -404,7 +404,7 @@ const ee = {
404
404
  t.appId && ne(t.appId, {
405
405
  el: n.value,
406
406
  onUnload(o, a) {
407
- console.log("on unload", a.app.name), g(a.app.name);
407
+ console.log("on unload", a.app.name), y(a.app.name);
408
408
  }
409
409
  }).then((o) => {
410
410
  console.debug("app mounted", t.appId);
@@ -415,24 +415,24 @@ const ee = {
415
415
  }), j(() => {
416
416
  r();
417
417
  }), F(() => {
418
- console.debug("「micro」", "app unmount", t.appId), g(t.appId);
418
+ console.debug("「micro」", "app unmount", t.appId), y(t.appId);
419
419
  }), (o, a) => (N(), V("div", B({
420
420
  ref_key: "refPanel",
421
421
  ref: n
422
422
  }, o.$attrs, { class: "xt-micro" }), null, 16));
423
423
  }
424
424
  });
425
- window[s.MICRO_VERSION] = u;
426
- const pe = {
425
+ window[s.MICRO_VERSION] = h;
426
+ const me = {
427
427
  install: (e, t = {}) => {
428
428
  e.component("xt-micro-view", re), J();
429
429
  }
430
430
  };
431
431
  export {
432
432
  re as XTMicroView,
433
- g as clearParentUrl,
434
- pe as default,
435
- y as getApp,
433
+ y as clearParentUrl,
434
+ me as default,
435
+ g as getApp,
436
436
  ce as microInit,
437
437
  de as reloadApp,
438
438
  le as setupApp,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xingtukeji/micro",
3
- "version": "1.1.14",
3
+ "version": "1.1.15",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "main": "dist/index.js",