@tma.js/bridge 2.0.3 → 2.1.1
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 +1 -1
- package/dist/dts/base64-url.d.ts +1 -1
- package/dist/dts/index.d.ts +2 -1
- package/dist/dts/launch-params.d.ts +1 -1
- package/dist/dts/methods/getReleaseVersion.d.ts +15 -0
- package/dist/dts/start-param.d.ts +1 -1
- package/dist/dts/utils/request.d.ts +7 -7
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.iife.js +3 -3
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +452 -577
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { is as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { parseLaunchParamsQueryFp as ee, themeParams as
|
|
7
|
-
import { errorClass as
|
|
8
|
-
import { signal as
|
|
9
|
-
import
|
|
10
|
-
function
|
|
11
|
-
return
|
|
12
|
-
|
|
1
|
+
import { is as L, looseObject as l, function as Y, nullish as h, boolean as I, number as j, string as d, optional as z, unknown as ye, parse as M, any as Ee } from "valibot";
|
|
2
|
+
import { throwifyFpFn as x, getStorageValue as Pe, setStorageValue as X, createLogger as xe, throwifyAnyEither as C, BetterTaskEither as ke, createCbCollector as Se } from "@tma.js/toolkit";
|
|
3
|
+
import { createLogger as or, deepSnakeToCamelObjKeys as ar } from "@tma.js/toolkit";
|
|
4
|
+
import { BetterPromise as Z, TimeoutError as Te } from "better-promises";
|
|
5
|
+
import { CancelledError as sr, TimeoutError as ur } from "better-promises";
|
|
6
|
+
import { parseLaunchParamsQueryFp as ee, themeParams as Ae, pipeJsonToSchema as te, miniAppsMessage as re, serializeLaunchParamsQuery as $e, parseLaunchParamsQuery as Me } from "@tma.js/transformers";
|
|
7
|
+
import { errorClass as b, errorClassWithData as Le } from "error-kid";
|
|
8
|
+
import { signal as k, computed as ne } from "@tma.js/signals";
|
|
9
|
+
import Ce from "mitt";
|
|
10
|
+
function oe(e) {
|
|
11
|
+
return L(
|
|
12
|
+
l({ TelegramWebviewProxy: l({ postEvent: Y() }) }),
|
|
13
13
|
e
|
|
14
14
|
);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function ae() {
|
|
17
17
|
try {
|
|
18
18
|
return window.self !== window.top;
|
|
19
19
|
} catch {
|
|
20
20
|
return !0;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
var
|
|
24
|
-
if (r || arguments.length === 2) for (var n = 0,
|
|
25
|
-
(
|
|
26
|
-
return e.concat(
|
|
23
|
+
var We = function(e, t, r) {
|
|
24
|
+
if (r || arguments.length === 2) for (var n = 0, a = t.length, o; n < a; n++)
|
|
25
|
+
(o || !(n in t)) && (o || (o = Array.prototype.slice.call(t, 0, n)), o[n] = t[n]);
|
|
26
|
+
return e.concat(o || Array.prototype.slice.call(t));
|
|
27
27
|
};
|
|
28
|
-
function
|
|
28
|
+
function Fe(e) {
|
|
29
29
|
return e;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function y(e, t, r, n, a, o, i, s, u) {
|
|
32
32
|
switch (arguments.length) {
|
|
33
33
|
case 1:
|
|
34
34
|
return e;
|
|
@@ -46,27 +46,27 @@ function E(e, t, r, n, o, a, i, c, u) {
|
|
|
46
46
|
};
|
|
47
47
|
case 5:
|
|
48
48
|
return function() {
|
|
49
|
-
return
|
|
49
|
+
return a(n(r(t(e.apply(this, arguments)))));
|
|
50
50
|
};
|
|
51
51
|
case 6:
|
|
52
52
|
return function() {
|
|
53
|
-
return a(
|
|
53
|
+
return o(a(n(r(t(e.apply(this, arguments))))));
|
|
54
54
|
};
|
|
55
55
|
case 7:
|
|
56
56
|
return function() {
|
|
57
|
-
return i(a(
|
|
57
|
+
return i(o(a(n(r(t(e.apply(this, arguments)))))));
|
|
58
58
|
};
|
|
59
59
|
case 8:
|
|
60
60
|
return function() {
|
|
61
|
-
return
|
|
61
|
+
return s(i(o(a(n(r(t(e.apply(this, arguments))))))));
|
|
62
62
|
};
|
|
63
63
|
case 9:
|
|
64
64
|
return function() {
|
|
65
|
-
return u(
|
|
65
|
+
return u(s(i(o(a(n(r(t(e.apply(this, arguments)))))))));
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function m(e, t, r, n, a, o, i, s, u) {
|
|
70
70
|
switch (arguments.length) {
|
|
71
71
|
case 1:
|
|
72
72
|
return e;
|
|
@@ -77,61 +77,61 @@ function l(e, t, r, n, o, a, i, c, u) {
|
|
|
77
77
|
case 4:
|
|
78
78
|
return n(r(t(e)));
|
|
79
79
|
case 5:
|
|
80
|
-
return
|
|
80
|
+
return a(n(r(t(e))));
|
|
81
81
|
case 6:
|
|
82
|
-
return a(
|
|
82
|
+
return o(a(n(r(t(e)))));
|
|
83
83
|
case 7:
|
|
84
|
-
return i(a(
|
|
84
|
+
return i(o(a(n(r(t(e))))));
|
|
85
85
|
case 8:
|
|
86
|
-
return
|
|
86
|
+
return s(i(o(a(n(r(t(e)))))));
|
|
87
87
|
case 9:
|
|
88
|
-
return u(
|
|
88
|
+
return u(s(i(o(a(n(r(t(e))))))));
|
|
89
89
|
default: {
|
|
90
|
-
for (var
|
|
91
|
-
|
|
92
|
-
return
|
|
90
|
+
for (var c = arguments[0], p = 1; p < arguments.length; p++)
|
|
91
|
+
c = arguments[p](c);
|
|
92
|
+
return c;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
var
|
|
96
|
+
var W = function(e, t) {
|
|
97
97
|
var r = typeof e == "number" ? function(n) {
|
|
98
98
|
return n.length >= e;
|
|
99
99
|
} : e;
|
|
100
100
|
return function() {
|
|
101
101
|
var n = Array.from(arguments);
|
|
102
|
-
return r(arguments) ? t.apply(this, n) : function(
|
|
103
|
-
return t.apply(void 0,
|
|
102
|
+
return r(arguments) ? t.apply(this, n) : function(a) {
|
|
103
|
+
return t.apply(void 0, We([a], n, !1));
|
|
104
104
|
};
|
|
105
105
|
};
|
|
106
|
-
},
|
|
106
|
+
}, qe = { _tag: "None" }, Oe = function(e) {
|
|
107
107
|
return { _tag: "Some", value: e };
|
|
108
|
-
},
|
|
108
|
+
}, Re = function(e) {
|
|
109
109
|
return e._tag === "Left";
|
|
110
|
-
},
|
|
110
|
+
}, Ue = function(e) {
|
|
111
111
|
return { _tag: "Left", left: e };
|
|
112
|
-
},
|
|
112
|
+
}, Ie = function(e) {
|
|
113
113
|
return { _tag: "Right", right: e };
|
|
114
|
-
},
|
|
115
|
-
return
|
|
116
|
-
}),
|
|
114
|
+
}, w = Ue, _ = Ie, ie = /* @__PURE__ */ W(2, function(e, t) {
|
|
115
|
+
return E(e) ? e : t(e.right);
|
|
116
|
+
}), je = function(e) {
|
|
117
117
|
return function(t) {
|
|
118
|
-
return
|
|
118
|
+
return E(t) ? t : _(e(t.right));
|
|
119
119
|
};
|
|
120
|
-
},
|
|
120
|
+
}, ze = function(e) {
|
|
121
121
|
return function(t) {
|
|
122
|
-
return
|
|
122
|
+
return E(t) ? w(e(t.left)) : t;
|
|
123
123
|
};
|
|
124
|
-
},
|
|
124
|
+
}, E = Re, se = function(e, t) {
|
|
125
125
|
return function(r) {
|
|
126
|
-
return
|
|
126
|
+
return E(r) ? e(r.left) : t(r.right);
|
|
127
127
|
};
|
|
128
|
-
},
|
|
128
|
+
}, Ge = se, F = se, Ve = F, q = function(e, t) {
|
|
129
129
|
try {
|
|
130
|
-
return
|
|
130
|
+
return _(e());
|
|
131
131
|
} catch (r) {
|
|
132
|
-
return
|
|
132
|
+
return w(t(r));
|
|
133
133
|
}
|
|
134
|
-
},
|
|
134
|
+
}, De = ie, Ne = ie, Be = qe, Je = Oe, Qe = function(e) {
|
|
135
135
|
return e._tag === "None";
|
|
136
136
|
}, He = function(e, t) {
|
|
137
137
|
return function(r) {
|
|
@@ -139,34 +139,29 @@ var $ = function(e, t) {
|
|
|
139
139
|
};
|
|
140
140
|
}, Ke = He;
|
|
141
141
|
function Ye(e) {
|
|
142
|
-
return
|
|
142
|
+
return y(_, e.of);
|
|
143
143
|
}
|
|
144
144
|
function Xe(e) {
|
|
145
|
-
return
|
|
145
|
+
return y(w, e.of);
|
|
146
146
|
}
|
|
147
147
|
function Ze(e) {
|
|
148
148
|
return function(t, r) {
|
|
149
149
|
return e.chain(t, function(n) {
|
|
150
|
-
return
|
|
150
|
+
return E(n) ? e.of(n) : r(n.right);
|
|
151
151
|
});
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
|
-
function Ve(e) {
|
|
155
|
-
return function(t, r) {
|
|
156
|
-
return e.map(t, ue(r));
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
154
|
function et(e) {
|
|
160
155
|
return function(t, r) {
|
|
161
156
|
return function(n) {
|
|
162
|
-
return e.map(n,
|
|
157
|
+
return e.map(n, F(t, r));
|
|
163
158
|
};
|
|
164
159
|
};
|
|
165
160
|
}
|
|
166
|
-
var
|
|
167
|
-
return
|
|
161
|
+
var ue = function(e, t) {
|
|
162
|
+
return m(e, rt(t));
|
|
168
163
|
}, tt = function(e, t) {
|
|
169
|
-
return
|
|
164
|
+
return m(e, nt(t));
|
|
170
165
|
}, rt = function(e) {
|
|
171
166
|
return function(t) {
|
|
172
167
|
return function() {
|
|
@@ -177,148 +172,42 @@ var _e = function(e, t) {
|
|
|
177
172
|
return function(t) {
|
|
178
173
|
return function() {
|
|
179
174
|
return Promise.all([Promise.resolve().then(t), Promise.resolve().then(e)]).then(function(r) {
|
|
180
|
-
var n = r[0],
|
|
181
|
-
return n(
|
|
175
|
+
var n = r[0], a = r[1];
|
|
176
|
+
return n(a);
|
|
182
177
|
});
|
|
183
178
|
};
|
|
184
179
|
};
|
|
185
|
-
},
|
|
180
|
+
}, ce = function(e) {
|
|
186
181
|
return function() {
|
|
187
182
|
return Promise.resolve(e);
|
|
188
183
|
};
|
|
189
|
-
},
|
|
184
|
+
}, ot = /* @__PURE__ */ W(2, function(e, t) {
|
|
190
185
|
return function() {
|
|
191
186
|
return Promise.resolve().then(e).then(function(r) {
|
|
192
187
|
return t(r)();
|
|
193
188
|
});
|
|
194
189
|
};
|
|
195
|
-
}),
|
|
196
|
-
URI:
|
|
197
|
-
map:
|
|
198
|
-
},
|
|
199
|
-
of:
|
|
200
|
-
},
|
|
201
|
-
URI:
|
|
202
|
-
map:
|
|
203
|
-
of:
|
|
190
|
+
}), pe = "Task", at = {
|
|
191
|
+
URI: pe,
|
|
192
|
+
map: ue
|
|
193
|
+
}, _e = {
|
|
194
|
+
of: ce
|
|
195
|
+
}, it = {
|
|
196
|
+
URI: pe,
|
|
197
|
+
map: ue,
|
|
198
|
+
of: ce,
|
|
204
199
|
ap: tt,
|
|
205
|
-
chain:
|
|
206
|
-
}, st =
|
|
207
|
-
|
|
208
|
-
return a instanceof r ? a : new r(function(i) {
|
|
209
|
-
i(a);
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
return new (r || (r = Promise))(function(a, i) {
|
|
213
|
-
function c(p) {
|
|
214
|
-
try {
|
|
215
|
-
s(n.next(p));
|
|
216
|
-
} catch (w) {
|
|
217
|
-
i(w);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
function u(p) {
|
|
221
|
-
try {
|
|
222
|
-
s(n.throw(p));
|
|
223
|
-
} catch (w) {
|
|
224
|
-
i(w);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
function s(p) {
|
|
228
|
-
p.done ? a(p.value) : o(p.value).then(c, u);
|
|
229
|
-
}
|
|
230
|
-
s((n = n.apply(e, t || [])).next());
|
|
231
|
-
});
|
|
232
|
-
}, it = function(e, t) {
|
|
233
|
-
var r = { label: 0, sent: function() {
|
|
234
|
-
if (a[0] & 1) throw a[1];
|
|
235
|
-
return a[1];
|
|
236
|
-
}, trys: [], ops: [] }, n, o, a, i;
|
|
237
|
-
return i = { next: c(0), throw: c(1), return: c(2) }, typeof Symbol == "function" && (i[Symbol.iterator] = function() {
|
|
238
|
-
return this;
|
|
239
|
-
}), i;
|
|
240
|
-
function c(s) {
|
|
241
|
-
return function(p) {
|
|
242
|
-
return u([s, p]);
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
function u(s) {
|
|
246
|
-
if (n) throw new TypeError("Generator is already executing.");
|
|
247
|
-
for (; i && (i = 0, s[0] && (r = 0)), r; ) try {
|
|
248
|
-
if (n = 1, o && (a = s[0] & 2 ? o.return : s[0] ? o.throw || ((a = o.return) && a.call(o), 0) : o.next) && !(a = a.call(o, s[1])).done) return a;
|
|
249
|
-
switch (o = 0, a && (s = [s[0] & 2, a.value]), s[0]) {
|
|
250
|
-
case 0:
|
|
251
|
-
case 1:
|
|
252
|
-
a = s;
|
|
253
|
-
break;
|
|
254
|
-
case 4:
|
|
255
|
-
return r.label++, { value: s[1], done: !1 };
|
|
256
|
-
case 5:
|
|
257
|
-
r.label++, o = s[1], s = [0];
|
|
258
|
-
continue;
|
|
259
|
-
case 7:
|
|
260
|
-
s = r.ops.pop(), r.trys.pop();
|
|
261
|
-
continue;
|
|
262
|
-
default:
|
|
263
|
-
if (a = r.trys, !(a = a.length > 0 && a[a.length - 1]) && (s[0] === 6 || s[0] === 2)) {
|
|
264
|
-
r = 0;
|
|
265
|
-
continue;
|
|
266
|
-
}
|
|
267
|
-
if (s[0] === 3 && (!a || s[1] > a[0] && s[1] < a[3])) {
|
|
268
|
-
r.label = s[1];
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
-
if (s[0] === 6 && r.label < a[1]) {
|
|
272
|
-
r.label = a[1], a = s;
|
|
273
|
-
break;
|
|
274
|
-
}
|
|
275
|
-
if (a && r.label < a[2]) {
|
|
276
|
-
r.label = a[2], r.ops.push(s);
|
|
277
|
-
break;
|
|
278
|
-
}
|
|
279
|
-
a[2] && r.ops.pop(), r.trys.pop();
|
|
280
|
-
continue;
|
|
281
|
-
}
|
|
282
|
-
s = t.call(e, r);
|
|
283
|
-
} catch (p) {
|
|
284
|
-
s = [6, p], o = 0;
|
|
285
|
-
} finally {
|
|
286
|
-
n = a = 0;
|
|
287
|
-
}
|
|
288
|
-
if (s[0] & 5) throw s[1];
|
|
289
|
-
return { value: s[0] ? s[1] : void 0, done: !0 };
|
|
290
|
-
}
|
|
291
|
-
}, ct = /* @__PURE__ */ Xe(we), me = /* @__PURE__ */ Ye(we), ut = I, A = /* @__PURE__ */ et(le), pt = function(e, t) {
|
|
292
|
-
return function() {
|
|
293
|
-
return st(void 0, void 0, void 0, function() {
|
|
294
|
-
var r;
|
|
295
|
-
return it(this, function(n) {
|
|
296
|
-
switch (n.label) {
|
|
297
|
-
case 0:
|
|
298
|
-
return n.trys.push([0, 2, , 3]), [4, e().then(ie)];
|
|
299
|
-
case 1:
|
|
300
|
-
return [2, n.sent()];
|
|
301
|
-
case 2:
|
|
302
|
-
return r = n.sent(), [2, se(t(r))];
|
|
303
|
-
case 3:
|
|
304
|
-
return [
|
|
305
|
-
2
|
|
306
|
-
/*return*/
|
|
307
|
-
];
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
});
|
|
311
|
-
};
|
|
312
|
-
}, _t = /* @__PURE__ */ $(2, Ve(le)), ft = _t, lt = /* @__PURE__ */ $(2, Ze(ot)), ge = lt;
|
|
313
|
-
class wt extends y("MethodUnsupportedError", (t, r) => [
|
|
200
|
+
chain: ot
|
|
201
|
+
}, st = /* @__PURE__ */ Xe(_e), fe = /* @__PURE__ */ Ye(_e), le = /* @__PURE__ */ et(at), me = /* @__PURE__ */ W(2, Ze(it)), ut = me, ct = me;
|
|
202
|
+
class pt extends b("MethodUnsupportedError", (t, r) => [
|
|
314
203
|
`Method "${t}" is unsupported in Mini Apps version ${r}`
|
|
315
204
|
]) {
|
|
316
205
|
}
|
|
317
|
-
class
|
|
206
|
+
class _t extends b("MethodParameterUnsupportedError", (t, r, n) => [
|
|
318
207
|
`Parameter "${r}" of "${t}" method is unsupported in Mini Apps version ${n}`
|
|
319
208
|
]) {
|
|
320
209
|
}
|
|
321
|
-
class
|
|
210
|
+
class ft extends Le(
|
|
322
211
|
"LaunchParamsRetrieveError",
|
|
323
212
|
(t) => ({ errors: t }),
|
|
324
213
|
(t) => [
|
|
@@ -334,102 +223,102 @@ class gt extends qe(
|
|
|
334
223
|
]
|
|
335
224
|
) {
|
|
336
225
|
}
|
|
337
|
-
class
|
|
226
|
+
class lt extends b("InvalidLaunchParamsError", (t, r) => [
|
|
338
227
|
`Invalid value for launch params: ${t}`,
|
|
339
228
|
{ cause: r }
|
|
340
229
|
]) {
|
|
341
230
|
}
|
|
342
|
-
class
|
|
231
|
+
class mt extends b("UnknownEnvError") {
|
|
343
232
|
}
|
|
344
|
-
class
|
|
233
|
+
class wt extends b(
|
|
345
234
|
"InvokeCustomMethodError",
|
|
346
235
|
(t) => [`Server returned error: ${t}`]
|
|
347
236
|
) {
|
|
348
237
|
}
|
|
349
|
-
const
|
|
350
|
-
function
|
|
238
|
+
const G = "launchParams";
|
|
239
|
+
function V(e) {
|
|
351
240
|
return e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&");
|
|
352
241
|
}
|
|
353
|
-
const
|
|
242
|
+
const gt = y(S, De(ee)), jt = x(gt), ht = y(S, je((e) => {
|
|
354
243
|
const t = new URLSearchParams(e).get("tgWebAppData");
|
|
355
|
-
return t ?
|
|
356
|
-
})),
|
|
357
|
-
|
|
358
|
-
|
|
244
|
+
return t ? Je(t) : Be;
|
|
245
|
+
})), zt = y(
|
|
246
|
+
ht,
|
|
247
|
+
Ve((e) => {
|
|
359
248
|
throw e;
|
|
360
249
|
}, (e) => e),
|
|
361
250
|
Ke(() => {
|
|
362
251
|
}, (e) => e)
|
|
363
252
|
);
|
|
364
|
-
function
|
|
253
|
+
function S() {
|
|
365
254
|
const e = [];
|
|
366
255
|
for (const [t, r] of [
|
|
367
256
|
// Try to retrieve launch parameters from the current location. This method
|
|
368
257
|
// can return nothing in case, location was changed, and then the page was
|
|
369
258
|
// reloaded.
|
|
370
|
-
[() =>
|
|
259
|
+
[() => V(window.location.href), "window.location.href"],
|
|
371
260
|
// Then, try using the lower level API - window.performance.
|
|
372
261
|
[() => {
|
|
373
262
|
const n = performance.getEntriesByType("navigation")[0];
|
|
374
|
-
return n &&
|
|
263
|
+
return n && V(n.name);
|
|
375
264
|
}, "performance navigation entries"],
|
|
376
265
|
// Finally, try using the session storage.
|
|
377
|
-
[() =>
|
|
266
|
+
[() => Pe(G), "local storage"]
|
|
378
267
|
]) {
|
|
379
268
|
const n = t();
|
|
380
269
|
if (!n) {
|
|
381
270
|
e.push({ source: r, error: new Error("Source is empty") });
|
|
382
271
|
continue;
|
|
383
272
|
}
|
|
384
|
-
const
|
|
273
|
+
const a = m(
|
|
385
274
|
ee(n),
|
|
386
|
-
|
|
275
|
+
Ge((o) => o, () => !0)
|
|
387
276
|
);
|
|
388
|
-
if (typeof
|
|
389
|
-
e.push({ source: r, error:
|
|
277
|
+
if (typeof a != "boolean") {
|
|
278
|
+
e.push({ source: r, error: a });
|
|
390
279
|
continue;
|
|
391
280
|
}
|
|
392
|
-
return
|
|
281
|
+
return X(G, n), _(n);
|
|
393
282
|
}
|
|
394
|
-
return
|
|
395
|
-
}
|
|
396
|
-
const
|
|
397
|
-
function
|
|
398
|
-
const r = /* @__PURE__ */ new Map(), n =
|
|
399
|
-
const u = r.get(
|
|
400
|
-
r.set(
|
|
401
|
-
const
|
|
402
|
-
u.set(i,
|
|
403
|
-
const p =
|
|
404
|
-
if (p >= 0 && (n.off(
|
|
405
|
-
const
|
|
406
|
-
r.delete(
|
|
283
|
+
return w(new ft(e));
|
|
284
|
+
}
|
|
285
|
+
const Gt = x(S);
|
|
286
|
+
function dt(e, t) {
|
|
287
|
+
const r = /* @__PURE__ */ new Map(), n = Ce(), a = (o, i, s = !1) => {
|
|
288
|
+
const u = r.get(o) || /* @__PURE__ */ new Map();
|
|
289
|
+
r.set(o, u);
|
|
290
|
+
const c = u.get(i) || [];
|
|
291
|
+
u.set(i, c);
|
|
292
|
+
const p = c.findIndex((f) => f[1] === s);
|
|
293
|
+
if (p >= 0 && (n.off(o, c[p][0]), c.splice(p, 1), !c.length && (u.delete(i), !u.size))) {
|
|
294
|
+
const f = r.size;
|
|
295
|
+
r.delete(o), f && !r.size && t();
|
|
407
296
|
}
|
|
408
297
|
};
|
|
409
298
|
return {
|
|
410
|
-
on(
|
|
299
|
+
on(o, i, s) {
|
|
411
300
|
!r.size && e();
|
|
412
301
|
const u = () => {
|
|
413
|
-
o
|
|
414
|
-
},
|
|
415
|
-
|
|
302
|
+
a(o, i, s);
|
|
303
|
+
}, c = (...T) => {
|
|
304
|
+
s && u(), o === "*" ? i({ name: T[0], payload: T[1] }) : i(...T);
|
|
416
305
|
};
|
|
417
|
-
n.on(
|
|
418
|
-
const p = r.get(
|
|
419
|
-
r.set(
|
|
420
|
-
const
|
|
421
|
-
return p.set(i,
|
|
306
|
+
n.on(o, c);
|
|
307
|
+
const p = r.get(o) || /* @__PURE__ */ new Map();
|
|
308
|
+
r.set(o, p);
|
|
309
|
+
const f = p.get(i) || [];
|
|
310
|
+
return p.set(i, f), f.push([c, s || !1]), u;
|
|
422
311
|
},
|
|
423
|
-
off:
|
|
312
|
+
off: a,
|
|
424
313
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
425
314
|
emit: n.emit,
|
|
426
315
|
clear() {
|
|
427
|
-
const
|
|
428
|
-
n.all.clear(), r.clear(),
|
|
316
|
+
const o = r.size;
|
|
317
|
+
n.all.clear(), r.clear(), o && t();
|
|
429
318
|
}
|
|
430
319
|
};
|
|
431
320
|
}
|
|
432
|
-
function
|
|
321
|
+
function A(e, t) {
|
|
433
322
|
window.dispatchEvent(new MessageEvent("message", {
|
|
434
323
|
data: JSON.stringify({ eventType: e, eventData: t }),
|
|
435
324
|
// We specify this kind of source here in order to allow the package's "on" function to
|
|
@@ -438,44 +327,44 @@ function C(e, t) {
|
|
|
438
327
|
source: window.parent
|
|
439
328
|
}));
|
|
440
329
|
}
|
|
441
|
-
function
|
|
442
|
-
const n = [r],
|
|
443
|
-
typeof
|
|
444
|
-
const
|
|
445
|
-
n.forEach((u) => u(...
|
|
446
|
-
}, i = Object.assign((...
|
|
447
|
-
|
|
330
|
+
function $(e, t, r) {
|
|
331
|
+
const n = [r], a = e[t];
|
|
332
|
+
typeof a == "function" && n.push(a);
|
|
333
|
+
const o = (...s) => {
|
|
334
|
+
n.forEach((u) => u(...s));
|
|
335
|
+
}, i = Object.assign((...s) => {
|
|
336
|
+
o(...s);
|
|
448
337
|
}, {
|
|
449
338
|
// Unwraps the composer.
|
|
450
339
|
unwrap() {
|
|
451
|
-
const { length:
|
|
452
|
-
if (
|
|
340
|
+
const { length: s } = n;
|
|
341
|
+
if (s === 1) {
|
|
453
342
|
delete e[t];
|
|
454
343
|
return;
|
|
455
344
|
}
|
|
456
|
-
if (
|
|
457
|
-
|
|
345
|
+
if (s === 2) {
|
|
346
|
+
N(e, t, n[1]);
|
|
458
347
|
return;
|
|
459
348
|
}
|
|
460
|
-
n.unshift(1),
|
|
349
|
+
n.unshift(1), N(e, t, o);
|
|
461
350
|
}
|
|
462
351
|
});
|
|
463
|
-
|
|
352
|
+
we(
|
|
464
353
|
e,
|
|
465
354
|
t,
|
|
466
355
|
() => i,
|
|
467
|
-
(
|
|
356
|
+
(s) => n.push(s)
|
|
468
357
|
);
|
|
469
358
|
}
|
|
470
|
-
function
|
|
359
|
+
function D(e, t) {
|
|
471
360
|
const r = e[t];
|
|
472
|
-
|
|
473
|
-
Object.entries(n).forEach(([
|
|
474
|
-
r[
|
|
361
|
+
we(e, t, () => r, (n) => {
|
|
362
|
+
Object.entries(n).forEach(([a, o]) => {
|
|
363
|
+
r[a] = o;
|
|
475
364
|
});
|
|
476
365
|
});
|
|
477
366
|
}
|
|
478
|
-
function
|
|
367
|
+
function we(e, t, r, n) {
|
|
479
368
|
Object.defineProperty(e, t, {
|
|
480
369
|
enumerable: !0,
|
|
481
370
|
configurable: !0,
|
|
@@ -483,7 +372,7 @@ function he(e, t, r, n) {
|
|
|
483
372
|
set: n
|
|
484
373
|
});
|
|
485
374
|
}
|
|
486
|
-
function
|
|
375
|
+
function N(e, t, r) {
|
|
487
376
|
Object.defineProperty(e, t, {
|
|
488
377
|
enumerable: !0,
|
|
489
378
|
configurable: !0,
|
|
@@ -491,27 +380,27 @@ function H(e, t, r) {
|
|
|
491
380
|
value: r
|
|
492
381
|
});
|
|
493
382
|
}
|
|
494
|
-
const
|
|
495
|
-
clipboard_text_received:
|
|
496
|
-
req_id:
|
|
497
|
-
data: d(
|
|
383
|
+
const vt = {
|
|
384
|
+
clipboard_text_received: l({
|
|
385
|
+
req_id: d(),
|
|
386
|
+
data: h(d())
|
|
498
387
|
}),
|
|
499
|
-
custom_method_invoked:
|
|
500
|
-
req_id:
|
|
501
|
-
result:
|
|
502
|
-
error:
|
|
388
|
+
custom_method_invoked: l({
|
|
389
|
+
req_id: d(),
|
|
390
|
+
result: z(ye()),
|
|
391
|
+
error: z(d())
|
|
503
392
|
}),
|
|
504
|
-
popup_closed:
|
|
505
|
-
|
|
393
|
+
popup_closed: h(
|
|
394
|
+
l({ button_id: h(d(), () => {
|
|
506
395
|
}) }),
|
|
507
396
|
{}
|
|
508
397
|
),
|
|
509
|
-
viewport_changed:
|
|
510
|
-
|
|
511
|
-
height:
|
|
512
|
-
width:
|
|
513
|
-
is_state_stable:
|
|
514
|
-
is_expanded:
|
|
398
|
+
viewport_changed: h(
|
|
399
|
+
l({
|
|
400
|
+
height: j(),
|
|
401
|
+
width: h(j(), () => window.innerWidth),
|
|
402
|
+
is_state_stable: I(),
|
|
403
|
+
is_expanded: I()
|
|
515
404
|
}),
|
|
516
405
|
// TODO: At the moment, macOS has a bug with the invalid event payload - it is always equal to
|
|
517
406
|
// null. Leaving this default value until the bug is fixed.
|
|
@@ -521,46 +410,46 @@ const Pt = {
|
|
|
521
410
|
is_expanded: !0
|
|
522
411
|
})
|
|
523
412
|
),
|
|
524
|
-
theme_changed:
|
|
525
|
-
theme_params:
|
|
413
|
+
theme_changed: l({
|
|
414
|
+
theme_params: Ae()
|
|
526
415
|
})
|
|
527
416
|
};
|
|
528
|
-
function
|
|
417
|
+
function B(e) {
|
|
529
418
|
if (e.source !== window.parent)
|
|
530
419
|
return;
|
|
531
420
|
let t;
|
|
532
421
|
try {
|
|
533
|
-
t =
|
|
422
|
+
t = M(te(re()), e.data);
|
|
534
423
|
} catch {
|
|
535
424
|
return;
|
|
536
425
|
}
|
|
537
|
-
const { eventType: r, eventData: n } = t,
|
|
538
|
-
let
|
|
426
|
+
const { eventType: r, eventData: n } = t, a = vt[r];
|
|
427
|
+
let o;
|
|
539
428
|
try {
|
|
540
|
-
|
|
429
|
+
o = a ? M(a, n) : n;
|
|
541
430
|
} catch (i) {
|
|
542
|
-
return
|
|
431
|
+
return g().forceError(
|
|
543
432
|
[
|
|
544
433
|
`An error occurred processing the "${r}" event from the Telegram application.`,
|
|
545
434
|
"Please, file an issue here:",
|
|
546
|
-
"https://github.com/Telegram-Mini-Apps/
|
|
435
|
+
"https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose"
|
|
547
436
|
].join(`
|
|
548
437
|
`),
|
|
549
438
|
t,
|
|
550
439
|
i
|
|
551
440
|
);
|
|
552
441
|
}
|
|
553
|
-
|
|
442
|
+
yt(r, o);
|
|
554
443
|
}
|
|
555
444
|
const {
|
|
556
|
-
on:
|
|
557
|
-
off:
|
|
558
|
-
emit:
|
|
559
|
-
clear:
|
|
560
|
-
} =
|
|
445
|
+
on: ge,
|
|
446
|
+
off: bt,
|
|
447
|
+
emit: yt,
|
|
448
|
+
clear: Et
|
|
449
|
+
} = dt(
|
|
561
450
|
() => {
|
|
562
451
|
const e = window;
|
|
563
|
-
!e.TelegramGameProxy && (e.TelegramGameProxy = {}),
|
|
452
|
+
!e.TelegramGameProxy && (e.TelegramGameProxy = {}), $(e.TelegramGameProxy, "receiveEvent", A), D(e, "TelegramGameProxy"), !e.Telegram && (e.Telegram = {}), !e.Telegram.WebView && (e.Telegram.WebView = {}), $(e.Telegram.WebView, "receiveEvent", A), D(e.Telegram, "WebView"), $(e, "TelegramGameProxy_receiveEvent", A), window.addEventListener("message", B);
|
|
564
453
|
},
|
|
565
454
|
() => {
|
|
566
455
|
[
|
|
@@ -570,412 +459,398 @@ const {
|
|
|
570
459
|
].forEach((e) => {
|
|
571
460
|
const t = window;
|
|
572
461
|
let r = [void 0, t];
|
|
573
|
-
for (const
|
|
574
|
-
if (r = [r[1], r[1][
|
|
462
|
+
for (const o of e)
|
|
463
|
+
if (r = [r[1], r[1][o]], !r[1])
|
|
575
464
|
return;
|
|
576
|
-
const [n,
|
|
577
|
-
"unwrap" in
|
|
578
|
-
}), window.removeEventListener("message",
|
|
465
|
+
const [n, a] = r;
|
|
466
|
+
"unwrap" in a && (a.unwrap(), n && n !== t && !Object.keys(n).length && delete t[e[0]]);
|
|
467
|
+
}), window.removeEventListener("message", B);
|
|
579
468
|
}
|
|
580
|
-
),
|
|
581
|
-
|
|
582
|
-
},
|
|
583
|
-
function
|
|
584
|
-
e !==
|
|
469
|
+
), P = k(!1), O = k("https://web.telegram.org"), Pt = (e) => {
|
|
470
|
+
g().log("Event received:", e);
|
|
471
|
+
}, he = ne(P);
|
|
472
|
+
function Vt(e) {
|
|
473
|
+
e !== P() && (P.set(e), (e ? ge : bt)("*", Pt));
|
|
585
474
|
}
|
|
586
|
-
const
|
|
587
|
-
function
|
|
588
|
-
|
|
475
|
+
const de = ne(O);
|
|
476
|
+
function Dt(e) {
|
|
477
|
+
O.set(e), g().log("New target origin set", e);
|
|
589
478
|
}
|
|
590
|
-
const
|
|
479
|
+
const v = k((...e) => {
|
|
591
480
|
window.parent.postMessage(...e);
|
|
592
|
-
}),
|
|
481
|
+
}), g = k(xe("Bridge", {
|
|
593
482
|
bgColor: "#9147ff",
|
|
594
483
|
textColor: "white",
|
|
595
|
-
shouldLog:
|
|
484
|
+
shouldLog: he
|
|
596
485
|
}));
|
|
597
|
-
function
|
|
598
|
-
|
|
486
|
+
function Nt() {
|
|
487
|
+
Et(), [v, O, de, P, he, g].forEach((e) => {
|
|
599
488
|
e.unsubAll(), "reset" in e && e.reset();
|
|
600
489
|
});
|
|
601
490
|
}
|
|
602
|
-
const
|
|
603
|
-
function
|
|
604
|
-
|
|
605
|
-
|
|
491
|
+
const xt = (...e) => v()(...e);
|
|
492
|
+
function kt(e, t) {
|
|
493
|
+
m(
|
|
494
|
+
R(
|
|
606
495
|
// @ts-expect-error It's ok, TS can't determine a specific override.
|
|
607
496
|
e,
|
|
608
497
|
t
|
|
609
498
|
),
|
|
610
|
-
|
|
499
|
+
ze((r) => {
|
|
611
500
|
throw r;
|
|
612
501
|
})
|
|
613
502
|
);
|
|
614
503
|
}
|
|
615
|
-
function
|
|
616
|
-
|
|
504
|
+
function R(e, t) {
|
|
505
|
+
g().log("Posting event:", t ? { eventType: e, eventData: t } : { eventType: e });
|
|
617
506
|
const r = window, n = JSON.stringify({ eventType: e, eventData: t });
|
|
618
|
-
return
|
|
507
|
+
return ae() ? (xt(n, de()), _(void 0)) : oe(r) ? (r.TelegramWebviewProxy.postEvent(e, JSON.stringify(t)), _(void 0)) : L(l({ external: l({ notify: Y() }) }), r) ? (r.external.notify(n), _(void 0)) : w(new mt());
|
|
619
508
|
}
|
|
620
|
-
function
|
|
621
|
-
r || (r = {});
|
|
509
|
+
function U(e, t, r = {}) {
|
|
622
510
|
const {
|
|
623
511
|
// If no capture function was passed, we capture the first compatible event.
|
|
624
512
|
capture: n = () => !0,
|
|
625
|
-
postEvent:
|
|
626
|
-
} = r
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
}
|
|
639
|
-
ge(() => pt(() => c, (u) => u))
|
|
513
|
+
postEvent: a = R
|
|
514
|
+
} = r;
|
|
515
|
+
return m(
|
|
516
|
+
async () => a(e, r.params),
|
|
517
|
+
ct(() => ke((o, i, s) => {
|
|
518
|
+
const [u, c] = Se();
|
|
519
|
+
(Array.isArray(t) ? t : [t]).forEach((p) => {
|
|
520
|
+
u(
|
|
521
|
+
ge(p, (f) => {
|
|
522
|
+
(Array.isArray(t) ? n({ event: p, payload: f }) : n(f)) && o(f);
|
|
523
|
+
})
|
|
524
|
+
);
|
|
525
|
+
}), s.on("finalized", c);
|
|
526
|
+
}, r))
|
|
640
527
|
);
|
|
641
528
|
}
|
|
642
|
-
function
|
|
529
|
+
function Bt(e, t, r) {
|
|
643
530
|
const { postEvent: n } = r || {};
|
|
644
|
-
return
|
|
531
|
+
return C(
|
|
645
532
|
// @ts-expect-error TypeScript will not be able to handle our overrides here.
|
|
646
|
-
|
|
533
|
+
U(e, t, {
|
|
647
534
|
...r,
|
|
648
|
-
postEvent: n ? (...
|
|
535
|
+
postEvent: n ? (...a) => {
|
|
649
536
|
try {
|
|
650
|
-
return n(...
|
|
651
|
-
} catch (
|
|
652
|
-
return
|
|
537
|
+
return n(...a), _(void 0);
|
|
538
|
+
} catch (o) {
|
|
539
|
+
return w(o);
|
|
653
540
|
}
|
|
654
|
-
} :
|
|
655
|
-
})
|
|
656
|
-
|
|
657
|
-
(o) => {
|
|
658
|
-
throw o;
|
|
659
|
-
},
|
|
660
|
-
(o) => o
|
|
661
|
-
)
|
|
662
|
-
)());
|
|
541
|
+
} : R
|
|
542
|
+
})
|
|
543
|
+
);
|
|
663
544
|
}
|
|
664
|
-
function
|
|
665
|
-
const r =
|
|
545
|
+
function Jt(e, t) {
|
|
546
|
+
const r = St(
|
|
666
547
|
// @ts-expect-error TS doesn't get what override we are going to use.
|
|
667
548
|
e,
|
|
668
549
|
t
|
|
669
550
|
);
|
|
670
|
-
return typeof r == "function" ?
|
|
671
|
-
(n) => {
|
|
672
|
-
throw n;
|
|
673
|
-
},
|
|
674
|
-
(n) => n
|
|
675
|
-
))()) : r;
|
|
551
|
+
return typeof r == "function" ? Z.fn(() => C(r)) : r;
|
|
676
552
|
}
|
|
677
|
-
function
|
|
678
|
-
const r =
|
|
553
|
+
function St(e, t) {
|
|
554
|
+
const r = oe(window);
|
|
679
555
|
if (!e)
|
|
680
|
-
return r ||
|
|
556
|
+
return r || m(S(), F(() => !1, () => !0));
|
|
681
557
|
if (r)
|
|
682
|
-
return
|
|
558
|
+
return fe(!0);
|
|
683
559
|
const { timeout: n = 100 } = t || {};
|
|
684
|
-
return
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
(
|
|
688
|
-
() =>
|
|
560
|
+
return m(
|
|
561
|
+
U("web_app_request_theme", "theme_changed", { ...t, timeout: n }),
|
|
562
|
+
le(
|
|
563
|
+
(a) => Te.is(a) ? _(!1) : w(a),
|
|
564
|
+
() => _(!0)
|
|
689
565
|
)
|
|
690
566
|
);
|
|
691
567
|
}
|
|
692
|
-
function
|
|
568
|
+
function Qt({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
|
|
693
569
|
if (e) {
|
|
694
|
-
const
|
|
570
|
+
const o = typeof e == "string" || e instanceof URLSearchParams ? e.toString() : (
|
|
695
571
|
// Here we have to trick serializeLaunchParamsQuery into thinking, it serializes a valid
|
|
696
572
|
// value. We are doing it because we are working with tgWebAppData presented as a
|
|
697
573
|
// string, not an object as serializeLaunchParamsQuery requires.
|
|
698
|
-
|
|
574
|
+
$e({ ...e, tgWebAppData: void 0 }) + (e.tgWebAppData ? `&tgWebAppData=${encodeURIComponent(e.tgWebAppData.toString())}` : "")
|
|
699
575
|
);
|
|
700
576
|
try {
|
|
701
|
-
|
|
577
|
+
Me(o);
|
|
702
578
|
} catch (i) {
|
|
703
|
-
throw new
|
|
579
|
+
throw new lt(o, i);
|
|
704
580
|
}
|
|
705
|
-
|
|
581
|
+
X("launchParams", o);
|
|
706
582
|
}
|
|
707
|
-
if (
|
|
583
|
+
if (ae()) {
|
|
708
584
|
if (!t)
|
|
709
585
|
return;
|
|
710
|
-
r &&
|
|
711
|
-
const
|
|
712
|
-
|
|
713
|
-
const [
|
|
714
|
-
|
|
586
|
+
r && v.reset();
|
|
587
|
+
const o = v();
|
|
588
|
+
v.set((...i) => {
|
|
589
|
+
const [s] = i, u = () => {
|
|
590
|
+
o(...i);
|
|
715
591
|
};
|
|
716
592
|
try {
|
|
717
|
-
const
|
|
718
|
-
t([
|
|
593
|
+
const c = M(te(re()), s);
|
|
594
|
+
t([c.eventType, c.eventData], u);
|
|
719
595
|
} catch {
|
|
720
596
|
u();
|
|
721
597
|
}
|
|
722
598
|
});
|
|
723
599
|
return;
|
|
724
600
|
}
|
|
725
|
-
const n = window.TelegramWebviewProxy || {},
|
|
601
|
+
const n = window.TelegramWebviewProxy || {}, a = n.postEvent || (() => {
|
|
726
602
|
});
|
|
727
603
|
window.TelegramWebviewProxy = {
|
|
728
604
|
...n,
|
|
729
|
-
postEvent(
|
|
730
|
-
const
|
|
731
|
-
o
|
|
605
|
+
postEvent(o, i) {
|
|
606
|
+
const s = () => {
|
|
607
|
+
a(o, i);
|
|
732
608
|
};
|
|
733
|
-
t ? t([
|
|
609
|
+
t ? t([o, i ? JSON.parse(i) : void 0], s) : s();
|
|
734
610
|
}
|
|
735
|
-
},
|
|
611
|
+
}, g().log("Environment was mocked by the mockTelegramEnv function");
|
|
736
612
|
}
|
|
737
|
-
function
|
|
613
|
+
function Tt(e) {
|
|
738
614
|
return ({ req_id: t }) => t === e;
|
|
739
615
|
}
|
|
740
|
-
function
|
|
616
|
+
function J(e) {
|
|
741
617
|
return e.split(".").map(Number);
|
|
742
618
|
}
|
|
743
|
-
function
|
|
744
|
-
const r =
|
|
745
|
-
for (let
|
|
746
|
-
const i = r[
|
|
747
|
-
if (i !==
|
|
748
|
-
return i >
|
|
619
|
+
function At(e, t) {
|
|
620
|
+
const r = J(e), n = J(t), a = Math.max(r.length, n.length);
|
|
621
|
+
for (let o = 0; o < a; o += 1) {
|
|
622
|
+
const i = r[o] || 0, s = n[o] || 0;
|
|
623
|
+
if (i !== s)
|
|
624
|
+
return i > s ? 1 : -1;
|
|
749
625
|
}
|
|
750
626
|
return 0;
|
|
751
627
|
}
|
|
752
|
-
|
|
753
|
-
|
|
628
|
+
const Q = {
|
|
629
|
+
"6.0": [
|
|
630
|
+
"iframe_ready",
|
|
631
|
+
"iframe_will_reload",
|
|
632
|
+
"web_app_close",
|
|
633
|
+
"web_app_data_send",
|
|
634
|
+
"web_app_expand",
|
|
635
|
+
"web_app_open_link",
|
|
636
|
+
"web_app_ready",
|
|
637
|
+
"web_app_request_theme",
|
|
638
|
+
"web_app_request_viewport",
|
|
639
|
+
"web_app_setup_main_button",
|
|
640
|
+
"web_app_setup_closing_behavior"
|
|
641
|
+
],
|
|
642
|
+
6.1: [
|
|
643
|
+
"web_app_open_tg_link",
|
|
644
|
+
"web_app_open_invoice",
|
|
645
|
+
"web_app_setup_back_button",
|
|
646
|
+
"web_app_set_background_color",
|
|
647
|
+
"web_app_set_header_color",
|
|
648
|
+
"web_app_trigger_haptic_feedback"
|
|
649
|
+
],
|
|
650
|
+
6.2: ["web_app_open_popup"],
|
|
651
|
+
6.4: [
|
|
652
|
+
"web_app_close_scan_qr_popup",
|
|
653
|
+
"web_app_open_scan_qr_popup",
|
|
654
|
+
"web_app_read_text_from_clipboard",
|
|
655
|
+
{ method: "web_app_open_link", param: "try_instant_view" }
|
|
656
|
+
],
|
|
657
|
+
6.7: ["web_app_switch_inline_query"],
|
|
658
|
+
6.9: [
|
|
659
|
+
"web_app_invoke_custom_method",
|
|
660
|
+
"web_app_request_write_access",
|
|
661
|
+
"web_app_request_phone",
|
|
662
|
+
{ method: "web_app_set_header_color", param: "color" }
|
|
663
|
+
],
|
|
664
|
+
"6.10": ["web_app_setup_settings_button"],
|
|
665
|
+
7.2: [
|
|
666
|
+
"web_app_biometry_get_info",
|
|
667
|
+
"web_app_biometry_open_settings",
|
|
668
|
+
"web_app_biometry_request_access",
|
|
669
|
+
"web_app_biometry_request_auth",
|
|
670
|
+
"web_app_biometry_update_token"
|
|
671
|
+
],
|
|
672
|
+
7.6: [
|
|
673
|
+
{ method: "web_app_open_link", param: "try_browser" },
|
|
674
|
+
{ method: "web_app_close", param: "return_back" }
|
|
675
|
+
],
|
|
676
|
+
7.7: ["web_app_setup_swipe_behavior"],
|
|
677
|
+
7.8: ["web_app_share_to_story"],
|
|
678
|
+
"7.10": [
|
|
679
|
+
"web_app_setup_secondary_button",
|
|
680
|
+
"web_app_set_bottom_bar_color",
|
|
681
|
+
{ method: "web_app_setup_main_button", param: "has_shine_effect" }
|
|
682
|
+
],
|
|
683
|
+
"8.0": [
|
|
684
|
+
"web_app_request_safe_area",
|
|
685
|
+
"web_app_request_content_safe_area",
|
|
686
|
+
"web_app_request_fullscreen",
|
|
687
|
+
"web_app_exit_fullscreen",
|
|
688
|
+
"web_app_set_emoji_status",
|
|
689
|
+
"web_app_add_to_home_screen",
|
|
690
|
+
"web_app_check_home_screen",
|
|
691
|
+
"web_app_request_emoji_status_access",
|
|
692
|
+
"web_app_check_location",
|
|
693
|
+
"web_app_open_location_settings",
|
|
694
|
+
"web_app_request_file_download",
|
|
695
|
+
"web_app_request_location",
|
|
696
|
+
"web_app_send_prepared_message",
|
|
697
|
+
"web_app_start_accelerometer",
|
|
698
|
+
"web_app_start_device_orientation",
|
|
699
|
+
"web_app_start_gyroscope",
|
|
700
|
+
"web_app_stop_accelerometer",
|
|
701
|
+
"web_app_stop_device_orientation",
|
|
702
|
+
"web_app_stop_gyroscope",
|
|
703
|
+
"web_app_toggle_orientation_lock"
|
|
704
|
+
],
|
|
705
|
+
"9.0": [
|
|
706
|
+
"web_app_device_storage_clear",
|
|
707
|
+
"web_app_device_storage_get_key",
|
|
708
|
+
"web_app_device_storage_save_key",
|
|
709
|
+
"web_app_secure_storage_clear",
|
|
710
|
+
"web_app_secure_storage_get_key",
|
|
711
|
+
"web_app_secure_storage_restore_key",
|
|
712
|
+
"web_app_secure_storage_save_key"
|
|
713
|
+
],
|
|
714
|
+
9.1: ["web_app_hide_keyboard"]
|
|
715
|
+
};
|
|
716
|
+
function H(e, t) {
|
|
717
|
+
return Object.keys(Q).find((n) => Q[n].some((a) => t ? typeof a == "object" && a.method === e && a.param === t : a === e)) || null;
|
|
754
718
|
}
|
|
755
|
-
function
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
return _("7.6", r);
|
|
762
|
-
}
|
|
763
|
-
if (e === "web_app_set_header_color" && t === "color")
|
|
764
|
-
return _("6.9", r);
|
|
765
|
-
if (e === "web_app_close" && t === "return_back")
|
|
766
|
-
return _("7.6", r);
|
|
767
|
-
if (e === "web_app_setup_main_button" && t === "has_shine_effect")
|
|
768
|
-
return _("7.10", r);
|
|
769
|
-
}
|
|
770
|
-
switch (e) {
|
|
771
|
-
case "web_app_open_tg_link":
|
|
772
|
-
case "web_app_open_invoice":
|
|
773
|
-
case "web_app_setup_back_button":
|
|
774
|
-
case "web_app_set_background_color":
|
|
775
|
-
case "web_app_set_header_color":
|
|
776
|
-
case "web_app_trigger_haptic_feedback":
|
|
777
|
-
return _("6.1", t);
|
|
778
|
-
case "web_app_open_popup":
|
|
779
|
-
return _("6.2", t);
|
|
780
|
-
case "web_app_close_scan_qr_popup":
|
|
781
|
-
case "web_app_open_scan_qr_popup":
|
|
782
|
-
case "web_app_read_text_from_clipboard":
|
|
783
|
-
return _("6.4", t);
|
|
784
|
-
case "web_app_switch_inline_query":
|
|
785
|
-
return _("6.7", t);
|
|
786
|
-
case "web_app_invoke_custom_method":
|
|
787
|
-
case "web_app_request_write_access":
|
|
788
|
-
case "web_app_request_phone":
|
|
789
|
-
return _("6.9", t);
|
|
790
|
-
case "web_app_setup_settings_button":
|
|
791
|
-
return _("6.10", t);
|
|
792
|
-
case "web_app_biometry_get_info":
|
|
793
|
-
case "web_app_biometry_open_settings":
|
|
794
|
-
case "web_app_biometry_request_access":
|
|
795
|
-
case "web_app_biometry_request_auth":
|
|
796
|
-
case "web_app_biometry_update_token":
|
|
797
|
-
return _("7.2", t);
|
|
798
|
-
case "web_app_setup_swipe_behavior":
|
|
799
|
-
return _("7.7", t);
|
|
800
|
-
case "web_app_share_to_story":
|
|
801
|
-
return _("7.8", t);
|
|
802
|
-
case "web_app_setup_secondary_button":
|
|
803
|
-
case "web_app_set_bottom_bar_color":
|
|
804
|
-
return _("7.10", t);
|
|
805
|
-
case "web_app_request_safe_area":
|
|
806
|
-
case "web_app_request_content_safe_area":
|
|
807
|
-
case "web_app_request_fullscreen":
|
|
808
|
-
case "web_app_exit_fullscreen":
|
|
809
|
-
case "web_app_set_emoji_status":
|
|
810
|
-
case "web_app_add_to_home_screen":
|
|
811
|
-
case "web_app_check_home_screen":
|
|
812
|
-
case "web_app_request_emoji_status_access":
|
|
813
|
-
case "web_app_check_location":
|
|
814
|
-
case "web_app_open_location_settings":
|
|
815
|
-
case "web_app_request_file_download":
|
|
816
|
-
case "web_app_request_location":
|
|
817
|
-
case "web_app_send_prepared_message":
|
|
818
|
-
case "web_app_start_accelerometer":
|
|
819
|
-
case "web_app_start_device_orientation":
|
|
820
|
-
case "web_app_start_gyroscope":
|
|
821
|
-
case "web_app_stop_accelerometer":
|
|
822
|
-
case "web_app_stop_device_orientation":
|
|
823
|
-
case "web_app_stop_gyroscope":
|
|
824
|
-
case "web_app_toggle_orientation_lock":
|
|
825
|
-
return _("8.0", t);
|
|
826
|
-
case "web_app_device_storage_clear":
|
|
827
|
-
case "web_app_device_storage_get_key":
|
|
828
|
-
case "web_app_device_storage_save_key":
|
|
829
|
-
case "web_app_secure_storage_clear":
|
|
830
|
-
case "web_app_secure_storage_get_key":
|
|
831
|
-
case "web_app_secure_storage_restore_key":
|
|
832
|
-
case "web_app_secure_storage_save_key":
|
|
833
|
-
return _("9.0", t);
|
|
834
|
-
case "web_app_hide_keyboard":
|
|
835
|
-
return _("9.1", t);
|
|
836
|
-
default:
|
|
837
|
-
return [
|
|
838
|
-
"iframe_ready",
|
|
839
|
-
"iframe_will_reload",
|
|
840
|
-
"web_app_close",
|
|
841
|
-
"web_app_data_send",
|
|
842
|
-
"web_app_expand",
|
|
843
|
-
"web_app_open_link",
|
|
844
|
-
"web_app_ready",
|
|
845
|
-
"web_app_request_theme",
|
|
846
|
-
"web_app_request_viewport",
|
|
847
|
-
"web_app_setup_main_button",
|
|
848
|
-
"web_app_setup_closing_behavior"
|
|
849
|
-
].includes(e);
|
|
850
|
-
}
|
|
719
|
+
function K(e, t, r) {
|
|
720
|
+
const n = r ? H(
|
|
721
|
+
e,
|
|
722
|
+
t
|
|
723
|
+
) : H(e);
|
|
724
|
+
return n ? At(n, r || t) <= 0 : !1;
|
|
851
725
|
}
|
|
852
|
-
function
|
|
726
|
+
function Ht(e, t = "strict") {
|
|
853
727
|
const r = typeof t == "function" ? t : (n) => {
|
|
854
|
-
const { method:
|
|
728
|
+
const { method: a, version: o } = n, i = "param" in n ? new _t(a, n.param, o) : new pt(a, o);
|
|
855
729
|
if (t === "strict")
|
|
856
730
|
throw i;
|
|
857
|
-
return
|
|
731
|
+
return g().forceWarn(i.message);
|
|
858
732
|
};
|
|
859
|
-
return (n,
|
|
733
|
+
return (n, a) => K(n, e) ? n === "web_app_set_header_color" && L(l({ color: Ee() }), a) && !K(n, "color", e) ? r({ version: e, method: n, param: "color" }) : kt(n, a) : r({ version: e, method: n });
|
|
860
734
|
}
|
|
861
|
-
function
|
|
862
|
-
return
|
|
863
|
-
|
|
735
|
+
function $t(e, t, r, n) {
|
|
736
|
+
return m(
|
|
737
|
+
U("web_app_invoke_custom_method", "custom_method_invoked", {
|
|
864
738
|
...n || {},
|
|
865
739
|
params: { method: e, params: t, req_id: r },
|
|
866
|
-
capture:
|
|
740
|
+
capture: Tt(r)
|
|
867
741
|
}),
|
|
868
|
-
|
|
742
|
+
ut(({ result: a, error: o }) => o ? st(new wt(o)) : fe(a))
|
|
869
743
|
);
|
|
870
744
|
}
|
|
871
|
-
function
|
|
872
|
-
return
|
|
745
|
+
function Kt(e, t, r, n) {
|
|
746
|
+
return Z.fn(() => m(
|
|
873
747
|
// @ts-expect-error TypeScript is unable to determine required override.
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
(
|
|
877
|
-
throw
|
|
748
|
+
$t(e, t, r, n),
|
|
749
|
+
le(
|
|
750
|
+
(a) => {
|
|
751
|
+
throw a;
|
|
878
752
|
},
|
|
879
|
-
(
|
|
753
|
+
(a) => a
|
|
880
754
|
)
|
|
881
755
|
)());
|
|
882
756
|
}
|
|
883
|
-
function
|
|
757
|
+
function Yt() {
|
|
884
758
|
Object.hasOwn || (Object.hasOwn = function(e, t) {
|
|
885
759
|
return Object.prototype.hasOwnProperty.call(e, t);
|
|
886
760
|
});
|
|
887
761
|
}
|
|
888
|
-
function
|
|
889
|
-
return
|
|
762
|
+
function ve(e) {
|
|
763
|
+
return q(() => decodeURIComponent(
|
|
890
764
|
atob(e).replace(/-/g, "+").replace(/_/g, "/").split("").map((t) => "%" + ("00" + t.charCodeAt(0).toString(16)).slice(-2)).join("")
|
|
891
765
|
), (t) => t);
|
|
892
766
|
}
|
|
893
|
-
const
|
|
894
|
-
function
|
|
767
|
+
const Xt = x(ve);
|
|
768
|
+
function be(e) {
|
|
895
769
|
return btoa(
|
|
896
770
|
encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, (t, r) => String.fromCharCode(parseInt(`0x${r}`)))
|
|
897
771
|
).replace(/\+/g, "-").replace(/\//g, "_");
|
|
898
772
|
}
|
|
899
|
-
var
|
|
900
|
-
return
|
|
773
|
+
var Mt = function(e) {
|
|
774
|
+
return q(function() {
|
|
901
775
|
return JSON.parse(e);
|
|
902
|
-
},
|
|
776
|
+
}, Fe);
|
|
903
777
|
};
|
|
904
|
-
function
|
|
905
|
-
const t =
|
|
906
|
-
return t.length > 512 ?
|
|
907
|
-
}
|
|
908
|
-
const
|
|
909
|
-
function
|
|
910
|
-
return
|
|
911
|
-
|
|
778
|
+
function Lt(e) {
|
|
779
|
+
const t = be(typeof e == "string" ? e : JSON.stringify(e));
|
|
780
|
+
return t.length > 512 ? w(new Error("Value is too long for start parameter")) : _(t);
|
|
781
|
+
}
|
|
782
|
+
const Zt = x(Lt);
|
|
783
|
+
function er(e, t) {
|
|
784
|
+
return C(
|
|
785
|
+
Ct(
|
|
912
786
|
e,
|
|
913
787
|
// @ts-expect-error TypeScript is unable to detect a correct override.
|
|
914
|
-
typeof t == "function" ? (r) =>
|
|
788
|
+
typeof t == "function" ? (r) => q(() => t(r), (n) => n) : t
|
|
915
789
|
)
|
|
916
790
|
);
|
|
917
791
|
}
|
|
918
|
-
function
|
|
919
|
-
return
|
|
920
|
-
|
|
921
|
-
|
|
792
|
+
function Ct(e, t) {
|
|
793
|
+
return m(
|
|
794
|
+
ve(e),
|
|
795
|
+
Ne((r) => t ? typeof t == "function" ? t(r) : Mt(r) : _(r))
|
|
922
796
|
);
|
|
923
797
|
}
|
|
924
|
-
function
|
|
925
|
-
return
|
|
798
|
+
function tr(e) {
|
|
799
|
+
return be(e).length <= 512;
|
|
926
800
|
}
|
|
927
801
|
export {
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
802
|
+
sr as CancelledError,
|
|
803
|
+
lt as InvalidLaunchParamsError,
|
|
804
|
+
wt as InvokeCustomMethodFailedError,
|
|
805
|
+
ft as LaunchParamsRetrieveError,
|
|
806
|
+
_t as MethodParameterUnsupportedError,
|
|
807
|
+
pt as MethodUnsupportedError,
|
|
934
808
|
ur as TimeoutError,
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
809
|
+
mt as UnknownEnvError,
|
|
810
|
+
Yt as applyPolyfills,
|
|
811
|
+
Tt as captureSameReq,
|
|
812
|
+
At as compareVersions,
|
|
813
|
+
or as createLogger,
|
|
814
|
+
Ht as createPostEvent,
|
|
815
|
+
Zt as createStartParam,
|
|
816
|
+
Lt as createStartParamFp,
|
|
817
|
+
he as debug,
|
|
818
|
+
Xt as decodeBase64Url,
|
|
819
|
+
ve as decodeBase64UrlFp,
|
|
820
|
+
er as decodeStartParam,
|
|
821
|
+
Ct as decodeStartParamFp,
|
|
822
|
+
ar as deepSnakeToCamelObjKeys,
|
|
823
|
+
A as emitEvent,
|
|
824
|
+
be as encodeBase64Url,
|
|
825
|
+
H as getReleaseVersion,
|
|
826
|
+
oe as hasWebviewProxy,
|
|
827
|
+
Kt as invokeCustomMethod,
|
|
828
|
+
$t as invokeCustomMethodFp,
|
|
829
|
+
ae as isIframe,
|
|
830
|
+
tr as isSafeToCreateStartParam,
|
|
831
|
+
Jt as isTMA,
|
|
832
|
+
St as isTMAFp,
|
|
833
|
+
g as logger,
|
|
834
|
+
Qt as mockTelegramEnv,
|
|
835
|
+
bt as off,
|
|
836
|
+
Et as offAll,
|
|
837
|
+
ge as on,
|
|
838
|
+
kt as postEvent,
|
|
839
|
+
R as postEventFp,
|
|
840
|
+
xt as postMessage,
|
|
841
|
+
v as postMessageImpl,
|
|
842
|
+
Bt as request,
|
|
843
|
+
U as requestFp,
|
|
844
|
+
Nt as resetGlobals,
|
|
845
|
+
jt as retrieveLaunchParams,
|
|
846
|
+
gt as retrieveLaunchParamsFp,
|
|
847
|
+
zt as retrieveRawInitData,
|
|
848
|
+
ht as retrieveRawInitDataFp,
|
|
849
|
+
Gt as retrieveRawLaunchParams,
|
|
850
|
+
S as retrieveRawLaunchParamsFp,
|
|
851
|
+
Vt as setDebug,
|
|
852
|
+
Dt as setTargetOrigin,
|
|
853
|
+
K as supports,
|
|
854
|
+
de as targetOrigin
|
|
980
855
|
};
|
|
981
856
|
//# sourceMappingURL=index.js.map
|