@tma.js/sdk 1.0.2 → 1.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/parsers/phoneRequested.d.ts +1 -1
- package/dist/dts/bridge/index.d.ts +1 -0
- package/dist/dts/bridge/invoke-custom-method.d.ts +18 -0
- package/dist/dts/bridge/methods/custom-methods.d.ts +56 -0
- package/dist/dts/bridge/methods/index.d.ts +1 -1
- package/dist/dts/bridge/methods/methods.d.ts +1 -1
- package/dist/dts/bridge/request.d.ts +3 -12
- package/dist/dts/cloud-storage/CloudStorage.d.ts +7 -16
- package/dist/dts/index.d.ts +8 -6
- package/dist/dts/init/creators/createMiniApp.d.ts +3 -1
- package/dist/dts/init/creators/createSettingsButton.d.ts +10 -0
- package/dist/dts/init/creators/index.d.ts +1 -0
- package/dist/dts/init/init.d.ts +1 -0
- package/dist/dts/init/types.d.ts +2 -0
- package/dist/dts/mini-app/MiniApp.d.ts +34 -4
- package/dist/dts/mini-app/contactParser.d.ts +2 -0
- package/dist/dts/mini-app/types.d.ts +12 -0
- package/dist/dts/settings-button/SettingsButton.d.ts +42 -0
- package/dist/dts/settings-button/index.d.ts +2 -0
- package/dist/dts/settings-button/types.d.ts +10 -0
- package/dist/dts/storage.d.ts +3 -0
- package/dist/dts/timeout/index.d.ts +1 -0
- package/dist/dts/timeout/sleep.d.ts +5 -0
- package/dist/dts/timeout/withTimeout.d.ts +5 -12
- package/dist/dts/types/index.d.ts +1 -0
- package/dist/dts/types/methods.d.ts +15 -0
- 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.mjs +854 -670
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/bridge/events/parsers/phoneRequested.ts +1 -1
- package/src/bridge/index.ts +1 -0
- package/src/bridge/invoke-custom-method.ts +56 -0
- package/src/bridge/methods/custom-methods.ts +68 -0
- package/src/bridge/methods/index.ts +1 -1
- package/src/bridge/methods/methods.ts +3 -5
- package/src/bridge/request.ts +35 -44
- package/src/cloud-storage/CloudStorage.ts +36 -53
- package/src/index.ts +14 -20
- package/src/init/creators/createMiniApp.ts +4 -0
- package/src/init/creators/createSettingsButton.ts +25 -0
- package/src/init/creators/createViewport.ts +16 -5
- package/src/init/creators/index.ts +1 -0
- package/src/init/init.ts +9 -5
- package/src/init/types.ts +2 -0
- package/src/mini-app/MiniApp.ts +131 -20
- package/src/mini-app/contactParser.ts +29 -0
- package/src/mini-app/types.ts +13 -0
- package/src/settings-button/SettingsButton.ts +85 -0
- package/src/settings-button/index.ts +2 -0
- package/src/settings-button/types.ts +15 -0
- package/src/storage.ts +3 -0
- package/src/timeout/index.ts +1 -0
- package/src/timeout/sleep.ts +10 -0
- package/src/timeout/withTimeout.ts +10 -22
- package/src/types/index.ts +1 -0
- package/src/types/methods.ts +18 -0
- package/dist/dts/bridge/methods/invoke-custom-method.d.ts +0 -24
- package/src/bridge/methods/invoke-custom-method.ts +0 -25
package/dist/index.mjs
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
var $t = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var o = (r, t, e) => (
|
|
4
|
-
function
|
|
2
|
+
var Tt = (r, t, e) => t in r ? $t(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
+
var o = (r, t, e) => (Tt(r, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
+
function H(r) {
|
|
5
5
|
return typeof r == "object" && r !== null && !Array.isArray(r);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function ht() {
|
|
8
8
|
return performance.getEntriesByType("navigation")[0] || null;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
const r =
|
|
10
|
+
function Bt() {
|
|
11
|
+
const r = ht();
|
|
12
12
|
return r ? r.type === "reload" : null;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function R() {
|
|
15
15
|
return new TypeError("Value has unexpected type");
|
|
16
16
|
}
|
|
17
|
-
class
|
|
18
|
-
constructor(e, { cause:
|
|
19
|
-
super(`Unable to parse value${
|
|
17
|
+
class F extends Error {
|
|
18
|
+
constructor(e, { cause: s, type: n } = {}) {
|
|
19
|
+
super(`Unable to parse value${n ? ` as ${n}` : ""}`, { cause: s });
|
|
20
20
|
/**
|
|
21
21
|
* Parser name.
|
|
22
22
|
*/
|
|
23
23
|
o(this, "type");
|
|
24
|
-
this.value = e, Object.setPrototypeOf(this,
|
|
24
|
+
this.value = e, Object.setPrototypeOf(this, F.prototype), this.type = n;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
class
|
|
28
|
-
constructor(t, e,
|
|
29
|
-
this.parser = t, this.isOptional = e, this.type =
|
|
27
|
+
class z {
|
|
28
|
+
constructor(t, e, s) {
|
|
29
|
+
this.parser = t, this.isOptional = e, this.type = s;
|
|
30
30
|
}
|
|
31
31
|
parse(t) {
|
|
32
32
|
if (!(this.isOptional && t === void 0))
|
|
33
33
|
try {
|
|
34
34
|
return this.parser(t);
|
|
35
35
|
} catch (e) {
|
|
36
|
-
throw new
|
|
36
|
+
throw new F(t, { type: this.type, cause: e });
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
optional() {
|
|
40
40
|
return this.isOptional = !0, this;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function Dt(r) {
|
|
44
44
|
if (Array.isArray(r))
|
|
45
45
|
return r;
|
|
46
46
|
if (typeof r == "string")
|
|
@@ -50,61 +50,61 @@ function It(r) {
|
|
|
50
50
|
return t;
|
|
51
51
|
} catch {
|
|
52
52
|
}
|
|
53
|
-
throw
|
|
53
|
+
throw R();
|
|
54
54
|
}
|
|
55
|
-
class
|
|
56
|
-
constructor(e,
|
|
57
|
-
super(
|
|
55
|
+
class Wt extends z {
|
|
56
|
+
constructor(e, s, n) {
|
|
57
|
+
super(Dt, s, n);
|
|
58
58
|
o(this, "itemParser");
|
|
59
59
|
this.itemParser = typeof e == "function" ? e : e.parse.bind(e);
|
|
60
60
|
}
|
|
61
61
|
parse(e) {
|
|
62
|
-
const
|
|
63
|
-
return
|
|
62
|
+
const s = super.parse(e);
|
|
63
|
+
return s === void 0 ? s : s.map(this.itemParser);
|
|
64
64
|
}
|
|
65
65
|
of(e) {
|
|
66
66
|
return this.itemParser = typeof e == "function" ? e : e.parse.bind(e), this;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
function
|
|
70
|
-
return () => new
|
|
69
|
+
function V(r, t) {
|
|
70
|
+
return () => new z(r, !1, t);
|
|
71
71
|
}
|
|
72
|
-
class
|
|
73
|
-
constructor(t, { cause: e, type:
|
|
74
|
-
super(`Unable to parse field "${t}"${
|
|
72
|
+
class j extends Error {
|
|
73
|
+
constructor(t, { cause: e, type: s } = {}) {
|
|
74
|
+
super(`Unable to parse field "${t}"${s ? ` as ${s}` : ""}`, { cause: e }), Object.setPrototypeOf(this, j.prototype);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
function
|
|
77
|
+
function ut(r, t) {
|
|
78
78
|
const e = {};
|
|
79
|
-
for (const
|
|
80
|
-
const
|
|
81
|
-
if (!
|
|
79
|
+
for (const s in r) {
|
|
80
|
+
const n = r[s];
|
|
81
|
+
if (!n)
|
|
82
82
|
continue;
|
|
83
83
|
let i, a;
|
|
84
|
-
if (typeof
|
|
85
|
-
i =
|
|
84
|
+
if (typeof n == "function" || "parse" in n)
|
|
85
|
+
i = s, a = typeof n == "function" ? n : n.parse.bind(n);
|
|
86
86
|
else {
|
|
87
|
-
const { type:
|
|
88
|
-
i =
|
|
87
|
+
const { type: p } = n;
|
|
88
|
+
i = n.from || s, a = typeof p == "function" ? p : p.parse.bind(p);
|
|
89
89
|
}
|
|
90
90
|
let c;
|
|
91
91
|
const u = t(i);
|
|
92
92
|
try {
|
|
93
93
|
c = a(u);
|
|
94
|
-
} catch (
|
|
95
|
-
throw
|
|
96
|
-
type:
|
|
97
|
-
cause:
|
|
98
|
-
}) : new
|
|
94
|
+
} catch (p) {
|
|
95
|
+
throw p instanceof F ? new j(i, {
|
|
96
|
+
type: p.type,
|
|
97
|
+
cause: p
|
|
98
|
+
}) : new j(i, { cause: p });
|
|
99
99
|
}
|
|
100
|
-
c !== void 0 && (e[
|
|
100
|
+
c !== void 0 && (e[s] = c);
|
|
101
101
|
}
|
|
102
102
|
return e;
|
|
103
103
|
}
|
|
104
|
-
function
|
|
105
|
-
return new
|
|
104
|
+
function Nt(r) {
|
|
105
|
+
return new Wt((t) => t, !1, r);
|
|
106
106
|
}
|
|
107
|
-
const
|
|
107
|
+
const P = V((r) => {
|
|
108
108
|
if (typeof r == "boolean")
|
|
109
109
|
return r;
|
|
110
110
|
const t = String(r);
|
|
@@ -112,8 +112,8 @@ const C = $((r) => {
|
|
|
112
112
|
return !0;
|
|
113
113
|
if (t === "0" || t === "false")
|
|
114
114
|
return !1;
|
|
115
|
-
throw
|
|
116
|
-
}, "boolean"),
|
|
115
|
+
throw R();
|
|
116
|
+
}, "boolean"), k = V((r) => {
|
|
117
117
|
if (typeof r == "number")
|
|
118
118
|
return r;
|
|
119
119
|
if (typeof r == "string") {
|
|
@@ -121,72 +121,72 @@ const C = $((r) => {
|
|
|
121
121
|
if (!Number.isNaN(t))
|
|
122
122
|
return t;
|
|
123
123
|
}
|
|
124
|
-
throw
|
|
125
|
-
}, "number"),
|
|
126
|
-
function
|
|
124
|
+
throw R();
|
|
125
|
+
}, "number"), pt = V((r) => r instanceof Date ? r : new Date(k().parse(r) * 1e3), "Date");
|
|
126
|
+
function Y(r) {
|
|
127
127
|
let t = r;
|
|
128
128
|
if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
|
|
129
|
-
throw
|
|
129
|
+
throw R();
|
|
130
130
|
return t;
|
|
131
131
|
}
|
|
132
132
|
function g(r, t) {
|
|
133
|
-
return new
|
|
134
|
-
const
|
|
135
|
-
return
|
|
133
|
+
return new z((e) => {
|
|
134
|
+
const s = Y(e);
|
|
135
|
+
return ut(r, (n) => s[n]);
|
|
136
136
|
}, !1, t);
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function lt(r) {
|
|
139
139
|
return /^#[\da-f]{6}$/i.test(r);
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function Ot(r) {
|
|
142
142
|
return /^#[\da-f]{3}$/i.test(r);
|
|
143
143
|
}
|
|
144
|
-
function
|
|
144
|
+
function dt(r) {
|
|
145
145
|
const t = r.replace(/\s/g, "").toLowerCase();
|
|
146
|
-
if (
|
|
146
|
+
if (lt(t))
|
|
147
147
|
return t;
|
|
148
|
-
if (
|
|
149
|
-
let
|
|
150
|
-
for (let
|
|
151
|
-
|
|
152
|
-
return
|
|
148
|
+
if (Ot(t)) {
|
|
149
|
+
let s = "#";
|
|
150
|
+
for (let n = 0; n < 3; n += 1)
|
|
151
|
+
s += t[1 + n].repeat(2);
|
|
152
|
+
return s;
|
|
153
153
|
}
|
|
154
154
|
const e = t.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/) || t.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),\d{1,3}\)$/);
|
|
155
155
|
if (e === null)
|
|
156
156
|
throw new Error(`Value "${r}" does not satisfy any of known RGB formats.`);
|
|
157
|
-
return e.slice(1).reduce((
|
|
158
|
-
const i = parseInt(
|
|
159
|
-
return
|
|
157
|
+
return e.slice(1).reduce((s, n) => {
|
|
158
|
+
const i = parseInt(n, 10).toString(16);
|
|
159
|
+
return s + (i.length === 1 ? "0" : "") + i;
|
|
160
160
|
}, "#");
|
|
161
161
|
}
|
|
162
|
-
function
|
|
163
|
-
const t =
|
|
162
|
+
function ft(r) {
|
|
163
|
+
const t = dt(r);
|
|
164
164
|
return Math.sqrt(
|
|
165
|
-
[0.299, 0.587, 0.114].reduce((
|
|
165
|
+
[0.299, 0.587, 0.114].reduce((s, n, i) => {
|
|
166
166
|
const a = parseInt(t.slice(1 + i * 2, 1 + (i + 1) * 2), 16);
|
|
167
|
-
return
|
|
167
|
+
return s + a * a * n;
|
|
168
168
|
}, 0)
|
|
169
169
|
) < 120;
|
|
170
170
|
}
|
|
171
|
-
const h =
|
|
171
|
+
const h = V((r) => {
|
|
172
172
|
if (typeof r == "string" || typeof r == "number")
|
|
173
173
|
return r.toString();
|
|
174
|
-
throw
|
|
175
|
-
}, "string"),
|
|
176
|
-
function
|
|
177
|
-
return new
|
|
174
|
+
throw R();
|
|
175
|
+
}, "string"), gt = V((r) => dt(h().parse(r)), "rgb");
|
|
176
|
+
function X(r, t) {
|
|
177
|
+
return new z((e) => {
|
|
178
178
|
if (typeof e != "string" && !(e instanceof URLSearchParams))
|
|
179
|
-
throw
|
|
180
|
-
const
|
|
181
|
-
return
|
|
182
|
-
const i =
|
|
179
|
+
throw R();
|
|
180
|
+
const s = typeof e == "string" ? new URLSearchParams(e) : e;
|
|
181
|
+
return ut(r, (n) => {
|
|
182
|
+
const i = s.get(n);
|
|
183
183
|
return i === null ? void 0 : i;
|
|
184
184
|
});
|
|
185
185
|
}, !1, t);
|
|
186
186
|
}
|
|
187
|
-
function
|
|
187
|
+
function Ht() {
|
|
188
188
|
return g({
|
|
189
|
-
id:
|
|
189
|
+
id: k(),
|
|
190
190
|
type: h(),
|
|
191
191
|
title: h(),
|
|
192
192
|
photoUrl: {
|
|
@@ -196,7 +196,7 @@ function Nt() {
|
|
|
196
196
|
username: h().optional()
|
|
197
197
|
}, "Chat");
|
|
198
198
|
}
|
|
199
|
-
class
|
|
199
|
+
class Ut {
|
|
200
200
|
constructor(t) {
|
|
201
201
|
this.initData = t;
|
|
202
202
|
}
|
|
@@ -269,27 +269,27 @@ class Ot {
|
|
|
269
269
|
return this.initData.user;
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
|
-
function
|
|
272
|
+
function rt() {
|
|
273
273
|
return g({
|
|
274
274
|
addedToAttachmentMenu: {
|
|
275
|
-
type:
|
|
275
|
+
type: P().optional(),
|
|
276
276
|
from: "added_to_attachment_menu"
|
|
277
277
|
},
|
|
278
278
|
allowsWriteToPm: {
|
|
279
|
-
type:
|
|
279
|
+
type: P().optional(),
|
|
280
280
|
from: "allows_write_to_pm"
|
|
281
281
|
},
|
|
282
282
|
firstName: {
|
|
283
283
|
type: h(),
|
|
284
284
|
from: "first_name"
|
|
285
285
|
},
|
|
286
|
-
id:
|
|
286
|
+
id: k(),
|
|
287
287
|
isBot: {
|
|
288
|
-
type:
|
|
288
|
+
type: P().optional(),
|
|
289
289
|
from: "is_bot"
|
|
290
290
|
},
|
|
291
291
|
isPremium: {
|
|
292
|
-
type:
|
|
292
|
+
type: P().optional(),
|
|
293
293
|
from: "is_premium"
|
|
294
294
|
},
|
|
295
295
|
languageCode: {
|
|
@@ -307,17 +307,17 @@ function tt() {
|
|
|
307
307
|
username: h().optional()
|
|
308
308
|
}, "User");
|
|
309
309
|
}
|
|
310
|
-
function
|
|
311
|
-
return
|
|
310
|
+
function wt() {
|
|
311
|
+
return X({
|
|
312
312
|
authDate: {
|
|
313
|
-
type:
|
|
313
|
+
type: pt(),
|
|
314
314
|
from: "auth_date"
|
|
315
315
|
},
|
|
316
316
|
canSendAfter: {
|
|
317
|
-
type:
|
|
317
|
+
type: k().optional(),
|
|
318
318
|
from: "can_send_after"
|
|
319
319
|
},
|
|
320
|
-
chat:
|
|
320
|
+
chat: Ht().optional(),
|
|
321
321
|
chatInstance: {
|
|
322
322
|
type: h().optional(),
|
|
323
323
|
from: "chat_instance"
|
|
@@ -331,39 +331,39 @@ function gt() {
|
|
|
331
331
|
type: h().optional(),
|
|
332
332
|
from: "query_id"
|
|
333
333
|
},
|
|
334
|
-
receiver:
|
|
334
|
+
receiver: rt().optional(),
|
|
335
335
|
startParam: {
|
|
336
336
|
type: h().optional(),
|
|
337
337
|
from: "start_param"
|
|
338
338
|
},
|
|
339
|
-
user:
|
|
339
|
+
user: rt().optional()
|
|
340
340
|
}, "InitData");
|
|
341
341
|
}
|
|
342
|
-
function
|
|
343
|
-
return
|
|
342
|
+
function er(r) {
|
|
343
|
+
return wt().parse(r);
|
|
344
344
|
}
|
|
345
|
-
function
|
|
345
|
+
function Mt(r) {
|
|
346
346
|
return r.replace(/(^|_)bg/, (t, e) => `${e}background`).replace(/_([a-z])/g, (t, e) => e.toUpperCase());
|
|
347
347
|
}
|
|
348
|
-
function
|
|
348
|
+
function jt(r) {
|
|
349
349
|
return r.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`).replace(/(^|_)background/, (t, e) => `${e}bg`);
|
|
350
350
|
}
|
|
351
|
-
const
|
|
351
|
+
const _t = V(
|
|
352
352
|
(r) => {
|
|
353
|
-
const t =
|
|
354
|
-
return Object.entries(
|
|
353
|
+
const t = gt().optional();
|
|
354
|
+
return Object.entries(Y(r)).reduce((e, [s, n]) => (e[Mt(s)] = t.parse(n), e), {});
|
|
355
355
|
},
|
|
356
356
|
"ThemeParams"
|
|
357
357
|
);
|
|
358
|
-
function
|
|
359
|
-
return
|
|
358
|
+
function bt(r) {
|
|
359
|
+
return _t().parse(r);
|
|
360
360
|
}
|
|
361
|
-
function
|
|
362
|
-
return
|
|
361
|
+
function rr(r = {}) {
|
|
362
|
+
return m("web_app_request_theme", "theme_changed", r).then(bt);
|
|
363
363
|
}
|
|
364
|
-
function
|
|
364
|
+
function Gt(r) {
|
|
365
365
|
return JSON.stringify(
|
|
366
|
-
Object.entries(r).reduce((t, [e,
|
|
366
|
+
Object.entries(r).reduce((t, [e, s]) => (s && (t[jt(e)] = s), t), {})
|
|
367
367
|
);
|
|
368
368
|
}
|
|
369
369
|
class w {
|
|
@@ -377,15 +377,15 @@ class w {
|
|
|
377
377
|
* @param listener - event listener.
|
|
378
378
|
* @param once - should listener called only once.
|
|
379
379
|
*/
|
|
380
|
-
addListener(t, e,
|
|
381
|
-
let
|
|
382
|
-
return
|
|
380
|
+
addListener(t, e, s) {
|
|
381
|
+
let n = this.listeners.get(t);
|
|
382
|
+
return n || (n = [], this.listeners.set(t, n)), n.push([e, s]), () => this.off(t, e);
|
|
383
383
|
}
|
|
384
384
|
emit(t, ...e) {
|
|
385
|
-
this.subscribeListeners.forEach((
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
|
|
385
|
+
this.subscribeListeners.forEach((n) => n(t, ...e));
|
|
386
|
+
const s = this.listeners.get(t);
|
|
387
|
+
s && s.forEach(([n, i], a) => {
|
|
388
|
+
n(...e), i && s.splice(a, 1);
|
|
389
389
|
});
|
|
390
390
|
}
|
|
391
391
|
/**
|
|
@@ -415,11 +415,11 @@ class w {
|
|
|
415
415
|
* @param listener - event listener.
|
|
416
416
|
*/
|
|
417
417
|
off(t, e) {
|
|
418
|
-
const
|
|
419
|
-
if (
|
|
420
|
-
for (let
|
|
421
|
-
if (e === n
|
|
422
|
-
|
|
418
|
+
const s = this.listeners.get(t);
|
|
419
|
+
if (s) {
|
|
420
|
+
for (let n = 0; n < s.length; n += 1)
|
|
421
|
+
if (e === s[n][0]) {
|
|
422
|
+
s.splice(n, 1);
|
|
423
423
|
return;
|
|
424
424
|
}
|
|
425
425
|
}
|
|
@@ -448,7 +448,7 @@ class w {
|
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
|
-
class
|
|
451
|
+
class _ {
|
|
452
452
|
constructor(t, e) {
|
|
453
453
|
this.state = t, this.ee = e;
|
|
454
454
|
}
|
|
@@ -462,13 +462,13 @@ class b {
|
|
|
462
462
|
return { ...this.state };
|
|
463
463
|
}
|
|
464
464
|
set(t, e) {
|
|
465
|
-
let
|
|
465
|
+
let s = !1;
|
|
466
466
|
if (typeof t == "string")
|
|
467
|
-
|
|
467
|
+
s = this.internalSet(t, e);
|
|
468
468
|
else
|
|
469
|
-
for (const
|
|
470
|
-
this.internalSet(
|
|
471
|
-
|
|
469
|
+
for (const n in t)
|
|
470
|
+
this.internalSet(n, t[n]) && (s = !0);
|
|
471
|
+
s && this.ee.emit("change");
|
|
472
472
|
}
|
|
473
473
|
/**
|
|
474
474
|
* Returns value by specified key.
|
|
@@ -478,7 +478,7 @@ class b {
|
|
|
478
478
|
return this.state[t];
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
|
-
class
|
|
481
|
+
class Ft {
|
|
482
482
|
constructor(t) {
|
|
483
483
|
o(this, "ee", new w());
|
|
484
484
|
o(this, "state");
|
|
@@ -490,7 +490,7 @@ class jt {
|
|
|
490
490
|
* Removes event listener.
|
|
491
491
|
*/
|
|
492
492
|
o(this, "off", this.ee.off.bind(this.ee));
|
|
493
|
-
this.state = new
|
|
493
|
+
this.state = new _(t, this.ee);
|
|
494
494
|
}
|
|
495
495
|
/**
|
|
496
496
|
* @since v6.10
|
|
@@ -537,7 +537,7 @@ class jt {
|
|
|
537
537
|
* value is calculated according to theme background color.
|
|
538
538
|
*/
|
|
539
539
|
get isDark() {
|
|
540
|
-
return !this.backgroundColor ||
|
|
540
|
+
return !this.backgroundColor || ft(this.backgroundColor);
|
|
541
541
|
}
|
|
542
542
|
get linkColor() {
|
|
543
543
|
return this.get("linkColor");
|
|
@@ -562,8 +562,8 @@ class jt {
|
|
|
562
562
|
* @returns Function to stop listening.
|
|
563
563
|
*/
|
|
564
564
|
listen() {
|
|
565
|
-
return
|
|
566
|
-
this.state.set(
|
|
565
|
+
return y("theme_changed", (t) => {
|
|
566
|
+
this.state.set(bt(t.theme_params));
|
|
567
567
|
});
|
|
568
568
|
}
|
|
569
569
|
/**
|
|
@@ -576,14 +576,14 @@ class jt {
|
|
|
576
576
|
return this.get("textColor");
|
|
577
577
|
}
|
|
578
578
|
}
|
|
579
|
-
function
|
|
580
|
-
return
|
|
579
|
+
function mt() {
|
|
580
|
+
return X({
|
|
581
581
|
botInline: {
|
|
582
|
-
type:
|
|
582
|
+
type: P().optional(),
|
|
583
583
|
from: "tgWebAppBotInline"
|
|
584
584
|
},
|
|
585
585
|
initData: {
|
|
586
|
-
type:
|
|
586
|
+
type: wt().optional(),
|
|
587
587
|
from: "tgWebAppData"
|
|
588
588
|
},
|
|
589
589
|
initDataRaw: {
|
|
@@ -595,11 +595,11 @@ function bt() {
|
|
|
595
595
|
from: "tgWebAppPlatform"
|
|
596
596
|
},
|
|
597
597
|
showSettings: {
|
|
598
|
-
type:
|
|
598
|
+
type: P().optional(),
|
|
599
599
|
from: "tgWebAppShowSettings"
|
|
600
600
|
},
|
|
601
601
|
themeParams: {
|
|
602
|
-
type:
|
|
602
|
+
type: _t(),
|
|
603
603
|
from: "tgWebAppThemeParams"
|
|
604
604
|
},
|
|
605
605
|
version: {
|
|
@@ -608,65 +608,65 @@ function bt() {
|
|
|
608
608
|
}
|
|
609
609
|
}, "LaunchParams");
|
|
610
610
|
}
|
|
611
|
-
function
|
|
612
|
-
return
|
|
611
|
+
function yt(r) {
|
|
612
|
+
return mt().parse(r);
|
|
613
613
|
}
|
|
614
|
-
function
|
|
615
|
-
return
|
|
614
|
+
function zt() {
|
|
615
|
+
return yt(window.location.hash.slice(1));
|
|
616
616
|
}
|
|
617
|
-
function
|
|
618
|
-
const r =
|
|
617
|
+
function Jt() {
|
|
618
|
+
const r = ht();
|
|
619
619
|
if (!r)
|
|
620
620
|
throw new Error("Unable to get first navigation entry.");
|
|
621
621
|
const t = r.name.match(/#(.*)/);
|
|
622
622
|
if (!t)
|
|
623
623
|
throw new Error("First navigation entry does not contain hash part.");
|
|
624
|
-
return
|
|
624
|
+
return yt(t[1]);
|
|
625
625
|
}
|
|
626
|
-
function
|
|
626
|
+
function Qt() {
|
|
627
627
|
try {
|
|
628
|
-
return
|
|
628
|
+
return Jt();
|
|
629
629
|
} catch {
|
|
630
630
|
}
|
|
631
631
|
try {
|
|
632
|
-
return
|
|
632
|
+
return zt();
|
|
633
633
|
} catch {
|
|
634
634
|
}
|
|
635
635
|
return null;
|
|
636
636
|
}
|
|
637
|
-
function
|
|
637
|
+
function Zt(r) {
|
|
638
638
|
const {
|
|
639
639
|
initDataRaw: t,
|
|
640
640
|
themeParams: e,
|
|
641
|
-
platform:
|
|
642
|
-
version:
|
|
641
|
+
platform: s,
|
|
642
|
+
version: n,
|
|
643
643
|
showSettings: i,
|
|
644
644
|
botInline: a
|
|
645
645
|
} = r, c = new URLSearchParams();
|
|
646
|
-
return t && c.set("tgWebAppData", t), c.set("tgWebAppPlatform",
|
|
646
|
+
return t && c.set("tgWebAppData", t), c.set("tgWebAppPlatform", s), c.set("tgWebAppThemeParams", Gt(e)), c.set("tgWebAppVersion", n), typeof i == "boolean" && c.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && c.set("tgWebAppBotInline", a ? "1" : "0"), c.toString();
|
|
647
647
|
}
|
|
648
|
-
const
|
|
649
|
-
function
|
|
650
|
-
const r = sessionStorage.getItem(
|
|
651
|
-
return r ?
|
|
648
|
+
const Et = "telegram-mini-apps-launch-params";
|
|
649
|
+
function Kt() {
|
|
650
|
+
const r = sessionStorage.getItem(Et);
|
|
651
|
+
return r ? mt().parse(r) : null;
|
|
652
652
|
}
|
|
653
|
-
function
|
|
654
|
-
sessionStorage.setItem(
|
|
653
|
+
function Yt(r) {
|
|
654
|
+
sessionStorage.setItem(Et, Zt(r));
|
|
655
655
|
}
|
|
656
|
-
function
|
|
656
|
+
function Xt() {
|
|
657
657
|
try {
|
|
658
658
|
return window.self !== window.top;
|
|
659
659
|
} catch {
|
|
660
660
|
return !0;
|
|
661
661
|
}
|
|
662
662
|
}
|
|
663
|
-
function
|
|
664
|
-
const r =
|
|
663
|
+
function te() {
|
|
664
|
+
const r = Kt(), t = Qt(), e = Bt();
|
|
665
665
|
if (r) {
|
|
666
666
|
if (t)
|
|
667
667
|
return {
|
|
668
668
|
launchParams: t,
|
|
669
|
-
isPageReload:
|
|
669
|
+
isPageReload: Xt() ? e || r.initDataRaw === t.initDataRaw : !0
|
|
670
670
|
};
|
|
671
671
|
if (e)
|
|
672
672
|
return {
|
|
@@ -682,45 +682,45 @@ function Yt() {
|
|
|
682
682
|
};
|
|
683
683
|
throw new Error("Unable to retrieve any launch parameters.");
|
|
684
684
|
}
|
|
685
|
-
const
|
|
686
|
-
function
|
|
687
|
-
const r = window[
|
|
685
|
+
const st = "tmajsLaunchData";
|
|
686
|
+
function Ct() {
|
|
687
|
+
const r = window[st];
|
|
688
688
|
if (r)
|
|
689
689
|
return r;
|
|
690
|
-
const t =
|
|
691
|
-
return window[
|
|
690
|
+
const t = te();
|
|
691
|
+
return window[st] = t, Yt(t.launchParams), t;
|
|
692
692
|
}
|
|
693
|
-
function
|
|
693
|
+
function sr() {
|
|
694
694
|
try {
|
|
695
|
-
return
|
|
695
|
+
return Ct(), !0;
|
|
696
696
|
} catch {
|
|
697
697
|
return !1;
|
|
698
698
|
}
|
|
699
699
|
}
|
|
700
|
-
function
|
|
701
|
-
return "external" in r &&
|
|
700
|
+
function ee(r) {
|
|
701
|
+
return "external" in r && H(r.external) && "notify" in r.external && typeof r.external.notify == "function";
|
|
702
702
|
}
|
|
703
|
-
function
|
|
704
|
-
return "TelegramWebviewProxy" in r &&
|
|
703
|
+
function re(r) {
|
|
704
|
+
return "TelegramWebviewProxy" in r && H(r.TelegramWebviewProxy) && "postEvent" in r.TelegramWebviewProxy && typeof r.TelegramWebviewProxy.postEvent == "function";
|
|
705
705
|
}
|
|
706
|
-
function
|
|
706
|
+
function vt() {
|
|
707
707
|
try {
|
|
708
708
|
return window.self !== window.top;
|
|
709
709
|
} catch {
|
|
710
710
|
return !0;
|
|
711
711
|
}
|
|
712
712
|
}
|
|
713
|
-
class
|
|
713
|
+
class tt extends Error {
|
|
714
714
|
constructor(t, e) {
|
|
715
|
-
super(`Method "${t}" is unsupported in the Mini Apps version ${e}.`), Object.setPrototypeOf(this,
|
|
715
|
+
super(`Method "${t}" is unsupported in the Mini Apps version ${e}.`), Object.setPrototypeOf(this, tt.prototype);
|
|
716
716
|
}
|
|
717
717
|
}
|
|
718
|
-
class
|
|
719
|
-
constructor(t, e,
|
|
720
|
-
super(`Parameter "${e}" in method "${t}" is unsupported in the Mini Apps version ${
|
|
718
|
+
class et extends Error {
|
|
719
|
+
constructor(t, e, s) {
|
|
720
|
+
super(`Parameter "${e}" in method "${t}" is unsupported in the Mini Apps version ${s}.`), Object.setPrototypeOf(this, et.prototype);
|
|
721
721
|
}
|
|
722
722
|
}
|
|
723
|
-
class
|
|
723
|
+
class Pt {
|
|
724
724
|
constructor(t, e) {
|
|
725
725
|
this.prefix = t, this.enabled = e;
|
|
726
726
|
}
|
|
@@ -732,14 +732,14 @@ class vt {
|
|
|
732
732
|
print(t, ...e) {
|
|
733
733
|
if (!this.enabled)
|
|
734
734
|
return;
|
|
735
|
-
const
|
|
735
|
+
const s = /* @__PURE__ */ new Date(), n = Intl.DateTimeFormat("en-GB", {
|
|
736
736
|
hour: "2-digit",
|
|
737
737
|
minute: "2-digit",
|
|
738
738
|
second: "2-digit",
|
|
739
739
|
fractionalSecondDigits: 3,
|
|
740
740
|
timeZone: "UTC"
|
|
741
|
-
}).format(
|
|
742
|
-
console[t](`[${
|
|
741
|
+
}).format(s);
|
|
742
|
+
console[t](`[${n}]`, this.prefix, ...e);
|
|
743
743
|
}
|
|
744
744
|
/**
|
|
745
745
|
* Disables the logger.
|
|
@@ -775,31 +775,31 @@ class vt {
|
|
|
775
775
|
this.print("warn", ...t);
|
|
776
776
|
}
|
|
777
777
|
}
|
|
778
|
-
let
|
|
779
|
-
const
|
|
780
|
-
function
|
|
778
|
+
let St = "https://web.telegram.org";
|
|
779
|
+
const q = new Pt("[SDK]", !1);
|
|
780
|
+
function nr(r) {
|
|
781
781
|
if (r) {
|
|
782
|
-
|
|
782
|
+
q.enable();
|
|
783
783
|
return;
|
|
784
784
|
}
|
|
785
|
-
|
|
785
|
+
q.disable();
|
|
786
786
|
}
|
|
787
|
-
function
|
|
788
|
-
|
|
787
|
+
function ir(r) {
|
|
788
|
+
St = r;
|
|
789
789
|
}
|
|
790
|
-
function
|
|
791
|
-
return
|
|
790
|
+
function se() {
|
|
791
|
+
return St;
|
|
792
792
|
}
|
|
793
|
-
const
|
|
793
|
+
const ne = g({
|
|
794
794
|
eventType: h(),
|
|
795
795
|
eventData: (r) => r
|
|
796
796
|
});
|
|
797
|
-
function
|
|
797
|
+
function ie(r, t) {
|
|
798
798
|
window.dispatchEvent(new MessageEvent("message", {
|
|
799
799
|
data: JSON.stringify({ eventType: r, eventData: t })
|
|
800
800
|
}));
|
|
801
801
|
}
|
|
802
|
-
function
|
|
802
|
+
function oe() {
|
|
803
803
|
const r = window;
|
|
804
804
|
"TelegramGameProxy_receiveEvent" in r || [
|
|
805
805
|
["TelegramGameProxy_receiveEvent"],
|
|
@@ -810,78 +810,78 @@ function se() {
|
|
|
810
810
|
// Android and iOS.
|
|
811
811
|
].forEach((t) => {
|
|
812
812
|
let e = r;
|
|
813
|
-
t.forEach((
|
|
814
|
-
if (
|
|
815
|
-
e[
|
|
813
|
+
t.forEach((s, n, i) => {
|
|
814
|
+
if (n === i.length - 1) {
|
|
815
|
+
e[s] = ie;
|
|
816
816
|
return;
|
|
817
817
|
}
|
|
818
|
-
|
|
818
|
+
s in e || (e[s] = {}), e = e[s];
|
|
819
819
|
});
|
|
820
820
|
});
|
|
821
821
|
}
|
|
822
|
-
function
|
|
823
|
-
|
|
822
|
+
function ae(r) {
|
|
823
|
+
oe(), window.addEventListener("message", (t) => {
|
|
824
824
|
try {
|
|
825
|
-
const { eventType: e, eventData:
|
|
826
|
-
r(e,
|
|
825
|
+
const { eventType: e, eventData: s } = ne.parse(t.data);
|
|
826
|
+
r(e, s);
|
|
827
827
|
} catch {
|
|
828
828
|
}
|
|
829
829
|
});
|
|
830
830
|
}
|
|
831
|
-
function
|
|
831
|
+
function ce() {
|
|
832
832
|
return g({
|
|
833
833
|
req_id: h(),
|
|
834
834
|
data: (r) => r === null ? r : h().optional().parse(r)
|
|
835
835
|
});
|
|
836
836
|
}
|
|
837
|
-
function
|
|
837
|
+
function he() {
|
|
838
838
|
return g({
|
|
839
839
|
req_id: h(),
|
|
840
840
|
result: (r) => r,
|
|
841
841
|
error: h().optional()
|
|
842
842
|
});
|
|
843
843
|
}
|
|
844
|
-
function
|
|
844
|
+
function ue() {
|
|
845
845
|
return g({
|
|
846
846
|
slug: h(),
|
|
847
847
|
status: h()
|
|
848
848
|
});
|
|
849
849
|
}
|
|
850
|
-
function
|
|
850
|
+
function pe() {
|
|
851
851
|
return g({ status: h() });
|
|
852
852
|
}
|
|
853
|
-
function
|
|
853
|
+
function le() {
|
|
854
854
|
return g({
|
|
855
855
|
button_id: (r) => r == null ? void 0 : h().parse(r)
|
|
856
856
|
});
|
|
857
857
|
}
|
|
858
|
-
function
|
|
858
|
+
function de() {
|
|
859
859
|
return g({
|
|
860
860
|
data: h().optional()
|
|
861
861
|
});
|
|
862
862
|
}
|
|
863
|
-
function
|
|
863
|
+
function fe() {
|
|
864
864
|
return g({
|
|
865
865
|
theme_params: (r) => {
|
|
866
|
-
const t =
|
|
867
|
-
return Object.entries(
|
|
866
|
+
const t = gt().optional();
|
|
867
|
+
return Object.entries(Y(r)).reduce((e, [s, n]) => (e[s] = t.parse(n), e), {});
|
|
868
868
|
}
|
|
869
869
|
});
|
|
870
870
|
}
|
|
871
|
-
function
|
|
871
|
+
function ge() {
|
|
872
872
|
return g({
|
|
873
|
-
height:
|
|
874
|
-
width: (r) => r == null ? window.innerWidth :
|
|
875
|
-
is_state_stable:
|
|
876
|
-
is_expanded:
|
|
873
|
+
height: k(),
|
|
874
|
+
width: (r) => r == null ? window.innerWidth : k().parse(r),
|
|
875
|
+
is_state_stable: P(),
|
|
876
|
+
is_expanded: P()
|
|
877
877
|
});
|
|
878
878
|
}
|
|
879
|
-
function
|
|
879
|
+
function we() {
|
|
880
880
|
return g({ status: h() });
|
|
881
881
|
}
|
|
882
|
-
function
|
|
883
|
-
const r = new w(), t = (e, ...
|
|
884
|
-
|
|
882
|
+
function _e() {
|
|
883
|
+
const r = new w(), t = (e, ...s) => {
|
|
884
|
+
q.log("Emitting processed event:", e, ...s), r.emit(e, ...s);
|
|
885
885
|
};
|
|
886
886
|
return window.addEventListener("resize", () => {
|
|
887
887
|
t("viewport_changed", {
|
|
@@ -890,33 +890,33 @@ function ge() {
|
|
|
890
890
|
is_state_stable: !0,
|
|
891
891
|
is_expanded: !0
|
|
892
892
|
});
|
|
893
|
-
}),
|
|
894
|
-
|
|
893
|
+
}), ae((e, s) => {
|
|
894
|
+
q.log("Received raw event:", e, s);
|
|
895
895
|
try {
|
|
896
896
|
switch (e) {
|
|
897
897
|
case "viewport_changed":
|
|
898
|
-
return t(e,
|
|
898
|
+
return t(e, ge().parse(s));
|
|
899
899
|
case "theme_changed":
|
|
900
|
-
return t(e,
|
|
900
|
+
return t(e, fe().parse(s));
|
|
901
901
|
case "popup_closed":
|
|
902
902
|
return (
|
|
903
903
|
// Sent on desktop.
|
|
904
|
-
|
|
904
|
+
s == null ? t(e, {}) : t(e, le().parse(s))
|
|
905
905
|
);
|
|
906
906
|
case "set_custom_style":
|
|
907
|
-
return t(e, h().parse(
|
|
907
|
+
return t(e, h().parse(s));
|
|
908
908
|
case "qr_text_received":
|
|
909
|
-
return t(e,
|
|
909
|
+
return t(e, de().parse(s));
|
|
910
910
|
case "clipboard_text_received":
|
|
911
|
-
return t(e,
|
|
911
|
+
return t(e, ce().parse(s));
|
|
912
912
|
case "invoice_closed":
|
|
913
|
-
return t(e,
|
|
913
|
+
return t(e, ue().parse(s));
|
|
914
914
|
case "phone_requested":
|
|
915
|
-
return t("phone_requested",
|
|
915
|
+
return t("phone_requested", pe().parse(s));
|
|
916
916
|
case "custom_method_invoked":
|
|
917
|
-
return t("custom_method_invoked",
|
|
917
|
+
return t("custom_method_invoked", he().parse(s));
|
|
918
918
|
case "write_access_requested":
|
|
919
|
-
return t("write_access_requested",
|
|
919
|
+
return t("write_access_requested", we().parse(s));
|
|
920
920
|
case "main_button_pressed":
|
|
921
921
|
case "back_button_pressed":
|
|
922
922
|
case "settings_button_pressed":
|
|
@@ -924,51 +924,51 @@ function ge() {
|
|
|
924
924
|
case "reload_iframe":
|
|
925
925
|
return t(e);
|
|
926
926
|
default:
|
|
927
|
-
return t(e,
|
|
927
|
+
return t(e, s);
|
|
928
928
|
}
|
|
929
|
-
} catch (
|
|
930
|
-
|
|
929
|
+
} catch (n) {
|
|
930
|
+
q.error("Error processing event:", n);
|
|
931
931
|
}
|
|
932
932
|
}), r;
|
|
933
933
|
}
|
|
934
|
-
const
|
|
935
|
-
function
|
|
934
|
+
const Q = "telegram-mini-apps-cached-emitter";
|
|
935
|
+
function U() {
|
|
936
936
|
const r = window;
|
|
937
|
-
return r[
|
|
937
|
+
return r[Q] === void 0 && (r[Q] = _e()), r[Q];
|
|
938
938
|
}
|
|
939
|
-
function
|
|
940
|
-
|
|
939
|
+
function I(r, t) {
|
|
940
|
+
U().off(r, t);
|
|
941
941
|
}
|
|
942
|
-
function
|
|
943
|
-
return
|
|
942
|
+
function y(r, t) {
|
|
943
|
+
return U().on(r, t), () => I(r, t);
|
|
944
944
|
}
|
|
945
|
-
function
|
|
946
|
-
return
|
|
945
|
+
function or(r, t) {
|
|
946
|
+
return U().once(r, t), () => I(r, t);
|
|
947
947
|
}
|
|
948
|
-
function
|
|
949
|
-
|
|
948
|
+
function be(r) {
|
|
949
|
+
U().unsubscribe(r);
|
|
950
950
|
}
|
|
951
|
-
function
|
|
952
|
-
return
|
|
951
|
+
function ar(r) {
|
|
952
|
+
return U().subscribe(r), () => be(r);
|
|
953
953
|
}
|
|
954
|
-
function
|
|
955
|
-
const e = r.split("."),
|
|
956
|
-
for (let i = 0; i <
|
|
957
|
-
const a = parseInt(e[i] || "0", 10), c = parseInt(
|
|
954
|
+
function me(r, t) {
|
|
955
|
+
const e = r.split("."), s = t.split("."), n = Math.max(e.length, s.length);
|
|
956
|
+
for (let i = 0; i < n; i += 1) {
|
|
957
|
+
const a = parseInt(e[i] || "0", 10), c = parseInt(s[i] || "0", 10);
|
|
958
958
|
if (a !== c)
|
|
959
959
|
return a > c ? 1 : -1;
|
|
960
960
|
}
|
|
961
961
|
return 0;
|
|
962
962
|
}
|
|
963
|
-
function
|
|
964
|
-
return
|
|
963
|
+
function v(r, t) {
|
|
964
|
+
return me(r, t) <= 0;
|
|
965
965
|
}
|
|
966
|
-
function
|
|
966
|
+
function A(r, t, e) {
|
|
967
967
|
if (typeof e == "string") {
|
|
968
968
|
if (r === "web_app_open_link" && t === "try_instant_view")
|
|
969
|
-
return
|
|
969
|
+
return v("6.4", e);
|
|
970
970
|
if (r === "web_app_set_header_color" && t === "color")
|
|
971
|
-
return
|
|
971
|
+
return v("6.9", e);
|
|
972
972
|
}
|
|
973
973
|
switch (r) {
|
|
974
974
|
case "web_app_open_tg_link":
|
|
@@ -977,102 +977,125 @@ function q(r, t, e) {
|
|
|
977
977
|
case "web_app_set_background_color":
|
|
978
978
|
case "web_app_set_header_color":
|
|
979
979
|
case "web_app_trigger_haptic_feedback":
|
|
980
|
-
return
|
|
980
|
+
return v("6.1", t);
|
|
981
981
|
case "web_app_open_popup":
|
|
982
|
-
return
|
|
982
|
+
return v("6.2", t);
|
|
983
983
|
case "web_app_close_scan_qr_popup":
|
|
984
984
|
case "web_app_open_scan_qr_popup":
|
|
985
985
|
case "web_app_read_text_from_clipboard":
|
|
986
|
-
return
|
|
986
|
+
return v("6.4", t);
|
|
987
987
|
case "web_app_switch_inline_query":
|
|
988
|
-
return
|
|
988
|
+
return v("6.7", t);
|
|
989
989
|
case "web_app_invoke_custom_method":
|
|
990
990
|
case "web_app_request_write_access":
|
|
991
991
|
case "web_app_request_phone":
|
|
992
|
-
return
|
|
992
|
+
return v("6.9", t);
|
|
993
993
|
case "web_app_setup_settings_button":
|
|
994
|
-
return
|
|
994
|
+
return v("6.10", t);
|
|
995
995
|
default:
|
|
996
996
|
return !0;
|
|
997
997
|
}
|
|
998
998
|
}
|
|
999
|
-
function
|
|
1000
|
-
return (e) =>
|
|
999
|
+
function E(r, t) {
|
|
1000
|
+
return (e) => A(t[e], r);
|
|
1001
1001
|
}
|
|
1002
|
-
function
|
|
1002
|
+
function kt(r, t) {
|
|
1003
1003
|
return (e) => {
|
|
1004
|
-
const [
|
|
1005
|
-
return
|
|
1004
|
+
const [s, n] = t[e];
|
|
1005
|
+
return A(s, n, r);
|
|
1006
1006
|
};
|
|
1007
1007
|
}
|
|
1008
1008
|
function f(r, t, e) {
|
|
1009
|
-
let
|
|
1010
|
-
t === void 0 && e === void 0 ?
|
|
1011
|
-
const { targetOrigin: i =
|
|
1012
|
-
if (
|
|
1009
|
+
let s = {}, n;
|
|
1010
|
+
t === void 0 && e === void 0 ? s = {} : t !== void 0 && e !== void 0 ? (s = e, n = t) : t !== void 0 && ("targetOrigin" in t ? s = t : n = t);
|
|
1011
|
+
const { targetOrigin: i = se() } = s;
|
|
1012
|
+
if (q.log(`Calling method "${r}"`, n), vt()) {
|
|
1013
1013
|
window.parent.postMessage(JSON.stringify({
|
|
1014
1014
|
eventType: r,
|
|
1015
|
-
eventData:
|
|
1015
|
+
eventData: n
|
|
1016
1016
|
}), i);
|
|
1017
1017
|
return;
|
|
1018
1018
|
}
|
|
1019
|
-
if (
|
|
1020
|
-
window.external.notify(JSON.stringify({ eventType: r, eventData:
|
|
1019
|
+
if (ee(window)) {
|
|
1020
|
+
window.external.notify(JSON.stringify({ eventType: r, eventData: n }));
|
|
1021
1021
|
return;
|
|
1022
1022
|
}
|
|
1023
|
-
if (
|
|
1024
|
-
window.TelegramWebviewProxy.postEvent(r, JSON.stringify(
|
|
1023
|
+
if (re(window)) {
|
|
1024
|
+
window.TelegramWebviewProxy.postEvent(r, JSON.stringify(n));
|
|
1025
1025
|
return;
|
|
1026
1026
|
}
|
|
1027
1027
|
throw new Error(
|
|
1028
1028
|
"Unable to determine current environment and possible way to send event."
|
|
1029
1029
|
);
|
|
1030
1030
|
}
|
|
1031
|
-
function
|
|
1031
|
+
function ye(r) {
|
|
1032
1032
|
return (t, e) => {
|
|
1033
|
-
if (!
|
|
1034
|
-
throw new
|
|
1035
|
-
if (
|
|
1036
|
-
let
|
|
1037
|
-
if (t === "web_app_open_link" && "try_instant_view" in e ?
|
|
1038
|
-
throw new
|
|
1033
|
+
if (!A(t, r))
|
|
1034
|
+
throw new tt(t, r);
|
|
1035
|
+
if (H(e)) {
|
|
1036
|
+
let s;
|
|
1037
|
+
if (t === "web_app_open_link" && "try_instant_view" in e ? s = "try_instant_view" : t === "web_app_set_header_color" && "color" in e && (s = "color"), s && !A(t, s, r))
|
|
1038
|
+
throw new et(t, s, r);
|
|
1039
1039
|
}
|
|
1040
1040
|
return f(t, e);
|
|
1041
1041
|
};
|
|
1042
1042
|
}
|
|
1043
|
-
class
|
|
1043
|
+
class J extends Error {
|
|
1044
1044
|
constructor(t) {
|
|
1045
|
-
super(`Async call timeout exceeded. Timeout: ${t}`), Object.setPrototypeOf(this,
|
|
1045
|
+
super(`Async call timeout exceeded. Timeout: ${t}`), Object.setPrototypeOf(this, J.prototype);
|
|
1046
1046
|
}
|
|
1047
1047
|
}
|
|
1048
|
-
function
|
|
1048
|
+
function cr(r) {
|
|
1049
|
+
return r instanceof J;
|
|
1050
|
+
}
|
|
1051
|
+
function Ee(r) {
|
|
1052
|
+
return new Promise((t) => {
|
|
1053
|
+
setTimeout(t, r);
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
function Ce(r) {
|
|
1049
1057
|
return new Promise((t, e) => {
|
|
1050
|
-
setTimeout(e, r, new
|
|
1058
|
+
setTimeout(e, r, new J(r));
|
|
1051
1059
|
});
|
|
1052
1060
|
}
|
|
1053
|
-
function
|
|
1054
|
-
return
|
|
1055
|
-
r(
|
|
1056
|
-
|
|
1057
|
-
])
|
|
1058
|
-
}
|
|
1059
|
-
function
|
|
1060
|
-
let
|
|
1061
|
-
typeof t == "string" || Array.isArray(t) ? (a = Array.isArray(t) ? t : [t],
|
|
1062
|
-
const { postEvent: u = f, timeout:
|
|
1063
|
-
const x = a.map((
|
|
1064
|
-
|
|
1065
|
-
})),
|
|
1061
|
+
function xt(r, t) {
|
|
1062
|
+
return Promise.race([
|
|
1063
|
+
r(),
|
|
1064
|
+
Ce(t)
|
|
1065
|
+
]);
|
|
1066
|
+
}
|
|
1067
|
+
function m(r, t, e, s) {
|
|
1068
|
+
let n, i, a, c;
|
|
1069
|
+
typeof t == "string" || Array.isArray(t) ? (a = Array.isArray(t) ? t : [t], n = e) : (i = t, a = Array.isArray(e) ? e : [e], n = s), H(i) && typeof i.req_id == "string" && (c = i.req_id);
|
|
1070
|
+
const { postEvent: u = f, timeout: p } = n || {}, l = n && "capture" in n ? n.capture : null, b = () => new Promise((d, C) => {
|
|
1071
|
+
const x = a.map((B) => y(B, (M) => {
|
|
1072
|
+
c && (!H(M) || M.req_id !== c) || typeof l == "function" && !l(M) || (T(), d(M));
|
|
1073
|
+
})), T = () => x.forEach((B) => B());
|
|
1066
1074
|
try {
|
|
1067
1075
|
u(r, i);
|
|
1068
|
-
} catch (
|
|
1069
|
-
|
|
1076
|
+
} catch (B) {
|
|
1077
|
+
T(), C(B);
|
|
1070
1078
|
}
|
|
1071
1079
|
});
|
|
1072
|
-
return typeof
|
|
1080
|
+
return typeof p == "number" ? xt(b, p) : b();
|
|
1081
|
+
}
|
|
1082
|
+
async function N(r, t, e, s = {}) {
|
|
1083
|
+
const { result: n, error: i } = await m(
|
|
1084
|
+
"web_app_invoke_custom_method",
|
|
1085
|
+
{
|
|
1086
|
+
method: r,
|
|
1087
|
+
params: t,
|
|
1088
|
+
req_id: e
|
|
1089
|
+
},
|
|
1090
|
+
"custom_method_invoked",
|
|
1091
|
+
s
|
|
1092
|
+
);
|
|
1093
|
+
if (i)
|
|
1094
|
+
throw new Error(i);
|
|
1095
|
+
return n;
|
|
1073
1096
|
}
|
|
1074
|
-
class
|
|
1075
|
-
constructor(t, e,
|
|
1097
|
+
class ve {
|
|
1098
|
+
constructor(t, e, s = f) {
|
|
1076
1099
|
o(this, "ee", new w());
|
|
1077
1100
|
o(this, "state");
|
|
1078
1101
|
/**
|
|
@@ -1080,18 +1103,18 @@ class ye {
|
|
|
1080
1103
|
* @param event - event name.
|
|
1081
1104
|
* @param listener - event listener.
|
|
1082
1105
|
*/
|
|
1083
|
-
o(this, "on", (t, e) => t === "click" ?
|
|
1106
|
+
o(this, "on", (t, e) => t === "click" ? y("back_button_pressed", e) : this.ee.on(t, e));
|
|
1084
1107
|
/**
|
|
1085
1108
|
* Removes event listener.
|
|
1086
1109
|
* @param event - event name.
|
|
1087
1110
|
* @param listener - event listener.
|
|
1088
1111
|
*/
|
|
1089
|
-
o(this, "off", (t, e) => t === "click" ?
|
|
1112
|
+
o(this, "off", (t, e) => t === "click" ? I("back_button_pressed", e) : this.ee.off(t, e));
|
|
1090
1113
|
/**
|
|
1091
1114
|
* Checks if specified method is supported by current component.
|
|
1092
1115
|
*/
|
|
1093
1116
|
o(this, "supports");
|
|
1094
|
-
this.postEvent =
|
|
1117
|
+
this.postEvent = s, this.state = new _({ isVisible: t }, this.ee), this.supports = E(e, {
|
|
1095
1118
|
show: "web_app_setup_back_button",
|
|
1096
1119
|
hide: "web_app_setup_back_button"
|
|
1097
1120
|
});
|
|
@@ -1121,22 +1144,22 @@ class ye {
|
|
|
1121
1144
|
function nt(r, t) {
|
|
1122
1145
|
return r + (r.length > 0 && t.length > 0 ? ` ${t}` : t);
|
|
1123
1146
|
}
|
|
1124
|
-
function
|
|
1147
|
+
function Pe(...r) {
|
|
1125
1148
|
return r.reduce((t, e) => {
|
|
1126
|
-
let
|
|
1127
|
-
return typeof e == "string" ?
|
|
1149
|
+
let s = "";
|
|
1150
|
+
return typeof e == "string" ? s = e : typeof e == "object" && e !== null && (s = Object.entries(e).reduce((n, [i, a]) => a ? nt(n, i) : n, "")), nt(t, s);
|
|
1128
1151
|
}, "");
|
|
1129
1152
|
}
|
|
1130
|
-
function
|
|
1153
|
+
function Se(r) {
|
|
1131
1154
|
return typeof r == "object" && r !== null && !Array.isArray(null);
|
|
1132
1155
|
}
|
|
1133
|
-
function
|
|
1134
|
-
return r.reduce((t, e) => (
|
|
1135
|
-
const i =
|
|
1136
|
-
i.length > 0 && (t[
|
|
1156
|
+
function hr(...r) {
|
|
1157
|
+
return r.reduce((t, e) => (Se(e) && Object.entries(e).forEach(([s, n]) => {
|
|
1158
|
+
const i = Pe(t[s], n);
|
|
1159
|
+
i.length > 0 && (t[s] = i);
|
|
1137
1160
|
}), t), {});
|
|
1138
1161
|
}
|
|
1139
|
-
class
|
|
1162
|
+
class ke {
|
|
1140
1163
|
constructor(t, e = f) {
|
|
1141
1164
|
o(this, "ee", new w());
|
|
1142
1165
|
o(this, "state");
|
|
@@ -1148,7 +1171,7 @@ class ve {
|
|
|
1148
1171
|
* Removes event listener.
|
|
1149
1172
|
*/
|
|
1150
1173
|
o(this, "off", this.ee.off.bind(this.ee));
|
|
1151
|
-
this.postEvent = e, this.state = new
|
|
1174
|
+
this.postEvent = e, this.state = new _({ isConfirmationNeeded: t }, this.ee);
|
|
1152
1175
|
}
|
|
1153
1176
|
set isConfirmationNeeded(t) {
|
|
1154
1177
|
this.state.set("isConfirmationNeeded", t), this.postEvent("web_app_setup_closing_behavior", { need_confirmation: t });
|
|
@@ -1175,63 +1198,61 @@ class ve {
|
|
|
1175
1198
|
this.isConfirmationNeeded = !0;
|
|
1176
1199
|
}
|
|
1177
1200
|
}
|
|
1178
|
-
function
|
|
1179
|
-
return r.reduce((e,
|
|
1201
|
+
function it(r, t) {
|
|
1202
|
+
return r.reduce((e, s) => (e[s] = t, e), {});
|
|
1180
1203
|
}
|
|
1181
|
-
class
|
|
1182
|
-
constructor(t, e,
|
|
1204
|
+
class xe {
|
|
1205
|
+
constructor(t, e, s = f) {
|
|
1183
1206
|
/**
|
|
1184
1207
|
* Checks if specified method is supported by current component.
|
|
1185
1208
|
*/
|
|
1186
1209
|
o(this, "supports");
|
|
1187
|
-
this.createRequestId = e, this.postEvent =
|
|
1210
|
+
this.createRequestId = e, this.postEvent = s, this.supports = E(t, {
|
|
1188
1211
|
delete: "web_app_invoke_custom_method",
|
|
1189
1212
|
get: "web_app_invoke_custom_method",
|
|
1190
1213
|
getKeys: "web_app_invoke_custom_method",
|
|
1191
1214
|
set: "web_app_invoke_custom_method"
|
|
1192
1215
|
});
|
|
1193
1216
|
}
|
|
1194
|
-
/**
|
|
1195
|
-
* Invokes custom method related to CloudStorage.
|
|
1196
|
-
* @param method - method name.
|
|
1197
|
-
* @param params - method parameters.
|
|
1198
|
-
* @param options - execution options.
|
|
1199
|
-
*/
|
|
1200
|
-
async invokeCustomMethod(t, e, n = {}) {
|
|
1201
|
-
const { result: s, error: i } = await _(
|
|
1202
|
-
"web_app_invoke_custom_method",
|
|
1203
|
-
{ method: t, params: e, req_id: this.createRequestId() },
|
|
1204
|
-
"custom_method_invoked",
|
|
1205
|
-
{ ...n, postEvent: this.postEvent }
|
|
1206
|
-
);
|
|
1207
|
-
if (i)
|
|
1208
|
-
throw new Error(i);
|
|
1209
|
-
return s;
|
|
1210
|
-
}
|
|
1211
1217
|
/**
|
|
1212
1218
|
* Deletes specified key or keys from the cloud storage.
|
|
1213
1219
|
* @param keyOrKeys - key or keys to delete.
|
|
1214
1220
|
* @param options - request execution options.
|
|
1215
1221
|
*/
|
|
1216
|
-
async delete(t, e) {
|
|
1217
|
-
const
|
|
1218
|
-
|
|
1222
|
+
async delete(t, e = {}) {
|
|
1223
|
+
const s = Array.isArray(t) ? t : [t];
|
|
1224
|
+
s.length !== 0 && await N(
|
|
1225
|
+
"deleteStorageValues",
|
|
1226
|
+
{ keys: s },
|
|
1227
|
+
this.createRequestId(),
|
|
1228
|
+
{ ...e, postEvent: this.postEvent }
|
|
1229
|
+
);
|
|
1219
1230
|
}
|
|
1220
1231
|
/**
|
|
1221
1232
|
* Returns list of all keys presented in the cloud storage.
|
|
1222
1233
|
* @param options - request execution options.
|
|
1223
1234
|
*/
|
|
1224
|
-
async getKeys(t) {
|
|
1225
|
-
const e = await
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
+
async getKeys(t = {}) {
|
|
1236
|
+
const e = await N(
|
|
1237
|
+
"getStorageKeys",
|
|
1238
|
+
{},
|
|
1239
|
+
this.createRequestId(),
|
|
1240
|
+
{ ...t, postEvent: this.postEvent }
|
|
1241
|
+
);
|
|
1242
|
+
return Nt().of(h()).parse(e);
|
|
1243
|
+
}
|
|
1244
|
+
async get(t, e = {}) {
|
|
1245
|
+
const s = Array.isArray(t) ? t : [t];
|
|
1246
|
+
if (s.length === 0)
|
|
1247
|
+
return it(s, "");
|
|
1248
|
+
const n = g(
|
|
1249
|
+
it(s, h())
|
|
1250
|
+
), i = await N(
|
|
1251
|
+
"getStorageValues",
|
|
1252
|
+
{ keys: s },
|
|
1253
|
+
this.createRequestId(),
|
|
1254
|
+
{ ...e, postEvent: this.postEvent }
|
|
1255
|
+
).then((a) => n.parse(a));
|
|
1235
1256
|
return Array.isArray(t) ? i : i[t];
|
|
1236
1257
|
}
|
|
1237
1258
|
/**
|
|
@@ -1240,17 +1261,22 @@ class ke {
|
|
|
1240
1261
|
* @param value - storage value.
|
|
1241
1262
|
* @param options - request execution options.
|
|
1242
1263
|
*/
|
|
1243
|
-
async set(t, e,
|
|
1244
|
-
await
|
|
1264
|
+
async set(t, e, s = {}) {
|
|
1265
|
+
await N(
|
|
1266
|
+
"saveStorageValue",
|
|
1267
|
+
{ key: t, value: e },
|
|
1268
|
+
this.createRequestId(),
|
|
1269
|
+
{ ...s, postEvent: this.postEvent }
|
|
1270
|
+
);
|
|
1245
1271
|
}
|
|
1246
1272
|
}
|
|
1247
|
-
class
|
|
1273
|
+
class qe {
|
|
1248
1274
|
constructor(t, e = f) {
|
|
1249
1275
|
/**
|
|
1250
1276
|
* Checks if specified method is supported by current component.
|
|
1251
1277
|
*/
|
|
1252
1278
|
o(this, "supports");
|
|
1253
|
-
this.postEvent = e, this.supports =
|
|
1279
|
+
this.postEvent = e, this.supports = E(t, {
|
|
1254
1280
|
impactOccurred: "web_app_trigger_haptic_feedback",
|
|
1255
1281
|
notificationOccurred: "web_app_trigger_haptic_feedback",
|
|
1256
1282
|
selectionChanged: "web_app_trigger_haptic_feedback"
|
|
@@ -1290,35 +1316,35 @@ class Se {
|
|
|
1290
1316
|
this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
|
|
1291
1317
|
}
|
|
1292
1318
|
}
|
|
1293
|
-
function
|
|
1319
|
+
function Ae() {
|
|
1294
1320
|
const r = document.createElement("style");
|
|
1295
|
-
r.id = "telegram-custom-styles", document.head.appendChild(r),
|
|
1321
|
+
r.id = "telegram-custom-styles", document.head.appendChild(r), y("set_custom_style", (t) => {
|
|
1296
1322
|
r.innerHTML = t;
|
|
1297
1323
|
});
|
|
1298
1324
|
}
|
|
1299
|
-
function
|
|
1325
|
+
function qt(r) {
|
|
1300
1326
|
return `telegram-mini-apps-${r}`;
|
|
1301
1327
|
}
|
|
1302
|
-
function
|
|
1303
|
-
sessionStorage.setItem(
|
|
1328
|
+
function L(r, t) {
|
|
1329
|
+
sessionStorage.setItem(qt(r), JSON.stringify(t));
|
|
1304
1330
|
}
|
|
1305
|
-
function
|
|
1306
|
-
const t = sessionStorage.getItem(
|
|
1331
|
+
function $(r) {
|
|
1332
|
+
const t = sessionStorage.getItem(qt(r));
|
|
1307
1333
|
return t ? JSON.parse(t) : null;
|
|
1308
1334
|
}
|
|
1309
|
-
function
|
|
1310
|
-
const { isVisible:
|
|
1311
|
-
return
|
|
1312
|
-
|
|
1313
|
-
}),
|
|
1335
|
+
function Re(r, t, e) {
|
|
1336
|
+
const { isVisible: s = !1 } = r ? $("back-button") || {} : {}, n = new ve(s, t, e);
|
|
1337
|
+
return n.on("change", () => {
|
|
1338
|
+
L("back-button", { isVisible: n.isVisible });
|
|
1339
|
+
}), n;
|
|
1314
1340
|
}
|
|
1315
|
-
function
|
|
1316
|
-
const { isConfirmationNeeded: e = !1 } = r ?
|
|
1317
|
-
return
|
|
1318
|
-
isConfirmationNeeded:
|
|
1319
|
-
})),
|
|
1341
|
+
function Ve(r, t) {
|
|
1342
|
+
const { isConfirmationNeeded: e = !1 } = r ? $("closing-behavior") || {} : {}, s = new ke(e, t);
|
|
1343
|
+
return s.on("change", () => L("closing-behavior", {
|
|
1344
|
+
isConfirmationNeeded: s.isConfirmationNeeded
|
|
1345
|
+
})), s;
|
|
1320
1346
|
}
|
|
1321
|
-
class
|
|
1347
|
+
class Ie {
|
|
1322
1348
|
constructor(t) {
|
|
1323
1349
|
o(this, "ee", new w());
|
|
1324
1350
|
o(this, "state");
|
|
@@ -1332,30 +1358,30 @@ class qe {
|
|
|
1332
1358
|
// FIXME: Event 'main_button_pressed' is still being received on Android
|
|
1333
1359
|
// even if the main button is disabled.
|
|
1334
1360
|
// Issue: https://github.com/Telegram-Mini-Apps/tma.js/issues/3
|
|
1335
|
-
t === "click" ?
|
|
1361
|
+
t === "click" ? y("main_button_pressed", e) : this.ee.on(t, e)
|
|
1336
1362
|
));
|
|
1337
1363
|
/**
|
|
1338
1364
|
* Removes event listener.
|
|
1339
1365
|
* @param event - event name.
|
|
1340
1366
|
* @param listener - event listener.
|
|
1341
1367
|
*/
|
|
1342
|
-
o(this, "off", (t, e) => t === "click" ?
|
|
1368
|
+
o(this, "off", (t, e) => t === "click" ? I("main_button_pressed", e) : this.ee.off(t, e));
|
|
1343
1369
|
const {
|
|
1344
1370
|
postEvent: e = f,
|
|
1345
|
-
text:
|
|
1346
|
-
textColor:
|
|
1371
|
+
text: s,
|
|
1372
|
+
textColor: n,
|
|
1347
1373
|
backgroundColor: i,
|
|
1348
1374
|
isEnabled: a,
|
|
1349
1375
|
isVisible: c,
|
|
1350
1376
|
isLoaderVisible: u
|
|
1351
1377
|
} = t;
|
|
1352
|
-
this.postEvent = e, this.state = new
|
|
1378
|
+
this.postEvent = e, this.state = new _({
|
|
1353
1379
|
backgroundColor: i,
|
|
1354
1380
|
isEnabled: a,
|
|
1355
1381
|
isVisible: c,
|
|
1356
1382
|
isLoaderVisible: u,
|
|
1357
|
-
text:
|
|
1358
|
-
textColor:
|
|
1383
|
+
text: s,
|
|
1384
|
+
textColor: n
|
|
1359
1385
|
}, this.ee);
|
|
1360
1386
|
}
|
|
1361
1387
|
/**
|
|
@@ -1483,38 +1509,66 @@ class qe {
|
|
|
1483
1509
|
return this.state.set(t), this.commit(), this;
|
|
1484
1510
|
}
|
|
1485
1511
|
}
|
|
1486
|
-
function Le(r, t, e,
|
|
1512
|
+
function Le(r, t, e, s) {
|
|
1487
1513
|
const {
|
|
1488
|
-
backgroundColor:
|
|
1514
|
+
backgroundColor: n = t,
|
|
1489
1515
|
isEnabled: i = !1,
|
|
1490
1516
|
isVisible: a = !1,
|
|
1491
1517
|
isLoaderVisible: c = !1,
|
|
1492
1518
|
textColor: u = e,
|
|
1493
|
-
text:
|
|
1494
|
-
} = r ?
|
|
1495
|
-
backgroundColor:
|
|
1519
|
+
text: p = ""
|
|
1520
|
+
} = r ? $("main-button") || {} : {}, l = new Ie({
|
|
1521
|
+
backgroundColor: n,
|
|
1496
1522
|
isEnabled: i,
|
|
1497
1523
|
isLoaderVisible: c,
|
|
1498
1524
|
isVisible: a,
|
|
1499
|
-
postEvent:
|
|
1500
|
-
text:
|
|
1525
|
+
postEvent: s,
|
|
1526
|
+
text: p,
|
|
1501
1527
|
textColor: u
|
|
1502
|
-
}),
|
|
1503
|
-
backgroundColor:
|
|
1504
|
-
isEnabled:
|
|
1505
|
-
isLoaderVisible:
|
|
1506
|
-
isVisible:
|
|
1507
|
-
text:
|
|
1508
|
-
textColor:
|
|
1528
|
+
}), b = () => L("main-button", {
|
|
1529
|
+
backgroundColor: l.backgroundColor,
|
|
1530
|
+
isEnabled: l.isEnabled,
|
|
1531
|
+
isLoaderVisible: l.isLoaderVisible,
|
|
1532
|
+
isVisible: l.isVisible,
|
|
1533
|
+
text: l.text,
|
|
1534
|
+
textColor: l.textColor
|
|
1509
1535
|
});
|
|
1510
|
-
return
|
|
1536
|
+
return l.on("change", b), l;
|
|
1511
1537
|
}
|
|
1512
|
-
|
|
1538
|
+
const $e = X({
|
|
1539
|
+
contact: g({
|
|
1540
|
+
userId: {
|
|
1541
|
+
type: k(),
|
|
1542
|
+
from: "user_id"
|
|
1543
|
+
},
|
|
1544
|
+
phoneNumber: {
|
|
1545
|
+
type: h(),
|
|
1546
|
+
from: "phone_number"
|
|
1547
|
+
},
|
|
1548
|
+
firstName: {
|
|
1549
|
+
type: h(),
|
|
1550
|
+
from: "first_name"
|
|
1551
|
+
},
|
|
1552
|
+
lastName: {
|
|
1553
|
+
type: h(),
|
|
1554
|
+
from: "last_name"
|
|
1555
|
+
}
|
|
1556
|
+
}),
|
|
1557
|
+
authDate: {
|
|
1558
|
+
type: pt(),
|
|
1559
|
+
from: "auth_date"
|
|
1560
|
+
},
|
|
1561
|
+
hash: h()
|
|
1562
|
+
});
|
|
1563
|
+
class Te {
|
|
1513
1564
|
constructor(t) {
|
|
1514
1565
|
o(this, "ee", new w());
|
|
1515
1566
|
o(this, "state");
|
|
1516
1567
|
o(this, "botInline");
|
|
1517
1568
|
o(this, "postEvent");
|
|
1569
|
+
o(this, "createRequestId");
|
|
1570
|
+
o(this, "requestingPhoneAccess", !1);
|
|
1571
|
+
o(this, "requestingWriteAccess", !1);
|
|
1518
1572
|
/**
|
|
1519
1573
|
* Adds new event listener.
|
|
1520
1574
|
*/
|
|
@@ -1533,21 +1587,36 @@ class $e {
|
|
|
1533
1587
|
o(this, "supportsParam");
|
|
1534
1588
|
const {
|
|
1535
1589
|
postEvent: e = f,
|
|
1536
|
-
headerColor:
|
|
1537
|
-
backgroundColor:
|
|
1590
|
+
headerColor: s,
|
|
1591
|
+
backgroundColor: n,
|
|
1538
1592
|
version: i,
|
|
1539
|
-
botInline: a
|
|
1540
|
-
|
|
1593
|
+
botInline: a,
|
|
1594
|
+
createRequestId: c
|
|
1595
|
+
} = t, u = E(i, {
|
|
1541
1596
|
requestPhoneAccess: "web_app_request_phone",
|
|
1542
1597
|
requestWriteAccess: "web_app_request_write_access",
|
|
1543
1598
|
switchInlineQuery: "web_app_switch_inline_query",
|
|
1544
1599
|
setHeaderColor: "web_app_set_header_color",
|
|
1545
1600
|
setBackgroundColor: "web_app_set_background_color"
|
|
1546
1601
|
});
|
|
1547
|
-
this.postEvent = e, this.botInline = a, this.supports = (
|
|
1602
|
+
this.postEvent = e, this.botInline = a, this.createRequestId = c, this.supports = (p) => !(!u(p) || p === "switchInlineQuery" && !a), this.state = new _({ backgroundColor: n, headerColor: s }, this.ee), this.supportsParam = kt(i, {
|
|
1548
1603
|
"setHeaderColor.color": ["web_app_set_header_color", "color"]
|
|
1549
1604
|
});
|
|
1550
1605
|
}
|
|
1606
|
+
/**
|
|
1607
|
+
* Attempts to get requested contact.
|
|
1608
|
+
*/
|
|
1609
|
+
async getRequestedContact() {
|
|
1610
|
+
return N(
|
|
1611
|
+
"getRequestedContact",
|
|
1612
|
+
{},
|
|
1613
|
+
this.createRequestId(),
|
|
1614
|
+
{
|
|
1615
|
+
postEvent: this.postEvent,
|
|
1616
|
+
timeout: 1e4
|
|
1617
|
+
}
|
|
1618
|
+
).then((t) => $e.parse(t));
|
|
1619
|
+
}
|
|
1551
1620
|
/**
|
|
1552
1621
|
* The Mini App background color.
|
|
1553
1622
|
*/
|
|
@@ -1576,7 +1645,19 @@ class $e {
|
|
|
1576
1645
|
* True if current Mini App background color recognized as dark.
|
|
1577
1646
|
*/
|
|
1578
1647
|
get isDark() {
|
|
1579
|
-
return
|
|
1648
|
+
return ft(this.backgroundColor);
|
|
1649
|
+
}
|
|
1650
|
+
/**
|
|
1651
|
+
* True if phone access is currently being requested.
|
|
1652
|
+
*/
|
|
1653
|
+
get isRequestingPhoneAccess() {
|
|
1654
|
+
return this.requestingPhoneAccess;
|
|
1655
|
+
}
|
|
1656
|
+
/**
|
|
1657
|
+
* True if write access is currently being requested.
|
|
1658
|
+
*/
|
|
1659
|
+
get isRequestingWriteAccess() {
|
|
1660
|
+
return this.requestingWriteAccess;
|
|
1580
1661
|
}
|
|
1581
1662
|
/**
|
|
1582
1663
|
* Informs the Telegram app that the Mini App is ready to be displayed.
|
|
@@ -1591,24 +1672,63 @@ class $e {
|
|
|
1591
1672
|
this.postEvent("web_app_ready");
|
|
1592
1673
|
}
|
|
1593
1674
|
/**
|
|
1594
|
-
* Requests current user
|
|
1675
|
+
* Requests current user contact information. In contrary to requestPhoneAccess, this method
|
|
1676
|
+
* returns promise with contact information that rejects in case, user denied access, or request
|
|
1677
|
+
* failed.
|
|
1678
|
+
* @param options - additional options.
|
|
1595
1679
|
*/
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1680
|
+
async requestContact({ timeout: t = 5e3 } = {}) {
|
|
1681
|
+
try {
|
|
1682
|
+
return await this.getRequestedContact();
|
|
1683
|
+
} catch {
|
|
1684
|
+
}
|
|
1685
|
+
if (await this.requestPhoneAccess() !== "sent")
|
|
1686
|
+
throw new Error("Access denied.");
|
|
1687
|
+
const s = Date.now() + t;
|
|
1688
|
+
let n = 50;
|
|
1689
|
+
return xt(async () => {
|
|
1690
|
+
for (; Date.now() < s; ) {
|
|
1691
|
+
try {
|
|
1692
|
+
return await this.getRequestedContact();
|
|
1693
|
+
} catch {
|
|
1694
|
+
}
|
|
1695
|
+
await Ee(n), n += 50;
|
|
1696
|
+
}
|
|
1697
|
+
throw new Error("Unable to retrieve requested contact.");
|
|
1698
|
+
}, t);
|
|
1699
|
+
}
|
|
1700
|
+
/**
|
|
1701
|
+
* Requests current user phone access. Method returns promise, which resolves
|
|
1702
|
+
* status of the request. In case, user accepted the request, Mini App bot will receive
|
|
1703
|
+
* the according notification.
|
|
1704
|
+
*
|
|
1705
|
+
* To obtain the retrieved information instead, utilize the requestContact method.
|
|
1706
|
+
* @param options - additional options.
|
|
1707
|
+
* @see requestContact
|
|
1708
|
+
*/
|
|
1709
|
+
requestPhoneAccess(t = {}) {
|
|
1710
|
+
if (this.requestingPhoneAccess)
|
|
1711
|
+
throw new Error("Phone access is already being requested.");
|
|
1712
|
+
return this.requestingPhoneAccess = !0, m("web_app_request_phone", "phone_requested", {
|
|
1713
|
+
...t,
|
|
1714
|
+
postEvent: this.postEvent
|
|
1715
|
+
}).then((e) => e.status).finally(() => {
|
|
1716
|
+
this.requestingPhoneAccess = !1;
|
|
1717
|
+
});
|
|
1602
1718
|
}
|
|
1603
1719
|
/**
|
|
1604
1720
|
* Requests write message access to current user.
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
"
|
|
1610
|
-
|
|
1611
|
-
|
|
1721
|
+
* @param options - additional options.
|
|
1722
|
+
*/
|
|
1723
|
+
requestWriteAccess(t = {}) {
|
|
1724
|
+
if (this.requestingWriteAccess)
|
|
1725
|
+
throw new Error("Write access is already being requested.");
|
|
1726
|
+
return this.requestingWriteAccess = !0, m("web_app_request_write_access", "write_access_requested", {
|
|
1727
|
+
...t,
|
|
1728
|
+
postEvent: this.postEvent
|
|
1729
|
+
}).then((e) => e.status).finally(() => {
|
|
1730
|
+
this.requestingWriteAccess = !1;
|
|
1731
|
+
});
|
|
1612
1732
|
}
|
|
1613
1733
|
/**
|
|
1614
1734
|
* A method used to send data to the bot. When this method called, a service message sent to
|
|
@@ -1630,7 +1750,7 @@ class $e {
|
|
|
1630
1750
|
* @param color - color key or RGB color.
|
|
1631
1751
|
*/
|
|
1632
1752
|
setHeaderColor(t) {
|
|
1633
|
-
this.postEvent("web_app_set_header_color",
|
|
1753
|
+
this.postEvent("web_app_set_header_color", lt(t) ? { color: t } : { color_key: t }), this.state.set("headerColor", t);
|
|
1634
1754
|
}
|
|
1635
1755
|
/**
|
|
1636
1756
|
* Updates current Mini App background color.
|
|
@@ -1658,32 +1778,86 @@ class $e {
|
|
|
1658
1778
|
});
|
|
1659
1779
|
}
|
|
1660
1780
|
}
|
|
1661
|
-
function
|
|
1781
|
+
function Be(r, t, e, s, n, i) {
|
|
1662
1782
|
const {
|
|
1663
|
-
backgroundColor:
|
|
1664
|
-
headerColor:
|
|
1665
|
-
} = r ?
|
|
1666
|
-
headerColor:
|
|
1667
|
-
backgroundColor:
|
|
1783
|
+
backgroundColor: a = t,
|
|
1784
|
+
headerColor: c = "bg_color"
|
|
1785
|
+
} = r ? $("mini-app") || {} : {}, u = new Te({
|
|
1786
|
+
headerColor: c,
|
|
1787
|
+
backgroundColor: a,
|
|
1668
1788
|
version: e,
|
|
1669
|
-
botInline:
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1789
|
+
botInline: s,
|
|
1790
|
+
createRequestId: n,
|
|
1791
|
+
postEvent: i
|
|
1792
|
+
}), p = () => L("mini-app", {
|
|
1793
|
+
backgroundColor: u.backgroundColor,
|
|
1794
|
+
headerColor: u.headerColor
|
|
1674
1795
|
});
|
|
1675
|
-
return
|
|
1796
|
+
return u.on("change", p), u;
|
|
1676
1797
|
}
|
|
1677
|
-
function
|
|
1798
|
+
function De() {
|
|
1678
1799
|
let r = 0;
|
|
1679
1800
|
return () => (r += 1, r.toString());
|
|
1680
1801
|
}
|
|
1681
|
-
|
|
1682
|
-
|
|
1802
|
+
class We {
|
|
1803
|
+
constructor(t, e, s = f) {
|
|
1804
|
+
o(this, "ee", new w());
|
|
1805
|
+
o(this, "state");
|
|
1806
|
+
/**
|
|
1807
|
+
* Adds event listener.
|
|
1808
|
+
* @param event - event name.
|
|
1809
|
+
* @param listener - event listener.
|
|
1810
|
+
*/
|
|
1811
|
+
o(this, "on", (t, e) => t === "click" ? y("settings_button_pressed", e) : this.ee.on(t, e));
|
|
1812
|
+
/**
|
|
1813
|
+
* Removes event listener.
|
|
1814
|
+
* @param event - event name.
|
|
1815
|
+
* @param listener - event listener.
|
|
1816
|
+
*/
|
|
1817
|
+
o(this, "off", (t, e) => t === "click" ? I("settings_button_pressed", e) : this.ee.off(t, e));
|
|
1818
|
+
/**
|
|
1819
|
+
* Checks if specified method is supported by current component.
|
|
1820
|
+
*/
|
|
1821
|
+
o(this, "supports");
|
|
1822
|
+
this.postEvent = s, this.state = new _({ isVisible: t }, this.ee), this.supports = E(e, {
|
|
1823
|
+
show: "web_app_setup_settings_button",
|
|
1824
|
+
hide: "web_app_setup_settings_button"
|
|
1825
|
+
});
|
|
1826
|
+
}
|
|
1827
|
+
set isVisible(t) {
|
|
1828
|
+
this.state.set("isVisible", t), this.postEvent("web_app_setup_settings_button", { is_visible: t });
|
|
1829
|
+
}
|
|
1830
|
+
/**
|
|
1831
|
+
* True if SettingsButton is currently visible.
|
|
1832
|
+
*/
|
|
1833
|
+
get isVisible() {
|
|
1834
|
+
return this.state.get("isVisible");
|
|
1835
|
+
}
|
|
1836
|
+
/**
|
|
1837
|
+
* Hides the SettingsButton.
|
|
1838
|
+
*/
|
|
1839
|
+
hide() {
|
|
1840
|
+
this.isVisible = !1;
|
|
1841
|
+
}
|
|
1842
|
+
/**
|
|
1843
|
+
* Shows the SettingsButton.
|
|
1844
|
+
*/
|
|
1845
|
+
show() {
|
|
1846
|
+
this.isVisible = !0;
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
function Ne(r, t, e) {
|
|
1850
|
+
const { isVisible: s = !1 } = r ? $("settings-button") || {} : {}, n = new We(s, t, e);
|
|
1851
|
+
return n.on("change", () => {
|
|
1852
|
+
L("settings-button", { isVisible: n.isVisible });
|
|
1853
|
+
}), n;
|
|
1854
|
+
}
|
|
1855
|
+
function Oe(r) {
|
|
1856
|
+
const t = new Ft(r);
|
|
1683
1857
|
return t.listen(), t;
|
|
1684
1858
|
}
|
|
1685
|
-
async function
|
|
1686
|
-
const t = await
|
|
1859
|
+
async function At(r) {
|
|
1860
|
+
const t = await m("web_app_request_viewport", "viewport_changed", r);
|
|
1687
1861
|
return {
|
|
1688
1862
|
height: t.height,
|
|
1689
1863
|
width: t.width,
|
|
@@ -1691,10 +1865,10 @@ async function Pt(r) {
|
|
|
1691
1865
|
isStateStable: t.is_state_stable
|
|
1692
1866
|
};
|
|
1693
1867
|
}
|
|
1694
|
-
function
|
|
1868
|
+
function D(r) {
|
|
1695
1869
|
return r < 0 ? 0 : r;
|
|
1696
1870
|
}
|
|
1697
|
-
class
|
|
1871
|
+
class G {
|
|
1698
1872
|
constructor(t) {
|
|
1699
1873
|
o(this, "ee", new w());
|
|
1700
1874
|
o(this, "state");
|
|
@@ -1709,16 +1883,16 @@ class j {
|
|
|
1709
1883
|
o(this, "off", this.ee.off.bind(this.ee));
|
|
1710
1884
|
const {
|
|
1711
1885
|
height: e,
|
|
1712
|
-
isExpanded:
|
|
1713
|
-
width:
|
|
1886
|
+
isExpanded: s,
|
|
1887
|
+
width: n,
|
|
1714
1888
|
stableHeight: i,
|
|
1715
1889
|
postEvent: a = f
|
|
1716
1890
|
} = t;
|
|
1717
|
-
this.postEvent = a, this.state = new
|
|
1718
|
-
height:
|
|
1719
|
-
isExpanded:
|
|
1720
|
-
stableHeight:
|
|
1721
|
-
width:
|
|
1891
|
+
this.postEvent = a, this.state = new _({
|
|
1892
|
+
height: D(e),
|
|
1893
|
+
isExpanded: s,
|
|
1894
|
+
stableHeight: D(i),
|
|
1895
|
+
width: D(n)
|
|
1722
1896
|
}, this.ee);
|
|
1723
1897
|
}
|
|
1724
1898
|
/**
|
|
@@ -1727,11 +1901,11 @@ class j {
|
|
|
1727
1901
|
* @param options - options to request fresh data.
|
|
1728
1902
|
*/
|
|
1729
1903
|
sync(t) {
|
|
1730
|
-
return
|
|
1904
|
+
return At(t).then(({ height: e, isExpanded: s, width: n, isStateStable: i }) => {
|
|
1731
1905
|
this.state.set({
|
|
1732
1906
|
height: e,
|
|
1733
|
-
width:
|
|
1734
|
-
isExpanded:
|
|
1907
|
+
width: n,
|
|
1908
|
+
isExpanded: s,
|
|
1735
1909
|
stableHeight: i ? e : this.state.get("stableHeight")
|
|
1736
1910
|
});
|
|
1737
1911
|
});
|
|
@@ -1777,16 +1951,16 @@ class j {
|
|
|
1777
1951
|
* @returns Function to stop listening.
|
|
1778
1952
|
*/
|
|
1779
1953
|
listen() {
|
|
1780
|
-
return
|
|
1954
|
+
return y("viewport_changed", (t) => {
|
|
1781
1955
|
const {
|
|
1782
1956
|
height: e,
|
|
1783
|
-
width:
|
|
1784
|
-
is_expanded:
|
|
1957
|
+
width: s,
|
|
1958
|
+
is_expanded: n,
|
|
1785
1959
|
is_state_stable: i
|
|
1786
1960
|
} = t, a = {
|
|
1787
|
-
height:
|
|
1788
|
-
isExpanded:
|
|
1789
|
-
width:
|
|
1961
|
+
height: D(e),
|
|
1962
|
+
isExpanded: n,
|
|
1963
|
+
width: D(s)
|
|
1790
1964
|
};
|
|
1791
1965
|
i && (a.stableHeight = a.height), this.state.set(a);
|
|
1792
1966
|
});
|
|
@@ -1823,29 +1997,32 @@ class j {
|
|
|
1823
1997
|
return this.stableHeight === this.height;
|
|
1824
1998
|
}
|
|
1825
1999
|
}
|
|
1826
|
-
function
|
|
1827
|
-
|
|
1828
|
-
|
|
2000
|
+
function Rt(r) {
|
|
2001
|
+
return !["macos", "web", "weba"].includes(r);
|
|
2002
|
+
}
|
|
2003
|
+
function Vt(r, t, e) {
|
|
2004
|
+
if (r || !Rt(t))
|
|
2005
|
+
return new G({
|
|
1829
2006
|
height: window.innerHeight,
|
|
1830
2007
|
isExpanded: !0,
|
|
1831
2008
|
postEvent: e,
|
|
1832
2009
|
stableHeight: window.innerHeight,
|
|
1833
2010
|
width: window.innerWidth
|
|
1834
2011
|
});
|
|
1835
|
-
const
|
|
1836
|
-
return
|
|
2012
|
+
const s = $("viewport");
|
|
2013
|
+
return s ? new G({ ...s, postEvent: e }) : null;
|
|
1837
2014
|
}
|
|
1838
|
-
function
|
|
1839
|
-
return r.listen(), r.on("change", () =>
|
|
2015
|
+
function It(r) {
|
|
2016
|
+
return r.listen(), r.on("change", () => L("viewport", {
|
|
1840
2017
|
height: r.height,
|
|
1841
2018
|
isExpanded: r.isExpanded,
|
|
1842
2019
|
stableHeight: r.stableHeight,
|
|
1843
2020
|
width: r.width
|
|
1844
2021
|
})), r;
|
|
1845
2022
|
}
|
|
1846
|
-
function
|
|
1847
|
-
const
|
|
1848
|
-
|
|
2023
|
+
function He(r, t, e) {
|
|
2024
|
+
const s = It(
|
|
2025
|
+
Vt(r, t, e) || new G({
|
|
1849
2026
|
width: 0,
|
|
1850
2027
|
height: 0,
|
|
1851
2028
|
isExpanded: !1,
|
|
@@ -1853,71 +2030,71 @@ function Re(r, t, e) {
|
|
|
1853
2030
|
stableHeight: 0
|
|
1854
2031
|
})
|
|
1855
2032
|
);
|
|
1856
|
-
return
|
|
1857
|
-
console.error("Unable to actualize viewport state",
|
|
1858
|
-
}),
|
|
2033
|
+
return Rt(t) && s.sync({ postEvent: e, timeout: 100 }).catch((n) => {
|
|
2034
|
+
console.error("Unable to actualize viewport state", n);
|
|
2035
|
+
}), s;
|
|
1859
2036
|
}
|
|
1860
|
-
async function
|
|
1861
|
-
return
|
|
1862
|
-
|
|
2037
|
+
async function Ue(r, t, e) {
|
|
2038
|
+
return It(
|
|
2039
|
+
Vt(r, t, e) || await At({ postEvent: e, timeout: 100 }).then(({ height: s, isStateStable: n, ...i }) => new G({
|
|
1863
2040
|
...i,
|
|
1864
|
-
height:
|
|
1865
|
-
stableHeight:
|
|
2041
|
+
height: s,
|
|
2042
|
+
stableHeight: n ? s : 0
|
|
1866
2043
|
}))
|
|
1867
2044
|
);
|
|
1868
2045
|
}
|
|
1869
|
-
function
|
|
2046
|
+
function S(r, t) {
|
|
1870
2047
|
document.documentElement.style.setProperty(r, t);
|
|
1871
2048
|
}
|
|
1872
|
-
function
|
|
2049
|
+
function Me(r, t) {
|
|
1873
2050
|
const e = () => {
|
|
1874
|
-
|
|
1875
|
-
},
|
|
2051
|
+
S("--tg-background-color", r.backgroundColor);
|
|
2052
|
+
}, s = () => {
|
|
1876
2053
|
const {
|
|
1877
|
-
backgroundColor:
|
|
2054
|
+
backgroundColor: n,
|
|
1878
2055
|
secondaryBackgroundColor: i
|
|
1879
2056
|
} = t;
|
|
1880
|
-
r.headerColor === "bg_color" ?
|
|
2057
|
+
r.headerColor === "bg_color" ? n && S("--tg-header-color", n) : r.headerColor === "secondary_bg_color" ? i && S("--tg-header-color", i) : S("--tg-header-color", r.headerColor);
|
|
1881
2058
|
};
|
|
1882
|
-
t.on("change",
|
|
2059
|
+
t.on("change", s), r.on("change:backgroundColor", e), r.on("change:headerColor", s), e(), s();
|
|
1883
2060
|
}
|
|
1884
|
-
function
|
|
2061
|
+
function je(r) {
|
|
1885
2062
|
const t = () => {
|
|
1886
2063
|
const e = r.getState();
|
|
1887
|
-
Object.entries(e).forEach(([
|
|
1888
|
-
if (
|
|
1889
|
-
const i =
|
|
1890
|
-
|
|
2064
|
+
Object.entries(e).forEach(([s, n]) => {
|
|
2065
|
+
if (n) {
|
|
2066
|
+
const i = s.replace(/[A-Z]/g, (a) => `-${a.toLowerCase()}`);
|
|
2067
|
+
S(`--tg-theme-${i}`, n);
|
|
1891
2068
|
}
|
|
1892
2069
|
});
|
|
1893
2070
|
};
|
|
1894
2071
|
r.on("change", t), t();
|
|
1895
2072
|
}
|
|
1896
|
-
function
|
|
1897
|
-
const t = () =>
|
|
1898
|
-
r.on("change:height", t), r.on("change:width", e), r.on("change:stableHeight",
|
|
2073
|
+
function ot(r) {
|
|
2074
|
+
const t = () => S("--tg-viewport-height", `${r.height}px`), e = () => S("--tg-viewport-width", `${r.width}px`), s = () => S("--tg-viewport-height", `${r.stableHeight}px`);
|
|
2075
|
+
r.on("change:height", t), r.on("change:width", e), r.on("change:stableHeight", s), t(), e(), s();
|
|
1899
2076
|
}
|
|
1900
|
-
function
|
|
2077
|
+
function Ge(r) {
|
|
1901
2078
|
return typeof r == "object" ? r : r ? {
|
|
1902
2079
|
themeParams: !0,
|
|
1903
2080
|
viewport: !0,
|
|
1904
2081
|
miniApp: !0
|
|
1905
2082
|
} : {};
|
|
1906
2083
|
}
|
|
1907
|
-
function
|
|
1908
|
-
const
|
|
1909
|
-
|
|
2084
|
+
function at(r, t, e, s) {
|
|
2085
|
+
const n = Ge(r);
|
|
2086
|
+
n.miniApp && Me(t, e), n.themeParams && je(e), n.viewport && (s instanceof Promise ? s.then(ot) : ot(s));
|
|
1910
2087
|
}
|
|
1911
|
-
function
|
|
2088
|
+
function Fe(r) {
|
|
1912
2089
|
const { hostname: t, pathname: e } = new URL(r, window.location.href);
|
|
1913
2090
|
if (t !== "t.me")
|
|
1914
2091
|
throw new Error(`Incorrect hostname: ${t}`);
|
|
1915
|
-
const
|
|
1916
|
-
if (
|
|
2092
|
+
const s = e.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
|
|
2093
|
+
if (s === null)
|
|
1917
2094
|
throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');
|
|
1918
|
-
return
|
|
2095
|
+
return s[2];
|
|
1919
2096
|
}
|
|
1920
|
-
class
|
|
2097
|
+
class ze {
|
|
1921
2098
|
constructor(t, e = f) {
|
|
1922
2099
|
o(this, "ee", new w());
|
|
1923
2100
|
o(this, "state");
|
|
@@ -1933,7 +2110,7 @@ class We {
|
|
|
1933
2110
|
* Checks if specified method is supported by current component.
|
|
1934
2111
|
*/
|
|
1935
2112
|
o(this, "supports");
|
|
1936
|
-
this.postEvent = e, this.state = new
|
|
2113
|
+
this.postEvent = e, this.state = new _({ isOpened: !1 }, this.ee), this.supports = E(t, { open: "web_app_open_invoice" });
|
|
1937
2114
|
}
|
|
1938
2115
|
set isOpened(t) {
|
|
1939
2116
|
this.state.set("isOpened", t);
|
|
@@ -1947,17 +2124,17 @@ class We {
|
|
|
1947
2124
|
async open(t, e) {
|
|
1948
2125
|
if (this.isOpened)
|
|
1949
2126
|
throw new Error("Invoice is already opened");
|
|
1950
|
-
const
|
|
2127
|
+
const s = e ? Fe(t) : t;
|
|
1951
2128
|
this.isOpened = !0;
|
|
1952
2129
|
try {
|
|
1953
|
-
return (await
|
|
2130
|
+
return (await m(
|
|
1954
2131
|
"web_app_open_invoice",
|
|
1955
|
-
{ slug:
|
|
2132
|
+
{ slug: s },
|
|
1956
2133
|
"invoice_closed",
|
|
1957
2134
|
{
|
|
1958
2135
|
postEvent: this.postEvent,
|
|
1959
2136
|
capture(i) {
|
|
1960
|
-
return
|
|
2137
|
+
return s === i.slug;
|
|
1961
2138
|
}
|
|
1962
2139
|
}
|
|
1963
2140
|
)).status;
|
|
@@ -1966,16 +2143,16 @@ class We {
|
|
|
1966
2143
|
}
|
|
1967
2144
|
}
|
|
1968
2145
|
}
|
|
1969
|
-
function
|
|
1970
|
-
const t = r.message.trim(), e = (r.title || "").trim(),
|
|
1971
|
-
let
|
|
2146
|
+
function Je(r) {
|
|
2147
|
+
const t = r.message.trim(), e = (r.title || "").trim(), s = r.buttons || [];
|
|
2148
|
+
let n;
|
|
1972
2149
|
if (e.length > 64)
|
|
1973
2150
|
throw new Error(`Title has incorrect size: ${e.length}`);
|
|
1974
2151
|
if (t.length === 0 || t.length > 256)
|
|
1975
2152
|
throw new Error(`Message has incorrect size: ${t.length}`);
|
|
1976
|
-
if (
|
|
1977
|
-
throw new Error(`Buttons have incorrect size: ${
|
|
1978
|
-
return
|
|
2153
|
+
if (s.length > 3)
|
|
2154
|
+
throw new Error(`Buttons have incorrect size: ${s.length}`);
|
|
2155
|
+
return s.length === 0 ? n = [{ type: "close", id: "" }] : n = s.map((i) => {
|
|
1979
2156
|
const { id: a = "" } = i;
|
|
1980
2157
|
if (a.length > 64)
|
|
1981
2158
|
throw new Error(`Button ID has incorrect size: ${a}`);
|
|
@@ -1988,9 +2165,9 @@ function Me(r) {
|
|
|
1988
2165
|
return { ...i, text: c, id: a };
|
|
1989
2166
|
}
|
|
1990
2167
|
return { ...i, id: a };
|
|
1991
|
-
}), { title: e, message: t, buttons:
|
|
2168
|
+
}), { title: e, message: t, buttons: n };
|
|
1992
2169
|
}
|
|
1993
|
-
class
|
|
2170
|
+
class Qe {
|
|
1994
2171
|
constructor(t, e = f) {
|
|
1995
2172
|
o(this, "ee", new w());
|
|
1996
2173
|
o(this, "state");
|
|
@@ -2006,7 +2183,7 @@ class Ue {
|
|
|
2006
2183
|
* Checks if specified method is supported by current component.
|
|
2007
2184
|
*/
|
|
2008
2185
|
o(this, "supports");
|
|
2009
|
-
this.postEvent = e, this.state = new
|
|
2186
|
+
this.postEvent = e, this.state = new _({ isOpened: !1 }, this.ee), this.supports = E(t, { open: "web_app_open_popup" });
|
|
2010
2187
|
}
|
|
2011
2188
|
set isOpened(t) {
|
|
2012
2189
|
this.state.set("isOpened", t);
|
|
@@ -2033,9 +2210,9 @@ class Ue {
|
|
|
2033
2210
|
open(t) {
|
|
2034
2211
|
if (this.isOpened)
|
|
2035
2212
|
throw new Error("Popup is already opened.");
|
|
2036
|
-
return this.isOpened = !0,
|
|
2213
|
+
return this.isOpened = !0, m(
|
|
2037
2214
|
"web_app_open_popup",
|
|
2038
|
-
|
|
2215
|
+
Je(t),
|
|
2039
2216
|
"popup_closed",
|
|
2040
2217
|
{ postEvent: this.postEvent }
|
|
2041
2218
|
).then(({ button_id: e = null }) => e).finally(() => {
|
|
@@ -2043,7 +2220,7 @@ class Ue {
|
|
|
2043
2220
|
});
|
|
2044
2221
|
}
|
|
2045
2222
|
}
|
|
2046
|
-
class
|
|
2223
|
+
class Ze {
|
|
2047
2224
|
constructor(t, e = f) {
|
|
2048
2225
|
o(this, "ee", new w());
|
|
2049
2226
|
o(this, "state");
|
|
@@ -2059,7 +2236,7 @@ class je {
|
|
|
2059
2236
|
* Checks if specified method is supported by current component.
|
|
2060
2237
|
*/
|
|
2061
2238
|
o(this, "supports");
|
|
2062
|
-
this.postEvent = e, this.state = new
|
|
2239
|
+
this.postEvent = e, this.state = new _({ isOpened: !1 }, this.ee), this.supports = E(t, {
|
|
2063
2240
|
close: "web_app_close_scan_qr_popup",
|
|
2064
2241
|
open: "web_app_open_scan_qr_popup"
|
|
2065
2242
|
});
|
|
@@ -2090,7 +2267,7 @@ class je {
|
|
|
2090
2267
|
throw new Error("QR scanner is already opened.");
|
|
2091
2268
|
this.isOpened = !0;
|
|
2092
2269
|
try {
|
|
2093
|
-
const e = await
|
|
2270
|
+
const e = await m(
|
|
2094
2271
|
"web_app_open_scan_qr_popup",
|
|
2095
2272
|
{ text: t },
|
|
2096
2273
|
["qr_text_received", "scan_qr_popup_closed"],
|
|
@@ -2102,8 +2279,8 @@ class je {
|
|
|
2102
2279
|
}
|
|
2103
2280
|
}
|
|
2104
2281
|
}
|
|
2105
|
-
class
|
|
2106
|
-
constructor(t, e,
|
|
2282
|
+
class Ke {
|
|
2283
|
+
constructor(t, e, s = f) {
|
|
2107
2284
|
/**
|
|
2108
2285
|
* Checks if specified method is supported by current component.
|
|
2109
2286
|
*/
|
|
@@ -2112,9 +2289,9 @@ class Ge {
|
|
|
2112
2289
|
* Checks if specified method parameter is supported by current component.
|
|
2113
2290
|
*/
|
|
2114
2291
|
o(this, "supportsParam");
|
|
2115
|
-
this.version = t, this.createRequestId = e, this.postEvent =
|
|
2292
|
+
this.version = t, this.createRequestId = e, this.postEvent = s, this.supports = E(t, {
|
|
2116
2293
|
readTextFromClipboard: "web_app_read_text_from_clipboard"
|
|
2117
|
-
}), this.supportsParam =
|
|
2294
|
+
}), this.supportsParam = kt(t, {
|
|
2118
2295
|
"openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
|
|
2119
2296
|
});
|
|
2120
2297
|
}
|
|
@@ -2128,13 +2305,13 @@ class Ge {
|
|
|
2128
2305
|
* @param tryInstantView
|
|
2129
2306
|
*/
|
|
2130
2307
|
openLink(t, e) {
|
|
2131
|
-
const
|
|
2132
|
-
if (!
|
|
2133
|
-
window.open(
|
|
2308
|
+
const s = new URL(t, window.location.href).toString();
|
|
2309
|
+
if (!A("web_app_open_link", this.version)) {
|
|
2310
|
+
window.open(s, "_blank");
|
|
2134
2311
|
return;
|
|
2135
2312
|
}
|
|
2136
2313
|
this.postEvent("web_app_open_link", {
|
|
2137
|
-
url:
|
|
2314
|
+
url: s,
|
|
2138
2315
|
...typeof e == "boolean" ? { try_instant_view: e } : {}
|
|
2139
2316
|
});
|
|
2140
2317
|
}
|
|
@@ -2147,16 +2324,16 @@ class Ge {
|
|
|
2147
2324
|
openTelegramLink(t) {
|
|
2148
2325
|
const {
|
|
2149
2326
|
hostname: e,
|
|
2150
|
-
pathname:
|
|
2151
|
-
search:
|
|
2327
|
+
pathname: s,
|
|
2328
|
+
search: n
|
|
2152
2329
|
} = new URL(t, window.location.href);
|
|
2153
2330
|
if (e !== "t.me")
|
|
2154
2331
|
throw new Error(`URL has not allowed hostname: ${e}. Only "t.me" is allowed`);
|
|
2155
|
-
if (!
|
|
2332
|
+
if (!A("web_app_open_tg_link", this.version)) {
|
|
2156
2333
|
window.location.href = t;
|
|
2157
2334
|
return;
|
|
2158
2335
|
}
|
|
2159
|
-
this.postEvent("web_app_open_tg_link", { path_full:
|
|
2336
|
+
this.postEvent("web_app_open_tg_link", { path_full: s + n });
|
|
2160
2337
|
}
|
|
2161
2338
|
/**
|
|
2162
2339
|
* Reads text from clipboard and returns string or null. null is returned
|
|
@@ -2165,7 +2342,7 @@ class Ge {
|
|
|
2165
2342
|
* - Access to clipboard is not allowed
|
|
2166
2343
|
*/
|
|
2167
2344
|
readTextFromClipboard() {
|
|
2168
|
-
return
|
|
2345
|
+
return m(
|
|
2169
2346
|
"web_app_read_text_from_clipboard",
|
|
2170
2347
|
{ req_id: this.createRequestId() },
|
|
2171
2348
|
"clipboard_text_received",
|
|
@@ -2173,83 +2350,85 @@ class Ge {
|
|
|
2173
2350
|
).then(({ data: t = null }) => t);
|
|
2174
2351
|
}
|
|
2175
2352
|
}
|
|
2176
|
-
function
|
|
2353
|
+
function ur(r = {}) {
|
|
2177
2354
|
const {
|
|
2178
2355
|
async: t = !1,
|
|
2179
2356
|
cssVars: e = !1,
|
|
2180
|
-
acceptCustomStyles:
|
|
2357
|
+
acceptCustomStyles: s = !1
|
|
2181
2358
|
} = r;
|
|
2182
2359
|
try {
|
|
2183
2360
|
const {
|
|
2184
2361
|
launchParams: {
|
|
2185
|
-
initData:
|
|
2362
|
+
initData: n,
|
|
2186
2363
|
initDataRaw: i,
|
|
2187
2364
|
version: a,
|
|
2188
2365
|
platform: c,
|
|
2189
2366
|
themeParams: u,
|
|
2190
|
-
botInline:
|
|
2367
|
+
botInline: p = !1
|
|
2191
2368
|
},
|
|
2192
|
-
isPageReload:
|
|
2193
|
-
} =
|
|
2194
|
-
|
|
2195
|
-
const
|
|
2196
|
-
backButton:
|
|
2197
|
-
closingBehavior:
|
|
2198
|
-
cloudStorage: new
|
|
2199
|
-
createRequestId:
|
|
2200
|
-
hapticFeedback: new
|
|
2201
|
-
invoice: new
|
|
2369
|
+
isPageReload: l
|
|
2370
|
+
} = Ct(), b = De(), d = ye(a);
|
|
2371
|
+
vt() && (s && Ae(), d("iframe_ready", { reload_supported: !0 }), y("reload_iframe", () => window.location.reload()));
|
|
2372
|
+
const C = {
|
|
2373
|
+
backButton: Re(l, a, d),
|
|
2374
|
+
closingBehavior: Ve(l, d),
|
|
2375
|
+
cloudStorage: new xe(a, b, d),
|
|
2376
|
+
createRequestId: b,
|
|
2377
|
+
hapticFeedback: new qe(a, d),
|
|
2378
|
+
invoice: new ze(a, d),
|
|
2202
2379
|
mainButton: Le(
|
|
2203
|
-
|
|
2380
|
+
l,
|
|
2204
2381
|
u.buttonColor || "#000000",
|
|
2205
2382
|
u.buttonTextColor || "#ffffff",
|
|
2206
2383
|
d
|
|
2207
2384
|
),
|
|
2208
|
-
miniApp:
|
|
2209
|
-
|
|
2385
|
+
miniApp: Be(
|
|
2386
|
+
l,
|
|
2210
2387
|
u.backgroundColor || "#ffffff",
|
|
2211
2388
|
a,
|
|
2212
|
-
|
|
2389
|
+
p,
|
|
2390
|
+
b,
|
|
2213
2391
|
d
|
|
2214
2392
|
),
|
|
2215
|
-
popup: new
|
|
2393
|
+
popup: new Qe(a, d),
|
|
2216
2394
|
postEvent: d,
|
|
2217
|
-
qrScanner: new
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2395
|
+
qrScanner: new Ze(a, d),
|
|
2396
|
+
settingsButton: Ne(l, a, d),
|
|
2397
|
+
themeParams: Oe(u),
|
|
2398
|
+
utils: new Ke(a, b, d),
|
|
2399
|
+
...n ? {
|
|
2400
|
+
initData: new Ut(n),
|
|
2222
2401
|
initDataRaw: i
|
|
2223
2402
|
} : {}
|
|
2224
|
-
}, x = t ?
|
|
2225
|
-
return x instanceof Promise ? x.then((
|
|
2403
|
+
}, x = t ? Ue(l, c, d) : He(l, c, d);
|
|
2404
|
+
return x instanceof Promise ? x.then((T) => (at(
|
|
2226
2405
|
e,
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2406
|
+
C.miniApp,
|
|
2407
|
+
C.themeParams,
|
|
2408
|
+
T
|
|
2230
2409
|
), {
|
|
2231
|
-
...
|
|
2232
|
-
viewport:
|
|
2233
|
-
})) : (
|
|
2410
|
+
...C,
|
|
2411
|
+
viewport: T
|
|
2412
|
+
})) : (at(
|
|
2234
2413
|
e,
|
|
2235
|
-
|
|
2236
|
-
|
|
2414
|
+
C.miniApp,
|
|
2415
|
+
C.themeParams,
|
|
2237
2416
|
x
|
|
2238
|
-
), { ...
|
|
2239
|
-
} catch (
|
|
2417
|
+
), { ...C, viewport: x });
|
|
2418
|
+
} catch (n) {
|
|
2240
2419
|
if (t)
|
|
2241
|
-
return Promise.reject(
|
|
2242
|
-
throw
|
|
2420
|
+
return Promise.reject(n);
|
|
2421
|
+
throw n;
|
|
2243
2422
|
}
|
|
2244
2423
|
}
|
|
2245
|
-
function
|
|
2424
|
+
function W(r, t) {
|
|
2246
2425
|
return r.startsWith(t) ? r : `${t}${r}`;
|
|
2247
2426
|
}
|
|
2248
|
-
function
|
|
2427
|
+
function pr(r) {
|
|
2249
2428
|
const t = r.match(/#(.+)/);
|
|
2250
2429
|
return t ? t[1] : null;
|
|
2251
2430
|
}
|
|
2252
|
-
async function
|
|
2431
|
+
async function O(r) {
|
|
2253
2432
|
return r === 0 ? !0 : Promise.race([
|
|
2254
2433
|
new Promise((t) => {
|
|
2255
2434
|
window.addEventListener("popstate", function e() {
|
|
@@ -2262,17 +2441,17 @@ async function B(r) {
|
|
|
2262
2441
|
})
|
|
2263
2442
|
]);
|
|
2264
2443
|
}
|
|
2265
|
-
async function
|
|
2266
|
-
if (window.history.length <= 1 || (window.history.pushState(null, ""), await
|
|
2444
|
+
async function Ye() {
|
|
2445
|
+
if (window.history.length <= 1 || (window.history.pushState(null, ""), await O(1 - window.history.length)))
|
|
2267
2446
|
return;
|
|
2268
|
-
let t = await
|
|
2447
|
+
let t = await O(-1);
|
|
2269
2448
|
for (; t; )
|
|
2270
|
-
t = await
|
|
2449
|
+
t = await O(-1);
|
|
2271
2450
|
}
|
|
2272
|
-
class
|
|
2451
|
+
class Xe {
|
|
2273
2452
|
constructor(t, e, {
|
|
2274
|
-
debug:
|
|
2275
|
-
loggerPrefix:
|
|
2453
|
+
debug: s = !1,
|
|
2454
|
+
loggerPrefix: n = "Navigator"
|
|
2276
2455
|
}) {
|
|
2277
2456
|
o(this, "logger");
|
|
2278
2457
|
o(this, "entries");
|
|
@@ -2284,11 +2463,11 @@ class ze {
|
|
|
2284
2463
|
if (!i.startsWith("/") && i.length > 0)
|
|
2285
2464
|
throw new Error('Pathname should start with "/"');
|
|
2286
2465
|
return {
|
|
2287
|
-
pathname:
|
|
2288
|
-
search: a ?
|
|
2289
|
-
hash: c ?
|
|
2466
|
+
pathname: W(i, "/"),
|
|
2467
|
+
search: a ? W(a, "?") : "",
|
|
2468
|
+
hash: c ? W(c, "#") : ""
|
|
2290
2469
|
};
|
|
2291
|
-
}), this.logger = new
|
|
2470
|
+
}), this.logger = new Pt(`[${n}]`, s);
|
|
2292
2471
|
}
|
|
2293
2472
|
/**
|
|
2294
2473
|
* Converts entry to the navigation entry.
|
|
@@ -2304,16 +2483,16 @@ class ze {
|
|
|
2304
2483
|
search: c,
|
|
2305
2484
|
hash: u
|
|
2306
2485
|
} = t;
|
|
2307
|
-
e = a + (c ?
|
|
2486
|
+
e = a + (c ? W(c, "?") : "") + (u ? W(u, "#") : "");
|
|
2308
2487
|
}
|
|
2309
2488
|
const {
|
|
2310
|
-
pathname:
|
|
2311
|
-
search:
|
|
2489
|
+
pathname: s,
|
|
2490
|
+
search: n,
|
|
2312
2491
|
hash: i
|
|
2313
2492
|
} = new URL(e, `https://localhost${this.path}`);
|
|
2314
2493
|
return {
|
|
2315
|
-
pathname:
|
|
2316
|
-
search:
|
|
2494
|
+
pathname: s,
|
|
2495
|
+
search: n,
|
|
2317
2496
|
hash: i
|
|
2318
2497
|
};
|
|
2319
2498
|
}
|
|
@@ -2368,14 +2547,14 @@ class ze {
|
|
|
2368
2547
|
updated: !1,
|
|
2369
2548
|
delta: t
|
|
2370
2549
|
});
|
|
2371
|
-
const n = this.entry;
|
|
2372
|
-
this.entriesCursor = e;
|
|
2373
2550
|
const s = this.entry;
|
|
2374
|
-
|
|
2551
|
+
this.entriesCursor = e;
|
|
2552
|
+
const n = this.entry;
|
|
2553
|
+
return this.logger.log("State changed", { before: s, after: n }), this.performGo({
|
|
2375
2554
|
updated: !0,
|
|
2376
2555
|
delta: t,
|
|
2377
|
-
before:
|
|
2378
|
-
after:
|
|
2556
|
+
before: s,
|
|
2557
|
+
after: n
|
|
2379
2558
|
});
|
|
2380
2559
|
}
|
|
2381
2560
|
/**
|
|
@@ -2415,12 +2594,12 @@ class ze {
|
|
|
2415
2594
|
*/
|
|
2416
2595
|
push(t) {
|
|
2417
2596
|
this.entriesCursor !== this.entries.length - 1 && this.entries.splice(this.entriesCursor + 1);
|
|
2418
|
-
const e = this.formatEntry(t),
|
|
2597
|
+
const e = this.formatEntry(t), s = this.entry;
|
|
2419
2598
|
this.entriesCursor += 1, this.entries[this.entriesCursor] = e;
|
|
2420
|
-
const
|
|
2421
|
-
return this.logger.log("State changed", { before:
|
|
2422
|
-
before:
|
|
2423
|
-
after:
|
|
2599
|
+
const n = this.entry;
|
|
2600
|
+
return this.logger.log("State changed", { before: s, after: n }), this.performPush({
|
|
2601
|
+
before: s,
|
|
2602
|
+
after: n
|
|
2424
2603
|
});
|
|
2425
2604
|
}
|
|
2426
2605
|
/**
|
|
@@ -2450,13 +2629,13 @@ class ze {
|
|
|
2450
2629
|
updated: !1,
|
|
2451
2630
|
entry: e
|
|
2452
2631
|
});
|
|
2453
|
-
const n = this.entry;
|
|
2454
|
-
this.entries[this.entriesCursor] = e;
|
|
2455
2632
|
const s = this.entry;
|
|
2456
|
-
|
|
2633
|
+
this.entries[this.entriesCursor] = e;
|
|
2634
|
+
const n = this.entry;
|
|
2635
|
+
return this.logger.log("State changed", { before: s, after: n }), this.performReplace({
|
|
2457
2636
|
updated: !0,
|
|
2458
|
-
before:
|
|
2459
|
-
after:
|
|
2637
|
+
before: s,
|
|
2638
|
+
after: n
|
|
2460
2639
|
});
|
|
2461
2640
|
}
|
|
2462
2641
|
/**
|
|
@@ -2468,11 +2647,11 @@ class ze {
|
|
|
2468
2647
|
return this.entry.search;
|
|
2469
2648
|
}
|
|
2470
2649
|
}
|
|
2471
|
-
const
|
|
2472
|
-
class Lt extends
|
|
2473
|
-
constructor(e,
|
|
2474
|
-
super(e,
|
|
2475
|
-
...
|
|
2650
|
+
const ct = 0, Z = 1, K = 2;
|
|
2651
|
+
class Lt extends Xe {
|
|
2652
|
+
constructor(e, s, n = {}) {
|
|
2653
|
+
super(e, s, {
|
|
2654
|
+
...n,
|
|
2476
2655
|
loggerPrefix: "HashNavigator"
|
|
2477
2656
|
});
|
|
2478
2657
|
o(this, "ee", new w());
|
|
@@ -2484,13 +2663,13 @@ class Lt extends ze {
|
|
|
2484
2663
|
o(this, "onPopState", async ({ state: e }) => {
|
|
2485
2664
|
if (this.logger.log('"popstate" event received. State:', e), e === null)
|
|
2486
2665
|
return this.push(window.location.hash.slice(1));
|
|
2487
|
-
if (e ===
|
|
2666
|
+
if (e === ct) {
|
|
2488
2667
|
this.logger.log("Void reached. Moving history forward"), window.history.forward();
|
|
2489
2668
|
return;
|
|
2490
2669
|
}
|
|
2491
|
-
if (e ===
|
|
2670
|
+
if (e === Z)
|
|
2492
2671
|
return this.back();
|
|
2493
|
-
if (e ===
|
|
2672
|
+
if (e === K)
|
|
2494
2673
|
return this.forward();
|
|
2495
2674
|
});
|
|
2496
2675
|
o(this, "back", () => super.back());
|
|
@@ -2509,20 +2688,20 @@ class Lt extends ze {
|
|
|
2509
2688
|
*/
|
|
2510
2689
|
static fromLocation(e) {
|
|
2511
2690
|
const {
|
|
2512
|
-
search:
|
|
2513
|
-
pathname:
|
|
2691
|
+
search: s,
|
|
2692
|
+
pathname: n,
|
|
2514
2693
|
hash: i
|
|
2515
2694
|
} = new URL(
|
|
2516
2695
|
window.location.hash.slice(1),
|
|
2517
2696
|
window.location.href
|
|
2518
2697
|
);
|
|
2519
|
-
return new Lt([{ search:
|
|
2698
|
+
return new Lt([{ search: s, pathname: n, hash: i }], 0, e);
|
|
2520
2699
|
}
|
|
2521
2700
|
async performGo(e) {
|
|
2522
2701
|
e.updated && (this.attached && await this.syncHistory(), this.emitChanged(e.before, e.after));
|
|
2523
2702
|
}
|
|
2524
|
-
async performPush({ before: e, after:
|
|
2525
|
-
this.attached && await this.syncHistory(), this.emitChanged(e,
|
|
2703
|
+
async performPush({ before: e, after: s }) {
|
|
2704
|
+
this.attached && await this.syncHistory(), this.emitChanged(e, s);
|
|
2526
2705
|
}
|
|
2527
2706
|
async performReplace(e) {
|
|
2528
2707
|
e.updated && (this.attached && window.history.replaceState(null, "", `#${this.path}`), this.emitChanged(e.before, e.after));
|
|
@@ -2533,13 +2712,13 @@ class Lt extends ze {
|
|
|
2533
2712
|
async syncHistory() {
|
|
2534
2713
|
window.removeEventListener("popstate", this.onPopState);
|
|
2535
2714
|
const e = `#${this.path}`;
|
|
2536
|
-
await
|
|
2715
|
+
await Ye(), f("web_app_setup_back_button", { is_visible: this.canGoBack }), this.canGoBack && this.canGoForward ? (this.logger.log("Setting up history: [<-, *, ->]"), window.history.replaceState(Z, ""), window.history.pushState(null, "", e), window.history.pushState(K, ""), await O(-1)) : this.canGoBack ? (this.logger.log("Setting up history: [<-, *]"), window.history.replaceState(Z, ""), window.history.pushState(null, "", e)) : this.canGoForward ? (this.logger.log("Setting up history: [*, ->]"), window.history.replaceState(null, e), window.history.pushState(K, ""), await O(-1)) : (this.logger.log("Setting up history: [~, *]"), window.history.replaceState(ct, ""), window.history.pushState(null, "", e)), window.addEventListener("popstate", this.onPopState);
|
|
2537
2716
|
}
|
|
2538
|
-
emitChanged(e,
|
|
2717
|
+
emitChanged(e, s) {
|
|
2539
2718
|
this.ee.emit("change", {
|
|
2540
2719
|
navigator: this,
|
|
2541
2720
|
from: e,
|
|
2542
|
-
to:
|
|
2721
|
+
to: s
|
|
2543
2722
|
});
|
|
2544
2723
|
}
|
|
2545
2724
|
/**
|
|
@@ -2547,68 +2726,73 @@ class Lt extends ze {
|
|
|
2547
2726
|
*/
|
|
2548
2727
|
async attach() {
|
|
2549
2728
|
if (!this.attached)
|
|
2550
|
-
return this.logger.log("Attaching", this), this.attached = !0,
|
|
2729
|
+
return this.logger.log("Attaching", this), this.attached = !0, y("back_button_pressed", this.back), this.syncHistory();
|
|
2551
2730
|
}
|
|
2552
2731
|
/**
|
|
2553
2732
|
* Detaches current navigator from the browser history.
|
|
2554
2733
|
*/
|
|
2555
2734
|
detach() {
|
|
2556
|
-
this.attached && (this.logger.log("Detaching", this), this.attached = !1, window.removeEventListener("popstate", this.onPopState),
|
|
2735
|
+
this.attached && (this.logger.log("Detaching", this), this.attached = !1, window.removeEventListener("popstate", this.onPopState), I("back_button_pressed", this.back));
|
|
2557
2736
|
}
|
|
2558
2737
|
}
|
|
2559
2738
|
export {
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2739
|
+
ve as BackButton,
|
|
2740
|
+
ke as ClosingBehavior,
|
|
2741
|
+
xe as CloudStorage,
|
|
2742
|
+
qe as HapticFeedback,
|
|
2564
2743
|
Lt as HashNavigator,
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2744
|
+
Ut as InitData,
|
|
2745
|
+
ze as Invoice,
|
|
2746
|
+
Ie as MainButton,
|
|
2747
|
+
tt as MethodUnsupportedError,
|
|
2748
|
+
Te as MiniApp,
|
|
2749
|
+
Xe as Navigator,
|
|
2750
|
+
et as ParameterUnsupportedError,
|
|
2751
|
+
Qe as Popup,
|
|
2752
|
+
Ze as QRScanner,
|
|
2753
|
+
We as SettingsButton,
|
|
2754
|
+
Ft as ThemeParams,
|
|
2755
|
+
J as TimeoutError,
|
|
2756
|
+
Ke as Utils,
|
|
2757
|
+
G as Viewport,
|
|
2758
|
+
Ht as chatParser,
|
|
2759
|
+
Pe as classNames,
|
|
2760
|
+
me as compareVersions,
|
|
2761
|
+
ye as createPostEvent,
|
|
2762
|
+
pr as getHash,
|
|
2763
|
+
ur as init,
|
|
2764
|
+
wt as initDataParser,
|
|
2765
|
+
N as invokeCustomMethod,
|
|
2766
|
+
ft as isColorDark,
|
|
2767
|
+
vt as isIframe,
|
|
2768
|
+
lt as isRGB,
|
|
2769
|
+
Ot as isRGBShort,
|
|
2770
|
+
H as isRecord,
|
|
2771
|
+
sr as isTMA,
|
|
2772
|
+
cr as isTimeoutError,
|
|
2773
|
+
mt as launchParamsParser,
|
|
2774
|
+
hr as mergeClassNames,
|
|
2775
|
+
I as off,
|
|
2776
|
+
y as on,
|
|
2777
|
+
or as once,
|
|
2778
|
+
er as parseInitData,
|
|
2779
|
+
yt as parseLaunchParams,
|
|
2780
|
+
bt as parseThemeParams,
|
|
2598
2781
|
f as postEvent,
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2782
|
+
m as request,
|
|
2783
|
+
rr as requestThemeParams,
|
|
2784
|
+
At as requestViewport,
|
|
2785
|
+
Ct as retrieveLaunchData,
|
|
2786
|
+
Zt as serializeLaunchParams,
|
|
2787
|
+
Gt as serializeThemeParams,
|
|
2788
|
+
nr as setDebug,
|
|
2789
|
+
ir as setTargetOrigin,
|
|
2790
|
+
ar as subscribe,
|
|
2791
|
+
A as supports,
|
|
2792
|
+
_t as themeParamsParser,
|
|
2793
|
+
dt as toRGB,
|
|
2794
|
+
be as unsubscribe,
|
|
2795
|
+
rt as userParser,
|
|
2796
|
+
xt as withTimeout
|
|
2613
2797
|
};
|
|
2614
2798
|
//# sourceMappingURL=index.mjs.map
|