@trimjs/web-app 0.1.0 → 0.1.2

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