@trimjs/web-app 0.1.1 → 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.cjs +3 -3
- package/dist/index.iife.js +2 -2
- package/dist/index.js +545 -589
- package/dist/index.umd.cjs +2 -2
- package/package.json +1 -4
package/dist/index.js
CHANGED
|
@@ -1,35 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
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
|
-
|
|
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
|
|
77
|
-
function
|
|
50
|
+
const d = new Ee();
|
|
51
|
+
function Se(r) {
|
|
78
52
|
const e = /FNOS\/([\d.]+)|FNAppType\/(\w+)|FNAppVer\/([\d.]+)/g, t = {};
|
|
79
|
-
let
|
|
80
|
-
for (; (
|
|
81
|
-
|
|
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
|
|
85
|
-
let
|
|
58
|
+
const ce = () => Se(navigator.userAgent).fnAppVersion;
|
|
59
|
+
let ae = !1;
|
|
86
60
|
window.addEventListener("flutterInAppWebViewPlatformReady", () => {
|
|
87
|
-
|
|
61
|
+
ae = !0;
|
|
88
62
|
});
|
|
89
|
-
const
|
|
63
|
+
const Ae = () => new Promise((r) => {
|
|
90
64
|
var e;
|
|
91
|
-
|
|
92
|
-
d.log("flutter_inappwebview is ready"),
|
|
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
|
-
}),
|
|
68
|
+
}), $e = async (r, e, t) => {
|
|
95
69
|
d.log(`callHandler: ${e}, params: ${t}`);
|
|
96
|
-
const
|
|
97
|
-
if (
|
|
70
|
+
const n = await r.callHandler(e, t);
|
|
71
|
+
if (n)
|
|
98
72
|
try {
|
|
99
|
-
const
|
|
100
|
-
d.log(`messageData: ${JSON.stringify(
|
|
101
|
-
const
|
|
102
|
-
return d.log(`appMessage: ${JSON.stringify(
|
|
103
|
-
} catch (
|
|
104
|
-
return d.error(`error: ${
|
|
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
|
-
}
|
|
108
|
-
function
|
|
109
|
-
window.fnAppMessage = (
|
|
110
|
-
d.log("app-message",
|
|
111
|
-
const e = JSON.parse(
|
|
112
|
-
t && (t(e),
|
|
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
|
-
|
|
116
|
-
var
|
|
117
|
-
const
|
|
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
|
|
93
|
+
let n = !1;
|
|
120
94
|
return {
|
|
121
|
-
destroy(
|
|
122
|
-
|
|
123
|
-
o
|
|
95
|
+
destroy(o) {
|
|
96
|
+
n || (n = !0, e(`${r}: Destroying connection`), t.forEach((i) => {
|
|
97
|
+
i(o);
|
|
124
98
|
}));
|
|
125
99
|
},
|
|
126
|
-
onDestroy(
|
|
127
|
-
|
|
100
|
+
onDestroy(o) {
|
|
101
|
+
n ? o() : t.push(o);
|
|
128
102
|
}
|
|
129
103
|
};
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
},
|
|
133
|
-
name:
|
|
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:
|
|
111
|
+
name: r,
|
|
138
112
|
message: e,
|
|
139
113
|
stack: t
|
|
140
|
-
}),
|
|
114
|
+
}), Ce = (r) => {
|
|
141
115
|
const e = new Error();
|
|
142
|
-
return Object.keys(
|
|
143
|
-
},
|
|
116
|
+
return Object.keys(r).forEach((t) => e[t] = r[t]), e;
|
|
117
|
+
}, Fe = (r, e, t) => {
|
|
144
118
|
const {
|
|
145
|
-
localName:
|
|
146
|
-
local:
|
|
147
|
-
remote:
|
|
119
|
+
localName: n,
|
|
120
|
+
local: o,
|
|
121
|
+
remote: i,
|
|
148
122
|
originForSending: s,
|
|
149
123
|
originForReceiving: c
|
|
150
|
-
} =
|
|
151
|
-
let
|
|
152
|
-
const
|
|
153
|
-
if (
|
|
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 !== "*" &&
|
|
129
|
+
if (c !== "*" && b.origin !== c) {
|
|
156
130
|
t(
|
|
157
|
-
`${
|
|
131
|
+
`${n} received message from origin ${b.origin} which did not match expected origin ${c}`
|
|
158
132
|
);
|
|
159
133
|
return;
|
|
160
134
|
}
|
|
161
|
-
const
|
|
162
|
-
t(`${
|
|
163
|
-
const
|
|
164
|
-
if (t(`${
|
|
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
|
-
`${
|
|
140
|
+
`${n}: Unable to send ${g}() reply due to destroyed connection`
|
|
167
141
|
);
|
|
168
142
|
return;
|
|
169
143
|
}
|
|
170
|
-
const
|
|
171
|
-
penpal:
|
|
172
|
-
id:
|
|
144
|
+
const $ = {
|
|
145
|
+
penpal: T.Reply,
|
|
146
|
+
id: m,
|
|
173
147
|
resolution: y,
|
|
174
|
-
returnValue:
|
|
148
|
+
returnValue: S
|
|
175
149
|
};
|
|
176
|
-
y ===
|
|
150
|
+
y === k.Rejected && S instanceof Error && ($.returnValue = G(S), $.returnValueIsError = !0);
|
|
177
151
|
try {
|
|
178
|
-
|
|
152
|
+
i.postMessage($, s);
|
|
179
153
|
} catch (M) {
|
|
180
|
-
if (M.name ===
|
|
154
|
+
if (M.name === le.DataCloneError) {
|
|
181
155
|
const _ = {
|
|
182
|
-
penpal:
|
|
183
|
-
id:
|
|
184
|
-
resolution:
|
|
185
|
-
returnValue:
|
|
156
|
+
penpal: T.Reply,
|
|
157
|
+
id: m,
|
|
158
|
+
resolution: k.Rejected,
|
|
159
|
+
returnValue: G(M),
|
|
186
160
|
returnValueIsError: !0
|
|
187
161
|
};
|
|
188
|
-
|
|
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
|
-
|
|
197
|
-
|
|
170
|
+
a(k.Fulfilled),
|
|
171
|
+
a(k.Rejected)
|
|
198
172
|
);
|
|
199
173
|
};
|
|
200
|
-
return
|
|
201
|
-
|
|
174
|
+
return o.addEventListener(R.Message, w), () => {
|
|
175
|
+
f = !0, o.removeEventListener(R.Message, w);
|
|
202
176
|
};
|
|
203
177
|
};
|
|
204
|
-
let
|
|
205
|
-
const
|
|
206
|
-
const t =
|
|
207
|
-
return t.push(
|
|
208
|
-
},
|
|
209
|
-
const
|
|
210
|
-
return
|
|
211
|
-
},
|
|
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(
|
|
214
|
-
const
|
|
215
|
-
typeof
|
|
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
|
-
},
|
|
191
|
+
}, Ie = (r) => {
|
|
218
192
|
const e = {};
|
|
219
|
-
for (const t in
|
|
220
|
-
|
|
193
|
+
for (const t in r)
|
|
194
|
+
De(e, t, r[t]);
|
|
221
195
|
return e;
|
|
222
|
-
},
|
|
196
|
+
}, ke = (r, e, t, n, o) => {
|
|
223
197
|
const {
|
|
224
|
-
localName:
|
|
198
|
+
localName: i,
|
|
225
199
|
local: s,
|
|
226
200
|
remote: c,
|
|
227
|
-
originForSending:
|
|
228
|
-
originForReceiving:
|
|
201
|
+
originForSending: f,
|
|
202
|
+
originForReceiving: w
|
|
229
203
|
} = e;
|
|
230
|
-
let
|
|
231
|
-
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
let
|
|
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 && (
|
|
237
|
-
} catch
|
|
238
|
-
|
|
210
|
+
c.closed && (a = !0);
|
|
211
|
+
} catch {
|
|
212
|
+
a = !0;
|
|
239
213
|
}
|
|
240
|
-
if (
|
|
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 =
|
|
218
|
+
throw y.code = z.ConnectionDestroyed, y;
|
|
245
219
|
}
|
|
246
|
-
return new Promise((y,
|
|
247
|
-
const
|
|
248
|
-
if (C.source !== c || C.data.penpal !==
|
|
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 (
|
|
251
|
-
|
|
252
|
-
`${
|
|
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
|
|
257
|
-
|
|
258
|
-
|
|
230
|
+
const V = C.data;
|
|
231
|
+
o(`${i}: Received ${p}() reply`), s.removeEventListener(
|
|
232
|
+
R.Message,
|
|
259
233
|
M
|
|
260
234
|
);
|
|
261
|
-
let
|
|
262
|
-
|
|
263
|
-
|
|
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(
|
|
240
|
+
s.addEventListener(R.Message, M);
|
|
267
241
|
const _ = {
|
|
268
|
-
penpal:
|
|
269
|
-
id:
|
|
242
|
+
penpal: T.Call,
|
|
243
|
+
id: $,
|
|
270
244
|
methodName: p,
|
|
271
|
-
args:
|
|
245
|
+
args: m
|
|
272
246
|
};
|
|
273
|
-
c.postMessage(_,
|
|
247
|
+
c.postMessage(_, f);
|
|
274
248
|
});
|
|
275
|
-
}, g = t.reduce((p,
|
|
276
|
-
return Object.assign(
|
|
277
|
-
|
|
249
|
+
}, g = t.reduce((p, m) => (p[m] = v(m), p), {});
|
|
250
|
+
return Object.assign(r, Ie(g)), () => {
|
|
251
|
+
b = !0;
|
|
278
252
|
};
|
|
279
|
-
},
|
|
253
|
+
}, Ve = (r, e) => {
|
|
280
254
|
let t;
|
|
281
|
-
return
|
|
282
|
-
const
|
|
283
|
-
`Connection timed out after ${
|
|
255
|
+
return r !== void 0 && (t = window.setTimeout(() => {
|
|
256
|
+
const n = new Error(
|
|
257
|
+
`Connection timed out after ${r}ms`
|
|
284
258
|
);
|
|
285
|
-
|
|
286
|
-
},
|
|
259
|
+
n.code = z.ConnectionTimeout, e(n);
|
|
260
|
+
}, r)), () => {
|
|
287
261
|
clearTimeout(t);
|
|
288
262
|
};
|
|
289
|
-
},
|
|
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
|
-
},
|
|
267
|
+
}, He = [
|
|
294
268
|
"src",
|
|
295
269
|
"dist"
|
|
296
|
-
],
|
|
270
|
+
], Ue = {
|
|
297
271
|
"@fn/micro-app-event": "^0.0.1",
|
|
298
272
|
rxjs: "^7.8.0"
|
|
299
|
-
},
|
|
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
|
-
},
|
|
282
|
+
}, Je = {
|
|
309
283
|
registry: "http://verdaccio.teiron-inc.cn:4873"
|
|
310
|
-
},
|
|
311
|
-
name:
|
|
312
|
-
version:
|
|
313
|
-
type:
|
|
314
|
-
main:
|
|
315
|
-
scripts:
|
|
316
|
-
files:
|
|
317
|
-
peerDependencies:
|
|
318
|
-
devDependencies:
|
|
319
|
-
publishConfig:
|
|
320
|
-
},
|
|
321
|
-
const { destroy:
|
|
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 (!(
|
|
324
|
-
|
|
325
|
-
`Child: Handshake - Received SYN-ACK from origin ${c.origin} which did not match expected origin ${
|
|
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
|
-
|
|
330
|
-
const
|
|
331
|
-
penpal:
|
|
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(
|
|
336
|
-
const
|
|
309
|
+
window.parent.postMessage(b, w);
|
|
310
|
+
const v = {
|
|
337
311
|
localName: "Child",
|
|
338
312
|
local: window,
|
|
339
313
|
remote: window.parent,
|
|
340
|
-
originForSending:
|
|
314
|
+
originForSending: w,
|
|
341
315
|
originForReceiving: c.origin
|
|
342
|
-
}, g =
|
|
343
|
-
|
|
316
|
+
}, g = Fe(
|
|
317
|
+
v,
|
|
344
318
|
e,
|
|
345
|
-
|
|
319
|
+
o
|
|
346
320
|
);
|
|
347
321
|
s(g);
|
|
348
|
-
const p = {},
|
|
322
|
+
const p = {}, m = ke(
|
|
349
323
|
p,
|
|
350
|
-
|
|
324
|
+
v,
|
|
351
325
|
c.data.methodNames,
|
|
352
|
-
|
|
353
|
-
|
|
326
|
+
i,
|
|
327
|
+
o
|
|
354
328
|
);
|
|
355
|
-
return s(
|
|
329
|
+
return s(m), p;
|
|
356
330
|
};
|
|
357
331
|
};
|
|
358
|
-
function
|
|
359
|
-
console == null || console.warn(`[fnApp warn]: ${
|
|
332
|
+
function X(r, e) {
|
|
333
|
+
console == null || console.warn(`[fnApp warn]: ${r}`, e);
|
|
360
334
|
}
|
|
361
|
-
function
|
|
362
|
-
console == null || console.error(`[fnApp error]: ${
|
|
335
|
+
function Z(r, e) {
|
|
336
|
+
console == null || console.error(`[fnApp error]: ${r}`, e);
|
|
363
337
|
}
|
|
364
|
-
const
|
|
365
|
-
class
|
|
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
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
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
|
-
|
|
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
|
|
379
|
-
return
|
|
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(
|
|
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
|
|
392
|
-
if (!e || !
|
|
393
|
-
return
|
|
394
|
-
let
|
|
395
|
-
for (;
|
|
396
|
-
if (
|
|
397
|
-
|
|
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(
|
|
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
|
|
413
|
-
return
|
|
414
|
-
if (
|
|
415
|
-
for (let s =
|
|
416
|
-
|
|
417
|
-
const c =
|
|
418
|
-
c.$__once &&
|
|
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 (
|
|
422
|
-
|
|
395
|
+
} catch (f) {
|
|
396
|
+
Z(f);
|
|
423
397
|
}
|
|
424
398
|
}
|
|
425
|
-
if (
|
|
426
|
-
for (let s =
|
|
427
|
-
|
|
428
|
-
const c =
|
|
429
|
-
c.$__once &&
|
|
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 (
|
|
433
|
-
|
|
406
|
+
} catch (f) {
|
|
407
|
+
Z(f);
|
|
434
408
|
}
|
|
435
409
|
}
|
|
436
|
-
}), (!e ||
|
|
410
|
+
}), (!e || n === 0 && o === 0) && X(`${e} ${ee}`), this;
|
|
437
411
|
}
|
|
438
412
|
// 清空当前所有的监听事件
|
|
439
413
|
$clear() {
|
|
440
|
-
|
|
441
|
-
|
|
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
|
|
446
|
-
return
|
|
447
|
-
t.__proto__ =
|
|
448
|
-
} || function(t,
|
|
449
|
-
for (var
|
|
450
|
-
},
|
|
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
|
|
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
|
-
|
|
428
|
+
U(r, e);
|
|
456
429
|
function t() {
|
|
457
|
-
this.constructor =
|
|
430
|
+
this.constructor = r;
|
|
458
431
|
}
|
|
459
|
-
|
|
432
|
+
r.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
|
|
460
433
|
}
|
|
461
|
-
function
|
|
462
|
-
var e = typeof Symbol == "function" && Symbol.iterator, t = e &&
|
|
463
|
-
if (t) return t.call(
|
|
464
|
-
if (
|
|
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
|
|
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
|
|
472
|
-
var t = typeof Symbol == "function" &&
|
|
473
|
-
if (!t) return
|
|
474
|
-
var
|
|
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) && !(
|
|
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
|
-
|
|
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
|
|
459
|
+
return i;
|
|
487
460
|
}
|
|
488
|
-
function
|
|
489
|
-
if (t || arguments.length === 2) for (var
|
|
490
|
-
(
|
|
491
|
-
return
|
|
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
|
|
494
|
-
return typeof
|
|
466
|
+
function O(r) {
|
|
467
|
+
return typeof r == "function";
|
|
495
468
|
}
|
|
496
|
-
function
|
|
497
|
-
var e = function(
|
|
498
|
-
Error.call(
|
|
499
|
-
}, t =
|
|
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
|
|
475
|
+
var L = Ke(function(r) {
|
|
503
476
|
return function(t) {
|
|
504
|
-
|
|
505
|
-
` + t.map(function(
|
|
506
|
-
return
|
|
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
|
|
512
|
-
if (
|
|
513
|
-
var t =
|
|
514
|
-
0 <= t &&
|
|
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
|
|
518
|
-
function
|
|
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
|
|
522
|
-
var e, t,
|
|
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 =
|
|
530
|
-
var
|
|
531
|
-
|
|
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 (
|
|
534
|
-
e = { error:
|
|
506
|
+
} catch (a) {
|
|
507
|
+
e = { error: a };
|
|
535
508
|
} finally {
|
|
536
509
|
try {
|
|
537
|
-
|
|
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
|
|
545
|
-
if (
|
|
517
|
+
var b = this.initialTeardown;
|
|
518
|
+
if (O(b))
|
|
546
519
|
try {
|
|
547
|
-
|
|
548
|
-
} catch (
|
|
549
|
-
|
|
520
|
+
b();
|
|
521
|
+
} catch (a) {
|
|
522
|
+
i = a instanceof L ? a.errors : [a];
|
|
550
523
|
}
|
|
551
|
-
var
|
|
552
|
-
if (
|
|
524
|
+
var v = this._finalizers;
|
|
525
|
+
if (v) {
|
|
553
526
|
this._finalizers = null;
|
|
554
527
|
try {
|
|
555
|
-
for (var g =
|
|
556
|
-
var
|
|
528
|
+
for (var g = re(v), p = g.next(); !p.done; p = g.next()) {
|
|
529
|
+
var m = p.value;
|
|
557
530
|
try {
|
|
558
|
-
|
|
559
|
-
} catch (
|
|
560
|
-
|
|
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 (
|
|
564
|
-
|
|
536
|
+
} catch (a) {
|
|
537
|
+
n = { error: a };
|
|
565
538
|
} finally {
|
|
566
539
|
try {
|
|
567
|
-
p && !p.done && (
|
|
540
|
+
p && !p.done && (o = g.return) && o.call(g);
|
|
568
541
|
} finally {
|
|
569
|
-
if (
|
|
542
|
+
if (n) throw n.error;
|
|
570
543
|
}
|
|
571
544
|
}
|
|
572
545
|
}
|
|
573
|
-
if (
|
|
574
|
-
throw new
|
|
546
|
+
if (i)
|
|
547
|
+
throw new L(i);
|
|
575
548
|
}
|
|
576
|
-
},
|
|
549
|
+
}, r.prototype.add = function(e) {
|
|
577
550
|
var t;
|
|
578
551
|
if (e && e !== this)
|
|
579
552
|
if (this.closed)
|
|
580
|
-
|
|
553
|
+
ie(e);
|
|
581
554
|
else {
|
|
582
|
-
if (e instanceof
|
|
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
|
-
},
|
|
562
|
+
}, r.prototype._hasParent = function(e) {
|
|
590
563
|
var t = this._parentage;
|
|
591
564
|
return t === e || Array.isArray(t) && t.includes(e);
|
|
592
|
-
},
|
|
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
|
-
},
|
|
568
|
+
}, r.prototype._removeParent = function(e) {
|
|
596
569
|
var t = this._parentage;
|
|
597
|
-
t === e ? this._parentage = null : Array.isArray(t) &&
|
|
598
|
-
},
|
|
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 &&
|
|
601
|
-
},
|
|
602
|
-
var e = new
|
|
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
|
-
}(),
|
|
577
|
+
}(), r;
|
|
605
578
|
}();
|
|
606
|
-
|
|
607
|
-
function
|
|
608
|
-
return
|
|
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
|
|
611
|
-
|
|
583
|
+
function ie(r) {
|
|
584
|
+
O(r) ? r() : r.unsubscribe();
|
|
612
585
|
}
|
|
613
|
-
var
|
|
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
|
-
},
|
|
620
|
-
setTimeout: function(
|
|
621
|
-
for (var t = [],
|
|
622
|
-
t[
|
|
623
|
-
return setTimeout.apply(void 0,
|
|
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(
|
|
626
|
-
return clearTimeout(
|
|
598
|
+
clearTimeout: function(r) {
|
|
599
|
+
return clearTimeout(r);
|
|
627
600
|
},
|
|
628
601
|
delegate: void 0
|
|
629
602
|
};
|
|
630
|
-
function
|
|
631
|
-
|
|
632
|
-
throw
|
|
603
|
+
function Ge(r) {
|
|
604
|
+
Qe.setTimeout(function() {
|
|
605
|
+
throw r;
|
|
633
606
|
});
|
|
634
607
|
}
|
|
635
|
-
function
|
|
608
|
+
function oe() {
|
|
636
609
|
}
|
|
637
|
-
function
|
|
638
|
-
|
|
610
|
+
function Xe(r) {
|
|
611
|
+
r();
|
|
639
612
|
}
|
|
640
|
-
var
|
|
641
|
-
|
|
613
|
+
var ye = function(r) {
|
|
614
|
+
de(e, r);
|
|
642
615
|
function e(t) {
|
|
643
|
-
var
|
|
644
|
-
return
|
|
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,
|
|
647
|
-
return new
|
|
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,
|
|
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
|
-
}(
|
|
672
|
-
function
|
|
673
|
-
return
|
|
644
|
+
}(K), Ze = Function.prototype.bind;
|
|
645
|
+
function H(r, e) {
|
|
646
|
+
return Ze.call(r, e);
|
|
674
647
|
}
|
|
675
|
-
var
|
|
676
|
-
function
|
|
648
|
+
var et = function() {
|
|
649
|
+
function r(e) {
|
|
677
650
|
this.partialObserver = e;
|
|
678
651
|
}
|
|
679
|
-
return
|
|
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 (
|
|
685
|
-
|
|
657
|
+
} catch (n) {
|
|
658
|
+
N(n);
|
|
686
659
|
}
|
|
687
|
-
},
|
|
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 (
|
|
693
|
-
|
|
665
|
+
} catch (n) {
|
|
666
|
+
N(n);
|
|
694
667
|
}
|
|
695
668
|
else
|
|
696
|
-
|
|
697
|
-
},
|
|
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
|
-
|
|
676
|
+
N(t);
|
|
704
677
|
}
|
|
705
|
-
},
|
|
706
|
-
}(),
|
|
707
|
-
|
|
708
|
-
function e(t,
|
|
709
|
-
var
|
|
710
|
-
if (
|
|
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
|
|
713
|
-
error:
|
|
714
|
-
complete:
|
|
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
|
-
|
|
719
|
-
return
|
|
691
|
+
i && ge.useDeprecatedNextContext ? (c = Object.create(t), c.unsubscribe = function() {
|
|
692
|
+
return i.unsubscribe();
|
|
720
693
|
}, s = {
|
|
721
|
-
next: t.next &&
|
|
722
|
-
error: t.error &&
|
|
723
|
-
complete: t.complete &&
|
|
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
|
|
699
|
+
return i.destination = new et(s), i;
|
|
727
700
|
}
|
|
728
701
|
return e;
|
|
729
|
-
}(
|
|
730
|
-
function
|
|
731
|
-
|
|
702
|
+
}(ye);
|
|
703
|
+
function N(r) {
|
|
704
|
+
Ge(r);
|
|
732
705
|
}
|
|
733
|
-
function
|
|
734
|
-
throw
|
|
706
|
+
function tt(r) {
|
|
707
|
+
throw r;
|
|
735
708
|
}
|
|
736
|
-
var
|
|
709
|
+
var rt = {
|
|
737
710
|
closed: !0,
|
|
738
|
-
next:
|
|
739
|
-
error:
|
|
740
|
-
complete:
|
|
741
|
-
},
|
|
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
|
|
745
|
-
return
|
|
717
|
+
function it(r) {
|
|
718
|
+
return r;
|
|
746
719
|
}
|
|
747
|
-
function
|
|
748
|
-
return
|
|
749
|
-
return
|
|
750
|
-
return
|
|
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
|
|
755
|
-
function
|
|
727
|
+
var st = function() {
|
|
728
|
+
function r(e) {
|
|
756
729
|
e && (this._subscribe = e);
|
|
757
730
|
}
|
|
758
|
-
return
|
|
759
|
-
var t = new
|
|
731
|
+
return r.prototype.lift = function(e) {
|
|
732
|
+
var t = new r();
|
|
760
733
|
return t.source = this, t.operator = e, t;
|
|
761
|
-
},
|
|
762
|
-
var
|
|
763
|
-
return
|
|
764
|
-
var s =
|
|
765
|
-
|
|
766
|
-
}),
|
|
767
|
-
},
|
|
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
|
-
},
|
|
774
|
-
var
|
|
775
|
-
return t =
|
|
776
|
-
var s = new
|
|
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 (
|
|
781
|
-
|
|
753
|
+
} catch (f) {
|
|
754
|
+
i(f), s.unsubscribe();
|
|
782
755
|
}
|
|
783
756
|
},
|
|
784
|
-
error:
|
|
785
|
-
complete:
|
|
757
|
+
error: i,
|
|
758
|
+
complete: o
|
|
786
759
|
});
|
|
787
|
-
|
|
760
|
+
n.subscribe(s);
|
|
788
761
|
});
|
|
789
|
-
},
|
|
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
|
-
},
|
|
765
|
+
}, r.prototype[nt] = function() {
|
|
793
766
|
return this;
|
|
794
|
-
},
|
|
767
|
+
}, r.prototype.pipe = function() {
|
|
795
768
|
for (var e = [], t = 0; t < arguments.length; t++)
|
|
796
769
|
e[t] = arguments[t];
|
|
797
|
-
return
|
|
798
|
-
},
|
|
770
|
+
return ot(e)(this);
|
|
771
|
+
}, r.prototype.toPromise = function(e) {
|
|
799
772
|
var t = this;
|
|
800
|
-
return e =
|
|
801
|
-
var
|
|
773
|
+
return e = se(e), new e(function(n, o) {
|
|
774
|
+
var i;
|
|
802
775
|
t.subscribe(function(s) {
|
|
803
|
-
return
|
|
776
|
+
return i = s;
|
|
804
777
|
}, function(s) {
|
|
805
|
-
return
|
|
778
|
+
return o(s);
|
|
806
779
|
}, function() {
|
|
807
|
-
return
|
|
780
|
+
return n(i);
|
|
808
781
|
});
|
|
809
782
|
});
|
|
810
|
-
},
|
|
811
|
-
return new
|
|
812
|
-
},
|
|
783
|
+
}, r.create = function(e) {
|
|
784
|
+
return new r(e);
|
|
785
|
+
}, r;
|
|
813
786
|
}();
|
|
814
|
-
function
|
|
787
|
+
function se(r) {
|
|
815
788
|
var e;
|
|
816
|
-
return (e =
|
|
789
|
+
return (e = r ?? ge.Promise) !== null && e !== void 0 ? e : Promise;
|
|
817
790
|
}
|
|
818
|
-
function
|
|
819
|
-
return
|
|
791
|
+
function ct(r) {
|
|
792
|
+
return r && O(r.next) && O(r.error) && O(r.complete);
|
|
820
793
|
}
|
|
821
|
-
function
|
|
822
|
-
return
|
|
794
|
+
function at(r) {
|
|
795
|
+
return r && r instanceof ye || ct(r) && he(r);
|
|
823
796
|
}
|
|
824
|
-
const
|
|
797
|
+
const lt = () => {
|
|
825
798
|
try {
|
|
826
799
|
clearTimeout(void 0);
|
|
827
|
-
} catch
|
|
800
|
+
} catch {
|
|
828
801
|
return !1;
|
|
829
802
|
}
|
|
830
803
|
return !0;
|
|
831
|
-
},
|
|
832
|
-
const { parentOrigin: e = "*", timeout: t, debug:
|
|
833
|
-
|
|
834
|
-
const
|
|
835
|
-
window.parent.postMessage(
|
|
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
|
-
(
|
|
840
|
-
const p =
|
|
841
|
-
if (
|
|
842
|
-
const y =
|
|
843
|
-
$emit: (
|
|
844
|
-
|
|
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: (
|
|
848
|
-
|
|
820
|
+
onQueryResult: (l) => {
|
|
821
|
+
$.$pureEmit(C(l.reqid), l);
|
|
849
822
|
},
|
|
850
|
-
onOsNotify: (
|
|
823
|
+
onOsNotify: (l) => {
|
|
851
824
|
}
|
|
852
|
-
},
|
|
853
|
-
const
|
|
854
|
-
|
|
855
|
-
|
|
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
|
-
},
|
|
830
|
+
}, me = pe(V), x = ze(
|
|
858
831
|
e,
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
832
|
+
me,
|
|
833
|
+
{
|
|
834
|
+
...o,
|
|
835
|
+
postmateVersion: Ye.version
|
|
836
|
+
},
|
|
863
837
|
s,
|
|
864
|
-
|
|
838
|
+
i
|
|
865
839
|
)(
|
|
866
|
-
|
|
867
|
-
), F = {},
|
|
868
|
-
if (
|
|
869
|
-
const
|
|
870
|
-
|
|
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(_,
|
|
873
|
-
$on:
|
|
874
|
-
$off: (
|
|
875
|
-
var
|
|
876
|
-
if (F[
|
|
877
|
-
const E = F[
|
|
878
|
-
E > -1 && (F[
|
|
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
|
-
|
|
854
|
+
P && delete F[u], (D = F[u]) != null && D.length || (q.$off(u, M), delete F[u]);
|
|
881
855
|
},
|
|
882
|
-
$once: (
|
|
883
|
-
u
|
|
856
|
+
$once: (u, h) => {
|
|
857
|
+
l(u, h, !0);
|
|
884
858
|
}
|
|
885
859
|
});
|
|
886
860
|
}
|
|
887
|
-
const
|
|
861
|
+
const be = {
|
|
862
|
+
...x,
|
|
888
863
|
bus: _,
|
|
889
|
-
query: (
|
|
890
|
-
const
|
|
891
|
-
return new Promise((
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
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" ?
|
|
874
|
+
(E == null ? void 0 : E.result) === "succ" ? P(E) : D(E);
|
|
899
875
|
});
|
|
900
876
|
});
|
|
901
|
-
}
|
|
902
|
-
createObservableQuery:
|
|
903
|
-
const
|
|
904
|
-
|
|
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
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
882
|
+
return x.query(
|
|
883
|
+
{
|
|
884
|
+
...l,
|
|
885
|
+
reqid: h
|
|
886
|
+
},
|
|
887
|
+
{
|
|
888
|
+
...u,
|
|
911
889
|
observable: !0
|
|
912
|
-
}
|
|
913
|
-
),
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
methods:
|
|
918
|
-
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(
|
|
923
|
-
window.removeEventListener(
|
|
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
|
-
},
|
|
932
|
-
debug:
|
|
909
|
+
}, ft = (r) => ut({
|
|
910
|
+
debug: r == null ? void 0 : r.debug
|
|
933
911
|
}).promise;
|
|
934
|
-
class
|
|
912
|
+
class ht {
|
|
935
913
|
constructor(e = {}) {
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
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
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
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
|
|
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
|
|
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 =
|
|
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
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
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
|
-
|
|
1015
|
-
|
|
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
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
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
|
-
|
|
1037
|
-
|
|
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
|
-
|
|
1046
|
-
|
|
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
|
-
|
|
1055
|
-
|
|
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
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
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
|
-
|
|
1079
|
-
|
|
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
|
-
|
|
1086
|
-
|
|
1041
|
+
ht as TrimApp,
|
|
1042
|
+
ht as default
|
|
1087
1043
|
};
|