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