@tma.js/sdk 1.4.2 → 1.4.4
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/classnames/mergeClassNames.d.ts +9 -12
- package/dist/dts/{init/css → css}/bindMiniAppCSSVars.d.ts +2 -2
- package/dist/dts/{init/css → css}/bindThemeCSSVars.d.ts +1 -1
- package/dist/dts/{init/css → css}/bindViewportCSSVars.d.ts +1 -1
- package/dist/dts/css/index.d.ts +4 -0
- package/dist/dts/index.d.ts +1 -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 +263 -251
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/bridge/events/__tests__/onTelegramEvent.ts +5 -7
- package/src/bridge/events/onTelegramEvent.ts +7 -1
- package/src/classnames/__tests__/mergeClassNames.ts +1 -1
- package/src/classnames/mergeClassNames.ts +16 -24
- package/src/css/__tests__/bindMiniAppCSSVars.ts +175 -0
- package/src/css/__tests__/bindThemeCSSVars.ts +52 -0
- package/src/css/__tests__/bindViewportCSSVars.ts +55 -0
- package/src/css/__tests__/setCSSVar.ts +14 -0
- package/src/{init/css → css}/bindMiniAppCSSVars.ts +13 -10
- package/src/{init/css → css}/bindViewportCSSVars.ts +1 -1
- package/src/css/index.ts +4 -0
- package/src/index.ts +6 -0
- package/src/init/css/processCSSVarsOption.ts +1 -3
- /package/dist/dts/{init/css → css}/setCSSVar.d.ts +0 -0
- /package/src/{init/css → css}/bindThemeCSSVars.ts +0 -0
- /package/src/{init/css → css}/setCSSVar.ts +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
var Rt = Object.defineProperty;
|
|
2
2
|
var It = (r, t, e) => t in r ? Rt(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
3
|
var o = (r, t, e) => (It(r, typeof t != "symbol" ? t + "" : t, e), e);
|
|
4
|
-
function
|
|
4
|
+
function R(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
10
|
function Lt() {
|
|
11
|
-
const r =
|
|
11
|
+
const r = ht();
|
|
12
12
|
return r ? r.type === "reload" : null;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function L() {
|
|
15
15
|
return new TypeError("Value has unexpected type");
|
|
16
16
|
}
|
|
17
17
|
class F extends Error {
|
|
@@ -50,7 +50,7 @@ function $t(r) {
|
|
|
50
50
|
return t;
|
|
51
51
|
} catch {
|
|
52
52
|
}
|
|
53
|
-
throw
|
|
53
|
+
throw L();
|
|
54
54
|
}
|
|
55
55
|
class Tt extends z {
|
|
56
56
|
constructor(e, s, n) {
|
|
@@ -66,15 +66,15 @@ class Tt extends z {
|
|
|
66
66
|
return this.itemParser = typeof e == "function" ? e : e.parse.bind(e), this;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function $(r, t) {
|
|
70
70
|
return () => new z(r, !1, t);
|
|
71
71
|
}
|
|
72
|
-
class
|
|
72
|
+
class j extends Error {
|
|
73
73
|
constructor(t, { cause: e, type: s } = {}) {
|
|
74
|
-
super(`Unable to parse field "${t}"${s ? ` as ${s}` : ""}`, { cause: e }), Object.setPrototypeOf(this,
|
|
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 pt(r, t) {
|
|
78
78
|
const e = {};
|
|
79
79
|
for (const s in r) {
|
|
80
80
|
const n = r[s];
|
|
@@ -92,10 +92,10 @@ function ht(r, t) {
|
|
|
92
92
|
try {
|
|
93
93
|
c = a(p);
|
|
94
94
|
} catch (h) {
|
|
95
|
-
throw h instanceof F ? new
|
|
95
|
+
throw h instanceof F ? new j(i, {
|
|
96
96
|
type: h.type,
|
|
97
97
|
cause: h
|
|
98
|
-
}) : new
|
|
98
|
+
}) : new j(i, { cause: h });
|
|
99
99
|
}
|
|
100
100
|
c !== void 0 && (e[s] = c);
|
|
101
101
|
}
|
|
@@ -104,7 +104,7 @@ function ht(r, t) {
|
|
|
104
104
|
function Bt(r) {
|
|
105
105
|
return new Tt((t) => t, !1, r);
|
|
106
106
|
}
|
|
107
|
-
const k =
|
|
107
|
+
const k = $((r) => {
|
|
108
108
|
if (typeof r == "boolean")
|
|
109
109
|
return r;
|
|
110
110
|
const t = String(r);
|
|
@@ -112,8 +112,8 @@ const k = L((r) => {
|
|
|
112
112
|
return !0;
|
|
113
113
|
if (t === "0" || t === "false")
|
|
114
114
|
return !1;
|
|
115
|
-
throw
|
|
116
|
-
}, "boolean"), q =
|
|
115
|
+
throw L();
|
|
116
|
+
}, "boolean"), q = $((r) => {
|
|
117
117
|
if (typeof r == "number")
|
|
118
118
|
return r;
|
|
119
119
|
if (typeof r == "string") {
|
|
@@ -121,21 +121,21 @@ const k = L((r) => {
|
|
|
121
121
|
if (!Number.isNaN(t))
|
|
122
122
|
return t;
|
|
123
123
|
}
|
|
124
|
-
throw
|
|
125
|
-
}, "number"),
|
|
124
|
+
throw L();
|
|
125
|
+
}, "number"), lt = $((r) => r instanceof Date ? r : new Date(q().parse(r) * 1e3), "Date");
|
|
126
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 L();
|
|
130
130
|
return t;
|
|
131
131
|
}
|
|
132
132
|
function f(r, t) {
|
|
133
133
|
return new z((e) => {
|
|
134
134
|
const s = Y(e);
|
|
135
|
-
return
|
|
135
|
+
return pt(r, (n) => s[n]);
|
|
136
136
|
}, !1, t);
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function X(r) {
|
|
139
139
|
return /^#[\da-f]{6}$/i.test(r);
|
|
140
140
|
}
|
|
141
141
|
function Dt(r) {
|
|
@@ -143,7 +143,7 @@ function Dt(r) {
|
|
|
143
143
|
}
|
|
144
144
|
function dt(r) {
|
|
145
145
|
const t = r.replace(/\s/g, "").toLowerCase();
|
|
146
|
-
if (
|
|
146
|
+
if (X(t))
|
|
147
147
|
return t;
|
|
148
148
|
if (Dt(t)) {
|
|
149
149
|
let s = "#";
|
|
@@ -168,17 +168,17 @@ function ft(r) {
|
|
|
168
168
|
}, 0)
|
|
169
169
|
) < 120;
|
|
170
170
|
}
|
|
171
|
-
const u =
|
|
171
|
+
const u = $((r) => {
|
|
172
172
|
if (typeof r == "string" || typeof r == "number")
|
|
173
173
|
return r.toString();
|
|
174
|
-
throw
|
|
175
|
-
}, "string"), gt =
|
|
176
|
-
function
|
|
174
|
+
throw L();
|
|
175
|
+
}, "string"), gt = $((r) => dt(u().parse(r)), "rgb");
|
|
176
|
+
function tt(r, t) {
|
|
177
177
|
return new z((e) => {
|
|
178
178
|
if (typeof e != "string" && !(e instanceof URLSearchParams))
|
|
179
|
-
throw
|
|
179
|
+
throw L();
|
|
180
180
|
const s = typeof e == "string" ? new URLSearchParams(e) : e;
|
|
181
|
-
return
|
|
181
|
+
return pt(r, (n) => {
|
|
182
182
|
const i = s.get(n);
|
|
183
183
|
return i === null ? void 0 : i;
|
|
184
184
|
});
|
|
@@ -196,7 +196,7 @@ function Wt() {
|
|
|
196
196
|
username: u().optional()
|
|
197
197
|
}, "Chat");
|
|
198
198
|
}
|
|
199
|
-
class
|
|
199
|
+
class Nt {
|
|
200
200
|
constructor(t) {
|
|
201
201
|
this.initData = t;
|
|
202
202
|
}
|
|
@@ -269,7 +269,7 @@ class Ot {
|
|
|
269
269
|
return this.initData.user;
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
|
-
function
|
|
272
|
+
function st() {
|
|
273
273
|
return f({
|
|
274
274
|
addedToAttachmentMenu: {
|
|
275
275
|
type: k().optional(),
|
|
@@ -308,9 +308,9 @@ function rt() {
|
|
|
308
308
|
}, "User");
|
|
309
309
|
}
|
|
310
310
|
function wt() {
|
|
311
|
-
return
|
|
311
|
+
return tt({
|
|
312
312
|
authDate: {
|
|
313
|
-
type:
|
|
313
|
+
type: lt(),
|
|
314
314
|
from: "auth_date"
|
|
315
315
|
},
|
|
316
316
|
canSendAfter: {
|
|
@@ -331,34 +331,34 @@ function wt() {
|
|
|
331
331
|
type: u().optional(),
|
|
332
332
|
from: "query_id"
|
|
333
333
|
},
|
|
334
|
-
receiver:
|
|
334
|
+
receiver: st().optional(),
|
|
335
335
|
startParam: {
|
|
336
336
|
type: u().optional(),
|
|
337
337
|
from: "start_param"
|
|
338
338
|
},
|
|
339
|
-
user:
|
|
339
|
+
user: st().optional()
|
|
340
340
|
}, "InitData");
|
|
341
341
|
}
|
|
342
|
-
function
|
|
342
|
+
function tr(r) {
|
|
343
343
|
return wt().parse(r);
|
|
344
344
|
}
|
|
345
|
-
function
|
|
345
|
+
function Ot(r) {
|
|
346
346
|
return r.replace(/(^|_)bg/, (t, e) => `${e}background`).replace(/_([a-z])/g, (t, e) => e.toUpperCase());
|
|
347
347
|
}
|
|
348
348
|
function Ht(r) {
|
|
349
349
|
return r.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`).replace(/(^|_)background/, (t, e) => `${e}bg`);
|
|
350
350
|
}
|
|
351
|
-
const _t =
|
|
351
|
+
const _t = $(
|
|
352
352
|
(r) => {
|
|
353
353
|
const t = gt().optional();
|
|
354
|
-
return Object.entries(Y(r)).reduce((e, [s, n]) => (e[
|
|
354
|
+
return Object.entries(Y(r)).reduce((e, [s, n]) => (e[Ot(s)] = t.parse(n), e), {});
|
|
355
355
|
},
|
|
356
356
|
"ThemeParams"
|
|
357
357
|
);
|
|
358
358
|
function bt(r) {
|
|
359
359
|
return _t().parse(r);
|
|
360
360
|
}
|
|
361
|
-
function
|
|
361
|
+
function er(r = {}) {
|
|
362
362
|
return m("web_app_request_theme", "theme_changed", r).then(bt);
|
|
363
363
|
}
|
|
364
364
|
function Ut(r) {
|
|
@@ -577,7 +577,7 @@ class Mt {
|
|
|
577
577
|
}
|
|
578
578
|
}
|
|
579
579
|
function mt() {
|
|
580
|
-
return
|
|
580
|
+
return tt({
|
|
581
581
|
botInline: {
|
|
582
582
|
type: k().optional(),
|
|
583
583
|
from: "tgWebAppBotInline"
|
|
@@ -612,18 +612,18 @@ function mt() {
|
|
|
612
612
|
}
|
|
613
613
|
}, "LaunchParams");
|
|
614
614
|
}
|
|
615
|
-
function
|
|
615
|
+
function Gt(r) {
|
|
616
616
|
return mt().parse(r);
|
|
617
617
|
}
|
|
618
618
|
function yt(r) {
|
|
619
619
|
const t = r.includes("?") ? r.replace("#", "&").slice(r.indexOf("?") + 1) : r.slice(r.indexOf("#") + 1);
|
|
620
|
-
return
|
|
620
|
+
return Gt(t);
|
|
621
621
|
}
|
|
622
|
-
function
|
|
622
|
+
function jt() {
|
|
623
623
|
return yt(window.location.href);
|
|
624
624
|
}
|
|
625
625
|
function Ft() {
|
|
626
|
-
const r =
|
|
626
|
+
const r = ht();
|
|
627
627
|
if (!r)
|
|
628
628
|
throw new Error("Unable to get first navigation entry.");
|
|
629
629
|
return yt(r.name);
|
|
@@ -634,7 +634,7 @@ function zt() {
|
|
|
634
634
|
} catch {
|
|
635
635
|
}
|
|
636
636
|
try {
|
|
637
|
-
return
|
|
637
|
+
return jt();
|
|
638
638
|
} catch {
|
|
639
639
|
}
|
|
640
640
|
return null;
|
|
@@ -687,15 +687,15 @@ function Yt() {
|
|
|
687
687
|
};
|
|
688
688
|
throw new Error("Unable to retrieve any launch parameters.");
|
|
689
689
|
}
|
|
690
|
-
const
|
|
690
|
+
const nt = "tmajsLaunchData";
|
|
691
691
|
function Ct() {
|
|
692
|
-
const r = window[
|
|
692
|
+
const r = window[nt];
|
|
693
693
|
if (r)
|
|
694
694
|
return r;
|
|
695
695
|
const t = Yt();
|
|
696
|
-
return window[
|
|
696
|
+
return window[nt] = t, Zt(t.launchParams), t;
|
|
697
697
|
}
|
|
698
|
-
function
|
|
698
|
+
function rr() {
|
|
699
699
|
try {
|
|
700
700
|
return Ct(), !0;
|
|
701
701
|
} catch {
|
|
@@ -703,10 +703,10 @@ function sr() {
|
|
|
703
703
|
}
|
|
704
704
|
}
|
|
705
705
|
function Xt(r) {
|
|
706
|
-
return "external" in r &&
|
|
706
|
+
return "external" in r && R(r.external) && "notify" in r.external && typeof r.external.notify == "function";
|
|
707
707
|
}
|
|
708
708
|
function te(r) {
|
|
709
|
-
return "TelegramWebviewProxy" in r &&
|
|
709
|
+
return "TelegramWebviewProxy" in r && R(r.TelegramWebviewProxy) && "postEvent" in r.TelegramWebviewProxy && typeof r.TelegramWebviewProxy.postEvent == "function";
|
|
710
710
|
}
|
|
711
711
|
function vt() {
|
|
712
712
|
try {
|
|
@@ -715,14 +715,14 @@ function vt() {
|
|
|
715
715
|
return !0;
|
|
716
716
|
}
|
|
717
717
|
}
|
|
718
|
-
class
|
|
718
|
+
class et extends Error {
|
|
719
719
|
constructor(t, e) {
|
|
720
|
-
super(`Method "${t}" is unsupported in the Mini Apps version ${e}.`), Object.setPrototypeOf(this,
|
|
720
|
+
super(`Method "${t}" is unsupported in the Mini Apps version ${e}.`), Object.setPrototypeOf(this, et.prototype);
|
|
721
721
|
}
|
|
722
722
|
}
|
|
723
|
-
class
|
|
723
|
+
class rt extends Error {
|
|
724
724
|
constructor(t, e, s) {
|
|
725
|
-
super(`Parameter "${e}" in method "${t}" is unsupported in the Mini Apps version ${s}.`), Object.setPrototypeOf(this,
|
|
725
|
+
super(`Parameter "${e}" in method "${t}" is unsupported in the Mini Apps version ${s}.`), Object.setPrototypeOf(this, rt.prototype);
|
|
726
726
|
}
|
|
727
727
|
}
|
|
728
728
|
class Pt {
|
|
@@ -782,14 +782,14 @@ class Pt {
|
|
|
782
782
|
}
|
|
783
783
|
let kt = "https://web.telegram.org";
|
|
784
784
|
const V = new Pt("[SDK]", !1);
|
|
785
|
-
function
|
|
785
|
+
function sr(r) {
|
|
786
786
|
if (r) {
|
|
787
787
|
V.enable();
|
|
788
788
|
return;
|
|
789
789
|
}
|
|
790
790
|
V.disable();
|
|
791
791
|
}
|
|
792
|
-
function
|
|
792
|
+
function nr(r) {
|
|
793
793
|
kt = r;
|
|
794
794
|
}
|
|
795
795
|
function ee() {
|
|
@@ -804,7 +804,9 @@ function se(r) {
|
|
|
804
804
|
}
|
|
805
805
|
function ne(r, t) {
|
|
806
806
|
window.dispatchEvent(new MessageEvent("message", {
|
|
807
|
-
data: JSON.stringify({ eventType: r, eventData: t })
|
|
807
|
+
data: JSON.stringify({ eventType: r, eventData: t }),
|
|
808
|
+
// We specify window.parent to imitate the case, it sent us this event.
|
|
809
|
+
source: window.parent
|
|
808
810
|
}));
|
|
809
811
|
}
|
|
810
812
|
function ie() {
|
|
@@ -829,11 +831,12 @@ function ie() {
|
|
|
829
831
|
}
|
|
830
832
|
function oe(r) {
|
|
831
833
|
ie(), window.addEventListener("message", (t) => {
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
834
|
+
if (t.source === window.parent)
|
|
835
|
+
try {
|
|
836
|
+
const { eventType: e, eventData: s } = se(t.data);
|
|
837
|
+
r(e, s);
|
|
838
|
+
} catch {
|
|
839
|
+
}
|
|
837
840
|
});
|
|
838
841
|
}
|
|
839
842
|
function ae() {
|
|
@@ -944,19 +947,19 @@ function U() {
|
|
|
944
947
|
const r = window;
|
|
945
948
|
return r[Q] === void 0 && (r[Q] = we()), r[Q];
|
|
946
949
|
}
|
|
947
|
-
function
|
|
950
|
+
function T(r, t) {
|
|
948
951
|
U().off(r, t);
|
|
949
952
|
}
|
|
950
953
|
function y(r, t) {
|
|
951
|
-
return U().on(r, t), () =>
|
|
954
|
+
return U().on(r, t), () => T(r, t);
|
|
952
955
|
}
|
|
953
|
-
function
|
|
954
|
-
return U().once(r, t), () =>
|
|
956
|
+
function ir(r, t) {
|
|
957
|
+
return U().once(r, t), () => T(r, t);
|
|
955
958
|
}
|
|
956
959
|
function _e(r) {
|
|
957
960
|
U().unsubscribe(r);
|
|
958
961
|
}
|
|
959
|
-
function
|
|
962
|
+
function or(r) {
|
|
960
963
|
return U().subscribe(r), () => _e(r);
|
|
961
964
|
}
|
|
962
965
|
function be(r, t) {
|
|
@@ -971,7 +974,7 @@ function be(r, t) {
|
|
|
971
974
|
function P(r, t) {
|
|
972
975
|
return be(r, t) <= 0;
|
|
973
976
|
}
|
|
974
|
-
function
|
|
977
|
+
function I(r, t, e) {
|
|
975
978
|
if (typeof e == "string") {
|
|
976
979
|
if (r === "web_app_open_link" && t === "try_instant_view")
|
|
977
980
|
return P("6.4", e);
|
|
@@ -1005,12 +1008,12 @@ function R(r, t, e) {
|
|
|
1005
1008
|
}
|
|
1006
1009
|
}
|
|
1007
1010
|
function E(r, t) {
|
|
1008
|
-
return (e) =>
|
|
1011
|
+
return (e) => I(t[e], r);
|
|
1009
1012
|
}
|
|
1010
1013
|
function St(r, t) {
|
|
1011
1014
|
return (e) => {
|
|
1012
1015
|
const [s, n] = t[e];
|
|
1013
|
-
return
|
|
1016
|
+
return I(s, n, r);
|
|
1014
1017
|
};
|
|
1015
1018
|
}
|
|
1016
1019
|
function d(r, t, e) {
|
|
@@ -1038,12 +1041,12 @@ function d(r, t, e) {
|
|
|
1038
1041
|
}
|
|
1039
1042
|
function me(r) {
|
|
1040
1043
|
return (t, e) => {
|
|
1041
|
-
if (!
|
|
1042
|
-
throw new
|
|
1043
|
-
if (
|
|
1044
|
+
if (!I(t, r))
|
|
1045
|
+
throw new et(t, r);
|
|
1046
|
+
if (R(e)) {
|
|
1044
1047
|
let s;
|
|
1045
|
-
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 && !
|
|
1046
|
-
throw new
|
|
1048
|
+
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 && !I(t, s, r))
|
|
1049
|
+
throw new rt(t, s, r);
|
|
1047
1050
|
}
|
|
1048
1051
|
return d(t, e);
|
|
1049
1052
|
};
|
|
@@ -1053,7 +1056,7 @@ class J extends Error {
|
|
|
1053
1056
|
super(`Async call timeout exceeded. Timeout: ${t}`), Object.setPrototypeOf(this, J.prototype);
|
|
1054
1057
|
}
|
|
1055
1058
|
}
|
|
1056
|
-
function
|
|
1059
|
+
function ar(r) {
|
|
1057
1060
|
return r instanceof J;
|
|
1058
1061
|
}
|
|
1059
1062
|
function ye(r) {
|
|
@@ -1074,10 +1077,10 @@ function xt(r, t) {
|
|
|
1074
1077
|
}
|
|
1075
1078
|
function m(r, t, e, s) {
|
|
1076
1079
|
let n, i, a, c;
|
|
1077
|
-
typeof t == "string" || Array.isArray(t) ? (a = Array.isArray(t) ? t : [t], n = e) : (i = t, a = Array.isArray(e) ? e : [e], n = s),
|
|
1080
|
+
typeof t == "string" || Array.isArray(t) ? (a = Array.isArray(t) ? t : [t], n = e) : (i = t, a = Array.isArray(e) ? e : [e], n = s), R(i) && typeof i.req_id == "string" && (c = i.req_id);
|
|
1078
1081
|
const { postEvent: p = d, timeout: h } = n || {}, g = n && "capture" in n ? n.capture : null, _ = () => new Promise((A, l) => {
|
|
1079
1082
|
const C = a.map((v) => y(v, (M) => {
|
|
1080
|
-
c && (!
|
|
1083
|
+
c && (!R(M) || M.req_id !== c) || typeof g == "function" && !g(M) || (x(), A(M));
|
|
1081
1084
|
})), x = () => C.forEach((v) => v());
|
|
1082
1085
|
try {
|
|
1083
1086
|
p(r, i);
|
|
@@ -1117,7 +1120,7 @@ class Ce {
|
|
|
1117
1120
|
* @param event - event name.
|
|
1118
1121
|
* @param listener - event listener.
|
|
1119
1122
|
*/
|
|
1120
|
-
o(this, "off", (t, e) => t === "click" ?
|
|
1123
|
+
o(this, "off", (t, e) => t === "click" ? T("back_button_pressed", e) : this.ee.off(t, e));
|
|
1121
1124
|
/**
|
|
1122
1125
|
* Checks if specified method is supported by current component.
|
|
1123
1126
|
*/
|
|
@@ -1149,25 +1152,22 @@ class Ce {
|
|
|
1149
1152
|
this.isVisible = !0;
|
|
1150
1153
|
}
|
|
1151
1154
|
}
|
|
1152
|
-
function
|
|
1155
|
+
function it(r, t) {
|
|
1153
1156
|
return r + (r.length > 0 && t.length > 0 ? ` ${t}` : t);
|
|
1154
1157
|
}
|
|
1155
1158
|
function ve(...r) {
|
|
1156
1159
|
return r.reduce((t, e) => {
|
|
1157
1160
|
let s = "";
|
|
1158
|
-
return typeof e == "string" ? s = e : typeof e == "object" && e !== null && (s = Object.entries(e).reduce((n, [i, a]) => a ?
|
|
1161
|
+
return typeof e == "string" ? s = e : typeof e == "object" && e !== null && (s = Object.entries(e).reduce((n, [i, a]) => a ? it(n, i) : n, "")), it(t, s);
|
|
1159
1162
|
}, "");
|
|
1160
1163
|
}
|
|
1161
|
-
function
|
|
1162
|
-
return
|
|
1163
|
-
}
|
|
1164
|
-
function ur(...r) {
|
|
1165
|
-
return r.reduce((t, e) => (Pe(e) && Object.entries(e).forEach(([s, n]) => {
|
|
1164
|
+
function cr(...r) {
|
|
1165
|
+
return r.reduce((t, e) => (R(e) && Object.entries(e).forEach(([s, n]) => {
|
|
1166
1166
|
const i = ve(t[s], n);
|
|
1167
1167
|
i.length > 0 && (t[s] = i);
|
|
1168
1168
|
}), t), {});
|
|
1169
1169
|
}
|
|
1170
|
-
class
|
|
1170
|
+
class Pe {
|
|
1171
1171
|
constructor(t, e = d) {
|
|
1172
1172
|
o(this, "ee", new w());
|
|
1173
1173
|
o(this, "state");
|
|
@@ -1206,10 +1206,10 @@ class ke {
|
|
|
1206
1206
|
this.isConfirmationNeeded = !0;
|
|
1207
1207
|
}
|
|
1208
1208
|
}
|
|
1209
|
-
function
|
|
1209
|
+
function ot(r, t) {
|
|
1210
1210
|
return r.reduce((e, s) => (e[s] = t, e), {});
|
|
1211
1211
|
}
|
|
1212
|
-
class
|
|
1212
|
+
class ke {
|
|
1213
1213
|
constructor(t, e, s = d) {
|
|
1214
1214
|
/**
|
|
1215
1215
|
* Checks if specified method is supported by current component.
|
|
@@ -1252,9 +1252,9 @@ class Se {
|
|
|
1252
1252
|
async get(t, e = {}) {
|
|
1253
1253
|
const s = Array.isArray(t) ? t : [t];
|
|
1254
1254
|
if (s.length === 0)
|
|
1255
|
-
return
|
|
1255
|
+
return ot(s, "");
|
|
1256
1256
|
const n = f(
|
|
1257
|
-
|
|
1257
|
+
ot(s, u())
|
|
1258
1258
|
), i = await O(
|
|
1259
1259
|
"getStorageValues",
|
|
1260
1260
|
{ keys: s },
|
|
@@ -1278,7 +1278,46 @@ class Se {
|
|
|
1278
1278
|
);
|
|
1279
1279
|
}
|
|
1280
1280
|
}
|
|
1281
|
-
|
|
1281
|
+
function S(r, t) {
|
|
1282
|
+
document.documentElement.style.setProperty(r, t);
|
|
1283
|
+
}
|
|
1284
|
+
function Se(r, t) {
|
|
1285
|
+
const e = () => {
|
|
1286
|
+
S("--tg-background-color", r.backgroundColor);
|
|
1287
|
+
}, s = () => {
|
|
1288
|
+
const {
|
|
1289
|
+
backgroundColor: n,
|
|
1290
|
+
secondaryBackgroundColor: i
|
|
1291
|
+
} = t;
|
|
1292
|
+
if (X(r.headerColor)) {
|
|
1293
|
+
S("--tg-header-color", r.headerColor);
|
|
1294
|
+
return;
|
|
1295
|
+
}
|
|
1296
|
+
if (r.headerColor === "bg_color" && n) {
|
|
1297
|
+
S("--tg-header-color", n);
|
|
1298
|
+
return;
|
|
1299
|
+
}
|
|
1300
|
+
r.headerColor === "secondary_bg_color" && i && S("--tg-header-color", i);
|
|
1301
|
+
};
|
|
1302
|
+
t.on("change", s), r.on("change:backgroundColor", e), r.on("change:headerColor", s), e(), s();
|
|
1303
|
+
}
|
|
1304
|
+
function xe(r) {
|
|
1305
|
+
const t = () => {
|
|
1306
|
+
const e = r.getState();
|
|
1307
|
+
Object.entries(e).forEach(([s, n]) => {
|
|
1308
|
+
if (n) {
|
|
1309
|
+
const i = s.replace(/[A-Z]/g, (a) => `-${a.toLowerCase()}`);
|
|
1310
|
+
S(`--tg-theme-${i}`, n);
|
|
1311
|
+
}
|
|
1312
|
+
});
|
|
1313
|
+
};
|
|
1314
|
+
r.on("change", t), t();
|
|
1315
|
+
}
|
|
1316
|
+
function at(r) {
|
|
1317
|
+
const t = () => S("--tg-viewport-height", `${r.height}px`), e = () => S("--tg-viewport-width", `${r.width}px`), s = () => S("--tg-viewport-stable-height", `${r.stableHeight}px`);
|
|
1318
|
+
r.on("change:height", t), r.on("change:width", e), r.on("change:stableHeight", s), t(), e(), s();
|
|
1319
|
+
}
|
|
1320
|
+
class qe {
|
|
1282
1321
|
constructor(t, e = d) {
|
|
1283
1322
|
/**
|
|
1284
1323
|
* Checks if specified method is supported by current component.
|
|
@@ -1324,7 +1363,7 @@ class xe {
|
|
|
1324
1363
|
this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
|
|
1325
1364
|
}
|
|
1326
1365
|
}
|
|
1327
|
-
function
|
|
1366
|
+
function Ae() {
|
|
1328
1367
|
const r = document.createElement("style");
|
|
1329
1368
|
r.id = "telegram-custom-styles", document.head.appendChild(r), y("set_custom_style", (t) => {
|
|
1330
1369
|
r.innerHTML = t;
|
|
@@ -1333,26 +1372,26 @@ function qe() {
|
|
|
1333
1372
|
function qt(r) {
|
|
1334
1373
|
return `telegram-mini-apps-${r}`;
|
|
1335
1374
|
}
|
|
1336
|
-
function
|
|
1375
|
+
function B(r, t) {
|
|
1337
1376
|
sessionStorage.setItem(qt(r), JSON.stringify(t));
|
|
1338
1377
|
}
|
|
1339
|
-
function
|
|
1378
|
+
function D(r) {
|
|
1340
1379
|
const t = sessionStorage.getItem(qt(r));
|
|
1341
1380
|
return t ? JSON.parse(t) : null;
|
|
1342
1381
|
}
|
|
1343
|
-
function
|
|
1344
|
-
const { isVisible: s = !1 } = r ?
|
|
1382
|
+
function Ve(r, t, e) {
|
|
1383
|
+
const { isVisible: s = !1 } = r ? D("back-button") || {} : {}, n = new Ce(s, t, e);
|
|
1345
1384
|
return n.on("change", () => {
|
|
1346
|
-
|
|
1385
|
+
B("back-button", { isVisible: n.isVisible });
|
|
1347
1386
|
}), n;
|
|
1348
1387
|
}
|
|
1349
|
-
function
|
|
1350
|
-
const { isConfirmationNeeded: e = !1 } = r ?
|
|
1351
|
-
return s.on("change", () =>
|
|
1388
|
+
function Re(r, t) {
|
|
1389
|
+
const { isConfirmationNeeded: e = !1 } = r ? D("closing-behavior") || {} : {}, s = new Pe(e, t);
|
|
1390
|
+
return s.on("change", () => B("closing-behavior", {
|
|
1352
1391
|
isConfirmationNeeded: s.isConfirmationNeeded
|
|
1353
1392
|
})), s;
|
|
1354
1393
|
}
|
|
1355
|
-
class
|
|
1394
|
+
class Ie {
|
|
1356
1395
|
constructor(t) {
|
|
1357
1396
|
o(this, "ee", new w());
|
|
1358
1397
|
o(this, "state");
|
|
@@ -1373,7 +1412,7 @@ class Re {
|
|
|
1373
1412
|
* @param event - event name.
|
|
1374
1413
|
* @param listener - event listener.
|
|
1375
1414
|
*/
|
|
1376
|
-
o(this, "off", (t, e) => t === "click" ?
|
|
1415
|
+
o(this, "off", (t, e) => t === "click" ? T("main_button_pressed", e) : this.ee.off(t, e));
|
|
1377
1416
|
const {
|
|
1378
1417
|
postEvent: e = d,
|
|
1379
1418
|
text: s,
|
|
@@ -1517,7 +1556,7 @@ class Re {
|
|
|
1517
1556
|
return this.state.set(t), this.commit(), this;
|
|
1518
1557
|
}
|
|
1519
1558
|
}
|
|
1520
|
-
function
|
|
1559
|
+
function Le(r, t, e, s) {
|
|
1521
1560
|
const {
|
|
1522
1561
|
backgroundColor: n = t,
|
|
1523
1562
|
isEnabled: i = !1,
|
|
@@ -1525,7 +1564,7 @@ function Ie(r, t, e, s) {
|
|
|
1525
1564
|
isLoaderVisible: c = !1,
|
|
1526
1565
|
textColor: p = e,
|
|
1527
1566
|
text: h = ""
|
|
1528
|
-
} = r ?
|
|
1567
|
+
} = r ? D("main-button") || {} : {}, g = new Ie({
|
|
1529
1568
|
backgroundColor: n,
|
|
1530
1569
|
isEnabled: i,
|
|
1531
1570
|
isLoaderVisible: c,
|
|
@@ -1533,7 +1572,7 @@ function Ie(r, t, e, s) {
|
|
|
1533
1572
|
postEvent: s,
|
|
1534
1573
|
text: h,
|
|
1535
1574
|
textColor: p
|
|
1536
|
-
}), _ = () =>
|
|
1575
|
+
}), _ = () => B("main-button", {
|
|
1537
1576
|
backgroundColor: g.backgroundColor,
|
|
1538
1577
|
isEnabled: g.isEnabled,
|
|
1539
1578
|
isLoaderVisible: g.isLoaderVisible,
|
|
@@ -1543,7 +1582,7 @@ function Ie(r, t, e, s) {
|
|
|
1543
1582
|
});
|
|
1544
1583
|
return g.on("change", _), g;
|
|
1545
1584
|
}
|
|
1546
|
-
const
|
|
1585
|
+
const $e = tt({
|
|
1547
1586
|
contact: f({
|
|
1548
1587
|
userId: {
|
|
1549
1588
|
type: q(),
|
|
@@ -1563,12 +1602,12 @@ const Le = X({
|
|
|
1563
1602
|
}
|
|
1564
1603
|
}),
|
|
1565
1604
|
authDate: {
|
|
1566
|
-
type:
|
|
1605
|
+
type: lt(),
|
|
1567
1606
|
from: "auth_date"
|
|
1568
1607
|
},
|
|
1569
1608
|
hash: u()
|
|
1570
1609
|
});
|
|
1571
|
-
class
|
|
1610
|
+
class Te {
|
|
1572
1611
|
constructor(t) {
|
|
1573
1612
|
o(this, "ee", new w());
|
|
1574
1613
|
o(this, "state");
|
|
@@ -1623,7 +1662,7 @@ class $e {
|
|
|
1623
1662
|
postEvent: this.postEvent,
|
|
1624
1663
|
timeout: 1e4
|
|
1625
1664
|
}
|
|
1626
|
-
).then((t) =>
|
|
1665
|
+
).then((t) => $e.parse(t));
|
|
1627
1666
|
}
|
|
1628
1667
|
/**
|
|
1629
1668
|
* The Mini App background color.
|
|
@@ -1758,7 +1797,7 @@ class $e {
|
|
|
1758
1797
|
* @param color - color key or RGB color.
|
|
1759
1798
|
*/
|
|
1760
1799
|
setHeaderColor(t) {
|
|
1761
|
-
this.postEvent("web_app_set_header_color",
|
|
1800
|
+
this.postEvent("web_app_set_header_color", X(t) ? { color: t } : { color_key: t }), this.state.set("headerColor", t);
|
|
1762
1801
|
}
|
|
1763
1802
|
/**
|
|
1764
1803
|
* Updates current Mini App background color.
|
|
@@ -1786,28 +1825,28 @@ class $e {
|
|
|
1786
1825
|
});
|
|
1787
1826
|
}
|
|
1788
1827
|
}
|
|
1789
|
-
function
|
|
1828
|
+
function Be(r, t, e, s, n, i) {
|
|
1790
1829
|
const {
|
|
1791
1830
|
backgroundColor: a = t,
|
|
1792
1831
|
headerColor: c = "bg_color"
|
|
1793
|
-
} = r ?
|
|
1832
|
+
} = r ? D("mini-app") || {} : {}, p = new Te({
|
|
1794
1833
|
headerColor: c,
|
|
1795
1834
|
backgroundColor: a,
|
|
1796
1835
|
version: e,
|
|
1797
1836
|
botInline: s,
|
|
1798
1837
|
createRequestId: n,
|
|
1799
1838
|
postEvent: i
|
|
1800
|
-
}), h = () =>
|
|
1839
|
+
}), h = () => B("mini-app", {
|
|
1801
1840
|
backgroundColor: p.backgroundColor,
|
|
1802
1841
|
headerColor: p.headerColor
|
|
1803
1842
|
});
|
|
1804
1843
|
return p.on("change", h), p;
|
|
1805
1844
|
}
|
|
1806
|
-
function
|
|
1845
|
+
function De() {
|
|
1807
1846
|
let r = 0;
|
|
1808
1847
|
return () => (r += 1, r.toString());
|
|
1809
1848
|
}
|
|
1810
|
-
class
|
|
1849
|
+
class We {
|
|
1811
1850
|
constructor(t, e, s = d) {
|
|
1812
1851
|
o(this, "ee", new w());
|
|
1813
1852
|
o(this, "state");
|
|
@@ -1822,7 +1861,7 @@ class De {
|
|
|
1822
1861
|
* @param event - event name.
|
|
1823
1862
|
* @param listener - event listener.
|
|
1824
1863
|
*/
|
|
1825
|
-
o(this, "off", (t, e) => t === "click" ?
|
|
1864
|
+
o(this, "off", (t, e) => t === "click" ? T("settings_button_pressed", e) : this.ee.off(t, e));
|
|
1826
1865
|
/**
|
|
1827
1866
|
* Checks if specified method is supported by current component.
|
|
1828
1867
|
*/
|
|
@@ -1854,17 +1893,17 @@ class De {
|
|
|
1854
1893
|
this.isVisible = !0;
|
|
1855
1894
|
}
|
|
1856
1895
|
}
|
|
1857
|
-
function
|
|
1858
|
-
const { isVisible: s = !1 } = r ?
|
|
1896
|
+
function Ne(r, t, e) {
|
|
1897
|
+
const { isVisible: s = !1 } = r ? D("settings-button") || {} : {}, n = new We(s, t, e);
|
|
1859
1898
|
return n.on("change", () => {
|
|
1860
|
-
|
|
1899
|
+
B("settings-button", { isVisible: n.isVisible });
|
|
1861
1900
|
}), n;
|
|
1862
1901
|
}
|
|
1863
1902
|
function Oe(r) {
|
|
1864
1903
|
const t = new Mt(r);
|
|
1865
1904
|
return t.listen(), t;
|
|
1866
1905
|
}
|
|
1867
|
-
function
|
|
1906
|
+
function He(r) {
|
|
1868
1907
|
return ["macos", "tdesktop", "unigram", "web", "weba"].includes(r);
|
|
1869
1908
|
}
|
|
1870
1909
|
async function At(r) {
|
|
@@ -1876,10 +1915,10 @@ async function At(r) {
|
|
|
1876
1915
|
isStateStable: t.is_state_stable
|
|
1877
1916
|
};
|
|
1878
1917
|
}
|
|
1879
|
-
function
|
|
1918
|
+
function W(r) {
|
|
1880
1919
|
return r < 0 ? 0 : r;
|
|
1881
1920
|
}
|
|
1882
|
-
class
|
|
1921
|
+
class Ue {
|
|
1883
1922
|
constructor(t) {
|
|
1884
1923
|
o(this, "ee", new w());
|
|
1885
1924
|
o(this, "state");
|
|
@@ -1900,10 +1939,10 @@ class He {
|
|
|
1900
1939
|
postEvent: a = d
|
|
1901
1940
|
} = t;
|
|
1902
1941
|
this.postEvent = a, this.state = new b({
|
|
1903
|
-
height:
|
|
1942
|
+
height: W(e),
|
|
1904
1943
|
isExpanded: s,
|
|
1905
|
-
stableHeight:
|
|
1906
|
-
width:
|
|
1944
|
+
stableHeight: W(i),
|
|
1945
|
+
width: W(n)
|
|
1907
1946
|
}, this.ee);
|
|
1908
1947
|
}
|
|
1909
1948
|
/**
|
|
@@ -1969,9 +2008,9 @@ class He {
|
|
|
1969
2008
|
is_expanded: n,
|
|
1970
2009
|
is_state_stable: i
|
|
1971
2010
|
} = t, a = {
|
|
1972
|
-
height:
|
|
2011
|
+
height: W(e),
|
|
1973
2012
|
isExpanded: n,
|
|
1974
|
-
width:
|
|
2013
|
+
width: W(s)
|
|
1975
2014
|
};
|
|
1976
2015
|
i && (a.stableHeight = a.height), this.state.set(a);
|
|
1977
2016
|
});
|
|
@@ -2008,21 +2047,21 @@ class He {
|
|
|
2008
2047
|
return this.stableHeight === this.height;
|
|
2009
2048
|
}
|
|
2010
2049
|
}
|
|
2011
|
-
function
|
|
2012
|
-
const t = new
|
|
2013
|
-
return t.on("change", () =>
|
|
2050
|
+
function G(r) {
|
|
2051
|
+
const t = new Ue(r);
|
|
2052
|
+
return t.on("change", () => B("viewport", {
|
|
2014
2053
|
height: t.height,
|
|
2015
2054
|
isExpanded: t.isExpanded,
|
|
2016
2055
|
stableHeight: t.stableHeight,
|
|
2017
2056
|
width: t.width
|
|
2018
2057
|
})), t.listen(), t;
|
|
2019
2058
|
}
|
|
2020
|
-
function
|
|
2021
|
-
const n = r ?
|
|
2059
|
+
function Me(r, t, e, s) {
|
|
2060
|
+
const n = r ? D("viewport") : null;
|
|
2022
2061
|
if (n)
|
|
2023
|
-
return
|
|
2024
|
-
if (
|
|
2025
|
-
return
|
|
2062
|
+
return G({ ...n, postEvent: e });
|
|
2063
|
+
if (He(t))
|
|
2064
|
+
return G({
|
|
2026
2065
|
height: window.innerHeight,
|
|
2027
2066
|
isExpanded: !0,
|
|
2028
2067
|
postEvent: e,
|
|
@@ -2033,12 +2072,12 @@ function Ue(r, t, e, s) {
|
|
|
2033
2072
|
return At({
|
|
2034
2073
|
postEvent: e,
|
|
2035
2074
|
timeout: 5e3
|
|
2036
|
-
}).then(({ height: a, isStateStable: c, ...p }) =>
|
|
2075
|
+
}).then(({ height: a, isStateStable: c, ...p }) => G({
|
|
2037
2076
|
...p,
|
|
2038
2077
|
height: a,
|
|
2039
2078
|
stableHeight: c ? a : 0
|
|
2040
2079
|
}));
|
|
2041
|
-
const i =
|
|
2080
|
+
const i = G({
|
|
2042
2081
|
width: 0,
|
|
2043
2082
|
height: 0,
|
|
2044
2083
|
isExpanded: !1,
|
|
@@ -2049,37 +2088,6 @@ function Ue(r, t, e, s) {
|
|
|
2049
2088
|
console.error("Unable to actualize viewport state", a);
|
|
2050
2089
|
}), i;
|
|
2051
2090
|
}
|
|
2052
|
-
function S(r, t) {
|
|
2053
|
-
document.documentElement.style.setProperty(r, t);
|
|
2054
|
-
}
|
|
2055
|
-
function Me(r, t) {
|
|
2056
|
-
const e = () => {
|
|
2057
|
-
S("--tg-background-color", r.backgroundColor);
|
|
2058
|
-
}, s = () => {
|
|
2059
|
-
const {
|
|
2060
|
-
backgroundColor: n,
|
|
2061
|
-
secondaryBackgroundColor: i
|
|
2062
|
-
} = t;
|
|
2063
|
-
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);
|
|
2064
|
-
};
|
|
2065
|
-
t.on("change", s), r.on("change:backgroundColor", e), r.on("change:headerColor", s), e(), s();
|
|
2066
|
-
}
|
|
2067
|
-
function je(r) {
|
|
2068
|
-
const t = () => {
|
|
2069
|
-
const e = r.getState();
|
|
2070
|
-
Object.entries(e).forEach(([s, n]) => {
|
|
2071
|
-
if (n) {
|
|
2072
|
-
const i = s.replace(/[A-Z]/g, (a) => `-${a.toLowerCase()}`);
|
|
2073
|
-
S(`--tg-theme-${i}`, n);
|
|
2074
|
-
}
|
|
2075
|
-
});
|
|
2076
|
-
};
|
|
2077
|
-
r.on("change", t), t();
|
|
2078
|
-
}
|
|
2079
|
-
function ot(r) {
|
|
2080
|
-
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`);
|
|
2081
|
-
r.on("change:height", t), r.on("change:width", e), r.on("change:stableHeight", s), t(), e(), s();
|
|
2082
|
-
}
|
|
2083
2091
|
function Ge(r) {
|
|
2084
2092
|
return typeof r == "object" ? r : r ? {
|
|
2085
2093
|
themeParams: !0,
|
|
@@ -2087,11 +2095,11 @@ function Ge(r) {
|
|
|
2087
2095
|
miniApp: !0
|
|
2088
2096
|
} : {};
|
|
2089
2097
|
}
|
|
2090
|
-
function
|
|
2098
|
+
function ct(r, t, e, s) {
|
|
2091
2099
|
const n = Ge(r);
|
|
2092
|
-
n.miniApp &&
|
|
2100
|
+
n.miniApp && Se(t, e), n.themeParams && xe(e), n.viewport && (s instanceof Promise ? s.then(at) : at(s));
|
|
2093
2101
|
}
|
|
2094
|
-
function
|
|
2102
|
+
function je(r) {
|
|
2095
2103
|
const { hostname: t, pathname: e } = new URL(r, window.location.href);
|
|
2096
2104
|
if (t !== "t.me")
|
|
2097
2105
|
throw new Error(`Incorrect hostname: ${t}`);
|
|
@@ -2100,7 +2108,7 @@ function Fe(r) {
|
|
|
2100
2108
|
throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');
|
|
2101
2109
|
return s[2];
|
|
2102
2110
|
}
|
|
2103
|
-
class
|
|
2111
|
+
class Fe {
|
|
2104
2112
|
constructor(t, e = d) {
|
|
2105
2113
|
o(this, "ee", new w());
|
|
2106
2114
|
o(this, "state");
|
|
@@ -2130,7 +2138,7 @@ class ze {
|
|
|
2130
2138
|
async open(t, e) {
|
|
2131
2139
|
if (this.isOpened)
|
|
2132
2140
|
throw new Error("Invoice is already opened");
|
|
2133
|
-
const s = e ?
|
|
2141
|
+
const s = e ? je(t) : t;
|
|
2134
2142
|
this.isOpened = !0;
|
|
2135
2143
|
try {
|
|
2136
2144
|
return (await m(
|
|
@@ -2149,7 +2157,7 @@ class ze {
|
|
|
2149
2157
|
}
|
|
2150
2158
|
}
|
|
2151
2159
|
}
|
|
2152
|
-
function
|
|
2160
|
+
function ze(r) {
|
|
2153
2161
|
const t = r.message.trim(), e = (r.title || "").trim(), s = r.buttons || [];
|
|
2154
2162
|
let n;
|
|
2155
2163
|
if (e.length > 64)
|
|
@@ -2173,7 +2181,7 @@ function Je(r) {
|
|
|
2173
2181
|
return { ...i, id: a };
|
|
2174
2182
|
}), { title: e, message: t, buttons: n };
|
|
2175
2183
|
}
|
|
2176
|
-
class
|
|
2184
|
+
class Je {
|
|
2177
2185
|
constructor(t, e = d) {
|
|
2178
2186
|
o(this, "ee", new w());
|
|
2179
2187
|
o(this, "state");
|
|
@@ -2218,7 +2226,7 @@ class Qe {
|
|
|
2218
2226
|
throw new Error("Popup is already opened.");
|
|
2219
2227
|
return this.isOpened = !0, m(
|
|
2220
2228
|
"web_app_open_popup",
|
|
2221
|
-
|
|
2229
|
+
ze(t),
|
|
2222
2230
|
"popup_closed",
|
|
2223
2231
|
{ postEvent: this.postEvent }
|
|
2224
2232
|
).then(({ button_id: e = null }) => e).finally(() => {
|
|
@@ -2226,7 +2234,7 @@ class Qe {
|
|
|
2226
2234
|
});
|
|
2227
2235
|
}
|
|
2228
2236
|
}
|
|
2229
|
-
class
|
|
2237
|
+
class Qe {
|
|
2230
2238
|
constructor(t, e = d) {
|
|
2231
2239
|
o(this, "ee", new w());
|
|
2232
2240
|
o(this, "state");
|
|
@@ -2285,7 +2293,7 @@ class Ze {
|
|
|
2285
2293
|
}
|
|
2286
2294
|
}
|
|
2287
2295
|
}
|
|
2288
|
-
class
|
|
2296
|
+
class Ze {
|
|
2289
2297
|
constructor(t, e, s = d) {
|
|
2290
2298
|
/**
|
|
2291
2299
|
* Checks if specified method is supported by current component.
|
|
@@ -2312,7 +2320,7 @@ class Ke {
|
|
|
2312
2320
|
*/
|
|
2313
2321
|
openLink(t, e) {
|
|
2314
2322
|
const s = new URL(t, window.location.href).toString();
|
|
2315
|
-
if (!
|
|
2323
|
+
if (!I("web_app_open_link", this.version)) {
|
|
2316
2324
|
window.open(s, "_blank");
|
|
2317
2325
|
return;
|
|
2318
2326
|
}
|
|
@@ -2335,7 +2343,7 @@ class Ke {
|
|
|
2335
2343
|
} = new URL(t, window.location.href);
|
|
2336
2344
|
if (e !== "t.me")
|
|
2337
2345
|
throw new Error(`URL has not allowed hostname: ${e}. Only "t.me" is allowed`);
|
|
2338
|
-
if (!
|
|
2346
|
+
if (!I("web_app_open_tg_link", this.version)) {
|
|
2339
2347
|
window.location.href = t;
|
|
2340
2348
|
return;
|
|
2341
2349
|
}
|
|
@@ -2356,7 +2364,7 @@ class Ke {
|
|
|
2356
2364
|
).then(({ data: t = null }) => t);
|
|
2357
2365
|
}
|
|
2358
2366
|
}
|
|
2359
|
-
function
|
|
2367
|
+
function ur(r = {}) {
|
|
2360
2368
|
const {
|
|
2361
2369
|
async: t = !1,
|
|
2362
2370
|
complete: e = t,
|
|
@@ -2374,22 +2382,22 @@ function hr(r = {}) {
|
|
|
2374
2382
|
botInline: g = !1
|
|
2375
2383
|
},
|
|
2376
2384
|
isPageReload: _
|
|
2377
|
-
} = Ct(), A =
|
|
2378
|
-
vt() && (n &&
|
|
2385
|
+
} = Ct(), A = De(), l = me(c);
|
|
2386
|
+
vt() && (n && Ae(), l("iframe_ready", { reload_supported: !0 }), y("reload_iframe", () => window.location.reload()));
|
|
2379
2387
|
const C = {
|
|
2380
|
-
backButton:
|
|
2381
|
-
closingBehavior:
|
|
2382
|
-
cloudStorage: new
|
|
2388
|
+
backButton: Ve(_, c, l),
|
|
2389
|
+
closingBehavior: Re(_, l),
|
|
2390
|
+
cloudStorage: new ke(c, A, l),
|
|
2383
2391
|
createRequestId: A,
|
|
2384
|
-
hapticFeedback: new
|
|
2385
|
-
invoice: new
|
|
2386
|
-
mainButton:
|
|
2392
|
+
hapticFeedback: new qe(c, l),
|
|
2393
|
+
invoice: new Fe(c, l),
|
|
2394
|
+
mainButton: Le(
|
|
2387
2395
|
_,
|
|
2388
2396
|
h.buttonColor || "#000000",
|
|
2389
2397
|
h.buttonTextColor || "#ffffff",
|
|
2390
2398
|
l
|
|
2391
2399
|
),
|
|
2392
|
-
miniApp:
|
|
2400
|
+
miniApp: Be(
|
|
2393
2401
|
_,
|
|
2394
2402
|
h.backgroundColor || "#ffffff",
|
|
2395
2403
|
c,
|
|
@@ -2397,23 +2405,23 @@ function hr(r = {}) {
|
|
|
2397
2405
|
A,
|
|
2398
2406
|
l
|
|
2399
2407
|
),
|
|
2400
|
-
popup: new
|
|
2408
|
+
popup: new Je(c, l),
|
|
2401
2409
|
postEvent: l,
|
|
2402
|
-
qrScanner: new
|
|
2403
|
-
settingsButton:
|
|
2410
|
+
qrScanner: new Qe(c, l),
|
|
2411
|
+
settingsButton: Ne(_, c, l),
|
|
2404
2412
|
themeParams: Oe(h),
|
|
2405
|
-
utils: new
|
|
2413
|
+
utils: new Ze(c, A, l),
|
|
2406
2414
|
...i ? {
|
|
2407
|
-
initData: new
|
|
2415
|
+
initData: new Nt(i),
|
|
2408
2416
|
initDataRaw: a
|
|
2409
2417
|
} : {}
|
|
2410
|
-
}, x =
|
|
2411
|
-
return x instanceof Promise || e ? Promise.resolve(x).then((v) => (
|
|
2418
|
+
}, x = Me(_, p, l, e);
|
|
2419
|
+
return x instanceof Promise || e ? Promise.resolve(x).then((v) => (ct(
|
|
2412
2420
|
s,
|
|
2413
2421
|
C.miniApp,
|
|
2414
2422
|
C.themeParams,
|
|
2415
2423
|
v
|
|
2416
|
-
), { ...C, viewport: v })) : (
|
|
2424
|
+
), { ...C, viewport: v })) : (ct(
|
|
2417
2425
|
s,
|
|
2418
2426
|
C.miniApp,
|
|
2419
2427
|
C.themeParams,
|
|
@@ -2425,14 +2433,14 @@ function hr(r = {}) {
|
|
|
2425
2433
|
throw i;
|
|
2426
2434
|
}
|
|
2427
2435
|
}
|
|
2428
|
-
function
|
|
2436
|
+
function N(r, t) {
|
|
2429
2437
|
return r.startsWith(t) ? r : `${t}${r}`;
|
|
2430
2438
|
}
|
|
2431
|
-
function
|
|
2439
|
+
function hr(r) {
|
|
2432
2440
|
const t = r.match(/#(.+)/);
|
|
2433
2441
|
return t ? t[1] : null;
|
|
2434
2442
|
}
|
|
2435
|
-
async function
|
|
2443
|
+
async function H(r) {
|
|
2436
2444
|
return r === 0 ? !0 : Promise.race([
|
|
2437
2445
|
new Promise((t) => {
|
|
2438
2446
|
window.addEventListener("popstate", function e() {
|
|
@@ -2445,14 +2453,14 @@ async function N(r) {
|
|
|
2445
2453
|
})
|
|
2446
2454
|
]);
|
|
2447
2455
|
}
|
|
2448
|
-
async function
|
|
2449
|
-
if (window.history.length <= 1 || (window.history.pushState(null, ""), await
|
|
2456
|
+
async function Ke() {
|
|
2457
|
+
if (window.history.length <= 1 || (window.history.pushState(null, ""), await H(1 - window.history.length)))
|
|
2450
2458
|
return;
|
|
2451
|
-
let t = await
|
|
2459
|
+
let t = await H(-1);
|
|
2452
2460
|
for (; t; )
|
|
2453
|
-
t = await
|
|
2461
|
+
t = await H(-1);
|
|
2454
2462
|
}
|
|
2455
|
-
class
|
|
2463
|
+
class Ye {
|
|
2456
2464
|
constructor(t, e, {
|
|
2457
2465
|
debug: s = !1,
|
|
2458
2466
|
loggerPrefix: n = "Navigator"
|
|
@@ -2467,9 +2475,9 @@ class Xe {
|
|
|
2467
2475
|
if (!i.startsWith("/") && i.length > 0)
|
|
2468
2476
|
throw new Error('Pathname should start with "/"');
|
|
2469
2477
|
return {
|
|
2470
|
-
pathname:
|
|
2471
|
-
search: a ?
|
|
2472
|
-
hash: c ?
|
|
2478
|
+
pathname: N(i, "/"),
|
|
2479
|
+
search: a ? N(a, "?") : "",
|
|
2480
|
+
hash: c ? N(c, "#") : ""
|
|
2473
2481
|
};
|
|
2474
2482
|
}), this.logger = new Pt(`[${n}]`, s);
|
|
2475
2483
|
}
|
|
@@ -2487,7 +2495,7 @@ class Xe {
|
|
|
2487
2495
|
search: c,
|
|
2488
2496
|
hash: p
|
|
2489
2497
|
} = t;
|
|
2490
|
-
e = a + (c ?
|
|
2498
|
+
e = a + (c ? N(c, "?") : "") + (p ? N(p, "#") : "");
|
|
2491
2499
|
}
|
|
2492
2500
|
const {
|
|
2493
2501
|
pathname: s,
|
|
@@ -2651,8 +2659,8 @@ class Xe {
|
|
|
2651
2659
|
return this.entry.search;
|
|
2652
2660
|
}
|
|
2653
2661
|
}
|
|
2654
|
-
const
|
|
2655
|
-
class Vt extends
|
|
2662
|
+
const ut = 0, Z = 1, K = 2;
|
|
2663
|
+
class Vt extends Ye {
|
|
2656
2664
|
constructor(e, s, n = {}) {
|
|
2657
2665
|
super(e, s, {
|
|
2658
2666
|
...n,
|
|
@@ -2667,7 +2675,7 @@ class Vt extends Xe {
|
|
|
2667
2675
|
o(this, "onPopState", async ({ state: e }) => {
|
|
2668
2676
|
if (this.logger.log('"popstate" event received. State:', e), e === null)
|
|
2669
2677
|
return this.push(window.location.hash.slice(1));
|
|
2670
|
-
if (e ===
|
|
2678
|
+
if (e === ut) {
|
|
2671
2679
|
this.logger.log("Void reached. Moving history forward"), window.history.forward();
|
|
2672
2680
|
return;
|
|
2673
2681
|
}
|
|
@@ -2716,7 +2724,7 @@ class Vt extends Xe {
|
|
|
2716
2724
|
async syncHistory() {
|
|
2717
2725
|
window.removeEventListener("popstate", this.onPopState);
|
|
2718
2726
|
const e = `#${this.path}`;
|
|
2719
|
-
await
|
|
2727
|
+
await Ke(), d("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 H(-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 H(-1)) : (this.logger.log("Setting up history: [~, *]"), window.history.replaceState(ut, ""), window.history.pushState(null, "", e)), window.addEventListener("popstate", this.onPopState);
|
|
2720
2728
|
}
|
|
2721
2729
|
emitChanged(e, s) {
|
|
2722
2730
|
this.ee.emit("change", {
|
|
@@ -2736,79 +2744,83 @@ class Vt extends Xe {
|
|
|
2736
2744
|
* Detaches current navigator from the browser history.
|
|
2737
2745
|
*/
|
|
2738
2746
|
detach() {
|
|
2739
|
-
this.attached && (this.logger.log("Detaching", this), this.attached = !1, window.removeEventListener("popstate", this.onPopState),
|
|
2747
|
+
this.attached && (this.logger.log("Detaching", this), this.attached = !1, window.removeEventListener("popstate", this.onPopState), T("back_button_pressed", this.back));
|
|
2740
2748
|
}
|
|
2741
2749
|
}
|
|
2742
2750
|
export {
|
|
2743
2751
|
Ce as BackButton,
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2752
|
+
Pe as ClosingBehavior,
|
|
2753
|
+
ke as CloudStorage,
|
|
2754
|
+
qe as HapticFeedback,
|
|
2747
2755
|
Vt as HashNavigator,
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2756
|
+
Nt as InitData,
|
|
2757
|
+
Fe as Invoice,
|
|
2758
|
+
Ie as MainButton,
|
|
2759
|
+
et as MethodUnsupportedError,
|
|
2760
|
+
Te as MiniApp,
|
|
2761
|
+
Ye as Navigator,
|
|
2762
|
+
rt as ParameterUnsupportedError,
|
|
2755
2763
|
F as ParseError,
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2764
|
+
j as ParseSchemaFieldError,
|
|
2765
|
+
Je as Popup,
|
|
2766
|
+
Qe as QRScanner,
|
|
2767
|
+
We as SettingsButton,
|
|
2760
2768
|
Mt as ThemeParams,
|
|
2761
2769
|
J as TimeoutError,
|
|
2762
|
-
|
|
2763
|
-
|
|
2770
|
+
Ze as Utils,
|
|
2771
|
+
Ue as Viewport,
|
|
2764
2772
|
Bt as array,
|
|
2773
|
+
Se as bindMiniAppCSSVars,
|
|
2774
|
+
xe as bindThemeCSSVars,
|
|
2775
|
+
at as bindViewportCSSVars,
|
|
2765
2776
|
k as boolean,
|
|
2766
2777
|
Wt as chatParser,
|
|
2767
2778
|
ve as classNames,
|
|
2768
2779
|
be as compareVersions,
|
|
2769
2780
|
me as createPostEvent,
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2781
|
+
lt as date,
|
|
2782
|
+
hr as getHash,
|
|
2783
|
+
ur as init,
|
|
2773
2784
|
wt as initDataParser,
|
|
2774
2785
|
O as invokeCustomMethod,
|
|
2775
2786
|
ft as isColorDark,
|
|
2776
2787
|
vt as isIframe,
|
|
2777
|
-
|
|
2788
|
+
X as isRGB,
|
|
2778
2789
|
Dt as isRGBShort,
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2790
|
+
R as isRecord,
|
|
2791
|
+
He as isStableViewportPlatform,
|
|
2792
|
+
rr as isTMA,
|
|
2793
|
+
ar as isTimeoutError,
|
|
2783
2794
|
f as json,
|
|
2784
2795
|
mt as launchParamsParser,
|
|
2785
|
-
|
|
2796
|
+
cr as mergeClassNames,
|
|
2786
2797
|
q as number,
|
|
2787
|
-
|
|
2798
|
+
T as off,
|
|
2788
2799
|
y as on,
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2800
|
+
ir as once,
|
|
2801
|
+
tr as parseInitData,
|
|
2802
|
+
Gt as parseLaunchParams,
|
|
2792
2803
|
se as parseMessage,
|
|
2793
2804
|
bt as parseThemeParams,
|
|
2794
2805
|
d as postEvent,
|
|
2795
2806
|
m as request,
|
|
2796
|
-
|
|
2807
|
+
er as requestThemeParams,
|
|
2797
2808
|
At as requestViewport,
|
|
2798
2809
|
Ct as retrieveLaunchData,
|
|
2799
2810
|
gt as rgb,
|
|
2800
|
-
|
|
2811
|
+
tt as searchParams,
|
|
2801
2812
|
Jt as serializeLaunchParams,
|
|
2802
2813
|
Ut as serializeThemeParams,
|
|
2803
|
-
|
|
2804
|
-
|
|
2814
|
+
S as setCSSVar,
|
|
2815
|
+
sr as setDebug,
|
|
2816
|
+
nr as setTargetOrigin,
|
|
2805
2817
|
u as string,
|
|
2806
|
-
|
|
2807
|
-
|
|
2818
|
+
or as subscribe,
|
|
2819
|
+
I as supports,
|
|
2808
2820
|
_t as themeParamsParser,
|
|
2809
2821
|
dt as toRGB,
|
|
2810
2822
|
_e as unsubscribe,
|
|
2811
|
-
|
|
2823
|
+
st as userParser,
|
|
2812
2824
|
xt as withTimeout
|
|
2813
2825
|
};
|
|
2814
2826
|
//# sourceMappingURL=index.mjs.map
|