@trimjs/web-app 0.1.2 → 0.1.3

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