@types/telegram-web-app 7.10.1 → 9.0.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: Fri, 04 Oct 2024 17:07:25 GMT
11
+ * Last updated: Tue, 29 Jul 2025 15:04:17 GMT
12
12
  * Dependencies: none
13
13
 
14
14
  # Credits
@@ -1,12 +1,16 @@
1
- declare var Telegram: Telegram;
1
+ declare global {
2
+ interface Window {
3
+ Telegram: Telegram;
4
+ }
5
+ }
2
6
 
3
- type Color = string | false;
7
+ export type Color = string | false;
4
8
 
5
- interface Telegram {
9
+ export interface Telegram {
6
10
  WebApp: WebApp;
7
11
  }
8
12
 
9
- interface WebApp {
13
+ export interface WebApp {
10
14
  /**
11
15
  * A string with raw data transferred to the Web App, convenient for
12
16
  * validating data. WARNING: Validate data from this field before using it
@@ -36,6 +40,13 @@ interface WebApp {
36
40
  * An object containing the current theme settings used in the Telegram app.
37
41
  */
38
42
  themeParams: ThemeParams;
43
+ /**
44
+ * **Bot API 8.0+**
45
+ *
46
+ * True, if the Mini App is currently active.
47
+ * False, if the Mini App is minimized.
48
+ */
49
+ isActive: boolean;
39
50
  /**
40
51
  * True if the Web App is expanded to the maximum available height.
41
52
  * False, if the Web App occupies part of the screen and can be expanded to the
@@ -95,6 +106,25 @@ interface WebApp {
95
106
  * close the Web App. False, if the confirmation dialog is disabled.
96
107
  */
97
108
  isClosingConfirmationEnabled: boolean;
109
+ /**
110
+ * True, if the Mini App is currently being displayed in fullscreen mode.
111
+ */
112
+ isFullscreen: boolean;
113
+ /**
114
+ * True, if the Mini App’s orientation is currently locked.
115
+ * False, if orientation changes freely based on the device’s rotation.
116
+ */
117
+ isOrientationLocked: boolean;
118
+ /**
119
+ * An object representing the device's safe area insets,
120
+ * accounting for system UI elements like notches or navigation bars.
121
+ */
122
+ safeAreaInset: SafeAreaInset;
123
+ /**
124
+ * An object representing the safe area for displaying content within the app,
125
+ * free from overlapping Telegram UI elements.
126
+ */
127
+ contentSafeAreaInset: ContentSafeAreaInset;
98
128
  /**
99
129
  * An object for controlling the back button which can be displayed in the
100
130
  * header of the Web App in the Telegram interface.
@@ -127,20 +157,43 @@ interface WebApp {
127
157
  * An object for controlling biometrics on the device.
128
158
  */
129
159
  BiometricManager: BiometricManager;
160
+ /**
161
+ * An object for accessing device orientation data on the device.
162
+ */
163
+ Accelerometer: Accelerometer;
164
+ /**
165
+ * An object for accessing device orientation data on the device.
166
+ */
167
+ DeviceOrientation: DeviceOrientation;
168
+ /**
169
+ * An object for accessing gyroscope data on the device.
170
+ */
171
+ Gyroscope: Gyroscope;
172
+ /**
173
+ * An object for controlling location on the device.
174
+ */
175
+ LocationManager: LocationManager;
176
+ /**
177
+ * An object for storing and retrieving data from the device's local storage.
178
+ */
179
+ DeviceStorage: DeviceStorage;
180
+ /**
181
+ * An object for storing and retrieving data from the device's secure storage.
182
+ */
183
+ SecureStorage: SecureStorage;
130
184
  /**
131
185
  * Returns true if the user's app supports a version of the Bot API that is
132
186
  * equal to or higher than the version passed as the parameter.
133
187
  */
134
188
  isVersionAtLeast(version: string): boolean;
135
189
  /**
136
- * A method that sets the app header color in the `#RRGGBB` format. You can
137
- * also use keywords bg_color and secondary_bg_color.
190
+ * A method that sets the app header color in the `#RRGGBB` format.
191
+ * You can also use keywords bg_color and secondary_bg_color.
138
192
  */
139
- // string & {} prevents this from eagerly collapsing into just string
140
193
  setHeaderColor(color: "bg_color" | "secondary_bg_color" | (string & {})): void;
141
194
  /**
142
- * A method that sets the app background color in the `#RRGGBB` format or
143
- * you can use keywords bg_color, secondary_bg_color instead.
195
+ * A method that sets the app background color in the `#RRGGBB` format
196
+ * or you can use keywords bg_color, secondary_bg_color instead.
144
197
  */
145
198
  setBackgroundColor(color: "bg_color" | "secondary_bg_color" | "bottom_bar_bg_color" | (string & {})): void;
146
199
  /**
@@ -162,14 +215,18 @@ interface WebApp {
162
215
  * A method that sets the app event handler. Check the list of available
163
216
  * events.
164
217
  */
218
+ onEvent(eventType: "activated", eventHandler: ActivatedCallback): void;
219
+ onEvent(eventType: "deactivated", eventHandler: DeactivatedCallback): void;
165
220
  onEvent(eventType: "themeChanged", eventHandler: ThemeChangedCallback): void;
221
+ onEvent(eventType: "viewportChanged", eventHandler: ViewportChangedCallback): void;
222
+ onEvent(eventType: "safeAreaChanged", eventHandler: SafeAreaChangedChangedCallback): void;
223
+ onEvent(eventType: "contentSafeAreaChanged", eventHandler: ContentSafeAreaChangedCallback): void;
166
224
  onEvent(eventType: "mainButtonClicked", eventHandler: MainButtonClickedCallback): void;
167
225
  onEvent(eventType: "secondaryButtonClicked", eventHandler: SecondaryButtonClickedCallback): void;
168
226
  onEvent(eventType: "backButtonClicked", eventHandler: BackButtonClickedCallback): void;
169
227
  onEvent(eventType: "settingsButtonClicked", eventHandler: SettingsButtonClickedCallback): void;
170
- onEvent(eventType: "popupClosed", eventHandler: PopupClosedCallback): void;
171
- onEvent(eventType: "viewportChanged", eventHandler: ViewportChangedCallback): void;
172
228
  onEvent(eventType: "invoiceClosed", eventHandler: InvoiceClosedCallback): void;
229
+ onEvent(eventType: "popupClosed", eventHandler: PopupClosedCallback): void;
173
230
  onEvent(eventType: "qrTextReceived", eventHandler: QrTextReceivedCallback): void;
174
231
  onEvent(eventType: "scanQrPopupClosed", eventHandler: ScanQrPopupClosedCallback): void;
175
232
  onEvent(eventType: "clipboardTextReceived", eventHandler: ClipboardTextReceivedCallback): void;
@@ -178,15 +235,44 @@ interface WebApp {
178
235
  onEvent(eventType: "biometricManagerUpdated", eventHandler: BiometricManagerUpdatedCallback): void;
179
236
  onEvent(eventType: "biometricAuthRequested", eventHandler: BiometricAuthRequestedCallback): void;
180
237
  onEvent(eventType: "biometricTokenUpdated", eventHandler: BiometricTokenUpdatedCallback): void;
238
+ onEvent(eventType: "fullscreenChanged", eventHandler: FullscreenChangedCallback): void;
239
+ onEvent(eventType: "fullscreenFailed", eventHandler: FullscreenFailedCallback): void;
240
+ onEvent(eventType: "homeScreenAdded", eventHandler: HomeScreenAddedCallback): void;
241
+ onEvent(eventType: "homeScreenChecked", eventHandler: HomeScreenCheckedCallback): void;
242
+ onEvent(eventType: "accelerometerStarted", eventHandler: AccelerometerStartedCallback): void;
243
+ onEvent(eventType: "accelerometerStopped", eventHandler: AccelerometerStoppedCallback): void;
244
+ onEvent(eventType: "accelerometerChanged", eventHandler: AccelerometerChangedCallback): void;
245
+ onEvent(eventType: "accelerometerFailed", eventHandler: AccelerometerFailedCallback): void;
246
+ onEvent(eventType: "deviceOrientationStarted", eventHandler: DeviceOrientationStartedCallback): void;
247
+ onEvent(eventType: "deviceOrientationStopped", eventHandler: DeviceOrientationStoppedCallback): void;
248
+ onEvent(eventType: "deviceOrientationChanged", eventHandler: DeviceOrientationChangedCallback): void;
249
+ onEvent(eventType: "deviceOrientationFailed", eventHandler: DeviceOrientationFailedCallback): void;
250
+ onEvent(eventType: "gyroscopeStarted", eventHandler: GyroscopeStartedCallback): void;
251
+ onEvent(eventType: "gyroscopeStopped", eventHandler: GyroscopeStoppedCallback): void;
252
+ onEvent(eventType: "gyroscopeChanged", eventHandler: GyroscopeChangedCallback): void;
253
+ onEvent(eventType: "gyroscopeFailed", eventHandler: GyroscopeFailedCallback): void;
254
+ onEvent(eventType: "locationManagerUpdated", eventHandler: LocationManagerUpdatedCallback): void;
255
+ onEvent(eventType: "locationRequested", eventHandler: LocationRequestedCallback): void;
256
+ onEvent(eventType: "shareMessageSent", eventHandler: ShareMessageSentCallback): void;
257
+ onEvent(eventType: "shareMessageFailed", eventHandler: ShareMessageFailedCallback): void;
258
+ onEvent(eventType: "emojiStatusSet", eventHandler: EmojiStatusSetCallback): void;
259
+ onEvent(eventType: "emojiStatusFailed", eventHandler: EmojiStatusFailedCallback): void;
260
+ onEvent(eventType: "emojiStatusAccessRequested", eventHandler: EmojiStatusAccessRequestedCallback): void;
261
+ onEvent(eventType: "fileDownloadRequested", eventHandler: FileDownloadRequestedCallback): void;
181
262
 
182
263
  /** A method that deletes a previously set event handler. */
264
+ offEvent(eventType: "activated", eventHandler: ActivatedCallback): void;
265
+ offEvent(eventType: "deactivated", eventHandler: DeactivatedCallback): void;
183
266
  offEvent(eventType: "themeChanged", eventHandler: ThemeChangedCallback): void;
267
+ offEvent(eventType: "viewportChanged", eventHandler: ViewportChangedCallback): void;
268
+ offEvent(eventType: "safeAreaChanged", eventHandler: SafeAreaChangedChangedCallback): void;
269
+ offEvent(eventType: "contentSafeAreaChanged", eventHandler: ContentSafeAreaChangedCallback): void;
184
270
  offEvent(eventType: "mainButtonClicked", eventHandler: MainButtonClickedCallback): void;
271
+ offEvent(eventType: "secondaryButtonClicked", eventHandler: SecondaryButtonClickedCallback): void;
185
272
  offEvent(eventType: "backButtonClicked", eventHandler: BackButtonClickedCallback): void;
186
273
  offEvent(eventType: "settingsButtonClicked", eventHandler: SettingsButtonClickedCallback): void;
187
- offEvent(eventType: "popupClosed", eventHandler: PopupClosedCallback): void;
188
- offEvent(eventType: "viewportChanged", eventHandler: ViewportChangedCallback): void;
189
274
  offEvent(eventType: "invoiceClosed", eventHandler: InvoiceClosedCallback): void;
275
+ offEvent(eventType: "popupClosed", eventHandler: PopupClosedCallback): void;
190
276
  offEvent(eventType: "qrTextReceived", eventHandler: QrTextReceivedCallback): void;
191
277
  offEvent(eventType: "scanQrPopupClosed", eventHandler: ScanQrPopupClosedCallback): void;
192
278
  offEvent(eventType: "clipboardTextReceived", eventHandler: ClipboardTextReceivedCallback): void;
@@ -195,6 +281,30 @@ interface WebApp {
195
281
  offEvent(eventType: "biometricManagerUpdated", eventHandler: BiometricManagerUpdatedCallback): void;
196
282
  offEvent(eventType: "biometricAuthRequested", eventHandler: BiometricAuthRequestedCallback): void;
197
283
  offEvent(eventType: "biometricTokenUpdated", eventHandler: BiometricTokenUpdatedCallback): void;
284
+ offEvent(eventType: "fullscreenChanged", eventHandler: FullscreenChangedCallback): void;
285
+ offEvent(eventType: "fullscreenFailed", eventHandler: FullscreenFailedCallback): void;
286
+ offEvent(eventType: "homeScreenAdded", eventHandler: HomeScreenAddedCallback): void;
287
+ offEvent(eventType: "homeScreenChecked", eventHandler: HomeScreenCheckedCallback): void;
288
+ offEvent(eventType: "accelerometerStarted", eventHandler: AccelerometerStartedCallback): void;
289
+ offEvent(eventType: "accelerometerStopped", eventHandler: AccelerometerStoppedCallback): void;
290
+ offEvent(eventType: "accelerometerChanged", eventHandler: AccelerometerChangedCallback): void;
291
+ offEvent(eventType: "accelerometerFailed", eventHandler: AccelerometerFailedCallback): void;
292
+ offEvent(eventType: "deviceOrientationStarted", eventHandler: DeviceOrientationStartedCallback): void;
293
+ offEvent(eventType: "deviceOrientationStopped", eventHandler: DeviceOrientationStoppedCallback): void;
294
+ offEvent(eventType: "deviceOrientationChanged", eventHandler: DeviceOrientationChangedCallback): void;
295
+ offEvent(eventType: "deviceOrientationFailed", eventHandler: DeviceOrientationFailedCallback): void;
296
+ offEvent(eventType: "gyroscopeStarted", eventHandler: GyroscopeStartedCallback): void;
297
+ offEvent(eventType: "gyroscopeStopped", eventHandler: GyroscopeStoppedCallback): void;
298
+ offEvent(eventType: "gyroscopeChanged", eventHandler: GyroscopeChangedCallback): void;
299
+ offEvent(eventType: "gyroscopeFailed", eventHandler: GyroscopeFailedCallback): void;
300
+ offEvent(eventType: "locationManagerUpdated", eventHandler: LocationManagerUpdatedCallback): void;
301
+ offEvent(eventType: "locationRequested", eventHandler: LocationRequestedCallback): void;
302
+ offEvent(eventType: "shareMessageSent", eventHandler: ShareMessageSentCallback): void;
303
+ offEvent(eventType: "shareMessageFailed", eventHandler: ShareMessageFailedCallback): void;
304
+ offEvent(eventType: "emojiStatusSet", eventHandler: EmojiStatusSetCallback): void;
305
+ offEvent(eventType: "emojiStatusFailed", eventHandler: EmojiStatusFailedCallback): void;
306
+ offEvent(eventType: "emojiStatusAccessRequested", eventHandler: EmojiStatusAccessRequestedCallback): void;
307
+ offEvent(eventType: "fileDownloadRequested", eventHandler: FileDownloadRequestedCallback): void;
198
308
 
199
309
  /**
200
310
  * A method used to send data to the bot. When this method is called, a
@@ -239,10 +349,7 @@ interface WebApp {
239
349
  * optional callback parameter was passed, the callback function will be
240
350
  * called and the invoice status will be passed as the first argument.
241
351
  */
242
- openInvoice(
243
- url: string,
244
- callback: (status: "paid" | "cancelled" | "failed" | "pending") => void,
245
- ): void;
352
+ openInvoice(url: string, callback: (status: "paid" | "cancelled" | "failed" | "pending") => void): void;
246
353
  /**
247
354
  * A method that shows a native popup described by the params argument of
248
355
  * the type PopupParams. The Web App will receive the event popupClosed when
@@ -288,10 +395,52 @@ interface WebApp {
288
395
  * the type StoryShareParams describes additional sharing settings. */
289
396
  shareToStory(media_url: string, params?: StoryShareParams): void;
290
397
  /**
291
- * A method that requests text from the clipboard. The Web App will receive
292
- * the event clipboardTextReceived. If an optional callback parameter was
293
- * passed, the callback function will be called and the text from the
294
- * clipboard will be passed as the first argument.
398
+ * **Bot API 8.0+**
399
+ *
400
+ * A method that opens a dialog allowing the user to share a message provided by the bot.
401
+ * If an optional callback parameter is provided,
402
+ * the callback function will be called with a boolean as the first argument,
403
+ * indicating whether the message was successfully sent.
404
+ */
405
+ shareMessage(msg_id: number, callback?: (success: boolean) => void): void;
406
+ /**
407
+ * **Bot API 8.0+**
408
+ *
409
+ * A method that opens a dialog allowing the user to set the specified custom emoji as their status.
410
+ * An optional params argument of type EmojiStatusParams specifies additional settings,such as duration.
411
+ * If an optional callback parameter is provided,
412
+ * the callback function will be called with a boolean as the first argument,
413
+ * indicating whether the status was set.
414
+ *
415
+ * Note: this method opens a native dialog and cannot be used to set the emoji status without manual user interaction.
416
+ * For fully programmatic changes, you should instead use the Bot API method setUserEmojiStatus
417
+ * after obtaining authorization to do so via the Mini App method requestEmojiStatusAccess.
418
+ */
419
+ setEmojiStatus(custom_emoji_id: string, params?: EmojiStatusParams, callback?: (success: boolean) => void): void;
420
+ /**
421
+ * **Bot API 8.0+**
422
+ *
423
+ * A method that shows a native popup requesting permission for the bot to manage user's emoji status.
424
+ * If an optional callback parameter was passed,
425
+ * the callback function will be called when the popup is closed
426
+ * and the first argument will be a boolean indicating whether the user granted this access.
427
+ */
428
+ requestEmojiStatusAccess(callback?: (success: boolean) => void): void;
429
+ /**
430
+ * **Bot API 8.0+**
431
+ *
432
+ * A method that displays a native popup prompting the user to download a file
433
+ * specified by the params argument of type DownloadFileParams.
434
+ * If an optional callback parameter is provided,
435
+ * the callback function will be called when the popup is closed,
436
+ * with the first argument as a boolean indicating whether the user accepted the download request.
437
+ */
438
+ downloadFile(params: DownloadFileParams, callback?: (success: boolean) => void): void;
439
+ /**
440
+ * A method that requests text from the clipboard.
441
+ * The Web App will receive the event clipboardTextReceived.
442
+ * If an optional callback parameter was passed,
443
+ * the callback function will be called and the text from the clipboard will be passed as the first argument.
295
444
  *
296
445
  * Note: this method can be called only for Web Apps launched from the
297
446
  * attachment menu and only in response to a user interaction with the Web
@@ -318,9 +467,7 @@ interface WebApp {
318
467
  * number. The second argument, contingent upon success, will be an object
319
468
  * detailing the shared contact information or a cancellation response.
320
469
  */
321
- requestContact(
322
- callback?: (success: boolean, response: RequestContactResponse) => void,
323
- ): void;
470
+ requestContact(callback?: (success: boolean, response: RequestContactResponse) => void): void;
324
471
  /**
325
472
  * A method that informs the Telegram app that the Web App is ready to be
326
473
  * displayed. It is recommended to call this method as early as possible, as
@@ -346,43 +493,146 @@ interface WebApp {
346
493
  */
347
494
  isVerticalSwipesEnabled: boolean;
348
495
  /**
349
- * **Bot API 7.7+** A method that enables vertical swipes to close or
350
- * minimize the Mini App. For user convenience, it is recommended to always
351
- * enable swipes unless they conflict with the Mini App's own gestures.
496
+ * **Bot API 7.7+**
497
+ * A method that enables vertical swipes to close or minimize the Mini App.
498
+ * For user convenience, it is recommended to always enable swipes unless they conflict
499
+ * with the Mini App's own gestures.
352
500
  */
353
501
  enableVerticalSwipes(): void;
354
502
  /**
355
- * **Bot API 7.7+** A method that disables vertical swipes to close or
356
- * minimize the Mini App. This method is useful if your Mini App uses swipe
357
- * gestures that may conflict with the gestures for minimizing and closing
358
- * the app.
503
+ * **Bot API 7.7+**
504
+ * A method that disables vertical swipes to close or minimize the Mini App.
505
+ * This method is useful if your Mini App uses swipe gestures that may conflict
506
+ * with the gestures for minimizing and closing the app.
359
507
  */
360
508
  disableVerticalSwipes(): void;
509
+ /**
510
+ * **Bot API 8.0+**
511
+ *
512
+ * A method that requests opening the Mini App in fullscreen mode.
513
+ * Although the header is transparent in fullscreen mode,
514
+ * it is recommended that the Mini App sets the header color using the setHeaderColor method.
515
+ * This color helps determine a contrasting color for the status bar and other UI controls.
516
+ */
517
+ requestFullscreen(): void;
518
+ /**
519
+ * **Bot API 8.0+**
520
+ *
521
+ * A method that requests exiting fullscreen mode.
522
+ */
523
+ exitFullscreen(): void;
524
+ /**
525
+ * **Bot API 8.0+**
526
+ *
527
+ * A method that locks the Mini App’s orientation to its current mode (either portrait or landscape).
528
+ * Once locked, the orientation remains fixed, regardless of device rotation.
529
+ * This is useful if a stable orientation is needed during specific interactions.
530
+ */
531
+ lockOrientation(): void;
532
+ /**
533
+ * **Bot API 8.0+**
534
+ *
535
+ * A method that unlocks the Mini App’s orientation, allowing it to follow the device's rotation freely.
536
+ * Use this to restore automatic orientation adjustments based on the device orientation.
537
+ */
538
+ unlockOrientation(): void;
539
+ /**
540
+ * **Bot API 8.0+**
541
+ *
542
+ * A method that prompts the user to add the Mini App to the home screen.
543
+ * After successfully adding the icon, the homeScreenAdded event will be triggered if supported by the device.
544
+ * Note that if the device cannot determine the installation status,
545
+ * the event may not be received even if the icon has been added.
546
+ */
547
+ addToHomeScreen(): void;
548
+ /**
549
+ * **Bot API 8.0+**
550
+ *
551
+ * A method that checks if adding to the home screen is supported and if the Mini App has already been added.
552
+ * If an optional callback parameter is provided,
553
+ * the callback function will be called with a single argument status,
554
+ * which is a string indicating the home screen status.
555
+ */
556
+ checkHomeScreenStatus(callback?: (status: "unsupported" | "unknown" | "added" | "missed") => void): void;
361
557
  }
362
558
 
363
- type ThemeChangedCallback = () => void;
364
- type ViewportChangedCallback = (eventData: { isStateStable: boolean }) => void;
365
- type MainButtonClickedCallback = () => void;
366
- type SecondaryButtonClickedCallback = () => void;
367
- type BackButtonClickedCallback = () => void;
368
- type SettingsButtonClickedCallback = () => void;
369
- type InvoiceClosedCallback = (eventData: { url: string; status: "paid" | "cancelled" | "failed" | "pending" }) => void;
370
- type PopupClosedCallback = (eventData: { button_id: string | null }) => void;
371
- type QrTextReceivedCallback = (eventData: { data: string }) => void;
372
- type ScanQrPopupClosedCallback = () => void;
373
- type ClipboardTextReceivedCallback = (eventData: { data: string | null }) => void;
374
- type WriteAccessRequestedCallback = (eventData: { status: "allowed" | "cancelled" }) => void;
375
- type ContactRequestedCallback = (eventData: RequestContactResponse) => void;
376
- type BiometricManagerUpdatedCallback = () => void;
377
- type BiometricAuthRequestedCallback = (eventData: { isAuthenticated: boolean; biometricToken?: string }) => void;
378
- type BiometricTokenUpdatedCallback = (eventData: { isUpdated: boolean }) => void;
559
+ export type ActivatedCallback = () => void;
560
+ export type DeactivatedCallback = () => void;
561
+ export type ThemeChangedCallback = () => void;
562
+ export type ViewportChangedCallback = (eventData: { isStateStable: boolean }) => void;
563
+ export type SafeAreaChangedChangedCallback = () => void;
564
+ export type ContentSafeAreaChangedCallback = () => void;
565
+ export type MainButtonClickedCallback = () => void;
566
+ export type SecondaryButtonClickedCallback = () => void;
567
+ export type BackButtonClickedCallback = () => void;
568
+ export type SettingsButtonClickedCallback = () => void;
569
+ export type InvoiceClosedCallback = (eventData: {
570
+ url: string;
571
+ status: "paid" | "cancelled" | "failed" | "pending";
572
+ }) => void;
573
+ export type PopupClosedCallback = (eventData: { button_id: string | null }) => void;
574
+ export type QrTextReceivedCallback = (eventData: { data: string }) => void;
575
+ export type ScanQrPopupClosedCallback = () => void;
576
+ export type ClipboardTextReceivedCallback = (eventData: { data: string | null }) => void;
577
+ export type WriteAccessRequestedCallback = (eventData: {
578
+ status: "allowed" | "cancelled";
579
+ }) => void;
580
+ export type ContactRequestedCallback = (eventData: RequestContactResponse) => void;
581
+ export type BiometricManagerUpdatedCallback = () => void;
582
+ export type BiometricAuthRequestedCallback = (eventData: {
583
+ isAuthenticated: boolean;
584
+ biometricToken?: string;
585
+ }) => void;
586
+ export type BiometricTokenUpdatedCallback = (eventData: { isUpdated: boolean }) => void;
587
+ export type FullscreenChangedCallback = () => void;
588
+ export type FullscreenFailedCallback = (eventData: {
589
+ error: "UNSUPPORTED" | "ALREADY_FULLSCREEN";
590
+ }) => void;
591
+ export type HomeScreenAddedCallback = () => void;
592
+ export type HomeScreenCheckedCallback = (eventData: {
593
+ status: "unsupported" | "unknown" | "added" | "missed";
594
+ }) => void;
595
+ export type AccelerometerStartedCallback = () => void;
596
+ export type AccelerometerStoppedCallback = () => void;
597
+ export type AccelerometerChangedCallback = () => void;
598
+ export type AccelerometerFailedCallback = (eventData: { error: "UNSUPPORTED" }) => void;
599
+ export type DeviceOrientationStartedCallback = () => void;
600
+ export type DeviceOrientationStoppedCallback = () => void;
601
+ export type DeviceOrientationChangedCallback = () => void;
602
+ export type DeviceOrientationFailedCallback = (eventData: { error: "UNSUPPORTED" }) => void;
603
+ export type GyroscopeStartedCallback = () => void;
604
+ export type GyroscopeStoppedCallback = () => void;
605
+ export type GyroscopeChangedCallback = () => void;
606
+ export type GyroscopeFailedCallback = (eventData: { error: "UNSUPPORTED" }) => void;
607
+ export type LocationManagerUpdatedCallback = () => void;
608
+ export type LocationRequestedCallback = (eventData: { locationData: LocationData }) => void;
609
+ export type ShareMessageSentCallback = () => void;
610
+ export type ShareMessageFailedCallback = (eventData: {
611
+ error: "UNSUPPORTED" | "MESSAGE_EXPIRED" | "MESSAGE_SEND_FAILED" | "USER_DECLINED" | "UNKNOWN_ERROR";
612
+ }) => void;
613
+ export type EmojiStatusSetCallback = () => void;
614
+ export type EmojiStatusFailedCallback = (eventData: {
615
+ error:
616
+ | "UNSUPPORTED"
617
+ | "SUGGESTED_EMOJI_INVALID"
618
+ | "DURATION_INVALID"
619
+ | "USER_DECLINED"
620
+ | "SERVER_ERROR"
621
+ | "UNKNOWN_ERROR";
622
+ }) => void;
623
+ export type EmojiStatusAccessRequestedCallback = (eventData: {
624
+ status: "allowed" | "cancelled";
625
+ }) => void;
626
+ export type FileDownloadRequestedCallback = (eventData: {
627
+ status: "downloading" | "cancelled";
628
+ }) => void;
379
629
 
380
630
  /**
381
631
  * Web Apps can adjust the appearance of the interface to match the Telegram
382
632
  * user's app in real time. This object contains the user's current theme
383
633
  * settings:
384
634
  */
385
- interface ThemeParams {
635
+ export interface ThemeParams {
386
636
  /**
387
637
  * Background color in the `#RRGGBB` format.
388
638
  * Also available as the CSS variable `var(--tg-theme-bg-color)`.
@@ -414,48 +664,66 @@ interface ThemeParams {
414
664
  */
415
665
  button_text_color?: string;
416
666
  /**
417
- * **Bot API 6.1+** Secondary background color in the `#RRGGBB` format.
667
+ * **Bot API 6.1+**
668
+ *
669
+ * Secondary background color in the `#RRGGBB` format.
418
670
  * Also available as the CSS variable `var(--tg-theme-secondary-bg-color)`.
419
671
  */
420
672
  secondary_bg_color?: string;
421
673
  /**
422
- * **Bot API 7.0+** Header background color in the `#RRGGBB` format.
674
+ * **Bot API 7.0+**
675
+ *
676
+ * Header background color in the `#RRGGBB` format.
423
677
  * Also available as the CSS variable `var(--tg-theme-header-bg-color)`.
424
678
  */
425
679
  header_bg_color?: string;
426
680
  /**
427
- * **Bot API 7.10+** Bottom background color in the #RRGGBB format.
681
+ * **Bot API 7.10+**
682
+ *
683
+ * Bottom background color in the #RRGGBB format.
428
684
  * Also available as the CSS variable var(--tg-theme-bottom-bar-bg-color).
429
685
  */
430
686
  bottom_bar_bg_color?: string;
431
687
  /**
432
- * **Bot API 7.0+** Accent text color in the `#RRGGBB` format.
688
+ * **Bot API 7.0+**
689
+ *
690
+ * Accent text color in the `#RRGGBB` format.
433
691
  * Also available as the CSS variable `var(--tg-theme-accent-text-color)`.
434
692
  */
435
693
  accent_text_color?: string;
436
694
  /**
437
- * **Bot API 7.0+** Background color for the section in the `#RRGGBB` format.
695
+ * **Bot API 7.0+**
696
+ *
697
+ * Background color for the section in the `#RRGGBB` format.
438
698
  * It is recommended to use this in conjunction with *secondary_bg_color*.
439
699
  * Also available as the CSS variable `var(--tg-theme-section-bg-color)`.
440
700
  */
441
701
  section_bg_color?: string;
442
702
  /**
443
- * **Bot API 7.0+** Header text color for the section in the `#RRGGBB` format.
703
+ * **Bot API 7.0+**
704
+ *
705
+ * Header text color for the section in the `#RRGGBB` format.
444
706
  * Also available as the CSS variable `var(--tg-theme-section-header-text-color)`.
445
707
  */
446
708
  section_header_text_color?: `#${string}`;
447
709
  /**
448
- * **Bot API 7.6+** Section separator color in the `#RRGGBB` format.
710
+ * **Bot API 7.6+**
711
+ *
712
+ * Section separator color in the `#RRGGBB` format.
449
713
  * Also available as the CSS variable `var(--tg-theme-section-separator-color)`.
450
714
  */
451
715
  section_separator_color?: string;
452
716
  /**
453
- * **Bot API 7.0+** Subtitle text color in the `#RRGGBB` format.
717
+ * **Bot API 7.0+**
718
+ *
719
+ * Subtitle text color in the `#RRGGBB` format.
454
720
  * Also available as the CSS variable `var(--tg-theme-subtitle-text-color)`.
455
721
  */
456
722
  subtitle_text_color?: string;
457
723
  /**
458
- * **Bot API 7.0+** Text color for destructive actions in the `#RRGGBB` format.
724
+ * **Bot API 7.0+**
725
+ *
726
+ * Text color for destructive actions in the `#RRGGBB` format.
459
727
  * Also available as the CSS variable `var(--tg-theme-destructive-text-color)`.
460
728
  */
461
729
  destructive_text_color?: string;
@@ -464,7 +732,7 @@ interface ThemeParams {
464
732
  /**
465
733
  * This object describes the native popup.
466
734
  */
467
- interface PopupParams {
735
+ export interface PopupParams {
468
736
  /**
469
737
  * The text to be displayed in the popup title, 0-64 characters.
470
738
  */
@@ -483,12 +751,11 @@ interface PopupParams {
483
751
  /**
484
752
  * This object describes the native popup button.
485
753
  */
486
- type PopupButton =
754
+ export type PopupButton =
487
755
  & {
488
756
  /**
489
- * Identifier of the button, 0-64 characters. Set to empty string by
490
- * default. If the button is pressed, its id is returned in the callback
491
- * and the popupClosed event.
757
+ * Identifier of the button, 0-64 characters. Set to empty string by default.
758
+ * If the button is pressed, its id is returned in the callback and the popupClosed event.
492
759
  */
493
760
  id?: string;
494
761
  /**
@@ -498,8 +765,7 @@ type PopupButton =
498
765
  * - `ok`, a button with the localized text “OK”,
499
766
  * - `close`, a button with the localized text “Close”,
500
767
  * - `cancel`, a button with the localized text “Cancel”,
501
- * - `destructive`, a button with a style that indicates a destructive
502
- * action (e.g. “Remove”, “Delete”, etc.).
768
+ * - `destructive`, a button with a style that indicates a destructive action (e.g. “Remove”, “Delete”, etc.).
503
769
  */
504
770
  type?: "default" | "ok" | "close" | "cancel" | "destructive";
505
771
  /**
@@ -523,7 +789,7 @@ type PopupButton =
523
789
  * This object controls the back button, which can be displayed in the header of
524
790
  * the Web App in the Telegram interface.
525
791
  */
526
- interface BackButton {
792
+ export interface BackButton {
527
793
  /**
528
794
  * Shows whether the button is visible. Set to false by default.
529
795
  */
@@ -552,7 +818,7 @@ interface BackButton {
552
818
  * This object controls the main button, which is displayed at the bottom of the
553
819
  * Web App in the Telegram interface.
554
820
  */
555
- interface BottomButton {
821
+ export interface BottomButton {
556
822
  /** Current button text. Set to CONTINUE by default. */
557
823
  text: string;
558
824
  /** Current button color. Set to themeParams.button_color by default. */
@@ -622,7 +888,7 @@ interface BottomButton {
622
888
  setParams(params: MainButtonParams): BottomButton;
623
889
  }
624
890
 
625
- interface MainButtonParams {
891
+ export interface MainButtonParams {
626
892
  /** button text */
627
893
  text?: string;
628
894
  /** button color */
@@ -643,30 +909,35 @@ interface MainButtonParams {
643
909
  * This object controls the Settings item in the context menu of the Mini App in
644
910
  * the Telegram interface.
645
911
  */
646
- interface SettingsButton {
912
+ export interface SettingsButton {
647
913
  /**
648
914
  * Shows whether the context menu item is visible. Set to false by default.
649
915
  */
650
916
  isVisible: boolean;
651
917
  /**
652
- * **Bot API 7.0+** A method that sets the press event handler for the
653
- * Settings item in the context menu. An alias for
654
- * `Telegram.WebApp.onEvent('settingsButtonClicked', callback)`
918
+ * **Bot API 7.0+**
919
+ *
920
+ * A method that sets the press event handler for the Settings item in the context menu.
921
+ * An alias for `Telegram.WebApp.onEvent('settingsButtonClicked', callback)`
655
922
  */
656
923
  onClick(callback: () => void): SettingsButton;
657
924
  /**
658
- * **Bot API 7.0+** A method that removes the press event handler from the
659
- * Settings item in the context menu. An alias for
660
- * `Telegram.WebApp.offEvent('settingsButtonClicked', callback)`
925
+ * **Bot API 7.0+**
926
+ *
927
+ * A method that removes the press event handler from the Settings item in the context menu.
928
+ * An alias for `Telegram.WebApp.offEvent('settingsButtonClicked', callback)`
661
929
  */
662
930
  offClick(callback: () => void): SettingsButton;
663
931
  /**
664
- * **Bot API 7.0+** A method to make the Settings item in the context menu
665
- * visible.
932
+ * **Bot API 7.0+**
933
+ *
934
+ * A method to make the Settings item in the context menu visible.
666
935
  */
667
936
  show(): SettingsButton;
668
937
  /**
669
- * **Bot API 7.0+** A method to hide the Settings item in the context menu.
938
+ * **Bot API 7.0+**
939
+ *
940
+ * A method to hide the Settings item in the context menu.
670
941
  */
671
942
  hide(): SettingsButton;
672
943
  }
@@ -674,7 +945,7 @@ interface SettingsButton {
674
945
  /**
675
946
  * This object controls haptic feedback.
676
947
  */
677
- interface HapticFeedback {
948
+ export interface HapticFeedback {
678
949
  /**
679
950
  * A method tells that an impact occurred. The Telegram app may play the
680
951
  * appropriate haptics based on style value passed. Style can be one of
@@ -706,7 +977,7 @@ interface HapticFeedback {
706
977
  selectionChanged(): void;
707
978
  }
708
979
 
709
- interface CloudStorage {
980
+ export interface CloudStorage {
710
981
  /**
711
982
  * A method that stores a value in the cloud storage using the specified
712
983
  * key.
@@ -783,18 +1054,18 @@ interface CloudStorage {
783
1054
  getKeys(callback?: CloudStorageGetKeysCallback): CloudStorage;
784
1055
  }
785
1056
 
786
- type CloudStorageSetItemCallback = (error: string | null, success: null | true) => void;
787
- type CloudStorageGetItemCallback = (error: string | null, value: null | string) => void;
788
- type CloudStorageGetItemsCallback = (error: string | null, values: null | Record<string, string>) => void;
789
- type CloudStorageRemoveItemCallback = (error: string | null, success: null | true) => void;
790
- type CloudStorageRemoveItemsCallback = (error: string | null, success: null | true) => void;
791
- type CloudStorageGetKeysCallback = (error: string | null, keys: null | string[]) => void;
1057
+ export type CloudStorageSetItemCallback = (error: string | null, success: null | true) => void;
1058
+ export type CloudStorageGetItemCallback = (error: string | null, value: null | string) => void;
1059
+ export type CloudStorageGetItemsCallback = (error: string | null, values: null | Record<string, string>) => void;
1060
+ export type CloudStorageRemoveItemCallback = (error: string | null, success: null | true) => void;
1061
+ export type CloudStorageRemoveItemsCallback = (error: string | null, success: null | true) => void;
1062
+ export type CloudStorageGetKeysCallback = (error: string | null, keys: null | string[]) => void;
792
1063
 
793
1064
  /**
794
1065
  * This object controls biometrics on the device. Before the first use of this
795
1066
  * object, it needs to be initialized using the init method.
796
1067
  */
797
- interface BiometricManager {
1068
+ export interface BiometricManager {
798
1069
  /**
799
1070
  * Shows whether biometrics object is initialized.
800
1071
  */
@@ -855,21 +1126,15 @@ interface BiometricManager {
855
1126
  *
856
1127
  * If so, the second argument will be a biometric token.
857
1128
  */
858
- authenticate: (
859
- params: BiometricAuthenticateParams,
860
- callback?: BiometricAuthenticateCallback,
861
- ) => BiometricManager;
1129
+ authenticate: (params: BiometricAuthenticateParams, callback?: BiometricAuthenticateCallback) => BiometricManager;
862
1130
  /**
863
- * A method that updates the biometric token in secure storage on the
864
- * device. To remove the token, pass an empty string. If an optional
865
- * callback parameter was passed, the callback function will be called and
866
- * the first argument will be a boolean indicating whether the token was
867
- * updated.
1131
+ * A method that updates the biometric token in secure storage on the device.
1132
+ * To remove the token, pass an empty string.
1133
+ * If an optional callback parameter was passed,
1134
+ * the callback function will be called
1135
+ * and the first argument will be a boolean indicating whether the token was updated.
868
1136
  */
869
- updateBiometricToken: (
870
- token: string,
871
- callback?: BiometricUpdateBiometricTokenCallback,
872
- ) => BiometricManager;
1137
+ updateBiometricToken: (token: string, callback?: (success: boolean) => void) => BiometricManager;
873
1138
  /**
874
1139
  * A method that opens the biometric access settings for bots. Useful when
875
1140
  * you need to request biometrics access to users who haven't granted it
@@ -882,15 +1147,14 @@ interface BiometricManager {
882
1147
  openSettings: () => BiometricManager;
883
1148
  }
884
1149
 
885
- type BiometricRequestAccessCallback = (isAccessGranted: boolean) => void;
886
- type BiometricAuthenticateCallback = (isAuthenticated: boolean, biometricToken?: string) => void;
887
- type BiometricUpdateBiometricTokenCallback = (applied: boolean) => void;
1150
+ export type BiometricRequestAccessCallback = (isAccessGranted: boolean) => void;
1151
+ export type BiometricAuthenticateCallback = (isAuthenticated: boolean, biometricToken?: string) => void;
888
1152
 
889
1153
  /**
890
1154
  * This object describes the native popup for requesting permission to use
891
1155
  * biometrics.
892
1156
  */
893
- interface BiometricRequestAccessParams {
1157
+ export interface BiometricRequestAccessParams {
894
1158
  /**
895
1159
  * The text to be displayed to a user in the popup describing why the bot
896
1160
  * needs access to biometrics, 0-128 characters.
@@ -902,7 +1166,7 @@ interface BiometricRequestAccessParams {
902
1166
  * This object describes the native popup for authenticating the user using
903
1167
  * biometrics.
904
1168
  */
905
- interface BiometricAuthenticateParams {
1169
+ export interface BiometricAuthenticateParams {
906
1170
  /**
907
1171
  * The text to be displayed to a user in the popup describing why you are
908
1172
  * asking them to authenticate and what action you will be taking based on
@@ -915,7 +1179,7 @@ interface BiometricAuthenticateParams {
915
1179
  * This object contains data that is transferred to the Web App when it is
916
1180
  * opened. It is empty if the Web App was launched from a keyboard button.
917
1181
  */
918
- interface WebAppInitData {
1182
+ export interface WebAppInitData {
919
1183
  /**
920
1184
  * A unique identifier for the Web App session, required for sending
921
1185
  * messages via the answerWebAppQuery method.
@@ -970,7 +1234,7 @@ interface WebAppInitData {
970
1234
  }
971
1235
 
972
1236
  /** This object contains the data of the Web App user. */
973
- interface WebAppUser {
1237
+ export interface WebAppUser {
974
1238
  /**
975
1239
  * A unique identifier for the user or bot. This number may have more than
976
1240
  * 32 significant bits and some programming languages may have
@@ -1005,7 +1269,7 @@ interface WebAppUser {
1005
1269
  /**
1006
1270
  * This object represents a chat.
1007
1271
  */
1008
- interface WebAppChat {
1272
+ export interface WebAppChat {
1009
1273
  /**
1010
1274
  * Unique identifier for this chat. This number may have more than 32
1011
1275
  * significant bits and some programming languages may have
@@ -1035,7 +1299,7 @@ interface WebAppChat {
1035
1299
  /**
1036
1300
  * This object describes the native popup for scanning QR codes.
1037
1301
  */
1038
- interface ScanQrPopupParams {
1302
+ export interface ScanQrPopupParams {
1039
1303
  /**
1040
1304
  * The text to be displayed under the 'Scan QR' heading, 0-64 characters.
1041
1305
  */
@@ -1046,7 +1310,7 @@ interface ScanQrPopupParams {
1046
1310
  * This object describes contact information shared when requestContact was
1047
1311
  * approved by the user.
1048
1312
  */
1049
- interface RequestContactResponseSent {
1313
+ export interface RequestContactResponseSent {
1050
1314
  /** Status 'sent' indicates that contact information has been shared. */
1051
1315
  status: "sent";
1052
1316
  /** A status message or result as a string. */
@@ -1076,17 +1340,17 @@ interface RequestContactResponseSent {
1076
1340
  /**
1077
1341
  * This object only contains a status to indicate the cancellation.
1078
1342
  */
1079
- interface RequestContactResponseCancelled {
1343
+ export interface RequestContactResponseCancelled {
1080
1344
  /** Status 'cancelled', indicates that user cancelled the contact share
1081
1345
  * request. */
1082
1346
  status: "cancelled";
1083
1347
  }
1084
1348
 
1085
- type RequestContactResponse = RequestContactResponseSent | RequestContactResponseCancelled;
1349
+ export type RequestContactResponse = RequestContactResponseSent | RequestContactResponseCancelled;
1086
1350
 
1087
1351
  /** This object describes additional sharing settings for the native story
1088
1352
  * editor. */
1089
- interface StoryShareParams {
1353
+ export interface StoryShareParams {
1090
1354
  /** The caption to be added to the media, 0-200 characters for regular users
1091
1355
  * and 0-2048 characters for premium subscribers. */
1092
1356
  text?: string;
@@ -1096,9 +1360,412 @@ interface StoryShareParams {
1096
1360
  }
1097
1361
 
1098
1362
  /** This object describes a widget link to be included in the story. */
1099
- interface StoryWidgetLink {
1363
+ export interface StoryWidgetLink {
1100
1364
  /** The URL to be included in the story. */
1101
1365
  url: string;
1102
1366
  /** The name to be displayed for the widget link, 0-48 characters. */
1103
1367
  name?: string;
1104
1368
  }
1369
+
1370
+ export interface LocationData {
1371
+ /**
1372
+ * Latitude in degrees.
1373
+ */
1374
+ latitude: number;
1375
+ /**
1376
+ * Longitude in degrees.
1377
+ */
1378
+ longitude: number;
1379
+ /**
1380
+ * Altitude above sea level in meters. null if altitude data is not available on the device.
1381
+ */
1382
+ altitude: number | null;
1383
+ /**
1384
+ * The direction the device is moving in degrees (0 = North, 90 = East, 180 = South, 270 = West).
1385
+ * null if course data is not available on the device.
1386
+ */
1387
+ course: number | null;
1388
+ /**
1389
+ * The speed of the device in m/s. null if speed data is not available on the device.
1390
+ */
1391
+ speed: number | null;
1392
+ /**
1393
+ * Accuracy of the latitude and longitude values in meters.
1394
+ * null if horizontal accuracy data is not available on the device.
1395
+ */
1396
+ horizontal_accuracy: number | null;
1397
+ /**
1398
+ * Accuracy of the altitude value in meters.
1399
+ * null if vertical accuracy data is not available on the device.
1400
+ */
1401
+ vertical_accuracy: number | null;
1402
+ /**
1403
+ * Accuracy of the course value in degrees.
1404
+ * null if course accuracy data is not available on the device.
1405
+ */
1406
+ course_accuracy: number | null;
1407
+ /**
1408
+ * Accuracy of the speed value in m/s.
1409
+ * null if speed accuracy data is not available on the device.
1410
+ */
1411
+ speed_accuracy: number | null;
1412
+ }
1413
+
1414
+ export interface EmojiStatusParams {
1415
+ /**
1416
+ * Optional. The duration for which the status will remain set, in seconds.
1417
+ */
1418
+ duration?: number;
1419
+ }
1420
+
1421
+ export interface DownloadFileParams {
1422
+ /**
1423
+ * The HTTPS URL of the file to be downloaded.
1424
+ */
1425
+ url: string;
1426
+ /**
1427
+ * The suggested name for the downloaded file.
1428
+ */
1429
+ file_name: string;
1430
+ }
1431
+
1432
+ export interface SafeAreaInset {
1433
+ /**
1434
+ * The top inset in pixels, representing the space to avoid at the top of the screen.
1435
+ * Also available as the CSS variable var(--tg-safe-area-inset-top).
1436
+ */
1437
+ top: number;
1438
+ /**
1439
+ * The bottom inset in pixels, representing the space to avoid at the bottom of the screen.
1440
+ * Also available as the CSS variable var(--tg-safe-area-inset-bottom).
1441
+ */
1442
+ bottom: number;
1443
+ /**
1444
+ * The left inset in pixels, representing the space to avoid on the left side of the screen.
1445
+ * Also available as the CSS variable var(--tg-safe-area-inset-left).
1446
+ */
1447
+ left: number;
1448
+ /**
1449
+ * The right inset in pixels, representing the space to avoid on the right side of the screen.
1450
+ * Also available as the CSS variable var(--tg-safe-area-inset-right).
1451
+ */
1452
+ right: number;
1453
+ }
1454
+
1455
+ export interface ContentSafeAreaInset {
1456
+ /**
1457
+ * The top inset in pixels, representing the space to avoid at the top of the content area.
1458
+ * Also available as the CSS variable var(--tg-content-safe-area-inset-top).
1459
+ */
1460
+ top: number;
1461
+ /**
1462
+ * The bottom inset in pixels, representing the space to avoid at the bottom of the content area.
1463
+ * Also available as the CSS variable var(--tg-content-safe-area-inset-bottom).
1464
+ */
1465
+ bottom: number;
1466
+ /**
1467
+ * The left inset in pixels, representing the space to avoid on the left side of the content area.
1468
+ * Also available as the CSS variable var(--tg-content-safe-area-inset-left).
1469
+ */
1470
+ left: number;
1471
+ /**
1472
+ * The right inset in pixels, representing the space to avoid on the right side of the content area.
1473
+ * Also available as the CSS variable var(--tg-content-safe-area-inset-right).
1474
+ */
1475
+ right: number;
1476
+ }
1477
+
1478
+ export interface Accelerometer {
1479
+ /**
1480
+ * Indicates whether accelerometer tracking is currently active.
1481
+ */
1482
+ isStarted: boolean;
1483
+ /**
1484
+ * The current acceleration in the X-axis, measured in m/s².
1485
+ */
1486
+ x: number;
1487
+ /**
1488
+ * The current acceleration in the Y-axis, measured in m/s².
1489
+ */
1490
+ y: number;
1491
+ /**
1492
+ * The current acceleration in the Z-axis, measured in m/s².
1493
+ */
1494
+ z: number;
1495
+ /**
1496
+ * **Bot API 8.0+**
1497
+ *
1498
+ * Starts tracking accelerometer data using params of type AccelerometerStartParams.
1499
+ * If an optional callback parameter is provided,
1500
+ * the callback function will be called with a boolean indicating whether tracking was successfully started.
1501
+ */
1502
+ start: (params: AccelerometerStartParams, callback?: (success: boolean) => void) => Accelerometer;
1503
+ /**
1504
+ * **Bot API 8.0+**
1505
+ *
1506
+ * Stops tracking accelerometer data.
1507
+ * If an optional callback parameter is provided,
1508
+ * the callback function will be called with a boolean indicating
1509
+ * whether tracking was successfully stopped.
1510
+ */
1511
+ stop: (callback?: (success: boolean) => void) => Accelerometer;
1512
+ }
1513
+
1514
+ export interface AccelerometerStartParams {
1515
+ /**
1516
+ * Optional.
1517
+ * The refresh rate in milliseconds, with acceptable values ranging from 20 to 1000.
1518
+ * Set to 1000 by default. Note that refresh_rate may not be supported on all platforms,
1519
+ * so the actual tracking frequency may differ from the specified value.
1520
+ */
1521
+ refresh_rate?: number;
1522
+ }
1523
+
1524
+ export interface DeviceOrientation {
1525
+ /**
1526
+ * Indicates whether device orientation tracking is currently active.
1527
+ */
1528
+ isStarted: boolean;
1529
+ /**
1530
+ * A boolean that indicates whether or not the device is providing orientation data in absolute values.
1531
+ */
1532
+ absolute: boolean;
1533
+ /**
1534
+ * The rotation around the Z-axis, measured in radians.
1535
+ */
1536
+ alpha: number;
1537
+ /**
1538
+ * The rotation around the X-axis, measured in radians.
1539
+ */
1540
+ beta: number;
1541
+ /**
1542
+ * The rotation around the Y-axis, measured in radians.
1543
+ */
1544
+ gamma: number;
1545
+ /**
1546
+ * **Bot API 8.0+**
1547
+ *
1548
+ * Starts tracking device orientation data using params of type DeviceOrientationStartParams.
1549
+ * If an optional callback parameter is provided,
1550
+ * the callback function will be called with a boolean indicating whether tracking was successfully started.
1551
+ */
1552
+ start: (params: DeviceOrientationStartParams, callback?: (success: boolean) => void) => DeviceOrientation;
1553
+ /**
1554
+ * **Bot API 8.0+**
1555
+ *
1556
+ * Stops tracking device orientation data.
1557
+ * If an optional callback parameter is provided,
1558
+ * the callback function will be called with a boolean indicating whether tracking was successfully stopped.
1559
+ */
1560
+ stop: (callback?: (success: boolean) => void) => DeviceOrientation;
1561
+ }
1562
+
1563
+ export interface DeviceOrientationStartParams {
1564
+ /**
1565
+ * Optional.
1566
+ * The refresh rate in milliseconds, with acceptable values ranging from 20 to 1000.
1567
+ * Set to 1000 by default. Note that refresh_rate may not be supported on all platforms,
1568
+ * so the actual tracking frequency may differ from the specified value.
1569
+ */
1570
+ refresh_rate?: number;
1571
+ /**
1572
+ * Optional.
1573
+ * Pass true to receive absolute orientation data,
1574
+ * allowing you to determine the device's attitude relative to magnetic north.
1575
+ * Use this option if implementing features like a compass in your app.
1576
+ * If relative data is sufficient, pass false. Set to false by default.
1577
+ *
1578
+ * Note: Keep in mind that some devices may not support absolute orientation data.
1579
+ * In such cases, you will receive relative data even if need_absolute=true is passed.
1580
+ * Check the DeviceOrientation.absolute parameter to determine whether the data provided is absolute or relative.
1581
+ */
1582
+ need_absolute?: boolean;
1583
+ }
1584
+
1585
+ export interface Gyroscope {
1586
+ /**
1587
+ * Indicates whether gyroscope tracking is currently active.
1588
+ */
1589
+ isStarted: boolean;
1590
+ /**
1591
+ * The current rotation rate around the X-axis, measured in rad/s.
1592
+ */
1593
+ x: number;
1594
+ /**
1595
+ * The current rotation rate around the Y-axis, measured in rad/s.
1596
+ */
1597
+ y: number;
1598
+ /**
1599
+ * The current rotation rate around the Z-axis, measured in rad/s.
1600
+ */
1601
+ z: number;
1602
+ /**
1603
+ * **Bot API 8.0+**
1604
+ *
1605
+ * Starts tracking gyroscope data using params of type GyroscopeStartParams.
1606
+ * If an optional callback parameter is provided,
1607
+ * the callback function will be called with a boolean indicating whether tracking was successfully started.
1608
+ */
1609
+ start: (params: GyroscopeStartParams, callback?: (success: boolean) => void) => Gyroscope;
1610
+ /**
1611
+ * **Bot API 8.0+**
1612
+ *
1613
+ * Stops tracking gyroscope data.
1614
+ * If an optional callback parameter is provided,
1615
+ * the callback function will be called with a boolean indicating whether tracking was successfully stopped.
1616
+ */
1617
+ stop: (callback?: (success: boolean) => void) => Gyroscope;
1618
+ }
1619
+
1620
+ export interface GyroscopeStartParams {
1621
+ /**
1622
+ * Optional.
1623
+ * The refresh rate in milliseconds, with acceptable values ranging from 20 to 1000.
1624
+ * Set to 1000 by default. Note that refresh_rate may not be supported on all platforms,
1625
+ * so the actual tracking frequency may differ from the specified value.
1626
+ */
1627
+ refresh_rate?: number;
1628
+ }
1629
+
1630
+ export interface LocationManager {
1631
+ /**
1632
+ * Shows whether the LocationManager object has been initialized.
1633
+ */
1634
+ isInited: boolean;
1635
+ /**
1636
+ * Shows whether location services are available on the current device.
1637
+ */
1638
+ isLocationAvailable: boolean;
1639
+ /**
1640
+ * Shows whether permission to use location has been requested.
1641
+ */
1642
+ isAccessRequested: boolean;
1643
+ /**
1644
+ * Shows whether permission to use location has been granted.
1645
+ */
1646
+ isAccessGranted: boolean;
1647
+ /**
1648
+ * Bot API 8.0+
1649
+ *
1650
+ * A method that initializes the LocationManager object.
1651
+ * It should be called before the object's first use.
1652
+ * If an optional callback parameter is provided,
1653
+ * the callback function will be called when the object is initialized.
1654
+ */
1655
+ init: (callback?: () => void) => LocationManager;
1656
+ /**
1657
+ * **Bot API 8.0+**
1658
+ *
1659
+ * A method that requests location data.
1660
+ * The callback function will be called with null as the first argument
1661
+ * if access to location was not granted,
1662
+ * or an object of type LocationData as the first argument if access was successful.
1663
+ */
1664
+ getLocation: (callback: (locationData: LocationData | null) => void) => LocationManager;
1665
+ /**
1666
+ * **Bot API 8.0+**
1667
+ *
1668
+ * A method that opens the location access settings for bots.
1669
+ * Useful when you need to request location access from users who haven't granted it yet.
1670
+ *
1671
+ * Note that this method can be called only in response to user interaction with the Mini App interface
1672
+ * (e.g., a click inside the Mini App or on the main button).
1673
+ */
1674
+ openSettings: () => LocationManager;
1675
+ }
1676
+
1677
+ export interface DeviceStorage {
1678
+ /**
1679
+ * Bot API 9.0+
1680
+ *
1681
+ * A method that stores a value in the device's local storage using the specified key.
1682
+ * If an optional callback parameter was passed, the callback function will be called.
1683
+ * In case of an error, the first argument will contain the error.
1684
+ * In case of success, the first argument will be null and the second argument will be a boolean
1685
+ * indicating whether the value was stored.
1686
+ */
1687
+ setItem: (key: string, value: string, callback?: (error: string | null, success: boolean) => void) => DeviceStorage;
1688
+ /**
1689
+ * Bot API 9.0+
1690
+ *
1691
+ * A method that receives a value from the device's local storage using the specified key.
1692
+ * In case of an error, the callback function will be called and the first argument will contain the error.
1693
+ * In case of success, the first argument will be null and the value will be passed as the second argument.
1694
+ */
1695
+ getItem: (key: string, callback?: (error: string | null, item: string) => void) => DeviceStorage;
1696
+ /**
1697
+ * Bot API 9.0+
1698
+ *
1699
+ * A method that removes a value from the device's local storage using the specified key.
1700
+ * If an optional callback parameter was passed, the callback function will be called.
1701
+ * In case of an error, the first argument will contain the error.
1702
+ * In case of success, the first argument will be null
1703
+ * and the second argument will be a boolean indicating whether the value was removed.
1704
+ */
1705
+ removeItem: (key: string, callback?: (error: string | null, success: boolean) => void) => DeviceStorage;
1706
+ /**
1707
+ * Bot API 9.0+
1708
+ *
1709
+ * A method that clears all keys previously stored by the bot in the device's local storage.
1710
+ * If an optional callback parameter was passed, the callback function will be called.
1711
+ * In case of an error, the first argument will contain the error.
1712
+ * In case of success, the first argument will be null
1713
+ * and the second argument will be a boolean indicating whether all values were removed.
1714
+ */
1715
+ clear: (callback?: (error: string | null, success: boolean) => void) => DeviceStorage;
1716
+ }
1717
+
1718
+ export interface SecureStorage {
1719
+ /**
1720
+ * Bot API 9.0+
1721
+ *
1722
+ * A method that stores a value in the device's secure storage using the specified key.
1723
+ * If an optional callback parameter was passed, the callback function will be called.
1724
+ * In case of an error, the first argument will contain the error.
1725
+ * In case of success, the first argument will be null
1726
+ * and the second argument will be a boolean indicating whether the value was stored.
1727
+ */
1728
+ setItem: (key: string, value: string, callback?: (error: string | null, success: boolean) => void) => SecureStorage;
1729
+ /**
1730
+ * Bot API 9.0+
1731
+ *
1732
+ * A method that receives a value from the device's secure storage using the specified key.
1733
+ * In case of an error, the callback function will be called and the first argument will contain the error.
1734
+ * In case of success, the first argument will be null and the value will be passed as the second argument.
1735
+ * If the key was not found, the second argument will be null,
1736
+ * and the third argument will be a boolean indicating whether the key can be restored from the current device.
1737
+ */
1738
+ getItem: (
1739
+ key: string,
1740
+ callback?: (error: string | null, item: string | null, restorable: boolean) => void,
1741
+ ) => SecureStorage;
1742
+ /**
1743
+ * Bot API 9.0+
1744
+ *
1745
+ * Attempts to restore a key that previously existed on the current device.
1746
+ * When called, the user will be asked for permission to restore the value.
1747
+ * If the user declines or an error occurs, the first argument in the callback will contain the error.
1748
+ * If restored successfully, the first argument will be null and the second argument will contain the restored value.
1749
+ */
1750
+ restoreItem: (key: string, callback?: (error: string | null, item: string) => void) => SecureStorage;
1751
+ /**
1752
+ * Bot API 9.0+
1753
+ *
1754
+ * A method that removes a value from the device's secure storage using the specified key.
1755
+ * If an optional callback parameter was passed, the callback function will be called.
1756
+ * In case of an error, the first argument will contain the error.
1757
+ * In case of success, the first argument will be null
1758
+ * and the second argument will be a boolean indicating whether the value was removed.
1759
+ */
1760
+ removeItem: (key: string, callback?: (error: string | null, success: boolean) => void) => SecureStorage;
1761
+ /**
1762
+ * Bot API 9.0+
1763
+ *
1764
+ * A method that clears all keys previously stored by the bot in the device's secure storage.
1765
+ * If an optional callback parameter was passed, the callback function will be called.
1766
+ * In case of an error, the first argument will contain the error. In case of success,
1767
+ * the first argument will be null
1768
+ * and the second argument will be a boolean indicating whether all values were removed.
1769
+ */
1770
+ clear: (callback?: (error: string | null, success: boolean) => void) => SecureStorage;
1771
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/telegram-web-app",
3
- "version": "7.10.1",
3
+ "version": "9.0.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,7 @@
30
30
  },
31
31
  "scripts": {},
32
32
  "dependencies": {},
33
- "typesPublisherContentHash": "dd411016825024a1d9831f7377413945af40bc47d3332d6e2bc950e461fe28cd",
34
- "typeScriptVersion": "4.8"
33
+ "peerDependencies": {},
34
+ "typesPublisherContentHash": "d7b82247812d99fcf54be15de02ee34a9f8303892f0fc6e52b1927018a8f4535",
35
+ "typeScriptVersion": "5.1"
35
36
  }