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