@tma.js/sdk 1.3.0 → 1.4.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/launch-params/index.d.ts +1 -0
- package/dist/dts/launch-params/retrieveFromUrl.d.ts +6 -0
- package/dist/dts/launch-params/types.d.ts +12 -8
- 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 +243 -238
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/globals.ts +39 -0
- package/src/back-button/__tests__/BackButton.ts +129 -0
- package/src/bridge/__tests__/request.ts +236 -0
- package/src/bridge/env/__tests__/hasExternalNotify.ts +15 -0
- package/src/bridge/env/__tests__/hasWebviewProxy.ts +15 -0
- package/src/bridge/env/__tests__/isIframe.ts +30 -0
- package/src/bridge/events/__tests__/createEmitter.ts +143 -0
- package/src/bridge/events/__tests__/off.ts +34 -0
- package/src/bridge/events/__tests__/on.ts +49 -0
- package/src/bridge/events/__tests__/onTelegramEvent.ts +51 -0
- package/src/bridge/events/__tests__/once.ts +64 -0
- package/src/bridge/events/__tests__/singletonEmitter.ts +22 -0
- package/src/bridge/events/__tests__/subscribe.ts +49 -0
- package/src/bridge/events/__tests__/unsubscribe.ts +34 -0
- package/src/bridge/events/parsers/__tests__/clipboardTextReceived.ts +21 -0
- package/src/bridge/events/parsers/__tests__/invoiceClosed.ts +12 -0
- package/src/bridge/events/parsers/__tests__/popupClosed.ts +10 -0
- package/src/bridge/events/parsers/__tests__/qrTextReceived.ts +9 -0
- package/src/bridge/events/parsers/__tests__/theme-changed.ts +42 -0
- package/src/bridge/events/parsers/__tests__/viewportChanged.ts +49 -0
- package/src/bridge/methods/__tests__/createPostEvent.ts +37 -0
- package/src/bridge/methods/__tests__/postEvent.ts +137 -0
- package/src/classnames/__tests__/classNames.ts +20 -0
- package/src/classnames/__tests__/mergeClassNames.ts +21 -0
- package/src/closing-behavior/__tests__/ClosingBehavior.ts +86 -0
- package/src/colors/__tests__/isColorDark.ts +12 -0
- package/src/colors/__tests__/isRGB.ts +13 -0
- package/src/colors/__tests__/isRGBShort.ts +13 -0
- package/src/colors/__tests__/toRGB.ts +23 -0
- package/src/event-emitter/__tests__/EventEmitter.ts +145 -0
- package/src/haptic-feedback/__tests__/HapticFeedback.ts +68 -0
- package/src/init/creators/__tests__/createViewport.ts +96 -0
- package/src/init-data/__tests__/InitData.ts +98 -0
- package/src/init-data/__tests__/chatParser.ts +102 -0
- package/src/init-data/__tests__/initDataParser.ts +136 -0
- package/src/init-data/__tests__/parseInitData.ts +136 -0
- package/src/init-data/__tests__/userParser.ts +96 -0
- package/src/launch-params/__tests__/retrieveFromUrl.ts +19 -0
- package/src/launch-params/index.ts +1 -0
- package/src/launch-params/launchParamsParser.ts +4 -0
- package/src/launch-params/retrieveFromLocation.ts +2 -2
- package/src/launch-params/retrieveFromPerformance.ts +2 -7
- package/src/launch-params/retrieveFromUrl.ts +19 -0
- package/src/launch-params/types.ts +13 -8
- package/src/logger/__tests__/Logger.ts +107 -0
- package/src/main-button/__tests__/MainButton.ts +346 -0
- package/src/mini-app/__tests__/MiniApp.ts +140 -0
- package/src/misc/__tests__/isRecord.ts +21 -0
- package/src/navigation/HashNavigator/__tests__/HashNavigator.ts +144 -0
- package/src/navigation/HashNavigator/__tests__/drop.ts +42 -0
- package/src/navigation/HashNavigator/__tests__/go.ts +9 -0
- package/src/parsing/__tests__/ArrayValueParser.ts +18 -0
- package/src/parsing/__tests__/toRecord.ts +10 -0
- package/src/parsing/parsers/__tests__/array.ts +39 -0
- package/src/parsing/parsers/__tests__/boolean.ts +31 -0
- package/src/parsing/parsers/__tests__/date.ts +25 -0
- package/src/parsing/parsers/__tests__/json.ts +80 -0
- package/src/parsing/parsers/__tests__/number.ts +23 -0
- package/src/parsing/parsers/__tests__/rgb.ts +22 -0
- package/src/parsing/parsers/__tests__/searchParams.ts +105 -0
- package/src/parsing/parsers/__tests__/string.ts +25 -0
- package/src/popup/__tests__/Popup.ts +130 -0
- package/src/popup/__tests__/preparePopupParams.ts +85 -0
- package/src/supports/__tests__/supports.ts +123 -0
- package/src/theme-params/__tests__/keys.ts +19 -0
- package/src/theme-params/__tests__/parseThemeParams.ts +29 -0
- package/src/theme-params/__tests__/serializeThemeParams.ts +29 -0
- package/src/theme-params/__tests__/themeParamsParser.ts +29 -0
- package/src/timeout/__tests__/isTimeoutError.ts +9 -0
- package/src/timeout/__tests__/withTimeout.ts +28 -0
- package/src/version/__tests__/compareVersions.ts +19 -0
- package/src/viewport/__tests__/isStableViewportPlatform.ts +15 -0
- package/src/viewport/__tests__/utils.ts +12 -0
package/dist/index.mjs
CHANGED
|
@@ -4,11 +4,11 @@ var o = (r, t, e) => (It(r, typeof t != "symbol" ? t + "" : t, e), e);
|
|
|
4
4
|
function H(r) {
|
|
5
5
|
return typeof r == "object" && r !== null && !Array.isArray(r);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function ut() {
|
|
8
8
|
return performance.getEntriesByType("navigation")[0] || null;
|
|
9
9
|
}
|
|
10
10
|
function Lt() {
|
|
11
|
-
const r =
|
|
11
|
+
const r = ut();
|
|
12
12
|
return r ? r.type === "reload" : null;
|
|
13
13
|
}
|
|
14
14
|
function I() {
|
|
@@ -74,7 +74,7 @@ class G extends Error {
|
|
|
74
74
|
super(`Unable to parse field "${t}"${s ? ` as ${s}` : ""}`, { cause: e }), Object.setPrototypeOf(this, G.prototype);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
function
|
|
77
|
+
function ht(r, t) {
|
|
78
78
|
const e = {};
|
|
79
79
|
for (const s in r) {
|
|
80
80
|
const n = r[s];
|
|
@@ -84,18 +84,18 @@ function ut(r, t) {
|
|
|
84
84
|
if (typeof n == "function" || "parse" in n)
|
|
85
85
|
i = s, a = typeof n == "function" ? n : n.parse.bind(n);
|
|
86
86
|
else {
|
|
87
|
-
const { type:
|
|
88
|
-
i = n.from || s, a = typeof
|
|
87
|
+
const { type: h } = n;
|
|
88
|
+
i = n.from || s, a = typeof h == "function" ? h : h.parse.bind(h);
|
|
89
89
|
}
|
|
90
90
|
let c;
|
|
91
91
|
const p = t(i);
|
|
92
92
|
try {
|
|
93
93
|
c = a(p);
|
|
94
|
-
} catch (
|
|
95
|
-
throw
|
|
96
|
-
type:
|
|
97
|
-
cause:
|
|
98
|
-
}) : new G(i, { cause:
|
|
94
|
+
} catch (h) {
|
|
95
|
+
throw h instanceof F ? new G(i, {
|
|
96
|
+
type: h.type,
|
|
97
|
+
cause: h
|
|
98
|
+
}) : new G(i, { cause: h });
|
|
99
99
|
}
|
|
100
100
|
c !== void 0 && (e[s] = c);
|
|
101
101
|
}
|
|
@@ -132,7 +132,7 @@ function Y(r) {
|
|
|
132
132
|
function f(r, t) {
|
|
133
133
|
return new z((e) => {
|
|
134
134
|
const s = Y(e);
|
|
135
|
-
return
|
|
135
|
+
return ht(r, (n) => s[n]);
|
|
136
136
|
}, !1, t);
|
|
137
137
|
}
|
|
138
138
|
function lt(r) {
|
|
@@ -168,17 +168,17 @@ function ft(r) {
|
|
|
168
168
|
}, 0)
|
|
169
169
|
) < 120;
|
|
170
170
|
}
|
|
171
|
-
const
|
|
171
|
+
const u = L((r) => {
|
|
172
172
|
if (typeof r == "string" || typeof r == "number")
|
|
173
173
|
return r.toString();
|
|
174
174
|
throw I();
|
|
175
|
-
}, "string"), gt = L((r) => dt(
|
|
175
|
+
}, "string"), gt = L((r) => dt(u().parse(r)), "rgb");
|
|
176
176
|
function X(r, t) {
|
|
177
177
|
return new z((e) => {
|
|
178
178
|
if (typeof e != "string" && !(e instanceof URLSearchParams))
|
|
179
179
|
throw I();
|
|
180
180
|
const s = typeof e == "string" ? new URLSearchParams(e) : e;
|
|
181
|
-
return
|
|
181
|
+
return ht(r, (n) => {
|
|
182
182
|
const i = s.get(n);
|
|
183
183
|
return i === null ? void 0 : i;
|
|
184
184
|
});
|
|
@@ -187,16 +187,16 @@ function X(r, t) {
|
|
|
187
187
|
function Wt() {
|
|
188
188
|
return f({
|
|
189
189
|
id: q(),
|
|
190
|
-
type:
|
|
191
|
-
title:
|
|
190
|
+
type: u(),
|
|
191
|
+
title: u(),
|
|
192
192
|
photoUrl: {
|
|
193
|
-
type:
|
|
193
|
+
type: u().optional(),
|
|
194
194
|
from: "photo_url"
|
|
195
195
|
},
|
|
196
|
-
username:
|
|
196
|
+
username: u().optional()
|
|
197
197
|
}, "Chat");
|
|
198
198
|
}
|
|
199
|
-
class
|
|
199
|
+
class Ot {
|
|
200
200
|
constructor(t) {
|
|
201
201
|
this.initData = t;
|
|
202
202
|
}
|
|
@@ -280,7 +280,7 @@ function rt() {
|
|
|
280
280
|
from: "allows_write_to_pm"
|
|
281
281
|
},
|
|
282
282
|
firstName: {
|
|
283
|
-
type:
|
|
283
|
+
type: u(),
|
|
284
284
|
from: "first_name"
|
|
285
285
|
},
|
|
286
286
|
id: q(),
|
|
@@ -293,18 +293,18 @@ function rt() {
|
|
|
293
293
|
from: "is_premium"
|
|
294
294
|
},
|
|
295
295
|
languageCode: {
|
|
296
|
-
type:
|
|
296
|
+
type: u().optional(),
|
|
297
297
|
from: "language_code"
|
|
298
298
|
},
|
|
299
299
|
lastName: {
|
|
300
|
-
type:
|
|
300
|
+
type: u().optional(),
|
|
301
301
|
from: "last_name"
|
|
302
302
|
},
|
|
303
303
|
photoUrl: {
|
|
304
|
-
type:
|
|
304
|
+
type: u().optional(),
|
|
305
305
|
from: "photo_url"
|
|
306
306
|
},
|
|
307
|
-
username:
|
|
307
|
+
username: u().optional()
|
|
308
308
|
}, "User");
|
|
309
309
|
}
|
|
310
310
|
function wt() {
|
|
@@ -319,30 +319,30 @@ function wt() {
|
|
|
319
319
|
},
|
|
320
320
|
chat: Wt().optional(),
|
|
321
321
|
chatInstance: {
|
|
322
|
-
type:
|
|
322
|
+
type: u().optional(),
|
|
323
323
|
from: "chat_instance"
|
|
324
324
|
},
|
|
325
325
|
chatType: {
|
|
326
|
-
type:
|
|
326
|
+
type: u().optional(),
|
|
327
327
|
from: "chat_type"
|
|
328
328
|
},
|
|
329
|
-
hash:
|
|
329
|
+
hash: u(),
|
|
330
330
|
queryId: {
|
|
331
|
-
type:
|
|
331
|
+
type: u().optional(),
|
|
332
332
|
from: "query_id"
|
|
333
333
|
},
|
|
334
334
|
receiver: rt().optional(),
|
|
335
335
|
startParam: {
|
|
336
|
-
type:
|
|
336
|
+
type: u().optional(),
|
|
337
337
|
from: "start_param"
|
|
338
338
|
},
|
|
339
339
|
user: rt().optional()
|
|
340
340
|
}, "InitData");
|
|
341
341
|
}
|
|
342
|
-
function
|
|
342
|
+
function tr(r) {
|
|
343
343
|
return wt().parse(r);
|
|
344
344
|
}
|
|
345
|
-
function
|
|
345
|
+
function Nt(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) {
|
|
@@ -351,14 +351,14 @@ function Ht(r) {
|
|
|
351
351
|
const _t = L(
|
|
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[Nt(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) {
|
|
@@ -587,54 +587,59 @@ function mt() {
|
|
|
587
587
|
from: "tgWebAppData"
|
|
588
588
|
},
|
|
589
589
|
initDataRaw: {
|
|
590
|
-
type:
|
|
590
|
+
type: u().optional(),
|
|
591
591
|
from: "tgWebAppData"
|
|
592
592
|
},
|
|
593
593
|
platform: {
|
|
594
|
-
type:
|
|
594
|
+
type: u(),
|
|
595
595
|
from: "tgWebAppPlatform"
|
|
596
596
|
},
|
|
597
597
|
showSettings: {
|
|
598
598
|
type: k().optional(),
|
|
599
599
|
from: "tgWebAppShowSettings"
|
|
600
600
|
},
|
|
601
|
+
startParam: {
|
|
602
|
+
type: u().optional(),
|
|
603
|
+
from: "tgWebAppStartParam"
|
|
604
|
+
},
|
|
601
605
|
themeParams: {
|
|
602
606
|
type: _t(),
|
|
603
607
|
from: "tgWebAppThemeParams"
|
|
604
608
|
},
|
|
605
609
|
version: {
|
|
606
|
-
type:
|
|
610
|
+
type: u(),
|
|
607
611
|
from: "tgWebAppVersion"
|
|
608
612
|
}
|
|
609
613
|
}, "LaunchParams");
|
|
610
614
|
}
|
|
611
|
-
function
|
|
615
|
+
function jt(r) {
|
|
612
616
|
return mt().parse(r);
|
|
613
617
|
}
|
|
614
|
-
function
|
|
615
|
-
|
|
618
|
+
function yt(r) {
|
|
619
|
+
const t = r.includes("?") ? r.replace("#", "&").slice(r.indexOf("?") + 1) : r.slice(r.indexOf("#") + 1);
|
|
620
|
+
return jt(t);
|
|
616
621
|
}
|
|
617
622
|
function Gt() {
|
|
618
|
-
|
|
623
|
+
return yt(window.location.href);
|
|
624
|
+
}
|
|
625
|
+
function Ft() {
|
|
626
|
+
const r = ut();
|
|
619
627
|
if (!r)
|
|
620
628
|
throw new Error("Unable to get first navigation entry.");
|
|
621
|
-
|
|
622
|
-
if (!t)
|
|
623
|
-
throw new Error("First navigation entry does not contain hash part.");
|
|
624
|
-
return yt(t[1]);
|
|
629
|
+
return yt(r.name);
|
|
625
630
|
}
|
|
626
|
-
function
|
|
631
|
+
function zt() {
|
|
627
632
|
try {
|
|
628
|
-
return
|
|
633
|
+
return Ft();
|
|
629
634
|
} catch {
|
|
630
635
|
}
|
|
631
636
|
try {
|
|
632
|
-
return
|
|
637
|
+
return Gt();
|
|
633
638
|
} catch {
|
|
634
639
|
}
|
|
635
640
|
return null;
|
|
636
641
|
}
|
|
637
|
-
function
|
|
642
|
+
function Jt(r) {
|
|
638
643
|
const {
|
|
639
644
|
initDataRaw: t,
|
|
640
645
|
themeParams: e,
|
|
@@ -646,27 +651,27 @@ function zt(r) {
|
|
|
646
651
|
return t && c.set("tgWebAppData", t), c.set("tgWebAppPlatform", s), c.set("tgWebAppThemeParams", Ut(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
652
|
}
|
|
648
653
|
const Et = "telegram-mini-apps-launch-params";
|
|
649
|
-
function
|
|
654
|
+
function Qt() {
|
|
650
655
|
const r = sessionStorage.getItem(Et);
|
|
651
656
|
return r ? mt().parse(r) : null;
|
|
652
657
|
}
|
|
653
|
-
function
|
|
654
|
-
sessionStorage.setItem(Et,
|
|
658
|
+
function Zt(r) {
|
|
659
|
+
sessionStorage.setItem(Et, Jt(r));
|
|
655
660
|
}
|
|
656
|
-
function
|
|
661
|
+
function Kt() {
|
|
657
662
|
try {
|
|
658
663
|
return window.self !== window.top;
|
|
659
664
|
} catch {
|
|
660
665
|
return !0;
|
|
661
666
|
}
|
|
662
667
|
}
|
|
663
|
-
function
|
|
664
|
-
const r =
|
|
668
|
+
function Yt() {
|
|
669
|
+
const r = Qt(), t = zt(), e = Lt();
|
|
665
670
|
if (r) {
|
|
666
671
|
if (t)
|
|
667
672
|
return {
|
|
668
673
|
launchParams: t,
|
|
669
|
-
isPageReload:
|
|
674
|
+
isPageReload: Kt() ? e || r.initDataRaw === t.initDataRaw : !0
|
|
670
675
|
};
|
|
671
676
|
if (e)
|
|
672
677
|
return {
|
|
@@ -687,20 +692,20 @@ function Ct() {
|
|
|
687
692
|
const r = window[st];
|
|
688
693
|
if (r)
|
|
689
694
|
return r;
|
|
690
|
-
const t =
|
|
691
|
-
return window[st] = t,
|
|
695
|
+
const t = Yt();
|
|
696
|
+
return window[st] = t, Zt(t.launchParams), t;
|
|
692
697
|
}
|
|
693
|
-
function
|
|
698
|
+
function rr() {
|
|
694
699
|
try {
|
|
695
700
|
return Ct(), !0;
|
|
696
701
|
} catch {
|
|
697
702
|
return !1;
|
|
698
703
|
}
|
|
699
704
|
}
|
|
700
|
-
function
|
|
705
|
+
function Xt(r) {
|
|
701
706
|
return "external" in r && H(r.external) && "notify" in r.external && typeof r.external.notify == "function";
|
|
702
707
|
}
|
|
703
|
-
function
|
|
708
|
+
function te(r) {
|
|
704
709
|
return "TelegramWebviewProxy" in r && H(r.TelegramWebviewProxy) && "postEvent" in r.TelegramWebviewProxy && typeof r.TelegramWebviewProxy.postEvent == "function";
|
|
705
710
|
}
|
|
706
711
|
function vt() {
|
|
@@ -777,29 +782,29 @@ class Pt {
|
|
|
777
782
|
}
|
|
778
783
|
let kt = "https://web.telegram.org";
|
|
779
784
|
const V = new Pt("[SDK]", !1);
|
|
780
|
-
function
|
|
785
|
+
function sr(r) {
|
|
781
786
|
if (r) {
|
|
782
787
|
V.enable();
|
|
783
788
|
return;
|
|
784
789
|
}
|
|
785
790
|
V.disable();
|
|
786
791
|
}
|
|
787
|
-
function
|
|
792
|
+
function nr(r) {
|
|
788
793
|
kt = r;
|
|
789
794
|
}
|
|
790
|
-
function
|
|
795
|
+
function ee() {
|
|
791
796
|
return kt;
|
|
792
797
|
}
|
|
793
|
-
const
|
|
794
|
-
eventType:
|
|
798
|
+
const re = f({
|
|
799
|
+
eventType: u(),
|
|
795
800
|
eventData: (r) => r
|
|
796
801
|
});
|
|
797
|
-
function
|
|
802
|
+
function se(r, t) {
|
|
798
803
|
window.dispatchEvent(new MessageEvent("message", {
|
|
799
804
|
data: JSON.stringify({ eventType: r, eventData: t })
|
|
800
805
|
}));
|
|
801
806
|
}
|
|
802
|
-
function
|
|
807
|
+
function ne() {
|
|
803
808
|
const r = window;
|
|
804
809
|
"TelegramGameProxy_receiveEvent" in r || [
|
|
805
810
|
["TelegramGameProxy_receiveEvent"],
|
|
@@ -812,55 +817,55 @@ function se() {
|
|
|
812
817
|
let e = r;
|
|
813
818
|
t.forEach((s, n, i) => {
|
|
814
819
|
if (n === i.length - 1) {
|
|
815
|
-
e[s] =
|
|
820
|
+
e[s] = se;
|
|
816
821
|
return;
|
|
817
822
|
}
|
|
818
823
|
s in e || (e[s] = {}), e = e[s];
|
|
819
824
|
});
|
|
820
825
|
});
|
|
821
826
|
}
|
|
822
|
-
function
|
|
823
|
-
|
|
827
|
+
function ie(r) {
|
|
828
|
+
ne(), window.addEventListener("message", (t) => {
|
|
824
829
|
try {
|
|
825
|
-
const { eventType: e, eventData: s } =
|
|
830
|
+
const { eventType: e, eventData: s } = re.parse(t.data);
|
|
826
831
|
r(e, s);
|
|
827
832
|
} catch {
|
|
828
833
|
}
|
|
829
834
|
});
|
|
830
835
|
}
|
|
831
|
-
function
|
|
836
|
+
function oe() {
|
|
832
837
|
return f({
|
|
833
|
-
req_id:
|
|
834
|
-
data: (r) => r === null ? r :
|
|
838
|
+
req_id: u(),
|
|
839
|
+
data: (r) => r === null ? r : u().optional().parse(r)
|
|
835
840
|
});
|
|
836
841
|
}
|
|
837
|
-
function
|
|
842
|
+
function ae() {
|
|
838
843
|
return f({
|
|
839
|
-
req_id:
|
|
844
|
+
req_id: u(),
|
|
840
845
|
result: (r) => r,
|
|
841
|
-
error:
|
|
846
|
+
error: u().optional()
|
|
842
847
|
});
|
|
843
848
|
}
|
|
844
|
-
function
|
|
849
|
+
function ce() {
|
|
845
850
|
return f({
|
|
846
|
-
slug:
|
|
847
|
-
status:
|
|
851
|
+
slug: u(),
|
|
852
|
+
status: u()
|
|
848
853
|
});
|
|
849
854
|
}
|
|
850
|
-
function
|
|
851
|
-
return f({ status:
|
|
855
|
+
function ue() {
|
|
856
|
+
return f({ status: u() });
|
|
852
857
|
}
|
|
853
858
|
function he() {
|
|
854
859
|
return f({
|
|
855
|
-
button_id: (r) => r == null ? void 0 :
|
|
860
|
+
button_id: (r) => r == null ? void 0 : u().parse(r)
|
|
856
861
|
});
|
|
857
862
|
}
|
|
858
|
-
function
|
|
863
|
+
function pe() {
|
|
859
864
|
return f({
|
|
860
|
-
data:
|
|
865
|
+
data: u().optional()
|
|
861
866
|
});
|
|
862
867
|
}
|
|
863
|
-
function
|
|
868
|
+
function le() {
|
|
864
869
|
return f({
|
|
865
870
|
theme_params: (r) => {
|
|
866
871
|
const t = gt().optional();
|
|
@@ -868,7 +873,7 @@ function pe() {
|
|
|
868
873
|
}
|
|
869
874
|
});
|
|
870
875
|
}
|
|
871
|
-
function
|
|
876
|
+
function de() {
|
|
872
877
|
return f({
|
|
873
878
|
height: q(),
|
|
874
879
|
width: (r) => r == null ? window.innerWidth : q().parse(r),
|
|
@@ -876,10 +881,10 @@ function le() {
|
|
|
876
881
|
is_expanded: k()
|
|
877
882
|
});
|
|
878
883
|
}
|
|
879
|
-
function de() {
|
|
880
|
-
return f({ status: h() });
|
|
881
|
-
}
|
|
882
884
|
function fe() {
|
|
885
|
+
return f({ status: u() });
|
|
886
|
+
}
|
|
887
|
+
function ge() {
|
|
883
888
|
const r = new w(), t = (e, ...s) => {
|
|
884
889
|
V.log("Emitting processed event:", e, ...s), r.emit(e, ...s);
|
|
885
890
|
};
|
|
@@ -890,33 +895,33 @@ function fe() {
|
|
|
890
895
|
is_state_stable: !0,
|
|
891
896
|
is_expanded: !0
|
|
892
897
|
});
|
|
893
|
-
}),
|
|
898
|
+
}), ie((e, s) => {
|
|
894
899
|
V.log("Received raw event:", e, s);
|
|
895
900
|
try {
|
|
896
901
|
switch (e) {
|
|
897
902
|
case "viewport_changed":
|
|
898
|
-
return t(e,
|
|
903
|
+
return t(e, de().parse(s));
|
|
899
904
|
case "theme_changed":
|
|
900
|
-
return t(e,
|
|
905
|
+
return t(e, le().parse(s));
|
|
901
906
|
case "popup_closed":
|
|
902
907
|
return (
|
|
903
908
|
// Sent on desktop.
|
|
904
909
|
s == null ? t(e, {}) : t(e, he().parse(s))
|
|
905
910
|
);
|
|
906
911
|
case "set_custom_style":
|
|
907
|
-
return t(e,
|
|
912
|
+
return t(e, u().parse(s));
|
|
908
913
|
case "qr_text_received":
|
|
909
|
-
return t(e,
|
|
914
|
+
return t(e, pe().parse(s));
|
|
910
915
|
case "clipboard_text_received":
|
|
911
|
-
return t(e,
|
|
916
|
+
return t(e, oe().parse(s));
|
|
912
917
|
case "invoice_closed":
|
|
913
|
-
return t(e,
|
|
918
|
+
return t(e, ce().parse(s));
|
|
914
919
|
case "phone_requested":
|
|
915
|
-
return t("phone_requested",
|
|
920
|
+
return t("phone_requested", ue().parse(s));
|
|
916
921
|
case "custom_method_invoked":
|
|
917
|
-
return t("custom_method_invoked",
|
|
922
|
+
return t("custom_method_invoked", ae().parse(s));
|
|
918
923
|
case "write_access_requested":
|
|
919
|
-
return t("write_access_requested",
|
|
924
|
+
return t("write_access_requested", fe().parse(s));
|
|
920
925
|
case "main_button_pressed":
|
|
921
926
|
case "back_button_pressed":
|
|
922
927
|
case "settings_button_pressed":
|
|
@@ -934,7 +939,7 @@ function fe() {
|
|
|
934
939
|
const Q = "telegram-mini-apps-cached-emitter";
|
|
935
940
|
function U() {
|
|
936
941
|
const r = window;
|
|
937
|
-
return r[Q] === void 0 && (r[Q] =
|
|
942
|
+
return r[Q] === void 0 && (r[Q] = ge()), r[Q];
|
|
938
943
|
}
|
|
939
944
|
function $(r, t) {
|
|
940
945
|
U().off(r, t);
|
|
@@ -942,16 +947,16 @@ function $(r, t) {
|
|
|
942
947
|
function y(r, t) {
|
|
943
948
|
return U().on(r, t), () => $(r, t);
|
|
944
949
|
}
|
|
945
|
-
function
|
|
950
|
+
function ir(r, t) {
|
|
946
951
|
return U().once(r, t), () => $(r, t);
|
|
947
952
|
}
|
|
948
|
-
function
|
|
953
|
+
function we(r) {
|
|
949
954
|
U().unsubscribe(r);
|
|
950
955
|
}
|
|
951
|
-
function
|
|
952
|
-
return U().subscribe(r), () =>
|
|
956
|
+
function or(r) {
|
|
957
|
+
return U().subscribe(r), () => we(r);
|
|
953
958
|
}
|
|
954
|
-
function
|
|
959
|
+
function _e(r, t) {
|
|
955
960
|
const e = r.split("."), s = t.split("."), n = Math.max(e.length, s.length);
|
|
956
961
|
for (let i = 0; i < n; i += 1) {
|
|
957
962
|
const a = parseInt(e[i] || "0", 10), c = parseInt(s[i] || "0", 10);
|
|
@@ -961,7 +966,7 @@ function we(r, t) {
|
|
|
961
966
|
return 0;
|
|
962
967
|
}
|
|
963
968
|
function P(r, t) {
|
|
964
|
-
return
|
|
969
|
+
return _e(r, t) <= 0;
|
|
965
970
|
}
|
|
966
971
|
function R(r, t, e) {
|
|
967
972
|
if (typeof e == "string") {
|
|
@@ -1008,7 +1013,7 @@ function St(r, t) {
|
|
|
1008
1013
|
function d(r, t, e) {
|
|
1009
1014
|
let s = {}, n;
|
|
1010
1015
|
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 =
|
|
1016
|
+
const { targetOrigin: i = ee() } = s;
|
|
1012
1017
|
if (V.log(`Calling method "${r}"`, n), vt()) {
|
|
1013
1018
|
window.parent.postMessage(JSON.stringify({
|
|
1014
1019
|
eventType: r,
|
|
@@ -1016,11 +1021,11 @@ function d(r, t, e) {
|
|
|
1016
1021
|
}), i);
|
|
1017
1022
|
return;
|
|
1018
1023
|
}
|
|
1019
|
-
if (
|
|
1024
|
+
if (Xt(window)) {
|
|
1020
1025
|
window.external.notify(JSON.stringify({ eventType: r, eventData: n }));
|
|
1021
1026
|
return;
|
|
1022
1027
|
}
|
|
1023
|
-
if (
|
|
1028
|
+
if (te(window)) {
|
|
1024
1029
|
window.TelegramWebviewProxy.postEvent(r, JSON.stringify(n));
|
|
1025
1030
|
return;
|
|
1026
1031
|
}
|
|
@@ -1028,7 +1033,7 @@ function d(r, t, e) {
|
|
|
1028
1033
|
"Unable to determine current environment and possible way to send event."
|
|
1029
1034
|
);
|
|
1030
1035
|
}
|
|
1031
|
-
function
|
|
1036
|
+
function be(r) {
|
|
1032
1037
|
return (t, e) => {
|
|
1033
1038
|
if (!R(t, r))
|
|
1034
1039
|
throw new tt(t, r);
|
|
@@ -1045,15 +1050,15 @@ class J extends Error {
|
|
|
1045
1050
|
super(`Async call timeout exceeded. Timeout: ${t}`), Object.setPrototypeOf(this, J.prototype);
|
|
1046
1051
|
}
|
|
1047
1052
|
}
|
|
1048
|
-
function
|
|
1053
|
+
function ar(r) {
|
|
1049
1054
|
return r instanceof J;
|
|
1050
1055
|
}
|
|
1051
|
-
function
|
|
1056
|
+
function me(r) {
|
|
1052
1057
|
return new Promise((t) => {
|
|
1053
1058
|
setTimeout(t, r);
|
|
1054
1059
|
});
|
|
1055
1060
|
}
|
|
1056
|
-
function
|
|
1061
|
+
function ye(r) {
|
|
1057
1062
|
return new Promise((t, e) => {
|
|
1058
1063
|
setTimeout(e, r, new J(r));
|
|
1059
1064
|
});
|
|
@@ -1061,13 +1066,13 @@ function me(r) {
|
|
|
1061
1066
|
function xt(r, t) {
|
|
1062
1067
|
return Promise.race([
|
|
1063
1068
|
r(),
|
|
1064
|
-
|
|
1069
|
+
ye(t)
|
|
1065
1070
|
]);
|
|
1066
1071
|
}
|
|
1067
1072
|
function m(r, t, e, s) {
|
|
1068
1073
|
let n, i, a, c;
|
|
1069
1074
|
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: p = d, timeout:
|
|
1075
|
+
const { postEvent: p = d, timeout: h } = n || {}, g = n && "capture" in n ? n.capture : null, _ = () => new Promise((A, l) => {
|
|
1071
1076
|
const C = a.map((v) => y(v, (M) => {
|
|
1072
1077
|
c && (!H(M) || M.req_id !== c) || typeof g == "function" && !g(M) || (x(), A(M));
|
|
1073
1078
|
})), x = () => C.forEach((v) => v());
|
|
@@ -1077,9 +1082,9 @@ function m(r, t, e, s) {
|
|
|
1077
1082
|
x(), l(v);
|
|
1078
1083
|
}
|
|
1079
1084
|
});
|
|
1080
|
-
return typeof
|
|
1085
|
+
return typeof h == "number" ? xt(_, h) : _();
|
|
1081
1086
|
}
|
|
1082
|
-
async function
|
|
1087
|
+
async function O(r, t, e, s = {}) {
|
|
1083
1088
|
const { result: n, error: i } = await m(
|
|
1084
1089
|
"web_app_invoke_custom_method",
|
|
1085
1090
|
{
|
|
@@ -1094,7 +1099,7 @@ async function N(r, t, e, s = {}) {
|
|
|
1094
1099
|
throw new Error(i);
|
|
1095
1100
|
return n;
|
|
1096
1101
|
}
|
|
1097
|
-
class
|
|
1102
|
+
class Ee {
|
|
1098
1103
|
constructor(t, e, s = d) {
|
|
1099
1104
|
o(this, "ee", new w());
|
|
1100
1105
|
o(this, "state");
|
|
@@ -1144,22 +1149,22 @@ class ye {
|
|
|
1144
1149
|
function nt(r, t) {
|
|
1145
1150
|
return r + (r.length > 0 && t.length > 0 ? ` ${t}` : t);
|
|
1146
1151
|
}
|
|
1147
|
-
function
|
|
1152
|
+
function Ce(...r) {
|
|
1148
1153
|
return r.reduce((t, e) => {
|
|
1149
1154
|
let s = "";
|
|
1150
1155
|
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);
|
|
1151
1156
|
}, "");
|
|
1152
1157
|
}
|
|
1153
|
-
function
|
|
1158
|
+
function ve(r) {
|
|
1154
1159
|
return typeof r == "object" && r !== null && !Array.isArray(null);
|
|
1155
1160
|
}
|
|
1156
|
-
function
|
|
1157
|
-
return r.reduce((t, e) => (
|
|
1158
|
-
const i =
|
|
1161
|
+
function cr(...r) {
|
|
1162
|
+
return r.reduce((t, e) => (ve(e) && Object.entries(e).forEach(([s, n]) => {
|
|
1163
|
+
const i = Ce(t[s], n);
|
|
1159
1164
|
i.length > 0 && (t[s] = i);
|
|
1160
1165
|
}), t), {});
|
|
1161
1166
|
}
|
|
1162
|
-
class
|
|
1167
|
+
class Pe {
|
|
1163
1168
|
constructor(t, e = d) {
|
|
1164
1169
|
o(this, "ee", new w());
|
|
1165
1170
|
o(this, "state");
|
|
@@ -1201,7 +1206,7 @@ class ve {
|
|
|
1201
1206
|
function it(r, t) {
|
|
1202
1207
|
return r.reduce((e, s) => (e[s] = t, e), {});
|
|
1203
1208
|
}
|
|
1204
|
-
class
|
|
1209
|
+
class ke {
|
|
1205
1210
|
constructor(t, e, s = d) {
|
|
1206
1211
|
/**
|
|
1207
1212
|
* Checks if specified method is supported by current component.
|
|
@@ -1221,7 +1226,7 @@ class Pe {
|
|
|
1221
1226
|
*/
|
|
1222
1227
|
async delete(t, e = {}) {
|
|
1223
1228
|
const s = Array.isArray(t) ? t : [t];
|
|
1224
|
-
s.length !== 0 && await
|
|
1229
|
+
s.length !== 0 && await O(
|
|
1225
1230
|
"deleteStorageValues",
|
|
1226
1231
|
{ keys: s },
|
|
1227
1232
|
this.createRequestId(),
|
|
@@ -1233,21 +1238,21 @@ class Pe {
|
|
|
1233
1238
|
* @param options - request execution options.
|
|
1234
1239
|
*/
|
|
1235
1240
|
async getKeys(t = {}) {
|
|
1236
|
-
const e = await
|
|
1241
|
+
const e = await O(
|
|
1237
1242
|
"getStorageKeys",
|
|
1238
1243
|
{},
|
|
1239
1244
|
this.createRequestId(),
|
|
1240
1245
|
{ ...t, postEvent: this.postEvent }
|
|
1241
1246
|
);
|
|
1242
|
-
return Bt().of(
|
|
1247
|
+
return Bt().of(u()).parse(e);
|
|
1243
1248
|
}
|
|
1244
1249
|
async get(t, e = {}) {
|
|
1245
1250
|
const s = Array.isArray(t) ? t : [t];
|
|
1246
1251
|
if (s.length === 0)
|
|
1247
1252
|
return it(s, "");
|
|
1248
1253
|
const n = f(
|
|
1249
|
-
it(s,
|
|
1250
|
-
), i = await
|
|
1254
|
+
it(s, u())
|
|
1255
|
+
), i = await O(
|
|
1251
1256
|
"getStorageValues",
|
|
1252
1257
|
{ keys: s },
|
|
1253
1258
|
this.createRequestId(),
|
|
@@ -1262,7 +1267,7 @@ class Pe {
|
|
|
1262
1267
|
* @param options - request execution options.
|
|
1263
1268
|
*/
|
|
1264
1269
|
async set(t, e, s = {}) {
|
|
1265
|
-
await
|
|
1270
|
+
await O(
|
|
1266
1271
|
"saveStorageValue",
|
|
1267
1272
|
{ key: t, value: e },
|
|
1268
1273
|
this.createRequestId(),
|
|
@@ -1270,7 +1275,7 @@ class Pe {
|
|
|
1270
1275
|
);
|
|
1271
1276
|
}
|
|
1272
1277
|
}
|
|
1273
|
-
class
|
|
1278
|
+
class Se {
|
|
1274
1279
|
constructor(t, e = d) {
|
|
1275
1280
|
/**
|
|
1276
1281
|
* Checks if specified method is supported by current component.
|
|
@@ -1316,7 +1321,7 @@ class ke {
|
|
|
1316
1321
|
this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
|
|
1317
1322
|
}
|
|
1318
1323
|
}
|
|
1319
|
-
function
|
|
1324
|
+
function xe() {
|
|
1320
1325
|
const r = document.createElement("style");
|
|
1321
1326
|
r.id = "telegram-custom-styles", document.head.appendChild(r), y("set_custom_style", (t) => {
|
|
1322
1327
|
r.innerHTML = t;
|
|
@@ -1332,19 +1337,19 @@ function B(r) {
|
|
|
1332
1337
|
const t = sessionStorage.getItem(qt(r));
|
|
1333
1338
|
return t ? JSON.parse(t) : null;
|
|
1334
1339
|
}
|
|
1335
|
-
function
|
|
1336
|
-
const { isVisible: s = !1 } = r ? B("back-button") || {} : {}, n = new
|
|
1340
|
+
function qe(r, t, e) {
|
|
1341
|
+
const { isVisible: s = !1 } = r ? B("back-button") || {} : {}, n = new Ee(s, t, e);
|
|
1337
1342
|
return n.on("change", () => {
|
|
1338
1343
|
T("back-button", { isVisible: n.isVisible });
|
|
1339
1344
|
}), n;
|
|
1340
1345
|
}
|
|
1341
|
-
function
|
|
1342
|
-
const { isConfirmationNeeded: e = !1 } = r ? B("closing-behavior") || {} : {}, s = new
|
|
1346
|
+
function Ae(r, t) {
|
|
1347
|
+
const { isConfirmationNeeded: e = !1 } = r ? B("closing-behavior") || {} : {}, s = new Pe(e, t);
|
|
1343
1348
|
return s.on("change", () => T("closing-behavior", {
|
|
1344
1349
|
isConfirmationNeeded: s.isConfirmationNeeded
|
|
1345
1350
|
})), s;
|
|
1346
1351
|
}
|
|
1347
|
-
class
|
|
1352
|
+
class Ve {
|
|
1348
1353
|
constructor(t) {
|
|
1349
1354
|
o(this, "ee", new w());
|
|
1350
1355
|
o(this, "state");
|
|
@@ -1509,21 +1514,21 @@ class Ae {
|
|
|
1509
1514
|
return this.state.set(t), this.commit(), this;
|
|
1510
1515
|
}
|
|
1511
1516
|
}
|
|
1512
|
-
function
|
|
1517
|
+
function Re(r, t, e, s) {
|
|
1513
1518
|
const {
|
|
1514
1519
|
backgroundColor: n = t,
|
|
1515
1520
|
isEnabled: i = !1,
|
|
1516
1521
|
isVisible: a = !1,
|
|
1517
1522
|
isLoaderVisible: c = !1,
|
|
1518
1523
|
textColor: p = e,
|
|
1519
|
-
text:
|
|
1520
|
-
} = r ? B("main-button") || {} : {}, g = new
|
|
1524
|
+
text: h = ""
|
|
1525
|
+
} = r ? B("main-button") || {} : {}, g = new Ve({
|
|
1521
1526
|
backgroundColor: n,
|
|
1522
1527
|
isEnabled: i,
|
|
1523
1528
|
isLoaderVisible: c,
|
|
1524
1529
|
isVisible: a,
|
|
1525
1530
|
postEvent: s,
|
|
1526
|
-
text:
|
|
1531
|
+
text: h,
|
|
1527
1532
|
textColor: p
|
|
1528
1533
|
}), _ = () => T("main-button", {
|
|
1529
1534
|
backgroundColor: g.backgroundColor,
|
|
@@ -1535,22 +1540,22 @@ function Ve(r, t, e, s) {
|
|
|
1535
1540
|
});
|
|
1536
1541
|
return g.on("change", _), g;
|
|
1537
1542
|
}
|
|
1538
|
-
const
|
|
1543
|
+
const Ie = X({
|
|
1539
1544
|
contact: f({
|
|
1540
1545
|
userId: {
|
|
1541
1546
|
type: q(),
|
|
1542
1547
|
from: "user_id"
|
|
1543
1548
|
},
|
|
1544
1549
|
phoneNumber: {
|
|
1545
|
-
type:
|
|
1550
|
+
type: u(),
|
|
1546
1551
|
from: "phone_number"
|
|
1547
1552
|
},
|
|
1548
1553
|
firstName: {
|
|
1549
|
-
type:
|
|
1554
|
+
type: u(),
|
|
1550
1555
|
from: "first_name"
|
|
1551
1556
|
},
|
|
1552
1557
|
lastName: {
|
|
1553
|
-
type:
|
|
1558
|
+
type: u().optional(),
|
|
1554
1559
|
from: "last_name"
|
|
1555
1560
|
}
|
|
1556
1561
|
}),
|
|
@@ -1558,9 +1563,9 @@ const Re = X({
|
|
|
1558
1563
|
type: pt(),
|
|
1559
1564
|
from: "auth_date"
|
|
1560
1565
|
},
|
|
1561
|
-
hash:
|
|
1566
|
+
hash: u()
|
|
1562
1567
|
});
|
|
1563
|
-
class
|
|
1568
|
+
class Le {
|
|
1564
1569
|
constructor(t) {
|
|
1565
1570
|
o(this, "ee", new w());
|
|
1566
1571
|
o(this, "state");
|
|
@@ -1599,7 +1604,7 @@ class Ie {
|
|
|
1599
1604
|
setHeaderColor: "web_app_set_header_color",
|
|
1600
1605
|
setBackgroundColor: "web_app_set_background_color"
|
|
1601
1606
|
});
|
|
1602
|
-
this.postEvent = e, this.botInline = a, this.createRequestId = c, this.supports = (
|
|
1607
|
+
this.postEvent = e, this.botInline = a, this.createRequestId = c, this.supports = (h) => !(!p(h) || h === "switchInlineQuery" && !a), this.state = new b({ backgroundColor: n, headerColor: s }, this.ee), this.supportsParam = St(i, {
|
|
1603
1608
|
"setHeaderColor.color": ["web_app_set_header_color", "color"]
|
|
1604
1609
|
});
|
|
1605
1610
|
}
|
|
@@ -1607,7 +1612,7 @@ class Ie {
|
|
|
1607
1612
|
* Attempts to get requested contact.
|
|
1608
1613
|
*/
|
|
1609
1614
|
async getRequestedContact() {
|
|
1610
|
-
return
|
|
1615
|
+
return O(
|
|
1611
1616
|
"getRequestedContact",
|
|
1612
1617
|
{},
|
|
1613
1618
|
this.createRequestId(),
|
|
@@ -1615,7 +1620,7 @@ class Ie {
|
|
|
1615
1620
|
postEvent: this.postEvent,
|
|
1616
1621
|
timeout: 1e4
|
|
1617
1622
|
}
|
|
1618
|
-
).then((t) =>
|
|
1623
|
+
).then((t) => Ie.parse(t));
|
|
1619
1624
|
}
|
|
1620
1625
|
/**
|
|
1621
1626
|
* The Mini App background color.
|
|
@@ -1692,7 +1697,7 @@ class Ie {
|
|
|
1692
1697
|
return await this.getRequestedContact();
|
|
1693
1698
|
} catch {
|
|
1694
1699
|
}
|
|
1695
|
-
await
|
|
1700
|
+
await me(n), n += 50;
|
|
1696
1701
|
}
|
|
1697
1702
|
throw new Error("Unable to retrieve requested contact.");
|
|
1698
1703
|
}, t);
|
|
@@ -1778,28 +1783,28 @@ class Ie {
|
|
|
1778
1783
|
});
|
|
1779
1784
|
}
|
|
1780
1785
|
}
|
|
1781
|
-
function
|
|
1786
|
+
function $e(r, t, e, s, n, i) {
|
|
1782
1787
|
const {
|
|
1783
1788
|
backgroundColor: a = t,
|
|
1784
1789
|
headerColor: c = "bg_color"
|
|
1785
|
-
} = r ? B("mini-app") || {} : {}, p = new
|
|
1790
|
+
} = r ? B("mini-app") || {} : {}, p = new Le({
|
|
1786
1791
|
headerColor: c,
|
|
1787
1792
|
backgroundColor: a,
|
|
1788
1793
|
version: e,
|
|
1789
1794
|
botInline: s,
|
|
1790
1795
|
createRequestId: n,
|
|
1791
1796
|
postEvent: i
|
|
1792
|
-
}),
|
|
1797
|
+
}), h = () => T("mini-app", {
|
|
1793
1798
|
backgroundColor: p.backgroundColor,
|
|
1794
1799
|
headerColor: p.headerColor
|
|
1795
1800
|
});
|
|
1796
|
-
return p.on("change",
|
|
1801
|
+
return p.on("change", h), p;
|
|
1797
1802
|
}
|
|
1798
|
-
function
|
|
1803
|
+
function Te() {
|
|
1799
1804
|
let r = 0;
|
|
1800
1805
|
return () => (r += 1, r.toString());
|
|
1801
1806
|
}
|
|
1802
|
-
class
|
|
1807
|
+
class Be {
|
|
1803
1808
|
constructor(t, e, s = d) {
|
|
1804
1809
|
o(this, "ee", new w());
|
|
1805
1810
|
o(this, "state");
|
|
@@ -1846,17 +1851,17 @@ class Te {
|
|
|
1846
1851
|
this.isVisible = !0;
|
|
1847
1852
|
}
|
|
1848
1853
|
}
|
|
1849
|
-
function
|
|
1850
|
-
const { isVisible: s = !1 } = r ? B("settings-button") || {} : {}, n = new
|
|
1854
|
+
function De(r, t, e) {
|
|
1855
|
+
const { isVisible: s = !1 } = r ? B("settings-button") || {} : {}, n = new Be(s, t, e);
|
|
1851
1856
|
return n.on("change", () => {
|
|
1852
1857
|
T("settings-button", { isVisible: n.isVisible });
|
|
1853
1858
|
}), n;
|
|
1854
1859
|
}
|
|
1855
|
-
function
|
|
1860
|
+
function We(r) {
|
|
1856
1861
|
const t = new Mt(r);
|
|
1857
1862
|
return t.listen(), t;
|
|
1858
1863
|
}
|
|
1859
|
-
function
|
|
1864
|
+
function Oe(r) {
|
|
1860
1865
|
return ["macos", "tdesktop", "unigram", "web", "weba"].includes(r);
|
|
1861
1866
|
}
|
|
1862
1867
|
async function At(r) {
|
|
@@ -2009,11 +2014,11 @@ function j(r) {
|
|
|
2009
2014
|
width: t.width
|
|
2010
2015
|
})), t.listen(), t;
|
|
2011
2016
|
}
|
|
2012
|
-
function
|
|
2017
|
+
function He(r, t, e, s) {
|
|
2013
2018
|
const n = r ? B("viewport") : null;
|
|
2014
2019
|
if (n)
|
|
2015
2020
|
return j({ ...n, postEvent: e });
|
|
2016
|
-
if (
|
|
2021
|
+
if (Oe(t))
|
|
2017
2022
|
return j({
|
|
2018
2023
|
height: window.innerHeight,
|
|
2019
2024
|
isExpanded: !0,
|
|
@@ -2044,7 +2049,7 @@ function Oe(r, t, e, s) {
|
|
|
2044
2049
|
function S(r, t) {
|
|
2045
2050
|
document.documentElement.style.setProperty(r, t);
|
|
2046
2051
|
}
|
|
2047
|
-
function
|
|
2052
|
+
function Ue(r, t) {
|
|
2048
2053
|
const e = () => {
|
|
2049
2054
|
S("--tg-background-color", r.backgroundColor);
|
|
2050
2055
|
}, s = () => {
|
|
@@ -2056,7 +2061,7 @@ function He(r, t) {
|
|
|
2056
2061
|
};
|
|
2057
2062
|
t.on("change", s), r.on("change:backgroundColor", e), r.on("change:headerColor", s), e(), s();
|
|
2058
2063
|
}
|
|
2059
|
-
function
|
|
2064
|
+
function Me(r) {
|
|
2060
2065
|
const t = () => {
|
|
2061
2066
|
const e = r.getState();
|
|
2062
2067
|
Object.entries(e).forEach(([s, n]) => {
|
|
@@ -2072,7 +2077,7 @@ function ot(r) {
|
|
|
2072
2077
|
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`);
|
|
2073
2078
|
r.on("change:height", t), r.on("change:width", e), r.on("change:stableHeight", s), t(), e(), s();
|
|
2074
2079
|
}
|
|
2075
|
-
function
|
|
2080
|
+
function je(r) {
|
|
2076
2081
|
return typeof r == "object" ? r : r ? {
|
|
2077
2082
|
themeParams: !0,
|
|
2078
2083
|
viewport: !0,
|
|
@@ -2080,10 +2085,10 @@ function Me(r) {
|
|
|
2080
2085
|
} : {};
|
|
2081
2086
|
}
|
|
2082
2087
|
function at(r, t, e, s) {
|
|
2083
|
-
const n =
|
|
2084
|
-
n.miniApp &&
|
|
2088
|
+
const n = je(r);
|
|
2089
|
+
n.miniApp && Ue(t, e), n.themeParams && Me(e), n.viewport && (s instanceof Promise ? s.then(ot) : ot(s));
|
|
2085
2090
|
}
|
|
2086
|
-
function
|
|
2091
|
+
function Ge(r) {
|
|
2087
2092
|
const { hostname: t, pathname: e } = new URL(r, window.location.href);
|
|
2088
2093
|
if (t !== "t.me")
|
|
2089
2094
|
throw new Error(`Incorrect hostname: ${t}`);
|
|
@@ -2092,7 +2097,7 @@ function je(r) {
|
|
|
2092
2097
|
throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');
|
|
2093
2098
|
return s[2];
|
|
2094
2099
|
}
|
|
2095
|
-
class
|
|
2100
|
+
class Fe {
|
|
2096
2101
|
constructor(t, e = d) {
|
|
2097
2102
|
o(this, "ee", new w());
|
|
2098
2103
|
o(this, "state");
|
|
@@ -2122,7 +2127,7 @@ class Ge {
|
|
|
2122
2127
|
async open(t, e) {
|
|
2123
2128
|
if (this.isOpened)
|
|
2124
2129
|
throw new Error("Invoice is already opened");
|
|
2125
|
-
const s = e ?
|
|
2130
|
+
const s = e ? Ge(t) : t;
|
|
2126
2131
|
this.isOpened = !0;
|
|
2127
2132
|
try {
|
|
2128
2133
|
return (await m(
|
|
@@ -2141,7 +2146,7 @@ class Ge {
|
|
|
2141
2146
|
}
|
|
2142
2147
|
}
|
|
2143
2148
|
}
|
|
2144
|
-
function
|
|
2149
|
+
function ze(r) {
|
|
2145
2150
|
const t = r.message.trim(), e = (r.title || "").trim(), s = r.buttons || [];
|
|
2146
2151
|
let n;
|
|
2147
2152
|
if (e.length > 64)
|
|
@@ -2165,7 +2170,7 @@ function Fe(r) {
|
|
|
2165
2170
|
return { ...i, id: a };
|
|
2166
2171
|
}), { title: e, message: t, buttons: n };
|
|
2167
2172
|
}
|
|
2168
|
-
class
|
|
2173
|
+
class Je {
|
|
2169
2174
|
constructor(t, e = d) {
|
|
2170
2175
|
o(this, "ee", new w());
|
|
2171
2176
|
o(this, "state");
|
|
@@ -2210,7 +2215,7 @@ class ze {
|
|
|
2210
2215
|
throw new Error("Popup is already opened.");
|
|
2211
2216
|
return this.isOpened = !0, m(
|
|
2212
2217
|
"web_app_open_popup",
|
|
2213
|
-
|
|
2218
|
+
ze(t),
|
|
2214
2219
|
"popup_closed",
|
|
2215
2220
|
{ postEvent: this.postEvent }
|
|
2216
2221
|
).then(({ button_id: e = null }) => e).finally(() => {
|
|
@@ -2218,7 +2223,7 @@ class ze {
|
|
|
2218
2223
|
});
|
|
2219
2224
|
}
|
|
2220
2225
|
}
|
|
2221
|
-
class
|
|
2226
|
+
class Qe {
|
|
2222
2227
|
constructor(t, e = d) {
|
|
2223
2228
|
o(this, "ee", new w());
|
|
2224
2229
|
o(this, "state");
|
|
@@ -2277,7 +2282,7 @@ class Je {
|
|
|
2277
2282
|
}
|
|
2278
2283
|
}
|
|
2279
2284
|
}
|
|
2280
|
-
class
|
|
2285
|
+
class Ze {
|
|
2281
2286
|
constructor(t, e, s = d) {
|
|
2282
2287
|
/**
|
|
2283
2288
|
* Checks if specified method is supported by current component.
|
|
@@ -2348,7 +2353,7 @@ class Qe {
|
|
|
2348
2353
|
).then(({ data: t = null }) => t);
|
|
2349
2354
|
}
|
|
2350
2355
|
}
|
|
2351
|
-
function
|
|
2356
|
+
function ur(r = {}) {
|
|
2352
2357
|
const {
|
|
2353
2358
|
async: t = !1,
|
|
2354
2359
|
complete: e = t,
|
|
@@ -2362,44 +2367,44 @@ function cr(r = {}) {
|
|
|
2362
2367
|
initDataRaw: a,
|
|
2363
2368
|
version: c,
|
|
2364
2369
|
platform: p,
|
|
2365
|
-
themeParams:
|
|
2370
|
+
themeParams: h,
|
|
2366
2371
|
botInline: g = !1
|
|
2367
2372
|
},
|
|
2368
2373
|
isPageReload: _
|
|
2369
|
-
} = Ct(), A =
|
|
2370
|
-
vt() && (n &&
|
|
2374
|
+
} = Ct(), A = Te(), l = be(c);
|
|
2375
|
+
vt() && (n && xe(), l("iframe_ready", { reload_supported: !0 }), y("reload_iframe", () => window.location.reload()));
|
|
2371
2376
|
const C = {
|
|
2372
|
-
backButton:
|
|
2373
|
-
closingBehavior:
|
|
2374
|
-
cloudStorage: new
|
|
2377
|
+
backButton: qe(_, c, l),
|
|
2378
|
+
closingBehavior: Ae(_, l),
|
|
2379
|
+
cloudStorage: new ke(c, A, l),
|
|
2375
2380
|
createRequestId: A,
|
|
2376
|
-
hapticFeedback: new
|
|
2377
|
-
invoice: new
|
|
2378
|
-
mainButton:
|
|
2381
|
+
hapticFeedback: new Se(c, l),
|
|
2382
|
+
invoice: new Fe(c, l),
|
|
2383
|
+
mainButton: Re(
|
|
2379
2384
|
_,
|
|
2380
|
-
|
|
2381
|
-
|
|
2385
|
+
h.buttonColor || "#000000",
|
|
2386
|
+
h.buttonTextColor || "#ffffff",
|
|
2382
2387
|
l
|
|
2383
2388
|
),
|
|
2384
|
-
miniApp:
|
|
2389
|
+
miniApp: $e(
|
|
2385
2390
|
_,
|
|
2386
|
-
|
|
2391
|
+
h.backgroundColor || "#ffffff",
|
|
2387
2392
|
c,
|
|
2388
2393
|
g,
|
|
2389
2394
|
A,
|
|
2390
2395
|
l
|
|
2391
2396
|
),
|
|
2392
|
-
popup: new
|
|
2397
|
+
popup: new Je(c, l),
|
|
2393
2398
|
postEvent: l,
|
|
2394
|
-
qrScanner: new
|
|
2395
|
-
settingsButton:
|
|
2396
|
-
themeParams:
|
|
2397
|
-
utils: new
|
|
2399
|
+
qrScanner: new Qe(c, l),
|
|
2400
|
+
settingsButton: De(_, c, l),
|
|
2401
|
+
themeParams: We(h),
|
|
2402
|
+
utils: new Ze(c, A, l),
|
|
2398
2403
|
...i ? {
|
|
2399
|
-
initData: new
|
|
2404
|
+
initData: new Ot(i),
|
|
2400
2405
|
initDataRaw: a
|
|
2401
2406
|
} : {}
|
|
2402
|
-
}, x =
|
|
2407
|
+
}, x = He(_, p, l, e);
|
|
2403
2408
|
return x instanceof Promise || e ? Promise.resolve(x).then((v) => (at(
|
|
2404
2409
|
s,
|
|
2405
2410
|
C.miniApp,
|
|
@@ -2424,7 +2429,7 @@ function hr(r) {
|
|
|
2424
2429
|
const t = r.match(/#(.+)/);
|
|
2425
2430
|
return t ? t[1] : null;
|
|
2426
2431
|
}
|
|
2427
|
-
async function
|
|
2432
|
+
async function N(r) {
|
|
2428
2433
|
return r === 0 ? !0 : Promise.race([
|
|
2429
2434
|
new Promise((t) => {
|
|
2430
2435
|
window.addEventListener("popstate", function e() {
|
|
@@ -2437,14 +2442,14 @@ async function O(r) {
|
|
|
2437
2442
|
})
|
|
2438
2443
|
]);
|
|
2439
2444
|
}
|
|
2440
|
-
async function
|
|
2441
|
-
if (window.history.length <= 1 || (window.history.pushState(null, ""), await
|
|
2445
|
+
async function Ke() {
|
|
2446
|
+
if (window.history.length <= 1 || (window.history.pushState(null, ""), await N(1 - window.history.length)))
|
|
2442
2447
|
return;
|
|
2443
|
-
let t = await
|
|
2448
|
+
let t = await N(-1);
|
|
2444
2449
|
for (; t; )
|
|
2445
|
-
t = await
|
|
2450
|
+
t = await N(-1);
|
|
2446
2451
|
}
|
|
2447
|
-
class
|
|
2452
|
+
class Ye {
|
|
2448
2453
|
constructor(t, e, {
|
|
2449
2454
|
debug: s = !1,
|
|
2450
2455
|
loggerPrefix: n = "Navigator"
|
|
@@ -2644,7 +2649,7 @@ class Ke {
|
|
|
2644
2649
|
}
|
|
2645
2650
|
}
|
|
2646
2651
|
const ct = 0, Z = 1, K = 2;
|
|
2647
|
-
class Vt extends
|
|
2652
|
+
class Vt extends Ye {
|
|
2648
2653
|
constructor(e, s, n = {}) {
|
|
2649
2654
|
super(e, s, {
|
|
2650
2655
|
...n,
|
|
@@ -2708,7 +2713,7 @@ class Vt extends Ke {
|
|
|
2708
2713
|
async syncHistory() {
|
|
2709
2714
|
window.removeEventListener("popstate", this.onPopState);
|
|
2710
2715
|
const e = `#${this.path}`;
|
|
2711
|
-
await
|
|
2716
|
+
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 N(-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 N(-1)) : (this.logger.log("Setting up history: [~, *]"), window.history.replaceState(ct, ""), window.history.pushState(null, "", e)), window.addEventListener("popstate", this.onPopState);
|
|
2712
2717
|
}
|
|
2713
2718
|
emitChanged(e, s) {
|
|
2714
2719
|
this.ee.emit("change", {
|
|
@@ -2732,63 +2737,63 @@ class Vt extends Ke {
|
|
|
2732
2737
|
}
|
|
2733
2738
|
}
|
|
2734
2739
|
export {
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2740
|
+
Ee as BackButton,
|
|
2741
|
+
Pe as ClosingBehavior,
|
|
2742
|
+
ke as CloudStorage,
|
|
2743
|
+
Se as HapticFeedback,
|
|
2739
2744
|
Vt as HashNavigator,
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2745
|
+
Ot as InitData,
|
|
2746
|
+
Fe as Invoice,
|
|
2747
|
+
Ve as MainButton,
|
|
2743
2748
|
tt as MethodUnsupportedError,
|
|
2744
|
-
|
|
2745
|
-
|
|
2749
|
+
Le as MiniApp,
|
|
2750
|
+
Ye as Navigator,
|
|
2746
2751
|
et as ParameterUnsupportedError,
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2752
|
+
Je as Popup,
|
|
2753
|
+
Qe as QRScanner,
|
|
2754
|
+
Be as SettingsButton,
|
|
2750
2755
|
Mt as ThemeParams,
|
|
2751
2756
|
J as TimeoutError,
|
|
2752
|
-
|
|
2757
|
+
Ze as Utils,
|
|
2753
2758
|
Ne as Viewport,
|
|
2754
2759
|
Wt as chatParser,
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2760
|
+
Ce as classNames,
|
|
2761
|
+
_e as compareVersions,
|
|
2762
|
+
be as createPostEvent,
|
|
2758
2763
|
hr as getHash,
|
|
2759
|
-
|
|
2764
|
+
ur as init,
|
|
2760
2765
|
wt as initDataParser,
|
|
2761
|
-
|
|
2766
|
+
O as invokeCustomMethod,
|
|
2762
2767
|
ft as isColorDark,
|
|
2763
2768
|
vt as isIframe,
|
|
2764
2769
|
lt as isRGB,
|
|
2765
2770
|
Dt as isRGBShort,
|
|
2766
2771
|
H as isRecord,
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2772
|
+
Oe as isStableViewportPlatform,
|
|
2773
|
+
rr as isTMA,
|
|
2774
|
+
ar as isTimeoutError,
|
|
2770
2775
|
mt as launchParamsParser,
|
|
2771
|
-
|
|
2776
|
+
cr as mergeClassNames,
|
|
2772
2777
|
$ as off,
|
|
2773
2778
|
y as on,
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2779
|
+
ir as once,
|
|
2780
|
+
tr as parseInitData,
|
|
2781
|
+
jt as parseLaunchParams,
|
|
2777
2782
|
bt as parseThemeParams,
|
|
2778
2783
|
d as postEvent,
|
|
2779
2784
|
m as request,
|
|
2780
|
-
|
|
2785
|
+
er as requestThemeParams,
|
|
2781
2786
|
At as requestViewport,
|
|
2782
2787
|
Ct as retrieveLaunchData,
|
|
2783
|
-
|
|
2788
|
+
Jt as serializeLaunchParams,
|
|
2784
2789
|
Ut as serializeThemeParams,
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2790
|
+
sr as setDebug,
|
|
2791
|
+
nr as setTargetOrigin,
|
|
2792
|
+
or as subscribe,
|
|
2788
2793
|
R as supports,
|
|
2789
2794
|
_t as themeParamsParser,
|
|
2790
2795
|
dt as toRGB,
|
|
2791
|
-
|
|
2796
|
+
we as unsubscribe,
|
|
2792
2797
|
rt as userParser,
|
|
2793
2798
|
xt as withTimeout
|
|
2794
2799
|
};
|