@vbotma/bridge 2.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +59 -0
  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/isVBMA.d.ts +31 -0
  8. package/dist/dts/env/mockVBotEnv.d.ts +60 -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 -0
  13. package/dist/dts/events/types/events.d.ts +780 -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 +53 -0
  18. package/dist/dts/index.d.ts +26 -0
  19. package/dist/dts/launch-params.d.ts +31 -0
  20. package/dist/dts/methods/captureSameReq.d.ts +10 -0
  21. package/dist/dts/methods/createPostEvent.d.ts +30 -0
  22. package/dist/dts/methods/getReleaseVersion.d.ts +15 -0
  23. package/dist/dts/methods/postEvent.d.ts +35 -0
  24. package/dist/dts/methods/postMessage.d.ts +7 -0
  25. package/dist/dts/methods/supports.d.ts +15 -0
  26. package/dist/dts/methods/types/custom-method.d.ts +59 -0
  27. package/dist/dts/methods/types/haptic-feedback.d.ts +40 -0
  28. package/dist/dts/methods/types/index.d.ts +7 -0
  29. package/dist/dts/methods/types/methods.d.ts +807 -0
  30. package/dist/dts/methods/types/misc.d.ts +27 -0
  31. package/dist/dts/methods/types/notification.d.ts +20 -0
  32. package/dist/dts/methods/types/popup.d.ts +49 -0
  33. package/dist/dts/methods/types/utils.d.ts +9 -0
  34. package/dist/dts/obj-prop-helpers.d.ts +39 -0
  35. package/dist/dts/start-param.d.ts +52 -0
  36. package/dist/dts/utils/compareVersions.d.ts +10 -0
  37. package/dist/dts/utils/invokeCustomMethod.d.ts +34 -0
  38. package/dist/dts/utils/request.d.ts +102 -0
  39. package/dist/dts/utils/request2.d.ts +62 -0
  40. package/dist/index.cjs +4 -0
  41. package/dist/index.cjs.map +1 -0
  42. package/dist/index.iife.js +4 -0
  43. package/dist/index.iife.js.map +1 -0
  44. package/dist/index.js +758 -0
  45. package/dist/index.js.map +1 -0
  46. package/package.json +54 -0
@@ -0,0 +1,780 @@
1
+ import { If, IsNever, Maybe } from '@vbotma/toolkit';
2
+ import { RGB } from '@vbotma/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.vbot-mini-apps.com/platform/events
13
+ */
14
+ export interface Events {
15
+ /**
16
+ * Accelerometer data changed.
17
+ * @since 8.0
18
+ * @see https://docs.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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
+ * VBot application attempted to extract text from clipboard.
148
+ * @since v6.4
149
+ * @see https://docs.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-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.vbot-mini-apps.com/platform/events#home_screen_failed
387
+ */
388
+ home_screen_failed: never;
389
+ /**
390
+ * An invoice was closed.
391
+ * @see https://docs.vbot-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.vbot-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.vbot-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.vbot-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.vbot-mini-apps.com/platform/events#phone-requested
470
+ */
471
+ phone_requested: {
472
+ /**
473
+ * Request status.
474
+ */
475
+ status: PhoneRequestedStatus;
476
+ };
477
+ /**
478
+ * Fired when storage access is granted and files/folders are selected.
479
+ * @since v9.3
480
+ */
481
+ storage_access_granted: {
482
+ /**
483
+ * Type of access that was granted.
484
+ */
485
+ access_type: 'file' | 'folder';
486
+ /**
487
+ * Array of selected items.
488
+ */
489
+ items: Array<{
490
+ /**
491
+ * File or folder name.
492
+ */
493
+ name: string;
494
+ /**
495
+ * Full path to the file/folder.
496
+ */
497
+ path: string;
498
+ /**
499
+ * File size in bytes (for files only).
500
+ */
501
+ size?: number;
502
+ /**
503
+ * MIME type (for files only).
504
+ */
505
+ type?: string;
506
+ /**
507
+ * Base64-encoded file content (if read_content was true).
508
+ */
509
+ content?: string;
510
+ /**
511
+ * Last modified timestamp.
512
+ */
513
+ last_modified?: number;
514
+ }>;
515
+ };
516
+ /**
517
+ * Fired when storage access is denied or canceled by user.
518
+ * @since v9.3
519
+ */
520
+ storage_access_denied: {
521
+ /**
522
+ * Reason for denial.
523
+ */
524
+ reason: 'permission_denied' | 'user_canceled' | 'file_too_large' | 'error';
525
+ /**
526
+ * Optional error message.
527
+ */
528
+ message?: string;
529
+ };
530
+ /**
531
+ * Popup was closed.
532
+ * @see https://docs.vbot-mini-apps.com/platform/events#popup-closed
533
+ */
534
+ popup_closed: {
535
+ /**
536
+ * Identifier of the clicked button. In case, the popup was closed without
537
+ * clicking any button, this property will be omitted.
538
+ */
539
+ button_id?: string;
540
+ };
541
+ /**
542
+ * Failed to send a prepared message.
543
+ * @since 8.0
544
+ * @see https://docs.vbot-mini-apps.com/platform/events#prepare-message-failed
545
+ */
546
+ prepared_message_failed: {
547
+ /**
548
+ * Occurred error.
549
+ */
550
+ error: string;
551
+ };
552
+ /**
553
+ * A prepared message was sent.
554
+ * @since 8.0
555
+ * @see https://docs.vbot-mini-apps.com/platform/events#prepare-message-sent
556
+ */
557
+ prepared_message_sent: never;
558
+ /**
559
+ * The QR scanner scanned some QR and extracted its content.
560
+ * @param payload - event payload.
561
+ * @since v6.4
562
+ * @see https://docs.vbot-mini-apps.com/platform/events#qr-text-received
563
+ */
564
+ qr_text_received: {
565
+ /**
566
+ * Data extracted from the QR.
567
+ */
568
+ data: string;
569
+ };
570
+ /**
571
+ * Parent iframe requested current iframe reload.
572
+ * @see https://docs.vbot-mini-apps.com/platform/events#reload-iframe
573
+ */
574
+ reload_iframe: never;
575
+ /**
576
+ * User initiated a pull-to-refresh gesture in the native app.
577
+ * @since v9.2
578
+ * @see https://docs.vbot-mini-apps.com/platform/events#refresh-requested
579
+ */
580
+ refresh_requested: never;
581
+ /**
582
+ * Occurs whenever the device's safe area insets change
583
+ * (e.g., due to orientation change or screen adjustments).
584
+ * @since Mini Apps v8.0
585
+ * @see https://docs.vbot-mini-apps.com/platform/events#safe_area_changed
586
+ * */
587
+ safe_area_changed: SafeAreaInsets;
588
+ /**
589
+ * QR scanner was closed.
590
+ * @since v6.4
591
+ * @see https://docs.vbot-mini-apps.com/platform/events#scan-qr-popup-closed
592
+ */
593
+ scan_qr_popup_closed: never;
594
+ /**
595
+ * User clicked the secondary button.
596
+ * @since v7.10
597
+ * @see https://docs.vbot-mini-apps.com/platform/events#secondary-button-pressed
598
+ */
599
+ secondary_button_pressed: never;
600
+ /**
601
+ * Device's secure storage was cleared.
602
+ * @since v9.0
603
+ * @see https://docs.vbot-mini-apps.com/platform/events#secure-storage-cleared
604
+ */
605
+ secure_storage_cleared: WithReqId;
606
+ /**
607
+ * An error occurred while working with the device's secure storage.
608
+ * @since v9.0
609
+ * @see https://docs.vbot-mini-apps.com/platform/events#secure-storage-failed
610
+ */
611
+ secure_storage_failed: WithReqId<{
612
+ /**
613
+ * An occurred error.
614
+ */
615
+ error?: string;
616
+ }>;
617
+ /**
618
+ * A value from the device's secure storage was retrieved.
619
+ * @since v9.0
620
+ * @see https://docs.vbot-mini-apps.com/platform/events#secure-storage-key-received
621
+ */
622
+ secure_storage_key_received: WithReqId<{
623
+ /**
624
+ * A retrieved value.
625
+ */
626
+ value: string | null;
627
+ /**
628
+ * True if this value can be restored.
629
+ */
630
+ can_restore?: boolean;
631
+ }>;
632
+ /**
633
+ * A value from the device's secure storage was restored.
634
+ * @since v9.0
635
+ * @see https://docs.vbot-mini-apps.com/platform/events#secure-storage-key-restored
636
+ */
637
+ secure_storage_key_restored: WithReqId<{
638
+ /**
639
+ * A restored value.
640
+ */
641
+ value: string | null;
642
+ }>;
643
+ /**
644
+ * A value in the device's secure storage was saved.
645
+ * @since v9.0
646
+ * @see https://docs.vbot-mini-apps.com/platform/events#secure-storage-key-saved
647
+ */
648
+ secure_storage_key_saved: WithReqId;
649
+ /**
650
+ * The event which is usually sent by the Telegram web application. Its
651
+ * payload represents
652
+ * `<style/>` tag html content, a developer could use. The stylesheet
653
+ * described in the payload will help the developer to stylize the app
654
+ * scrollbar (but he is still able to do it himself).
655
+ * @see https://docs.vbot-mini-apps.com/platform/events#set-custom-style
656
+ */
657
+ set_custom_style: string;
658
+ /**
659
+ * Occurs when the Settings Button was pressed.
660
+ * @since v6.1
661
+ * @see https://docs.vbot-mini-apps.com/platform/events#settings-button-pressed
662
+ */
663
+ settings_button_pressed: never;
664
+ /**
665
+ * Occurs whenever theme settings are changed in the user's Telegram app
666
+ * (including switching to night mode).
667
+ * @see https://docs.vbot-mini-apps.com/platform/events#theme-changed
668
+ */
669
+ theme_changed: {
670
+ /**
671
+ * Map where the key is a theme stylesheet key and value is the
672
+ * corresponding color in
673
+ * `#RRGGBB` format.
674
+ */
675
+ theme_params: {
676
+ /**
677
+ * @since v6.10
678
+ */
679
+ accent_text_color?: RGB;
680
+ /**
681
+ * @since 7.10
682
+ */
683
+ bottom_bar_bg_color?: RGB;
684
+ bg_color?: RGB;
685
+ button_color?: RGB;
686
+ button_text_color?: RGB;
687
+ /**
688
+ * @since v6.10
689
+ */
690
+ destructive_text_color?: RGB;
691
+ /**
692
+ * @since v6.10
693
+ */
694
+ header_bg_color?: RGB;
695
+ hint_color?: RGB;
696
+ link_color?: RGB;
697
+ secondary_bg_color?: RGB;
698
+ /**
699
+ * @since v6.10
700
+ */
701
+ section_bg_color?: RGB;
702
+ /**
703
+ * @since v6.10
704
+ */
705
+ section_header_text_color?: RGB;
706
+ /**
707
+ * @since v6.10
708
+ */
709
+ subtitle_text_color?: RGB;
710
+ text_color?: RGB;
711
+ [key: string]: RGB | undefined;
712
+ };
713
+ };
714
+ /**
715
+ * Occurs whenever the viewport has been changed. For example, when the user
716
+ * started dragging the application or called the expansion method.
717
+ * @see https://docs.vbot-mini-apps.com/platform/events#viewport-changed
718
+ */
719
+ viewport_changed: {
720
+ /**
721
+ * The viewport height.
722
+ */
723
+ height: number;
724
+ /**
725
+ * The viewport width.
726
+ */
727
+ width: number;
728
+ /**
729
+ * Is the viewport currently expanded.
730
+ */
731
+ is_expanded: boolean;
732
+ /**
733
+ * Is the viewport current state stable and not going to change in the next
734
+ * moment.
735
+ */
736
+ is_state_stable: boolean;
737
+ };
738
+ /**
739
+ * Occurs whenever the mini app becomes active or inactive.
740
+ *
741
+ * Active state assumes that the native VBot client is currently working with the
742
+ * current mini application. It is important to note that this is not related to the
743
+ * mini application’s visibility, but rather its selection among other currently opened
744
+ * mini applications.
745
+ * @since v8.0
746
+ * @see https://docs.vbot-mini-apps.com/platform/events#visibility_changed
747
+ */
748
+ visibility_changed: {
749
+ /**
750
+ * Indicates if the application is currently active.
751
+ */
752
+ is_visible: boolean;
753
+ };
754
+ /**
755
+ * Application received write access request status.
756
+ * @since v6.9
757
+ * @see https://docs.vbot-mini-apps.com/platform/events#write-access-requested
758
+ */
759
+ write_access_requested: {
760
+ /**
761
+ * Request status.
762
+ */
763
+ status: WriteAccessRequestedStatus;
764
+ };
765
+ }
766
+ /**
767
+ * Mini Apps event name.
768
+ */
769
+ export type EventName = keyof Events;
770
+ /**
771
+ * Payload of the specified Mini Apps event.
772
+ */
773
+ export type EventPayload<E extends EventName> = Events[E];
774
+ export type EventWithoutPayload = {
775
+ [E in EventName]: If<IsNever<EventPayload<E>>, E, never>;
776
+ }[EventName];
777
+ export type EventWithPayload = {
778
+ [E in EventName]: undefined extends EventPayload<E> ? never : E;
779
+ }[EventName];
780
+ export {};