@tma.js/sdk 2.1.0 → 2.2.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/bridge/events/types.d.ts +12 -6
- package/dist/dts/components/MainButton/MainButton.d.ts +28 -28
- package/dist/dts/components/MainButton/types.d.ts +1 -1
- package/dist/dts/misc/createCleanup.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +414 -402
- package/dist/index.js.map +1 -1
- package/dist/index.low-level.iife.js +1 -1
- package/dist/index.low-level.iife.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var c = (e, t, s) => (
|
|
1
|
+
var Vt = Object.defineProperty;
|
|
2
|
+
var $t = (e, t, s) => t in e ? Vt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
|
3
|
+
var c = (e, t, s) => ($t(e, typeof t != "symbol" ? t + "" : t, s), s);
|
|
4
4
|
function it(e, t) {
|
|
5
5
|
let s;
|
|
6
6
|
const n = () => {
|
|
@@ -12,10 +12,10 @@ function ot(e) {
|
|
|
12
12
|
const t = M(), { count: s } = t;
|
|
13
13
|
t.unsubscribe(e), s && !t.count && ne();
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function Mt(e) {
|
|
16
16
|
return M().subscribe(e), () => ot(e);
|
|
17
17
|
}
|
|
18
|
-
class
|
|
18
|
+
class Lt {
|
|
19
19
|
constructor(t, s = {}) {
|
|
20
20
|
this.scope = t, this.options = s;
|
|
21
21
|
}
|
|
@@ -55,21 +55,21 @@ class Mt {
|
|
|
55
55
|
this.print("log", ...t);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
const F = new
|
|
58
|
+
const F = new Lt("SDK", {
|
|
59
59
|
bgColor: "forestgreen",
|
|
60
60
|
textColor: "white"
|
|
61
61
|
});
|
|
62
62
|
let G = !1;
|
|
63
|
-
const et = ({
|
|
64
|
-
F.log("Event received:", t
|
|
63
|
+
const et = ({ name: e, payload: t }) => {
|
|
64
|
+
F.log("Event received:", t ? { name: e, payload: t } : { name: e });
|
|
65
65
|
};
|
|
66
|
-
function
|
|
67
|
-
G !== e && (G = e, e ?
|
|
66
|
+
function Ye(e) {
|
|
67
|
+
G !== e && (G = e, e ? Mt(et) : ot(et));
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function Bt(...e) {
|
|
70
70
|
G && F.log(...e);
|
|
71
71
|
}
|
|
72
|
-
class
|
|
72
|
+
class R {
|
|
73
73
|
constructor() {
|
|
74
74
|
c(this, "listeners", /* @__PURE__ */ new Map());
|
|
75
75
|
c(this, "listenersCount", 0);
|
|
@@ -144,6 +144,17 @@ class D {
|
|
|
144
144
|
function j(e, t, s) {
|
|
145
145
|
return window.addEventListener(e, t, s), () => window.removeEventListener(e, t, s);
|
|
146
146
|
}
|
|
147
|
+
function at(...e) {
|
|
148
|
+
let t = !1;
|
|
149
|
+
const s = [...e];
|
|
150
|
+
return [
|
|
151
|
+
(n) => !t && s.push(n),
|
|
152
|
+
() => {
|
|
153
|
+
t || (t = !0, s.forEach((n) => n()));
|
|
154
|
+
},
|
|
155
|
+
t
|
|
156
|
+
];
|
|
157
|
+
}
|
|
147
158
|
class V extends Error {
|
|
148
159
|
constructor(t, s, n) {
|
|
149
160
|
super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, V.prototype);
|
|
@@ -152,9 +163,9 @@ class V extends Error {
|
|
|
152
163
|
function f(e, t, s) {
|
|
153
164
|
return new V(e, t, s);
|
|
154
165
|
}
|
|
155
|
-
const
|
|
166
|
+
const Ot = "ERR_METHOD_UNSUPPORTED", Ut = "ERR_METHOD_PARAMETER_UNSUPPORTED", Wt = "ERR_UNKNOWN_ENV", Ht = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", Gt = "ERR_TIMED_OUT", jt = "ERR_UNEXPECTED_TYPE", ct = "ERR_PARSE", zt = "ERR_NAVIGATION_LIST_EMPTY", Ft = "ERR_NAVIGATION_CURSOR_INVALID", Ze = "ERR_NAVIGATION_ITEM_INVALID", Ke = "ERR_SSR_INIT", Jt = "ERR_INVALID_PATH_BASE";
|
|
156
167
|
function E() {
|
|
157
|
-
return f(
|
|
168
|
+
return f(jt, "Value has unexpected type");
|
|
158
169
|
}
|
|
159
170
|
class $ {
|
|
160
171
|
constructor(t, s, n) {
|
|
@@ -172,7 +183,7 @@ class $ {
|
|
|
172
183
|
return this.parser(t);
|
|
173
184
|
} catch (s) {
|
|
174
185
|
throw f(
|
|
175
|
-
|
|
186
|
+
ct,
|
|
176
187
|
`Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
|
|
177
188
|
s
|
|
178
189
|
);
|
|
@@ -195,7 +206,7 @@ const w = P((e) => {
|
|
|
195
206
|
return !1;
|
|
196
207
|
throw E();
|
|
197
208
|
}, "boolean");
|
|
198
|
-
function
|
|
209
|
+
function ht(e, t) {
|
|
199
210
|
const s = {};
|
|
200
211
|
for (const n in e) {
|
|
201
212
|
const r = e[n];
|
|
@@ -212,7 +223,7 @@ function ct(e, t) {
|
|
|
212
223
|
const o = a(t(i));
|
|
213
224
|
o !== void 0 && (s[n] = o);
|
|
214
225
|
} catch (o) {
|
|
215
|
-
throw f(
|
|
226
|
+
throw f(ct, `Unable to parse field "${n}"`, o);
|
|
216
227
|
}
|
|
217
228
|
}
|
|
218
229
|
return s;
|
|
@@ -226,7 +237,7 @@ function J(e) {
|
|
|
226
237
|
function d(e, t) {
|
|
227
238
|
return new $((s) => {
|
|
228
239
|
const n = J(s);
|
|
229
|
-
return
|
|
240
|
+
return ht(e, (r) => n[r]);
|
|
230
241
|
}, !1, t);
|
|
231
242
|
}
|
|
232
243
|
const y = P((e) => {
|
|
@@ -242,14 +253,14 @@ const y = P((e) => {
|
|
|
242
253
|
function Q(e) {
|
|
243
254
|
return /^#[\da-f]{6}$/i.test(e);
|
|
244
255
|
}
|
|
245
|
-
function
|
|
256
|
+
function Qt(e) {
|
|
246
257
|
return /^#[\da-f]{3}$/i.test(e);
|
|
247
258
|
}
|
|
248
|
-
function
|
|
259
|
+
function pt(e) {
|
|
249
260
|
const t = e.replace(/\s/g, "").toLowerCase();
|
|
250
261
|
if (Q(t))
|
|
251
262
|
return t;
|
|
252
|
-
if (
|
|
263
|
+
if (Qt(t)) {
|
|
253
264
|
let n = "#";
|
|
254
265
|
for (let r = 0; r < 3; r += 1)
|
|
255
266
|
n += t[1 + r].repeat(2);
|
|
@@ -267,26 +278,26 @@ const h = P((e) => {
|
|
|
267
278
|
if (typeof e == "string" || typeof e == "number")
|
|
268
279
|
return e.toString();
|
|
269
280
|
throw E();
|
|
270
|
-
}, "string"),
|
|
271
|
-
function
|
|
281
|
+
}, "string"), ut = P((e) => pt(h().parse(e)), "rgb");
|
|
282
|
+
function Yt(e) {
|
|
272
283
|
return d({
|
|
273
284
|
eventType: h(),
|
|
274
285
|
eventData: (t) => t
|
|
275
286
|
}).parse(e);
|
|
276
287
|
}
|
|
277
|
-
function
|
|
288
|
+
function Zt() {
|
|
278
289
|
["TelegramGameProxy_receiveEvent", "TelegramGameProxy", "Telegram"].forEach((e) => {
|
|
279
290
|
delete window[e];
|
|
280
291
|
});
|
|
281
292
|
}
|
|
282
|
-
function
|
|
293
|
+
function Kt(e, t) {
|
|
283
294
|
window.dispatchEvent(new MessageEvent("message", {
|
|
284
295
|
data: JSON.stringify({ eventType: e, eventData: t }),
|
|
285
296
|
// We specify window.parent to imitate the case, the parent iframe sent us this event.
|
|
286
297
|
source: window.parent
|
|
287
298
|
}));
|
|
288
299
|
}
|
|
289
|
-
function
|
|
300
|
+
function Xt() {
|
|
290
301
|
[
|
|
291
302
|
["TelegramGameProxy_receiveEvent"],
|
|
292
303
|
// Windows Phone.
|
|
@@ -298,16 +309,14 @@ function Kt() {
|
|
|
298
309
|
let t = window;
|
|
299
310
|
e.forEach((s, n, r) => {
|
|
300
311
|
if (n === r.length - 1) {
|
|
301
|
-
t[s] =
|
|
312
|
+
t[s] = Kt;
|
|
302
313
|
return;
|
|
303
314
|
}
|
|
304
315
|
s in t || (t[s] = {}), t = t[s];
|
|
305
316
|
});
|
|
306
317
|
});
|
|
307
318
|
}
|
|
308
|
-
const
|
|
309
|
-
button_id: (e) => e == null ? void 0 : h().parse(e)
|
|
310
|
-
}), te = {
|
|
319
|
+
const te = {
|
|
311
320
|
clipboard_text_received: d({
|
|
312
321
|
req_id: h(),
|
|
313
322
|
data: (e) => e === null ? e : h().optional().parse(e)
|
|
@@ -317,22 +326,19 @@ const Xt = d({
|
|
|
317
326
|
result: (e) => e,
|
|
318
327
|
error: h().optional()
|
|
319
328
|
}),
|
|
320
|
-
invoice_closed: d({
|
|
321
|
-
|
|
322
|
-
status: h()
|
|
323
|
-
}),
|
|
324
|
-
phone_requested: d({
|
|
325
|
-
status: h()
|
|
326
|
-
}),
|
|
329
|
+
invoice_closed: d({ slug: h(), status: h() }),
|
|
330
|
+
phone_requested: d({ status: h() }),
|
|
327
331
|
popup_closed: {
|
|
328
|
-
parse
|
|
332
|
+
parse(e) {
|
|
333
|
+
return d({
|
|
334
|
+
button_id: (t) => t == null ? void 0 : h().parse(t)
|
|
335
|
+
}).parse(e ?? {});
|
|
336
|
+
}
|
|
329
337
|
},
|
|
330
|
-
qr_text_received: d({
|
|
331
|
-
data: h().optional()
|
|
332
|
-
}),
|
|
338
|
+
qr_text_received: d({ data: h().optional() }),
|
|
333
339
|
theme_changed: d({
|
|
334
340
|
theme_params: (e) => {
|
|
335
|
-
const t =
|
|
341
|
+
const t = ut().optional();
|
|
336
342
|
return Object.entries(J(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
|
|
337
343
|
}
|
|
338
344
|
}),
|
|
@@ -342,23 +348,23 @@ const Xt = d({
|
|
|
342
348
|
is_state_stable: w(),
|
|
343
349
|
is_expanded: w()
|
|
344
350
|
}),
|
|
345
|
-
write_access_requested: d({
|
|
346
|
-
status: h()
|
|
347
|
-
})
|
|
351
|
+
write_access_requested: d({ status: h() })
|
|
348
352
|
};
|
|
349
353
|
function ee() {
|
|
350
|
-
const e = new
|
|
351
|
-
|
|
352
|
-
|
|
354
|
+
const e = new R(), t = new R();
|
|
355
|
+
t.subscribe((n) => {
|
|
356
|
+
e.emit("event", { name: n.event, payload: n.args[0] });
|
|
357
|
+
}), Xt();
|
|
358
|
+
const [, s] = at(
|
|
353
359
|
// Don't forget to remove created handlers.
|
|
354
|
-
|
|
360
|
+
Zt,
|
|
355
361
|
// Add "resize" event listener to make sure, we always have fresh viewport information.
|
|
356
362
|
// Desktop version of Telegram is sometimes not sending the viewport_changed
|
|
357
363
|
// event. For example, when the MainButton is shown. That's why we should
|
|
358
364
|
// add our own listener to make sure, viewport information is always fresh.
|
|
359
365
|
// Issue: https://github.com/Telegram-Mini-Apps/tma.js/issues/10
|
|
360
366
|
j("resize", () => {
|
|
361
|
-
|
|
367
|
+
t.emit("viewport_changed", {
|
|
362
368
|
width: window.innerWidth,
|
|
363
369
|
height: window.innerHeight,
|
|
364
370
|
is_state_stable: !0,
|
|
@@ -367,33 +373,44 @@ function ee() {
|
|
|
367
373
|
}),
|
|
368
374
|
// Add listener, which handles events sent from the Telegram web application and also events
|
|
369
375
|
// generated by the local emitEvent function.
|
|
370
|
-
j("message", (
|
|
371
|
-
if (
|
|
376
|
+
j("message", (n) => {
|
|
377
|
+
if (n.source !== window.parent)
|
|
372
378
|
return;
|
|
373
|
-
let
|
|
379
|
+
let r;
|
|
374
380
|
try {
|
|
375
|
-
|
|
381
|
+
r = Yt(n.data);
|
|
376
382
|
} catch {
|
|
377
383
|
return;
|
|
378
384
|
}
|
|
379
|
-
const { eventType:
|
|
385
|
+
const { eventType: i, eventData: a } = r, o = te[i];
|
|
380
386
|
try {
|
|
381
|
-
const
|
|
382
|
-
|
|
383
|
-
} catch (
|
|
387
|
+
const p = o ? o.parse(a) : a;
|
|
388
|
+
t.emit(...p ? [i, p] : [i]);
|
|
389
|
+
} catch (p) {
|
|
384
390
|
F.error(
|
|
385
|
-
`An error occurred processing the "${
|
|
386
|
-
|
|
387
|
-
|
|
391
|
+
`An error occurred processing the "${i}" event from the Telegram application. Please, file an issue here: https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose`,
|
|
392
|
+
r,
|
|
393
|
+
p
|
|
388
394
|
);
|
|
389
395
|
}
|
|
390
396
|
}),
|
|
391
|
-
// Clear
|
|
392
|
-
() => e.clear()
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
+
// Clear emitters.
|
|
398
|
+
() => e.clear(),
|
|
399
|
+
() => t.clear()
|
|
400
|
+
);
|
|
401
|
+
return [{
|
|
402
|
+
on: t.on.bind(t),
|
|
403
|
+
off: t.off.bind(t),
|
|
404
|
+
subscribe(n) {
|
|
405
|
+
return e.on("event", n);
|
|
406
|
+
},
|
|
407
|
+
unsubscribe(n) {
|
|
408
|
+
e.off("event", n);
|
|
409
|
+
},
|
|
410
|
+
get count() {
|
|
411
|
+
return t.count + e.count;
|
|
412
|
+
}
|
|
413
|
+
}, s];
|
|
397
414
|
}
|
|
398
415
|
const [se, ne] = it(
|
|
399
416
|
(e) => {
|
|
@@ -414,7 +431,7 @@ function L(e, t) {
|
|
|
414
431
|
function b(e, t, s) {
|
|
415
432
|
return M().on(e, t, s);
|
|
416
433
|
}
|
|
417
|
-
function
|
|
434
|
+
function I(e) {
|
|
418
435
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
419
436
|
}
|
|
420
437
|
function re(e, t) {
|
|
@@ -481,10 +498,10 @@ function v(e, t, s) {
|
|
|
481
498
|
}
|
|
482
499
|
}
|
|
483
500
|
function ie(e) {
|
|
484
|
-
return "external" in e &&
|
|
501
|
+
return "external" in e && I(e.external) && "notify" in e.external && typeof e.external.notify == "function";
|
|
485
502
|
}
|
|
486
|
-
function
|
|
487
|
-
return "TelegramWebviewProxy" in e &&
|
|
503
|
+
function lt(e) {
|
|
504
|
+
return "TelegramWebviewProxy" in e && I(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
|
|
488
505
|
}
|
|
489
506
|
function oe() {
|
|
490
507
|
try {
|
|
@@ -493,18 +510,18 @@ function oe() {
|
|
|
493
510
|
return !0;
|
|
494
511
|
}
|
|
495
512
|
}
|
|
496
|
-
let
|
|
497
|
-
function
|
|
498
|
-
|
|
513
|
+
let dt = "https://web.telegram.org";
|
|
514
|
+
function Xe(e) {
|
|
515
|
+
dt = e;
|
|
499
516
|
}
|
|
500
517
|
function ae() {
|
|
501
|
-
return
|
|
518
|
+
return dt;
|
|
502
519
|
}
|
|
503
|
-
function
|
|
520
|
+
function A(e, t, s) {
|
|
504
521
|
let n = {}, r;
|
|
505
522
|
t === void 0 && s === void 0 ? n = {} : t !== void 0 && s !== void 0 ? (n = s, r = t) : t !== void 0 && ("targetOrigin" in t ? n = t : r = t);
|
|
506
523
|
const { targetOrigin: i = ae() } = n;
|
|
507
|
-
if (
|
|
524
|
+
if (Bt("Posting event:", r ? { event: e, data: r } : { event: e }), oe()) {
|
|
508
525
|
window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
|
|
509
526
|
return;
|
|
510
527
|
}
|
|
@@ -512,42 +529,42 @@ function R(e, t, s) {
|
|
|
512
529
|
window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
|
|
513
530
|
return;
|
|
514
531
|
}
|
|
515
|
-
if (
|
|
532
|
+
if (lt(window)) {
|
|
516
533
|
window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
|
|
517
534
|
return;
|
|
518
535
|
}
|
|
519
536
|
throw f(
|
|
520
|
-
|
|
537
|
+
Wt,
|
|
521
538
|
"Unable to determine current environment and possible way to send event. You are probably trying to use Mini Apps method outside of Telegram application environment."
|
|
522
539
|
);
|
|
523
540
|
}
|
|
524
541
|
function ce(e) {
|
|
525
542
|
return (t, s) => {
|
|
526
543
|
if (!v(t, e))
|
|
527
|
-
throw f(
|
|
528
|
-
if (
|
|
544
|
+
throw f(Ot, `Method "${t}" is unsupported in Mini Apps version ${e}`);
|
|
545
|
+
if (I(s)) {
|
|
529
546
|
let n;
|
|
530
547
|
if (t === "web_app_open_link" && "try_instant_view" in s ? n = "try_instant_view" : t === "web_app_set_header_color" && "color" in s && (n = "color"), n && !v(t, n, e))
|
|
531
548
|
throw f(
|
|
532
|
-
|
|
549
|
+
Ut,
|
|
533
550
|
`Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
|
|
534
551
|
);
|
|
535
552
|
}
|
|
536
|
-
return
|
|
553
|
+
return A(t, s);
|
|
537
554
|
};
|
|
538
555
|
}
|
|
539
|
-
function
|
|
556
|
+
function _t(e) {
|
|
540
557
|
return ({ req_id: t }) => t === e;
|
|
541
558
|
}
|
|
542
|
-
function
|
|
543
|
-
return f(
|
|
559
|
+
function ft(e) {
|
|
560
|
+
return f(Gt, `Timeout reached: ${e}ms`);
|
|
544
561
|
}
|
|
545
|
-
function
|
|
562
|
+
function gt(e, t) {
|
|
546
563
|
return Promise.race([
|
|
547
564
|
typeof e == "function" ? e() : e,
|
|
548
565
|
new Promise((s, n) => {
|
|
549
566
|
setTimeout(() => {
|
|
550
|
-
n(
|
|
567
|
+
n(ft(t));
|
|
551
568
|
}, t);
|
|
552
569
|
})
|
|
553
570
|
]);
|
|
@@ -560,18 +577,18 @@ async function _(e) {
|
|
|
560
577
|
method: n,
|
|
561
578
|
event: r,
|
|
562
579
|
capture: i,
|
|
563
|
-
postEvent: a =
|
|
580
|
+
postEvent: a = A,
|
|
564
581
|
timeout: o
|
|
565
582
|
} = e, p = (Array.isArray(r) ? r : [r]).map(
|
|
566
|
-
(u) => b(u, (
|
|
583
|
+
(u) => b(u, (k) => (!i || i(k)) && t(k))
|
|
567
584
|
);
|
|
568
585
|
try {
|
|
569
|
-
return a(n, e.params), await (o ?
|
|
586
|
+
return a(n, e.params), await (o ? gt(s, o) : s);
|
|
570
587
|
} finally {
|
|
571
588
|
p.forEach((u) => u());
|
|
572
589
|
}
|
|
573
590
|
}
|
|
574
|
-
async function
|
|
591
|
+
async function S(e, t, s, n = {}) {
|
|
575
592
|
const {
|
|
576
593
|
result: r,
|
|
577
594
|
error: i
|
|
@@ -584,30 +601,30 @@ async function C(e, t, s, n = {}) {
|
|
|
584
601
|
params: t,
|
|
585
602
|
req_id: s
|
|
586
603
|
},
|
|
587
|
-
capture:
|
|
604
|
+
capture: _t(s)
|
|
588
605
|
});
|
|
589
606
|
if (i)
|
|
590
|
-
throw f(
|
|
607
|
+
throw f(Ht, i);
|
|
591
608
|
return r;
|
|
592
609
|
}
|
|
593
610
|
function z(...e) {
|
|
594
611
|
return e.map((t) => {
|
|
595
612
|
if (typeof t == "string")
|
|
596
613
|
return t;
|
|
597
|
-
if (
|
|
614
|
+
if (I(t))
|
|
598
615
|
return z(Object.entries(t).map((s) => s[1] && s[0]));
|
|
599
616
|
if (Array.isArray(t))
|
|
600
617
|
return z(...t);
|
|
601
618
|
}).filter(Boolean).join(" ");
|
|
602
619
|
}
|
|
603
|
-
function
|
|
604
|
-
return e.reduce((t, s) => (
|
|
620
|
+
function ts(...e) {
|
|
621
|
+
return e.reduce((t, s) => (I(s) && Object.entries(s).forEach(([n, r]) => {
|
|
605
622
|
const i = z(t[n], r);
|
|
606
623
|
i.length && (t[n] = i);
|
|
607
624
|
}), t), {});
|
|
608
625
|
}
|
|
609
|
-
function
|
|
610
|
-
const t =
|
|
626
|
+
function bt(e) {
|
|
627
|
+
const t = pt(e);
|
|
611
628
|
return Math.sqrt(
|
|
612
629
|
[0.299, 0.587, 0.114].reduce((s, n, r) => {
|
|
613
630
|
const i = parseInt(t.slice(1 + r * 2, 1 + (r + 1) * 2), 16);
|
|
@@ -617,7 +634,7 @@ function gt(e) {
|
|
|
617
634
|
}
|
|
618
635
|
class he {
|
|
619
636
|
constructor(t) {
|
|
620
|
-
c(this, "ee", new
|
|
637
|
+
c(this, "ee", new R());
|
|
621
638
|
/**
|
|
622
639
|
* Adds new event listener.
|
|
623
640
|
*/
|
|
@@ -663,7 +680,7 @@ class Y {
|
|
|
663
680
|
this.state = new he(t), this.set = this.state.set.bind(this.state), this.get = this.state.get.bind(this.state), this.clone = this.state.clone.bind(this.state);
|
|
664
681
|
}
|
|
665
682
|
}
|
|
666
|
-
function
|
|
683
|
+
function wt(e, t) {
|
|
667
684
|
return (s) => v(t[s], e);
|
|
668
685
|
}
|
|
669
686
|
class Z extends Y {
|
|
@@ -673,7 +690,7 @@ class Z extends Y {
|
|
|
673
690
|
* @returns True, if specified method is supported by the current component.
|
|
674
691
|
*/
|
|
675
692
|
c(this, "supports");
|
|
676
|
-
this.supports =
|
|
693
|
+
this.supports = wt(n, r);
|
|
677
694
|
}
|
|
678
695
|
}
|
|
679
696
|
class pe extends Z {
|
|
@@ -718,13 +735,13 @@ class pe extends Z {
|
|
|
718
735
|
this.isVisible = !0;
|
|
719
736
|
}
|
|
720
737
|
}
|
|
721
|
-
const
|
|
738
|
+
const mt = P((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
|
|
722
739
|
function K(e, t) {
|
|
723
740
|
return new $((s) => {
|
|
724
741
|
if (typeof s != "string" && !(s instanceof URLSearchParams))
|
|
725
742
|
throw E();
|
|
726
743
|
const n = typeof s == "string" ? new URLSearchParams(s) : s;
|
|
727
|
-
return
|
|
744
|
+
return ht(e, (r) => {
|
|
728
745
|
const i = n.get(r);
|
|
729
746
|
return i === null ? void 0 : i;
|
|
730
747
|
});
|
|
@@ -775,10 +792,10 @@ const ue = d({
|
|
|
775
792
|
},
|
|
776
793
|
username: h().optional()
|
|
777
794
|
}, "User").optional();
|
|
778
|
-
function
|
|
795
|
+
function yt() {
|
|
779
796
|
return K({
|
|
780
797
|
authDate: {
|
|
781
|
-
type:
|
|
798
|
+
type: mt(),
|
|
782
799
|
from: "auth_date"
|
|
783
800
|
},
|
|
784
801
|
canSendAfter: {
|
|
@@ -813,21 +830,21 @@ function le(e) {
|
|
|
813
830
|
function de(e) {
|
|
814
831
|
return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
|
|
815
832
|
}
|
|
816
|
-
const
|
|
833
|
+
const vt = P(
|
|
817
834
|
(e) => {
|
|
818
|
-
const t =
|
|
835
|
+
const t = ut().optional();
|
|
819
836
|
return Object.entries(J(e)).reduce((s, [n, r]) => (s[le(n)] = t.parse(r), s), {});
|
|
820
837
|
},
|
|
821
838
|
"ThemeParams"
|
|
822
839
|
);
|
|
823
|
-
function
|
|
840
|
+
function Et(e) {
|
|
824
841
|
return K({
|
|
825
842
|
botInline: {
|
|
826
843
|
type: w().optional(),
|
|
827
844
|
from: "tgWebAppBotInline"
|
|
828
845
|
},
|
|
829
846
|
initData: {
|
|
830
|
-
type:
|
|
847
|
+
type: yt().optional(),
|
|
831
848
|
from: "tgWebAppData"
|
|
832
849
|
},
|
|
833
850
|
initDataRaw: {
|
|
@@ -847,7 +864,7 @@ function vt(e) {
|
|
|
847
864
|
from: "tgWebAppStartParam"
|
|
848
865
|
},
|
|
849
866
|
themeParams: {
|
|
850
|
-
type:
|
|
867
|
+
type: vt(),
|
|
851
868
|
from: "tgWebAppThemeParams"
|
|
852
869
|
},
|
|
853
870
|
version: {
|
|
@@ -856,38 +873,38 @@ function vt(e) {
|
|
|
856
873
|
}
|
|
857
874
|
}).parse(e);
|
|
858
875
|
}
|
|
859
|
-
function
|
|
860
|
-
return
|
|
876
|
+
function Pt(e) {
|
|
877
|
+
return Et(
|
|
861
878
|
e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
|
|
862
879
|
);
|
|
863
880
|
}
|
|
864
881
|
function _e() {
|
|
865
|
-
return
|
|
882
|
+
return Pt(window.location.href);
|
|
866
883
|
}
|
|
867
|
-
function
|
|
884
|
+
function xt() {
|
|
868
885
|
return performance.getEntriesByType("navigation")[0];
|
|
869
886
|
}
|
|
870
887
|
function fe() {
|
|
871
|
-
const e =
|
|
888
|
+
const e = xt();
|
|
872
889
|
if (!e)
|
|
873
890
|
throw new Error("Unable to get first navigation entry.");
|
|
874
|
-
return
|
|
891
|
+
return Pt(e.name);
|
|
875
892
|
}
|
|
876
|
-
function
|
|
893
|
+
function St(e) {
|
|
877
894
|
return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
|
|
878
895
|
}
|
|
879
896
|
function Ct(e, t) {
|
|
880
|
-
sessionStorage.setItem(
|
|
897
|
+
sessionStorage.setItem(St(e), JSON.stringify(t));
|
|
881
898
|
}
|
|
882
|
-
function
|
|
883
|
-
const t = sessionStorage.getItem(
|
|
899
|
+
function Rt(e) {
|
|
900
|
+
const t = sessionStorage.getItem(St(e));
|
|
884
901
|
try {
|
|
885
902
|
return t ? JSON.parse(t) : void 0;
|
|
886
903
|
} catch {
|
|
887
904
|
}
|
|
888
905
|
}
|
|
889
906
|
function ge() {
|
|
890
|
-
return
|
|
907
|
+
return Et(Rt("launchParams") || "");
|
|
891
908
|
}
|
|
892
909
|
function be(e) {
|
|
893
910
|
return JSON.stringify(
|
|
@@ -928,45 +945,34 @@ function ye() {
|
|
|
928
945
|
}
|
|
929
946
|
throw new Error("Unable to retrieve launch parameters from any known source.");
|
|
930
947
|
}
|
|
931
|
-
function
|
|
932
|
-
const e =
|
|
948
|
+
function At() {
|
|
949
|
+
const e = xt();
|
|
933
950
|
return !!(e && e.type === "reload");
|
|
934
951
|
}
|
|
935
952
|
function ve() {
|
|
936
953
|
let e = 0;
|
|
937
954
|
return () => (e += 1).toString();
|
|
938
955
|
}
|
|
939
|
-
|
|
940
|
-
let e = !1;
|
|
941
|
-
const t = [];
|
|
942
|
-
return [
|
|
943
|
-
(s) => !e && t.push(s),
|
|
944
|
-
() => {
|
|
945
|
-
e || (e = !0, t.forEach((s) => s()));
|
|
946
|
-
},
|
|
947
|
-
e
|
|
948
|
-
];
|
|
949
|
-
}
|
|
950
|
-
const [Pe] = it(ve);
|
|
956
|
+
const [Ee] = it(ve);
|
|
951
957
|
function l(e, t) {
|
|
952
958
|
return () => {
|
|
953
959
|
const s = ye(), n = {
|
|
954
960
|
...s,
|
|
955
961
|
postEvent: ce(s.version),
|
|
956
|
-
createRequestId:
|
|
962
|
+
createRequestId: Ee()
|
|
957
963
|
};
|
|
958
964
|
if (typeof e == "function")
|
|
959
965
|
return e(n);
|
|
960
|
-
const [r, i, a] =
|
|
966
|
+
const [r, i, a] = at(), o = t({
|
|
961
967
|
...n,
|
|
962
968
|
// State should only be passed only in case, current page was reloaded. If we don't add
|
|
963
969
|
// this check, state restoration will work improperly in the web version of Telegram,
|
|
964
970
|
// when we are always working in the same "session" (tab).
|
|
965
|
-
state:
|
|
971
|
+
state: At() ? Rt(e) : void 0,
|
|
966
972
|
addCleanup: r
|
|
967
973
|
}), p = (u) => (a || r(
|
|
968
|
-
u.on("change", (
|
|
969
|
-
Ct(e,
|
|
974
|
+
u.on("change", (k) => {
|
|
975
|
+
Ct(e, k);
|
|
970
976
|
})
|
|
971
977
|
), u);
|
|
972
978
|
return [
|
|
@@ -975,12 +981,12 @@ function l(e, t) {
|
|
|
975
981
|
];
|
|
976
982
|
};
|
|
977
983
|
}
|
|
978
|
-
const
|
|
984
|
+
const es = l("backButton", ({
|
|
979
985
|
postEvent: e,
|
|
980
986
|
version: t,
|
|
981
987
|
state: s = { isVisible: !1 }
|
|
982
988
|
}) => new pe(s.isVisible, t, e));
|
|
983
|
-
class
|
|
989
|
+
class q extends Z {
|
|
984
990
|
constructor() {
|
|
985
991
|
super(...arguments);
|
|
986
992
|
/**
|
|
@@ -993,7 +999,7 @@ class I extends Z {
|
|
|
993
999
|
c(this, "off", this.state.off.bind(this.state));
|
|
994
1000
|
}
|
|
995
1001
|
}
|
|
996
|
-
function
|
|
1002
|
+
function Tt(e) {
|
|
997
1003
|
const t = e.available ? e : {
|
|
998
1004
|
available: !1,
|
|
999
1005
|
device_id: "",
|
|
@@ -1011,7 +1017,7 @@ function At(e) {
|
|
|
1011
1017
|
accessGranted: t.access_granted
|
|
1012
1018
|
};
|
|
1013
1019
|
}
|
|
1014
|
-
class
|
|
1020
|
+
class Pe extends q {
|
|
1015
1021
|
constructor({ postEvent: s, version: n, ...r }) {
|
|
1016
1022
|
super(r, n, {
|
|
1017
1023
|
auth: "web_app_biometry_request_auth",
|
|
@@ -1093,7 +1099,7 @@ class xe extends I {
|
|
|
1093
1099
|
event: "biometry_info_received",
|
|
1094
1100
|
params: { reason: s || "" }
|
|
1095
1101
|
}).then((r) => {
|
|
1096
|
-
const i =
|
|
1102
|
+
const i = Tt(r);
|
|
1097
1103
|
return this.set(i), i.accessGranted;
|
|
1098
1104
|
}).finally(() => this.accessPromise = void 0)), this.accessPromise;
|
|
1099
1105
|
}
|
|
@@ -1125,8 +1131,8 @@ class xe extends I {
|
|
|
1125
1131
|
);
|
|
1126
1132
|
}
|
|
1127
1133
|
}
|
|
1128
|
-
async function
|
|
1129
|
-
return
|
|
1134
|
+
async function xe(e) {
|
|
1135
|
+
return Tt(
|
|
1130
1136
|
await _({
|
|
1131
1137
|
...e || {},
|
|
1132
1138
|
method: "web_app_biometry_get_info",
|
|
@@ -1134,10 +1140,16 @@ async function Ce(e) {
|
|
|
1134
1140
|
})
|
|
1135
1141
|
);
|
|
1136
1142
|
}
|
|
1137
|
-
const
|
|
1143
|
+
const ss = l(
|
|
1138
1144
|
"biometryManager",
|
|
1139
|
-
async ({ postEvent: e, version: t, state: s }) => new
|
|
1140
|
-
...s || await
|
|
1145
|
+
async ({ postEvent: e, version: t, state: s }) => new Pe({
|
|
1146
|
+
...s || v("web_app_biometry_get_info", t) ? s || await xe({ timeout: 1e3 }) : {
|
|
1147
|
+
available: !1,
|
|
1148
|
+
accessGranted: !1,
|
|
1149
|
+
accessRequested: !1,
|
|
1150
|
+
tokenSaved: !1,
|
|
1151
|
+
deviceId: ""
|
|
1152
|
+
},
|
|
1141
1153
|
version: t,
|
|
1142
1154
|
postEvent: e
|
|
1143
1155
|
})
|
|
@@ -1182,7 +1194,7 @@ class Se extends X {
|
|
|
1182
1194
|
this.isConfirmationNeeded = !0;
|
|
1183
1195
|
}
|
|
1184
1196
|
}
|
|
1185
|
-
const
|
|
1197
|
+
const ns = l(
|
|
1186
1198
|
"closingBehavior",
|
|
1187
1199
|
({
|
|
1188
1200
|
postEvent: e,
|
|
@@ -1195,10 +1207,10 @@ class tt {
|
|
|
1195
1207
|
* @returns True, if specified method is supported by the current component.
|
|
1196
1208
|
*/
|
|
1197
1209
|
c(this, "supports");
|
|
1198
|
-
this.supports =
|
|
1210
|
+
this.supports = wt(t, s);
|
|
1199
1211
|
}
|
|
1200
1212
|
}
|
|
1201
|
-
function
|
|
1213
|
+
function Ce(e) {
|
|
1202
1214
|
if (Array.isArray(e))
|
|
1203
1215
|
return e;
|
|
1204
1216
|
if (typeof e == "string")
|
|
@@ -1210,9 +1222,9 @@ function Re(e) {
|
|
|
1210
1222
|
}
|
|
1211
1223
|
throw E();
|
|
1212
1224
|
}
|
|
1213
|
-
class
|
|
1225
|
+
class Re extends $ {
|
|
1214
1226
|
constructor(s, n, r) {
|
|
1215
|
-
super(
|
|
1227
|
+
super(Ce, n, r);
|
|
1216
1228
|
c(this, "itemParser");
|
|
1217
1229
|
this.itemParser = typeof s == "function" ? s : s.parse.bind(s);
|
|
1218
1230
|
}
|
|
@@ -1230,13 +1242,13 @@ class Ae extends $ {
|
|
|
1230
1242
|
return this.itemParser = typeof s == "function" ? s : s.parse.bind(s), this;
|
|
1231
1243
|
}
|
|
1232
1244
|
}
|
|
1233
|
-
function
|
|
1234
|
-
return new
|
|
1245
|
+
function Ae(e) {
|
|
1246
|
+
return new Re((t) => t, !1, e);
|
|
1235
1247
|
}
|
|
1236
1248
|
function nt(e, t) {
|
|
1237
1249
|
return Object.fromEntries(e.map((s) => [s, t]));
|
|
1238
1250
|
}
|
|
1239
|
-
class
|
|
1251
|
+
class Te extends tt {
|
|
1240
1252
|
constructor(t, s, n) {
|
|
1241
1253
|
super(t, {
|
|
1242
1254
|
delete: "web_app_invoke_custom_method",
|
|
@@ -1252,7 +1264,7 @@ class Ie extends tt {
|
|
|
1252
1264
|
*/
|
|
1253
1265
|
async delete(t, s = {}) {
|
|
1254
1266
|
const n = Array.isArray(t) ? t : [t];
|
|
1255
|
-
n.length && await
|
|
1267
|
+
n.length && await S(
|
|
1256
1268
|
"deleteStorageValues",
|
|
1257
1269
|
{ keys: n },
|
|
1258
1270
|
this.createRequestId(),
|
|
@@ -1264,8 +1276,8 @@ class Ie extends tt {
|
|
|
1264
1276
|
* @param options - request execution options.
|
|
1265
1277
|
*/
|
|
1266
1278
|
async getKeys(t = {}) {
|
|
1267
|
-
return
|
|
1268
|
-
await
|
|
1279
|
+
return Ae().of(h()).parse(
|
|
1280
|
+
await S(
|
|
1269
1281
|
"getStorageKeys",
|
|
1270
1282
|
{},
|
|
1271
1283
|
this.createRequestId(),
|
|
@@ -1277,7 +1289,7 @@ class Ie extends tt {
|
|
|
1277
1289
|
const n = Array.isArray(t) ? t : [t];
|
|
1278
1290
|
if (!n.length)
|
|
1279
1291
|
return nt(n, "");
|
|
1280
|
-
const r = await
|
|
1292
|
+
const r = await S(
|
|
1281
1293
|
"getStorageValues",
|
|
1282
1294
|
{ keys: n },
|
|
1283
1295
|
this.createRequestId(),
|
|
@@ -1292,7 +1304,7 @@ class Ie extends tt {
|
|
|
1292
1304
|
* @param options - request execution options.
|
|
1293
1305
|
*/
|
|
1294
1306
|
async set(t, s, n = {}) {
|
|
1295
|
-
await
|
|
1307
|
+
await S(
|
|
1296
1308
|
"saveStorageValue",
|
|
1297
1309
|
{ key: t, value: s },
|
|
1298
1310
|
this.createRequestId(),
|
|
@@ -1300,10 +1312,10 @@ class Ie extends tt {
|
|
|
1300
1312
|
);
|
|
1301
1313
|
}
|
|
1302
1314
|
}
|
|
1303
|
-
const
|
|
1304
|
-
({ createRequestId: e, postEvent: t, version: s }) => new
|
|
1315
|
+
const rs = l(
|
|
1316
|
+
({ createRequestId: e, postEvent: t, version: s }) => new Te(s, e, t)
|
|
1305
1317
|
);
|
|
1306
|
-
class
|
|
1318
|
+
class Ie extends tt {
|
|
1307
1319
|
constructor(t, s) {
|
|
1308
1320
|
super(t, {
|
|
1309
1321
|
impactOccurred: "web_app_trigger_haptic_feedback",
|
|
@@ -1345,10 +1357,10 @@ class qe extends tt {
|
|
|
1345
1357
|
this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
|
|
1346
1358
|
}
|
|
1347
1359
|
}
|
|
1348
|
-
const
|
|
1349
|
-
({ version: e, postEvent: t }) => new
|
|
1360
|
+
const is = l(
|
|
1361
|
+
({ version: e, postEvent: t }) => new Ie(e, t)
|
|
1350
1362
|
);
|
|
1351
|
-
class
|
|
1363
|
+
class qe {
|
|
1352
1364
|
constructor(t) {
|
|
1353
1365
|
this.initData = t;
|
|
1354
1366
|
}
|
|
@@ -1421,13 +1433,13 @@ class ke {
|
|
|
1421
1433
|
return this.initData.user;
|
|
1422
1434
|
}
|
|
1423
1435
|
}
|
|
1424
|
-
const
|
|
1425
|
-
({ initData: e }) => e ? new
|
|
1436
|
+
const os = l(
|
|
1437
|
+
({ initData: e }) => e ? new qe(e) : void 0
|
|
1426
1438
|
);
|
|
1427
|
-
function
|
|
1428
|
-
return
|
|
1439
|
+
function as(e) {
|
|
1440
|
+
return yt().parse(e);
|
|
1429
1441
|
}
|
|
1430
|
-
class
|
|
1442
|
+
class ke extends q {
|
|
1431
1443
|
constructor(t, s, n) {
|
|
1432
1444
|
super({ isOpened: t }, s, { open: "web_app_open_invoice" }), this.postEvent = n;
|
|
1433
1445
|
}
|
|
@@ -1471,10 +1483,10 @@ class Ne extends I {
|
|
|
1471
1483
|
}
|
|
1472
1484
|
}
|
|
1473
1485
|
}
|
|
1474
|
-
const
|
|
1475
|
-
({ version: e, postEvent: t }) => new
|
|
1486
|
+
const cs = l(
|
|
1487
|
+
({ version: e, postEvent: t }) => new ke(!1, e, t)
|
|
1476
1488
|
);
|
|
1477
|
-
class
|
|
1489
|
+
class Ne extends Y {
|
|
1478
1490
|
constructor({ postEvent: s, ...n }) {
|
|
1479
1491
|
super(n);
|
|
1480
1492
|
c(this, "postEvent");
|
|
@@ -1492,6 +1504,12 @@ class De extends Y {
|
|
|
1492
1504
|
c(this, "off", (s, n) => s === "click" ? L("main_button_pressed", n) : this.state.off(s, n));
|
|
1493
1505
|
this.postEvent = s;
|
|
1494
1506
|
}
|
|
1507
|
+
/**
|
|
1508
|
+
* The MainButton background color.
|
|
1509
|
+
*/
|
|
1510
|
+
get bgColor() {
|
|
1511
|
+
return this.get("bgColor");
|
|
1512
|
+
}
|
|
1495
1513
|
/**
|
|
1496
1514
|
* Sends current local state to the Telegram application.
|
|
1497
1515
|
*/
|
|
@@ -1501,10 +1519,35 @@ class De extends Y {
|
|
|
1501
1519
|
is_active: this.isEnabled,
|
|
1502
1520
|
is_progress_visible: this.isLoaderVisible,
|
|
1503
1521
|
text: this.text,
|
|
1504
|
-
color: this.
|
|
1522
|
+
color: this.bgColor,
|
|
1505
1523
|
text_color: this.textColor
|
|
1506
1524
|
});
|
|
1507
1525
|
}
|
|
1526
|
+
/**
|
|
1527
|
+
* Disables the MainButton.
|
|
1528
|
+
* @see Does not work on Android: https://github.com/Telegram-Mini-Apps/issues/issues/1
|
|
1529
|
+
*/
|
|
1530
|
+
disable() {
|
|
1531
|
+
return this.isEnabled = !1, this;
|
|
1532
|
+
}
|
|
1533
|
+
/**
|
|
1534
|
+
* Enables the MainButton.
|
|
1535
|
+
*/
|
|
1536
|
+
enable() {
|
|
1537
|
+
return this.isEnabled = !0, this;
|
|
1538
|
+
}
|
|
1539
|
+
/**
|
|
1540
|
+
* Hides the MainButton.
|
|
1541
|
+
*/
|
|
1542
|
+
hide() {
|
|
1543
|
+
return this.isVisible = !1, this;
|
|
1544
|
+
}
|
|
1545
|
+
/**
|
|
1546
|
+
* Hides the MainButton loading indicator.
|
|
1547
|
+
*/
|
|
1548
|
+
hideLoader() {
|
|
1549
|
+
return this.isLoaderVisible = !1, this;
|
|
1550
|
+
}
|
|
1508
1551
|
set isEnabled(s) {
|
|
1509
1552
|
this.setParams({ isEnabled: s });
|
|
1510
1553
|
}
|
|
@@ -1532,49 +1575,6 @@ class De extends Y {
|
|
|
1532
1575
|
get isVisible() {
|
|
1533
1576
|
return this.get("isVisible");
|
|
1534
1577
|
}
|
|
1535
|
-
/**
|
|
1536
|
-
* The MainButton background color.
|
|
1537
|
-
*/
|
|
1538
|
-
get backgroundColor() {
|
|
1539
|
-
return this.get("backgroundColor");
|
|
1540
|
-
}
|
|
1541
|
-
/**
|
|
1542
|
-
* The MainButton text.
|
|
1543
|
-
*/
|
|
1544
|
-
get text() {
|
|
1545
|
-
return this.get("text");
|
|
1546
|
-
}
|
|
1547
|
-
/**
|
|
1548
|
-
* The MainButton text color.
|
|
1549
|
-
*/
|
|
1550
|
-
get textColor() {
|
|
1551
|
-
return this.get("textColor");
|
|
1552
|
-
}
|
|
1553
|
-
/**
|
|
1554
|
-
* Disables the MainButton.
|
|
1555
|
-
* @see Does not work on Android: https://github.com/Telegram-Mini-Apps/issues/issues/1
|
|
1556
|
-
*/
|
|
1557
|
-
disable() {
|
|
1558
|
-
return this.isEnabled = !1, this;
|
|
1559
|
-
}
|
|
1560
|
-
/**
|
|
1561
|
-
* Enables the MainButton.
|
|
1562
|
-
*/
|
|
1563
|
-
enable() {
|
|
1564
|
-
return this.isEnabled = !0, this;
|
|
1565
|
-
}
|
|
1566
|
-
/**
|
|
1567
|
-
* Hides the MainButton.
|
|
1568
|
-
*/
|
|
1569
|
-
hide() {
|
|
1570
|
-
return this.isVisible = !1, this;
|
|
1571
|
-
}
|
|
1572
|
-
/**
|
|
1573
|
-
* Hides the MainButton loading indicator.
|
|
1574
|
-
*/
|
|
1575
|
-
hideLoader() {
|
|
1576
|
-
return this.isLoaderVisible = !1, this;
|
|
1577
|
-
}
|
|
1578
1578
|
/**
|
|
1579
1579
|
* Shows the MainButton.
|
|
1580
1580
|
*
|
|
@@ -1606,10 +1606,10 @@ class De extends Y {
|
|
|
1606
1606
|
}
|
|
1607
1607
|
/**
|
|
1608
1608
|
* Updates current Main Button color.
|
|
1609
|
-
* @param
|
|
1609
|
+
* @param bgColor - color to set.
|
|
1610
1610
|
*/
|
|
1611
|
-
|
|
1612
|
-
return this.setParams({
|
|
1611
|
+
setBgColor(s) {
|
|
1612
|
+
return this.setParams({ bgColor: s });
|
|
1613
1613
|
}
|
|
1614
1614
|
/**
|
|
1615
1615
|
* Allows setting multiple Main Button parameters.
|
|
@@ -1618,8 +1618,20 @@ class De extends Y {
|
|
|
1618
1618
|
setParams(s) {
|
|
1619
1619
|
return this.set(s), this.commit(), this;
|
|
1620
1620
|
}
|
|
1621
|
+
/**
|
|
1622
|
+
* The MainButton text.
|
|
1623
|
+
*/
|
|
1624
|
+
get text() {
|
|
1625
|
+
return this.get("text");
|
|
1626
|
+
}
|
|
1627
|
+
/**
|
|
1628
|
+
* The MainButton text color.
|
|
1629
|
+
*/
|
|
1630
|
+
get textColor() {
|
|
1631
|
+
return this.get("textColor");
|
|
1632
|
+
}
|
|
1621
1633
|
}
|
|
1622
|
-
const
|
|
1634
|
+
const hs = l(
|
|
1623
1635
|
"mainButton",
|
|
1624
1636
|
({
|
|
1625
1637
|
postEvent: e,
|
|
@@ -1630,11 +1642,11 @@ const ps = l(
|
|
|
1630
1642
|
text: "",
|
|
1631
1643
|
isLoaderVisible: !1,
|
|
1632
1644
|
textColor: t.buttonTextColor || "#ffffff",
|
|
1633
|
-
|
|
1645
|
+
bgColor: t.buttonColor || "#000000"
|
|
1634
1646
|
}
|
|
1635
|
-
}) => new
|
|
1647
|
+
}) => new Ne({ ...s, postEvent: e })
|
|
1636
1648
|
);
|
|
1637
|
-
function
|
|
1649
|
+
function De() {
|
|
1638
1650
|
return K({
|
|
1639
1651
|
contact: d({
|
|
1640
1652
|
userId: {
|
|
@@ -1655,24 +1667,24 @@ function Ve() {
|
|
|
1655
1667
|
}
|
|
1656
1668
|
}),
|
|
1657
1669
|
authDate: {
|
|
1658
|
-
type:
|
|
1670
|
+
type: mt(),
|
|
1659
1671
|
from: "auth_date"
|
|
1660
1672
|
},
|
|
1661
1673
|
hash: h()
|
|
1662
1674
|
}, "RequestedContact");
|
|
1663
1675
|
}
|
|
1664
|
-
function
|
|
1676
|
+
function It(e, t) {
|
|
1665
1677
|
return (s) => {
|
|
1666
1678
|
const [n, r] = t[s];
|
|
1667
1679
|
return v(n, r, e);
|
|
1668
1680
|
};
|
|
1669
1681
|
}
|
|
1670
|
-
function
|
|
1682
|
+
function Ve(e) {
|
|
1671
1683
|
return new Promise((t) => {
|
|
1672
1684
|
setTimeout(t, e);
|
|
1673
1685
|
});
|
|
1674
1686
|
}
|
|
1675
|
-
class
|
|
1687
|
+
class $e extends q {
|
|
1676
1688
|
constructor({ postEvent: s, createRequestId: n, version: r, botInline: i, ...a }) {
|
|
1677
1689
|
super(a, r, {
|
|
1678
1690
|
requestPhoneAccess: "web_app_request_phone",
|
|
@@ -1692,7 +1704,7 @@ class Me extends I {
|
|
|
1692
1704
|
c(this, "supportsParam");
|
|
1693
1705
|
this.createRequestId = n, this.postEvent = s, this.botInline = i;
|
|
1694
1706
|
const o = this.supports.bind(this);
|
|
1695
|
-
this.supports = (p) => o(p) ? p !== "switchInlineQuery" || i : !1, this.supportsParam =
|
|
1707
|
+
this.supports = (p) => o(p) ? p !== "switchInlineQuery" || i : !1, this.supportsParam = It(r, {
|
|
1696
1708
|
"setHeaderColor.color": ["web_app_set_header_color", "color"]
|
|
1697
1709
|
});
|
|
1698
1710
|
}
|
|
@@ -1703,8 +1715,8 @@ class Me extends I {
|
|
|
1703
1715
|
async getRequestedContact({
|
|
1704
1716
|
timeout: s = 1e4
|
|
1705
1717
|
} = {}) {
|
|
1706
|
-
return
|
|
1707
|
-
await
|
|
1718
|
+
return De().parse(
|
|
1719
|
+
await S(
|
|
1708
1720
|
"getRequestedContact",
|
|
1709
1721
|
{},
|
|
1710
1722
|
this.createRequestId(),
|
|
@@ -1743,7 +1755,7 @@ class Me extends I {
|
|
|
1743
1755
|
* True if current Mini App background color is recognized as dark.
|
|
1744
1756
|
*/
|
|
1745
1757
|
get isDark() {
|
|
1746
|
-
return
|
|
1758
|
+
return bt(this.bgColor);
|
|
1747
1759
|
}
|
|
1748
1760
|
/**
|
|
1749
1761
|
* Informs the Telegram app that the Mini App is ready to be displayed.
|
|
@@ -1772,15 +1784,15 @@ class Me extends I {
|
|
|
1772
1784
|
throw new Error("Access denied.");
|
|
1773
1785
|
const r = Date.now() + s;
|
|
1774
1786
|
let i = 50;
|
|
1775
|
-
return
|
|
1787
|
+
return gt(async () => {
|
|
1776
1788
|
for (; Date.now() < r; ) {
|
|
1777
1789
|
try {
|
|
1778
1790
|
return await this.getRequestedContact();
|
|
1779
1791
|
} catch {
|
|
1780
1792
|
}
|
|
1781
|
-
await
|
|
1793
|
+
await Ve(i), i += 50;
|
|
1782
1794
|
}
|
|
1783
|
-
throw
|
|
1795
|
+
throw ft(s);
|
|
1784
1796
|
}, s);
|
|
1785
1797
|
}
|
|
1786
1798
|
/**
|
|
@@ -1863,7 +1875,7 @@ class Me extends I {
|
|
|
1863
1875
|
this.postEvent("web_app_switch_inline_query", { query: s, chat_types: n });
|
|
1864
1876
|
}
|
|
1865
1877
|
}
|
|
1866
|
-
const
|
|
1878
|
+
const ps = l(
|
|
1867
1879
|
"miniApp",
|
|
1868
1880
|
({
|
|
1869
1881
|
themeParams: e,
|
|
@@ -1873,9 +1885,9 @@ const us = l(
|
|
|
1873
1885
|
headerColor: e.headerBgColor || "#000000"
|
|
1874
1886
|
},
|
|
1875
1887
|
...n
|
|
1876
|
-
}) => new
|
|
1888
|
+
}) => new $e({ ...n, ...s, botInline: t })
|
|
1877
1889
|
);
|
|
1878
|
-
function
|
|
1890
|
+
function Me(e) {
|
|
1879
1891
|
const t = e.message.trim(), s = (e.title || "").trim(), n = e.buttons || [];
|
|
1880
1892
|
let r;
|
|
1881
1893
|
if (s.length > 64)
|
|
@@ -1899,7 +1911,7 @@ function Le(e) {
|
|
|
1899
1911
|
return { ...i, id: a };
|
|
1900
1912
|
}) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
|
|
1901
1913
|
}
|
|
1902
|
-
class
|
|
1914
|
+
class Le extends q {
|
|
1903
1915
|
constructor(t, s, n) {
|
|
1904
1916
|
super({ isOpened: t }, s, { open: "web_app_open_popup" }), this.postEvent = n;
|
|
1905
1917
|
}
|
|
@@ -1932,7 +1944,7 @@ class Be extends I {
|
|
|
1932
1944
|
event: "popup_closed",
|
|
1933
1945
|
method: "web_app_open_popup",
|
|
1934
1946
|
postEvent: this.postEvent,
|
|
1935
|
-
params:
|
|
1947
|
+
params: Me(t)
|
|
1936
1948
|
});
|
|
1937
1949
|
return s;
|
|
1938
1950
|
} finally {
|
|
@@ -1940,10 +1952,10 @@ class Be extends I {
|
|
|
1940
1952
|
}
|
|
1941
1953
|
}
|
|
1942
1954
|
}
|
|
1943
|
-
const
|
|
1944
|
-
({ postEvent: e, version: t }) => new
|
|
1955
|
+
const us = l(
|
|
1956
|
+
({ postEvent: e, version: t }) => new Le(!1, t, e)
|
|
1945
1957
|
);
|
|
1946
|
-
class
|
|
1958
|
+
class Be extends q {
|
|
1947
1959
|
constructor(t, s, n) {
|
|
1948
1960
|
super({ isOpened: t }, s, {
|
|
1949
1961
|
close: "web_app_close_scan_qr_popup",
|
|
@@ -1987,10 +1999,10 @@ class Oe extends I {
|
|
|
1987
1999
|
}
|
|
1988
2000
|
}
|
|
1989
2001
|
}
|
|
1990
|
-
const
|
|
1991
|
-
({ version: e, postEvent: t }) => new
|
|
2002
|
+
const ls = l(
|
|
2003
|
+
({ version: e, postEvent: t }) => new Be(!1, e, t)
|
|
1992
2004
|
);
|
|
1993
|
-
class
|
|
2005
|
+
class Oe extends Z {
|
|
1994
2006
|
constructor(s, n, r) {
|
|
1995
2007
|
super({ isVisible: s }, n, {
|
|
1996
2008
|
show: "web_app_setup_settings_button",
|
|
@@ -2032,18 +2044,18 @@ class Ue extends Z {
|
|
|
2032
2044
|
this.isVisible = !0;
|
|
2033
2045
|
}
|
|
2034
2046
|
}
|
|
2035
|
-
const
|
|
2047
|
+
const ds = l(
|
|
2036
2048
|
"settingsButton",
|
|
2037
2049
|
({
|
|
2038
2050
|
version: e,
|
|
2039
2051
|
postEvent: t,
|
|
2040
2052
|
state: s = { isVisible: !1 }
|
|
2041
|
-
}) => new
|
|
2053
|
+
}) => new Oe(s.isVisible, e, t)
|
|
2042
2054
|
);
|
|
2043
|
-
function
|
|
2044
|
-
return
|
|
2055
|
+
function qt(e) {
|
|
2056
|
+
return vt().parse(e);
|
|
2045
2057
|
}
|
|
2046
|
-
class
|
|
2058
|
+
class Ue extends X {
|
|
2047
2059
|
/**
|
|
2048
2060
|
* @since v6.10
|
|
2049
2061
|
*/
|
|
@@ -2082,7 +2094,7 @@ class We extends X {
|
|
|
2082
2094
|
* value is calculated according to theme bg color.
|
|
2083
2095
|
*/
|
|
2084
2096
|
get isDark() {
|
|
2085
|
-
return !this.bgColor ||
|
|
2097
|
+
return !this.bgColor || bt(this.bgColor);
|
|
2086
2098
|
}
|
|
2087
2099
|
get linkColor() {
|
|
2088
2100
|
return this.get("linkColor");
|
|
@@ -2108,7 +2120,7 @@ class We extends X {
|
|
|
2108
2120
|
*/
|
|
2109
2121
|
listen() {
|
|
2110
2122
|
return b("theme_changed", (t) => {
|
|
2111
|
-
this.set(
|
|
2123
|
+
this.set(qt(t.theme_params));
|
|
2112
2124
|
});
|
|
2113
2125
|
}
|
|
2114
2126
|
/**
|
|
@@ -2121,28 +2133,28 @@ class We extends X {
|
|
|
2121
2133
|
return this.get("textColor");
|
|
2122
2134
|
}
|
|
2123
2135
|
}
|
|
2124
|
-
const
|
|
2136
|
+
const _s = l(
|
|
2125
2137
|
"themeParams",
|
|
2126
2138
|
({ themeParams: e, state: t = e, addCleanup: s }) => {
|
|
2127
|
-
const n = new
|
|
2139
|
+
const n = new Ue(t);
|
|
2128
2140
|
return s(n.listen()), n;
|
|
2129
2141
|
}
|
|
2130
2142
|
);
|
|
2131
|
-
function
|
|
2143
|
+
function fs(e = {}) {
|
|
2132
2144
|
return _({
|
|
2133
2145
|
...e,
|
|
2134
2146
|
method: "web_app_request_theme",
|
|
2135
2147
|
event: "theme_changed"
|
|
2136
|
-
}).then(
|
|
2148
|
+
}).then(qt);
|
|
2137
2149
|
}
|
|
2138
|
-
class
|
|
2150
|
+
class We extends tt {
|
|
2139
2151
|
constructor(s, n, r) {
|
|
2140
2152
|
super(s, { readTextFromClipboard: "web_app_read_text_from_clipboard" });
|
|
2141
2153
|
/**
|
|
2142
2154
|
* Checks if specified method parameter is supported by current component.
|
|
2143
2155
|
*/
|
|
2144
2156
|
c(this, "supportsParam");
|
|
2145
|
-
this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam =
|
|
2157
|
+
this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam = It(s, {
|
|
2146
2158
|
"openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
|
|
2147
2159
|
});
|
|
2148
2160
|
}
|
|
@@ -2196,15 +2208,15 @@ class He extends tt {
|
|
|
2196
2208
|
event: "clipboard_text_received",
|
|
2197
2209
|
postEvent: this.postEvent,
|
|
2198
2210
|
params: { req_id: s },
|
|
2199
|
-
capture:
|
|
2211
|
+
capture: _t(s)
|
|
2200
2212
|
});
|
|
2201
2213
|
return n;
|
|
2202
2214
|
}
|
|
2203
2215
|
}
|
|
2204
|
-
const
|
|
2205
|
-
({ version: e, postEvent: t, createRequestId: s }) => new
|
|
2216
|
+
const gs = l(
|
|
2217
|
+
({ version: e, postEvent: t, createRequestId: s }) => new We(e, s, t)
|
|
2206
2218
|
);
|
|
2207
|
-
async function
|
|
2219
|
+
async function kt(e = {}) {
|
|
2208
2220
|
const {
|
|
2209
2221
|
is_expanded: t,
|
|
2210
2222
|
is_state_stable: s,
|
|
@@ -2219,7 +2231,7 @@ async function qt(e = {}) {
|
|
|
2219
2231
|
function x(e) {
|
|
2220
2232
|
return e < 0 ? 0 : e;
|
|
2221
2233
|
}
|
|
2222
|
-
class
|
|
2234
|
+
class He extends X {
|
|
2223
2235
|
constructor({ postEvent: s, stableHeight: n, height: r, width: i, isExpanded: a }) {
|
|
2224
2236
|
super({
|
|
2225
2237
|
height: x(r),
|
|
@@ -2236,7 +2248,7 @@ class Ge extends X {
|
|
|
2236
2248
|
* @param options - options to request fresh data.
|
|
2237
2249
|
*/
|
|
2238
2250
|
async sync(s) {
|
|
2239
|
-
const { isStateStable: n, ...r } = await
|
|
2251
|
+
const { isStateStable: n, ...r } = await kt(s);
|
|
2240
2252
|
this.set({
|
|
2241
2253
|
...r,
|
|
2242
2254
|
stableHeight: n ? r.height : this.get("stableHeight")
|
|
@@ -2328,7 +2340,7 @@ class Ge extends X {
|
|
|
2328
2340
|
return this.stableHeight === this.height;
|
|
2329
2341
|
}
|
|
2330
2342
|
}
|
|
2331
|
-
const
|
|
2343
|
+
const bs = l(
|
|
2332
2344
|
"viewport",
|
|
2333
2345
|
async ({ state: e, platform: t, postEvent: s, addCleanup: n }) => {
|
|
2334
2346
|
let r = !1, i = 0, a = 0, o = 0;
|
|
@@ -2337,10 +2349,10 @@ const ws = l(
|
|
|
2337
2349
|
else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
|
|
2338
2350
|
r = !0, i = window.innerHeight, a = window.innerWidth, o = window.innerHeight;
|
|
2339
2351
|
else {
|
|
2340
|
-
const u = await
|
|
2352
|
+
const u = await kt({ timeout: 1e3, postEvent: s });
|
|
2341
2353
|
r = u.isExpanded, i = u.height, a = u.width, o = u.isStateStable ? i : 0;
|
|
2342
2354
|
}
|
|
2343
|
-
const p = new
|
|
2355
|
+
const p = new He({
|
|
2344
2356
|
postEvent: s,
|
|
2345
2357
|
height: i,
|
|
2346
2358
|
width: a,
|
|
@@ -2353,7 +2365,7 @@ const ws = l(
|
|
|
2353
2365
|
function m(e, t) {
|
|
2354
2366
|
document.documentElement.style.setProperty(e, t);
|
|
2355
2367
|
}
|
|
2356
|
-
function
|
|
2368
|
+
function ws(e, t, s) {
|
|
2357
2369
|
s || (s = (o) => `--tg-${o}-color`);
|
|
2358
2370
|
const n = s("header"), r = s("bg"), i = () => {
|
|
2359
2371
|
const { headerColor: o } = e;
|
|
@@ -2370,7 +2382,7 @@ function ms(e, t, s) {
|
|
|
2370
2382
|
];
|
|
2371
2383
|
return i(), () => a.forEach((o) => o());
|
|
2372
2384
|
}
|
|
2373
|
-
function
|
|
2385
|
+
function ms(e, t) {
|
|
2374
2386
|
t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
|
|
2375
2387
|
const s = () => {
|
|
2376
2388
|
Object.entries(e.getState()).forEach(([n, r]) => {
|
|
@@ -2379,7 +2391,7 @@ function ys(e, t) {
|
|
|
2379
2391
|
};
|
|
2380
2392
|
return s(), e.on("change", s);
|
|
2381
2393
|
}
|
|
2382
|
-
function
|
|
2394
|
+
function ys(e, t) {
|
|
2383
2395
|
t || (t = (u) => `--tg-viewport-${u}`);
|
|
2384
2396
|
const [
|
|
2385
2397
|
s,
|
|
@@ -2392,10 +2404,10 @@ function vs(e, t) {
|
|
|
2392
2404
|
];
|
|
2393
2405
|
return i(), a(), o(), () => p.forEach((u) => u());
|
|
2394
2406
|
}
|
|
2395
|
-
function
|
|
2407
|
+
function vs(e = !0) {
|
|
2396
2408
|
const t = [
|
|
2397
2409
|
b("reload_iframe", () => {
|
|
2398
|
-
|
|
2410
|
+
A("iframe_will_reload"), window.location.reload();
|
|
2399
2411
|
})
|
|
2400
2412
|
], s = () => t.forEach((n) => n());
|
|
2401
2413
|
if (e) {
|
|
@@ -2407,13 +2419,13 @@ function Es(e = !0) {
|
|
|
2407
2419
|
() => document.head.removeChild(n)
|
|
2408
2420
|
);
|
|
2409
2421
|
}
|
|
2410
|
-
return
|
|
2422
|
+
return A("iframe_ready", { reload_supported: !0 }), s;
|
|
2411
2423
|
}
|
|
2412
|
-
function
|
|
2424
|
+
function Es() {
|
|
2413
2425
|
return typeof window > "u";
|
|
2414
2426
|
}
|
|
2415
|
-
async function
|
|
2416
|
-
if (
|
|
2427
|
+
async function Ps() {
|
|
2428
|
+
if (lt(window))
|
|
2417
2429
|
return !0;
|
|
2418
2430
|
try {
|
|
2419
2431
|
return await _({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
|
|
@@ -2421,11 +2433,11 @@ async function xs() {
|
|
|
2421
2433
|
return !1;
|
|
2422
2434
|
}
|
|
2423
2435
|
}
|
|
2424
|
-
function
|
|
2436
|
+
function Ge(e) {
|
|
2425
2437
|
return e instanceof V;
|
|
2426
2438
|
}
|
|
2427
|
-
function
|
|
2428
|
-
return
|
|
2439
|
+
function xs(e, t) {
|
|
2440
|
+
return Ge(e) && e.type === t;
|
|
2429
2441
|
}
|
|
2430
2442
|
function B(e, t) {
|
|
2431
2443
|
let s, n, r;
|
|
@@ -2435,13 +2447,13 @@ function B(e, t) {
|
|
|
2435
2447
|
params: n
|
|
2436
2448
|
});
|
|
2437
2449
|
}
|
|
2438
|
-
class
|
|
2439
|
-
constructor(t, s, n =
|
|
2450
|
+
class je {
|
|
2451
|
+
constructor(t, s, n = A) {
|
|
2440
2452
|
/**
|
|
2441
2453
|
* Navigation history.
|
|
2442
2454
|
*/
|
|
2443
2455
|
c(this, "history");
|
|
2444
|
-
c(this, "ee", new
|
|
2456
|
+
c(this, "ee", new R());
|
|
2445
2457
|
/**
|
|
2446
2458
|
* True, if current navigator is currently attached.
|
|
2447
2459
|
*/
|
|
@@ -2459,10 +2471,10 @@ class ze {
|
|
|
2459
2471
|
*/
|
|
2460
2472
|
c(this, "off", this.ee.off.bind(this.ee));
|
|
2461
2473
|
if (this._index = s, this.postEvent = n, t.length === 0)
|
|
2462
|
-
throw f(
|
|
2474
|
+
throw f(zt, "History should not be empty.");
|
|
2463
2475
|
if (s < 0 || s >= t.length)
|
|
2464
2476
|
throw f(
|
|
2465
|
-
|
|
2477
|
+
Ft,
|
|
2466
2478
|
"Index should not be zero and higher or equal than history size."
|
|
2467
2479
|
);
|
|
2468
2480
|
this.history = t.map((r) => B(r, ""));
|
|
@@ -2583,26 +2595,26 @@ function O({
|
|
|
2583
2595
|
}) {
|
|
2584
2596
|
return { ...e || { hash: "", search: "" }, ...t };
|
|
2585
2597
|
}
|
|
2586
|
-
function
|
|
2598
|
+
function T(e, t) {
|
|
2587
2599
|
return e.startsWith(t) ? e : `${t}${e}`;
|
|
2588
2600
|
}
|
|
2589
|
-
function
|
|
2601
|
+
function N(e) {
|
|
2590
2602
|
return new URL(
|
|
2591
|
-
typeof e == "string" ? e : `${e.pathname || ""}${
|
|
2603
|
+
typeof e == "string" ? e : `${e.pathname || ""}${T(e.search || "", "?")}${T(e.hash || "", "#")}`,
|
|
2592
2604
|
"http://a"
|
|
2593
2605
|
);
|
|
2594
2606
|
}
|
|
2595
|
-
function
|
|
2596
|
-
const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s =
|
|
2607
|
+
function D(e) {
|
|
2608
|
+
const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = N(e);
|
|
2597
2609
|
return `${t ? s.pathname : s.pathname.slice(1)}${s.search}${s.hash}`;
|
|
2598
2610
|
}
|
|
2599
2611
|
function U(e, t, s) {
|
|
2600
2612
|
let n, r;
|
|
2601
|
-
typeof e == "string" ? n = e : (n =
|
|
2602
|
-
const { pathname: i, search: a, hash: o } = new URL(n, `http://a${
|
|
2613
|
+
typeof e == "string" ? n = e : (n = D(e), s = e.state, r = e.id);
|
|
2614
|
+
const { pathname: i, search: a, hash: o } = new URL(n, `http://a${T(t, "/")}`);
|
|
2603
2615
|
return { id: r, pathname: i, params: { hash: o, search: a, state: s } };
|
|
2604
2616
|
}
|
|
2605
|
-
async function
|
|
2617
|
+
async function C(e) {
|
|
2606
2618
|
return e === 0 ? !0 : Promise.race([
|
|
2607
2619
|
new Promise((t) => {
|
|
2608
2620
|
const s = j("popstate", () => {
|
|
@@ -2616,21 +2628,21 @@ async function S(e) {
|
|
|
2616
2628
|
})
|
|
2617
2629
|
]);
|
|
2618
2630
|
}
|
|
2619
|
-
async function
|
|
2620
|
-
if (window.history.length <= 1 || (window.history.pushState(null, ""), await
|
|
2631
|
+
async function ze() {
|
|
2632
|
+
if (window.history.length <= 1 || (window.history.pushState(null, ""), await C(1 - window.history.length)))
|
|
2621
2633
|
return;
|
|
2622
|
-
let t = await
|
|
2634
|
+
let t = await C(-1);
|
|
2623
2635
|
for (; t; )
|
|
2624
|
-
t = await
|
|
2636
|
+
t = await C(-1);
|
|
2625
2637
|
}
|
|
2626
|
-
function
|
|
2627
|
-
return
|
|
2638
|
+
function Nt(e) {
|
|
2639
|
+
return N(e).pathname;
|
|
2628
2640
|
}
|
|
2629
2641
|
const rt = 0, W = 1, H = 2;
|
|
2630
|
-
class
|
|
2642
|
+
class Dt {
|
|
2631
2643
|
constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
|
|
2632
2644
|
c(this, "navigator");
|
|
2633
|
-
c(this, "ee", new
|
|
2645
|
+
c(this, "ee", new R());
|
|
2634
2646
|
c(this, "hashMode");
|
|
2635
2647
|
c(this, "base");
|
|
2636
2648
|
/**
|
|
@@ -2669,11 +2681,11 @@ class Nt {
|
|
|
2669
2681
|
* Removes event listener.
|
|
2670
2682
|
*/
|
|
2671
2683
|
c(this, "off", this.ee.off.bind(this.ee));
|
|
2672
|
-
this.navigator = new
|
|
2684
|
+
this.navigator = new je(
|
|
2673
2685
|
t.map((a) => U(a, "/")),
|
|
2674
2686
|
s,
|
|
2675
2687
|
n
|
|
2676
|
-
), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base =
|
|
2688
|
+
), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Nt(i || "");
|
|
2677
2689
|
}
|
|
2678
2690
|
/**
|
|
2679
2691
|
* Attaches current navigator to the browser history allowing navigator to manipulate it.
|
|
@@ -2771,7 +2783,7 @@ class Nt {
|
|
|
2771
2783
|
* "/pathname?search#hash"
|
|
2772
2784
|
*/
|
|
2773
2785
|
get path() {
|
|
2774
|
-
return
|
|
2786
|
+
return D(this);
|
|
2775
2787
|
}
|
|
2776
2788
|
/**
|
|
2777
2789
|
* Current pathname. Always starts with the slash.
|
|
@@ -2800,8 +2812,8 @@ class Nt {
|
|
|
2800
2812
|
* // { pathname: '/tma', search: '?is=cool', hash: '#yeah' }
|
|
2801
2813
|
*/
|
|
2802
2814
|
parsePath(t) {
|
|
2803
|
-
let s =
|
|
2804
|
-
return this.hashMode && (s =
|
|
2815
|
+
let s = N(t);
|
|
2816
|
+
return this.hashMode && (s = N(s.hash.slice(1))), {
|
|
2805
2817
|
pathname: s.pathname,
|
|
2806
2818
|
search: s.search,
|
|
2807
2819
|
hash: s.hash
|
|
@@ -2821,8 +2833,8 @@ class Nt {
|
|
|
2821
2833
|
* @param value - path presented as string or URLLike.
|
|
2822
2834
|
*/
|
|
2823
2835
|
renderPath(t) {
|
|
2824
|
-
const s = (this.base.length === 1 ? "" : this.base) +
|
|
2825
|
-
return this.hashMode ?
|
|
2836
|
+
const s = (this.base.length === 1 ? "" : this.base) + T(D(t), "/");
|
|
2837
|
+
return this.hashMode ? T(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
|
|
2826
2838
|
}
|
|
2827
2839
|
/**
|
|
2828
2840
|
* Synchronizes current navigator state with browser history.
|
|
@@ -2830,7 +2842,7 @@ class Nt {
|
|
|
2830
2842
|
async syncHistory() {
|
|
2831
2843
|
window.removeEventListener("popstate", this.onPopState);
|
|
2832
2844
|
const { state: t } = this, s = this.renderPath(this);
|
|
2833
|
-
await
|
|
2845
|
+
await ze(), this.hasPrev && this.hasNext ? (window.history.replaceState(W, ""), window.history.pushState(t, "", s), window.history.pushState(H, ""), await C(-1)) : this.hasPrev ? (window.history.replaceState(W, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(H, ""), await C(-1)) : (window.history.replaceState(rt, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
|
|
2834
2846
|
}
|
|
2835
2847
|
/**
|
|
2836
2848
|
* Current query parameters.
|
|
@@ -2848,42 +2860,42 @@ class Nt {
|
|
|
2848
2860
|
return (this.navigator.current.params || {}).state;
|
|
2849
2861
|
}
|
|
2850
2862
|
}
|
|
2851
|
-
function
|
|
2863
|
+
function Fe(e) {
|
|
2852
2864
|
e || (e = {});
|
|
2853
2865
|
const { href: t, hash: s } = window.location;
|
|
2854
|
-
let n =
|
|
2866
|
+
let n = D(
|
|
2855
2867
|
e.hashMode === null ? t : s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
|
|
2856
2868
|
);
|
|
2857
|
-
const r = e.base ?
|
|
2869
|
+
const r = e.base ? Nt(e.base) : void 0;
|
|
2858
2870
|
if (r) {
|
|
2859
2871
|
if (!n.startsWith(r))
|
|
2860
2872
|
throw f(
|
|
2861
|
-
|
|
2873
|
+
Jt,
|
|
2862
2874
|
`Path "${n}" expected to be starting with "${r}"`
|
|
2863
2875
|
);
|
|
2864
2876
|
n = n.slice(r.length);
|
|
2865
2877
|
}
|
|
2866
|
-
return new
|
|
2878
|
+
return new Dt([n], 0, e);
|
|
2867
2879
|
}
|
|
2868
2880
|
function Ss(e) {
|
|
2869
2881
|
const t = e.match(/#(.+)/);
|
|
2870
2882
|
return t ? t[1] : null;
|
|
2871
2883
|
}
|
|
2872
|
-
function
|
|
2873
|
-
if (
|
|
2884
|
+
function Je(e, t) {
|
|
2885
|
+
if (At()) {
|
|
2874
2886
|
const s = sessionStorage.getItem(e);
|
|
2875
2887
|
if (s)
|
|
2876
2888
|
try {
|
|
2877
2889
|
const { index: n, history: r } = JSON.parse(s);
|
|
2878
|
-
return new
|
|
2890
|
+
return new Dt(r, n, t);
|
|
2879
2891
|
} catch (n) {
|
|
2880
2892
|
console.error("Unable to restore hash navigator state.", n);
|
|
2881
2893
|
}
|
|
2882
2894
|
}
|
|
2883
|
-
return
|
|
2895
|
+
return Fe(t);
|
|
2884
2896
|
}
|
|
2885
|
-
function
|
|
2886
|
-
const s =
|
|
2897
|
+
function Cs(e, t) {
|
|
2898
|
+
const s = Je(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
|
|
2887
2899
|
index: s.index,
|
|
2888
2900
|
history: s.history
|
|
2889
2901
|
}));
|
|
@@ -2891,105 +2903,105 @@ function Rs(e, t) {
|
|
|
2891
2903
|
}
|
|
2892
2904
|
export {
|
|
2893
2905
|
pe as BackButton,
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2906
|
+
je as BasicNavigator,
|
|
2907
|
+
Pe as BiometryManager,
|
|
2908
|
+
Dt as BrowserNavigator,
|
|
2897
2909
|
Se as ClosingBehavior,
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2910
|
+
Te as CloudStorage,
|
|
2911
|
+
Jt as ERR_INVALID_PATH_BASE,
|
|
2912
|
+
Ht as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
|
|
2913
|
+
Ut as ERR_METHOD_PARAMETER_UNSUPPORTED,
|
|
2914
|
+
Ot as ERR_METHOD_UNSUPPORTED,
|
|
2915
|
+
zt as ERR_NAVIGATION_HISTORY_EMPTY,
|
|
2916
|
+
Ft as ERR_NAVIGATION_INDEX_INVALID,
|
|
2917
|
+
Ze as ERR_NAVIGATION_ITEM_INVALID,
|
|
2918
|
+
ct as ERR_PARSE,
|
|
2919
|
+
Ke as ERR_SSR_INIT,
|
|
2920
|
+
Gt as ERR_TIMED_OUT,
|
|
2921
|
+
jt as ERR_UNEXPECTED_TYPE,
|
|
2922
|
+
Wt as ERR_UNKNOWN_ENV,
|
|
2923
|
+
R as EventEmitter,
|
|
2924
|
+
Ie as HapticFeedback,
|
|
2925
|
+
qe as InitData,
|
|
2926
|
+
ke as Invoice,
|
|
2927
|
+
Ne as MainButton,
|
|
2928
|
+
$e as MiniApp,
|
|
2929
|
+
Le as Popup,
|
|
2930
|
+
Be as QRScanner,
|
|
2919
2931
|
V as SDKError,
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2932
|
+
Oe as SettingsButton,
|
|
2933
|
+
Ue as ThemeParams,
|
|
2934
|
+
We as Utils,
|
|
2935
|
+
He as Viewport,
|
|
2936
|
+
Ae as array,
|
|
2937
|
+
ws as bindMiniAppCSSVars,
|
|
2938
|
+
ms as bindThemeParamsCSSVars,
|
|
2939
|
+
ys as bindViewportCSSVars,
|
|
2928
2940
|
w as boolean,
|
|
2929
|
-
|
|
2941
|
+
_t as captureSameReq,
|
|
2930
2942
|
z as classNames,
|
|
2931
2943
|
re as compareVersions,
|
|
2932
|
-
|
|
2944
|
+
Fe as createBrowserNavigatorFromLocation,
|
|
2933
2945
|
ce as createPostEvent,
|
|
2934
|
-
|
|
2935
|
-
|
|
2946
|
+
N as createSafeURL,
|
|
2947
|
+
mt as date,
|
|
2936
2948
|
Ss as getHash,
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2949
|
+
Nt as getPathname,
|
|
2950
|
+
es as initBackButton,
|
|
2951
|
+
ss as initBiometryManager,
|
|
2952
|
+
ns as initClosingBehavior,
|
|
2953
|
+
rs as initCloudStorage,
|
|
2954
|
+
is as initHapticFeedback,
|
|
2955
|
+
os as initInitData,
|
|
2956
|
+
cs as initInvoice,
|
|
2957
|
+
hs as initMainButton,
|
|
2958
|
+
ps as initMiniApp,
|
|
2959
|
+
Cs as initNavigator,
|
|
2960
|
+
us as initPopup,
|
|
2961
|
+
ls as initQRScanner,
|
|
2962
|
+
ds as initSettingsButton,
|
|
2963
|
+
_s as initThemeParams,
|
|
2964
|
+
gs as initUtils,
|
|
2965
|
+
bs as initViewport,
|
|
2966
|
+
vs as initWeb,
|
|
2967
|
+
S as invokeCustomMethod,
|
|
2968
|
+
bt as isColorDark,
|
|
2957
2969
|
oe as isIframe,
|
|
2958
|
-
|
|
2970
|
+
At as isPageReload,
|
|
2959
2971
|
Q as isRGB,
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2972
|
+
Qt as isRGBShort,
|
|
2973
|
+
Ge as isSDKError,
|
|
2974
|
+
xs as isSDKErrorOfType,
|
|
2975
|
+
Es as isSSR,
|
|
2976
|
+
Ps as isTMA,
|
|
2965
2977
|
d as json,
|
|
2966
|
-
|
|
2978
|
+
ts as mergeClassNames,
|
|
2967
2979
|
y as number,
|
|
2968
2980
|
L as off,
|
|
2969
2981
|
b as on,
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2982
|
+
as as parseInitData,
|
|
2983
|
+
Et as parseLaunchParams,
|
|
2984
|
+
qt as parseThemeParams,
|
|
2985
|
+
A as postEvent,
|
|
2974
2986
|
_ as request,
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2987
|
+
xe as requestBiometryInfo,
|
|
2988
|
+
fs as requestThemeParams,
|
|
2989
|
+
kt as requestViewport,
|
|
2978
2990
|
ye as retrieveLaunchParams,
|
|
2979
|
-
|
|
2991
|
+
ut as rgb,
|
|
2980
2992
|
K as searchParams,
|
|
2981
2993
|
we as serializeLaunchParams,
|
|
2982
2994
|
be as serializeThemeParams,
|
|
2983
2995
|
m as setCSSVar,
|
|
2984
|
-
|
|
2985
|
-
|
|
2996
|
+
Ye as setDebug,
|
|
2997
|
+
Xe as setTargetOrigin,
|
|
2986
2998
|
h as string,
|
|
2987
|
-
|
|
2999
|
+
Mt as subscribe,
|
|
2988
3000
|
v as supports,
|
|
2989
3001
|
ae as targetOrigin,
|
|
2990
|
-
|
|
3002
|
+
pt as toRGB,
|
|
2991
3003
|
ot as unsubscribe,
|
|
2992
|
-
|
|
2993
|
-
|
|
3004
|
+
D as urlToPath,
|
|
3005
|
+
gt as withTimeout
|
|
2994
3006
|
};
|
|
2995
3007
|
//# sourceMappingURL=index.js.map
|