@tma.js/bridge 2.0.3 → 2.1.0
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/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 +525 -650
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,517 +1,406 @@
|
|
|
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 ot, deepSnakeToCamelObjKeys as at } from "@tma.js/toolkit";
|
|
4
|
+
import { BetterPromise as Z, TimeoutError as Te } from "better-promises";
|
|
5
|
+
import { CancelledError as st, TimeoutError as ut } from "better-promises";
|
|
6
|
+
import { parseLaunchParamsQueryFp as ee, themeParams as Ae, pipeJsonToSchema as re, miniAppsMessage as te, 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 (
|
|
25
|
-
(
|
|
26
|
-
return e.concat(
|
|
23
|
+
var We = function(e, r, t) {
|
|
24
|
+
if (t || arguments.length === 2) for (var n = 0, a = r.length, o; n < a; n++)
|
|
25
|
+
(o || !(n in r)) && (o || (o = Array.prototype.slice.call(r, 0, n)), o[n] = r[n]);
|
|
26
|
+
return e.concat(o || Array.prototype.slice.call(r));
|
|
27
27
|
};
|
|
28
|
-
function
|
|
28
|
+
function Fe(e) {
|
|
29
29
|
return e;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function y(e, r, t, n, a, o, i, s, u) {
|
|
32
32
|
switch (arguments.length) {
|
|
33
33
|
case 1:
|
|
34
34
|
return e;
|
|
35
35
|
case 2:
|
|
36
36
|
return function() {
|
|
37
|
-
return
|
|
37
|
+
return r(e.apply(this, arguments));
|
|
38
38
|
};
|
|
39
39
|
case 3:
|
|
40
40
|
return function() {
|
|
41
|
-
return r(
|
|
41
|
+
return t(r(e.apply(this, arguments)));
|
|
42
42
|
};
|
|
43
43
|
case 4:
|
|
44
44
|
return function() {
|
|
45
|
-
return n(r(
|
|
45
|
+
return n(t(r(e.apply(this, arguments))));
|
|
46
46
|
};
|
|
47
47
|
case 5:
|
|
48
48
|
return function() {
|
|
49
|
-
return
|
|
49
|
+
return a(n(t(r(e.apply(this, arguments)))));
|
|
50
50
|
};
|
|
51
51
|
case 6:
|
|
52
52
|
return function() {
|
|
53
|
-
return a(
|
|
53
|
+
return o(a(n(t(r(e.apply(this, arguments))))));
|
|
54
54
|
};
|
|
55
55
|
case 7:
|
|
56
56
|
return function() {
|
|
57
|
-
return i(a(
|
|
57
|
+
return i(o(a(n(t(r(e.apply(this, arguments)))))));
|
|
58
58
|
};
|
|
59
59
|
case 8:
|
|
60
60
|
return function() {
|
|
61
|
-
return
|
|
61
|
+
return s(i(o(a(n(t(r(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(t(r(e.apply(this, arguments)))))))));
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function m(e, r, t, n, a, o, i, s, u) {
|
|
70
70
|
switch (arguments.length) {
|
|
71
71
|
case 1:
|
|
72
72
|
return e;
|
|
73
73
|
case 2:
|
|
74
|
-
return
|
|
74
|
+
return r(e);
|
|
75
75
|
case 3:
|
|
76
|
-
return r(
|
|
76
|
+
return t(r(e));
|
|
77
77
|
case 4:
|
|
78
|
-
return n(r(
|
|
78
|
+
return n(t(r(e)));
|
|
79
79
|
case 5:
|
|
80
|
-
return
|
|
80
|
+
return a(n(t(r(e))));
|
|
81
81
|
case 6:
|
|
82
|
-
return a(
|
|
82
|
+
return o(a(n(t(r(e)))));
|
|
83
83
|
case 7:
|
|
84
|
-
return i(a(
|
|
84
|
+
return i(o(a(n(t(r(e))))));
|
|
85
85
|
case 8:
|
|
86
|
-
return
|
|
86
|
+
return s(i(o(a(n(t(r(e)))))));
|
|
87
87
|
case 9:
|
|
88
|
-
return u(
|
|
88
|
+
return u(s(i(o(a(n(t(r(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
|
|
97
|
-
var
|
|
96
|
+
var W = function(e, r) {
|
|
97
|
+
var t = 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
|
|
103
|
-
return
|
|
102
|
+
return t(arguments) ? r.apply(this, n) : function(a) {
|
|
103
|
+
return r.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
|
-
}),
|
|
117
|
-
return function(
|
|
118
|
-
return
|
|
119
|
-
};
|
|
120
|
-
}, ue = function(e) {
|
|
121
|
-
return function(t) {
|
|
122
|
-
return P(t) ? g(e(t.left)) : t;
|
|
114
|
+
}, w = Ue, _ = Ie, ie = /* @__PURE__ */ W(2, function(e, r) {
|
|
115
|
+
return E(e) ? e : r(e.right);
|
|
116
|
+
}), je = function(e) {
|
|
117
|
+
return function(r) {
|
|
118
|
+
return E(r) ? r : _(e(r.right));
|
|
123
119
|
};
|
|
124
|
-
},
|
|
120
|
+
}, ze = function(e) {
|
|
125
121
|
return function(r) {
|
|
126
|
-
return
|
|
122
|
+
return E(r) ? w(e(r.left)) : r;
|
|
123
|
+
};
|
|
124
|
+
}, E = Re, se = function(e, r) {
|
|
125
|
+
return function(t) {
|
|
126
|
+
return E(t) ? e(t.left) : r(t.right);
|
|
127
127
|
};
|
|
128
|
-
},
|
|
128
|
+
}, Ge = se, F = se, Ve = F, q = function(e, r) {
|
|
129
129
|
try {
|
|
130
|
-
return
|
|
131
|
-
} catch (
|
|
132
|
-
return
|
|
130
|
+
return _(e());
|
|
131
|
+
} catch (t) {
|
|
132
|
+
return w(r(t));
|
|
133
133
|
}
|
|
134
|
-
},
|
|
134
|
+
}, De = ie, Ne = ie, Be = qe, Je = Oe, Qe = function(e) {
|
|
135
135
|
return e._tag === "None";
|
|
136
|
-
}, He = function(e,
|
|
137
|
-
return function(
|
|
138
|
-
return Qe(
|
|
136
|
+
}, He = function(e, r) {
|
|
137
|
+
return function(t) {
|
|
138
|
+
return Qe(t) ? e() : r(t.value);
|
|
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
|
-
return function(
|
|
149
|
-
return e.chain(
|
|
150
|
-
return
|
|
148
|
+
return function(r, t) {
|
|
149
|
+
return e.chain(r, function(n) {
|
|
150
|
+
return E(n) ? e.of(n) : t(n.right);
|
|
151
151
|
});
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
|
-
function
|
|
155
|
-
return function(
|
|
156
|
-
return e.map(t, ue(r));
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
function et(e) {
|
|
160
|
-
return function(t, r) {
|
|
154
|
+
function er(e) {
|
|
155
|
+
return function(r, t) {
|
|
161
156
|
return function(n) {
|
|
162
|
-
return e.map(n,
|
|
157
|
+
return e.map(n, F(r, t));
|
|
163
158
|
};
|
|
164
159
|
};
|
|
165
160
|
}
|
|
166
|
-
var
|
|
167
|
-
return
|
|
168
|
-
},
|
|
169
|
-
return
|
|
170
|
-
},
|
|
171
|
-
return function(
|
|
161
|
+
var ue = function(e, r) {
|
|
162
|
+
return m(e, tr(r));
|
|
163
|
+
}, rr = function(e, r) {
|
|
164
|
+
return m(e, nr(r));
|
|
165
|
+
}, tr = function(e) {
|
|
166
|
+
return function(r) {
|
|
172
167
|
return function() {
|
|
173
|
-
return Promise.resolve().then(
|
|
168
|
+
return Promise.resolve().then(r).then(e);
|
|
174
169
|
};
|
|
175
170
|
};
|
|
176
|
-
},
|
|
177
|
-
return function(
|
|
171
|
+
}, nr = function(e) {
|
|
172
|
+
return function(r) {
|
|
178
173
|
return function() {
|
|
179
|
-
return Promise.all([Promise.resolve().then(
|
|
180
|
-
var n =
|
|
181
|
-
return n(
|
|
174
|
+
return Promise.all([Promise.resolve().then(r), Promise.resolve().then(e)]).then(function(t) {
|
|
175
|
+
var n = t[0], a = t[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
|
-
},
|
|
190
|
-
return function() {
|
|
191
|
-
return Promise.resolve().then(e).then(function(r) {
|
|
192
|
-
return t(r)();
|
|
193
|
-
});
|
|
194
|
-
};
|
|
195
|
-
}), fe = "Task", le = {
|
|
196
|
-
URI: fe,
|
|
197
|
-
map: _e
|
|
198
|
-
}, we = {
|
|
199
|
-
of: I
|
|
200
|
-
}, ot = {
|
|
201
|
-
URI: fe,
|
|
202
|
-
map: _e,
|
|
203
|
-
of: I,
|
|
204
|
-
ap: tt,
|
|
205
|
-
chain: at
|
|
206
|
-
}, st = function(e, t, r, n) {
|
|
207
|
-
function o(a) {
|
|
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) {
|
|
184
|
+
}, or = /* @__PURE__ */ W(2, function(e, r) {
|
|
292
185
|
return function() {
|
|
293
|
-
return
|
|
294
|
-
|
|
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
|
-
});
|
|
186
|
+
return Promise.resolve().then(e).then(function(t) {
|
|
187
|
+
return r(t)();
|
|
310
188
|
});
|
|
311
189
|
};
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
|
|
190
|
+
}), pe = "Task", ar = {
|
|
191
|
+
URI: pe,
|
|
192
|
+
map: ue
|
|
193
|
+
}, _e = {
|
|
194
|
+
of: ce
|
|
195
|
+
}, ir = {
|
|
196
|
+
URI: pe,
|
|
197
|
+
map: ue,
|
|
198
|
+
of: ce,
|
|
199
|
+
ap: rr,
|
|
200
|
+
chain: or
|
|
201
|
+
}, sr = /* @__PURE__ */ Xe(_e), fe = /* @__PURE__ */ Ye(_e), le = /* @__PURE__ */ er(ar), me = /* @__PURE__ */ W(2, Ze(ir)), ur = me, cr = me;
|
|
202
|
+
class pr extends b("MethodUnsupportedError", (r, t) => [
|
|
203
|
+
`Method "${r}" is unsupported in Mini Apps version ${t}`
|
|
315
204
|
]) {
|
|
316
205
|
}
|
|
317
|
-
class
|
|
318
|
-
`Parameter "${
|
|
206
|
+
class _r extends b("MethodParameterUnsupportedError", (r, t, n) => [
|
|
207
|
+
`Parameter "${t}" of "${r}" method is unsupported in Mini Apps version ${n}`
|
|
319
208
|
]) {
|
|
320
209
|
}
|
|
321
|
-
class
|
|
210
|
+
class fr extends Le(
|
|
322
211
|
"LaunchParamsRetrieveError",
|
|
323
|
-
(
|
|
324
|
-
(
|
|
212
|
+
(r) => ({ errors: r }),
|
|
213
|
+
(r) => [
|
|
325
214
|
[
|
|
326
215
|
"Unable to retrieve launch parameters from any known source. Perhaps, you have opened your app outside Telegram?",
|
|
327
216
|
"📖 Refer to docs for more information:",
|
|
328
217
|
"https://docs.telegram-mini-apps.com/packages/tma-js-bridge/environment",
|
|
329
218
|
"",
|
|
330
219
|
"Collected errors:",
|
|
331
|
-
...
|
|
220
|
+
...r.map(({ source: t, error: n }) => `Source: ${t} / ${n instanceof Error ? n.message : String(n)}`)
|
|
332
221
|
].join(`
|
|
333
222
|
`)
|
|
334
223
|
]
|
|
335
224
|
) {
|
|
336
225
|
}
|
|
337
|
-
class
|
|
338
|
-
`Invalid value for launch params: ${
|
|
339
|
-
{ cause:
|
|
226
|
+
class lr extends b("InvalidLaunchParamsError", (r, t) => [
|
|
227
|
+
`Invalid value for launch params: ${r}`,
|
|
228
|
+
{ cause: t }
|
|
340
229
|
]) {
|
|
341
230
|
}
|
|
342
|
-
class
|
|
231
|
+
class mr extends b("UnknownEnvError") {
|
|
343
232
|
}
|
|
344
|
-
class
|
|
233
|
+
class wr extends b(
|
|
345
234
|
"InvokeCustomMethodError",
|
|
346
|
-
(
|
|
235
|
+
(r) => [`Server returned error: ${r}`]
|
|
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
|
|
354
|
-
const
|
|
355
|
-
return
|
|
356
|
-
})),
|
|
357
|
-
|
|
358
|
-
|
|
242
|
+
const gr = y(S, De(ee)), jr = x(gr), hr = y(S, je((e) => {
|
|
243
|
+
const r = new URLSearchParams(e).get("tgWebAppData");
|
|
244
|
+
return r ? Je(r) : Be;
|
|
245
|
+
})), zr = y(
|
|
246
|
+
hr,
|
|
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
|
-
for (const [
|
|
255
|
+
for (const [r, t] 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
|
-
const n =
|
|
268
|
+
const n = r();
|
|
380
269
|
if (!n) {
|
|
381
|
-
e.push({ source:
|
|
270
|
+
e.push({ source: t, 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:
|
|
277
|
+
if (typeof a != "boolean") {
|
|
278
|
+
e.push({ source: t, 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
|
|
399
|
-
const u =
|
|
400
|
-
|
|
401
|
-
const
|
|
402
|
-
u.set(i,
|
|
403
|
-
const p =
|
|
404
|
-
if (p >= 0 && (n.off(
|
|
405
|
-
const
|
|
406
|
-
|
|
283
|
+
return w(new fr(e));
|
|
284
|
+
}
|
|
285
|
+
const Gr = x(S);
|
|
286
|
+
function dr(e, r) {
|
|
287
|
+
const t = /* @__PURE__ */ new Map(), n = Ce(), a = (o, i, s = !1) => {
|
|
288
|
+
const u = t.get(o) || /* @__PURE__ */ new Map();
|
|
289
|
+
t.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 = t.size;
|
|
295
|
+
t.delete(o), f && !t.size && r();
|
|
407
296
|
}
|
|
408
297
|
};
|
|
409
298
|
return {
|
|
410
|
-
on(
|
|
411
|
-
!
|
|
299
|
+
on(o, i, s) {
|
|
300
|
+
!t.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 =
|
|
419
|
-
|
|
420
|
-
const
|
|
421
|
-
return p.set(i,
|
|
306
|
+
n.on(o, c);
|
|
307
|
+
const p = t.get(o) || /* @__PURE__ */ new Map();
|
|
308
|
+
t.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(),
|
|
316
|
+
const o = t.size;
|
|
317
|
+
n.all.clear(), t.clear(), o && r();
|
|
429
318
|
}
|
|
430
319
|
};
|
|
431
320
|
}
|
|
432
|
-
function
|
|
321
|
+
function A(e, r) {
|
|
433
322
|
window.dispatchEvent(new MessageEvent("message", {
|
|
434
|
-
data: JSON.stringify({ eventType: e, eventData:
|
|
323
|
+
data: JSON.stringify({ eventType: e, eventData: r }),
|
|
435
324
|
// We specify this kind of source here in order to allow the package's "on" function to
|
|
436
325
|
// capture it. The reason is this function always checks the event source and relies on
|
|
437
326
|
// it to be the parent window.
|
|
438
327
|
source: window.parent
|
|
439
328
|
}));
|
|
440
329
|
}
|
|
441
|
-
function
|
|
442
|
-
const n = [
|
|
443
|
-
typeof
|
|
444
|
-
const
|
|
445
|
-
n.forEach((u) => u(...
|
|
446
|
-
}, i = Object.assign((...
|
|
447
|
-
|
|
330
|
+
function $(e, r, t) {
|
|
331
|
+
const n = [t], a = e[r];
|
|
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 (
|
|
453
|
-
delete e[
|
|
340
|
+
const { length: s } = n;
|
|
341
|
+
if (s === 1) {
|
|
342
|
+
delete e[r];
|
|
454
343
|
return;
|
|
455
344
|
}
|
|
456
|
-
if (
|
|
457
|
-
|
|
345
|
+
if (s === 2) {
|
|
346
|
+
N(e, r, n[1]);
|
|
458
347
|
return;
|
|
459
348
|
}
|
|
460
|
-
n.unshift(1),
|
|
349
|
+
n.unshift(1), N(e, r, o);
|
|
461
350
|
}
|
|
462
351
|
});
|
|
463
|
-
|
|
352
|
+
we(
|
|
464
353
|
e,
|
|
465
|
-
|
|
354
|
+
r,
|
|
466
355
|
() => i,
|
|
467
|
-
(
|
|
356
|
+
(s) => n.push(s)
|
|
468
357
|
);
|
|
469
358
|
}
|
|
470
|
-
function
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
Object.entries(n).forEach(([
|
|
474
|
-
|
|
359
|
+
function D(e, r) {
|
|
360
|
+
const t = e[r];
|
|
361
|
+
we(e, r, () => t, (n) => {
|
|
362
|
+
Object.entries(n).forEach(([a, o]) => {
|
|
363
|
+
t[a] = o;
|
|
475
364
|
});
|
|
476
365
|
});
|
|
477
366
|
}
|
|
478
|
-
function
|
|
479
|
-
Object.defineProperty(e,
|
|
367
|
+
function we(e, r, t, n) {
|
|
368
|
+
Object.defineProperty(e, r, {
|
|
480
369
|
enumerable: !0,
|
|
481
370
|
configurable: !0,
|
|
482
|
-
get:
|
|
371
|
+
get: t,
|
|
483
372
|
set: n
|
|
484
373
|
});
|
|
485
374
|
}
|
|
486
|
-
function
|
|
487
|
-
Object.defineProperty(e,
|
|
375
|
+
function N(e, r, t) {
|
|
376
|
+
Object.defineProperty(e, r, {
|
|
488
377
|
enumerable: !0,
|
|
489
378
|
configurable: !0,
|
|
490
379
|
writable: !0,
|
|
491
|
-
value:
|
|
380
|
+
value: t
|
|
492
381
|
});
|
|
493
382
|
}
|
|
494
|
-
const
|
|
495
|
-
clipboard_text_received:
|
|
496
|
-
req_id:
|
|
497
|
-
data: d(
|
|
383
|
+
const vr = {
|
|
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
|
-
let
|
|
420
|
+
let r;
|
|
532
421
|
try {
|
|
533
|
-
|
|
422
|
+
r = M(re(te()), e.data);
|
|
534
423
|
} catch {
|
|
535
424
|
return;
|
|
536
425
|
}
|
|
537
|
-
const { eventType:
|
|
538
|
-
let
|
|
426
|
+
const { eventType: t, eventData: n } = r, a = vr[t];
|
|
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
|
-
`An error occurred processing the "${
|
|
433
|
+
`An error occurred processing the "${t}" event from the Telegram application.`,
|
|
545
434
|
"Please, file an issue here:",
|
|
546
435
|
"https://github.com/Telegram-Mini-Apps/telegram-apps/issues/new/choose"
|
|
547
436
|
].join(`
|
|
548
437
|
`),
|
|
549
|
-
|
|
438
|
+
r,
|
|
550
439
|
i
|
|
551
440
|
);
|
|
552
441
|
}
|
|
553
|
-
|
|
442
|
+
yr(t, o);
|
|
554
443
|
}
|
|
555
444
|
const {
|
|
556
|
-
on:
|
|
557
|
-
off:
|
|
558
|
-
emit:
|
|
559
|
-
clear:
|
|
560
|
-
} =
|
|
445
|
+
on: ge,
|
|
446
|
+
off: br,
|
|
447
|
+
emit: yr,
|
|
448
|
+
clear: Er
|
|
449
|
+
} = dr(
|
|
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
|
[
|
|
@@ -568,414 +457,400 @@ const {
|
|
|
568
457
|
["TelegramGameProxy", "receiveEvent"],
|
|
569
458
|
["Telegram", "WebView", "receiveEvent"]
|
|
570
459
|
].forEach((e) => {
|
|
571
|
-
const
|
|
572
|
-
let
|
|
573
|
-
for (const
|
|
574
|
-
if (
|
|
460
|
+
const r = window;
|
|
461
|
+
let t = [void 0, r];
|
|
462
|
+
for (const o of e)
|
|
463
|
+
if (t = [t[1], t[1][o]], !t[1])
|
|
575
464
|
return;
|
|
576
|
-
const [n,
|
|
577
|
-
"unwrap" in
|
|
578
|
-
}), window.removeEventListener("message",
|
|
465
|
+
const [n, a] = t;
|
|
466
|
+
"unwrap" in a && (a.unwrap(), n && n !== r && !Object.keys(n).length && delete r[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"), Pr = (e) => {
|
|
470
|
+
g().log("Event received:", e);
|
|
471
|
+
}, he = ne(P);
|
|
472
|
+
function Vr(e) {
|
|
473
|
+
e !== P() && (P.set(e), (e ? ge : br)("*", Pr));
|
|
585
474
|
}
|
|
586
|
-
const
|
|
587
|
-
function
|
|
588
|
-
|
|
475
|
+
const de = ne(O);
|
|
476
|
+
function Dr(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 Nr() {
|
|
487
|
+
Er(), [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 xr = (...e) => v()(...e);
|
|
492
|
+
function kr(e, r) {
|
|
493
|
+
m(
|
|
494
|
+
R(
|
|
606
495
|
// @ts-expect-error It's ok, TS can't determine a specific override.
|
|
607
496
|
e,
|
|
608
|
-
|
|
497
|
+
r
|
|
609
498
|
),
|
|
610
|
-
|
|
611
|
-
throw
|
|
499
|
+
ze((t) => {
|
|
500
|
+
throw t;
|
|
612
501
|
})
|
|
613
502
|
);
|
|
614
503
|
}
|
|
615
|
-
function
|
|
616
|
-
|
|
617
|
-
const
|
|
618
|
-
return
|
|
504
|
+
function R(e, r) {
|
|
505
|
+
g().log("Posting event:", r ? { eventType: e, eventData: r } : { eventType: e });
|
|
506
|
+
const t = window, n = JSON.stringify({ eventType: e, eventData: r });
|
|
507
|
+
return ae() ? (xr(n, de()), _(void 0)) : oe(t) ? (t.TelegramWebviewProxy.postEvent(e, JSON.stringify(r)), _(void 0)) : L(l({ external: l({ notify: Y() }) }), t) ? (t.external.notify(n), _(void 0)) : w(new mr());
|
|
619
508
|
}
|
|
620
|
-
function
|
|
621
|
-
r || (r = {});
|
|
509
|
+
function U(e, r, t = {}) {
|
|
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
|
-
} =
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
}
|
|
639
|
-
ge(() => pt(() => c, (u) => u))
|
|
513
|
+
postEvent: a = R
|
|
514
|
+
} = t;
|
|
515
|
+
return m(
|
|
516
|
+
async () => a(e, t.params),
|
|
517
|
+
cr(() => ke((o, i, s) => {
|
|
518
|
+
const [u, c] = Se();
|
|
519
|
+
(Array.isArray(r) ? r : [r]).forEach((p) => {
|
|
520
|
+
u(
|
|
521
|
+
ge(p, (f) => {
|
|
522
|
+
(Array.isArray(r) ? n({ event: p, payload: f }) : n(f)) && o(f);
|
|
523
|
+
})
|
|
524
|
+
);
|
|
525
|
+
}), s.on("finalized", c);
|
|
526
|
+
}, t))
|
|
640
527
|
);
|
|
641
528
|
}
|
|
642
|
-
function
|
|
643
|
-
const { postEvent: n } =
|
|
644
|
-
return
|
|
529
|
+
function Br(e, r, t) {
|
|
530
|
+
const { postEvent: n } = t || {};
|
|
531
|
+
return C(
|
|
645
532
|
// @ts-expect-error TypeScript will not be able to handle our overrides here.
|
|
646
|
-
|
|
647
|
-
...
|
|
648
|
-
postEvent: n ? (...
|
|
533
|
+
U(e, r, {
|
|
534
|
+
...t,
|
|
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
|
|
545
|
+
function Jr(e, r) {
|
|
546
|
+
const t = Sr(
|
|
666
547
|
// @ts-expect-error TS doesn't get what override we are going to use.
|
|
667
548
|
e,
|
|
668
|
-
|
|
549
|
+
r
|
|
669
550
|
);
|
|
670
|
-
return typeof
|
|
671
|
-
(n) => {
|
|
672
|
-
throw n;
|
|
673
|
-
},
|
|
674
|
-
(n) => n
|
|
675
|
-
))()) : r;
|
|
551
|
+
return typeof t == "function" ? Z.fn(() => C(t)) : t;
|
|
676
552
|
}
|
|
677
|
-
function
|
|
678
|
-
const
|
|
553
|
+
function Sr(e, r) {
|
|
554
|
+
const t = oe(window);
|
|
679
555
|
if (!e)
|
|
680
|
-
return
|
|
681
|
-
if (
|
|
682
|
-
return
|
|
683
|
-
const { timeout: n = 100 } =
|
|
684
|
-
return
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
(
|
|
688
|
-
() =>
|
|
556
|
+
return t || m(S(), F(() => !1, () => !0));
|
|
557
|
+
if (t)
|
|
558
|
+
return fe(!0);
|
|
559
|
+
const { timeout: n = 100 } = r || {};
|
|
560
|
+
return m(
|
|
561
|
+
U("web_app_request_theme", "theme_changed", { ...r, timeout: n }),
|
|
562
|
+
le(
|
|
563
|
+
(a) => Te.is(a) ? _(!1) : w(a),
|
|
564
|
+
() => _(!0)
|
|
689
565
|
)
|
|
690
566
|
);
|
|
691
567
|
}
|
|
692
|
-
function
|
|
568
|
+
function Qr({ launchParams: e, onEvent: r, resetPostMessage: t } = {}) {
|
|
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 lr(o, i);
|
|
704
580
|
}
|
|
705
|
-
|
|
581
|
+
X("launchParams", o);
|
|
706
582
|
}
|
|
707
|
-
if (
|
|
708
|
-
if (!
|
|
583
|
+
if (ae()) {
|
|
584
|
+
if (!r)
|
|
709
585
|
return;
|
|
710
|
-
|
|
711
|
-
const
|
|
712
|
-
|
|
713
|
-
const [
|
|
714
|
-
|
|
586
|
+
t && 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
|
-
|
|
593
|
+
const c = M(re(te()), s);
|
|
594
|
+
r([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
|
-
|
|
609
|
+
r ? r([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
|
|
738
|
-
return ({ req_id:
|
|
613
|
+
function Tr(e) {
|
|
614
|
+
return ({ req_id: r }) => r === e;
|
|
739
615
|
}
|
|
740
|
-
function
|
|
616
|
+
function J(e) {
|
|
741
617
|
return e.split(".").map(Number);
|
|
742
618
|
}
|
|
743
|
-
function
|
|
744
|
-
const
|
|
745
|
-
for (let
|
|
746
|
-
const i =
|
|
747
|
-
if (i !==
|
|
748
|
-
return i >
|
|
619
|
+
function Ar(e, r) {
|
|
620
|
+
const t = J(e), n = J(r), a = Math.max(t.length, n.length);
|
|
621
|
+
for (let o = 0; o < a; o += 1) {
|
|
622
|
+
const i = t[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
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
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
|
-
}
|
|
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, r) {
|
|
717
|
+
return Object.keys(Q).find((n) => Q[n].some((a) => r ? typeof a == "object" && a.method === e && a.param === r : a === e)) || null;
|
|
851
718
|
}
|
|
852
|
-
function
|
|
853
|
-
const
|
|
854
|
-
|
|
855
|
-
|
|
719
|
+
function K(e, r, t) {
|
|
720
|
+
const n = t ? H(
|
|
721
|
+
e,
|
|
722
|
+
r
|
|
723
|
+
) : H(e);
|
|
724
|
+
return n ? Ar(n, t || r) <= 0 : !1;
|
|
725
|
+
}
|
|
726
|
+
function Hr(e, r = "strict") {
|
|
727
|
+
const t = typeof r == "function" ? r : (n) => {
|
|
728
|
+
const { method: a, version: o } = n, i = "param" in n ? new _r(a, n.param, o) : new pr(a, o);
|
|
729
|
+
if (r === "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) ? t({ version: e, method: n, param: "color" }) : kr(n, a) : t({ version: e, method: n });
|
|
860
734
|
}
|
|
861
|
-
function
|
|
862
|
-
return
|
|
863
|
-
|
|
735
|
+
function $r(e, r, t, n) {
|
|
736
|
+
return m(
|
|
737
|
+
U("web_app_invoke_custom_method", "custom_method_invoked", {
|
|
864
738
|
...n || {},
|
|
865
|
-
params: { method: e, params:
|
|
866
|
-
capture:
|
|
739
|
+
params: { method: e, params: r, req_id: t },
|
|
740
|
+
capture: Tr(t)
|
|
867
741
|
}),
|
|
868
|
-
|
|
742
|
+
ur(({ result: a, error: o }) => o ? sr(new wr(o)) : fe(a))
|
|
869
743
|
);
|
|
870
744
|
}
|
|
871
|
-
function
|
|
872
|
-
return
|
|
745
|
+
function Kr(e, r, t, n) {
|
|
746
|
+
return Z.fn(() => m(
|
|
873
747
|
// @ts-expect-error TypeScript is unable to determine required override.
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
(
|
|
877
|
-
throw
|
|
748
|
+
$r(e, r, t, n),
|
|
749
|
+
le(
|
|
750
|
+
(a) => {
|
|
751
|
+
throw a;
|
|
878
752
|
},
|
|
879
|
-
(
|
|
753
|
+
(a) => a
|
|
880
754
|
)
|
|
881
755
|
)());
|
|
882
756
|
}
|
|
883
|
-
function
|
|
884
|
-
Object.hasOwn || (Object.hasOwn = function(e,
|
|
885
|
-
return Object.prototype.hasOwnProperty.call(e,
|
|
757
|
+
function Yr() {
|
|
758
|
+
Object.hasOwn || (Object.hasOwn = function(e, r) {
|
|
759
|
+
return Object.prototype.hasOwnProperty.call(e, r);
|
|
886
760
|
});
|
|
887
761
|
}
|
|
888
|
-
function
|
|
889
|
-
return
|
|
890
|
-
atob(e).replace(/-/g, "+").replace(/_/g, "/").split("").map((
|
|
891
|
-
), (
|
|
762
|
+
function ve(e) {
|
|
763
|
+
return q(() => decodeURIComponent(
|
|
764
|
+
atob(e).replace(/-/g, "+").replace(/_/g, "/").split("").map((r) => "%" + ("00" + r.charCodeAt(0).toString(16)).slice(-2)).join("")
|
|
765
|
+
), (r) => r);
|
|
892
766
|
}
|
|
893
|
-
const
|
|
894
|
-
function
|
|
767
|
+
const Xr = x(ve);
|
|
768
|
+
function be(e) {
|
|
895
769
|
return btoa(
|
|
896
|
-
encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, (
|
|
770
|
+
encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, (r, t) => String.fromCharCode(parseInt(`0x${t}`)))
|
|
897
771
|
).replace(/\+/g, "-").replace(/\//g, "_");
|
|
898
772
|
}
|
|
899
|
-
var
|
|
900
|
-
return
|
|
773
|
+
var Mr = function(e) {
|
|
774
|
+
return q(function() {
|
|
901
775
|
return JSON.parse(e);
|
|
902
|
-
},
|
|
776
|
+
}, Fe);
|
|
903
777
|
};
|
|
904
|
-
function
|
|
905
|
-
const
|
|
906
|
-
return
|
|
907
|
-
}
|
|
908
|
-
const
|
|
909
|
-
function
|
|
910
|
-
return
|
|
911
|
-
|
|
778
|
+
function Lr(e) {
|
|
779
|
+
const r = be(typeof e == "string" ? e : JSON.stringify(e));
|
|
780
|
+
return r.length > 512 ? w(new Error("Value is too long for start parameter")) : _(r);
|
|
781
|
+
}
|
|
782
|
+
const Zr = x(Lr);
|
|
783
|
+
function et(e, r) {
|
|
784
|
+
return C(
|
|
785
|
+
Cr(
|
|
912
786
|
e,
|
|
913
787
|
// @ts-expect-error TypeScript is unable to detect a correct override.
|
|
914
|
-
typeof
|
|
788
|
+
typeof r == "function" ? (t) => q(() => r(t), (n) => n) : r
|
|
915
789
|
)
|
|
916
790
|
);
|
|
917
791
|
}
|
|
918
|
-
function
|
|
919
|
-
return
|
|
920
|
-
|
|
921
|
-
|
|
792
|
+
function Cr(e, r) {
|
|
793
|
+
return m(
|
|
794
|
+
ve(e),
|
|
795
|
+
Ne((t) => r ? typeof r == "function" ? r(t) : Mr(t) : _(t))
|
|
922
796
|
);
|
|
923
797
|
}
|
|
924
|
-
function
|
|
925
|
-
return
|
|
798
|
+
function rt(e) {
|
|
799
|
+
return be(e).length <= 512;
|
|
926
800
|
}
|
|
927
801
|
export {
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
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
|
-
|
|
802
|
+
st as CancelledError,
|
|
803
|
+
lr as InvalidLaunchParamsError,
|
|
804
|
+
wr as InvokeCustomMethodFailedError,
|
|
805
|
+
fr as LaunchParamsRetrieveError,
|
|
806
|
+
_r as MethodParameterUnsupportedError,
|
|
807
|
+
pr as MethodUnsupportedError,
|
|
808
|
+
ut as TimeoutError,
|
|
809
|
+
mr as UnknownEnvError,
|
|
810
|
+
Yr as applyPolyfills,
|
|
811
|
+
Tr as captureSameReq,
|
|
812
|
+
Ar as compareVersions,
|
|
813
|
+
ot as createLogger,
|
|
814
|
+
Hr as createPostEvent,
|
|
815
|
+
Zr as createStartParam,
|
|
816
|
+
Lr as createStartParamFp,
|
|
817
|
+
he as debug,
|
|
818
|
+
Xr as decodeBase64Url,
|
|
819
|
+
ve as decodeBase64UrlFp,
|
|
820
|
+
et as decodeStartParam,
|
|
821
|
+
Cr as decodeStartParamFp,
|
|
822
|
+
at as deepSnakeToCamelObjKeys,
|
|
823
|
+
A as emitEvent,
|
|
824
|
+
be as encodeBase64Url,
|
|
825
|
+
H as getReleaseVersion,
|
|
826
|
+
oe as hasWebviewProxy,
|
|
827
|
+
Kr as invokeCustomMethod,
|
|
828
|
+
$r as invokeCustomMethodFp,
|
|
829
|
+
ae as isIframe,
|
|
830
|
+
rt as isSafeToCreateStartParam,
|
|
831
|
+
Jr as isTMA,
|
|
832
|
+
Sr as isTMAFp,
|
|
833
|
+
g as logger,
|
|
834
|
+
Qr as mockTelegramEnv,
|
|
835
|
+
br as off,
|
|
836
|
+
Er as offAll,
|
|
837
|
+
ge as on,
|
|
838
|
+
kr as postEvent,
|
|
839
|
+
R as postEventFp,
|
|
840
|
+
xr as postMessage,
|
|
841
|
+
v as postMessageImpl,
|
|
842
|
+
Br as request,
|
|
843
|
+
U as requestFp,
|
|
844
|
+
Nr as resetGlobals,
|
|
845
|
+
jr as retrieveLaunchParams,
|
|
846
|
+
gr as retrieveLaunchParamsFp,
|
|
847
|
+
zr as retrieveRawInitData,
|
|
848
|
+
hr as retrieveRawInitDataFp,
|
|
849
|
+
Gr as retrieveRawLaunchParams,
|
|
850
|
+
S as retrieveRawLaunchParamsFp,
|
|
851
|
+
Vr as setDebug,
|
|
852
|
+
Dr as setTargetOrigin,
|
|
853
|
+
K as supports,
|
|
854
|
+
de as targetOrigin
|
|
980
855
|
};
|
|
981
856
|
//# sourceMappingURL=index.js.map
|