@tma.js/sdk 0.13.2 → 0.13.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/components/ThemeParams/ThemeParams.d.ts +14 -2
- package/dist/dts/components/ThemeParams/types.d.ts +1 -4
- package/dist/dts/init/css.d.ts +3 -10
- package/dist/dts/state/State.d.ts +4 -3
- 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 +339 -346
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/components/ThemeParams/ThemeParams.ts +45 -43
- package/src/components/ThemeParams/types.ts +1 -8
- package/src/init/css.ts +11 -35
- package/src/state/State.ts +9 -5
package/dist/index.mjs
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (s, t, e) => (
|
|
4
|
-
import { retrieveLaunchData as
|
|
5
|
-
import { EventEmitter as
|
|
6
|
-
import { supports as
|
|
7
|
-
import { array as
|
|
1
|
+
var st = Object.defineProperty;
|
|
2
|
+
var rt = (s, t, e) => t in s ? st(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
|
+
var i = (s, t, e) => (rt(s, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
+
import { retrieveLaunchData as N, parse as ot } from "@tma.js/launch-params";
|
|
5
|
+
import { EventEmitter as f } from "@tma.js/event-emitter";
|
|
6
|
+
import { supports as S, postEvent as g, on as E, off as z, request as _, setDebug as nt, setTargetOrigin as it, createPostEvent as at, isIframe as ct } from "@tma.js/bridge";
|
|
7
|
+
import { array as ht, string as W, json as ut } from "@tma.js/parsing";
|
|
8
8
|
import { parse as D } from "@tma.js/theme-params";
|
|
9
|
-
import { isColorDark as
|
|
10
|
-
import { compareVersions as
|
|
11
|
-
function
|
|
12
|
-
return (e) =>
|
|
9
|
+
import { isColorDark as U, isRGB as pt } from "@tma.js/colors";
|
|
10
|
+
import { compareVersions as lt, withTimeout as dt } from "@tma.js/utils";
|
|
11
|
+
function m(s, t) {
|
|
12
|
+
return (e) => S(t[e], s);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function gt(s, t) {
|
|
15
15
|
return (e) => {
|
|
16
|
-
const [
|
|
17
|
-
return
|
|
16
|
+
const [r, o] = t[e];
|
|
17
|
+
return S(r, o, s);
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
class
|
|
20
|
+
class b {
|
|
21
21
|
constructor(t, e) {
|
|
22
22
|
this.state = t, this.ee = e;
|
|
23
23
|
}
|
|
@@ -25,24 +25,27 @@ class m {
|
|
|
25
25
|
this.ee && this.ee.emit(t, e);
|
|
26
26
|
}
|
|
27
27
|
internalSet(t, e) {
|
|
28
|
-
return this.state[t] === e ? !1 : (this.state[t] = e, this.emit(`${t}Changed`, e), !0);
|
|
28
|
+
return this.state[t] === e ? !1 : (this.state[t] = e, this.emit(`${String(t)}Changed`, e), !0);
|
|
29
29
|
}
|
|
30
30
|
set(t, e) {
|
|
31
|
-
let
|
|
31
|
+
let r = !1;
|
|
32
32
|
if (typeof t == "string")
|
|
33
|
-
|
|
33
|
+
r = this.internalSet(t, e);
|
|
34
34
|
else
|
|
35
|
-
for (const
|
|
36
|
-
this.internalSet(
|
|
37
|
-
|
|
35
|
+
for (const o in t)
|
|
36
|
+
this.internalSet(o, t[o]) && (r = !0);
|
|
37
|
+
r && this.emit("changed");
|
|
38
38
|
}
|
|
39
39
|
get(t) {
|
|
40
40
|
return this.state[t];
|
|
41
41
|
}
|
|
42
|
+
getState() {
|
|
43
|
+
return { ...this.state };
|
|
44
|
+
}
|
|
42
45
|
}
|
|
43
46
|
class _t {
|
|
44
|
-
constructor(t, e,
|
|
45
|
-
i(this, "ee", new
|
|
47
|
+
constructor(t, e, r = g) {
|
|
48
|
+
i(this, "ee", new f());
|
|
46
49
|
i(this, "state");
|
|
47
50
|
/**
|
|
48
51
|
* Adds event listener.
|
|
@@ -57,14 +60,14 @@ class _t {
|
|
|
57
60
|
*/
|
|
58
61
|
i(this, "off", (t, e) => {
|
|
59
62
|
if (t === "click")
|
|
60
|
-
return
|
|
63
|
+
return z("back_button_pressed", e);
|
|
61
64
|
this.ee.off(t, e);
|
|
62
65
|
});
|
|
63
66
|
/**
|
|
64
67
|
* Checks if specified method is supported by current component.
|
|
65
68
|
*/
|
|
66
69
|
i(this, "supports");
|
|
67
|
-
this.postEvent =
|
|
70
|
+
this.postEvent = r, this.state = new b({ isVisible: t }, this.ee), this.supports = m(e, {
|
|
68
71
|
show: "web_app_setup_back_button",
|
|
69
72
|
hide: "web_app_setup_back_button"
|
|
70
73
|
});
|
|
@@ -91,9 +94,9 @@ class _t {
|
|
|
91
94
|
this.isVisible = !0;
|
|
92
95
|
}
|
|
93
96
|
}
|
|
94
|
-
class
|
|
97
|
+
class bt {
|
|
95
98
|
constructor(t, e = g) {
|
|
96
|
-
i(this, "ee", new
|
|
99
|
+
i(this, "ee", new f());
|
|
97
100
|
i(this, "state");
|
|
98
101
|
/**
|
|
99
102
|
* Adds new event listener.
|
|
@@ -103,7 +106,7 @@ class ft {
|
|
|
103
106
|
* Removes event listener.
|
|
104
107
|
*/
|
|
105
108
|
i(this, "off", this.ee.off.bind(this.ee));
|
|
106
|
-
this.postEvent = e, this.state = new
|
|
109
|
+
this.postEvent = e, this.state = new b({ isConfirmationNeeded: t }, this.ee);
|
|
107
110
|
}
|
|
108
111
|
set isConfirmationNeeded(t) {
|
|
109
112
|
this.state.set("isConfirmationNeeded", t), this.postEvent("web_app_setup_closing_behavior", { need_confirmation: t });
|
|
@@ -130,17 +133,17 @@ class ft {
|
|
|
130
133
|
this.isConfirmationNeeded = !0;
|
|
131
134
|
}
|
|
132
135
|
}
|
|
133
|
-
const
|
|
136
|
+
const ft = ht().of(W());
|
|
134
137
|
function L(s, t) {
|
|
135
|
-
return s.reduce((e,
|
|
138
|
+
return s.reduce((e, r) => (e[r] = t, e), {});
|
|
136
139
|
}
|
|
137
140
|
class wt {
|
|
138
|
-
constructor(t, e,
|
|
141
|
+
constructor(t, e, r = g) {
|
|
139
142
|
/**
|
|
140
143
|
* Checks if specified method is supported by current component.
|
|
141
144
|
*/
|
|
142
145
|
i(this, "supports");
|
|
143
|
-
this.createRequestId = e, this.postEvent =
|
|
146
|
+
this.createRequestId = e, this.postEvent = r, this.supports = m(t, {
|
|
144
147
|
deleteKeys: "web_app_invoke_custom_method",
|
|
145
148
|
getKeys: "web_app_invoke_custom_method",
|
|
146
149
|
getValues: "web_app_invoke_custom_method",
|
|
@@ -153,16 +156,16 @@ class wt {
|
|
|
153
156
|
* @param params - method parameters.
|
|
154
157
|
* @param options - execution options.
|
|
155
158
|
*/
|
|
156
|
-
async invokeCustomMethod(t, e,
|
|
157
|
-
const { result:
|
|
159
|
+
async invokeCustomMethod(t, e, r = {}) {
|
|
160
|
+
const { result: o, error: n } = await _(
|
|
158
161
|
"web_app_invoke_custom_method",
|
|
159
162
|
{ method: t, params: e, req_id: this.createRequestId() },
|
|
160
163
|
"custom_method_invoked",
|
|
161
|
-
{ ...
|
|
164
|
+
{ ...r, postEvent: this.postEvent }
|
|
162
165
|
);
|
|
163
|
-
if (
|
|
164
|
-
throw new Error(typeof
|
|
165
|
-
return
|
|
166
|
+
if (n)
|
|
167
|
+
throw new Error(typeof n == "string" ? n : `Unknown error: ${JSON.stringify(n)}`);
|
|
168
|
+
return o;
|
|
166
169
|
}
|
|
167
170
|
/**
|
|
168
171
|
* Deletes specified keys from the CloudStorage.
|
|
@@ -178,7 +181,7 @@ class wt {
|
|
|
178
181
|
*/
|
|
179
182
|
async getKeys(t) {
|
|
180
183
|
const e = await this.invokeCustomMethod("getStorageKeys", {}, t);
|
|
181
|
-
return
|
|
184
|
+
return ft.parse(e);
|
|
182
185
|
}
|
|
183
186
|
/**
|
|
184
187
|
* Returns map, where key is one of the specified in keys argument, and value is according
|
|
@@ -189,11 +192,11 @@ class wt {
|
|
|
189
192
|
async getValues(t, e) {
|
|
190
193
|
if (t.length === 0)
|
|
191
194
|
return L(t, "");
|
|
192
|
-
const
|
|
193
|
-
L(t,
|
|
195
|
+
const r = ut(
|
|
196
|
+
L(t, W())
|
|
194
197
|
// fixme
|
|
195
|
-
),
|
|
196
|
-
return
|
|
198
|
+
), o = await this.invokeCustomMethod("getStorageValues", { keys: t }, e);
|
|
199
|
+
return r.parse(o);
|
|
197
200
|
}
|
|
198
201
|
/**
|
|
199
202
|
* Saves specified value by key.
|
|
@@ -201,17 +204,17 @@ class wt {
|
|
|
201
204
|
* @param value - storage value.
|
|
202
205
|
* @param options - request execution options.
|
|
203
206
|
*/
|
|
204
|
-
async saveValue(t, e,
|
|
205
|
-
await this.invokeCustomMethod("saveStorageValue", { key: t, value: e },
|
|
207
|
+
async saveValue(t, e, r) {
|
|
208
|
+
await this.invokeCustomMethod("saveStorageValue", { key: t, value: e }, r);
|
|
206
209
|
}
|
|
207
210
|
}
|
|
208
|
-
class
|
|
211
|
+
class mt {
|
|
209
212
|
constructor(t, e = g) {
|
|
210
213
|
/**
|
|
211
214
|
* Checks if specified method is supported by current component.
|
|
212
215
|
*/
|
|
213
216
|
i(this, "supports");
|
|
214
|
-
this.postEvent = e, this.supports =
|
|
217
|
+
this.postEvent = e, this.supports = m(t, {
|
|
215
218
|
impactOccurred: "web_app_trigger_haptic_feedback",
|
|
216
219
|
notificationOccurred: "web_app_trigger_haptic_feedback",
|
|
217
220
|
selectionChanged: "web_app_trigger_haptic_feedback"
|
|
@@ -248,29 +251,29 @@ class Ct {
|
|
|
248
251
|
this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
|
|
249
252
|
}
|
|
250
253
|
}
|
|
251
|
-
class
|
|
252
|
-
constructor(t, e,
|
|
254
|
+
class Ct {
|
|
255
|
+
constructor(t, e, r = {}) {
|
|
253
256
|
i(this, "state");
|
|
254
257
|
const {
|
|
255
|
-
chat:
|
|
256
|
-
canSendAfter:
|
|
258
|
+
chat: o = null,
|
|
259
|
+
canSendAfter: n = null,
|
|
257
260
|
chatType: a = null,
|
|
258
|
-
chatInstance:
|
|
261
|
+
chatInstance: u = null,
|
|
259
262
|
user: c = null,
|
|
260
|
-
queryId:
|
|
261
|
-
receiver:
|
|
262
|
-
startParam:
|
|
263
|
-
} =
|
|
264
|
-
this.state = new
|
|
263
|
+
queryId: p = null,
|
|
264
|
+
receiver: h = null,
|
|
265
|
+
startParam: d = null
|
|
266
|
+
} = r;
|
|
267
|
+
this.state = new b({
|
|
265
268
|
authDate: t,
|
|
266
|
-
canSendAfter:
|
|
267
|
-
chat:
|
|
269
|
+
canSendAfter: n === null ? null : new Date(t.getTime() + n * 1e3),
|
|
270
|
+
chat: o,
|
|
268
271
|
chatType: a,
|
|
269
|
-
chatInstance:
|
|
272
|
+
chatInstance: u,
|
|
270
273
|
user: c,
|
|
271
|
-
queryId:
|
|
272
|
-
receiver:
|
|
273
|
-
startParam:
|
|
274
|
+
queryId: p,
|
|
275
|
+
receiver: h,
|
|
276
|
+
startParam: d,
|
|
274
277
|
hash: e
|
|
275
278
|
});
|
|
276
279
|
}
|
|
@@ -347,9 +350,9 @@ class vt {
|
|
|
347
350
|
return this.state.get("user");
|
|
348
351
|
}
|
|
349
352
|
}
|
|
350
|
-
class
|
|
351
|
-
constructor(t, e, o, n,
|
|
352
|
-
i(this, "ee", new
|
|
353
|
+
class vt {
|
|
354
|
+
constructor(t, e, r, o, n, a, u = g) {
|
|
355
|
+
i(this, "ee", new f());
|
|
353
356
|
i(this, "state");
|
|
354
357
|
/**
|
|
355
358
|
* Adds new event listener.
|
|
@@ -367,15 +370,15 @@ class yt {
|
|
|
367
370
|
*/
|
|
368
371
|
i(this, "off", (t, e) => {
|
|
369
372
|
if (t === "click")
|
|
370
|
-
return
|
|
373
|
+
return z("main_button_pressed", e);
|
|
371
374
|
this.ee.off(t, e);
|
|
372
375
|
});
|
|
373
|
-
this.postEvent =
|
|
376
|
+
this.postEvent = u, this.state = new b({
|
|
374
377
|
backgroundColor: t,
|
|
375
378
|
isEnabled: e,
|
|
376
|
-
isVisible:
|
|
377
|
-
isProgressVisible:
|
|
378
|
-
text:
|
|
379
|
+
isVisible: r,
|
|
380
|
+
isProgressVisible: o,
|
|
381
|
+
text: n,
|
|
379
382
|
textColor: a
|
|
380
383
|
}, this.ee);
|
|
381
384
|
}
|
|
@@ -512,33 +515,33 @@ class yt {
|
|
|
512
515
|
return this.state.set("backgroundColor", t), this.commit(), this;
|
|
513
516
|
}
|
|
514
517
|
}
|
|
515
|
-
function
|
|
516
|
-
const t = s.message.trim(), e = (s.title || "").trim(),
|
|
517
|
-
let
|
|
518
|
+
function yt(s) {
|
|
519
|
+
const t = s.message.trim(), e = (s.title || "").trim(), r = s.buttons || [];
|
|
520
|
+
let o;
|
|
518
521
|
if (e.length > 64)
|
|
519
522
|
throw new Error(`Title has incorrect size: ${e.length}`);
|
|
520
523
|
if (t.length === 0 || t.length > 256)
|
|
521
524
|
throw new Error(`Message has incorrect size: ${t.length}`);
|
|
522
|
-
if (
|
|
523
|
-
throw new Error(`Buttons have incorrect size: ${
|
|
524
|
-
return
|
|
525
|
-
const { id: a = "" } =
|
|
525
|
+
if (r.length > 3)
|
|
526
|
+
throw new Error(`Buttons have incorrect size: ${r.length}`);
|
|
527
|
+
return r.length === 0 ? o = [{ type: "close", id: "" }] : o = r.map((n) => {
|
|
528
|
+
const { id: a = "" } = n;
|
|
526
529
|
if (a.length > 64)
|
|
527
530
|
throw new Error(`Button ID has incorrect size: ${a}`);
|
|
528
|
-
if (
|
|
529
|
-
const
|
|
530
|
-
if (
|
|
531
|
-
const c =
|
|
532
|
-
throw new Error(`Button text with type "${c}" has incorrect size: ${
|
|
531
|
+
if (n.type === void 0 || n.type === "default" || n.type === "destructive") {
|
|
532
|
+
const u = n.text.trim();
|
|
533
|
+
if (u.length === 0 || u.length > 64) {
|
|
534
|
+
const c = n.type || "default";
|
|
535
|
+
throw new Error(`Button text with type "${c}" has incorrect size: ${n.text.length}`);
|
|
533
536
|
}
|
|
534
|
-
return { ...
|
|
537
|
+
return { ...n, text: u, id: a };
|
|
535
538
|
}
|
|
536
|
-
return { ...
|
|
537
|
-
}), { title: e, message: t, buttons:
|
|
539
|
+
return { ...n, id: a };
|
|
540
|
+
}), { title: e, message: t, buttons: o };
|
|
538
541
|
}
|
|
539
542
|
class Et {
|
|
540
543
|
constructor(t, e = g) {
|
|
541
|
-
i(this, "ee", new
|
|
544
|
+
i(this, "ee", new f());
|
|
542
545
|
i(this, "state");
|
|
543
546
|
/**
|
|
544
547
|
* Adds new event listener.
|
|
@@ -552,7 +555,7 @@ class Et {
|
|
|
552
555
|
* Checks if specified method is supported by current component.
|
|
553
556
|
*/
|
|
554
557
|
i(this, "supports");
|
|
555
|
-
this.postEvent = e, this.state = new
|
|
558
|
+
this.postEvent = e, this.state = new b({ isOpened: !1 }, this.ee), this.supports = m(t, { open: "web_app_open_popup" });
|
|
556
559
|
}
|
|
557
560
|
/**
|
|
558
561
|
* Shows whether popup is currently opened.
|
|
@@ -578,9 +581,9 @@ class Et {
|
|
|
578
581
|
throw new Error("Popup is already opened.");
|
|
579
582
|
this.state.set("isOpened", !0);
|
|
580
583
|
try {
|
|
581
|
-
const { button_id: e = null } = await
|
|
584
|
+
const { button_id: e = null } = await _(
|
|
582
585
|
"web_app_open_popup",
|
|
583
|
-
|
|
586
|
+
yt(t),
|
|
584
587
|
"popup_closed",
|
|
585
588
|
{ postEvent: this.postEvent }
|
|
586
589
|
);
|
|
@@ -590,9 +593,9 @@ class Et {
|
|
|
590
593
|
}
|
|
591
594
|
}
|
|
592
595
|
}
|
|
593
|
-
class
|
|
596
|
+
class kt {
|
|
594
597
|
constructor(t, e = g) {
|
|
595
|
-
i(this, "ee", new
|
|
598
|
+
i(this, "ee", new f());
|
|
596
599
|
i(this, "state");
|
|
597
600
|
/**
|
|
598
601
|
* Adds new event listener.
|
|
@@ -606,7 +609,7 @@ class xt {
|
|
|
606
609
|
* Checks if specified method is supported by current component.
|
|
607
610
|
*/
|
|
608
611
|
i(this, "supports");
|
|
609
|
-
this.postEvent = e, this.state = new
|
|
612
|
+
this.postEvent = e, this.state = new b({ isOpened: !1 }, this.ee), this.supports = m(t, {
|
|
610
613
|
close: "web_app_close_scan_qr_popup",
|
|
611
614
|
open: "web_app_open_scan_qr_popup"
|
|
612
615
|
});
|
|
@@ -637,7 +640,7 @@ class xt {
|
|
|
637
640
|
throw new Error("QR scanner is already opened.");
|
|
638
641
|
this.isOpened = !0;
|
|
639
642
|
try {
|
|
640
|
-
const e = await
|
|
643
|
+
const e = await _(
|
|
641
644
|
"web_app_open_scan_qr_popup",
|
|
642
645
|
{ text: t },
|
|
643
646
|
["qr_text_received", "scan_qr_popup_closed"],
|
|
@@ -649,41 +652,9 @@ class xt {
|
|
|
649
652
|
}
|
|
650
653
|
}
|
|
651
654
|
}
|
|
652
|
-
|
|
653
|
-
const {
|
|
654
|
-
accentTextColor: t = null,
|
|
655
|
-
backgroundColor: e = null,
|
|
656
|
-
buttonColor: o = null,
|
|
657
|
-
buttonTextColor: n = null,
|
|
658
|
-
destructiveTextColor: r = null,
|
|
659
|
-
headerBackgroundColor: a = null,
|
|
660
|
-
hintColor: h = null,
|
|
661
|
-
linkColor: c = null,
|
|
662
|
-
secondaryBackgroundColor: l = null,
|
|
663
|
-
sectionBackgroundColor: u = null,
|
|
664
|
-
sectionHeaderTextColor: p = null,
|
|
665
|
-
subtitleTextColor: b = null,
|
|
666
|
-
textColor: S = null
|
|
667
|
-
} = s;
|
|
668
|
-
return {
|
|
669
|
-
accentTextColor: t,
|
|
670
|
-
backgroundColor: e,
|
|
671
|
-
buttonColor: o,
|
|
672
|
-
buttonTextColor: n,
|
|
673
|
-
destructiveTextColor: r,
|
|
674
|
-
headerBackgroundColor: a,
|
|
675
|
-
hintColor: h,
|
|
676
|
-
linkColor: c,
|
|
677
|
-
secondaryBackgroundColor: l,
|
|
678
|
-
sectionBackgroundColor: u,
|
|
679
|
-
sectionHeaderTextColor: p,
|
|
680
|
-
subtitleTextColor: b,
|
|
681
|
-
textColor: S
|
|
682
|
-
};
|
|
683
|
-
}
|
|
684
|
-
class q {
|
|
655
|
+
class V {
|
|
685
656
|
constructor(t) {
|
|
686
|
-
i(this, "ee", new
|
|
657
|
+
i(this, "ee", new f());
|
|
687
658
|
i(this, "state");
|
|
688
659
|
/**
|
|
689
660
|
* Adds new event listener.
|
|
@@ -693,7 +664,7 @@ class q {
|
|
|
693
664
|
* Removes event listener.
|
|
694
665
|
*/
|
|
695
666
|
i(this, "off", this.ee.off.bind(this.ee));
|
|
696
|
-
this.state = new
|
|
667
|
+
this.state = new b(t, this.ee);
|
|
697
668
|
}
|
|
698
669
|
/**
|
|
699
670
|
* Requests fresh information about current theme.
|
|
@@ -702,11 +673,11 @@ class q {
|
|
|
702
673
|
* @param options - method options.
|
|
703
674
|
*/
|
|
704
675
|
static async request(t = {}) {
|
|
705
|
-
const { timeout: e = 1e3, ...
|
|
706
|
-
...
|
|
676
|
+
const { timeout: e = 1e3, ...r } = t, o = await _("web_app_request_theme", "theme_changed", {
|
|
677
|
+
...r,
|
|
707
678
|
timeout: e
|
|
708
679
|
});
|
|
709
|
-
return D(
|
|
680
|
+
return D(o.theme_params);
|
|
710
681
|
}
|
|
711
682
|
/**
|
|
712
683
|
* Synchronizes specified instance of ThemeParams with the actual value in the native
|
|
@@ -715,7 +686,7 @@ class q {
|
|
|
715
686
|
*/
|
|
716
687
|
static sync(t) {
|
|
717
688
|
E("theme_changed", (e) => {
|
|
718
|
-
t.state.set(
|
|
689
|
+
t.state.set(D(e.theme_params));
|
|
719
690
|
});
|
|
720
691
|
}
|
|
721
692
|
/**
|
|
@@ -724,65 +695,93 @@ class q {
|
|
|
724
695
|
* @param options - method options.
|
|
725
696
|
*/
|
|
726
697
|
static async synced(t) {
|
|
727
|
-
const e = await this.request(t),
|
|
728
|
-
return this.sync(
|
|
698
|
+
const e = await this.request(t), r = new V(e);
|
|
699
|
+
return this.sync(r), r;
|
|
700
|
+
}
|
|
701
|
+
get accentTextColor() {
|
|
702
|
+
return this.get("accentTextColor");
|
|
729
703
|
}
|
|
730
704
|
/**
|
|
731
705
|
* Returns background color.
|
|
732
706
|
*/
|
|
733
707
|
get backgroundColor() {
|
|
734
|
-
return this.
|
|
708
|
+
return this.get("backgroundColor");
|
|
735
709
|
}
|
|
736
710
|
/**
|
|
737
711
|
* Returns button color.
|
|
738
712
|
*/
|
|
739
713
|
get buttonColor() {
|
|
740
|
-
return this.
|
|
714
|
+
return this.get("buttonColor");
|
|
741
715
|
}
|
|
742
716
|
/**
|
|
743
717
|
* Returns button text color.
|
|
744
718
|
*/
|
|
745
719
|
get buttonTextColor() {
|
|
746
|
-
return this.
|
|
720
|
+
return this.get("buttonTextColor");
|
|
721
|
+
}
|
|
722
|
+
get destructiveTextColor() {
|
|
723
|
+
return this.get("destructiveTextColor");
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Retrieves palette color value by its name.
|
|
727
|
+
* @param key - palette key name.
|
|
728
|
+
*/
|
|
729
|
+
get(t) {
|
|
730
|
+
return this.state.get(t) || null;
|
|
731
|
+
}
|
|
732
|
+
getState() {
|
|
733
|
+
return this.state.getState();
|
|
734
|
+
}
|
|
735
|
+
get headerBackgroundColor() {
|
|
736
|
+
return this.get("headerBackgroundColor");
|
|
747
737
|
}
|
|
748
738
|
/**
|
|
749
739
|
* Returns hint color.
|
|
750
740
|
*/
|
|
751
741
|
get hintColor() {
|
|
752
|
-
return this.
|
|
742
|
+
return this.get("hintColor");
|
|
753
743
|
}
|
|
754
744
|
/**
|
|
755
745
|
* Returns true in case, current color scheme is recognized as dark. This
|
|
756
746
|
* value is calculated according to theme background color.
|
|
757
747
|
*/
|
|
758
748
|
get isDark() {
|
|
759
|
-
return this.backgroundColor === null ||
|
|
749
|
+
return this.backgroundColor === null || U(this.backgroundColor);
|
|
760
750
|
}
|
|
761
751
|
/**
|
|
762
752
|
* Returns current link color.
|
|
763
753
|
*/
|
|
764
754
|
get linkColor() {
|
|
765
|
-
return this.
|
|
755
|
+
return this.get("linkColor");
|
|
766
756
|
}
|
|
767
757
|
/**
|
|
768
758
|
* Returns secondary background color.
|
|
769
759
|
*/
|
|
770
760
|
get secondaryBackgroundColor() {
|
|
771
|
-
return this.
|
|
761
|
+
return this.get("secondaryBackgroundColor");
|
|
762
|
+
}
|
|
763
|
+
get sectionBackgroundColor() {
|
|
764
|
+
return this.get("sectionBackgroundColor");
|
|
765
|
+
}
|
|
766
|
+
get sectionHeaderTextColor() {
|
|
767
|
+
return this.get("sectionHeaderTextColor");
|
|
768
|
+
}
|
|
769
|
+
get subtitleTextColor() {
|
|
770
|
+
return this.get("subtitleTextColor");
|
|
772
771
|
}
|
|
773
772
|
/**
|
|
774
773
|
* Returns text color.
|
|
775
774
|
*/
|
|
776
775
|
get textColor() {
|
|
777
|
-
return this.
|
|
776
|
+
return this.get("textColor");
|
|
778
777
|
}
|
|
779
778
|
}
|
|
780
|
-
function
|
|
779
|
+
function v(s) {
|
|
781
780
|
return s < 0 ? 0 : s;
|
|
782
781
|
}
|
|
783
|
-
class
|
|
784
|
-
constructor(t, e, o, n
|
|
785
|
-
i(this, "ee", new
|
|
782
|
+
class y {
|
|
783
|
+
constructor(t, e, r, o, n = g) {
|
|
784
|
+
i(this, "ee", new f());
|
|
786
785
|
i(this, "state");
|
|
787
786
|
/**
|
|
788
787
|
* Adds new event listener.
|
|
@@ -792,11 +791,11 @@ class k {
|
|
|
792
791
|
* Removes event listener.
|
|
793
792
|
*/
|
|
794
793
|
i(this, "off", this.ee.off.bind(this.ee));
|
|
795
|
-
this.postEvent =
|
|
796
|
-
height:
|
|
797
|
-
isExpanded:
|
|
798
|
-
stableHeight:
|
|
799
|
-
width:
|
|
794
|
+
this.postEvent = n, this.state = new b({
|
|
795
|
+
height: v(t),
|
|
796
|
+
isExpanded: o,
|
|
797
|
+
stableHeight: v(r),
|
|
798
|
+
width: v(e)
|
|
800
799
|
}, this.ee);
|
|
801
800
|
}
|
|
802
801
|
/**
|
|
@@ -807,15 +806,15 @@ class k {
|
|
|
807
806
|
* @param options - method options.
|
|
808
807
|
*/
|
|
809
808
|
static async request(t = {}) {
|
|
810
|
-
const { timeout: e = 1e3, ...
|
|
811
|
-
is_expanded:
|
|
812
|
-
is_state_stable:
|
|
809
|
+
const { timeout: e = 1e3, ...r } = t, {
|
|
810
|
+
is_expanded: o,
|
|
811
|
+
is_state_stable: n,
|
|
813
812
|
...a
|
|
814
|
-
} = await
|
|
815
|
-
...
|
|
813
|
+
} = await _("web_app_request_viewport", "viewport_changed", {
|
|
814
|
+
...r,
|
|
816
815
|
timeout: e
|
|
817
816
|
});
|
|
818
|
-
return { ...a, isExpanded:
|
|
817
|
+
return { ...a, isExpanded: o, isStateStable: n };
|
|
819
818
|
}
|
|
820
819
|
/**
|
|
821
820
|
* Synchronizes specified instance of Viewport with the actual value in the native
|
|
@@ -825,16 +824,16 @@ class k {
|
|
|
825
824
|
static sync(t) {
|
|
826
825
|
E("viewport_changed", (e) => {
|
|
827
826
|
const {
|
|
828
|
-
height:
|
|
829
|
-
width:
|
|
830
|
-
is_expanded:
|
|
827
|
+
height: r,
|
|
828
|
+
width: o,
|
|
829
|
+
is_expanded: n,
|
|
831
830
|
is_state_stable: a
|
|
832
|
-
} = e,
|
|
831
|
+
} = e, u = v(r);
|
|
833
832
|
t.state.set({
|
|
834
|
-
height:
|
|
835
|
-
isExpanded:
|
|
836
|
-
width:
|
|
837
|
-
stableHeight: a ?
|
|
833
|
+
height: u,
|
|
834
|
+
isExpanded: n,
|
|
835
|
+
width: v(o),
|
|
836
|
+
stableHeight: a ? u : void 0
|
|
838
837
|
});
|
|
839
838
|
});
|
|
840
839
|
}
|
|
@@ -844,8 +843,8 @@ class k {
|
|
|
844
843
|
* @param options - method options.
|
|
845
844
|
*/
|
|
846
845
|
static async synced(t = {}) {
|
|
847
|
-
const { height: e, isExpanded:
|
|
848
|
-
return this.sync(
|
|
846
|
+
const { height: e, isExpanded: r, width: o } = await this.request(t), n = new y(e, o, e, r, t.postEvent);
|
|
847
|
+
return this.sync(n), n;
|
|
849
848
|
}
|
|
850
849
|
/**
|
|
851
850
|
* The current height of the visible area of the Mini App.
|
|
@@ -923,7 +922,7 @@ class k {
|
|
|
923
922
|
return this.stableHeight === this.height;
|
|
924
923
|
}
|
|
925
924
|
}
|
|
926
|
-
function
|
|
925
|
+
function T(s) {
|
|
927
926
|
const t = document.createElement("a");
|
|
928
927
|
if (t.href = s, t.protocol !== "http:" && t.protocol !== "https:")
|
|
929
928
|
throw Error(
|
|
@@ -931,9 +930,9 @@ function I(s) {
|
|
|
931
930
|
);
|
|
932
931
|
return t.href;
|
|
933
932
|
}
|
|
934
|
-
class
|
|
935
|
-
constructor(t, e, o, n,
|
|
936
|
-
i(this, "ee", new
|
|
933
|
+
class xt {
|
|
934
|
+
constructor(t, e, r, o, n, a = g) {
|
|
935
|
+
i(this, "ee", new f());
|
|
937
936
|
i(this, "state");
|
|
938
937
|
/**
|
|
939
938
|
* Adds new event listener.
|
|
@@ -951,17 +950,17 @@ class Vt {
|
|
|
951
950
|
* Checks if specified method parameter is supported by current component.
|
|
952
951
|
*/
|
|
953
952
|
i(this, "supportsParam");
|
|
954
|
-
this.currentVersion =
|
|
953
|
+
this.currentVersion = r, this.currentPlatform = o, this.createRequestId = n, this.postEvent = a, this.state = new b({
|
|
955
954
|
backgroundColor: e,
|
|
956
955
|
headerColor: t
|
|
957
|
-
}, this.ee), this.supports =
|
|
956
|
+
}, this.ee), this.supports = m(r, {
|
|
958
957
|
openInvoice: "web_app_open_invoice",
|
|
959
958
|
readTextFromClipboard: "web_app_read_text_from_clipboard",
|
|
960
959
|
setHeaderColor: "web_app_set_header_color",
|
|
961
960
|
setBackgroundColor: "web_app_set_background_color",
|
|
962
961
|
requestPhoneAccess: "web_app_request_phone",
|
|
963
962
|
requestWriteAccess: "web_app_request_write_access"
|
|
964
|
-
}), this.supportsParam =
|
|
963
|
+
}), this.supportsParam = gt(r, {
|
|
965
964
|
"setHeaderColor.color": ["web_app_set_header_color", "color"],
|
|
966
965
|
"openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
|
|
967
966
|
});
|
|
@@ -977,7 +976,7 @@ class Vt {
|
|
|
977
976
|
* computed based on the current background color.
|
|
978
977
|
*/
|
|
979
978
|
get colorScheme() {
|
|
980
|
-
return
|
|
979
|
+
return U(this.backgroundColor) ? "dark" : "light";
|
|
981
980
|
}
|
|
982
981
|
/**
|
|
983
982
|
* Closes the Mini App.
|
|
@@ -997,7 +996,7 @@ class Vt {
|
|
|
997
996
|
* @param version - compared version.
|
|
998
997
|
*/
|
|
999
998
|
isVersionAtLeast(t) {
|
|
1000
|
-
return
|
|
999
|
+
return lt(t, this.version) >= 0;
|
|
1001
1000
|
}
|
|
1002
1001
|
/**
|
|
1003
1002
|
* Opens a link in an external browser. The Mini App will not be closed.
|
|
@@ -1009,13 +1008,13 @@ class Vt {
|
|
|
1009
1008
|
* @param tryInstantView
|
|
1010
1009
|
*/
|
|
1011
1010
|
openLink(t, e) {
|
|
1012
|
-
const
|
|
1013
|
-
if (!
|
|
1014
|
-
window.open(
|
|
1011
|
+
const r = T(t);
|
|
1012
|
+
if (!S("web_app_open_link", this.version)) {
|
|
1013
|
+
window.open(r, "_blank");
|
|
1015
1014
|
return;
|
|
1016
1015
|
}
|
|
1017
1016
|
return this.postEvent("web_app_open_link", {
|
|
1018
|
-
url:
|
|
1017
|
+
url: r,
|
|
1019
1018
|
...typeof e == "boolean" ? { try_instant_view: e } : {}
|
|
1020
1019
|
});
|
|
1021
1020
|
}
|
|
@@ -1026,14 +1025,14 @@ class Vt {
|
|
|
1026
1025
|
* @throws {Error} URL has not allowed hostname.
|
|
1027
1026
|
*/
|
|
1028
1027
|
openTelegramLink(t) {
|
|
1029
|
-
const { hostname: e, pathname:
|
|
1028
|
+
const { hostname: e, pathname: r, search: o } = new URL(T(t));
|
|
1030
1029
|
if (e !== "t.me")
|
|
1031
1030
|
throw new Error(`URL has not allowed hostname: ${e}. Only "t.me" is allowed`);
|
|
1032
|
-
if (!
|
|
1031
|
+
if (!S("web_app_open_tg_link", this.version)) {
|
|
1033
1032
|
window.location.href = t;
|
|
1034
1033
|
return;
|
|
1035
1034
|
}
|
|
1036
|
-
return this.postEvent("web_app_open_tg_link", { path_full:
|
|
1035
|
+
return this.postEvent("web_app_open_tg_link", { path_full: r + o });
|
|
1037
1036
|
}
|
|
1038
1037
|
/**
|
|
1039
1038
|
* Opens an invoice using its url. It expects passing link in full format,
|
|
@@ -1041,16 +1040,16 @@ class Vt {
|
|
|
1041
1040
|
* @param url - invoice URL.
|
|
1042
1041
|
*/
|
|
1043
1042
|
async openInvoice(t) {
|
|
1044
|
-
const { hostname: e, pathname:
|
|
1043
|
+
const { hostname: e, pathname: r } = new URL(T(t));
|
|
1045
1044
|
if (e !== "t.me")
|
|
1046
1045
|
throw new Error(`Incorrect hostname: ${e}`);
|
|
1047
|
-
const
|
|
1048
|
-
if (
|
|
1046
|
+
const o = r.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
|
|
1047
|
+
if (o === null)
|
|
1049
1048
|
throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/slug" or "/$slug"');
|
|
1050
|
-
const [, ,
|
|
1051
|
-
return (await
|
|
1049
|
+
const [, , n] = o;
|
|
1050
|
+
return (await _("web_app_open_invoice", { slug: n }, "invoice_closed", {
|
|
1052
1051
|
postEvent: this.postEvent,
|
|
1053
|
-
capture: ({ slug:
|
|
1052
|
+
capture: ({ slug: u }) => n === u
|
|
1054
1053
|
})).status;
|
|
1055
1054
|
}
|
|
1056
1055
|
/**
|
|
@@ -1079,7 +1078,7 @@ class Vt {
|
|
|
1079
1078
|
* - Access to clipboard is not allowed
|
|
1080
1079
|
*/
|
|
1081
1080
|
async readTextFromClipboard() {
|
|
1082
|
-
const { data: t = null } = await
|
|
1081
|
+
const { data: t = null } = await _(
|
|
1083
1082
|
"web_app_read_text_from_clipboard",
|
|
1084
1083
|
{ req_id: this.createRequestId() },
|
|
1085
1084
|
"clipboard_text_received",
|
|
@@ -1091,7 +1090,7 @@ class Vt {
|
|
|
1091
1090
|
* Requests current user phone access.
|
|
1092
1091
|
*/
|
|
1093
1092
|
async requestPhoneAccess() {
|
|
1094
|
-
const { status: t } = await
|
|
1093
|
+
const { status: t } = await _("web_app_request_phone", "phone_requested", {
|
|
1095
1094
|
postEvent: this.postEvent
|
|
1096
1095
|
});
|
|
1097
1096
|
return t;
|
|
@@ -1100,7 +1099,7 @@ class Vt {
|
|
|
1100
1099
|
* Requests write message access to current user.
|
|
1101
1100
|
*/
|
|
1102
1101
|
async requestWriteAccess() {
|
|
1103
|
-
const { status: t } = await
|
|
1102
|
+
const { status: t } = await _("web_app_request_write_access", "write_access_requested", {
|
|
1104
1103
|
postEvent: this.postEvent
|
|
1105
1104
|
});
|
|
1106
1105
|
return t;
|
|
@@ -1151,242 +1150,236 @@ class Vt {
|
|
|
1151
1150
|
return this.currentVersion;
|
|
1152
1151
|
}
|
|
1153
1152
|
}
|
|
1154
|
-
class
|
|
1153
|
+
class K extends Error {
|
|
1155
1154
|
constructor(t, e) {
|
|
1156
|
-
super(`Method "${t}" is not supported in the Mini Apps version ${e}.`), Object.setPrototypeOf(this,
|
|
1155
|
+
super(`Method "${t}" is not supported in the Mini Apps version ${e}.`), Object.setPrototypeOf(this, K.prototype);
|
|
1157
1156
|
}
|
|
1158
1157
|
}
|
|
1159
1158
|
class j extends Error {
|
|
1160
|
-
constructor(t, e,
|
|
1161
|
-
super(`Parameter "${e}" in method "${t}" is not supported in the Mini Apps version ${
|
|
1159
|
+
constructor(t, e, r) {
|
|
1160
|
+
super(`Parameter "${e}" in method "${t}" is not supported in the Mini Apps version ${r}.`), Object.setPrototypeOf(this, j.prototype);
|
|
1162
1161
|
}
|
|
1163
1162
|
}
|
|
1164
|
-
function
|
|
1163
|
+
function F(s, t) {
|
|
1165
1164
|
document.documentElement.style.setProperty(s, t);
|
|
1166
1165
|
}
|
|
1167
|
-
function
|
|
1168
|
-
t !== null &&
|
|
1166
|
+
function B(s, t) {
|
|
1167
|
+
t !== null && F(s, t);
|
|
1169
1168
|
}
|
|
1170
|
-
function
|
|
1171
|
-
|
|
1169
|
+
function M(s, t) {
|
|
1170
|
+
F(s, `${t}px`);
|
|
1172
1171
|
}
|
|
1173
|
-
function St(s) {
|
|
1174
|
-
const {
|
|
1175
|
-
|
|
1176
|
-
buttonTextColor: e,
|
|
1177
|
-
secondaryBackgroundColor: o,
|
|
1178
|
-
hintColor: n,
|
|
1179
|
-
buttonColor: r,
|
|
1180
|
-
linkColor: a,
|
|
1181
|
-
textColor: h
|
|
1182
|
-
} = s;
|
|
1183
|
-
_("--tg-theme-bg-color", t), _("--tg-theme-button-color", r), _("--tg-theme-button-text-color", e), _("--tg-theme-hint-color", n), _("--tg-theme-link-color", a), _("--tg-theme-secondary-bg-color", o), _("--tg-theme-text-color", h);
|
|
1184
|
-
}
|
|
1185
|
-
function Pt(s, t) {
|
|
1186
|
-
const { backgroundColor: e, secondaryBackgroundColor: o } = t, { backgroundColor: n, headerColor: r } = s;
|
|
1187
|
-
_("--tg-bg-color", n), _("--tg-header-color", r === "bg_color" ? e : o);
|
|
1172
|
+
function St(s, t) {
|
|
1173
|
+
const { backgroundColor: e, secondaryBackgroundColor: r } = t, { backgroundColor: o, headerColor: n } = s;
|
|
1174
|
+
B("--tg-bg-color", o), B("--tg-header-color", n === "bg_color" ? e : r);
|
|
1188
1175
|
}
|
|
1189
|
-
function
|
|
1190
|
-
const t = () =>
|
|
1176
|
+
function Vt(s) {
|
|
1177
|
+
const t = () => {
|
|
1178
|
+
const e = s.getState();
|
|
1179
|
+
Object.entries(e).forEach(([r, o]) => {
|
|
1180
|
+
const n = r.replace(/[A-Z]/g, (a) => `-${a.toLowerCase()}`);
|
|
1181
|
+
B(`--tg-theme-${n}`, o || null);
|
|
1182
|
+
});
|
|
1183
|
+
};
|
|
1191
1184
|
s.on("changed", t), t();
|
|
1192
1185
|
}
|
|
1193
|
-
function
|
|
1194
|
-
const e = () =>
|
|
1186
|
+
function Pt(s, t) {
|
|
1187
|
+
const e = () => St(s, t);
|
|
1195
1188
|
t.on("changed", e), s.on("backgroundColorChanged", e), s.on("headerColorChanged", e), e();
|
|
1196
1189
|
}
|
|
1197
|
-
function
|
|
1190
|
+
function qt(s) {
|
|
1198
1191
|
const t = () => {
|
|
1199
|
-
|
|
1192
|
+
M("--tg-viewport-height", s.height);
|
|
1200
1193
|
}, e = () => {
|
|
1201
|
-
|
|
1194
|
+
M("--tg-viewport-stable-height", s.stableHeight);
|
|
1202
1195
|
};
|
|
1203
1196
|
s.on("heightChanged", t), s.on("stableHeightChanged", e), t(), e();
|
|
1204
1197
|
}
|
|
1205
|
-
function
|
|
1198
|
+
function Ot(s) {
|
|
1206
1199
|
return typeof s == "boolean" ? s ? { themeParams: !0, viewport: !0, webApp: !0 } : {} : s;
|
|
1207
1200
|
}
|
|
1208
|
-
function
|
|
1201
|
+
function J(s) {
|
|
1209
1202
|
return `telegram-mini-apps-${s}`;
|
|
1210
1203
|
}
|
|
1211
|
-
function
|
|
1212
|
-
sessionStorage.setItem(
|
|
1204
|
+
function k(s, t) {
|
|
1205
|
+
sessionStorage.setItem(J(s), JSON.stringify(t));
|
|
1213
1206
|
}
|
|
1214
|
-
function
|
|
1215
|
-
const t = sessionStorage.getItem(
|
|
1207
|
+
function x(s) {
|
|
1208
|
+
const t = sessionStorage.getItem(J(s));
|
|
1216
1209
|
return t ? JSON.parse(t) : null;
|
|
1217
1210
|
}
|
|
1218
|
-
function
|
|
1219
|
-
const { isVisible:
|
|
1220
|
-
return
|
|
1221
|
-
|
|
1222
|
-
}),
|
|
1211
|
+
function Tt(s, t, e) {
|
|
1212
|
+
const { isVisible: r = !1 } = s ? x("back-button") || {} : {}, o = new _t(r, t, e);
|
|
1213
|
+
return o.on("isVisibleChanged", () => {
|
|
1214
|
+
k("back-button", { isVisible: o.isVisible });
|
|
1215
|
+
}), o;
|
|
1223
1216
|
}
|
|
1224
|
-
function
|
|
1225
|
-
const { isConfirmationNeeded: e = !1 } = s ?
|
|
1226
|
-
return
|
|
1227
|
-
isConfirmationNeeded:
|
|
1228
|
-
})),
|
|
1217
|
+
function Bt(s, t) {
|
|
1218
|
+
const { isConfirmationNeeded: e = !1 } = s ? x("closing-behavior") || {} : {}, r = new bt(e, t);
|
|
1219
|
+
return r.on("isConfirmationNeededChanged", () => k("closing-behavior", {
|
|
1220
|
+
isConfirmationNeeded: r.isConfirmationNeeded
|
|
1221
|
+
})), r;
|
|
1229
1222
|
}
|
|
1230
|
-
function
|
|
1223
|
+
function $t(s, t, e, r) {
|
|
1231
1224
|
const {
|
|
1232
|
-
backgroundColor:
|
|
1233
|
-
isEnabled:
|
|
1225
|
+
backgroundColor: o = t,
|
|
1226
|
+
isEnabled: n = !1,
|
|
1234
1227
|
isVisible: a = !1,
|
|
1235
|
-
isProgressVisible:
|
|
1228
|
+
isProgressVisible: u = !1,
|
|
1236
1229
|
textColor: c = e,
|
|
1237
|
-
text:
|
|
1238
|
-
} = s ?
|
|
1230
|
+
text: p = ""
|
|
1231
|
+
} = s ? x("main-button") || {} : {}, h = new vt(
|
|
1232
|
+
o,
|
|
1239
1233
|
n,
|
|
1240
|
-
r,
|
|
1241
1234
|
a,
|
|
1242
|
-
|
|
1243
|
-
|
|
1235
|
+
u,
|
|
1236
|
+
p,
|
|
1244
1237
|
c,
|
|
1245
|
-
|
|
1246
|
-
),
|
|
1247
|
-
backgroundColor:
|
|
1248
|
-
isEnabled:
|
|
1249
|
-
isVisible:
|
|
1250
|
-
isProgressVisible:
|
|
1251
|
-
text:
|
|
1252
|
-
textColor:
|
|
1238
|
+
r
|
|
1239
|
+
), d = () => k("main-button", {
|
|
1240
|
+
backgroundColor: h.backgroundColor,
|
|
1241
|
+
isEnabled: h.isEnabled,
|
|
1242
|
+
isVisible: h.isVisible,
|
|
1243
|
+
isProgressVisible: h.isProgressVisible,
|
|
1244
|
+
text: h.text,
|
|
1245
|
+
textColor: h.textColor
|
|
1253
1246
|
});
|
|
1254
|
-
return
|
|
1247
|
+
return h.on("backgroundColorChanged", d), h.on("isEnabledChanged", d), h.on("isVisibleChanged", d), h.on("isProgressVisibleChanged", d), h.on("textColorChanged", d), h.on("textChanged", d), h;
|
|
1255
1248
|
}
|
|
1256
|
-
function
|
|
1249
|
+
function It() {
|
|
1257
1250
|
let s = 0;
|
|
1258
1251
|
return () => (s += 1, s.toString());
|
|
1259
1252
|
}
|
|
1260
|
-
function
|
|
1261
|
-
const t = new
|
|
1262
|
-
return
|
|
1253
|
+
function At(s) {
|
|
1254
|
+
const t = new V(s);
|
|
1255
|
+
return V.sync(t), t;
|
|
1263
1256
|
}
|
|
1264
|
-
async function
|
|
1257
|
+
async function Ht(s, t, e) {
|
|
1265
1258
|
const {
|
|
1266
|
-
height:
|
|
1267
|
-
stableHeight:
|
|
1268
|
-
width:
|
|
1259
|
+
height: r = window.innerHeight,
|
|
1260
|
+
stableHeight: o = window.innerHeight,
|
|
1261
|
+
width: n = window.innerWidth,
|
|
1269
1262
|
isExpanded: a = !1
|
|
1270
|
-
} = s ?
|
|
1271
|
-
const
|
|
1272
|
-
return
|
|
1273
|
-
})() : await
|
|
1263
|
+
} = s ? x("viewport") || {} : {}, c = t === "macos" || t === "web" ? (() => {
|
|
1264
|
+
const h = new y(r, n, o, a, e);
|
|
1265
|
+
return y.sync(h), h;
|
|
1266
|
+
})() : await y.synced({ postEvent: e }), p = () => k("viewport", {
|
|
1274
1267
|
height: c.height,
|
|
1275
1268
|
isExpanded: c.isExpanded,
|
|
1276
1269
|
stableHeight: c.stableHeight,
|
|
1277
1270
|
width: c.width
|
|
1278
1271
|
});
|
|
1279
|
-
return c.on("heightChanged",
|
|
1272
|
+
return c.on("heightChanged", p), c.on("isExpandedChanged", p), c.on("stableHeightChanged", p), c.on("widthChanged", p), c;
|
|
1280
1273
|
}
|
|
1281
|
-
function
|
|
1274
|
+
function Rt(s, t, e, r, o, n) {
|
|
1282
1275
|
const {
|
|
1283
1276
|
backgroundColor: a = t,
|
|
1284
|
-
headerColor:
|
|
1285
|
-
} = s ?
|
|
1286
|
-
|
|
1277
|
+
headerColor: u = "bg_color"
|
|
1278
|
+
} = s ? x("web-app") || {} : {}, c = new xt(
|
|
1279
|
+
u,
|
|
1287
1280
|
a,
|
|
1288
1281
|
e,
|
|
1282
|
+
r,
|
|
1289
1283
|
o,
|
|
1290
|
-
n
|
|
1291
|
-
|
|
1292
|
-
), l = () => x("web-app", {
|
|
1284
|
+
n
|
|
1285
|
+
), p = () => k("web-app", {
|
|
1293
1286
|
backgroundColor: c.backgroundColor,
|
|
1294
1287
|
headerColor: c.headerColor
|
|
1295
1288
|
});
|
|
1296
|
-
return c.on("backgroundColorChanged",
|
|
1289
|
+
return c.on("backgroundColorChanged", p), c.on("headerColorChanged", p), c;
|
|
1297
1290
|
}
|
|
1298
|
-
async function
|
|
1291
|
+
async function Dt(s = {}) {
|
|
1299
1292
|
const {
|
|
1300
1293
|
checkCompat: t = !0,
|
|
1301
1294
|
cssVars: e = !1,
|
|
1302
|
-
acceptScrollbarStyle:
|
|
1303
|
-
acceptCustomStyles:
|
|
1304
|
-
targetOrigin:
|
|
1295
|
+
acceptScrollbarStyle: r = !0,
|
|
1296
|
+
acceptCustomStyles: o = r,
|
|
1297
|
+
targetOrigin: n,
|
|
1305
1298
|
launchParams: a,
|
|
1306
|
-
debug:
|
|
1299
|
+
debug: u = !1
|
|
1307
1300
|
} = s;
|
|
1308
|
-
|
|
1309
|
-
const { launchParams: c, isPageReload:
|
|
1310
|
-
currentLaunchParams: typeof a == "string" || a instanceof URLSearchParams ?
|
|
1301
|
+
u && nt(u), typeof n == "string" && it(n);
|
|
1302
|
+
const { launchParams: c, isPageReload: p } = N({
|
|
1303
|
+
currentLaunchParams: typeof a == "string" || a instanceof URLSearchParams ? ot(a) : a
|
|
1311
1304
|
}), {
|
|
1312
|
-
initData:
|
|
1313
|
-
initDataRaw:
|
|
1314
|
-
version:
|
|
1315
|
-
platform:
|
|
1316
|
-
themeParams:
|
|
1305
|
+
initData: h,
|
|
1306
|
+
initDataRaw: d,
|
|
1307
|
+
version: w,
|
|
1308
|
+
platform: $,
|
|
1309
|
+
themeParams: I
|
|
1317
1310
|
} = c, {
|
|
1318
|
-
backgroundColor:
|
|
1319
|
-
buttonColor:
|
|
1320
|
-
buttonTextColor:
|
|
1321
|
-
} =
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1311
|
+
backgroundColor: G = "#ffffff",
|
|
1312
|
+
buttonColor: Q = "#000000",
|
|
1313
|
+
buttonTextColor: Z = "#ffffff"
|
|
1314
|
+
} = I, A = It(), l = t ? at(w) : g, P = At(I), H = Rt(
|
|
1315
|
+
p,
|
|
1316
|
+
G,
|
|
1317
|
+
w,
|
|
1318
|
+
$,
|
|
1326
1319
|
A,
|
|
1327
|
-
|
|
1320
|
+
l
|
|
1328
1321
|
), {
|
|
1329
|
-
themeParams:
|
|
1330
|
-
viewport:
|
|
1331
|
-
webApp:
|
|
1332
|
-
} =
|
|
1333
|
-
|
|
1334
|
-
const R = await
|
|
1335
|
-
if (
|
|
1336
|
-
const
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
}),
|
|
1340
|
-
}
|
|
1341
|
-
const
|
|
1342
|
-
backButton:
|
|
1343
|
-
closingBehavior:
|
|
1344
|
-
cloudStorage: new wt(
|
|
1345
|
-
haptic: new
|
|
1346
|
-
mainButton:
|
|
1347
|
-
popup: new Et(
|
|
1348
|
-
postEvent:
|
|
1349
|
-
qrScanner: new
|
|
1350
|
-
themeParams:
|
|
1322
|
+
themeParams: X,
|
|
1323
|
+
viewport: Y,
|
|
1324
|
+
webApp: tt
|
|
1325
|
+
} = Ot(e);
|
|
1326
|
+
tt && Pt(H, P), X && Vt(P);
|
|
1327
|
+
const R = await Ht(p, $, l);
|
|
1328
|
+
if (Y && qt(R), o && ct()) {
|
|
1329
|
+
const C = document.createElement("style");
|
|
1330
|
+
C.id = "telegram-custom-styles", document.head.appendChild(C), E("set_custom_style", (O) => {
|
|
1331
|
+
C.innerHTML = O;
|
|
1332
|
+
}), l("iframe_ready");
|
|
1333
|
+
}
|
|
1334
|
+
const q = {
|
|
1335
|
+
backButton: Tt(p, w, l),
|
|
1336
|
+
closingBehavior: Bt(p, l),
|
|
1337
|
+
cloudStorage: new wt(w, A, l),
|
|
1338
|
+
haptic: new mt(w, l),
|
|
1339
|
+
mainButton: $t(p, Q, Z, l),
|
|
1340
|
+
popup: new Et(w, l),
|
|
1341
|
+
postEvent: l,
|
|
1342
|
+
qrScanner: new kt(w, l),
|
|
1343
|
+
themeParams: P,
|
|
1351
1344
|
viewport: R,
|
|
1352
1345
|
webApp: H
|
|
1353
1346
|
};
|
|
1354
|
-
if (
|
|
1355
|
-
const { authDate:
|
|
1356
|
-
|
|
1347
|
+
if (h !== void 0) {
|
|
1348
|
+
const { authDate: C, hash: O, ...et } = h;
|
|
1349
|
+
q.initData = new Ct(C, O, et), q.initDataRaw = d;
|
|
1357
1350
|
}
|
|
1358
|
-
return
|
|
1351
|
+
return q;
|
|
1359
1352
|
}
|
|
1360
|
-
function
|
|
1361
|
-
return
|
|
1353
|
+
function Jt(s = {}) {
|
|
1354
|
+
return dt(Dt(s), s.timeout || 1e3);
|
|
1362
1355
|
}
|
|
1363
|
-
function
|
|
1356
|
+
function Lt() {
|
|
1364
1357
|
try {
|
|
1365
|
-
return
|
|
1358
|
+
return N(), !0;
|
|
1366
1359
|
} catch {
|
|
1367
1360
|
return !1;
|
|
1368
1361
|
}
|
|
1369
1362
|
}
|
|
1370
|
-
function
|
|
1371
|
-
return
|
|
1363
|
+
function Gt() {
|
|
1364
|
+
return Lt();
|
|
1372
1365
|
}
|
|
1373
1366
|
export {
|
|
1374
1367
|
_t as BackButton,
|
|
1375
|
-
|
|
1368
|
+
bt as ClosingBehaviour,
|
|
1376
1369
|
wt as CloudStorage,
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1370
|
+
mt as HapticFeedback,
|
|
1371
|
+
Ct as InitData,
|
|
1372
|
+
vt as MainButton,
|
|
1373
|
+
K as MethodNotSupportedError,
|
|
1381
1374
|
j as ParameterUnsupportedError,
|
|
1382
1375
|
Et as Popup,
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1376
|
+
kt as QRScanner,
|
|
1377
|
+
V as ThemeParams,
|
|
1378
|
+
y as Viewport,
|
|
1379
|
+
xt as WebApp,
|
|
1380
|
+
T as formatURL,
|
|
1381
|
+
Jt as init,
|
|
1382
|
+
Lt as isTMA,
|
|
1383
|
+
Gt as isTWA
|
|
1391
1384
|
};
|
|
1392
1385
|
//# sourceMappingURL=index.mjs.map
|