@types/telegram-web-app 7.2.1 → 7.3.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.
@@ -8,7 +8,7 @@ This package contains type definitions for telegram-web-app (https://telegram.or
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/telegram-web-app.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Mon, 01 Apr 2024 20:35:45 GMT
11
+ * Last updated: Sun, 07 Jul 2024 15:07:38 GMT
12
12
  * Dependencies: none
13
13
 
14
14
  # Credits
@@ -145,62 +145,38 @@ interface WebApp {
145
145
  * A method that sets the app event handler. Check the list of available
146
146
  * events.
147
147
  */
148
- onEvent(
149
- eventType:
150
- | "themeChanged"
151
- | "mainButtonClicked"
152
- | "backButtonClicked"
153
- | "settingsButtonClicked"
154
- | "biometricManagerUpdated",
155
- eventHandler: () => void,
156
- ): void;
157
- onEvent(eventType: "popupClosed", eventHandler: (eventData: { button_id: string | null }) => void): void;
158
- onEvent(eventType: "viewportChanged", eventHandler: (eventData: { isStateStable: boolean }) => void): void;
159
- onEvent(
160
- eventType: "invoiceClosed",
161
- eventHandler: (eventData: { url: string; status: "paid" | "cancelled" | "failed" | "pending" }) => void,
162
- ): void;
163
- onEvent(eventType: "qrTextReceived", eventHandler: (eventData: { data: string }) => void): void;
164
- onEvent(eventType: "clipboardTextReceived", eventHandler: (eventData: { data: string | null }) => void): void;
165
- onEvent(
166
- eventType: "writeAccessRequested",
167
- eventHandler: (eventData: { status: "allowed" | "cancelled" }) => void,
168
- ): void;
169
- onEvent(eventType: "contactRequested", eventHandler: (eventData: RequestContactResponse) => void): void;
170
- onEvent(
171
- eventType: "biometricAuthRequested",
172
- eventHandler: (eventData: { isAuthenticated: boolean; biometricToken?: string }) => void,
173
- ): void;
174
- onEvent(eventType: "biometricTokenUpdated", eventHandler: (eventData: { isUpdated: boolean }) => void): void;
148
+ onEvent(eventType: "themeChanged", eventHandler: ThemeChangedCallback): void;
149
+ onEvent(eventType: "mainButtonClicked", eventHandler: MainButtonClickedCallback): void;
150
+ onEvent(eventType: "backButtonClicked", eventHandler: BackButtonClickedCallback): void;
151
+ onEvent(eventType: "settingsButtonClicked", eventHandler: SettingsButtonClickedCallback): void;
152
+ onEvent(eventType: "popupClosed", eventHandler: PopupClosedCallback): void;
153
+ onEvent(eventType: "viewportChanged", eventHandler: ViewportChangedCallback): void;
154
+ onEvent(eventType: "invoiceClosed", eventHandler: InvoiceClosedCallback): void;
155
+ onEvent(eventType: "qrTextReceived", eventHandler: QrTextReceivedCallback): void;
156
+ onEvent(eventType: "scanQrPopupClosed", eventHandler: ScanQrPopupClosedCallback): void;
157
+ onEvent(eventType: "clipboardTextReceived", eventHandler: ClipboardTextReceivedCallback): void;
158
+ onEvent(eventType: "writeAccessRequested", eventHandler: WriteAccessRequestedCallback): void;
159
+ onEvent(eventType: "contactRequested", eventHandler: ContactRequestedCallback): void;
160
+ onEvent(eventType: "biometricManagerUpdated", eventHandler: BiometricManagerUpdatedCallback): void;
161
+ onEvent(eventType: "biometricAuthRequested", eventHandler: BiometricAuthRequestedCallback): void;
162
+ onEvent(eventType: "biometricTokenUpdated", eventHandler: BiometricTokenUpdatedCallback): void;
175
163
 
176
164
  /** A method that deletes a previously set event handler. */
177
- offEvent(
178
- eventType:
179
- | "themeChanged"
180
- | "mainButtonClicked"
181
- | "backButtonClicked"
182
- | "settingsButtonClicked"
183
- | "biometricManagerUpdated",
184
- eventHandler: () => void,
185
- ): void;
186
- offEvent(eventType: "popupClosed", eventHandler: (eventData: { button_id: string | null }) => void): void;
187
- offEvent(eventType: "viewportChanged", eventHandler: (eventData: { isStateStable: boolean }) => void): void;
188
- offEvent(
189
- eventType: "invoiceClosed",
190
- eventHandler: (eventData: { url: string; status: "paid" | "cancelled" | "failed" | "pending" }) => void,
191
- ): void;
192
- offEvent(eventType: "qrTextReceived", eventHandler: (eventData: { data: string }) => void): void;
193
- offEvent(eventType: "clipboardTextReceived", eventHandler: (eventData: { data: string | null }) => void): void;
194
- offEvent(
195
- eventType: "writeAccessRequested",
196
- eventHandler: (eventData: { status: "allowed" | "cancelled" }) => void,
197
- ): void;
198
- offEvent(eventType: "contactRequested", eventHandler: (eventData: RequestContactResponse) => void): void;
199
- offEvent(
200
- eventType: "biometricAuthRequested",
201
- eventHandler: (eventData: { isAuthenticated: boolean; biometricToken?: string }) => void,
202
- ): void;
203
- offEvent(eventType: "biometricTokenUpdated", eventHandler: (eventData: { isUpdated: boolean }) => void): void;
165
+ offEvent(eventType: "themeChanged", eventHandler: ThemeChangedCallback): void;
166
+ offEvent(eventType: "mainButtonClicked", eventHandler: MainButtonClickedCallback): void;
167
+ offEvent(eventType: "backButtonClicked", eventHandler: BackButtonClickedCallback): void;
168
+ offEvent(eventType: "settingsButtonClicked", eventHandler: SettingsButtonClickedCallback): void;
169
+ offEvent(eventType: "popupClosed", eventHandler: PopupClosedCallback): void;
170
+ offEvent(eventType: "viewportChanged", eventHandler: ViewportChangedCallback): void;
171
+ offEvent(eventType: "invoiceClosed", eventHandler: InvoiceClosedCallback): void;
172
+ offEvent(eventType: "qrTextReceived", eventHandler: QrTextReceivedCallback): void;
173
+ offEvent(eventType: "scanQrPopupClosed", eventHandler: ScanQrPopupClosedCallback): void;
174
+ offEvent(eventType: "clipboardTextReceived", eventHandler: ClipboardTextReceivedCallback): void;
175
+ offEvent(eventType: "writeAccessRequested", eventHandler: WriteAccessRequestedCallback): void;
176
+ offEvent(eventType: "contactRequested", eventHandler: ContactRequestedCallback): void;
177
+ offEvent(eventType: "biometricManagerUpdated", eventHandler: BiometricManagerUpdatedCallback): void;
178
+ offEvent(eventType: "biometricAuthRequested", eventHandler: BiometricAuthRequestedCallback): void;
179
+ offEvent(eventType: "biometricTokenUpdated", eventHandler: BiometricTokenUpdatedCallback): void;
204
180
 
205
181
  /**
206
182
  * A method used to send data to the bot. When this method is called, a
@@ -269,6 +245,7 @@ interface WebApp {
269
245
  * The Web App will receive the event qrTextReceived every time the scanner catches a code with text data.
270
246
  * If an optional callback parameter was passed, the callback function will be called and the text from the QR
271
247
  * code will be passed as the first argument. Returning true inside this callback function causes the popup to be closed.
248
+ * Starting from **Bot API 7.7**, the Mini App will receive the scanQrPopupClosed event if the user closes the native popup for scanning a QR code.
272
249
  */
273
250
  showScanQrPopup(params: ScanQrPopupParams, callback?: (data: string) => void): void;
274
251
  /**
@@ -325,8 +302,40 @@ interface WebApp {
325
302
  expand(): void;
326
303
  /** A method that closes the Web App. */
327
304
  close(): void;
305
+ /**
306
+ * `True`, if vertical swipes to close or minimize the Mini App are enabled.
307
+ * `False`, if vertical swipes to close or minimize the Mini App are disabled.
308
+ * In any case, the user will still be able to minimize and close the Mini App by swiping the Mini App's header.
309
+ */
310
+ isVerticalSwipesEnabled: boolean;
311
+ /**
312
+ * **Bot API 7.7+** A method that enables vertical swipes to close or minimize the Mini App.
313
+ * For user convenience, it is recommended to always enable swipes unless they conflict with the Mini App's own gestures.
314
+ */
315
+ enableVerticalSwipes(): void;
316
+ /**
317
+ * **Bot API 7.7+** A method that disables vertical swipes to close or minimize the Mini App.
318
+ * This method is useful if your Mini App uses swipe gestures that may conflict with the gestures for minimizing and closing the app.
319
+ */
320
+ disableVerticalSwipes(): void;
328
321
  }
329
322
 
323
+ type ThemeChangedCallback = () => void;
324
+ type ViewportChangedCallback = (eventData: { isStateStable: boolean }) => void;
325
+ type MainButtonClickedCallback = () => void;
326
+ type BackButtonClickedCallback = () => void;
327
+ type SettingsButtonClickedCallback = () => void;
328
+ type InvoiceClosedCallback = (eventData: { url: string; status: "paid" | "cancelled" | "failed" | "pending" }) => void;
329
+ type PopupClosedCallback = (eventData: { button_id: string | null }) => void;
330
+ type QrTextReceivedCallback = (eventData: { data: string }) => void;
331
+ type ScanQrPopupClosedCallback = () => void;
332
+ type ClipboardTextReceivedCallback = (eventData: { data: string | null }) => void;
333
+ type WriteAccessRequestedCallback = (eventData: { status: "allowed" | "cancelled" }) => void;
334
+ type ContactRequestedCallback = (eventData: RequestContactResponse) => void;
335
+ type BiometricManagerUpdatedCallback = () => void;
336
+ type BiometricAuthRequestedCallback = (eventData: { isAuthenticated: boolean; biometricToken?: string }) => void;
337
+ type BiometricTokenUpdatedCallback = (eventData: { isUpdated: boolean }) => void;
338
+
330
339
  /**
331
340
  * Web Apps can adjust the appearance of the interface to match the Telegram
332
341
  * user's app in real time. This object contains the user's current theme
@@ -389,6 +398,11 @@ interface ThemeParams {
389
398
  * Also available as the CSS variable `var(--tg-theme-section-header-text-color)`.
390
399
  */
391
400
  section_header_text_color?: `#${string}`;
401
+ /**
402
+ * **Bot API 7.6+** Section separator color in the `#RRGGBB` format.
403
+ * Also available as the CSS variable `var(--tg-theme-section-separator-color)`.
404
+ */
405
+ section_separator_color?: string;
392
406
  /**
393
407
  * **Bot API 7.0+** Subtitle text color in the `#RRGGBB` format.
394
408
  * Also available as the CSS variable `var(--tg-theme-subtitle-text-color)`.
@@ -640,7 +654,7 @@ interface CloudStorage {
640
654
  * null and the second argument will be a boolean indicating whether the
641
655
  * value was stored.
642
656
  */
643
- setItem(key: string, value: string, callback?: (error: string | null, success: null | true) => void): CloudStorage;
657
+ setItem(key: string, value: string, callback?: CloudStorageSetItemCallback): CloudStorage;
644
658
  /**
645
659
  * A method that receives a value from the cloud storage using
646
660
  * the specified key.
@@ -652,7 +666,7 @@ interface CloudStorage {
652
666
  * success, the first argument will be null and the value will be passed
653
667
  * as the second argument.
654
668
  */
655
- getItem(key: string, callback?: (error: string | null, value: null | string) => void): CloudStorage;
669
+ getItem(key: string, callback?: CloudStorageGetItemCallback): CloudStorage;
656
670
  /**
657
671
  * A method that receives values from the cloud storage using the specified
658
672
  * keys.
@@ -664,10 +678,7 @@ interface CloudStorage {
664
678
  * success, the first argument will be null and the values will be passed
665
679
  * as the second argument.
666
680
  */
667
- getItems(
668
- keys: string[],
669
- callback?: (error: string | null, values: null | Record<string, string>) => void,
670
- ): CloudStorage;
681
+ getItems(keys: string[], callback?: CloudStorageGetItemsCallback): CloudStorage;
671
682
  /**
672
683
  * A method that removes a value from the cloud storage using the specified
673
684
  * key.
@@ -680,7 +691,7 @@ interface CloudStorage {
680
691
  * argument will be null and the second argument will be a boolean
681
692
  * indicating whether the value was removed.
682
693
  */
683
- removeItem(key: string, callback?: (error: string | null, success: null | true) => void): CloudStorage;
694
+ removeItem(key: string, callback?: CloudStorageRemoveItemCallback): CloudStorage;
684
695
  /**
685
696
  * A method that removes values from the cloud storage using the specified
686
697
  * keys.
@@ -693,7 +704,7 @@ interface CloudStorage {
693
704
  * argument will be null and the second argument will be a boolean
694
705
  * indicating whether the values were removed.
695
706
  */
696
- removeItems(keys: string[], callback?: (error: string | null, success: null | true) => void): CloudStorage;
707
+ removeItems(keys: string[], callback?: CloudStorageRemoveItemsCallback): CloudStorage;
697
708
  /**
698
709
  * A method that receives the list of all keys stored in the cloud storage.
699
710
  *
@@ -702,9 +713,16 @@ interface CloudStorage {
702
713
  * first argument will be null and the list of keys will be passed as the
703
714
  * second argument.
704
715
  */
705
- getKeys(callback?: (error: string | null, keys: null | string[]) => void): CloudStorage;
716
+ getKeys(callback?: CloudStorageGetKeysCallback): CloudStorage;
706
717
  }
707
718
 
719
+ type CloudStorageSetItemCallback = (error: string | null, success: null | true) => void;
720
+ type CloudStorageGetItemCallback = (error: string | null, value: null | string) => void;
721
+ type CloudStorageGetItemsCallback = (error: string | null, values: null | Record<string, string>) => void;
722
+ type CloudStorageRemoveItemCallback = (error: string | null, success: null | true) => void;
723
+ type CloudStorageRemoveItemsCallback = (error: string | null, success: null | true) => void;
724
+ type CloudStorageGetKeysCallback = (error: string | null, keys: null | string[]) => void;
725
+
708
726
  /**
709
727
  * This object controls biometrics on the device. Before the first use
710
728
  * of this object, it needs to be initialized using the init method.
@@ -755,7 +773,7 @@ interface BiometricManager {
755
773
  */
756
774
  requestAccess: (
757
775
  params: BiometricRequestAccessParams,
758
- callback?: (isAccessGranted: boolean) => void,
776
+ callback?: BiometricRequestAccessCallback,
759
777
  ) => BiometricManager;
760
778
  /**
761
779
  * A method that authenticates the user using biometrics according to the params
@@ -767,7 +785,7 @@ interface BiometricManager {
767
785
  */
768
786
  authenticate: (
769
787
  params: BiometricAuthenticateParams,
770
- callback?: (isAuthenticated: boolean, biometricToken?: string) => void,
788
+ callback?: BiometricAuthenticateCallback,
771
789
  ) => BiometricManager;
772
790
  /**
773
791
  * A method that updates the biometric token in secure storage on the device.
@@ -775,7 +793,10 @@ interface BiometricManager {
775
793
  * was passed, the callback function will be called and the first argument will be
776
794
  * a boolean indicating whether the token was updated.
777
795
  */
778
- updateBiometricToken: (token: string, callback?: (applied: boolean) => void) => BiometricManager;
796
+ updateBiometricToken: (
797
+ token: string,
798
+ callback?: BiometricUpdateBiometricTokenCallback,
799
+ ) => BiometricManager;
779
800
  /**
780
801
  * A method that opens the biometric access settings for bots. Useful when you
781
802
  * need to request biometrics access to users who haven't granted it yet.
@@ -786,6 +807,10 @@ interface BiometricManager {
786
807
  openSettings: () => BiometricManager;
787
808
  }
788
809
 
810
+ type BiometricRequestAccessCallback = (isAccessGranted: boolean) => void;
811
+ type BiometricAuthenticateCallback = (isAuthenticated: boolean, biometricToken?: string) => void;
812
+ type BiometricUpdateBiometricTokenCallback = (applied: boolean) => void;
813
+
789
814
  /**
790
815
  * This object describes the native popup for requesting permission to use biometrics.
791
816
  */
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/telegram-web-app",
3
- "version": "7.2.1",
3
+ "version": "7.3.0",
4
4
  "description": "TypeScript definitions for telegram-web-app",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/telegram-web-app",
6
6
  "license": "MIT",
@@ -30,6 +30,6 @@
30
30
  },
31
31
  "scripts": {},
32
32
  "dependencies": {},
33
- "typesPublisherContentHash": "e87c2922126e55e70715960da38494b6d0a54ec039165c4d5e8c15410bb27006",
34
- "typeScriptVersion": "4.7"
33
+ "typesPublisherContentHash": "454635b3bca8c32e7748437927a9e968f86ea42b27df2ebebc933218e84373fa",
34
+ "typeScriptVersion": "4.8"
35
35
  }