@tma.js/sdk-solid 2.1.2 → 2.1.3
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/SDKProvider/SDKProvider.types.d.ts +23 -6
- package/dist/dts/createHook.d.ts +4 -4
- package/dist/dts/hooks-hocs/back-button.d.ts +2 -2
- package/dist/dts/hooks-hocs/biometry-manager.d.ts +2 -2
- package/dist/dts/hooks-hocs/closing-behavior.d.ts +2 -2
- package/dist/dts/hooks-hocs/cloud-storage.d.ts +2 -2
- package/dist/dts/hooks-hocs/haptic-feedback.d.ts +2 -2
- package/dist/dts/hooks-hocs/init-data.d.ts +2 -2
- package/dist/dts/hooks-hocs/invoice.d.ts +2 -2
- package/dist/dts/hooks-hocs/main-button.d.ts +2 -2
- package/dist/dts/hooks-hocs/mini-app.d.ts +2 -2
- package/dist/dts/hooks-hocs/popup.d.ts +2 -2
- package/dist/dts/hooks-hocs/qr-scanner.d.ts +2 -2
- package/dist/dts/hooks-hocs/settings-button.d.ts +2 -2
- package/dist/dts/hooks-hocs/theme-params.d.ts +2 -2
- package/dist/dts/hooks-hocs/utils.d.ts +2 -2
- package/dist/dts/hooks-hocs/viewport.d.ts +2 -2
- package/dist/dts/index.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +643 -626
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { createComponent as
|
|
2
|
-
var
|
|
3
|
-
function
|
|
1
|
+
import { createComponent as gt, mergeProps as at, createContext as Qt, useContext as Ft, createEffect as ct, onCleanup as ht, createResource as Yt, createMemo as pt, from as Zt } from "solid-js";
|
|
2
|
+
var Xt = Object.defineProperty, te = (e, t, s) => t in e ? Xt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => (te(e, typeof t != "symbol" ? t + "" : t, s), s);
|
|
3
|
+
function ft(e, t) {
|
|
4
4
|
let s;
|
|
5
5
|
const n = () => {
|
|
6
6
|
s !== void 0 && t && t(s), s = void 0;
|
|
7
7
|
};
|
|
8
8
|
return [() => s === void 0 ? s = e(n) : s, n];
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
const t =
|
|
12
|
-
t.unsubscribe(e), s && !t.count &&
|
|
10
|
+
function mt(e) {
|
|
11
|
+
const t = U(), { count: s } = t;
|
|
12
|
+
t.unsubscribe(e), s && !t.count && Pe();
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
return
|
|
14
|
+
function ee(e) {
|
|
15
|
+
return U().subscribe(e), () => mt(e);
|
|
16
16
|
}
|
|
17
|
-
class
|
|
17
|
+
class se {
|
|
18
18
|
constructor(t, s = {}) {
|
|
19
19
|
this.scope = t, this.options = s;
|
|
20
20
|
}
|
|
@@ -54,21 +54,21 @@ class re {
|
|
|
54
54
|
this.print("log", ...t);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
const
|
|
57
|
+
const Z = new se("SDK", {
|
|
58
58
|
bgColor: "forestgreen",
|
|
59
59
|
textColor: "white"
|
|
60
60
|
});
|
|
61
|
-
let
|
|
61
|
+
let Q = !1;
|
|
62
62
|
const ut = ({ event: e, args: [t] }) => {
|
|
63
|
-
|
|
63
|
+
Z.log("Event received:", t === void 0 ? { name: e } : { name: e, data: t });
|
|
64
64
|
};
|
|
65
|
-
function
|
|
66
|
-
|
|
65
|
+
function ne(e) {
|
|
66
|
+
Q !== e && (Q = e, e ? ee(ut) : mt(ut));
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
|
|
68
|
+
function re(...e) {
|
|
69
|
+
Q && Z.log(...e);
|
|
70
70
|
}
|
|
71
|
-
class
|
|
71
|
+
class B {
|
|
72
72
|
constructor() {
|
|
73
73
|
c(this, "listeners", /* @__PURE__ */ new Map()), c(this, "listenersCount", 0), c(this, "subscribeListeners", []);
|
|
74
74
|
}
|
|
@@ -138,22 +138,22 @@ class L {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function F(e, t, s) {
|
|
142
142
|
return window.addEventListener(e, t, s), () => window.removeEventListener(e, t, s);
|
|
143
143
|
}
|
|
144
|
-
class
|
|
144
|
+
class $ extends Error {
|
|
145
145
|
constructor(t, s, n) {
|
|
146
|
-
super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this,
|
|
146
|
+
super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, $.prototype);
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
-
function
|
|
150
|
-
return new
|
|
149
|
+
function w(e, t, s) {
|
|
150
|
+
return new $(e, t, s);
|
|
151
151
|
}
|
|
152
|
-
const
|
|
152
|
+
const ie = "ERR_METHOD_UNSUPPORTED", oe = "ERR_METHOD_PARAMETER_UNSUPPORTED", ae = "ERR_UNKNOWN_ENV", ce = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", he = "ERR_TIMED_OUT", pe = "ERR_UNEXPECTED_TYPE", wt = "ERR_PARSE", ue = "ERR_NAVIGATION_LIST_EMPTY", le = "ERR_NAVIGATION_CURSOR_INVALID", Js = "ERR_NAVIGATION_ITEM_INVALID", Qs = "ERR_SSR_INIT", de = "ERR_INVALID_PATH_BASE";
|
|
153
153
|
function S() {
|
|
154
|
-
return
|
|
154
|
+
return w(pe, "Value has unexpected type");
|
|
155
155
|
}
|
|
156
|
-
class
|
|
156
|
+
class L {
|
|
157
157
|
constructor(t, s, n) {
|
|
158
158
|
this.parser = t, this.isOptional = s, this.type = n;
|
|
159
159
|
}
|
|
@@ -168,8 +168,8 @@ class H {
|
|
|
168
168
|
try {
|
|
169
169
|
return this.parser(t);
|
|
170
170
|
} catch (s) {
|
|
171
|
-
throw
|
|
172
|
-
|
|
171
|
+
throw w(
|
|
172
|
+
wt,
|
|
173
173
|
`Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
|
|
174
174
|
s
|
|
175
175
|
);
|
|
@@ -180,9 +180,9 @@ class H {
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
function R(e, t) {
|
|
183
|
-
return () => new
|
|
183
|
+
return () => new L(e, !1, t);
|
|
184
184
|
}
|
|
185
|
-
const
|
|
185
|
+
const y = R((e) => {
|
|
186
186
|
if (typeof e == "boolean")
|
|
187
187
|
return e;
|
|
188
188
|
const t = String(e);
|
|
@@ -192,7 +192,7 @@ const v = R((e) => {
|
|
|
192
192
|
return !1;
|
|
193
193
|
throw S();
|
|
194
194
|
}, "boolean");
|
|
195
|
-
function
|
|
195
|
+
function bt(e, t) {
|
|
196
196
|
const s = {};
|
|
197
197
|
for (const n in e) {
|
|
198
198
|
const r = e[n];
|
|
@@ -209,21 +209,21 @@ function yt(e, t) {
|
|
|
209
209
|
const a = o(t(i));
|
|
210
210
|
a !== void 0 && (s[n] = a);
|
|
211
211
|
} catch (a) {
|
|
212
|
-
throw
|
|
212
|
+
throw w(wt, `Unable to parse field "${n}"`, a);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
return s;
|
|
216
216
|
}
|
|
217
|
-
function
|
|
217
|
+
function X(e) {
|
|
218
218
|
let t = e;
|
|
219
219
|
if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
|
|
220
220
|
throw S();
|
|
221
221
|
return t;
|
|
222
222
|
}
|
|
223
|
-
function
|
|
224
|
-
return new
|
|
225
|
-
const n =
|
|
226
|
-
return
|
|
223
|
+
function f(e, t) {
|
|
224
|
+
return new L((s) => {
|
|
225
|
+
const n = X(s);
|
|
226
|
+
return bt(e, (r) => n[r]);
|
|
227
227
|
}, !1, t);
|
|
228
228
|
}
|
|
229
229
|
const P = R((e) => {
|
|
@@ -236,17 +236,17 @@ const P = R((e) => {
|
|
|
236
236
|
}
|
|
237
237
|
throw S();
|
|
238
238
|
}, "number");
|
|
239
|
-
function
|
|
239
|
+
function tt(e) {
|
|
240
240
|
return /^#[\da-f]{6}$/i.test(e);
|
|
241
241
|
}
|
|
242
|
-
function
|
|
242
|
+
function _e(e) {
|
|
243
243
|
return /^#[\da-f]{3}$/i.test(e);
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function vt(e) {
|
|
246
246
|
const t = e.replace(/\s/g, "").toLowerCase();
|
|
247
|
-
if (
|
|
247
|
+
if (tt(t))
|
|
248
248
|
return t;
|
|
249
|
-
if (
|
|
249
|
+
if (_e(t)) {
|
|
250
250
|
let n = "#";
|
|
251
251
|
for (let r = 0; r < 3; r += 1)
|
|
252
252
|
n += t[1 + r].repeat(2);
|
|
@@ -260,30 +260,30 @@ function Et(e) {
|
|
|
260
260
|
return n + (i.length === 1 ? "0" : "") + i;
|
|
261
261
|
}, "#");
|
|
262
262
|
}
|
|
263
|
-
const
|
|
263
|
+
const h = R((e) => {
|
|
264
264
|
if (typeof e == "string" || typeof e == "number")
|
|
265
265
|
return e.toString();
|
|
266
266
|
throw S();
|
|
267
|
-
}, "string"),
|
|
268
|
-
function
|
|
269
|
-
return
|
|
270
|
-
eventType:
|
|
267
|
+
}, "string"), yt = R((e) => vt(h().parse(e)), "rgb");
|
|
268
|
+
function ge(e) {
|
|
269
|
+
return f({
|
|
270
|
+
eventType: h(),
|
|
271
271
|
eventData: (t) => t
|
|
272
272
|
}).parse(e);
|
|
273
273
|
}
|
|
274
|
-
function
|
|
274
|
+
function fe() {
|
|
275
275
|
["TelegramGameProxy_receiveEvent", "TelegramGameProxy", "Telegram"].forEach((e) => {
|
|
276
276
|
delete window[e];
|
|
277
277
|
});
|
|
278
278
|
}
|
|
279
|
-
function
|
|
279
|
+
function me(e, t) {
|
|
280
280
|
window.dispatchEvent(new MessageEvent("message", {
|
|
281
281
|
data: JSON.stringify({ eventType: e, eventData: t }),
|
|
282
282
|
// We specify window.parent to imitate the case, the parent iframe sent us this event.
|
|
283
283
|
source: window.parent
|
|
284
284
|
}));
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function we() {
|
|
287
287
|
[
|
|
288
288
|
["TelegramGameProxy_receiveEvent"],
|
|
289
289
|
// Windows Phone.
|
|
@@ -295,66 +295,66 @@ function ve() {
|
|
|
295
295
|
let t = window;
|
|
296
296
|
e.forEach((s, n, r) => {
|
|
297
297
|
if (n === r.length - 1) {
|
|
298
|
-
t[s] =
|
|
298
|
+
t[s] = me;
|
|
299
299
|
return;
|
|
300
300
|
}
|
|
301
301
|
s in t || (t[s] = {}), t = t[s];
|
|
302
302
|
});
|
|
303
303
|
});
|
|
304
304
|
}
|
|
305
|
-
const
|
|
306
|
-
button_id: (e) => e == null ? void 0 :
|
|
307
|
-
}),
|
|
308
|
-
clipboard_text_received:
|
|
309
|
-
req_id:
|
|
310
|
-
data: (e) => e === null ? e :
|
|
305
|
+
const be = f({
|
|
306
|
+
button_id: (e) => e == null ? void 0 : h().parse(e)
|
|
307
|
+
}), ve = {
|
|
308
|
+
clipboard_text_received: f({
|
|
309
|
+
req_id: h(),
|
|
310
|
+
data: (e) => e === null ? e : h().optional().parse(e)
|
|
311
311
|
}),
|
|
312
|
-
custom_method_invoked:
|
|
313
|
-
req_id:
|
|
312
|
+
custom_method_invoked: f({
|
|
313
|
+
req_id: h(),
|
|
314
314
|
result: (e) => e,
|
|
315
|
-
error:
|
|
315
|
+
error: h().optional()
|
|
316
316
|
}),
|
|
317
|
-
invoice_closed:
|
|
318
|
-
slug:
|
|
319
|
-
status:
|
|
317
|
+
invoice_closed: f({
|
|
318
|
+
slug: h(),
|
|
319
|
+
status: h()
|
|
320
320
|
}),
|
|
321
|
-
phone_requested:
|
|
322
|
-
status:
|
|
321
|
+
phone_requested: f({
|
|
322
|
+
status: h()
|
|
323
323
|
}),
|
|
324
324
|
popup_closed: {
|
|
325
|
-
parse: (e) =>
|
|
325
|
+
parse: (e) => be.parse(e ?? {})
|
|
326
326
|
},
|
|
327
|
-
qr_text_received:
|
|
328
|
-
data:
|
|
327
|
+
qr_text_received: f({
|
|
328
|
+
data: h().optional()
|
|
329
329
|
}),
|
|
330
|
-
theme_changed:
|
|
330
|
+
theme_changed: f({
|
|
331
331
|
theme_params: (e) => {
|
|
332
|
-
const t =
|
|
333
|
-
return Object.entries(
|
|
332
|
+
const t = yt().optional();
|
|
333
|
+
return Object.entries(X(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
|
|
334
334
|
}
|
|
335
335
|
}),
|
|
336
|
-
viewport_changed:
|
|
336
|
+
viewport_changed: f({
|
|
337
337
|
height: P(),
|
|
338
338
|
width: (e) => e == null ? window.innerWidth : P().parse(e),
|
|
339
|
-
is_state_stable:
|
|
340
|
-
is_expanded:
|
|
339
|
+
is_state_stable: y(),
|
|
340
|
+
is_expanded: y()
|
|
341
341
|
}),
|
|
342
|
-
write_access_requested:
|
|
343
|
-
status:
|
|
342
|
+
write_access_requested: f({
|
|
343
|
+
status: h()
|
|
344
344
|
})
|
|
345
345
|
};
|
|
346
|
-
function
|
|
347
|
-
const e = new
|
|
348
|
-
|
|
346
|
+
function ye() {
|
|
347
|
+
const e = new B();
|
|
348
|
+
we();
|
|
349
349
|
let t = [
|
|
350
350
|
// Don't forget to remove created handlers.
|
|
351
|
-
|
|
351
|
+
fe,
|
|
352
352
|
// Add "resize" event listener to make sure, we always have fresh viewport information.
|
|
353
353
|
// Desktop version of Telegram is sometimes not sending the viewport_changed
|
|
354
354
|
// event. For example, when the MainButton is shown. That's why we should
|
|
355
355
|
// add our own listener to make sure, viewport information is always fresh.
|
|
356
356
|
// Issue: https://github.com/Telegram-Mini-Apps/tma.js/issues/10
|
|
357
|
-
|
|
357
|
+
F("resize", () => {
|
|
358
358
|
e.emit("viewport_changed", {
|
|
359
359
|
width: window.innerWidth,
|
|
360
360
|
height: window.innerHeight,
|
|
@@ -364,21 +364,21 @@ function Pe() {
|
|
|
364
364
|
}),
|
|
365
365
|
// Add listener, which handles events sent from the Telegram web application and also events
|
|
366
366
|
// generated by the local emitEvent function.
|
|
367
|
-
|
|
367
|
+
F("message", (s) => {
|
|
368
368
|
if (s.source !== window.parent)
|
|
369
369
|
return;
|
|
370
370
|
let n;
|
|
371
371
|
try {
|
|
372
|
-
n =
|
|
372
|
+
n = ge(s.data);
|
|
373
373
|
} catch {
|
|
374
374
|
return;
|
|
375
375
|
}
|
|
376
|
-
const { eventType: r, eventData: i } = n, o =
|
|
376
|
+
const { eventType: r, eventData: i } = n, o = ve[r];
|
|
377
377
|
try {
|
|
378
378
|
const a = o ? o.parse(i) : i;
|
|
379
379
|
e.emit(...a ? [r, a] : [r]);
|
|
380
380
|
} catch (a) {
|
|
381
|
-
|
|
381
|
+
Z.error(
|
|
382
382
|
`An error occurred processing the "${r}" event from the Telegram application. Please, file an issue here: https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose`,
|
|
383
383
|
n,
|
|
384
384
|
a
|
|
@@ -392,9 +392,9 @@ function Pe() {
|
|
|
392
392
|
t.forEach((s) => s()), t = [];
|
|
393
393
|
}];
|
|
394
394
|
}
|
|
395
|
-
const [
|
|
395
|
+
const [Ee, Pe] = ft(
|
|
396
396
|
(e) => {
|
|
397
|
-
const [t, s] =
|
|
397
|
+
const [t, s] = ye(), n = t.off.bind(t);
|
|
398
398
|
return t.off = (r, i) => {
|
|
399
399
|
const { count: o } = t;
|
|
400
400
|
n(r, i), o && !t.count && e();
|
|
@@ -402,19 +402,19 @@ const [xe, Ce] = mt(
|
|
|
402
402
|
},
|
|
403
403
|
([, e]) => e()
|
|
404
404
|
);
|
|
405
|
-
function
|
|
406
|
-
return
|
|
405
|
+
function U() {
|
|
406
|
+
return Ee()[0];
|
|
407
407
|
}
|
|
408
|
-
function
|
|
409
|
-
|
|
408
|
+
function H(e, t) {
|
|
409
|
+
U().off(e, t);
|
|
410
410
|
}
|
|
411
|
-
function
|
|
412
|
-
return
|
|
411
|
+
function v(e, t, s) {
|
|
412
|
+
return U().on(e, t, s);
|
|
413
413
|
}
|
|
414
414
|
function q(e) {
|
|
415
415
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
416
416
|
}
|
|
417
|
-
function
|
|
417
|
+
function xe(e, t) {
|
|
418
418
|
const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
|
|
419
419
|
for (let i = 0; i < r; i += 1) {
|
|
420
420
|
const o = parseInt(s[i] || "0", 10), a = parseInt(n[i] || "0", 10);
|
|
@@ -423,15 +423,15 @@ function Se(e, t) {
|
|
|
423
423
|
}
|
|
424
424
|
return 0;
|
|
425
425
|
}
|
|
426
|
-
function
|
|
427
|
-
return
|
|
426
|
+
function b(e, t) {
|
|
427
|
+
return xe(e, t) <= 0;
|
|
428
428
|
}
|
|
429
429
|
function C(e, t, s) {
|
|
430
430
|
if (typeof s == "string") {
|
|
431
431
|
if (e === "web_app_open_link" && t === "try_instant_view")
|
|
432
|
-
return
|
|
432
|
+
return b("6.4", s);
|
|
433
433
|
if (e === "web_app_set_header_color" && t === "color")
|
|
434
|
-
return
|
|
434
|
+
return b("6.9", s);
|
|
435
435
|
}
|
|
436
436
|
switch (e) {
|
|
437
437
|
case "web_app_open_tg_link":
|
|
@@ -440,27 +440,27 @@ function C(e, t, s) {
|
|
|
440
440
|
case "web_app_set_background_color":
|
|
441
441
|
case "web_app_set_header_color":
|
|
442
442
|
case "web_app_trigger_haptic_feedback":
|
|
443
|
-
return
|
|
443
|
+
return b("6.1", t);
|
|
444
444
|
case "web_app_open_popup":
|
|
445
|
-
return
|
|
445
|
+
return b("6.2", t);
|
|
446
446
|
case "web_app_close_scan_qr_popup":
|
|
447
447
|
case "web_app_open_scan_qr_popup":
|
|
448
448
|
case "web_app_read_text_from_clipboard":
|
|
449
|
-
return
|
|
449
|
+
return b("6.4", t);
|
|
450
450
|
case "web_app_switch_inline_query":
|
|
451
|
-
return
|
|
451
|
+
return b("6.7", t);
|
|
452
452
|
case "web_app_invoke_custom_method":
|
|
453
453
|
case "web_app_request_write_access":
|
|
454
454
|
case "web_app_request_phone":
|
|
455
|
-
return
|
|
455
|
+
return b("6.9", t);
|
|
456
456
|
case "web_app_setup_settings_button":
|
|
457
|
-
return
|
|
457
|
+
return b("6.10", t);
|
|
458
458
|
case "web_app_biometry_get_info":
|
|
459
459
|
case "web_app_biometry_open_settings":
|
|
460
460
|
case "web_app_biometry_request_access":
|
|
461
461
|
case "web_app_biometry_request_auth":
|
|
462
462
|
case "web_app_biometry_update_token":
|
|
463
|
-
return
|
|
463
|
+
return b("7.2", t);
|
|
464
464
|
default:
|
|
465
465
|
return [
|
|
466
466
|
"iframe_ready",
|
|
@@ -477,79 +477,79 @@ function C(e, t, s) {
|
|
|
477
477
|
].includes(e);
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
|
-
function
|
|
480
|
+
function Ce(e) {
|
|
481
481
|
return "external" in e && q(e.external) && "notify" in e.external && typeof e.external.notify == "function";
|
|
482
482
|
}
|
|
483
|
-
function
|
|
483
|
+
function Et(e) {
|
|
484
484
|
return "TelegramWebviewProxy" in e && q(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
|
|
485
485
|
}
|
|
486
|
-
function
|
|
486
|
+
function Pt() {
|
|
487
487
|
try {
|
|
488
488
|
return window.self !== window.top;
|
|
489
489
|
} catch {
|
|
490
490
|
return !0;
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
|
-
let
|
|
493
|
+
let xt = "https://web.telegram.org";
|
|
494
494
|
function Fs(e) {
|
|
495
|
-
|
|
495
|
+
xt = e;
|
|
496
496
|
}
|
|
497
|
-
function
|
|
498
|
-
return
|
|
497
|
+
function Se() {
|
|
498
|
+
return xt;
|
|
499
499
|
}
|
|
500
500
|
function k(e, t, s) {
|
|
501
501
|
let n = {}, r;
|
|
502
502
|
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);
|
|
503
|
-
const { targetOrigin: i =
|
|
504
|
-
if (
|
|
503
|
+
const { targetOrigin: i = Se() } = n;
|
|
504
|
+
if (re("Posting event:", r ? { event: e, data: r } : { event: e }), Pt()) {
|
|
505
505
|
window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
|
|
506
506
|
return;
|
|
507
507
|
}
|
|
508
|
-
if (
|
|
508
|
+
if (Ce(window)) {
|
|
509
509
|
window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
|
|
510
510
|
return;
|
|
511
511
|
}
|
|
512
|
-
if (
|
|
512
|
+
if (Et(window)) {
|
|
513
513
|
window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
|
|
514
514
|
return;
|
|
515
515
|
}
|
|
516
|
-
throw
|
|
517
|
-
|
|
516
|
+
throw w(
|
|
517
|
+
ae,
|
|
518
518
|
"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."
|
|
519
519
|
);
|
|
520
520
|
}
|
|
521
|
-
function
|
|
521
|
+
function Re(e) {
|
|
522
522
|
return (t, s) => {
|
|
523
523
|
if (!C(t, e))
|
|
524
|
-
throw
|
|
524
|
+
throw w(ie, `Method "${t}" is unsupported in Mini Apps version ${e}`);
|
|
525
525
|
if (q(s)) {
|
|
526
526
|
let n;
|
|
527
527
|
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 && !C(t, n, e))
|
|
528
|
-
throw
|
|
529
|
-
|
|
528
|
+
throw w(
|
|
529
|
+
oe,
|
|
530
530
|
`Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
|
|
531
531
|
);
|
|
532
532
|
}
|
|
533
533
|
return k(t, s);
|
|
534
534
|
};
|
|
535
535
|
}
|
|
536
|
-
function
|
|
536
|
+
function Ct(e) {
|
|
537
537
|
return ({ req_id: t }) => t === e;
|
|
538
538
|
}
|
|
539
|
-
function
|
|
540
|
-
return
|
|
539
|
+
function St(e) {
|
|
540
|
+
return w(he, `Timeout reached: ${e}ms`);
|
|
541
541
|
}
|
|
542
|
-
function
|
|
542
|
+
function Rt(e, t) {
|
|
543
543
|
return Promise.race([
|
|
544
544
|
typeof e == "function" ? e() : e,
|
|
545
545
|
new Promise((s, n) => {
|
|
546
546
|
setTimeout(() => {
|
|
547
|
-
n(
|
|
547
|
+
n(St(t));
|
|
548
548
|
}, t);
|
|
549
549
|
})
|
|
550
550
|
]);
|
|
551
551
|
}
|
|
552
|
-
async function
|
|
552
|
+
async function m(e) {
|
|
553
553
|
let t;
|
|
554
554
|
const s = new Promise((u) => {
|
|
555
555
|
t = u;
|
|
@@ -559,20 +559,20 @@ async function f(e) {
|
|
|
559
559
|
capture: i,
|
|
560
560
|
postEvent: o = k,
|
|
561
561
|
timeout: a
|
|
562
|
-
} = e,
|
|
563
|
-
(u) =>
|
|
562
|
+
} = e, p = (Array.isArray(r) ? r : [r]).map(
|
|
563
|
+
(u) => v(u, (l) => (!i || i(l)) && t(l))
|
|
564
564
|
);
|
|
565
565
|
try {
|
|
566
|
-
return o(n, e.params), await (a ?
|
|
566
|
+
return o(n, e.params), await (a ? Rt(s, a) : s);
|
|
567
567
|
} finally {
|
|
568
|
-
|
|
568
|
+
p.forEach((u) => u());
|
|
569
569
|
}
|
|
570
570
|
}
|
|
571
|
-
async function
|
|
571
|
+
async function A(e, t, s, n = {}) {
|
|
572
572
|
const {
|
|
573
573
|
result: r,
|
|
574
574
|
error: i
|
|
575
|
-
} = await
|
|
575
|
+
} = await m({
|
|
576
576
|
...n,
|
|
577
577
|
method: "web_app_invoke_custom_method",
|
|
578
578
|
event: "custom_method_invoked",
|
|
@@ -581,30 +581,30 @@ async function T(e, t, s, n = {}) {
|
|
|
581
581
|
params: t,
|
|
582
582
|
req_id: s
|
|
583
583
|
},
|
|
584
|
-
capture:
|
|
584
|
+
capture: Ct(s)
|
|
585
585
|
});
|
|
586
586
|
if (i)
|
|
587
|
-
throw
|
|
587
|
+
throw w(ce, i);
|
|
588
588
|
return r;
|
|
589
589
|
}
|
|
590
|
-
function
|
|
590
|
+
function Y(...e) {
|
|
591
591
|
return e.map((t) => {
|
|
592
592
|
if (typeof t == "string")
|
|
593
593
|
return t;
|
|
594
594
|
if (q(t))
|
|
595
|
-
return
|
|
595
|
+
return Y(Object.entries(t).map((s) => s[1] && s[0]));
|
|
596
596
|
if (Array.isArray(t))
|
|
597
|
-
return
|
|
597
|
+
return Y(...t);
|
|
598
598
|
}).filter(Boolean).join(" ");
|
|
599
599
|
}
|
|
600
600
|
function Ys(...e) {
|
|
601
601
|
return e.reduce((t, s) => (q(s) && Object.entries(s).forEach(([n, r]) => {
|
|
602
|
-
const i =
|
|
602
|
+
const i = Y(t[n], r);
|
|
603
603
|
i.length && (t[n] = i);
|
|
604
604
|
}), t), {});
|
|
605
605
|
}
|
|
606
|
-
function
|
|
607
|
-
const t =
|
|
606
|
+
function Tt(e) {
|
|
607
|
+
const t = vt(e);
|
|
608
608
|
return Math.sqrt(
|
|
609
609
|
[0.299, 0.587, 0.114].reduce((s, n, r) => {
|
|
610
610
|
const i = parseInt(t.slice(1 + r * 2, 1 + (r + 1) * 2), 16);
|
|
@@ -612,9 +612,9 @@ function It(e) {
|
|
|
612
612
|
}, 0)
|
|
613
613
|
) < 120;
|
|
614
614
|
}
|
|
615
|
-
class
|
|
615
|
+
class Te {
|
|
616
616
|
constructor(t) {
|
|
617
|
-
c(this, "ee", new
|
|
617
|
+
c(this, "ee", new B()), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.state = t;
|
|
618
618
|
}
|
|
619
619
|
/**
|
|
620
620
|
* Clones current state and returns its copy.
|
|
@@ -633,25 +633,25 @@ class Ie {
|
|
|
633
633
|
return this.state[t];
|
|
634
634
|
}
|
|
635
635
|
}
|
|
636
|
-
class
|
|
636
|
+
class et {
|
|
637
637
|
constructor(t) {
|
|
638
|
-
c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new
|
|
638
|
+
c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new Te(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);
|
|
639
639
|
}
|
|
640
640
|
}
|
|
641
|
-
function
|
|
641
|
+
function At(e, t) {
|
|
642
642
|
return (s) => C(t[s], e);
|
|
643
643
|
}
|
|
644
|
-
class
|
|
644
|
+
class st extends et {
|
|
645
645
|
constructor(t, s, n) {
|
|
646
|
-
super(t), c(this, "supports"), this.supports =
|
|
646
|
+
super(t), c(this, "supports"), this.supports = At(s, n);
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
|
-
class
|
|
649
|
+
class Ae extends st {
|
|
650
650
|
constructor(t, s, n) {
|
|
651
651
|
super({ isVisible: t }, s, {
|
|
652
652
|
show: "web_app_setup_back_button",
|
|
653
653
|
hide: "web_app_setup_back_button"
|
|
654
|
-
}), c(this, "on", (r, i) => r === "click" ?
|
|
654
|
+
}), c(this, "on", (r, i) => r === "click" ? v("back_button_pressed", i) : this.state.on(r, i)), c(this, "off", (r, i) => r === "click" ? H("back_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
|
|
655
655
|
}
|
|
656
656
|
set isVisible(t) {
|
|
657
657
|
this.set("isVisible", t), this.postEvent("web_app_setup_back_button", { is_visible: t });
|
|
@@ -675,188 +675,185 @@ class ke extends nt {
|
|
|
675
675
|
this.isVisible = !0;
|
|
676
676
|
}
|
|
677
677
|
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
const Ot = R((e) => e instanceof Date ? e : new Date(P().parse(e) * 1e3), "Date");
|
|
682
|
-
function rt(e, t) {
|
|
683
|
-
return new H((s) => {
|
|
678
|
+
const It = R((e) => e instanceof Date ? e : new Date(P().parse(e) * 1e3), "Date");
|
|
679
|
+
function nt(e, t) {
|
|
680
|
+
return new L((s) => {
|
|
684
681
|
if (typeof s != "string" && !(s instanceof URLSearchParams))
|
|
685
682
|
throw S();
|
|
686
683
|
const n = typeof s == "string" ? new URLSearchParams(s) : s;
|
|
687
|
-
return
|
|
684
|
+
return bt(e, (r) => {
|
|
688
685
|
const i = n.get(r);
|
|
689
686
|
return i === null ? void 0 : i;
|
|
690
687
|
});
|
|
691
688
|
}, !1, t);
|
|
692
689
|
}
|
|
693
|
-
const
|
|
690
|
+
const Ie = f({
|
|
694
691
|
id: P(),
|
|
695
|
-
type:
|
|
696
|
-
title:
|
|
692
|
+
type: h(),
|
|
693
|
+
title: h(),
|
|
697
694
|
photoUrl: {
|
|
698
|
-
type:
|
|
695
|
+
type: h().optional(),
|
|
699
696
|
from: "photo_url"
|
|
700
697
|
},
|
|
701
|
-
username:
|
|
702
|
-
}, "Chat").optional(),
|
|
698
|
+
username: h().optional()
|
|
699
|
+
}, "Chat").optional(), lt = f({
|
|
703
700
|
addedToAttachmentMenu: {
|
|
704
|
-
type:
|
|
701
|
+
type: y().optional(),
|
|
705
702
|
from: "added_to_attachment_menu"
|
|
706
703
|
},
|
|
707
704
|
allowsWriteToPm: {
|
|
708
|
-
type:
|
|
705
|
+
type: y().optional(),
|
|
709
706
|
from: "allows_write_to_pm"
|
|
710
707
|
},
|
|
711
708
|
firstName: {
|
|
712
|
-
type:
|
|
709
|
+
type: h(),
|
|
713
710
|
from: "first_name"
|
|
714
711
|
},
|
|
715
712
|
id: P(),
|
|
716
713
|
isBot: {
|
|
717
|
-
type:
|
|
714
|
+
type: y().optional(),
|
|
718
715
|
from: "is_bot"
|
|
719
716
|
},
|
|
720
717
|
isPremium: {
|
|
721
|
-
type:
|
|
718
|
+
type: y().optional(),
|
|
722
719
|
from: "is_premium"
|
|
723
720
|
},
|
|
724
721
|
languageCode: {
|
|
725
|
-
type:
|
|
722
|
+
type: h().optional(),
|
|
726
723
|
from: "language_code"
|
|
727
724
|
},
|
|
728
725
|
lastName: {
|
|
729
|
-
type:
|
|
726
|
+
type: h().optional(),
|
|
730
727
|
from: "last_name"
|
|
731
728
|
},
|
|
732
729
|
photoUrl: {
|
|
733
|
-
type:
|
|
730
|
+
type: h().optional(),
|
|
734
731
|
from: "photo_url"
|
|
735
732
|
},
|
|
736
|
-
username:
|
|
733
|
+
username: h().optional()
|
|
737
734
|
}, "User").optional();
|
|
738
|
-
function
|
|
739
|
-
return
|
|
735
|
+
function kt() {
|
|
736
|
+
return nt({
|
|
740
737
|
authDate: {
|
|
741
|
-
type:
|
|
738
|
+
type: It(),
|
|
742
739
|
from: "auth_date"
|
|
743
740
|
},
|
|
744
741
|
canSendAfter: {
|
|
745
742
|
type: P().optional(),
|
|
746
743
|
from: "can_send_after"
|
|
747
744
|
},
|
|
748
|
-
chat:
|
|
745
|
+
chat: Ie,
|
|
749
746
|
chatInstance: {
|
|
750
|
-
type:
|
|
747
|
+
type: h().optional(),
|
|
751
748
|
from: "chat_instance"
|
|
752
749
|
},
|
|
753
750
|
chatType: {
|
|
754
|
-
type:
|
|
751
|
+
type: h().optional(),
|
|
755
752
|
from: "chat_type"
|
|
756
753
|
},
|
|
757
|
-
hash:
|
|
754
|
+
hash: h(),
|
|
758
755
|
queryId: {
|
|
759
|
-
type:
|
|
756
|
+
type: h().optional(),
|
|
760
757
|
from: "query_id"
|
|
761
758
|
},
|
|
762
|
-
receiver:
|
|
759
|
+
receiver: lt,
|
|
763
760
|
startParam: {
|
|
764
|
-
type:
|
|
761
|
+
type: h().optional(),
|
|
765
762
|
from: "start_param"
|
|
766
763
|
},
|
|
767
|
-
user:
|
|
764
|
+
user: lt
|
|
768
765
|
}, "InitData");
|
|
769
766
|
}
|
|
770
|
-
function
|
|
767
|
+
function ke(e) {
|
|
771
768
|
return e.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
|
|
772
769
|
}
|
|
773
|
-
function
|
|
770
|
+
function Oe(e) {
|
|
774
771
|
return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
|
|
775
772
|
}
|
|
776
|
-
const
|
|
773
|
+
const Ot = R(
|
|
777
774
|
(e) => {
|
|
778
|
-
const t =
|
|
779
|
-
return Object.entries(
|
|
775
|
+
const t = yt().optional();
|
|
776
|
+
return Object.entries(X(e)).reduce((s, [n, r]) => (s[ke(n)] = t.parse(r), s), {});
|
|
780
777
|
},
|
|
781
778
|
"ThemeParams"
|
|
782
779
|
);
|
|
783
|
-
function
|
|
784
|
-
return
|
|
780
|
+
function qt(e) {
|
|
781
|
+
return nt({
|
|
785
782
|
botInline: {
|
|
786
|
-
type:
|
|
783
|
+
type: y().optional(),
|
|
787
784
|
from: "tgWebAppBotInline"
|
|
788
785
|
},
|
|
789
786
|
initData: {
|
|
790
|
-
type:
|
|
787
|
+
type: kt().optional(),
|
|
791
788
|
from: "tgWebAppData"
|
|
792
789
|
},
|
|
793
790
|
initDataRaw: {
|
|
794
|
-
type:
|
|
791
|
+
type: h().optional(),
|
|
795
792
|
from: "tgWebAppData"
|
|
796
793
|
},
|
|
797
794
|
platform: {
|
|
798
|
-
type:
|
|
795
|
+
type: h(),
|
|
799
796
|
from: "tgWebAppPlatform"
|
|
800
797
|
},
|
|
801
798
|
showSettings: {
|
|
802
|
-
type:
|
|
799
|
+
type: y().optional(),
|
|
803
800
|
from: "tgWebAppShowSettings"
|
|
804
801
|
},
|
|
805
802
|
startParam: {
|
|
806
|
-
type:
|
|
803
|
+
type: h().optional(),
|
|
807
804
|
from: "tgWebAppStartParam"
|
|
808
805
|
},
|
|
809
806
|
themeParams: {
|
|
810
|
-
type:
|
|
807
|
+
type: Ot(),
|
|
811
808
|
from: "tgWebAppThemeParams"
|
|
812
809
|
},
|
|
813
810
|
version: {
|
|
814
|
-
type:
|
|
811
|
+
type: h(),
|
|
815
812
|
from: "tgWebAppVersion"
|
|
816
813
|
}
|
|
817
814
|
}).parse(e);
|
|
818
815
|
}
|
|
819
|
-
function
|
|
820
|
-
return
|
|
816
|
+
function Dt(e) {
|
|
817
|
+
return qt(
|
|
821
818
|
e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
|
|
822
819
|
);
|
|
823
820
|
}
|
|
824
|
-
function
|
|
825
|
-
return
|
|
821
|
+
function qe() {
|
|
822
|
+
return Dt(window.location.href);
|
|
826
823
|
}
|
|
827
|
-
function
|
|
824
|
+
function Nt() {
|
|
828
825
|
return performance.getEntriesByType("navigation")[0];
|
|
829
826
|
}
|
|
830
|
-
function
|
|
831
|
-
const e =
|
|
827
|
+
function De() {
|
|
828
|
+
const e = Nt();
|
|
832
829
|
if (!e)
|
|
833
830
|
throw new Error("Unable to get first navigation entry.");
|
|
834
|
-
return
|
|
831
|
+
return Dt(e.name);
|
|
835
832
|
}
|
|
836
|
-
function
|
|
833
|
+
function Vt(e) {
|
|
837
834
|
return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
|
|
838
835
|
}
|
|
839
|
-
function
|
|
840
|
-
sessionStorage.setItem(
|
|
836
|
+
function Mt(e, t) {
|
|
837
|
+
sessionStorage.setItem(Vt(e), JSON.stringify(t));
|
|
841
838
|
}
|
|
842
|
-
function
|
|
843
|
-
const t = sessionStorage.getItem(
|
|
839
|
+
function Bt(e) {
|
|
840
|
+
const t = sessionStorage.getItem(Vt(e));
|
|
844
841
|
try {
|
|
845
842
|
return t ? JSON.parse(t) : void 0;
|
|
846
843
|
} catch {
|
|
847
844
|
}
|
|
848
845
|
}
|
|
849
|
-
function
|
|
850
|
-
return
|
|
846
|
+
function Ne() {
|
|
847
|
+
return qt(Bt("launchParams") || "");
|
|
851
848
|
}
|
|
852
|
-
function
|
|
849
|
+
function Ve(e) {
|
|
853
850
|
return JSON.stringify(
|
|
854
851
|
Object.fromEntries(
|
|
855
|
-
Object.entries(e).map(([t, s]) => [
|
|
852
|
+
Object.entries(e).map(([t, s]) => [Oe(t), s])
|
|
856
853
|
)
|
|
857
854
|
);
|
|
858
855
|
}
|
|
859
|
-
function
|
|
856
|
+
function Me(e) {
|
|
860
857
|
const {
|
|
861
858
|
initDataRaw: t,
|
|
862
859
|
themeParams: s,
|
|
@@ -865,72 +862,87 @@ function $e(e) {
|
|
|
865
862
|
showSettings: i,
|
|
866
863
|
startParam: o,
|
|
867
864
|
botInline: a
|
|
868
|
-
} = e,
|
|
869
|
-
return
|
|
865
|
+
} = e, p = new URLSearchParams();
|
|
866
|
+
return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", Ve(s)), p.set("tgWebAppVersion", r), t && p.set("tgWebAppData", t), o && p.set("tgWebAppStartParam", o), typeof i == "boolean" && p.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && p.set("tgWebAppBotInline", a ? "1" : "0"), p.toString();
|
|
870
867
|
}
|
|
871
|
-
function
|
|
872
|
-
|
|
868
|
+
function Be(e) {
|
|
869
|
+
Mt("launchParams", Me(e));
|
|
873
870
|
}
|
|
874
|
-
function
|
|
871
|
+
function $e() {
|
|
875
872
|
for (const e of [
|
|
876
873
|
// Try to retrieve launch parameters from the current location. This method can return
|
|
877
874
|
// nothing in case, location was changed and then page was reloaded.
|
|
878
|
-
|
|
875
|
+
qe,
|
|
879
876
|
// Then, try using the lower level API - window.performance.
|
|
880
|
-
|
|
877
|
+
De,
|
|
881
878
|
// Finally, try to extract launch parameters from the session storage.
|
|
882
|
-
|
|
879
|
+
Ne
|
|
883
880
|
])
|
|
884
881
|
try {
|
|
885
882
|
const t = e();
|
|
886
|
-
return
|
|
883
|
+
return Be(t), t;
|
|
887
884
|
} catch {
|
|
888
885
|
}
|
|
889
886
|
throw new Error("Unable to retrieve launch parameters from any known source.");
|
|
890
887
|
}
|
|
891
|
-
function
|
|
892
|
-
const e =
|
|
888
|
+
function $t() {
|
|
889
|
+
const e = Nt();
|
|
893
890
|
return !!(e && e.type === "reload");
|
|
894
891
|
}
|
|
895
|
-
function
|
|
892
|
+
function Le() {
|
|
896
893
|
let e = 0;
|
|
897
894
|
return () => (e += 1).toString();
|
|
898
895
|
}
|
|
899
|
-
|
|
896
|
+
function Ue() {
|
|
897
|
+
let e = !1;
|
|
898
|
+
const t = [];
|
|
899
|
+
return [
|
|
900
|
+
(s) => !e && t.push(s),
|
|
901
|
+
() => {
|
|
902
|
+
e || (e = !0, t.forEach((s) => s()));
|
|
903
|
+
},
|
|
904
|
+
e
|
|
905
|
+
];
|
|
906
|
+
}
|
|
907
|
+
const [He] = ft(Le);
|
|
900
908
|
function d(e, t) {
|
|
901
|
-
return (
|
|
902
|
-
const
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
...s || {}
|
|
907
|
-
} : Ue(), r = {
|
|
908
|
-
...n,
|
|
909
|
-
postEvent: E() ? () => null : Te(n.version),
|
|
910
|
-
createRequestId: We()
|
|
909
|
+
return () => {
|
|
910
|
+
const s = $e(), n = {
|
|
911
|
+
...s,
|
|
912
|
+
postEvent: Re(s.version),
|
|
913
|
+
createRequestId: He()
|
|
911
914
|
};
|
|
912
|
-
if (
|
|
913
|
-
return
|
|
914
|
-
const i = t({
|
|
915
|
-
...
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
915
|
+
if (typeof e == "function")
|
|
916
|
+
return e(n);
|
|
917
|
+
const [r, i, o] = Ue(), a = t({
|
|
918
|
+
...n,
|
|
919
|
+
// State should only be passed only in case, current page was reloaded. If we don't add
|
|
920
|
+
// this check, state restoration will work improperly in the web version of Telegram,
|
|
921
|
+
// when we are always working in the same "session" (tab).
|
|
922
|
+
state: $t() ? Bt(e) : void 0,
|
|
923
|
+
addCleanup: r
|
|
924
|
+
}), p = (u) => (o || r(
|
|
925
|
+
u.on("change", (l) => {
|
|
926
|
+
Mt(e, l);
|
|
927
|
+
})
|
|
928
|
+
), u);
|
|
929
|
+
return [
|
|
930
|
+
a instanceof Promise ? a.then(p) : p(a),
|
|
931
|
+
i
|
|
932
|
+
];
|
|
921
933
|
};
|
|
922
934
|
}
|
|
923
|
-
const
|
|
935
|
+
const We = d("backButton", ({
|
|
924
936
|
postEvent: e,
|
|
925
937
|
version: t,
|
|
926
938
|
state: s = { isVisible: !1 }
|
|
927
|
-
}) => new
|
|
928
|
-
class D extends
|
|
939
|
+
}) => new Ae(s.isVisible, t, e));
|
|
940
|
+
class D extends st {
|
|
929
941
|
constructor() {
|
|
930
942
|
super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
|
|
931
943
|
}
|
|
932
944
|
}
|
|
933
|
-
function
|
|
945
|
+
function Lt(e) {
|
|
934
946
|
const t = e.available ? e : {
|
|
935
947
|
available: !1,
|
|
936
948
|
device_id: "",
|
|
@@ -948,7 +960,7 @@ function Ht(e) {
|
|
|
948
960
|
accessGranted: t.access_granted
|
|
949
961
|
};
|
|
950
962
|
}
|
|
951
|
-
class
|
|
963
|
+
class je extends D {
|
|
952
964
|
constructor({ postEvent: t, version: s, ...n }) {
|
|
953
965
|
super(n, s, {
|
|
954
966
|
auth: "web_app_biometry_request_auth",
|
|
@@ -985,7 +997,7 @@ class lt extends D {
|
|
|
985
997
|
reason: t,
|
|
986
998
|
...s
|
|
987
999
|
}) {
|
|
988
|
-
return this.authPromise || (this.authPromise =
|
|
1000
|
+
return this.authPromise || (this.authPromise = m({
|
|
989
1001
|
...s,
|
|
990
1002
|
method: "web_app_biometry_request_auth",
|
|
991
1003
|
event: "biometry_auth_requested",
|
|
@@ -1019,14 +1031,14 @@ class lt extends D {
|
|
|
1019
1031
|
* @returns Promise with true, if access was granted.
|
|
1020
1032
|
*/
|
|
1021
1033
|
requestAccess({ reason: t, ...s } = {}) {
|
|
1022
|
-
return this.accessPromise || (this.accessPromise =
|
|
1034
|
+
return this.accessPromise || (this.accessPromise = m({
|
|
1023
1035
|
...s,
|
|
1024
1036
|
postEvent: this.postEvent,
|
|
1025
1037
|
method: "web_app_biometry_request_access",
|
|
1026
1038
|
event: "biometry_info_received",
|
|
1027
1039
|
params: { reason: t || "" }
|
|
1028
1040
|
}).then((n) => {
|
|
1029
|
-
const r =
|
|
1041
|
+
const r = Lt(n);
|
|
1030
1042
|
return this.set(r), r.accessGranted;
|
|
1031
1043
|
}).finally(() => this.accessPromise = void 0)), this.accessPromise;
|
|
1032
1044
|
}
|
|
@@ -1048,7 +1060,7 @@ class lt extends D {
|
|
|
1048
1060
|
*/
|
|
1049
1061
|
async updateToken({ token: t, ...s } = {}) {
|
|
1050
1062
|
return ["removed", "updated"].includes(
|
|
1051
|
-
(await
|
|
1063
|
+
(await m({
|
|
1052
1064
|
...s,
|
|
1053
1065
|
postEvent: this.postEvent,
|
|
1054
1066
|
method: "web_app_biometry_update_token",
|
|
@@ -1059,34 +1071,28 @@ class lt extends D {
|
|
|
1059
1071
|
}
|
|
1060
1072
|
}
|
|
1061
1073
|
async function Ge(e) {
|
|
1062
|
-
return
|
|
1063
|
-
await
|
|
1074
|
+
return Lt(
|
|
1075
|
+
await m({
|
|
1064
1076
|
...e || {},
|
|
1065
1077
|
method: "web_app_biometry_get_info",
|
|
1066
1078
|
event: "biometry_info_received"
|
|
1067
1079
|
})
|
|
1068
1080
|
);
|
|
1069
1081
|
}
|
|
1070
|
-
const
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
throw m(
|
|
1075
|
-
vt,
|
|
1076
|
-
"BiometryManager cannot be instantiated on the server side without passing the ssr.state object."
|
|
1077
|
-
);
|
|
1078
|
-
return new lt({
|
|
1079
|
-
...await Ge({ timeout: 1e3 }),
|
|
1082
|
+
const Ke = d(
|
|
1083
|
+
"biometryManager",
|
|
1084
|
+
async ({ postEvent: e, version: t, state: s }) => new je({
|
|
1085
|
+
...s || await Ge({ timeout: 1e3 }),
|
|
1080
1086
|
version: t,
|
|
1081
1087
|
postEvent: e
|
|
1082
|
-
})
|
|
1083
|
-
|
|
1084
|
-
class
|
|
1088
|
+
})
|
|
1089
|
+
);
|
|
1090
|
+
class rt extends et {
|
|
1085
1091
|
constructor() {
|
|
1086
1092
|
super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
|
|
1087
1093
|
}
|
|
1088
1094
|
}
|
|
1089
|
-
class
|
|
1095
|
+
class ze extends rt {
|
|
1090
1096
|
constructor(t, s) {
|
|
1091
1097
|
super({ isConfirmationNeeded: t }), this.postEvent = s;
|
|
1092
1098
|
}
|
|
@@ -1113,13 +1119,16 @@ class Ke extends it {
|
|
|
1113
1119
|
this.isConfirmationNeeded = !0;
|
|
1114
1120
|
}
|
|
1115
1121
|
}
|
|
1116
|
-
const Je = d(
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1122
|
+
const Je = d(
|
|
1123
|
+
"closingBehavior",
|
|
1124
|
+
({
|
|
1125
|
+
postEvent: e,
|
|
1126
|
+
state: t = { isConfirmationNeeded: !1 }
|
|
1127
|
+
}) => new ze(t.isConfirmationNeeded, e)
|
|
1128
|
+
);
|
|
1129
|
+
class it {
|
|
1121
1130
|
constructor(t, s) {
|
|
1122
|
-
c(this, "supports"), this.supports =
|
|
1131
|
+
c(this, "supports"), this.supports = At(t, s);
|
|
1123
1132
|
}
|
|
1124
1133
|
}
|
|
1125
1134
|
function Qe(e) {
|
|
@@ -1134,7 +1143,7 @@ function Qe(e) {
|
|
|
1134
1143
|
}
|
|
1135
1144
|
throw S();
|
|
1136
1145
|
}
|
|
1137
|
-
class Fe extends
|
|
1146
|
+
class Fe extends L {
|
|
1138
1147
|
constructor(t, s, n) {
|
|
1139
1148
|
super(Qe, s, n), c(this, "itemParser"), this.itemParser = typeof t == "function" ? t : t.parse.bind(t);
|
|
1140
1149
|
}
|
|
@@ -1155,10 +1164,10 @@ class Fe extends H {
|
|
|
1155
1164
|
function Ye(e) {
|
|
1156
1165
|
return new Fe((t) => t, !1, e);
|
|
1157
1166
|
}
|
|
1158
|
-
function
|
|
1167
|
+
function dt(e, t) {
|
|
1159
1168
|
return Object.fromEntries(e.map((s) => [s, t]));
|
|
1160
1169
|
}
|
|
1161
|
-
class Ze extends
|
|
1170
|
+
class Ze extends it {
|
|
1162
1171
|
constructor(t, s, n) {
|
|
1163
1172
|
super(t, {
|
|
1164
1173
|
delete: "web_app_invoke_custom_method",
|
|
@@ -1174,7 +1183,7 @@ class Ze extends ot {
|
|
|
1174
1183
|
*/
|
|
1175
1184
|
async delete(t, s = {}) {
|
|
1176
1185
|
const n = Array.isArray(t) ? t : [t];
|
|
1177
|
-
n.length && await
|
|
1186
|
+
n.length && await A(
|
|
1178
1187
|
"deleteStorageValues",
|
|
1179
1188
|
{ keys: n },
|
|
1180
1189
|
this.createRequestId(),
|
|
@@ -1186,8 +1195,8 @@ class Ze extends ot {
|
|
|
1186
1195
|
* @param options - request execution options.
|
|
1187
1196
|
*/
|
|
1188
1197
|
async getKeys(t = {}) {
|
|
1189
|
-
return Ye().of(
|
|
1190
|
-
await
|
|
1198
|
+
return Ye().of(h()).parse(
|
|
1199
|
+
await A(
|
|
1191
1200
|
"getStorageKeys",
|
|
1192
1201
|
{},
|
|
1193
1202
|
this.createRequestId(),
|
|
@@ -1198,13 +1207,13 @@ class Ze extends ot {
|
|
|
1198
1207
|
async get(t, s = {}) {
|
|
1199
1208
|
const n = Array.isArray(t) ? t : [t];
|
|
1200
1209
|
if (!n.length)
|
|
1201
|
-
return
|
|
1202
|
-
const r = await
|
|
1210
|
+
return dt(n, "");
|
|
1211
|
+
const r = await A(
|
|
1203
1212
|
"getStorageValues",
|
|
1204
1213
|
{ keys: n },
|
|
1205
1214
|
this.createRequestId(),
|
|
1206
1215
|
{ ...s, postEvent: this.postEvent }
|
|
1207
|
-
), i =
|
|
1216
|
+
), i = f(dt(n, h()), "CloudStorageData").parse(r);
|
|
1208
1217
|
return Array.isArray(t) ? i : i[t];
|
|
1209
1218
|
}
|
|
1210
1219
|
/**
|
|
@@ -1214,7 +1223,7 @@ class Ze extends ot {
|
|
|
1214
1223
|
* @param options - request execution options.
|
|
1215
1224
|
*/
|
|
1216
1225
|
async set(t, s, n = {}) {
|
|
1217
|
-
await
|
|
1226
|
+
await A(
|
|
1218
1227
|
"saveStorageValue",
|
|
1219
1228
|
{ key: t, value: s },
|
|
1220
1229
|
this.createRequestId(),
|
|
@@ -1225,7 +1234,7 @@ class Ze extends ot {
|
|
|
1225
1234
|
const Xe = d(
|
|
1226
1235
|
({ createRequestId: e, postEvent: t, version: s }) => new Ze(s, e, t)
|
|
1227
1236
|
);
|
|
1228
|
-
class ts extends
|
|
1237
|
+
class ts extends it {
|
|
1229
1238
|
constructor(t, s) {
|
|
1230
1239
|
super(t, {
|
|
1231
1240
|
impactOccurred: "web_app_trigger_haptic_feedback",
|
|
@@ -1347,7 +1356,7 @@ const ns = d(
|
|
|
1347
1356
|
({ initData: e }) => e ? new ss(e) : void 0
|
|
1348
1357
|
);
|
|
1349
1358
|
function Zs(e) {
|
|
1350
|
-
return
|
|
1359
|
+
return kt().parse(e);
|
|
1351
1360
|
}
|
|
1352
1361
|
class rs extends D {
|
|
1353
1362
|
constructor(t, s, n) {
|
|
@@ -1379,7 +1388,7 @@ class rs extends D {
|
|
|
1379
1388
|
}
|
|
1380
1389
|
this.isOpened = !0;
|
|
1381
1390
|
try {
|
|
1382
|
-
return (await
|
|
1391
|
+
return (await m({
|
|
1383
1392
|
method: "web_app_open_invoice",
|
|
1384
1393
|
event: "invoice_closed",
|
|
1385
1394
|
params: { slug: n },
|
|
@@ -1396,9 +1405,9 @@ class rs extends D {
|
|
|
1396
1405
|
const is = d(
|
|
1397
1406
|
({ version: e, postEvent: t }) => new rs(!1, e, t)
|
|
1398
1407
|
);
|
|
1399
|
-
class os extends
|
|
1408
|
+
class os extends et {
|
|
1400
1409
|
constructor({ postEvent: t, ...s }) {
|
|
1401
|
-
super(s), c(this, "postEvent"), c(this, "on", (n, r) => n === "click" ?
|
|
1410
|
+
super(s), c(this, "postEvent"), c(this, "on", (n, r) => n === "click" ? v("main_button_pressed", r) : this.state.on(n, r)), c(this, "off", (n, r) => n === "click" ? H("main_button_pressed", r) : this.state.off(n, r)), this.postEvent = t;
|
|
1402
1411
|
}
|
|
1403
1412
|
/**
|
|
1404
1413
|
* Sends current local state to the Telegram application.
|
|
@@ -1527,46 +1536,49 @@ class os extends st {
|
|
|
1527
1536
|
return this.set(t), this.commit(), this;
|
|
1528
1537
|
}
|
|
1529
1538
|
}
|
|
1530
|
-
const as = d(
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1539
|
+
const as = d(
|
|
1540
|
+
"mainButton",
|
|
1541
|
+
({
|
|
1542
|
+
postEvent: e,
|
|
1543
|
+
themeParams: t,
|
|
1544
|
+
state: s = {
|
|
1545
|
+
isVisible: !1,
|
|
1546
|
+
isEnabled: !1,
|
|
1547
|
+
text: "",
|
|
1548
|
+
isLoaderVisible: !1,
|
|
1549
|
+
textColor: t.buttonTextColor || "#ffffff",
|
|
1550
|
+
backgroundColor: t.buttonColor || "#000000"
|
|
1551
|
+
}
|
|
1552
|
+
}) => new os({ ...s, postEvent: e })
|
|
1553
|
+
);
|
|
1542
1554
|
function cs() {
|
|
1543
|
-
return
|
|
1544
|
-
contact:
|
|
1555
|
+
return nt({
|
|
1556
|
+
contact: f({
|
|
1545
1557
|
userId: {
|
|
1546
1558
|
type: P(),
|
|
1547
1559
|
from: "user_id"
|
|
1548
1560
|
},
|
|
1549
1561
|
phoneNumber: {
|
|
1550
|
-
type:
|
|
1562
|
+
type: h(),
|
|
1551
1563
|
from: "phone_number"
|
|
1552
1564
|
},
|
|
1553
1565
|
firstName: {
|
|
1554
|
-
type:
|
|
1566
|
+
type: h(),
|
|
1555
1567
|
from: "first_name"
|
|
1556
1568
|
},
|
|
1557
1569
|
lastName: {
|
|
1558
|
-
type:
|
|
1570
|
+
type: h().optional(),
|
|
1559
1571
|
from: "last_name"
|
|
1560
1572
|
}
|
|
1561
1573
|
}),
|
|
1562
1574
|
authDate: {
|
|
1563
|
-
type:
|
|
1575
|
+
type: It(),
|
|
1564
1576
|
from: "auth_date"
|
|
1565
1577
|
},
|
|
1566
|
-
hash:
|
|
1578
|
+
hash: h()
|
|
1567
1579
|
}, "RequestedContact");
|
|
1568
1580
|
}
|
|
1569
|
-
function
|
|
1581
|
+
function Ut(e, t) {
|
|
1570
1582
|
return (s) => {
|
|
1571
1583
|
const [n, r] = t[s];
|
|
1572
1584
|
return C(n, r, e);
|
|
@@ -1587,7 +1599,7 @@ class ps extends D {
|
|
|
1587
1599
|
setBackgroundColor: "web_app_set_background_color"
|
|
1588
1600
|
}), c(this, "botInline"), c(this, "postEvent"), c(this, "createRequestId"), c(this, "requestPhoneAccessPromise"), c(this, "requestWriteAccessPromise"), c(this, "supportsParam"), this.createRequestId = s, this.postEvent = t, this.botInline = r;
|
|
1589
1601
|
const o = this.supports.bind(this);
|
|
1590
|
-
this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam =
|
|
1602
|
+
this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam = Ut(n, {
|
|
1591
1603
|
"setHeaderColor.color": ["web_app_set_header_color", "color"]
|
|
1592
1604
|
});
|
|
1593
1605
|
}
|
|
@@ -1599,7 +1611,7 @@ class ps extends D {
|
|
|
1599
1611
|
timeout: t = 1e4
|
|
1600
1612
|
} = {}) {
|
|
1601
1613
|
return cs().parse(
|
|
1602
|
-
await
|
|
1614
|
+
await A(
|
|
1603
1615
|
"getRequestedContact",
|
|
1604
1616
|
{},
|
|
1605
1617
|
this.createRequestId(),
|
|
@@ -1638,7 +1650,7 @@ class ps extends D {
|
|
|
1638
1650
|
* True if current Mini App background color is recognized as dark.
|
|
1639
1651
|
*/
|
|
1640
1652
|
get isDark() {
|
|
1641
|
-
return
|
|
1653
|
+
return Tt(this.bgColor);
|
|
1642
1654
|
}
|
|
1643
1655
|
/**
|
|
1644
1656
|
* Informs the Telegram app that the Mini App is ready to be displayed.
|
|
@@ -1667,7 +1679,7 @@ class ps extends D {
|
|
|
1667
1679
|
throw new Error("Access denied.");
|
|
1668
1680
|
const s = Date.now() + t;
|
|
1669
1681
|
let n = 50;
|
|
1670
|
-
return
|
|
1682
|
+
return Rt(async () => {
|
|
1671
1683
|
for (; Date.now() < s; ) {
|
|
1672
1684
|
try {
|
|
1673
1685
|
return await this.getRequestedContact();
|
|
@@ -1675,7 +1687,7 @@ class ps extends D {
|
|
|
1675
1687
|
}
|
|
1676
1688
|
await hs(n), n += 50;
|
|
1677
1689
|
}
|
|
1678
|
-
throw
|
|
1690
|
+
throw St(t);
|
|
1679
1691
|
}, t);
|
|
1680
1692
|
}
|
|
1681
1693
|
/**
|
|
@@ -1688,7 +1700,7 @@ class ps extends D {
|
|
|
1688
1700
|
* @see requestContact
|
|
1689
1701
|
*/
|
|
1690
1702
|
async requestPhoneAccess(t = {}) {
|
|
1691
|
-
return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise =
|
|
1703
|
+
return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise = m({
|
|
1692
1704
|
...t,
|
|
1693
1705
|
method: "web_app_request_phone",
|
|
1694
1706
|
event: "phone_requested",
|
|
@@ -1700,7 +1712,7 @@ class ps extends D {
|
|
|
1700
1712
|
* @param options - additional options.
|
|
1701
1713
|
*/
|
|
1702
1714
|
async requestWriteAccess(t = {}) {
|
|
1703
|
-
return this.requestWriteAccessPromise || (this.requestWriteAccessPromise =
|
|
1715
|
+
return this.requestWriteAccessPromise || (this.requestWriteAccessPromise = m({
|
|
1704
1716
|
...t,
|
|
1705
1717
|
method: "web_app_request_write_access",
|
|
1706
1718
|
event: "write_access_requested",
|
|
@@ -1730,7 +1742,7 @@ class ps extends D {
|
|
|
1730
1742
|
* @param color - color key or RGB color.
|
|
1731
1743
|
*/
|
|
1732
1744
|
setHeaderColor(t) {
|
|
1733
|
-
this.postEvent("web_app_set_header_color",
|
|
1745
|
+
this.postEvent("web_app_set_header_color", tt(t) ? { color: t } : { color_key: t }), this.set("headerColor", t);
|
|
1734
1746
|
}
|
|
1735
1747
|
/**
|
|
1736
1748
|
* Updates current Mini App background color.
|
|
@@ -1758,16 +1770,19 @@ class ps extends D {
|
|
|
1758
1770
|
this.postEvent("web_app_switch_inline_query", { query: t, chat_types: s });
|
|
1759
1771
|
}
|
|
1760
1772
|
}
|
|
1761
|
-
const us = d(
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
}
|
|
1770
|
-
|
|
1773
|
+
const us = d(
|
|
1774
|
+
"miniApp",
|
|
1775
|
+
({
|
|
1776
|
+
themeParams: e,
|
|
1777
|
+
botInline: t = !1,
|
|
1778
|
+
state: s = {
|
|
1779
|
+
bgColor: e.bgColor || "#ffffff",
|
|
1780
|
+
headerColor: e.headerBgColor || "#000000"
|
|
1781
|
+
},
|
|
1782
|
+
...n
|
|
1783
|
+
}) => new ps({ ...n, ...s, botInline: t })
|
|
1784
|
+
);
|
|
1785
|
+
function ls(e) {
|
|
1771
1786
|
const t = e.message.trim(), s = (e.title || "").trim(), n = e.buttons || [];
|
|
1772
1787
|
let r;
|
|
1773
1788
|
if (s.length > 64)
|
|
@@ -1783,15 +1798,15 @@ function ds(e) {
|
|
|
1783
1798
|
if (!i.type || i.type === "default" || i.type === "destructive") {
|
|
1784
1799
|
const a = i.text.trim();
|
|
1785
1800
|
if (!a.length || a.length > 64) {
|
|
1786
|
-
const
|
|
1787
|
-
throw new Error(`Button text with type "${
|
|
1801
|
+
const p = i.type || "default";
|
|
1802
|
+
throw new Error(`Button text with type "${p}" has incorrect size: ${i.text.length}`);
|
|
1788
1803
|
}
|
|
1789
1804
|
return { ...i, text: a, id: o };
|
|
1790
1805
|
}
|
|
1791
1806
|
return { ...i, id: o };
|
|
1792
1807
|
}) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
|
|
1793
1808
|
}
|
|
1794
|
-
class
|
|
1809
|
+
class ds extends D {
|
|
1795
1810
|
constructor(t, s, n) {
|
|
1796
1811
|
super({ isOpened: t }, s, { open: "web_app_open_popup" }), this.postEvent = n;
|
|
1797
1812
|
}
|
|
@@ -1820,11 +1835,11 @@ class ls extends D {
|
|
|
1820
1835
|
throw new Error("Popup is already opened.");
|
|
1821
1836
|
this.isOpened = !0;
|
|
1822
1837
|
try {
|
|
1823
|
-
const { button_id: s = null } = await
|
|
1838
|
+
const { button_id: s = null } = await m({
|
|
1824
1839
|
event: "popup_closed",
|
|
1825
1840
|
method: "web_app_open_popup",
|
|
1826
1841
|
postEvent: this.postEvent,
|
|
1827
|
-
params:
|
|
1842
|
+
params: ls(t)
|
|
1828
1843
|
});
|
|
1829
1844
|
return s;
|
|
1830
1845
|
} finally {
|
|
@@ -1833,7 +1848,7 @@ class ls extends D {
|
|
|
1833
1848
|
}
|
|
1834
1849
|
}
|
|
1835
1850
|
const _s = d(
|
|
1836
|
-
({ postEvent: e, version: t }) => new
|
|
1851
|
+
({ postEvent: e, version: t }) => new ds(!1, t, e)
|
|
1837
1852
|
);
|
|
1838
1853
|
class gs extends D {
|
|
1839
1854
|
constructor(t, s, n) {
|
|
@@ -1868,7 +1883,7 @@ class gs extends D {
|
|
|
1868
1883
|
throw new Error("QR scanner is already opened.");
|
|
1869
1884
|
this.isOpened = !0;
|
|
1870
1885
|
try {
|
|
1871
|
-
return (await
|
|
1886
|
+
return (await m({
|
|
1872
1887
|
method: "web_app_open_scan_qr_popup",
|
|
1873
1888
|
event: ["qr_text_received", "scan_qr_popup_closed"],
|
|
1874
1889
|
postEvent: this.postEvent,
|
|
@@ -1882,12 +1897,12 @@ class gs extends D {
|
|
|
1882
1897
|
const fs = d(
|
|
1883
1898
|
({ version: e, postEvent: t }) => new gs(!1, e, t)
|
|
1884
1899
|
);
|
|
1885
|
-
class ms extends
|
|
1900
|
+
class ms extends st {
|
|
1886
1901
|
constructor(t, s, n) {
|
|
1887
1902
|
super({ isVisible: t }, s, {
|
|
1888
1903
|
show: "web_app_setup_settings_button",
|
|
1889
1904
|
hide: "web_app_setup_settings_button"
|
|
1890
|
-
}), c(this, "on", (r, i) => r === "click" ?
|
|
1905
|
+
}), c(this, "on", (r, i) => r === "click" ? v("settings_button_pressed", i) : this.state.on(r, i)), c(this, "off", (r, i) => r === "click" ? H("settings_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
|
|
1891
1906
|
}
|
|
1892
1907
|
set isVisible(t) {
|
|
1893
1908
|
this.set("isVisible", t), this.postEvent("web_app_setup_settings_button", { is_visible: t });
|
|
@@ -1911,15 +1926,18 @@ class ms extends nt {
|
|
|
1911
1926
|
this.isVisible = !0;
|
|
1912
1927
|
}
|
|
1913
1928
|
}
|
|
1914
|
-
const ws = d(
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1929
|
+
const ws = d(
|
|
1930
|
+
"settingsButton",
|
|
1931
|
+
({
|
|
1932
|
+
version: e,
|
|
1933
|
+
postEvent: t,
|
|
1934
|
+
state: s = { isVisible: !1 }
|
|
1935
|
+
}) => new ms(s.isVisible, e, t)
|
|
1936
|
+
);
|
|
1937
|
+
function Ht(e) {
|
|
1938
|
+
return Ot().parse(e);
|
|
1921
1939
|
}
|
|
1922
|
-
class bs extends
|
|
1940
|
+
class bs extends rt {
|
|
1923
1941
|
/**
|
|
1924
1942
|
* @since v6.10
|
|
1925
1943
|
*/
|
|
@@ -1958,7 +1976,7 @@ class bs extends it {
|
|
|
1958
1976
|
* value is calculated according to theme bg color.
|
|
1959
1977
|
*/
|
|
1960
1978
|
get isDark() {
|
|
1961
|
-
return !this.bgColor ||
|
|
1979
|
+
return !this.bgColor || Tt(this.bgColor);
|
|
1962
1980
|
}
|
|
1963
1981
|
get linkColor() {
|
|
1964
1982
|
return this.get("linkColor");
|
|
@@ -1983,8 +2001,8 @@ class bs extends it {
|
|
|
1983
2001
|
* @returns Function to stop listening.
|
|
1984
2002
|
*/
|
|
1985
2003
|
listen() {
|
|
1986
|
-
return
|
|
1987
|
-
this.set(
|
|
2004
|
+
return v("theme_changed", (t) => {
|
|
2005
|
+
this.set(Ht(t.theme_params));
|
|
1988
2006
|
});
|
|
1989
2007
|
}
|
|
1990
2008
|
/**
|
|
@@ -1997,20 +2015,23 @@ class bs extends it {
|
|
|
1997
2015
|
return this.get("textColor");
|
|
1998
2016
|
}
|
|
1999
2017
|
}
|
|
2000
|
-
const vs = d(
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2018
|
+
const vs = d(
|
|
2019
|
+
"themeParams",
|
|
2020
|
+
({ themeParams: e, state: t = e, addCleanup: s }) => {
|
|
2021
|
+
const n = new bs(t);
|
|
2022
|
+
return s(n.listen()), n;
|
|
2023
|
+
}
|
|
2024
|
+
);
|
|
2004
2025
|
function Xs(e = {}) {
|
|
2005
|
-
return
|
|
2026
|
+
return m({
|
|
2006
2027
|
...e,
|
|
2007
2028
|
method: "web_app_request_theme",
|
|
2008
2029
|
event: "theme_changed"
|
|
2009
|
-
}).then(
|
|
2030
|
+
}).then(Ht);
|
|
2010
2031
|
}
|
|
2011
|
-
class ys extends
|
|
2032
|
+
class ys extends it {
|
|
2012
2033
|
constructor(t, s, n) {
|
|
2013
|
-
super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam =
|
|
2034
|
+
super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam = Ut(t, {
|
|
2014
2035
|
"openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
|
|
2015
2036
|
});
|
|
2016
2037
|
}
|
|
@@ -2059,12 +2080,12 @@ class ys extends ot {
|
|
|
2059
2080
|
async readTextFromClipboard() {
|
|
2060
2081
|
const t = this.createRequestId(), {
|
|
2061
2082
|
data: s = null
|
|
2062
|
-
} = await
|
|
2083
|
+
} = await m({
|
|
2063
2084
|
method: "web_app_read_text_from_clipboard",
|
|
2064
2085
|
event: "clipboard_text_received",
|
|
2065
2086
|
postEvent: this.postEvent,
|
|
2066
2087
|
params: { req_id: t },
|
|
2067
|
-
capture:
|
|
2088
|
+
capture: Ct(t)
|
|
2068
2089
|
});
|
|
2069
2090
|
return s;
|
|
2070
2091
|
}
|
|
@@ -2072,28 +2093,28 @@ class ys extends ot {
|
|
|
2072
2093
|
const Es = d(
|
|
2073
2094
|
({ version: e, postEvent: t, createRequestId: s }) => new ys(e, s, t)
|
|
2074
2095
|
);
|
|
2075
|
-
async function
|
|
2096
|
+
async function Wt(e = {}) {
|
|
2076
2097
|
const {
|
|
2077
2098
|
is_expanded: t,
|
|
2078
2099
|
is_state_stable: s,
|
|
2079
2100
|
...n
|
|
2080
|
-
} = await
|
|
2101
|
+
} = await m({
|
|
2081
2102
|
...e,
|
|
2082
2103
|
method: "web_app_request_viewport",
|
|
2083
2104
|
event: "viewport_changed"
|
|
2084
2105
|
});
|
|
2085
2106
|
return { ...n, isExpanded: t, isStateStable: s };
|
|
2086
2107
|
}
|
|
2087
|
-
function
|
|
2108
|
+
function T(e) {
|
|
2088
2109
|
return e < 0 ? 0 : e;
|
|
2089
2110
|
}
|
|
2090
|
-
class
|
|
2111
|
+
class Ps extends rt {
|
|
2091
2112
|
constructor({ postEvent: t, stableHeight: s, height: n, width: r, isExpanded: i }) {
|
|
2092
2113
|
super({
|
|
2093
|
-
height:
|
|
2114
|
+
height: T(n),
|
|
2094
2115
|
isExpanded: i,
|
|
2095
|
-
stableHeight:
|
|
2096
|
-
width:
|
|
2116
|
+
stableHeight: T(s),
|
|
2117
|
+
width: T(r)
|
|
2097
2118
|
}), c(this, "postEvent"), this.postEvent = t;
|
|
2098
2119
|
}
|
|
2099
2120
|
/**
|
|
@@ -2102,7 +2123,7 @@ class zt extends it {
|
|
|
2102
2123
|
* @param options - options to request fresh data.
|
|
2103
2124
|
*/
|
|
2104
2125
|
async sync(t) {
|
|
2105
|
-
const { isStateStable: s, ...n } = await
|
|
2126
|
+
const { isStateStable: s, ...n } = await Wt(t);
|
|
2106
2127
|
this.set({
|
|
2107
2128
|
...n,
|
|
2108
2129
|
stableHeight: s ? n.height : this.get("stableHeight")
|
|
@@ -2149,17 +2170,17 @@ class zt extends it {
|
|
|
2149
2170
|
* @returns Function to stop listening.
|
|
2150
2171
|
*/
|
|
2151
2172
|
listen() {
|
|
2152
|
-
return
|
|
2173
|
+
return v("viewport_changed", (t) => {
|
|
2153
2174
|
const {
|
|
2154
2175
|
height: s,
|
|
2155
2176
|
width: n,
|
|
2156
2177
|
is_expanded: r,
|
|
2157
2178
|
is_state_stable: i
|
|
2158
|
-
} = t, o =
|
|
2179
|
+
} = t, o = T(s);
|
|
2159
2180
|
this.set({
|
|
2160
2181
|
height: o,
|
|
2161
2182
|
isExpanded: r,
|
|
2162
|
-
width:
|
|
2183
|
+
width: T(n),
|
|
2163
2184
|
...i ? { stableHeight: o } : {}
|
|
2164
2185
|
});
|
|
2165
2186
|
});
|
|
@@ -2194,61 +2215,42 @@ class zt extends it {
|
|
|
2194
2215
|
return this.stableHeight === this.height;
|
|
2195
2216
|
}
|
|
2196
2217
|
}
|
|
2197
|
-
|
|
2198
|
-
const {
|
|
2199
|
-
height: s,
|
|
2200
|
-
width: n,
|
|
2201
|
-
isExpanded: r,
|
|
2202
|
-
isStateStable: i
|
|
2203
|
-
} = await Gt({ ...t, postEvent: e });
|
|
2204
|
-
return new zt({
|
|
2205
|
-
postEvent: e,
|
|
2206
|
-
height: s,
|
|
2207
|
-
width: n,
|
|
2208
|
-
isExpanded: r,
|
|
2209
|
-
stableHeight: i ? s : 0
|
|
2210
|
-
});
|
|
2211
|
-
}
|
|
2212
|
-
function xs({
|
|
2213
|
-
state: e,
|
|
2214
|
-
platform: t,
|
|
2215
|
-
postEvent: s
|
|
2216
|
-
}) {
|
|
2217
|
-
let n = !1, r = 0, i = 0, o = 0;
|
|
2218
|
-
return e ? (n = e.isExpanded, r = e.height, i = e.width, o = e.stableHeight) : ["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t) && (n = !0, r = window.innerHeight, i = window.innerWidth, o = window.innerHeight), new zt({
|
|
2219
|
-
postEvent: s,
|
|
2220
|
-
height: r,
|
|
2221
|
-
width: i,
|
|
2222
|
-
stableHeight: o,
|
|
2223
|
-
isExpanded: n
|
|
2224
|
-
});
|
|
2225
|
-
}
|
|
2226
|
-
const Cs = d(
|
|
2218
|
+
const xs = d(
|
|
2227
2219
|
"viewport",
|
|
2228
|
-
async (e) => {
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2220
|
+
async ({ state: e, platform: t, postEvent: s, addCleanup: n }) => {
|
|
2221
|
+
let r = !1, i = 0, o = 0, a = 0;
|
|
2222
|
+
if (e)
|
|
2223
|
+
r = e.isExpanded, i = e.height, o = e.width, a = e.stableHeight;
|
|
2224
|
+
else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
|
|
2225
|
+
r = !0, i = window.innerHeight, o = window.innerWidth, a = window.innerHeight;
|
|
2226
|
+
else {
|
|
2227
|
+
const u = await Wt({ timeout: 1e3, postEvent: s });
|
|
2228
|
+
r = u.isExpanded, i = u.height, o = u.width, a = u.isStateStable ? i : 0;
|
|
2229
|
+
}
|
|
2230
|
+
const p = new Ps({
|
|
2231
|
+
postEvent: s,
|
|
2232
|
+
height: i,
|
|
2233
|
+
width: o,
|
|
2234
|
+
stableHeight: a,
|
|
2235
|
+
isExpanded: r
|
|
2236
|
+
});
|
|
2237
|
+
return n(p.listen()), p;
|
|
2236
2238
|
}
|
|
2237
2239
|
);
|
|
2238
|
-
function
|
|
2240
|
+
function E(e, t) {
|
|
2239
2241
|
document.documentElement.style.setProperty(e, t);
|
|
2240
2242
|
}
|
|
2241
2243
|
function tn(e, t, s) {
|
|
2242
2244
|
s || (s = (a) => `--tg-${a}-color`);
|
|
2243
2245
|
const n = s("header"), r = s("bg"), i = () => {
|
|
2244
2246
|
const { headerColor: a } = e;
|
|
2245
|
-
if (
|
|
2246
|
-
|
|
2247
|
+
if (tt(a))
|
|
2248
|
+
E(n, a);
|
|
2247
2249
|
else {
|
|
2248
|
-
const { bgColor:
|
|
2249
|
-
a === "bg_color" &&
|
|
2250
|
+
const { bgColor: p, secondaryBgColor: u } = t;
|
|
2251
|
+
a === "bg_color" && p ? E(n, p) : a === "secondary_bg_color" && u && E(n, u);
|
|
2250
2252
|
}
|
|
2251
|
-
|
|
2253
|
+
E(r, e.bgColor);
|
|
2252
2254
|
}, o = [
|
|
2253
2255
|
t.on("change", i),
|
|
2254
2256
|
e.on("change", i)
|
|
@@ -2259,7 +2261,7 @@ function en(e, t) {
|
|
|
2259
2261
|
t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
|
|
2260
2262
|
const s = () => {
|
|
2261
2263
|
Object.entries(e.getState()).forEach(([n, r]) => {
|
|
2262
|
-
r &&
|
|
2264
|
+
r && E(t(n), r);
|
|
2263
2265
|
});
|
|
2264
2266
|
};
|
|
2265
2267
|
return s(), e.on("change", s);
|
|
@@ -2270,23 +2272,23 @@ function sn(e, t) {
|
|
|
2270
2272
|
s,
|
|
2271
2273
|
n,
|
|
2272
2274
|
r
|
|
2273
|
-
] = ["height", "width", "stable-height"].map((u) => t(u)), i = () =>
|
|
2275
|
+
] = ["height", "width", "stable-height"].map((u) => t(u)), i = () => E(s, `${e.height}px`), o = () => E(n, `${e.width}px`), a = () => E(r, `${e.stableHeight}px`), p = [
|
|
2274
2276
|
e.on("change:height", i),
|
|
2275
2277
|
e.on("change:width", o),
|
|
2276
2278
|
e.on("change:stableHeight", a)
|
|
2277
2279
|
];
|
|
2278
|
-
return i(), o(), a(), () =>
|
|
2280
|
+
return i(), o(), a(), () => p.forEach((u) => u());
|
|
2279
2281
|
}
|
|
2280
|
-
function
|
|
2282
|
+
function Cs(e = !0) {
|
|
2281
2283
|
const t = [
|
|
2282
|
-
|
|
2284
|
+
v("reload_iframe", () => {
|
|
2283
2285
|
k("iframe_will_reload"), window.location.reload();
|
|
2284
2286
|
})
|
|
2285
2287
|
], s = () => t.forEach((n) => n());
|
|
2286
2288
|
if (e) {
|
|
2287
2289
|
const n = document.createElement("style");
|
|
2288
2290
|
n.id = "telegram-custom-styles", document.head.appendChild(n), t.push(
|
|
2289
|
-
|
|
2291
|
+
v("set_custom_style", (r) => {
|
|
2290
2292
|
n.innerHTML = r;
|
|
2291
2293
|
}),
|
|
2292
2294
|
() => document.head.removeChild(n)
|
|
@@ -2294,22 +2296,25 @@ function Ss(e = !0) {
|
|
|
2294
2296
|
}
|
|
2295
2297
|
return k("iframe_ready", { reload_supported: !0 }), s;
|
|
2296
2298
|
}
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
+
function nn() {
|
|
2300
|
+
return typeof window > "u";
|
|
2301
|
+
}
|
|
2302
|
+
async function rn() {
|
|
2303
|
+
if (Et(window))
|
|
2299
2304
|
return !0;
|
|
2300
2305
|
try {
|
|
2301
|
-
return await
|
|
2306
|
+
return await m({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
|
|
2302
2307
|
} catch {
|
|
2303
2308
|
return !1;
|
|
2304
2309
|
}
|
|
2305
2310
|
}
|
|
2306
|
-
function
|
|
2307
|
-
return e instanceof
|
|
2311
|
+
function Ss(e) {
|
|
2312
|
+
return e instanceof $;
|
|
2308
2313
|
}
|
|
2309
|
-
function
|
|
2310
|
-
return
|
|
2314
|
+
function on(e, t) {
|
|
2315
|
+
return Ss(e) && e.type === t;
|
|
2311
2316
|
}
|
|
2312
|
-
function
|
|
2317
|
+
function j(e, t) {
|
|
2313
2318
|
let s, n, r;
|
|
2314
2319
|
return typeof e == "string" ? s = e : (s = e.pathname === void 0 ? t : e.pathname, n = e.params, r = e.id), Object.freeze({
|
|
2315
2320
|
id: r || (Math.random() * 2 ** 14 | 0).toString(16),
|
|
@@ -2317,23 +2322,23 @@ function z(e, t) {
|
|
|
2317
2322
|
params: n
|
|
2318
2323
|
});
|
|
2319
2324
|
}
|
|
2320
|
-
class
|
|
2325
|
+
class Rs {
|
|
2321
2326
|
constructor(t, s, n = k) {
|
|
2322
|
-
if (c(this, "history"), c(this, "ee", new
|
|
2323
|
-
throw
|
|
2327
|
+
if (c(this, "history"), c(this, "ee", new B()), c(this, "attached", !1), c(this, "back", () => this.go(-1)), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this._index = s, this.postEvent = n, t.length === 0)
|
|
2328
|
+
throw w(ue, "History should not be empty.");
|
|
2324
2329
|
if (s < 0 || s >= t.length)
|
|
2325
|
-
throw
|
|
2326
|
-
|
|
2330
|
+
throw w(
|
|
2331
|
+
le,
|
|
2327
2332
|
"Index should not be zero and higher or equal than history size."
|
|
2328
2333
|
);
|
|
2329
|
-
this.history = t.map((r) =>
|
|
2334
|
+
this.history = t.map((r) => j(r, ""));
|
|
2330
2335
|
}
|
|
2331
2336
|
/**
|
|
2332
2337
|
* Allows this navigator to control the `BackButton` visibility state. It also tracks the
|
|
2333
2338
|
* `BackButton` clicks and calls the `back` method.
|
|
2334
2339
|
*/
|
|
2335
2340
|
attach() {
|
|
2336
|
-
this.attached || (this.attached = !0, this.sync(),
|
|
2341
|
+
this.attached || (this.attached = !0, this.sync(), v("back_button_pressed", this.back));
|
|
2337
2342
|
}
|
|
2338
2343
|
/**
|
|
2339
2344
|
* Currently active history item.
|
|
@@ -2345,7 +2350,7 @@ class As {
|
|
|
2345
2350
|
* Prevents current navigator from controlling the BackButton visibility state.
|
|
2346
2351
|
*/
|
|
2347
2352
|
detach() {
|
|
2348
|
-
this.attached = !1,
|
|
2353
|
+
this.attached = !1, H("back_button_pressed", this.back);
|
|
2349
2354
|
}
|
|
2350
2355
|
/**
|
|
2351
2356
|
* Goes to the next history item.
|
|
@@ -2401,14 +2406,14 @@ class As {
|
|
|
2401
2406
|
* @param item - item to add.
|
|
2402
2407
|
*/
|
|
2403
2408
|
push(t) {
|
|
2404
|
-
this.hasNext && this.history.splice(this.index + 1), this.replaceAndMove(this.index + 1,
|
|
2409
|
+
this.hasNext && this.history.splice(this.index + 1), this.replaceAndMove(this.index + 1, j(t, this.current.pathname));
|
|
2405
2410
|
}
|
|
2406
2411
|
/**
|
|
2407
2412
|
* Replaces the current history item.
|
|
2408
2413
|
* @param item - item to replace the current item with.
|
|
2409
2414
|
*/
|
|
2410
2415
|
replace(t) {
|
|
2411
|
-
this.replaceAndMove(this.index,
|
|
2416
|
+
this.replaceAndMove(this.index, j(t, this.current.pathname));
|
|
2412
2417
|
}
|
|
2413
2418
|
/**
|
|
2414
2419
|
* Sets history item by the specified index.
|
|
@@ -2438,7 +2443,7 @@ class As {
|
|
|
2438
2443
|
this.postEvent("web_app_setup_back_button", { is_visible: !!this.index });
|
|
2439
2444
|
}
|
|
2440
2445
|
}
|
|
2441
|
-
function
|
|
2446
|
+
function G({
|
|
2442
2447
|
params: e,
|
|
2443
2448
|
...t
|
|
2444
2449
|
}) {
|
|
@@ -2447,26 +2452,26 @@ function K({
|
|
|
2447
2452
|
function O(e, t) {
|
|
2448
2453
|
return e.startsWith(t) ? e : `${t}${e}`;
|
|
2449
2454
|
}
|
|
2450
|
-
function
|
|
2455
|
+
function V(e) {
|
|
2451
2456
|
return new URL(
|
|
2452
2457
|
typeof e == "string" ? e : `${e.pathname || ""}${O(e.search || "", "?")}${O(e.hash || "", "#")}`,
|
|
2453
2458
|
"http://a"
|
|
2454
2459
|
);
|
|
2455
2460
|
}
|
|
2456
|
-
function
|
|
2457
|
-
const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s =
|
|
2461
|
+
function M(e) {
|
|
2462
|
+
const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = V(e);
|
|
2458
2463
|
return `${t ? s.pathname : s.pathname.slice(1)}${s.search}${s.hash}`;
|
|
2459
2464
|
}
|
|
2460
|
-
function
|
|
2465
|
+
function K(e, t, s) {
|
|
2461
2466
|
let n, r;
|
|
2462
|
-
typeof e == "string" ? n = e : (n =
|
|
2467
|
+
typeof e == "string" ? n = e : (n = M(e), s = e.state, r = e.id);
|
|
2463
2468
|
const { pathname: i, search: o, hash: a } = new URL(n, `http://a${O(t, "/")}`);
|
|
2464
2469
|
return { id: r, pathname: i, params: { hash: a, search: o, state: s } };
|
|
2465
2470
|
}
|
|
2466
2471
|
async function I(e) {
|
|
2467
2472
|
return e === 0 ? !0 : Promise.race([
|
|
2468
2473
|
new Promise((t) => {
|
|
2469
|
-
const s =
|
|
2474
|
+
const s = F("popstate", () => {
|
|
2470
2475
|
s(), t(!0);
|
|
2471
2476
|
});
|
|
2472
2477
|
window.history.go(e);
|
|
@@ -2484,32 +2489,32 @@ async function Ts() {
|
|
|
2484
2489
|
for (; e; )
|
|
2485
2490
|
e = await I(-1);
|
|
2486
2491
|
}
|
|
2487
|
-
function
|
|
2488
|
-
return
|
|
2492
|
+
function jt(e) {
|
|
2493
|
+
return V(e).pathname;
|
|
2489
2494
|
}
|
|
2490
|
-
const
|
|
2491
|
-
class
|
|
2492
|
-
constructor(t, s, { postEvent: n, hashMode: r, base: i } = {}) {
|
|
2493
|
-
c(this, "navigator"), c(this, "ee", new
|
|
2495
|
+
const _t = 0, z = 1, J = 2;
|
|
2496
|
+
class Gt {
|
|
2497
|
+
constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
|
|
2498
|
+
c(this, "navigator"), c(this, "ee", new B()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: o }) => {
|
|
2494
2499
|
if (o === null)
|
|
2495
2500
|
return this.push(this.parsePath(window.location.href));
|
|
2496
|
-
o ===
|
|
2501
|
+
o === _t ? window.history.forward() : o === z && this.back(), o === J && this.forward();
|
|
2497
2502
|
}), c(this, "onNavigatorChange", async ({
|
|
2498
2503
|
to: o,
|
|
2499
2504
|
from: a,
|
|
2500
|
-
delta:
|
|
2505
|
+
delta: p
|
|
2501
2506
|
}) => {
|
|
2502
2507
|
this.attached && await this.syncHistory(), this.ee.emit("change", {
|
|
2503
|
-
delta:
|
|
2504
|
-
from:
|
|
2505
|
-
to:
|
|
2508
|
+
delta: p,
|
|
2509
|
+
from: G(a),
|
|
2510
|
+
to: G(o),
|
|
2506
2511
|
navigator: this
|
|
2507
2512
|
});
|
|
2508
|
-
}), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.navigator = new
|
|
2509
|
-
t.map((o) =>
|
|
2513
|
+
}), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.navigator = new Rs(
|
|
2514
|
+
t.map((o) => K(o, "/")),
|
|
2510
2515
|
s,
|
|
2511
2516
|
n
|
|
2512
|
-
), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base =
|
|
2517
|
+
), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = jt(i || "");
|
|
2513
2518
|
}
|
|
2514
2519
|
/**
|
|
2515
2520
|
* Attaches current navigator to the browser history allowing navigator to manipulate it.
|
|
@@ -2593,7 +2598,7 @@ class Jt {
|
|
|
2593
2598
|
* Navigation history.
|
|
2594
2599
|
*/
|
|
2595
2600
|
get history() {
|
|
2596
|
-
return this.navigator.history.map(
|
|
2601
|
+
return this.navigator.history.map(G);
|
|
2597
2602
|
}
|
|
2598
2603
|
/**
|
|
2599
2604
|
* Path, including pathname, search and hash.
|
|
@@ -2607,7 +2612,7 @@ class Jt {
|
|
|
2607
2612
|
* "/pathname?search#hash"
|
|
2608
2613
|
*/
|
|
2609
2614
|
get path() {
|
|
2610
|
-
return
|
|
2615
|
+
return M(this);
|
|
2611
2616
|
}
|
|
2612
2617
|
/**
|
|
2613
2618
|
* Current pathname. Always starts with the slash.
|
|
@@ -2636,19 +2641,19 @@ class Jt {
|
|
|
2636
2641
|
* // { pathname: '/tma', search: '?is=cool', hash: '#yeah' }
|
|
2637
2642
|
*/
|
|
2638
2643
|
parsePath(t) {
|
|
2639
|
-
let s =
|
|
2640
|
-
return this.hashMode && (s =
|
|
2644
|
+
let s = V(t);
|
|
2645
|
+
return this.hashMode && (s = V(s.hash.slice(1))), {
|
|
2641
2646
|
pathname: s.pathname,
|
|
2642
2647
|
search: s.search,
|
|
2643
2648
|
hash: s.hash
|
|
2644
2649
|
};
|
|
2645
2650
|
}
|
|
2646
2651
|
push(t, s) {
|
|
2647
|
-
const n =
|
|
2652
|
+
const n = K(t, this.path), { state: r = s } = n.params;
|
|
2648
2653
|
this.navigator.push({ ...n, params: { ...n.params, state: r } });
|
|
2649
2654
|
}
|
|
2650
2655
|
replace(t, s) {
|
|
2651
|
-
const n =
|
|
2656
|
+
const n = K(t, this.path), { state: r = s } = n.params;
|
|
2652
2657
|
this.navigator.replace({ ...n, params: { ...n.params, state: r } });
|
|
2653
2658
|
}
|
|
2654
2659
|
/**
|
|
@@ -2657,8 +2662,8 @@ class Jt {
|
|
|
2657
2662
|
* @param value - path presented as string or URLLike.
|
|
2658
2663
|
*/
|
|
2659
2664
|
renderPath(t) {
|
|
2660
|
-
const s = (this.base.length === 1 ? "" : this.base) + O(
|
|
2661
|
-
return this.hashMode ? O(s.slice(1), this.hashMode === "
|
|
2665
|
+
const s = (this.base.length === 1 ? "" : this.base) + O(M(t), "/");
|
|
2666
|
+
return this.hashMode ? O(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
|
|
2662
2667
|
}
|
|
2663
2668
|
/**
|
|
2664
2669
|
* Synchronizes current navigator state with browser history.
|
|
@@ -2666,7 +2671,7 @@ class Jt {
|
|
|
2666
2671
|
async syncHistory() {
|
|
2667
2672
|
window.removeEventListener("popstate", this.onPopState);
|
|
2668
2673
|
const { state: t } = this, s = this.renderPath(this);
|
|
2669
|
-
await Ts(), this.hasPrev && this.hasNext ? (window.history.replaceState(
|
|
2674
|
+
await Ts(), this.hasPrev && this.hasNext ? (window.history.replaceState(z, ""), window.history.pushState(t, "", s), window.history.pushState(J, ""), await I(-1)) : this.hasPrev ? (window.history.replaceState(z, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(J, ""), await I(-1)) : (window.history.replaceState(_t, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
|
|
2670
2675
|
}
|
|
2671
2676
|
/**
|
|
2672
2677
|
* Current query parameters.
|
|
@@ -2684,109 +2689,121 @@ class Jt {
|
|
|
2684
2689
|
return (this.navigator.current.params || {}).state;
|
|
2685
2690
|
}
|
|
2686
2691
|
}
|
|
2687
|
-
function
|
|
2692
|
+
function As(e) {
|
|
2688
2693
|
e || (e = {});
|
|
2689
2694
|
const { href: t, hash: s } = window.location;
|
|
2690
|
-
let n =
|
|
2691
|
-
e.hashMode ? s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
|
|
2695
|
+
let n = M(
|
|
2696
|
+
e.hashMode === null ? t : s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
|
|
2692
2697
|
);
|
|
2693
|
-
const r = e.base ?
|
|
2698
|
+
const r = e.base ? jt(e.base) : void 0;
|
|
2694
2699
|
if (r) {
|
|
2695
2700
|
if (!n.startsWith(r))
|
|
2696
|
-
throw
|
|
2697
|
-
|
|
2701
|
+
throw w(
|
|
2702
|
+
de,
|
|
2698
2703
|
`Path "${n}" expected to be starting with "${r}"`
|
|
2699
2704
|
);
|
|
2700
2705
|
n = n.slice(r.length);
|
|
2701
2706
|
}
|
|
2702
|
-
return new
|
|
2707
|
+
return new Gt([n], 0, e);
|
|
2703
2708
|
}
|
|
2704
|
-
function
|
|
2709
|
+
function an(e) {
|
|
2705
2710
|
const t = e.match(/#(.+)/);
|
|
2706
2711
|
return t ? t[1] : null;
|
|
2707
2712
|
}
|
|
2708
|
-
function
|
|
2709
|
-
if (
|
|
2713
|
+
function Is(e, t) {
|
|
2714
|
+
if ($t()) {
|
|
2710
2715
|
const s = sessionStorage.getItem(e);
|
|
2711
2716
|
if (s)
|
|
2712
2717
|
try {
|
|
2713
2718
|
const { index: n, history: r } = JSON.parse(s);
|
|
2714
|
-
return new
|
|
2719
|
+
return new Gt(r, n, t);
|
|
2715
2720
|
} catch (n) {
|
|
2716
2721
|
console.error("Unable to restore hash navigator state.", n);
|
|
2717
2722
|
}
|
|
2718
2723
|
}
|
|
2719
|
-
return
|
|
2724
|
+
return As(t);
|
|
2720
2725
|
}
|
|
2721
|
-
function
|
|
2722
|
-
const s =
|
|
2726
|
+
function cn(e, t) {
|
|
2727
|
+
const s = Is(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
|
|
2723
2728
|
index: s.index,
|
|
2724
2729
|
history: s.history
|
|
2725
2730
|
}));
|
|
2726
2731
|
return s.on("change", n), n(), s;
|
|
2727
2732
|
}
|
|
2728
|
-
function
|
|
2729
|
-
return (t, s, ...n) => (r) =>
|
|
2733
|
+
function _(e) {
|
|
2734
|
+
return (t, s, ...n) => (r) => gt(s, at(() => at({
|
|
2730
2735
|
[t]: e(...n)
|
|
2731
2736
|
}, r)));
|
|
2732
2737
|
}
|
|
2733
|
-
const
|
|
2734
|
-
function
|
|
2735
|
-
const e =
|
|
2738
|
+
const Kt = Qt();
|
|
2739
|
+
function ks() {
|
|
2740
|
+
const e = Ft(Kt);
|
|
2736
2741
|
if (!e)
|
|
2737
2742
|
throw new Error("useSDK was used outside of SDKProvider.");
|
|
2738
2743
|
return e;
|
|
2739
2744
|
}
|
|
2740
|
-
function
|
|
2741
|
-
return (...t) =>
|
|
2745
|
+
function g(e) {
|
|
2746
|
+
return (...t) => {
|
|
2747
|
+
const s = ks()(e, ...t), n = () => s.signal();
|
|
2748
|
+
return Object.defineProperty(n, "error", () => s.error), n;
|
|
2749
|
+
};
|
|
2742
2750
|
}
|
|
2743
|
-
const
|
|
2751
|
+
const Os = g(We), hn = _(Os), qs = g(Ke), pn = _(qs), Ds = g(Je), un = _(Ds), Ns = g(Xe), ln = _(Ns), Vs = g(es), dn = _(Vs), Ms = g(ns), _n = _(Ms), Bs = g(is), gn = _(Bs), $s = g(as), fn = _($s), Ls = g(us), mn = _(Ls), Us = g(_s), wn = _(Us), Hs = g(fs), bn = _(Hs), Ws = g(ws), vn = _(Ws), js = g(vs), yn = _(js), Gs = g(Es), En = _(Gs), Ks = g(xs), Pn = _(Ks), xn = (e) => {
|
|
2744
2752
|
const t = /* @__PURE__ */ new Map(), s = (n, ...r) => {
|
|
2745
2753
|
if (t.has(n))
|
|
2746
2754
|
return t.get(n);
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
}
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2755
|
+
function i(l) {
|
|
2756
|
+
return t.set(n, l), l;
|
|
2757
|
+
}
|
|
2758
|
+
let o;
|
|
2759
|
+
try {
|
|
2760
|
+
o = n(...r);
|
|
2761
|
+
} catch (l) {
|
|
2762
|
+
return i({
|
|
2763
|
+
error: l,
|
|
2764
|
+
signal: () => {
|
|
2765
|
+
throw l;
|
|
2766
|
+
}
|
|
2767
|
+
});
|
|
2768
|
+
}
|
|
2769
|
+
let a;
|
|
2770
|
+
Array.isArray(o) && ([o, a] = o);
|
|
2771
|
+
const [p] = Yt(() => o), u = pt(() => {
|
|
2772
|
+
if (p.state !== "ready")
|
|
2757
2773
|
return;
|
|
2758
|
-
const
|
|
2759
|
-
if (
|
|
2760
|
-
return
|
|
2761
|
-
const
|
|
2762
|
-
return new Proxy(
|
|
2763
|
-
get(
|
|
2764
|
-
if (!(x in
|
|
2765
|
-
const
|
|
2766
|
-
|
|
2774
|
+
const l = p();
|
|
2775
|
+
if (!l || !("on" in l))
|
|
2776
|
+
return l;
|
|
2777
|
+
const zt = Zt((N) => (N(l), l.on("change", () => N(l)))), Jt = Object.getPrototypeOf(l), W = {};
|
|
2778
|
+
return new Proxy(l, {
|
|
2779
|
+
get(N, x) {
|
|
2780
|
+
if (!(x in W)) {
|
|
2781
|
+
const ot = Reflect.getOwnPropertyDescriptor(Jt, x);
|
|
2782
|
+
W[x] = ot && "get" in ot ? pt(() => zt()[x]) : () => Reflect.get(N, x);
|
|
2767
2783
|
}
|
|
2768
|
-
return
|
|
2784
|
+
return W[x]();
|
|
2769
2785
|
}
|
|
2770
2786
|
});
|
|
2771
2787
|
});
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
}), t.set(n, a), a;
|
|
2788
|
+
return i({
|
|
2789
|
+
signal() {
|
|
2790
|
+
if (p.error)
|
|
2791
|
+
throw p.error;
|
|
2792
|
+
return u();
|
|
2793
|
+
},
|
|
2794
|
+
get error() {
|
|
2795
|
+
return p.error;
|
|
2796
|
+
},
|
|
2797
|
+
cleanup: a
|
|
2798
|
+
});
|
|
2784
2799
|
};
|
|
2785
|
-
return
|
|
2786
|
-
|
|
2800
|
+
return ct(() => {
|
|
2801
|
+
ne(e.debug || !1);
|
|
2802
|
+
}), ct(() => {
|
|
2803
|
+
Pt() && ht(Cs(e.acceptCustomStyles));
|
|
2787
2804
|
}), ht(() => {
|
|
2788
|
-
|
|
2789
|
-
}),
|
|
2805
|
+
t.forEach((n) => n.cleanup && n.cleanup());
|
|
2806
|
+
}), gt(Kt.Provider, {
|
|
2790
2807
|
value: s,
|
|
2791
2808
|
get children() {
|
|
2792
2809
|
return e.children;
|
|
@@ -2794,54 +2811,54 @@ const qs = _(je), cn = l(qs), Ds = _(ze), hn = l(Ds), Ns = _(Je), pn = l(Ns), Vs
|
|
|
2794
2811
|
});
|
|
2795
2812
|
};
|
|
2796
2813
|
export {
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2814
|
+
Ae as BackButton,
|
|
2815
|
+
Rs as BasicNavigator,
|
|
2816
|
+
je as BiometryManager,
|
|
2817
|
+
Gt as BrowserNavigator,
|
|
2818
|
+
ze as ClosingBehavior,
|
|
2802
2819
|
Ze as CloudStorage,
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2820
|
+
de as ERR_INVALID_PATH_BASE,
|
|
2821
|
+
ce as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
|
|
2822
|
+
oe as ERR_METHOD_PARAMETER_UNSUPPORTED,
|
|
2823
|
+
ie as ERR_METHOD_UNSUPPORTED,
|
|
2824
|
+
ue as ERR_NAVIGATION_HISTORY_EMPTY,
|
|
2825
|
+
le as ERR_NAVIGATION_INDEX_INVALID,
|
|
2826
|
+
Js as ERR_NAVIGATION_ITEM_INVALID,
|
|
2827
|
+
wt as ERR_PARSE,
|
|
2828
|
+
Qs as ERR_SSR_INIT,
|
|
2829
|
+
he as ERR_TIMED_OUT,
|
|
2830
|
+
pe as ERR_UNEXPECTED_TYPE,
|
|
2831
|
+
ae as ERR_UNKNOWN_ENV,
|
|
2832
|
+
B as EventEmitter,
|
|
2816
2833
|
ts as HapticFeedback,
|
|
2817
2834
|
ss as InitData,
|
|
2818
2835
|
rs as Invoice,
|
|
2819
2836
|
os as MainButton,
|
|
2820
2837
|
ps as MiniApp,
|
|
2821
|
-
|
|
2838
|
+
ds as Popup,
|
|
2822
2839
|
gs as QRScanner,
|
|
2823
|
-
|
|
2824
|
-
|
|
2840
|
+
$ as SDKError,
|
|
2841
|
+
xn as SDKProvider,
|
|
2825
2842
|
ms as SettingsButton,
|
|
2826
2843
|
bs as ThemeParams,
|
|
2827
2844
|
ys as Utils,
|
|
2828
|
-
|
|
2845
|
+
Ps as Viewport,
|
|
2829
2846
|
Ye as array,
|
|
2830
2847
|
tn as bindMiniAppCSSVars,
|
|
2831
2848
|
en as bindThemeParamsCSSVars,
|
|
2832
2849
|
sn as bindViewportCSSVars,
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2850
|
+
y as boolean,
|
|
2851
|
+
Ct as captureSameReq,
|
|
2852
|
+
Y as classNames,
|
|
2853
|
+
xe as compareVersions,
|
|
2854
|
+
As as createBrowserNavigatorFromLocation,
|
|
2855
|
+
Re as createPostEvent,
|
|
2856
|
+
V as createSafeURL,
|
|
2857
|
+
It as date,
|
|
2858
|
+
an as getHash,
|
|
2859
|
+
jt as getPathname,
|
|
2860
|
+
We as initBackButton,
|
|
2861
|
+
Ke as initBiometryManager,
|
|
2845
2862
|
Je as initClosingBehavior,
|
|
2846
2863
|
Xe as initCloudStorage,
|
|
2847
2864
|
es as initHapticFeedback,
|
|
@@ -2849,83 +2866,83 @@ export {
|
|
|
2849
2866
|
is as initInvoice,
|
|
2850
2867
|
as as initMainButton,
|
|
2851
2868
|
us as initMiniApp,
|
|
2852
|
-
|
|
2869
|
+
cn as initNavigator,
|
|
2853
2870
|
_s as initPopup,
|
|
2854
2871
|
fs as initQRScanner,
|
|
2855
2872
|
ws as initSettingsButton,
|
|
2856
2873
|
vs as initThemeParams,
|
|
2857
2874
|
Es as initUtils,
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2875
|
+
xs as initViewport,
|
|
2876
|
+
Cs as initWeb,
|
|
2877
|
+
A as invokeCustomMethod,
|
|
2878
|
+
Tt as isColorDark,
|
|
2879
|
+
Pt as isIframe,
|
|
2880
|
+
$t as isPageReload,
|
|
2881
|
+
tt as isRGB,
|
|
2882
|
+
_e as isRGBShort,
|
|
2883
|
+
Ss as isSDKError,
|
|
2884
|
+
on as isSDKErrorOfType,
|
|
2885
|
+
nn as isSSR,
|
|
2886
|
+
rn as isTMA,
|
|
2887
|
+
f as json,
|
|
2871
2888
|
Ys as mergeClassNames,
|
|
2872
2889
|
P as number,
|
|
2873
|
-
|
|
2874
|
-
|
|
2890
|
+
H as off,
|
|
2891
|
+
v as on,
|
|
2875
2892
|
Zs as parseInitData,
|
|
2876
|
-
|
|
2877
|
-
|
|
2893
|
+
qt as parseLaunchParams,
|
|
2894
|
+
Ht as parseThemeParams,
|
|
2878
2895
|
k as postEvent,
|
|
2879
|
-
|
|
2896
|
+
m as request,
|
|
2880
2897
|
Ge as requestBiometryInfo,
|
|
2881
2898
|
Xs as requestThemeParams,
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2899
|
+
Wt as requestViewport,
|
|
2900
|
+
$e as retrieveLaunchParams,
|
|
2901
|
+
yt as rgb,
|
|
2902
|
+
nt as searchParams,
|
|
2903
|
+
Me as serializeLaunchParams,
|
|
2904
|
+
Ve as serializeThemeParams,
|
|
2905
|
+
E as setCSSVar,
|
|
2906
|
+
ne as setDebug,
|
|
2890
2907
|
Fs as setTargetOrigin,
|
|
2891
|
-
|
|
2892
|
-
|
|
2908
|
+
h as string,
|
|
2909
|
+
ee as subscribe,
|
|
2893
2910
|
C as supports,
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2911
|
+
Se as targetOrigin,
|
|
2912
|
+
vt as toRGB,
|
|
2913
|
+
mt as unsubscribe,
|
|
2914
|
+
M as urlToPath,
|
|
2915
|
+
Os as useBackButton,
|
|
2916
|
+
qs as useBiometryManager,
|
|
2917
|
+
Ds as useClosingBehavior,
|
|
2918
|
+
Ns as useCloudStorage,
|
|
2919
|
+
Vs as useHapticFeedback,
|
|
2920
|
+
Ms as useInitData,
|
|
2921
|
+
Bs as useInvoice,
|
|
2922
|
+
$s as useMainButton,
|
|
2923
|
+
Ls as useMiniApp,
|
|
2924
|
+
Us as usePopup,
|
|
2925
|
+
Hs as useQRScanner,
|
|
2926
|
+
ks as useSDK,
|
|
2927
|
+
Ws as useSettingsButton,
|
|
2928
|
+
js as useThemeParams,
|
|
2929
|
+
Gs as useUtils,
|
|
2913
2930
|
Ks as useViewport,
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2931
|
+
hn as withBackButton,
|
|
2932
|
+
pn as withBiometryManager,
|
|
2933
|
+
un as withClosingBehavior,
|
|
2934
|
+
ln as withCloudStorage,
|
|
2918
2935
|
dn as withHapticFeedback,
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2936
|
+
_n as withInitData,
|
|
2937
|
+
gn as withInvoice,
|
|
2938
|
+
fn as withMainButton,
|
|
2939
|
+
mn as withMiniApp,
|
|
2940
|
+
wn as withPopup,
|
|
2941
|
+
bn as withQRScanner,
|
|
2942
|
+
vn as withSettingsButton,
|
|
2943
|
+
yn as withThemeParams,
|
|
2944
|
+
Rt as withTimeout,
|
|
2945
|
+
En as withUtils,
|
|
2946
|
+
Pn as withViewport
|
|
2930
2947
|
};
|
|
2931
2948
|
//# sourceMappingURL=index.js.map
|