@trimjs/web-app 0.1.2 → 0.1.4

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,33 +1,33 @@
1
1
  var $e = Object.defineProperty, Pe = Object.defineProperties;
2
2
  var Me = Object.getOwnPropertyDescriptors;
3
3
  var ee = Object.getOwnPropertySymbols;
4
- var _e = Object.prototype.hasOwnProperty, Ce = Object.prototype.propertyIsEnumerable;
5
- var B = (n, e, t) => e in n ? $e(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, D = (n, e) => {
4
+ var Ce = Object.prototype.hasOwnProperty, Fe = Object.prototype.propertyIsEnumerable;
5
+ var B = (r, e, t) => e in r ? $e(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, D = (r, e) => {
6
6
  for (var t in e || (e = {}))
7
- _e.call(e, t) && B(n, t, e[t]);
7
+ Ce.call(e, t) && B(r, t, e[t]);
8
8
  if (ee)
9
9
  for (var t of ee(e))
10
- Ce.call(e, t) && B(n, t, e[t]);
11
- return n;
12
- }, V = (n, e) => Pe(n, Me(e));
13
- var $ = (n, e, t) => B(n, typeof e != "symbol" ? e + "" : e, t);
14
- var w = (n, e, t) => new Promise((r, i) => {
15
- var o = (a) => {
10
+ Fe.call(e, t) && B(r, t, e[t]);
11
+ return r;
12
+ }, j = (r, e) => Pe(r, Me(e));
13
+ var $ = (r, e, t) => B(r, typeof e != "symbol" ? e + "" : e, t);
14
+ var w = (r, e, t) => new Promise((n, o) => {
15
+ var i = (a) => {
16
16
  try {
17
17
  c(t.next(a));
18
18
  } catch (h) {
19
- i(h);
19
+ o(h);
20
20
  }
21
21
  }, s = (a) => {
22
22
  try {
23
23
  c(t.throw(a));
24
24
  } catch (h) {
25
- i(h);
25
+ o(h);
26
26
  }
27
- }, c = (a) => a.done ? r(a.value) : Promise.resolve(a.value).then(o, s);
28
- c((t = t.apply(n, e)).next());
27
+ }, c = (a) => a.done ? n(a.value) : Promise.resolve(a.value).then(i, s);
28
+ c((t = t.apply(r, e)).next());
29
29
  });
30
- class Fe {
30
+ class Te {
31
31
  constructor() {
32
32
  $(this, "debug", !1);
33
33
  }
@@ -48,144 +48,160 @@ class Fe {
48
48
  * 输出日志(只在 debug 模式下)
49
49
  * @param args 日志参数
50
50
  */
51
- log(...e) {
52
- this.debug && console.log("[Trim App]", ...e);
51
+ log() {
52
+ if (this.debug) {
53
+ for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
54
+ t[n] = arguments[n];
55
+ console.log("[Trim App]", ...t);
56
+ }
53
57
  }
54
58
  /**
55
59
  * 输出警告日志(只在 debug 模式下)
56
60
  * @param args 日志参数
57
61
  */
58
- warn(...e) {
59
- this.debug && console.warn("[Trim App]", ...e);
62
+ warn() {
63
+ if (this.debug) {
64
+ for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
65
+ t[n] = arguments[n];
66
+ console.warn("[Trim App]", ...t);
67
+ }
60
68
  }
61
69
  /**
62
70
  * 输出错误日志(只在 debug 模式下)
63
71
  * @param args 日志参数
64
72
  */
65
- error(...e) {
66
- this.debug && console.error("[Trim App]", ...e);
73
+ error() {
74
+ if (this.debug) {
75
+ for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
76
+ t[n] = arguments[n];
77
+ console.error("[Trim App]", ...t);
78
+ }
67
79
  }
68
80
  /**
69
81
  * 输出信息日志(只在 debug 模式下)
70
82
  * @param args 日志参数
71
83
  */
72
- info(...e) {
73
- this.debug && console.info("[Trim App]", ...e);
84
+ info() {
85
+ if (this.debug) {
86
+ for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
87
+ t[n] = arguments[n];
88
+ console.info("[Trim App]", ...t);
89
+ }
74
90
  }
75
91
  }
76
- const d = new Fe();
77
- function Te(n) {
92
+ const d = new Te();
93
+ function _e(r) {
78
94
  const e = /FNOS\/([\d.]+)|FNAppType\/(\w+)|FNAppVer\/([\d.]+)/g, t = {};
79
- let r;
80
- for (; (r = e.exec(n)) !== null; )
81
- r[1] && (t.fnOSVersion = r[1]), r[2] && (t.fnAppType = r[2]), r[3] && (t.fnAppVersion = r[3]);
95
+ let n;
96
+ for (; (n = e.exec(r)) !== null; )
97
+ n[1] && (t.fnOSVersion = n[1]), n[2] && (t.fnAppType = n[2]), n[3] && (t.fnAppVersion = n[3]);
82
98
  return t;
83
99
  }
84
- const pe = () => Te(navigator.userAgent).fnAppVersion;
100
+ const pe = () => _e(navigator.userAgent).fnAppVersion;
85
101
  let de = !1;
86
102
  window.addEventListener("flutterInAppWebViewPlatformReady", () => {
87
103
  de = !0;
88
104
  });
89
- const Oe = () => new Promise((n) => {
105
+ const Oe = () => new Promise((r) => {
90
106
  var e;
91
- de || (e = window.flutter_inappwebview) != null && e._platformReady ? (d.log("flutter_inappwebview is ready"), n(window.flutter_inappwebview)) : window.addEventListener("flutterInAppWebViewPlatformReady", () => {
92
- d.log("flutter_inappwebview is ready"), n(window.flutter_inappwebview);
107
+ de || (e = window.flutter_inappwebview) != null && e._platformReady ? (d.log("flutter_inappwebview is ready"), r(window.flutter_inappwebview)) : window.addEventListener("flutterInAppWebViewPlatformReady", () => {
108
+ d.log("flutter_inappwebview is ready"), r(window.flutter_inappwebview);
93
109
  });
94
- }), Re = (n, e, t) => w(void 0, null, function* () {
110
+ }), Re = (r, e, t) => w(void 0, null, function* () {
95
111
  d.log(`callHandler: ${e}, params: ${t}`);
96
- const r = yield n.callHandler(e, t);
97
- if (r)
112
+ const n = yield r.callHandler(e, t);
113
+ if (n)
98
114
  try {
99
- const i = JSON.parse(r);
100
- d.log(`messageData: ${JSON.stringify(i)}`);
101
- const o = JSON.parse(i.result);
102
- return d.log(`appMessage: ${JSON.stringify(o)}`), o;
103
- } catch (i) {
104
- return d.error(`error: ${i}`), null;
115
+ const o = JSON.parse(n);
116
+ d.log(`messageData: ${JSON.stringify(o)}`);
117
+ const i = JSON.parse(o.result);
118
+ return d.log(`appMessage: ${JSON.stringify(i)}`), i;
119
+ } catch (o) {
120
+ return d.error(`error: ${o}`), null;
105
121
  }
106
122
  return null;
107
123
  }), te = /* @__PURE__ */ new Map();
108
124
  function xe() {
109
- window.fnAppMessage = (n) => {
110
- d.log("app-message", n);
111
- const e = JSON.parse(n), t = te.get(e.reqId);
125
+ window.fnAppMessage = (r) => {
126
+ d.log("app-message", r);
127
+ const e = JSON.parse(r), t = te.get(e.reqId);
112
128
  t && (t(e), te.delete(e.reqId));
113
129
  };
114
130
  }
115
131
  pe() && xe();
116
- var O = /* @__PURE__ */ ((n) => (n.Call = "call", n.Reply = "reply", n.Syn = "syn", n.SynAck = "synAck", n.Ack = "ack", n))(O || {}), W = /* @__PURE__ */ ((n) => (n.Fulfilled = "fulfilled", n.Rejected = "rejected", n))(W || {}), X = /* @__PURE__ */ ((n) => (n.ConnectionDestroyed = "ConnectionDestroyed", n.ConnectionTimeout = "ConnectionTimeout", n.NoIframeSrc = "NoIframeSrc", n))(X || {}), he = /* @__PURE__ */ ((n) => (n.DataCloneError = "DataCloneError", n))(he || {}), I = /* @__PURE__ */ ((n) => (n.Message = "message", n))(I || {});
117
- const De = (n, e) => {
132
+ var O = /* @__PURE__ */ ((r) => (r.Call = "call", r.Reply = "reply", r.Syn = "syn", r.SynAck = "synAck", r.Ack = "ack", r))(O || {}), q = /* @__PURE__ */ ((r) => (r.Fulfilled = "fulfilled", r.Rejected = "rejected", r))(q || {}), X = /* @__PURE__ */ ((r) => (r.ConnectionDestroyed = "ConnectionDestroyed", r.ConnectionTimeout = "ConnectionTimeout", r.NoIframeSrc = "NoIframeSrc", r))(X || {}), he = /* @__PURE__ */ ((r) => (r.DataCloneError = "DataCloneError", r))(he || {}), I = /* @__PURE__ */ ((r) => (r.Message = "message", r))(I || {});
133
+ const De = (r, e) => {
118
134
  const t = [];
119
- let r = !1;
135
+ let n = !1;
120
136
  return {
121
- destroy(i) {
122
- r || (r = !0, e(`${n}: Destroying connection`), t.forEach((o) => {
123
- o(i);
137
+ destroy(o) {
138
+ n || (n = !0, e(`${r}: Destroying connection`), t.forEach((i) => {
139
+ i(o);
124
140
  }));
125
141
  },
126
- onDestroy(i) {
127
- r ? i() : t.push(i);
142
+ onDestroy(o) {
143
+ n ? o() : t.push(o);
128
144
  }
129
145
  };
130
- }, Ie = (n) => (...e) => {
131
- n && console.log("[Penpal]", ...e);
132
- }, ne = ({
133
- name: n,
146
+ }, Ie = (r) => (...e) => {
147
+ r && console.log("[Penpal]", ...e);
148
+ }, re = ({
149
+ name: r,
134
150
  message: e,
135
151
  stack: t
136
152
  }) => ({
137
- name: n,
153
+ name: r,
138
154
  message: e,
139
155
  stack: t
140
- }), ke = (n) => {
156
+ }), Ve = (r) => {
141
157
  const e = new Error();
142
- return Object.keys(n).forEach((t) => e[t] = n[t]), e;
143
- }, Ve = (n, e, t) => {
158
+ return Object.keys(r).forEach((t) => e[t] = r[t]), e;
159
+ }, je = (r, e, t) => {
144
160
  const {
145
- localName: r,
146
- local: i,
147
- remote: o,
161
+ localName: n,
162
+ local: o,
163
+ remote: i,
148
164
  originForSending: s,
149
165
  originForReceiving: c
150
- } = n;
166
+ } = r;
151
167
  let a = !1;
152
168
  const h = (v) => {
153
- if (v.source !== o || v.data.penpal !== O.Call)
169
+ if (v.source !== i || v.data.penpal !== O.Call)
154
170
  return;
155
171
  if (c !== "*" && v.origin !== c) {
156
172
  t(
157
- `${r} received message from origin ${v.origin} which did not match expected origin ${c}`
173
+ `${n} received message from origin ${v.origin} which did not match expected origin ${c}`
158
174
  );
159
175
  return;
160
176
  }
161
- const S = v.data, { methodName: g, args: p, id: b } = S;
162
- t(`${r}: Received ${g}() call`);
163
- const l = (y) => (A) => {
164
- if (t(`${r}: Sending ${g}() reply`), a) {
177
+ const A = v.data, { methodName: g, args: p, id: m } = A;
178
+ t(`${n}: Received ${g}() call`);
179
+ const l = (y) => (S) => {
180
+ if (t(`${n}: Sending ${g}() reply`), a) {
165
181
  t(
166
- `${r}: Unable to send ${g}() reply due to destroyed connection`
182
+ `${n}: Unable to send ${g}() reply due to destroyed connection`
167
183
  );
168
184
  return;
169
185
  }
170
186
  const P = {
171
187
  penpal: O.Reply,
172
- id: b,
188
+ id: m,
173
189
  resolution: y,
174
- returnValue: A
190
+ returnValue: S
175
191
  };
176
- y === W.Rejected && A instanceof Error && (P.returnValue = ne(A), P.returnValueIsError = !0);
192
+ y === q.Rejected && S instanceof Error && (P.returnValue = re(S), P.returnValueIsError = !0);
177
193
  try {
178
- o.postMessage(P, s);
194
+ i.postMessage(P, s);
179
195
  } catch (M) {
180
196
  if (M.name === he.DataCloneError) {
181
- const _ = {
197
+ const C = {
182
198
  penpal: O.Reply,
183
- id: b,
184
- resolution: W.Rejected,
185
- returnValue: ne(M),
199
+ id: m,
200
+ resolution: q.Rejected,
201
+ returnValue: re(M),
186
202
  returnValueIsError: !0
187
203
  };
188
- o.postMessage(_, s);
204
+ i.postMessage(C, s);
189
205
  }
190
206
  throw M;
191
207
  }
@@ -193,97 +209,97 @@ const De = (n, e) => {
193
209
  new Promise(
194
210
  (y) => y(e[g].apply(e, p))
195
211
  ).then(
196
- l(W.Fulfilled),
197
- l(W.Rejected)
212
+ l(q.Fulfilled),
213
+ l(q.Rejected)
198
214
  );
199
215
  };
200
- return i.addEventListener(I.Message, h), () => {
201
- a = !0, i.removeEventListener(I.Message, h);
216
+ return o.addEventListener(I.Message, h), () => {
217
+ a = !0, o.removeEventListener(I.Message, h);
202
218
  };
203
219
  };
204
- let je = 0;
205
- const We = () => ++je, ge = ".", ye = (n) => n ? n.split(ge) : [], qe = (n) => n.join(ge), Le = (n, e) => {
220
+ let We = 0;
221
+ const qe = () => ++We, ge = ".", ye = (r) => r ? r.split(ge) : [], Ne = (r) => r.join(ge), Le = (r, e) => {
206
222
  const t = ye(e || "");
207
- return t.push(n), qe(t);
208
- }, Ne = (n, e, t) => {
209
- const r = ye(e);
210
- return r.reduce((i, o, s) => (typeof i[o] == "undefined" && (i[o] = {}), s === r.length - 1 && (i[o] = t), i[o]), n), n;
211
- }, be = (n, e) => {
223
+ return t.push(r), Ne(t);
224
+ }, He = (r, e, t) => {
225
+ const n = ye(e);
226
+ return n.reduce((o, i, s) => (typeof o[i] == "undefined" && (o[i] = {}), s === n.length - 1 && (o[i] = t), o[i]), r), r;
227
+ }, me = (r, e) => {
212
228
  const t = {};
213
- return Object.keys(n).forEach((r) => {
214
- const i = n[r], o = Le(r, e);
215
- typeof i == "object" && Object.assign(t, be(i, o)), typeof i == "function" && (t[o] = i);
229
+ return Object.keys(r).forEach((n) => {
230
+ const o = r[n], i = Le(n, e);
231
+ typeof o == "object" && Object.assign(t, me(o, i)), typeof o == "function" && (t[i] = o);
216
232
  }), t;
217
- }, He = (n) => {
233
+ }, ke = (r) => {
218
234
  const e = {};
219
- for (const t in n)
220
- Ne(e, t, n[t]);
235
+ for (const t in r)
236
+ He(e, t, r[t]);
221
237
  return e;
222
- }, Ue = (n, e, t, r, i) => {
238
+ }, Ue = (r, e, t, n, o) => {
223
239
  const {
224
- localName: o,
240
+ localName: i,
225
241
  local: s,
226
242
  remote: c,
227
243
  originForSending: a,
228
244
  originForReceiving: h
229
245
  } = e;
230
246
  let v = !1;
231
- i(`${o}: Connecting call sender`);
232
- const S = (p) => (...b) => {
233
- i(`${o}: Sending ${p}() call`);
247
+ o(`${i}: Connecting call sender`);
248
+ const A = (p) => (...m) => {
249
+ o(`${i}: Sending ${p}() call`);
234
250
  let l;
235
251
  try {
236
252
  c.closed && (l = !0);
237
253
  } catch (y) {
238
254
  l = !0;
239
255
  }
240
- if (l && r(), v) {
256
+ if (l && n(), v) {
241
257
  const y = new Error(
242
258
  `Unable to send ${p}() call due to destroyed connection`
243
259
  );
244
260
  throw y.code = X.ConnectionDestroyed, y;
245
261
  }
246
- return new Promise((y, A) => {
247
- const P = We(), M = (C) => {
248
- if (C.source !== c || C.data.penpal !== O.Reply || C.data.id !== P)
262
+ return new Promise((y, S) => {
263
+ const P = qe(), M = (F) => {
264
+ if (F.source !== c || F.data.penpal !== O.Reply || F.data.id !== P)
249
265
  return;
250
- if (h !== "*" && C.origin !== h) {
251
- i(
252
- `${o} received message from origin ${C.origin} which did not match expected origin ${h}`
266
+ if (h !== "*" && F.origin !== h) {
267
+ o(
268
+ `${i} received message from origin ${F.origin} which did not match expected origin ${h}`
253
269
  );
254
270
  return;
255
271
  }
256
- const q = C.data;
257
- i(`${o}: Received ${p}() reply`), s.removeEventListener(
272
+ const N = F.data;
273
+ o(`${i}: Received ${p}() reply`), s.removeEventListener(
258
274
  I.Message,
259
275
  M
260
276
  );
261
- let L = q.returnValue;
262
- q.returnValueIsError && (L = ke(L)), (q.resolution === W.Fulfilled ? y : A)(
277
+ let L = N.returnValue;
278
+ N.returnValueIsError && (L = Ve(L)), (N.resolution === q.Fulfilled ? y : S)(
263
279
  L
264
280
  );
265
281
  };
266
282
  s.addEventListener(I.Message, M);
267
- const _ = {
283
+ const C = {
268
284
  penpal: O.Call,
269
285
  id: P,
270
286
  methodName: p,
271
- args: b
287
+ args: m
272
288
  };
273
- c.postMessage(_, a);
289
+ c.postMessage(C, a);
274
290
  });
275
- }, g = t.reduce((p, b) => (p[b] = S(b), p), {});
276
- return Object.assign(n, He(g)), () => {
291
+ }, g = t.reduce((p, m) => (p[m] = A(m), p), {});
292
+ return Object.assign(r, ke(g)), () => {
277
293
  v = !0;
278
294
  };
279
- }, Be = (n, e) => {
295
+ }, Be = (r, e) => {
280
296
  let t;
281
- return n !== void 0 && (t = window.setTimeout(() => {
282
- const r = new Error(
283
- `Connection timed out after ${n}ms`
297
+ return r !== void 0 && (t = window.setTimeout(() => {
298
+ const n = new Error(
299
+ `Connection timed out after ${r}ms`
284
300
  );
285
- r.code = X.ConnectionTimeout, e(r);
286
- }, n)), () => {
301
+ n.code = X.ConnectionTimeout, e(n);
302
+ }, r)), () => {
287
303
  clearTimeout(t);
288
304
  };
289
305
  }, Je = "@fn/micro-app-postmate", Ye = "0.1.2", ze = "module", Ke = "src/index.ts", Qe = {
@@ -317,51 +333,51 @@ const We = () => ++je, ge = ".", ye = (n) => n ? n.split(ge) : [], qe = (n) => n
317
333
  peerDependencies: Xe,
318
334
  devDependencies: Ze,
319
335
  publishConfig: et
320
- }, nt = (n, e, t, r, i) => {
321
- const { destroy: o, onDestroy: s } = r;
336
+ }, rt = (r, e, t, n, o) => {
337
+ const { destroy: i, onDestroy: s } = n;
322
338
  return (c) => {
323
- if (!(n instanceof RegExp ? n.test(c.origin) : n === "*" || n === c.origin)) {
324
- i(
325
- `Child: Handshake - Received SYN-ACK from origin ${c.origin} which did not match expected origin ${n}`
339
+ if (!(r instanceof RegExp ? r.test(c.origin) : r === "*" || r === c.origin)) {
340
+ o(
341
+ `Child: Handshake - Received SYN-ACK from origin ${c.origin} which did not match expected origin ${r}`
326
342
  );
327
343
  return;
328
344
  }
329
- i("Child: Handshake - Received SYN-ACK, responding with ACK");
345
+ o("Child: Handshake - Received SYN-ACK, responding with ACK");
330
346
  const h = c.origin === "null" ? "*" : c.origin, v = {
331
347
  penpal: O.Ack,
332
348
  methodNames: Object.keys(e),
333
349
  config: t
334
350
  };
335
351
  window.parent.postMessage(v, h);
336
- const S = {
352
+ const A = {
337
353
  localName: "Child",
338
354
  local: window,
339
355
  remote: window.parent,
340
356
  originForSending: h,
341
357
  originForReceiving: c.origin
342
- }, g = Ve(
343
- S,
358
+ }, g = je(
359
+ A,
344
360
  e,
345
- i
361
+ o
346
362
  );
347
363
  s(g);
348
- const p = {}, b = Ue(
364
+ const p = {}, m = Ue(
349
365
  p,
350
- S,
366
+ A,
351
367
  c.data.methodNames,
352
- o,
353
- i
368
+ i,
369
+ o
354
370
  );
355
- return s(b), p;
371
+ return s(m), p;
356
372
  };
357
373
  };
358
- function re(n, e) {
359
- console == null || console.warn(`[fnApp warn]: ${n}`, e);
374
+ function ne(r, e) {
375
+ console == null || console.warn(`[fnApp warn]: ${r}`, e);
360
376
  }
361
- function ie(n, e) {
362
- console == null || console.error(`[fnApp error]: ${n}`, e);
377
+ function ie(r, e) {
378
+ console == null || console.error(`[fnApp error]: ${r}`, e);
363
379
  }
364
- const j = "_fn_all_event", oe = "事件订阅数量为空", N = window.__POWERED_BY_FNAPP__ ? window.__FNAPP.inject.appEventObjMap : /* @__PURE__ */ new Map();
380
+ const W = "_fn_all_event", oe = "事件订阅数量为空", H = window.__POWERED_BY_FNAPP__ ? window.__FNAPP.inject.appEventObjMap : /* @__PURE__ */ new Map();
365
381
  class se {
366
382
  constructor(e, t) {
367
383
  $(this, "id");
@@ -371,16 +387,16 @@ class se {
371
387
  var t;
372
388
  return ((t = this.eventObj[e]) == null ? void 0 : t.length) || 0;
373
389
  });
374
- console.log("id", e, t), this.id = e, this.appName = t, this.$clear(), N.get(this.id) || N.set(this.id, {}), this.eventObj = N.get(this.id);
390
+ this.id = e, this.appName = t, this.$clear(), H.get(this.id) || H.set(this.id, {}), this.eventObj = H.get(this.id);
375
391
  }
376
392
  // 监听事件
377
393
  $on(e, t) {
378
- const r = this.eventObj[e];
379
- return r ? (r.includes(t) || r.push(t), this) : (this.eventObj[e] = [t], this);
394
+ const n = this.eventObj[e];
395
+ return n ? (n.includes(t) || n.push(t), this) : (this.eventObj[e] = [t], this);
380
396
  }
381
397
  /** 任何$emit都会导致监听函数触发,第一个参数为事件名,后续的参数为$emit的参数 */
382
398
  $onAll(e) {
383
- return this.$on(j, e);
399
+ return this.$on(W, e);
384
400
  }
385
401
  // 一次性监听事件
386
402
  $once(e, t) {
@@ -388,20 +404,20 @@ class se {
388
404
  }
389
405
  // 取消监听
390
406
  $off(e, t) {
391
- const r = this.eventObj[e];
392
- if (!e || !r || !r.length)
393
- return re(`${e} ${oe}`), this;
394
- let i, o = r.length;
395
- for (; o--; )
396
- if (i = r[o], i === t) {
397
- r.splice(o, 1);
407
+ const n = this.eventObj[e];
408
+ if (!e || !n || !n.length)
409
+ return ne(`${e} ${oe}`), this;
410
+ let o, i = n.length;
411
+ for (; i--; )
412
+ if (o = n[i], o === t) {
413
+ n.splice(i, 1);
398
414
  break;
399
415
  }
400
416
  return this;
401
417
  }
402
418
  // 取消监听$onAll
403
419
  $offAll(e) {
404
- return this.$off(j, e);
420
+ return this.$off(W, e);
405
421
  }
406
422
  // 发送事件
407
423
  $emit(e, ...t) {
@@ -409,117 +425,116 @@ class se {
409
425
  }
410
426
  // 发送事件
411
427
  $pureEmit(e, ...t) {
412
- let r = 0, i = 0;
413
- return N.forEach((o) => {
414
- if (o[e])
415
- for (let s = o[e].length - 1; s >= 0; s--) {
416
- r++;
417
- const c = o[e][s];
418
- c.$__once && o[e].splice(s, 1);
428
+ let n = 0, o = 0;
429
+ return H.forEach((i) => {
430
+ if (i[e])
431
+ for (let s = i[e].length - 1; s >= 0; s--) {
432
+ n++;
433
+ const c = i[e][s];
434
+ c.$__once && i[e].splice(s, 1);
419
435
  try {
420
436
  c(...t);
421
437
  } catch (a) {
422
438
  ie(a);
423
439
  }
424
440
  }
425
- if (o[j])
426
- for (let s = o[j].length - 1; s >= 0; s--) {
427
- r++;
428
- const c = o[j][s];
429
- c.$__once && o[j].splice(s, 1);
441
+ if (i[W])
442
+ for (let s = i[W].length - 1; s >= 0; s--) {
443
+ n++;
444
+ const c = i[W][s];
445
+ c.$__once && i[W].splice(s, 1);
430
446
  try {
431
447
  c(...t);
432
448
  } catch (a) {
433
449
  ie(a);
434
450
  }
435
451
  }
436
- }), (!e || r === 0 && i === 0) && re(`${e} ${oe}`), this;
452
+ }), (!e || n === 0 && o === 0) && ne(`${e} ${oe}`), this;
437
453
  }
438
454
  // 清空当前所有的监听事件
439
455
  $clear() {
440
- var r;
441
- const e = (r = N.get(this.id)) != null ? r : {};
442
- return Object.keys(e).forEach((i) => delete e[i]), this;
456
+ const e = H.get(this.id) || {};
457
+ return Object.keys(e).forEach((n) => delete e[n]), this;
443
458
  }
444
459
  }
445
- var z = function(n, e) {
446
- return z = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, r) {
447
- t.__proto__ = r;
448
- } || function(t, r) {
449
- for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (t[i] = r[i]);
450
- }, z(n, e);
460
+ var z = function(r, e) {
461
+ return z = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, n) {
462
+ t.__proto__ = n;
463
+ } || function(t, n) {
464
+ for (var o in n) Object.prototype.hasOwnProperty.call(n, o) && (t[o] = n[o]);
465
+ }, z(r, e);
451
466
  };
452
- function me(n, e) {
467
+ function be(r, e) {
453
468
  if (typeof e != "function" && e !== null)
454
469
  throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
455
- z(n, e);
470
+ z(r, e);
456
471
  function t() {
457
- this.constructor = n;
472
+ this.constructor = r;
458
473
  }
459
- n.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
474
+ r.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
460
475
  }
461
- function ce(n) {
462
- var e = typeof Symbol == "function" && Symbol.iterator, t = e && n[e], r = 0;
463
- if (t) return t.call(n);
464
- if (n && typeof n.length == "number") return {
476
+ function ce(r) {
477
+ var e = typeof Symbol == "function" && Symbol.iterator, t = e && r[e], n = 0;
478
+ if (t) return t.call(r);
479
+ if (r && typeof r.length == "number") return {
465
480
  next: function() {
466
- return n && r >= n.length && (n = void 0), { value: n && n[r++], done: !n };
481
+ return r && n >= r.length && (r = void 0), { value: r && r[n++], done: !r };
467
482
  }
468
483
  };
469
484
  throw new TypeError(e ? "Object is not iterable." : "Symbol.iterator is not defined.");
470
485
  }
471
- function K(n, e) {
472
- var t = typeof Symbol == "function" && n[Symbol.iterator];
473
- if (!t) return n;
474
- var r = t.call(n), i, o = [], s;
486
+ function K(r, e) {
487
+ var t = typeof Symbol == "function" && r[Symbol.iterator];
488
+ if (!t) return r;
489
+ var n = t.call(r), o, i = [], s;
475
490
  try {
476
- for (; (e === void 0 || e-- > 0) && !(i = r.next()).done; ) o.push(i.value);
491
+ for (; (e === void 0 || e-- > 0) && !(o = n.next()).done; ) i.push(o.value);
477
492
  } catch (c) {
478
493
  s = { error: c };
479
494
  } finally {
480
495
  try {
481
- i && !i.done && (t = r.return) && t.call(r);
496
+ o && !o.done && (t = n.return) && t.call(n);
482
497
  } finally {
483
498
  if (s) throw s.error;
484
499
  }
485
500
  }
486
- return o;
501
+ return i;
487
502
  }
488
- function Q(n, e, t) {
489
- if (t || arguments.length === 2) for (var r = 0, i = e.length, o; r < i; r++)
490
- (o || !(r in e)) && (o || (o = Array.prototype.slice.call(e, 0, r)), o[r] = e[r]);
491
- return n.concat(o || Array.prototype.slice.call(e));
503
+ function Q(r, e, t) {
504
+ if (t || arguments.length === 2) for (var n = 0, o = e.length, i; n < o; n++)
505
+ (i || !(n in e)) && (i || (i = Array.prototype.slice.call(e, 0, n)), i[n] = e[n]);
506
+ return r.concat(i || Array.prototype.slice.call(e));
492
507
  }
493
- function R(n) {
494
- return typeof n == "function";
508
+ function R(r) {
509
+ return typeof r == "function";
495
510
  }
496
- function rt(n) {
497
- var e = function(r) {
498
- Error.call(r), r.stack = new Error().stack;
499
- }, t = n(e);
511
+ function nt(r) {
512
+ var e = function(n) {
513
+ Error.call(n), n.stack = new Error().stack;
514
+ }, t = r(e);
500
515
  return t.prototype = Object.create(Error.prototype), t.prototype.constructor = t, t;
501
516
  }
502
- var J = rt(function(n) {
517
+ var J = nt(function(r) {
503
518
  return function(t) {
504
- n(this), this.message = t ? t.length + ` errors occurred during unsubscription:
505
- ` + t.map(function(r, i) {
506
- return i + 1 + ") " + r.toString();
519
+ r(this), this.message = t ? t.length + ` errors occurred during unsubscription:
520
+ ` + t.map(function(n, o) {
521
+ return o + 1 + ") " + n.toString();
507
522
  }).join(`
508
523
  `) : "", this.name = "UnsubscriptionError", this.errors = t;
509
524
  };
510
525
  });
511
- function ae(n, e) {
512
- if (n) {
513
- var t = n.indexOf(e);
514
- 0 <= t && n.splice(t, 1);
526
+ function ae(r, e) {
527
+ if (r) {
528
+ var t = r.indexOf(e);
529
+ 0 <= t && r.splice(t, 1);
515
530
  }
516
531
  }
517
532
  var Z = function() {
518
- function n(e) {
533
+ function r(e) {
519
534
  this.initialTeardown = e, this.closed = !1, this._parentage = null, this._finalizers = null;
520
535
  }
521
- return n.prototype.unsubscribe = function() {
522
- var e, t, r, i, o;
536
+ return r.prototype.unsubscribe = function() {
537
+ var e, t, n, o, i;
523
538
  if (!this.closed) {
524
539
  this.closed = !0;
525
540
  var s = this._parentage;
@@ -546,69 +561,69 @@ var Z = function() {
546
561
  try {
547
562
  v();
548
563
  } catch (l) {
549
- o = l instanceof J ? l.errors : [l];
564
+ i = l instanceof J ? l.errors : [l];
550
565
  }
551
- var S = this._finalizers;
552
- if (S) {
566
+ var A = this._finalizers;
567
+ if (A) {
553
568
  this._finalizers = null;
554
569
  try {
555
- for (var g = ce(S), p = g.next(); !p.done; p = g.next()) {
556
- var b = p.value;
570
+ for (var g = ce(A), p = g.next(); !p.done; p = g.next()) {
571
+ var m = p.value;
557
572
  try {
558
- le(b);
573
+ le(m);
559
574
  } catch (l) {
560
- o = o != null ? o : [], l instanceof J ? o = Q(Q([], K(o)), K(l.errors)) : o.push(l);
575
+ i = i != null ? i : [], l instanceof J ? i = Q(Q([], K(i)), K(l.errors)) : i.push(l);
561
576
  }
562
577
  }
563
578
  } catch (l) {
564
- r = { error: l };
579
+ n = { error: l };
565
580
  } finally {
566
581
  try {
567
- p && !p.done && (i = g.return) && i.call(g);
582
+ p && !p.done && (o = g.return) && o.call(g);
568
583
  } finally {
569
- if (r) throw r.error;
584
+ if (n) throw n.error;
570
585
  }
571
586
  }
572
587
  }
573
- if (o)
574
- throw new J(o);
588
+ if (i)
589
+ throw new J(i);
575
590
  }
576
- }, n.prototype.add = function(e) {
591
+ }, r.prototype.add = function(e) {
577
592
  var t;
578
593
  if (e && e !== this)
579
594
  if (this.closed)
580
595
  le(e);
581
596
  else {
582
- if (e instanceof n) {
597
+ if (e instanceof r) {
583
598
  if (e.closed || e._hasParent(this))
584
599
  return;
585
600
  e._addParent(this);
586
601
  }
587
602
  (this._finalizers = (t = this._finalizers) !== null && t !== void 0 ? t : []).push(e);
588
603
  }
589
- }, n.prototype._hasParent = function(e) {
604
+ }, r.prototype._hasParent = function(e) {
590
605
  var t = this._parentage;
591
606
  return t === e || Array.isArray(t) && t.includes(e);
592
- }, n.prototype._addParent = function(e) {
607
+ }, r.prototype._addParent = function(e) {
593
608
  var t = this._parentage;
594
609
  this._parentage = Array.isArray(t) ? (t.push(e), t) : t ? [t, e] : e;
595
- }, n.prototype._removeParent = function(e) {
610
+ }, r.prototype._removeParent = function(e) {
596
611
  var t = this._parentage;
597
612
  t === e ? this._parentage = null : Array.isArray(t) && ae(t, e);
598
- }, n.prototype.remove = function(e) {
613
+ }, r.prototype.remove = function(e) {
599
614
  var t = this._finalizers;
600
- t && ae(t, e), e instanceof n && e._removeParent(this);
601
- }, n.EMPTY = function() {
602
- var e = new n();
615
+ t && ae(t, e), e instanceof r && e._removeParent(this);
616
+ }, r.EMPTY = function() {
617
+ var e = new r();
603
618
  return e.closed = !0, e;
604
- }(), n;
619
+ }(), r;
605
620
  }();
606
621
  Z.EMPTY;
607
- function we(n) {
608
- return n instanceof Z || n && "closed" in n && R(n.remove) && R(n.add) && R(n.unsubscribe);
622
+ function we(r) {
623
+ return r instanceof Z || r && "closed" in r && R(r.remove) && R(r.add) && R(r.unsubscribe);
609
624
  }
610
- function le(n) {
611
- R(n) ? n() : n.unsubscribe();
625
+ function le(r) {
626
+ R(r) ? r() : r.unsubscribe();
612
627
  }
613
628
  var ve = {
614
629
  onUnhandledError: null,
@@ -617,34 +632,34 @@ var ve = {
617
632
  useDeprecatedSynchronousErrorHandling: !1,
618
633
  useDeprecatedNextContext: !1
619
634
  }, it = {
620
- setTimeout: function(n, e) {
621
- for (var t = [], r = 2; r < arguments.length; r++)
622
- t[r - 2] = arguments[r];
623
- return setTimeout.apply(void 0, Q([n, e], K(t)));
635
+ setTimeout: function(r, e) {
636
+ for (var t = [], n = 2; n < arguments.length; n++)
637
+ t[n - 2] = arguments[n];
638
+ return setTimeout.apply(void 0, Q([r, e], K(t)));
624
639
  },
625
- clearTimeout: function(n) {
626
- return clearTimeout(n);
640
+ clearTimeout: function(r) {
641
+ return clearTimeout(r);
627
642
  },
628
643
  delegate: void 0
629
644
  };
630
- function ot(n) {
645
+ function ot(r) {
631
646
  it.setTimeout(function() {
632
- throw n;
647
+ throw r;
633
648
  });
634
649
  }
635
650
  function ue() {
636
651
  }
637
- function st(n) {
638
- n();
652
+ function st(r) {
653
+ r();
639
654
  }
640
- var Ee = function(n) {
641
- me(e, n);
655
+ var Ee = function(r) {
656
+ be(e, r);
642
657
  function e(t) {
643
- var r = n.call(this) || this;
644
- return r.isStopped = !1, t ? (r.destination = t, we(t) && t.add(r)) : r.destination = ut, r;
658
+ var n = r.call(this) || this;
659
+ return n.isStopped = !1, t ? (n.destination = t, we(t) && t.add(n)) : n.destination = ut, n;
645
660
  }
646
- return e.create = function(t, r, i) {
647
- return new G(t, r, i);
661
+ return e.create = function(t, n, o) {
662
+ return new G(t, n, o);
648
663
  }, e.prototype.next = function(t) {
649
664
  this.isStopped || this._next(t);
650
665
  }, e.prototype.error = function(t) {
@@ -652,7 +667,7 @@ var Ee = function(n) {
652
667
  }, e.prototype.complete = function() {
653
668
  this.isStopped || (this.isStopped = !0, this._complete());
654
669
  }, e.prototype.unsubscribe = function() {
655
- this.closed || (this.isStopped = !0, n.prototype.unsubscribe.call(this), this.destination = null);
670
+ this.closed || (this.isStopped = !0, r.prototype.unsubscribe.call(this), this.destination = null);
656
671
  }, e.prototype._next = function(t) {
657
672
  this.destination.next(t);
658
673
  }, e.prototype._error = function(t) {
@@ -669,32 +684,32 @@ var Ee = function(n) {
669
684
  }
670
685
  }, e;
671
686
  }(Z), ct = Function.prototype.bind;
672
- function Y(n, e) {
673
- return ct.call(n, e);
687
+ function Y(r, e) {
688
+ return ct.call(r, e);
674
689
  }
675
690
  var at = function() {
676
- function n(e) {
691
+ function r(e) {
677
692
  this.partialObserver = e;
678
693
  }
679
- return n.prototype.next = function(e) {
694
+ return r.prototype.next = function(e) {
680
695
  var t = this.partialObserver;
681
696
  if (t.next)
682
697
  try {
683
698
  t.next(e);
684
- } catch (r) {
685
- U(r);
699
+ } catch (n) {
700
+ U(n);
686
701
  }
687
- }, n.prototype.error = function(e) {
702
+ }, r.prototype.error = function(e) {
688
703
  var t = this.partialObserver;
689
704
  if (t.error)
690
705
  try {
691
706
  t.error(e);
692
- } catch (r) {
693
- U(r);
707
+ } catch (n) {
708
+ U(n);
694
709
  }
695
710
  else
696
711
  U(e);
697
- }, n.prototype.complete = function() {
712
+ }, r.prototype.complete = function() {
698
713
  var e = this.partialObserver;
699
714
  if (e.complete)
700
715
  try {
@@ -702,36 +717,36 @@ var at = function() {
702
717
  } catch (t) {
703
718
  U(t);
704
719
  }
705
- }, n;
706
- }(), G = function(n) {
707
- me(e, n);
708
- function e(t, r, i) {
709
- var o = n.call(this) || this, s;
720
+ }, r;
721
+ }(), G = function(r) {
722
+ be(e, r);
723
+ function e(t, n, o) {
724
+ var i = r.call(this) || this, s;
710
725
  if (R(t) || !t)
711
726
  s = {
712
727
  next: t != null ? t : void 0,
713
- error: r != null ? r : void 0,
714
- complete: i != null ? i : void 0
728
+ error: n != null ? n : void 0,
729
+ complete: o != null ? o : void 0
715
730
  };
716
731
  else {
717
732
  var c;
718
- o && ve.useDeprecatedNextContext ? (c = Object.create(t), c.unsubscribe = function() {
719
- return o.unsubscribe();
733
+ i && ve.useDeprecatedNextContext ? (c = Object.create(t), c.unsubscribe = function() {
734
+ return i.unsubscribe();
720
735
  }, s = {
721
736
  next: t.next && Y(t.next, c),
722
737
  error: t.error && Y(t.error, c),
723
738
  complete: t.complete && Y(t.complete, c)
724
739
  }) : s = t;
725
740
  }
726
- return o.destination = new at(s), o;
741
+ return i.destination = new at(s), i;
727
742
  }
728
743
  return e;
729
744
  }(Ee);
730
- function U(n) {
731
- ot(n);
745
+ function U(r) {
746
+ ot(r);
732
747
  }
733
- function lt(n) {
734
- throw n;
748
+ function lt(r) {
749
+ throw r;
735
750
  }
736
751
  var ut = {
737
752
  closed: !0,
@@ -741,186 +756,186 @@ var ut = {
741
756
  }, ft = function() {
742
757
  return typeof Symbol == "function" && Symbol.observable || "@@observable";
743
758
  }();
744
- function pt(n) {
745
- return n;
759
+ function pt(r) {
760
+ return r;
746
761
  }
747
- function dt(n) {
748
- return n.length === 0 ? pt : n.length === 1 ? n[0] : function(t) {
749
- return n.reduce(function(r, i) {
750
- return i(r);
762
+ function dt(r) {
763
+ return r.length === 0 ? pt : r.length === 1 ? r[0] : function(t) {
764
+ return r.reduce(function(n, o) {
765
+ return o(n);
751
766
  }, t);
752
767
  };
753
768
  }
754
769
  var ht = function() {
755
- function n(e) {
770
+ function r(e) {
756
771
  e && (this._subscribe = e);
757
772
  }
758
- return n.prototype.lift = function(e) {
759
- var t = new n();
773
+ return r.prototype.lift = function(e) {
774
+ var t = new r();
760
775
  return t.source = this, t.operator = e, t;
761
- }, n.prototype.subscribe = function(e, t, r) {
762
- var i = this, o = yt(e) ? e : new G(e, t, r);
776
+ }, r.prototype.subscribe = function(e, t, n) {
777
+ var o = this, i = yt(e) ? e : new G(e, t, n);
763
778
  return st(function() {
764
- var s = i, c = s.operator, a = s.source;
765
- o.add(c ? c.call(o, a) : a ? i._subscribe(o) : i._trySubscribe(o));
766
- }), o;
767
- }, n.prototype._trySubscribe = function(e) {
779
+ var s = o, c = s.operator, a = s.source;
780
+ i.add(c ? c.call(i, a) : a ? o._subscribe(i) : o._trySubscribe(i));
781
+ }), i;
782
+ }, r.prototype._trySubscribe = function(e) {
768
783
  try {
769
784
  return this._subscribe(e);
770
785
  } catch (t) {
771
786
  e.error(t);
772
787
  }
773
- }, n.prototype.forEach = function(e, t) {
774
- var r = this;
775
- return t = fe(t), new t(function(i, o) {
788
+ }, r.prototype.forEach = function(e, t) {
789
+ var n = this;
790
+ return t = fe(t), new t(function(o, i) {
776
791
  var s = new G({
777
792
  next: function(c) {
778
793
  try {
779
794
  e(c);
780
795
  } catch (a) {
781
- o(a), s.unsubscribe();
796
+ i(a), s.unsubscribe();
782
797
  }
783
798
  },
784
- error: o,
785
- complete: i
799
+ error: i,
800
+ complete: o
786
801
  });
787
- r.subscribe(s);
802
+ n.subscribe(s);
788
803
  });
789
- }, n.prototype._subscribe = function(e) {
804
+ }, r.prototype._subscribe = function(e) {
790
805
  var t;
791
806
  return (t = this.source) === null || t === void 0 ? void 0 : t.subscribe(e);
792
- }, n.prototype[ft] = function() {
807
+ }, r.prototype[ft] = function() {
793
808
  return this;
794
- }, n.prototype.pipe = function() {
809
+ }, r.prototype.pipe = function() {
795
810
  for (var e = [], t = 0; t < arguments.length; t++)
796
811
  e[t] = arguments[t];
797
812
  return dt(e)(this);
798
- }, n.prototype.toPromise = function(e) {
813
+ }, r.prototype.toPromise = function(e) {
799
814
  var t = this;
800
- return e = fe(e), new e(function(r, i) {
801
- var o;
815
+ return e = fe(e), new e(function(n, o) {
816
+ var i;
802
817
  t.subscribe(function(s) {
803
- return o = s;
818
+ return i = s;
804
819
  }, function(s) {
805
- return i(s);
820
+ return o(s);
806
821
  }, function() {
807
- return r(o);
822
+ return n(i);
808
823
  });
809
824
  });
810
- }, n.create = function(e) {
811
- return new n(e);
812
- }, n;
825
+ }, r.create = function(e) {
826
+ return new r(e);
827
+ }, r;
813
828
  }();
814
- function fe(n) {
829
+ function fe(r) {
815
830
  var e;
816
- return (e = n != null ? n : ve.Promise) !== null && e !== void 0 ? e : Promise;
831
+ return (e = r != null ? r : ve.Promise) !== null && e !== void 0 ? e : Promise;
817
832
  }
818
- function gt(n) {
819
- return n && R(n.next) && R(n.error) && R(n.complete);
833
+ function gt(r) {
834
+ return r && R(r.next) && R(r.error) && R(r.complete);
820
835
  }
821
- function yt(n) {
822
- return n && n instanceof Ee || gt(n) && we(n);
836
+ function yt(r) {
837
+ return r && r instanceof Ee || gt(r) && we(r);
823
838
  }
824
- const bt = () => {
839
+ const mt = () => {
825
840
  try {
826
841
  clearTimeout(void 0);
827
- } catch (n) {
842
+ } catch (r) {
828
843
  return !1;
829
844
  }
830
845
  return !0;
831
- }, mt = (n = {}) => {
832
- const { parentOrigin: e = "*", timeout: t, debug: r = !1, config: i = {} } = n, o = Ie(r), s = De("App", o), { destroy: c, onDestroy: a } = s, h = () => {
833
- o("Child: Handshake - Sending SYN");
834
- const S = { penpal: O.Syn }, g = e instanceof RegExp ? "*" : e;
835
- window.parent.postMessage(S, g);
846
+ }, bt = (r = {}) => {
847
+ const { parentOrigin: e = "*", timeout: t, debug: n = !1, config: o = {} } = r, i = Ie(n), s = De("App", i), { destroy: c, onDestroy: a } = s, h = () => {
848
+ i("Child: Handshake - Sending SYN");
849
+ const A = { penpal: O.Syn }, g = e instanceof RegExp ? "*" : e;
850
+ window.parent.postMessage(A, g);
836
851
  };
837
852
  return {
838
853
  promise: new Promise(
839
- (S, g) => {
840
- const p = Be(t, c), b = (l) => {
841
- if (bt() && !(l.source !== parent || !l.data) && l.data.penpal === O.SynAck) {
842
- const y = l.data, A = new se(y.id, y.appName), P = new se(y.id + "/api", y.appName), M = y.id, _ = {}, C = (u) => "api/" + u, q = {
854
+ (A, g) => {
855
+ const p = Be(t, c), m = (l) => {
856
+ if (mt() && !(l.source !== parent || !l.data) && l.data.penpal === O.SynAck) {
857
+ const y = l.data, S = new se(y.id, y.appName), P = new se(y.id + "/api", y.appName), M = y.id, C = {}, F = (u) => "api/" + u, N = {
843
858
  $emit: (u, ...f) => {
844
- A.getEventCallBackLength(u) > 0 ? A.$pureEmit(u, ...f) : _ == null || _.$off(u, () => {
859
+ S.getEventCallBackLength(u) > 0 ? S.$pureEmit(u, ...f) : C == null || C.$off(u, () => {
845
860
  }, !0);
846
861
  },
847
862
  onQueryResult: (u) => {
848
- P.$pureEmit(C(u.reqid), u);
863
+ P.$pureEmit(F(u.reqid), u);
849
864
  },
850
865
  onOsNotify: (u) => {
851
866
  }
852
- }, L = (u) => function(m) {
853
- const x = C(u);
854
- P.$on(x, function T(E) {
855
- m.next(E), E.reqid && E.result === "succ" && (m.complete(), P.$off(x, T));
867
+ }, L = (u) => function(b) {
868
+ const x = F(u);
869
+ P.$on(x, function _(E) {
870
+ b.next(E), E.reqid && E.result === "succ" && (b.complete(), P.$off(x, _));
856
871
  });
857
- }, Se = be(q), k = nt(
872
+ }, Ae = me(N), V = rt(
858
873
  e,
859
- Se,
860
- V(D({}, i), {
874
+ Ae,
875
+ j(D({}, o), {
861
876
  postmateVersion: tt.version
862
877
  }),
863
878
  s,
864
- o
879
+ i
865
880
  )(
866
881
  l
867
- ), F = {}, H = k.bus;
868
- if (H) {
869
- const u = (f, m, x) => {
870
- x ? (m.$__once = !0, A.$once(f, m)) : A.$on(f, m), F[f] ? F[f].push(m) : (F[f] = [m], H.$on(f, M));
882
+ ), T = {}, k = V.bus;
883
+ if (k) {
884
+ const u = (f, b, x) => {
885
+ x ? (b.$__once = !0, S.$once(f, b)) : S.$on(f, b), T[f] ? T[f].push(b) : (T[f] = [b], k.$on(f, M));
871
886
  };
872
- Object.assign(_, H, {
887
+ Object.assign(C, k, {
873
888
  $on: u,
874
- $off: (f, m, x) => {
875
- var T;
876
- if (F[f]) {
877
- const E = F[f].indexOf(m);
878
- E > -1 && (F[f].splice(E, 1), A.$off(f, m));
889
+ $off: (f, b, x) => {
890
+ var _;
891
+ if (T[f]) {
892
+ const E = T[f].indexOf(b);
893
+ E > -1 && (T[f].splice(E, 1), S.$off(f, b));
879
894
  }
880
- x && delete F[f], (T = F[f]) != null && T.length || (H.$off(f, M), delete F[f]);
895
+ x && delete T[f], (_ = T[f]) != null && _.length || (k.$off(f, M), delete T[f]);
881
896
  },
882
- $once: (f, m) => {
883
- u(f, m, !0);
897
+ $once: (f, b) => {
898
+ u(f, b, !0);
884
899
  }
885
900
  });
886
901
  }
887
- const Ae = V(D({}, k), {
888
- bus: _,
902
+ const Se = j(D({}, V), {
903
+ bus: C,
889
904
  query: (u, f) => w(void 0, null, function* () {
890
- const m = (u == null ? void 0 : u.reqid) || (yield k.genReqId());
891
- return new Promise((x, T) => {
892
- k.query(
893
- V(D({}, u), {
894
- reqid: m
905
+ const b = (u == null ? void 0 : u.reqid) || (yield V.genReqId());
906
+ return new Promise((x, _) => {
907
+ V.query(
908
+ j(D({}, u), {
909
+ reqid: b
895
910
  }),
896
911
  f
897
912
  ).then((E) => {
898
- (E == null ? void 0 : E.result) === "succ" ? x(E) : T(E);
913
+ (E == null ? void 0 : E.result) === "succ" ? x(E) : _(E);
899
914
  });
900
915
  });
901
916
  }),
902
- createObservableQuery: (m, ...x) => w(void 0, [m, ...x], function* (u, f = {}) {
903
- const T = (u == null ? void 0 : u.reqid) || (yield k.genReqId()), E = new ht(
904
- L(T)
917
+ createObservableQuery: (b, ...x) => w(void 0, [b, ...x], function* (u, f = {}) {
918
+ const _ = (u == null ? void 0 : u.reqid) || (yield V.genReqId()), E = new ht(
919
+ L(_)
905
920
  );
906
- return k.query(
907
- V(D({}, u), {
908
- reqid: T
921
+ return V.query(
922
+ j(D({}, u), {
923
+ reqid: _
909
924
  }),
910
- V(D({}, f), {
925
+ j(D({}, f), {
911
926
  observable: !0
912
927
  })
913
928
  ), E;
914
929
  })
915
930
  });
916
- k && (window.removeEventListener(I.Message, b), p(), S({
917
- methods: Ae,
931
+ V && (window.removeEventListener(I.Message, m), p(), A({
932
+ methods: Se,
918
933
  config: l.data.config
919
934
  }));
920
935
  }
921
936
  };
922
- window.addEventListener(I.Message, b), h(), a((l) => {
923
- window.removeEventListener(I.Message, b), l && g(l);
937
+ window.addEventListener(I.Message, m), h(), a((l) => {
938
+ window.removeEventListener(I.Message, m), l && g(l);
924
939
  });
925
940
  }
926
941
  ),
@@ -928,16 +943,17 @@ const bt = () => {
928
943
  c();
929
944
  }
930
945
  };
931
- }, wt = (n) => mt({
932
- debug: n == null ? void 0 : n.debug
946
+ }, wt = (r) => bt({
947
+ debug: r == null ? void 0 : r.debug
933
948
  }).promise;
934
- class St {
935
- constructor(e = {}) {
949
+ class At {
950
+ constructor() {
936
951
  $(this, "options");
937
952
  $(this, "flutterInAppWebView", null);
938
953
  $(this, "osConnector", null);
939
954
  $(this, "initPromise");
940
955
  $(this, "isWeb", !0);
956
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
941
957
  this.options = e, e.debug && (d.setDebug(!0), d.log("Trim App initialized with debug mode")), d.log("Options:", e), this.initPromise = this.init();
942
958
  }
943
959
  init() {
@@ -1023,10 +1039,7 @@ class St {
1023
1039
  setExitPageTips(e) {
1024
1040
  return w(this, null, function* () {
1025
1041
  var t;
1026
- return yield this.initPromise, this.isWeb ? (t = this.osConnector) == null ? void 0 : t.methods.setExitPageTips(e) : this.callAppMethod(
1027
- "setExitPageTips",
1028
- e ? JSON.stringify(e) : ""
1029
- );
1042
+ return yield this.initPromise, this.isWeb ? (t = this.osConnector) == null ? void 0 : t.methods.setExitPageTips(e) : this.callAppMethod("setExitPageTips", e ? JSON.stringify(e) : "");
1030
1043
  });
1031
1044
  }
1032
1045
  /**
@@ -1061,12 +1074,12 @@ class St {
1061
1074
  */
1062
1075
  query(e, t) {
1063
1076
  return w(this, null, function* () {
1064
- var r;
1077
+ var n;
1065
1078
  if (yield this.initPromise, this.isWeb) {
1066
- const i = yield (r = this.osConnector) == null ? void 0 : r.methods.query(e, t);
1067
- if (!i)
1079
+ const o = yield (n = this.osConnector) == null ? void 0 : n.methods.query(e, t);
1080
+ if (!o)
1068
1081
  throw new Error("Failed to query");
1069
- return i;
1082
+ return o;
1070
1083
  } else
1071
1084
  throw new Error("query is not supported on mobile platform");
1072
1085
  });
@@ -1082,6 +1095,6 @@ class St {
1082
1095
  }
1083
1096
  }
1084
1097
  export {
1085
- St as TrimApp,
1086
- St as default
1098
+ At as TrimApp,
1099
+ At as default
1087
1100
  };