@tma.js/bridge 1.4.0 → 2.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.
Files changed (92) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +44 -13
  3. package/dist/dts/applyPolyfills.d.ts +5 -0
  4. package/dist/dts/base64-url.d.ts +24 -0
  5. package/dist/dts/env/hasWebviewProxy.d.ts +10 -0
  6. package/dist/dts/env/isIframe.d.ts +5 -0
  7. package/dist/dts/env/isTMA.d.ts +31 -0
  8. package/dist/dts/env/mockTelegramEnv.d.ts +57 -0
  9. package/dist/dts/errors.d.ts +27 -0
  10. package/dist/dts/events/createEmitter.d.ts +58 -0
  11. package/dist/dts/events/emitEvent.d.ts +33 -0
  12. package/dist/dts/events/emitter.d.ts +2 -11
  13. package/dist/dts/events/types/events.d.ts +721 -0
  14. package/dist/dts/events/types/index.d.ts +3 -0
  15. package/dist/dts/events/types/listening.d.ts +5 -0
  16. package/dist/dts/events/types/misc.d.ts +16 -0
  17. package/dist/dts/globals.d.ts +45 -14
  18. package/dist/dts/index.d.ts +24 -7
  19. package/dist/dts/launch-params.d.ts +32 -0
  20. package/dist/dts/methods/captureSameReq.d.ts +10 -0
  21. package/dist/dts/methods/createPostEvent.d.ts +27 -7
  22. package/dist/dts/methods/postEvent.d.ts +31 -25
  23. package/dist/dts/methods/postMessage.d.ts +7 -0
  24. package/dist/dts/methods/supports.d.ts +15 -0
  25. package/dist/dts/methods/types/custom-method.d.ts +59 -0
  26. package/dist/dts/methods/types/index.d.ts +6 -0
  27. package/dist/dts/methods/types/methods.d.ts +756 -0
  28. package/dist/dts/methods/types/misc.d.ts +27 -0
  29. package/dist/dts/methods/{popup.d.ts → types/popup.d.ts} +1 -1
  30. package/dist/dts/methods/types/utils.d.ts +9 -0
  31. package/dist/dts/obj-prop-helpers.d.ts +39 -0
  32. package/dist/dts/start-param.d.ts +53 -0
  33. package/dist/dts/utils/compareVersions.d.ts +10 -0
  34. package/dist/dts/utils/invokeCustomMethod.d.ts +34 -0
  35. package/dist/dts/utils/request.d.ts +90 -0
  36. package/dist/index.cjs +3 -1
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.iife.js +3 -1
  39. package/dist/index.iife.js.map +1 -1
  40. package/dist/index.js +977 -0
  41. package/dist/index.js.map +1 -0
  42. package/package.json +26 -26
  43. package/dist/dts/env.d.ts +0 -29
  44. package/dist/dts/errors/MethodUnsupportedError.d.ts +0 -8
  45. package/dist/dts/errors/ParameterUnsupportedError.d.ts +0 -8
  46. package/dist/dts/errors/index.d.ts +0 -2
  47. package/dist/dts/events/events.d.ts +0 -130
  48. package/dist/dts/events/index.d.ts +0 -7
  49. package/dist/dts/events/off.d.ts +0 -7
  50. package/dist/dts/events/on.d.ts +0 -10
  51. package/dist/dts/events/onTelegramEvent.d.ts +0 -7
  52. package/dist/dts/events/once.d.ts +0 -9
  53. package/dist/dts/events/parsing.d.ts +0 -38
  54. package/dist/dts/events/payloads.d.ts +0 -93
  55. package/dist/dts/events/subscribe.d.ts +0 -9
  56. package/dist/dts/events/unsubscribe.d.ts +0 -6
  57. package/dist/dts/methods/index.d.ts +0 -6
  58. package/dist/dts/methods/invoke-custom-method.d.ts +0 -24
  59. package/dist/dts/methods/methods.d.ts +0 -330
  60. package/dist/dts/request.d.ts +0 -66
  61. package/dist/dts/shared.d.ts +0 -5
  62. package/dist/dts/supports.d.ts +0 -15
  63. package/dist/index.mjs +0 -297
  64. package/dist/index.mjs.map +0 -1
  65. package/src/env.ts +0 -49
  66. package/src/errors/MethodUnsupportedError.ts +0 -13
  67. package/src/errors/ParameterUnsupportedError.ts +0 -13
  68. package/src/errors/index.ts +0 -2
  69. package/src/events/emitter.ts +0 -126
  70. package/src/events/events.ts +0 -169
  71. package/src/events/index.ts +0 -7
  72. package/src/events/off.ts +0 -12
  73. package/src/events/on.ts +0 -17
  74. package/src/events/onTelegramEvent.ts +0 -83
  75. package/src/events/once.ts +0 -16
  76. package/src/events/parsing.ts +0 -110
  77. package/src/events/payloads.ts +0 -125
  78. package/src/events/subscribe.ts +0 -16
  79. package/src/events/unsubscribe.ts +0 -11
  80. package/src/globals.ts +0 -38
  81. package/src/index.ts +0 -7
  82. package/src/methods/createPostEvent.ts +0 -39
  83. package/src/methods/haptic.ts +0 -52
  84. package/src/methods/index.ts +0 -6
  85. package/src/methods/invoke-custom-method.ts +0 -25
  86. package/src/methods/methods.ts +0 -373
  87. package/src/methods/popup.ts +0 -53
  88. package/src/methods/postEvent.ts +0 -101
  89. package/src/request.ts +0 -168
  90. package/src/shared.ts +0 -5
  91. package/src/supports.ts +0 -82
  92. /package/dist/dts/methods/{haptic.d.ts → types/haptic-feedback.d.ts} +0 -0
@@ -0,0 +1,721 @@
1
+ import { If, IsNever, Maybe } from '@tma.js/toolkit';
2
+ import { RGB } from '@tma.js/types';
3
+ import { BiometryAuthRequestStatus, BiometryTokenUpdateStatus, BiometryType, EmojiStatusAccessRequestedStatus, EmojiStatusFailedError, FullScreenErrorStatus, HomeScreenStatus, InvoiceStatus, PhoneRequestedStatus, SafeAreaInsets, WriteAccessRequestedStatus } from './misc.js';
4
+ type WithReqId<T = {}> = T & {
5
+ /**
6
+ * Unique request identifier.
7
+ */
8
+ req_id: string;
9
+ };
10
+ /**
11
+ * Map where key is known event name, and value is its listener.
12
+ * @see https://docs.telegram-mini-apps.com/platform/events
13
+ */
14
+ export interface Events {
15
+ /**
16
+ * Accelerometer data changed.
17
+ * @since 8.0
18
+ * @see https://docs.telegram-mini-apps.com/platform/events#accelerometer-changed
19
+ */
20
+ accelerometer_changed: {
21
+ /**
22
+ * The current acceleration in the X-axis, measured in m/s².
23
+ */
24
+ x: number;
25
+ /**
26
+ * The current acceleration in the Y-axis, measured in m/s².
27
+ */
28
+ y: number;
29
+ /**
30
+ * The current acceleration in the Z-axis, measured in m/s².
31
+ */
32
+ z: number;
33
+ };
34
+ /**
35
+ * Failed to start accelerometer data tracking.
36
+ * @since 8.0
37
+ * @see https://docs.telegram-mini-apps.com/platform/events#accelerometer-failed
38
+ */
39
+ accelerometer_failed: {
40
+ /**
41
+ * Occurred error.
42
+ */
43
+ error: string;
44
+ };
45
+ /**
46
+ * Accelerometer data tracking started.
47
+ * @since 8.0
48
+ * @see https://docs.telegram-mini-apps.com/platform/events#accelerometer-started
49
+ */
50
+ accelerometer_started: never;
51
+ /**
52
+ * Accelerometer data tracking stopped.
53
+ * @since 8.0
54
+ * @see https://docs.telegram-mini-apps.com/platform/events#accelerometer-stopped
55
+ */
56
+ accelerometer_stopped: never;
57
+ /**
58
+ * User clicked the BackButton.
59
+ * @since v6.1
60
+ * @see https://docs.telegram-mini-apps.com/platform/events#back-button-pressed
61
+ */
62
+ back_button_pressed: never;
63
+ /**
64
+ * Biometry authentication request completed.
65
+ * @since 7.2
66
+ * @see https://docs.telegram-mini-apps.com/platform/events#biometry-auth-requested
67
+ */
68
+ biometry_auth_requested: {
69
+ /**
70
+ * Authentication status.
71
+ */
72
+ status: BiometryAuthRequestStatus;
73
+ /**
74
+ * Token from the local secure storage saved previously.
75
+ */
76
+ token?: string;
77
+ };
78
+ /**
79
+ * Biometry settings were received.
80
+ * @since 7.2
81
+ * @see https://docs.telegram-mini-apps.com/platform/events#biometry-info-received
82
+ */
83
+ biometry_info_received: {
84
+ /**
85
+ * If true, indicates that biometric authentication is available on the
86
+ * current device.
87
+ */
88
+ available: false;
89
+ } | {
90
+ /**
91
+ * If true, indicates that biometric authentication is available on the
92
+ * current device.
93
+ */
94
+ available: true;
95
+ /**
96
+ * Indicates whether the app has previously requested permission to use
97
+ * biometrics.
98
+ */
99
+ access_requested: boolean;
100
+ /**
101
+ * Indicates whether the user has granted the app permission to use
102
+ * biometrics.
103
+ *
104
+ * If false and access_requested is true may indicate that:
105
+ *
106
+ * - The user has simply canceled the permission popup, in which case
107
+ * a `web_app_biometry_request_access` event can be emitted to re-open the
108
+ * popup.
109
+ *
110
+ * - The user has denied the app permission to use biometrics, in which
111
+ * case the app should open a prompt notifying the user that the biometric
112
+ * settings must be changed to use biometrics.
113
+ */
114
+ access_granted: boolean;
115
+ /**
116
+ * A unique device identifier that can be used to match the token to the
117
+ * device.
118
+ */
119
+ device_id: string;
120
+ /**
121
+ * Show whether a token was safely stored on-device.
122
+ */
123
+ token_saved: boolean;
124
+ /**
125
+ * The type of biometrics currently available on the device.
126
+ */
127
+ type: BiometryType;
128
+ };
129
+ /**
130
+ * Biometry token was updated.
131
+ * @since 7.2
132
+ * @see https://docs.telegram-mini-apps.com/platform/events#biometry-token-updated
133
+ */
134
+ biometry_token_updated: {
135
+ /**
136
+ * Update status.
137
+ *
138
+ * One of:
139
+ * - `updated` - If the token was successfully updated.
140
+ * - `removed` - If the token was successfully removed.
141
+ * - `failed` - If biometric authentication failed, or the app doesn't have
142
+ * permission to use biometrics.
143
+ */
144
+ status: BiometryTokenUpdateStatus;
145
+ };
146
+ /**
147
+ * Telegram application attempted to extract text from clipboard.
148
+ * @since v6.4
149
+ * @see https://docs.telegram-mini-apps.com/platform/events#clipboard-text-received
150
+ */
151
+ clipboard_text_received: WithReqId<{
152
+ /**
153
+ * Data extracted from the clipboard. The returned value will have the type
154
+ * `string` only in the case, application has access to the clipboard.
155
+ */
156
+ data?: string | null;
157
+ }>;
158
+ /**
159
+ * Occurs when the safe area for content changes
160
+ * (e.g., due to orientation change or screen adjustments).
161
+ * @since Mini Apps v8.0
162
+ * @see https://docs.telegram-mini-apps.com/platform/events#content_safe_area_changed
163
+ * */
164
+ content_safe_area_changed: SafeAreaInsets;
165
+ /**
166
+ * Custom method invocation completed.
167
+ * @since v6.9
168
+ * @see https://docs.telegram-mini-apps.com/platform/events#custom-method-invoked
169
+ */
170
+ custom_method_invoked: WithReqId<{
171
+ /**
172
+ * Method invocation successful result.
173
+ */
174
+ result?: unknown;
175
+ /**
176
+ * Method invocation error code.
177
+ */
178
+ error?: string;
179
+ }>;
180
+ /**
181
+ * Device orientation data changed.
182
+ * @since 8.0
183
+ * @see https://docs.telegram-mini-apps.com/platform/events#device-orientation-changed
184
+ */
185
+ device_orientation_changed: {
186
+ /**
187
+ * A boolean that indicates whether the device is providing orientation data in
188
+ * absolute values.
189
+ */
190
+ absolute?: Maybe<boolean>;
191
+ /**
192
+ * The rotation around the Z-axis, measured in radians.
193
+ */
194
+ alpha: number;
195
+ /**
196
+ * The rotation around the X-axis, measured in radians.
197
+ */
198
+ beta: number;
199
+ /**
200
+ * The rotation around the Y-axis, measured in radians.
201
+ */
202
+ gamma: number;
203
+ };
204
+ /**
205
+ * Device orientation data tracking failed to start.
206
+ * @since 8.0
207
+ * @see https://docs.telegram-mini-apps.com/platform/events#device-orientation-failed
208
+ */
209
+ device_orientation_failed: {
210
+ /**
211
+ * Occurred error.
212
+ */
213
+ error: string;
214
+ };
215
+ /**
216
+ * Device orientation data tracking started.
217
+ * @since 8.0
218
+ * @see https://docs.telegram-mini-apps.com/platform/events#device-orientation-started
219
+ */
220
+ device_orientation_started: never;
221
+ /**
222
+ * Device orientation data tracking stopped.
223
+ * @since 8.0
224
+ * @see https://docs.telegram-mini-apps.com/platform/events#device-orientation-stopped
225
+ */
226
+ device_orientation_stopped: never;
227
+ /**
228
+ * Device's local storage was cleared.
229
+ * @since v9.0
230
+ * @see https://docs.telegram-mini-apps.com/platform/events#device-storage-cleared
231
+ */
232
+ device_storage_cleared: WithReqId;
233
+ /**
234
+ * An error occurred while working with the device's local storage.
235
+ * @since v9.0
236
+ * @see https://docs.telegram-mini-apps.com/platform/events#device-storage-failed
237
+ */
238
+ device_storage_failed: WithReqId<{
239
+ /**
240
+ * An occurred error.
241
+ */
242
+ error?: string;
243
+ }>;
244
+ /**
245
+ * A value from the device's local storage was retrieved.
246
+ * @since v9.0
247
+ * @see https://docs.telegram-mini-apps.com/platform/events#device-storage-key-received
248
+ */
249
+ device_storage_key_received: WithReqId<{
250
+ /**
251
+ * A retrieved value.
252
+ */
253
+ value: string | null;
254
+ }>;
255
+ /**
256
+ * A value in the device's local storage was saved.
257
+ * @since v9.0
258
+ * @see https://docs.telegram-mini-apps.com/platform/events#device-storage-key-saved
259
+ */
260
+ device_storage_key_saved: WithReqId;
261
+ /**
262
+ * Request to set custom emoji status was requested.
263
+ * @see https://docs.telegram-mini-apps.com/platform/events#emoji-status-access-requested
264
+ * @since v8.0
265
+ */
266
+ emoji_status_access_requested: {
267
+ /**
268
+ * Request status.
269
+ */
270
+ status: EmojiStatusAccessRequestedStatus;
271
+ };
272
+ /**
273
+ * Failed to set custom emoji status.
274
+ * @see https://docs.telegram-mini-apps.com/platform/events#emoji-status-failed
275
+ * @since v8.0
276
+ */
277
+ emoji_status_failed: {
278
+ error: EmojiStatusFailedError;
279
+ };
280
+ /**
281
+ * Custom emoji status set.
282
+ * @see https://docs.telegram-mini-apps.com/platform/events#emoji-status-set
283
+ * @since v8.0
284
+ */
285
+ emoji_status_set: never;
286
+ /**
287
+ * Application received file download request status.
288
+ * @since 8.0
289
+ * @see https://docs.telegram-mini-apps.com/platform/events#file-download-requested
290
+ */
291
+ file_download_requested: {
292
+ status?: Maybe<'downloading' | string>;
293
+ };
294
+ /**
295
+ * App entered or exited fullscreen mode.
296
+ * @since v8.0
297
+ * @see https://docs.telegram-mini-apps.com/platform/events#fullscreen-changed
298
+ */
299
+ fullscreen_changed: {
300
+ /**
301
+ * Is application currently in the fullscreen mode.
302
+ */
303
+ is_fullscreen: boolean;
304
+ };
305
+ /**
306
+ * App failed to expand to the fullscreen mode.
307
+ * @since v8.0
308
+ * @see https://docs.telegram-mini-apps.com/platform/events#fullscreen-changed
309
+ */
310
+ fullscreen_failed: {
311
+ /**
312
+ * Full Screen mode status error.
313
+ */
314
+ error: FullScreenErrorStatus;
315
+ };
316
+ /**
317
+ * Gyroscope data changed.
318
+ * @since 8.0
319
+ * @see https://docs.telegram-mini-apps.com/platform/events#gyroscope-changed
320
+ */
321
+ gyroscope_changed: {
322
+ /**
323
+ * The current rotation rate around the X-axis, measured in rad/s.
324
+ */
325
+ x: number;
326
+ /**
327
+ * The current rotation rate around the Y-axis, measured in rad/s.
328
+ */
329
+ y: number;
330
+ /**
331
+ * The current rotation rate around the Z-axis, measured in rad/s.
332
+ */
333
+ z: number;
334
+ };
335
+ /**
336
+ * Gyroscope data tracking failed to run.
337
+ * @since 8.0
338
+ * @see https://docs.telegram-mini-apps.com/platform/events#gyroscope-failed
339
+ */
340
+ gyroscope_failed: {
341
+ /**
342
+ * Occurred error.
343
+ */
344
+ error: string;
345
+ };
346
+ /**
347
+ * Gyroscope data tracking started.
348
+ * @since 8.0
349
+ * @see https://docs.telegram-mini-apps.com/platform/events#gyroscope-started
350
+ */
351
+ gyroscope_started: never;
352
+ /**
353
+ * Gyroscope data tracking stopped.
354
+ * @since 8.0
355
+ * @see https://docs.telegram-mini-apps.com/platform/events#gyroscope-stopped
356
+ */
357
+ gyroscope_stopped: never;
358
+ /**
359
+ * The mini application was added to the device's home screen.
360
+ * @since v8.0
361
+ * @see https://docs.telegram-mini-apps.com/platform/events#home_screen_added
362
+ */
363
+ home_screen_added: never;
364
+ /**
365
+ * The status of the mini application being added to the home screen has been checked.
366
+ * @since v8.0
367
+ * @see https://docs.telegram-mini-apps.com/platform/events#home_screen_checked
368
+ */
369
+ home_screen_checked: {
370
+ /**
371
+ * The status of the mini application being added to the home screen.
372
+ *
373
+ * Possible values:
374
+ * - `unsupported` – the feature is not supported, and it is not possible to add the icon to
375
+ * the home screen,
376
+ * - `unknown` – the feature is supported, and the icon can be added, but it is not possible to
377
+ * determine if the icon has already been added,
378
+ * - `added` – the icon has already been added to the home screen,
379
+ * - `missed` – the icon has not been added to the home screen.
380
+ */
381
+ status?: HomeScreenStatus;
382
+ };
383
+ /**
384
+ * User declined the request to add the current mini application to the device's home screen.
385
+ * @since v8.0
386
+ * @see https://docs.telegram-mini-apps.com/platform/events#home_screen_failed
387
+ */
388
+ home_screen_failed: never;
389
+ /**
390
+ * An invoice was closed.
391
+ * @see https://docs.telegram-mini-apps.com/platform/events#invoice-closed
392
+ */
393
+ invoice_closed: {
394
+ /**
395
+ * Passed during the `web_app_open_invoice` method invocation `slug` value.
396
+ */
397
+ slug: string;
398
+ /**
399
+ * Invoice status.
400
+ */
401
+ status: InvoiceStatus;
402
+ };
403
+ /**
404
+ * Checks the location-related functionality availability state.
405
+ * @since 8.0
406
+ * @see https://docs.telegram-mini-apps.com/platform/events#location-checked
407
+ */
408
+ location_checked: {
409
+ available: false;
410
+ } | {
411
+ available: true;
412
+ access_requested?: Maybe<boolean>;
413
+ access_granted?: Maybe<boolean>;
414
+ };
415
+ /**
416
+ * Location-related functionality availability status was retrieved.
417
+ * @since 8.0
418
+ * @see https://docs.telegram-mini-apps.com/platform/events#location-requested
419
+ */
420
+ location_requested: {
421
+ available: false;
422
+ } | {
423
+ available: true;
424
+ /**
425
+ * Latitude in degrees.
426
+ */
427
+ latitude: number;
428
+ /**
429
+ * Longitude in degrees.
430
+ */
431
+ longitude: number;
432
+ /**
433
+ * Altitude above sea level in meters.
434
+ */
435
+ altitude?: Maybe<number>;
436
+ /**
437
+ * The direction the device is moving in degrees.
438
+ */
439
+ course?: Maybe<number>;
440
+ /**
441
+ * The speed of the device in m/s.
442
+ */
443
+ speed?: Maybe<number>;
444
+ /**
445
+ * Accuracy of the latitude and longitude values in meters.
446
+ */
447
+ horizontal_accuracy?: Maybe<number>;
448
+ /**
449
+ * Accuracy of the altitude value in meters.
450
+ */
451
+ vertical_accuracy?: Maybe<number>;
452
+ /**
453
+ * Accuracy of the course value in degrees.
454
+ */
455
+ course_accuracy?: Maybe<number>;
456
+ /**
457
+ * Accuracy of the speed value in m/s.
458
+ */
459
+ speed_accuracy?: Maybe<number>;
460
+ };
461
+ /**
462
+ * A user clicked the Main Button.
463
+ * @see https://docs.telegram-mini-apps.com/platform/events#main-button-pressed
464
+ */
465
+ main_button_pressed: never;
466
+ /**
467
+ * Application received phone access request status.
468
+ * @since v6.9
469
+ * @see https://docs.telegram-mini-apps.com/platform/events#phone-requested
470
+ */
471
+ phone_requested: {
472
+ /**
473
+ * Request status.
474
+ */
475
+ status: PhoneRequestedStatus;
476
+ };
477
+ /**
478
+ * Popup was closed.
479
+ * @see https://docs.telegram-mini-apps.com/platform/events#popup-closed
480
+ */
481
+ popup_closed: {
482
+ /**
483
+ * Identifier of the clicked button. In case, the popup was closed without
484
+ * clicking any button, this property will be omitted.
485
+ */
486
+ button_id?: string;
487
+ };
488
+ /**
489
+ * Failed to send a prepared message.
490
+ * @since 8.0
491
+ * @see https://docs.telegram-mini-apps.com/platform/events#prepare-message-failed
492
+ */
493
+ prepared_message_failed: {
494
+ /**
495
+ * Occurred error.
496
+ */
497
+ error: string;
498
+ };
499
+ /**
500
+ * A prepared message was sent.
501
+ * @since 8.0
502
+ * @see https://docs.telegram-mini-apps.com/platform/events#prepare-message-sent
503
+ */
504
+ prepared_message_sent: never;
505
+ /**
506
+ * The QR scanner scanned some QR and extracted its content.
507
+ * @param payload - event payload.
508
+ * @since v6.4
509
+ * @see https://docs.telegram-mini-apps.com/platform/events#qr-text-received
510
+ */
511
+ qr_text_received: {
512
+ /**
513
+ * Data extracted from the QR.
514
+ */
515
+ data: string;
516
+ };
517
+ /**
518
+ * Parent iframe requested current iframe reload.
519
+ * @see https://docs.telegram-mini-apps.com/platform/events#reload-iframe
520
+ */
521
+ reload_iframe: never;
522
+ /**
523
+ * Occurs whenever the device's safe area insets change
524
+ * (e.g., due to orientation change or screen adjustments).
525
+ * @since Mini Apps v8.0
526
+ * @see https://docs.telegram-mini-apps.com/platform/events#safe_area_changed
527
+ * */
528
+ safe_area_changed: SafeAreaInsets;
529
+ /**
530
+ * QR scanner was closed.
531
+ * @since v6.4
532
+ * @see https://docs.telegram-mini-apps.com/platform/events#scan-qr-popup-closed
533
+ */
534
+ scan_qr_popup_closed: never;
535
+ /**
536
+ * User clicked the secondary button.
537
+ * @since v7.10
538
+ * @see https://docs.telegram-mini-apps.com/platform/events#secondary-button-pressed
539
+ */
540
+ secondary_button_pressed: never;
541
+ /**
542
+ * Device's secure storage was cleared.
543
+ * @since v9.0
544
+ * @see https://docs.telegram-mini-apps.com/platform/events#secure-storage-cleared
545
+ */
546
+ secure_storage_cleared: WithReqId;
547
+ /**
548
+ * An error occurred while working with the device's secure storage.
549
+ * @since v9.0
550
+ * @see https://docs.telegram-mini-apps.com/platform/events#secure-storage-failed
551
+ */
552
+ secure_storage_failed: WithReqId<{
553
+ /**
554
+ * An occurred error.
555
+ */
556
+ error?: string;
557
+ }>;
558
+ /**
559
+ * A value from the device's secure storage was retrieved.
560
+ * @since v9.0
561
+ * @see https://docs.telegram-mini-apps.com/platform/events#secure-storage-key-received
562
+ */
563
+ secure_storage_key_received: WithReqId<{
564
+ /**
565
+ * A retrieved value.
566
+ */
567
+ value: string | null;
568
+ /**
569
+ * True if this value can be restored.
570
+ */
571
+ can_restore?: boolean;
572
+ }>;
573
+ /**
574
+ * A value from the device's secure storage was restored.
575
+ * @since v9.0
576
+ * @see https://docs.telegram-mini-apps.com/platform/events#secure-storage-key-restored
577
+ */
578
+ secure_storage_key_restored: WithReqId<{
579
+ /**
580
+ * A restored value.
581
+ */
582
+ value: string | null;
583
+ }>;
584
+ /**
585
+ * A value in the device's secure storage was saved.
586
+ * @since v9.0
587
+ * @see https://docs.telegram-mini-apps.com/platform/events#secure-storage-key-saved
588
+ */
589
+ secure_storage_key_saved: WithReqId;
590
+ /**
591
+ * The event which is usually sent by the Telegram web application. Its
592
+ * payload represents
593
+ * `<style/>` tag html content, a developer could use. The stylesheet
594
+ * described in the payload will help the developer to stylize the app
595
+ * scrollbar (but he is still able to do it himself).
596
+ * @see https://docs.telegram-mini-apps.com/platform/events#set-custom-style
597
+ */
598
+ set_custom_style: string;
599
+ /**
600
+ * Occurs when the Settings Button was pressed.
601
+ * @since v6.1
602
+ * @see https://docs.telegram-mini-apps.com/platform/events#settings-button-pressed
603
+ */
604
+ settings_button_pressed: never;
605
+ /**
606
+ * Occurs whenever theme settings are changed in the user's Telegram app
607
+ * (including switching to night mode).
608
+ * @see https://docs.telegram-mini-apps.com/platform/events#theme-changed
609
+ */
610
+ theme_changed: {
611
+ /**
612
+ * Map where the key is a theme stylesheet key and value is the
613
+ * corresponding color in
614
+ * `#RRGGBB` format.
615
+ */
616
+ theme_params: {
617
+ /**
618
+ * @since v6.10
619
+ */
620
+ accent_text_color?: RGB;
621
+ /**
622
+ * @since 7.10
623
+ */
624
+ bottom_bar_bg_color?: RGB;
625
+ bg_color?: RGB;
626
+ button_color?: RGB;
627
+ button_text_color?: RGB;
628
+ /**
629
+ * @since v6.10
630
+ */
631
+ destructive_text_color?: RGB;
632
+ /**
633
+ * @since v6.10
634
+ */
635
+ header_bg_color?: RGB;
636
+ hint_color?: RGB;
637
+ link_color?: RGB;
638
+ secondary_bg_color?: RGB;
639
+ /**
640
+ * @since v6.10
641
+ */
642
+ section_bg_color?: RGB;
643
+ /**
644
+ * @since v6.10
645
+ */
646
+ section_header_text_color?: RGB;
647
+ /**
648
+ * @since v6.10
649
+ */
650
+ subtitle_text_color?: RGB;
651
+ text_color?: RGB;
652
+ [key: string]: RGB | undefined;
653
+ };
654
+ };
655
+ /**
656
+ * Occurs whenever the viewport has been changed. For example, when the user
657
+ * started dragging the application or called the expansion method.
658
+ * @see https://docs.telegram-mini-apps.com/platform/events#viewport-changed
659
+ */
660
+ viewport_changed: {
661
+ /**
662
+ * The viewport height.
663
+ */
664
+ height: number;
665
+ /**
666
+ * The viewport width.
667
+ */
668
+ width: number;
669
+ /**
670
+ * Is the viewport currently expanded.
671
+ */
672
+ is_expanded: boolean;
673
+ /**
674
+ * Is the viewport current state stable and not going to change in the next
675
+ * moment.
676
+ */
677
+ is_state_stable: boolean;
678
+ };
679
+ /**
680
+ * Occurs whenever the mini app becomes active or inactive.
681
+ *
682
+ * Active state assumes that the native Telegram client is currently working with the
683
+ * current mini application. It is important to note that this is not related to the
684
+ * mini application’s visibility, but rather its selection among other currently opened
685
+ * mini applications.
686
+ * @since v8.0
687
+ * @see https://docs.telegram-mini-apps.com/platform/events#visibility_changed
688
+ */
689
+ visibility_changed: {
690
+ /**
691
+ * Indicates if the application is currently active.
692
+ */
693
+ is_visible: boolean;
694
+ };
695
+ /**
696
+ * Application received write access request status.
697
+ * @since v6.9
698
+ * @see https://docs.telegram-mini-apps.com/platform/events#write-access-requested
699
+ */
700
+ write_access_requested: {
701
+ /**
702
+ * Request status.
703
+ */
704
+ status: WriteAccessRequestedStatus;
705
+ };
706
+ }
707
+ /**
708
+ * Mini Apps event name.
709
+ */
710
+ export type EventName = keyof Events;
711
+ /**
712
+ * Payload of the specified Mini Apps event.
713
+ */
714
+ export type EventPayload<E extends EventName> = Events[E];
715
+ export type EventWithoutPayload = {
716
+ [E in EventName]: If<IsNever<EventPayload<E>>, E, never>;
717
+ }[EventName];
718
+ export type EventWithPayload = {
719
+ [E in EventName]: undefined extends EventPayload<E> ? never : E;
720
+ }[EventName];
721
+ export {};