@apiteam/twa-bridge 7.1.0 → 7.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/solid/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as solid_js from 'solid-js';
2
+ import { Context, JSX, Component } from 'solid-js';
2
3
 
3
4
  declare const createIsViewportChanged: () => solid_js.Accessor<{
4
5
  height: number;
@@ -7,7 +8,7 @@ declare const createIsViewportChanged: () => solid_js.Accessor<{
7
8
  is_state_stable: boolean;
8
9
  }>;
9
10
 
10
- type Close = () => {
11
+ type Close = (eventData?: SenderData[typeof MethodClose]) => {
11
12
  status: boolean | typeof NOT_SUPPORTED;
12
13
  };
13
14
  /**
@@ -21,7 +22,7 @@ declare const close: Close;
21
22
  */
22
23
  declare const supportClose: () => boolean;
23
24
 
24
- type CloseScanQrPopup = () => {
25
+ type CloseScanQrPopup = (eventData?: SenderData[typeof MethodCloseScanQrPopup]) => {
25
26
  status: boolean | typeof NOT_SUPPORTED;
26
27
  };
27
28
  /**
@@ -39,14 +40,7 @@ declare const closeScanQrPopup: CloseScanQrPopup;
39
40
  */
40
41
  declare const supportCloseScanQrPopup: () => boolean;
41
42
 
42
- type DataSend = (eventData: {
43
- /**
44
- ** EN: Data to send to a bot. Should not have size of more than 4096 bytes.
45
-
46
- ** RU: Данные для отправки боту. Не должен иметь размер более 4096 байт.
47
- */
48
- data: string;
49
- }) => {
43
+ type DataSend = (eventData: SenderData[typeof MethodDataSend]) => {
50
44
  status: boolean | typeof NOT_SUPPORTED;
51
45
  };
52
46
  /**
@@ -72,7 +66,7 @@ declare const dataSend: DataSend;
72
66
  */
73
67
  declare const supportDataSend: () => boolean;
74
68
 
75
- type Expand = () => {
69
+ type Expand = (props?: SenderData[typeof MethodExpand]) => {
76
70
  status: boolean | typeof NOT_SUPPORTED;
77
71
  };
78
72
  /**
@@ -86,12 +80,7 @@ declare const expand: Expand;
86
80
  */
87
81
  declare const supportExpand: () => boolean;
88
82
 
89
- type IframeReady = (eventData: {
90
- /**
91
- * Optional. True, if current Mini App supports native reloading.
92
- */
93
- reload_supported?: boolean;
94
- }) => {
83
+ type IframeReady = (eventData: SenderData[typeof MethodIframeReady]) => {
95
84
  status: boolean | typeof NOT_SUPPORTED;
96
85
  };
97
86
  /**
@@ -107,7 +96,7 @@ declare const iframeReady: IframeReady;
107
96
  */
108
97
  declare const supportIframeReady: () => boolean;
109
98
 
110
- type IframeWillReload = () => {
99
+ type IframeWillReload = (eventData: SenderData[typeof MethodIframeReady]) => {
111
100
  status: boolean | typeof NOT_SUPPORTED;
112
101
  };
113
102
  /**
@@ -121,22 +110,7 @@ declare const iframeWillReload: IframeWillReload;
121
110
  */
122
111
  declare const supportIframeWillReload: () => boolean;
123
112
 
124
- type InvokeCustomMethod = (eventData: {
125
- /**
126
- * Current invocation unique identifier.
127
- *
128
- * Default: () => randomReqId
129
- */
130
- req_id?: string;
131
- /**
132
- * Method name.
133
- */
134
- method: string;
135
- /**
136
- * Parameters according to method.
137
- */
138
- params: unknown;
139
- }) => Promise<{
113
+ type InvokeCustomMethod = (eventData: SenderData[typeof MethodInvokeCustomMethod]) => Promise<{
140
114
  status: boolean | typeof NOT_SUPPORTED;
141
115
  data?: EventsData[typeof EventCustomMethodInvoked];
142
116
  }>;
@@ -149,12 +123,7 @@ declare const invokeCustomMethod: InvokeCustomMethod;
149
123
  */
150
124
  declare const supportInvokeCustomMethod: () => boolean;
151
125
 
152
- type OpenInvoice = (eventData: {
153
- /**
154
- * Invoice unique identifier.
155
- */
156
- slug: string;
157
- }) => {
126
+ type OpenInvoice = (eventData: SenderData[typeof MethodOpenInvoice]) => {
158
127
  status: boolean | typeof NOT_SUPPORTED;
159
128
  };
160
129
  /**
@@ -170,16 +139,7 @@ declare const openInvoice: OpenInvoice;
170
139
  */
171
140
  declare const supportOpenInvoice: () => boolean;
172
141
 
173
- type OpenLink = (eventData: {
174
- /**
175
- * URL to be opened by Telegram application. Should be a full path with https protocol.
176
- */
177
- url: string;
178
- /**
179
- * Optional. Link will be opened in Instant View mode if possible.
180
- */
181
- try_instant_view?: boolean;
182
- }) => {
142
+ type OpenLink = (eventData: SenderData[typeof MethodOpenLink]) => {
183
143
  status: boolean | typeof NOT_SUPPORTED;
184
144
  };
185
145
  /**
@@ -195,31 +155,7 @@ declare const openLink: OpenLink;
195
155
  */
196
156
  declare const supportOpenLink: () => boolean;
197
157
 
198
- type PopupButton = {
199
- /**
200
- * Identifier of the button, 0-64 characters.
201
- */
202
- id: string;
203
- type: 'default' | 'destructive' | 'ok' | 'close' | 'cancel';
204
- /**
205
- * The text to be displayed on the button, 0-64 characters. Ignored when type is ok, close or cancel.
206
- */
207
- text: string;
208
- };
209
- type OpenPopup = (eventData: {
210
- /**
211
- * The text to be displayed in the popup title, 0-64 characters
212
- */
213
- title: string;
214
- /**
215
- * The message to be displayed in the body of the popup, 1-256 characters
216
- */
217
- message: string;
218
- /**
219
- * List of buttons to be displayed in the popup, 1-3 buttons
220
- */
221
- buttons: PopupButton[];
222
- }) => Promise<{
158
+ type OpenPopup = (eventData: SenderData[typeof MethodOpenPopup]) => Promise<{
223
159
  status: boolean | typeof NOT_SUPPORTED;
224
160
  data?: EventsData['popup_closed'];
225
161
  }>;
@@ -234,16 +170,7 @@ declare const openPopup: OpenPopup;
234
170
  */
235
171
  declare const supportOpenPopup: () => boolean;
236
172
 
237
- type OpenScanQrPopup = (eventData: {
238
- /**
239
- * Optional. Text to be displayed in the QR scanner.
240
- */
241
- text?: string;
242
- /**
243
- * [Custom] Optional. Сlose QR scanner after receiving data
244
- */
245
- is_close?: boolean;
246
- }) => Promise<{
173
+ type OpenScanQrPopup = (eventData: SenderData[typeof MethodOpenScanQrPopup]) => Promise<{
247
174
  status: boolean | typeof NOT_SUPPORTED | 'closed';
248
175
  data?: EventsData[typeof EventQrTextReceived];
249
176
  }>;
@@ -262,14 +189,7 @@ declare const openScanQrPopup: OpenScanQrPopup;
262
189
  */
263
190
  declare const supportOpenScanQrPopup: () => boolean;
264
191
 
265
- type OpenTgLink = (eventData: {
266
- /**
267
- * Should be a value taken from the link of this format: https://t.me/{path_full}.
268
- *
269
- * Can additionally contain query parameters.
270
- */
271
- path_full: string;
272
- }) => {
192
+ type OpenTgLink = (eventData: SenderData[typeof MethodOpenTgLink]) => {
273
193
  status: boolean | typeof NOT_SUPPORTED;
274
194
  };
275
195
  /**
@@ -285,14 +205,7 @@ declare const openTgLink: OpenTgLink;
285
205
  */
286
206
  declare const supportOpenTgLink: () => boolean;
287
207
 
288
- type ReadTextFromClipboard = (eventData: {
289
- /**
290
- * Unique request identifier. Should be any unique string to handle the generated event appropriately.
291
- *
292
- * Default: () => randomReqId
293
- */
294
- req_id?: string;
295
- }) => Promise<{
208
+ type ReadTextFromClipboard = (eventData?: SenderData[typeof MethodReadTextFromClipboard]) => Promise<{
296
209
  status: boolean | typeof NOT_SUPPORTED;
297
210
  data?: EventsData[typeof EventClipboardTextReceived];
298
211
  }>;
@@ -309,7 +222,7 @@ declare const readTextFromClipboard: ReadTextFromClipboard;
309
222
  */
310
223
  declare const supportReadTextFromClipboard: () => boolean;
311
224
 
312
- type Ready = () => {
225
+ type Ready = (eventData?: SenderData[typeof MethodReady]) => {
313
226
  status: boolean | typeof NOT_SUPPORTED;
314
227
  };
315
228
  /**
@@ -325,7 +238,7 @@ declare const ready: Ready;
325
238
  */
326
239
  declare const supportReady: () => boolean;
327
240
 
328
- type RequestPhone = () => Promise<{
241
+ type RequestPhone = (eventData?: SenderData[typeof MethodRequestPhone]) => Promise<{
329
242
  status: boolean | typeof NOT_SUPPORTED;
330
243
  }>;
331
244
  /**
@@ -339,7 +252,7 @@ declare const requestPhone: RequestPhone;
339
252
  */
340
253
  declare const supportRequestPhone: () => boolean;
341
254
 
342
- type RequestTheme = () => {
255
+ type RequestTheme = (eventData?: SenderData[typeof MethodRequestTheme]) => {
343
256
  status: boolean | typeof NOT_SUPPORTED;
344
257
  };
345
258
  /**
@@ -355,7 +268,7 @@ declare const requestTheme: RequestTheme;
355
268
  */
356
269
  declare const supportRequestTheme: () => boolean;
357
270
 
358
- type RequestViewport = () => {
271
+ type RequestViewport = (eventData?: SenderData[typeof MethodRequestViewport]) => {
359
272
  status: boolean | typeof NOT_SUPPORTED;
360
273
  };
361
274
  /**
@@ -371,7 +284,7 @@ declare const requestViewport: RequestViewport;
371
284
  */
372
285
  declare const supportRequestViewport: () => boolean;
373
286
 
374
- type RequestWriteAccess = () => {
287
+ type RequestWriteAccess = (eventData?: SenderData[typeof MethodRequestWriteAccess]) => {
375
288
  status: boolean | typeof NOT_SUPPORTED;
376
289
  };
377
290
  /**
@@ -385,12 +298,7 @@ declare const requestWriteAccess: RequestWriteAccess;
385
298
  */
386
299
  declare const supportRequestWriteAccess: () => boolean;
387
300
 
388
- type SetBackgroundColor = (eventData: {
389
- /**
390
- * The Mini App background color in #RRGGBB format.
391
- */
392
- color: string;
393
- }) => {
301
+ type SetBackgroundColor = (eventData: SenderData[typeof MethodSetBackgroundColor]) => {
394
302
  status: boolean | typeof NOT_SUPPORTED;
395
303
  };
396
304
  /**
@@ -404,16 +312,7 @@ declare const setBackgroundColor: SetBackgroundColor;
404
312
  */
405
313
  declare const supportSetBackgroundColor: () => boolean;
406
314
 
407
- type SetHeaderColor = (eventData: {
408
- /**
409
- * The Mini App header color key. Could be either bg_color or secondary_bg_color.
410
- */
411
- color_key?: 'bg_color' | 'secondary_bg_color';
412
- /**
413
- * Color in HEX format.
414
- */
415
- color?: string;
416
- }) => {
315
+ type SetHeaderColor = (eventData: SenderData[typeof MethodSetHeaderColor]) => {
417
316
  status: boolean | typeof NOT_SUPPORTED;
418
317
  };
419
318
  /**
@@ -427,16 +326,7 @@ declare const setHeaderColor: SetHeaderColor;
427
326
  */
428
327
  declare const supportSetHeaderColor: () => boolean;
429
328
 
430
- type SetBottomBarColor = (eventData: {
431
- /**
432
- * The Mini App header color key. Could be either bg_color or secondary_bg_color.
433
- */
434
- color_key?: 'bg_color' | 'secondary_bg_color' | 'bottom_bar_bg_color';
435
- /**
436
- * Color in HEX format.
437
- */
438
- color?: string;
439
- }) => {
329
+ type SetBottomBarColor = (eventData: SenderData[typeof MethodSetBottomBarColor]) => {
440
330
  status: boolean | typeof NOT_SUPPORTED;
441
331
  };
442
332
  /**
@@ -448,12 +338,7 @@ declare const setBottomBarColor: SetBottomBarColor;
448
338
  */
449
339
  declare const supportSetBottomBarColor: () => boolean;
450
340
 
451
- type SetupBackButton = (eventData: {
452
- /**
453
- * Should the Back Button be visible.
454
- */
455
- is_visible: boolean;
456
- }) => {
341
+ type SetupBackButton = (eventData: SenderData[typeof MethodSetupBackButton]) => {
457
342
  status: boolean | typeof NOT_SUPPORTED;
458
343
  };
459
344
  /**
@@ -467,12 +352,7 @@ declare const setupBackButton: SetupBackButton;
467
352
  */
468
353
  declare const supportSetupBackButton: () => boolean;
469
354
 
470
- type SetupClosingBehavior = (eventData: {
471
- /**
472
- * Will user be prompted in case, an application is going to be closed.
473
- */
474
- need_confirmation: boolean;
475
- }) => {
355
+ type SetupClosingBehavior = (eventData: SenderData[typeof MethodSetupClosingBehavior]) => {
476
356
  status: boolean | typeof NOT_SUPPORTED;
477
357
  };
478
358
  /**
@@ -486,32 +366,7 @@ declare const setupClosingBehavior: SetupClosingBehavior;
486
366
  */
487
367
  declare const supportSetupClosingBehavior: () => boolean;
488
368
 
489
- type SetupMainButton = (eventData: {
490
- /**
491
- * Optional. Should the Main Button be displayed.
492
- */
493
- is_visible?: boolean;
494
- /**
495
- * Optional. Should the Main Button be enabled.
496
- */
497
- is_active?: boolean;
498
- /**
499
- * Optional. Should loader inside the Main Button be displayed. Use this property in case, some operation takes time. This loader will make user notified about it.
500
- */
501
- is_progress_visible?: boolean;
502
- /**
503
- * Optional. Text inside the Main Button.
504
- */
505
- text?: string;
506
- /**
507
- * Optional. The Main Button background color in #RRGGBB format.
508
- */
509
- color?: string;
510
- /**
511
- * Optional. The Main Button text color in #RRGGBB format.
512
- */
513
- text_color?: string;
514
- }) => {
369
+ type SetupMainButton = (eventData: SenderData[typeof MethodSetupMainButton]) => {
515
370
  status: boolean | typeof NOT_SUPPORTED;
516
371
  };
517
372
  /**
@@ -525,12 +380,7 @@ declare const setupMainButton: SetupMainButton;
525
380
  */
526
381
  declare const supportSetupMainButton: () => boolean;
527
382
 
528
- type SetupSettingsButton = (eventData: {
529
- /**
530
- * Should the Settings Button be displayed.
531
- */
532
- is_visible: boolean;
533
- }) => {
383
+ type SetupSettingsButton = (eventData: SenderData[typeof MethodSetupSettingsButton]) => {
534
384
  status: boolean | typeof NOT_SUPPORTED;
535
385
  };
536
386
  /**
@@ -544,18 +394,7 @@ declare const setupSettingsButton: SetupSettingsButton;
544
394
  */
545
395
  declare const supportSetupSettingsButton: () => boolean;
546
396
 
547
- type SwitchInlineQuery = (eventData: {
548
- /**
549
- * Text which should be inserted in the input after the current bot name. Max length is 256 symbols.
550
- */
551
- query: string;
552
- /**
553
- * List of chat types which could be chosen to send the message. Could be empty list. Values:
554
- *
555
- * users, bots, groups, channels
556
- */
557
- chat_types: ['users', 'bots', 'groups', 'channels'];
558
- }) => {
397
+ type SwitchInlineQuery = (eventData: SenderData[typeof MethodSwitchInlineQuery]) => {
559
398
  status: boolean | typeof NOT_SUPPORTED;
560
399
  };
561
400
  /**
@@ -573,42 +412,7 @@ declare const switchInlineQuery: SwitchInlineQuery;
573
412
  */
574
413
  declare const supportSwitchInlineQuery: () => boolean;
575
414
 
576
- type TriggerHapticFeedback = (eventData: {
577
- /**
578
- * Type of haptic event. Values:
579
- *
580
- * impact - when there's a collision involving UI components.
581
- *
582
- * notification - when some action execution has been completed.
583
- *
584
- * selection_change - when the user changes their selection.
585
- */
586
- type: 'impact' | 'notification' | 'selection_change';
587
- /**
588
- * Required when type is impact. Values:
589
- *
590
- * light - indicates a collision between small or lightweight UI objects
591
- *
592
- * medium - indicates a collision between medium-sized or medium-weight UI objects
593
- *
594
- * heavy - indicates a collision between large or heavyweight UI objects
595
- *
596
- * rigid - indicates a collision between hard or inflexible UI objects
597
- *
598
- * soft - indicates a collision between soft or flexible UI objects
599
- */
600
- impact_style: 'light' | 'medium' | 'heavy' | 'rigid' | 'soft';
601
- /**
602
- * Required when type is notification. Values:
603
- *
604
- * error - indicates that a task or action has failed
605
- *
606
- * success - indicates that a task or action has completed successfully
607
- *
608
- * warning - indicates that a task or action produced a warning
609
- */
610
- notification_type: 'error' | 'success' | 'warning';
611
- }) => {
415
+ type TriggerHapticFeedback = (eventData: SenderData[typeof MethodTriggerHapticFeedback]) => {
612
416
  status: boolean | typeof NOT_SUPPORTED;
613
417
  };
614
418
  /**
@@ -640,6 +444,7 @@ declare const supportSessionStorageSet: () => boolean;
640
444
  type SessionStorageGet = ({ key }: {
641
445
  key: string;
642
446
  }) => {
447
+ is_json: boolean;
643
448
  status: boolean | typeof NOT_SUPPORTED;
644
449
  value?: any;
645
450
  };
@@ -652,9 +457,7 @@ declare const sessionStorageGet: SessionStorageGet;
652
457
  */
653
458
  declare const supportSessionStorageGet: () => boolean;
654
459
 
655
- type SetupSwipeBehavior = ({ allow_vertical_swipe, }: {
656
- allow_vertical_swipe: boolean;
657
- }) => {
460
+ type SetupSwipeBehavior = (eventData: SenderData[typeof MethodSetupSwipeBehavior]) => {
658
461
  status: boolean | typeof NOT_SUPPORTED;
659
462
  };
660
463
  /**
@@ -738,7 +541,7 @@ type Chat = {
738
541
  */
739
542
  username?: string;
740
543
  };
741
- type GetInitData = () => null | {
544
+ type GetInitData = {
742
545
  /**
743
546
  * The date the initialization data was created.
744
547
  *
@@ -791,7 +594,7 @@ type GetInitData = () => null | {
791
594
  * Optional. An object containing information about the current user.
792
595
  */
793
596
  user?: User;
794
- };
597
+ } | undefined;
795
598
  /**
796
599
  * In the list of launch parameters, initialization data is located in the tgWebAppData parameter.
797
600
  *
@@ -799,7 +602,53 @@ type GetInitData = () => null | {
799
602
  *
800
603
  * Original: https://docs.telegram-mini-apps.com/platform/launch-parameters/init-data#init-data
801
604
  */
802
- declare const getInitData: GetInitData;
605
+ declare const getInitData: () => GetInitData;
606
+
607
+ type ThemeParams = {
608
+ bg_color: string;
609
+ text_color: string;
610
+ hint_color: string;
611
+ link_color: string;
612
+ button_color: string;
613
+ button_text_color: string;
614
+ /**
615
+ * Bot API 6.1+
616
+ */
617
+ secondary_bg_color: string;
618
+ /**
619
+ * Bot API 7.0+
620
+ */
621
+ header_bg_color: string;
622
+ /**
623
+ * Bot API 7.10+
624
+ */
625
+ bottom_bar_bg_color: string;
626
+ /**
627
+ * Bot API 7.0+
628
+ */
629
+ accent_text_color: string;
630
+ /**
631
+ * Bot API 7.0+
632
+ */
633
+ section_bg_color: string;
634
+ /**
635
+ * Bot API 7.0+
636
+ */
637
+ section_header_text_color: string;
638
+ /**
639
+ * Bot API 7.6+
640
+ */
641
+ section_separator_color: string;
642
+ /**
643
+ * Bot API 7.0+
644
+ */
645
+ subtitle_text_color: string;
646
+ /**
647
+ * Bot API 7.0+
648
+ */
649
+ destructive_text_color: string;
650
+ };
651
+ declare const getThemeParams: (theme_params: ThemeParams) => Record<string, string>;
803
652
 
804
653
  type Sender = (eventType: string, eventData?: any) => void;
805
654
  /**
@@ -810,9 +659,291 @@ type Sender = (eventType: string, eventData?: any) => void;
810
659
  */
811
660
  declare const sender: Sender;
812
661
 
662
+ declare const MethodInvokeCustomMethod = "web_app_invoke_custom_method";
663
+ declare const MethodOpenScanQrPopup = "web_app_open_scan_qr_popup";
664
+ declare const MethodReadTextFromClipboard = "web_app_read_text_from_clipboard";
665
+ declare const MethodRequestPhone = "web_app_request_phone";
666
+ declare const MethodClose = "web_app_close";
667
+ declare const MethodCloseScanQrPopup = "web_app_close_scan_qr_popup";
668
+ declare const MethodDataSend = "web_app_data_send";
669
+ declare const MethodExpand = "web_app_expand";
670
+ declare const MethodIframeReady = "iframe_ready";
671
+ declare const MethodIframeWillReload = "iframe_will_reload";
672
+ declare const MethodOpenInvoice = "web_app_open_invoice";
673
+ declare const MethodOpenLink = "web_app_open_link";
674
+ declare const MethodOpenPopup = "web_app_open_popup";
675
+ declare const MethodOpenTgLink = "web_app_open_tg_link";
676
+ declare const MethodReady = "web_app_ready";
677
+ declare const MethodRequestTheme = "web_app_request_theme";
678
+ declare const MethodRequestViewport = "web_app_request_viewport";
679
+ declare const MethodRequestWriteAccess = "web_app_request_write_access";
680
+ declare const MethodSetBackgroundColor = "web_app_set_background_color";
681
+ declare const MethodSetHeaderColor = "web_app_set_header_color";
682
+ declare const MethodSetBottomBarColor = "web_app_set_bottom_bar_color";
683
+ declare const MethodSetupBackButton = "web_app_setup_back_button";
684
+ declare const MethodSetupClosingBehavior = "web_app_setup_closing_behavior";
685
+ declare const MethodSetupMainButton = "web_app_setup_main_button";
686
+ declare const MethodSetupSettingsButton = "web_app_setup_settings_button";
687
+ declare const MethodSwitchInlineQuery = "web_app_switch_inline_query";
688
+ declare const MethodTriggerHapticFeedback = "web_app_trigger_haptic_feedback";
689
+ declare const MethodSetupSwipeBehavior = "web_app_setup_swipe_behavior";
690
+ type PopupButton = {
691
+ /**
692
+ * Identifier of the button, 0-64 characters.
693
+ */
694
+ id: string;
695
+ type: 'default' | 'destructive' | 'ok' | 'close' | 'cancel';
696
+ /**
697
+ * The text to be displayed on the button, 0-64 characters. Ignored when type is ok, close or cancel.
698
+ */
699
+ text: string;
700
+ };
701
+ type SenderData = {
702
+ [MethodInvokeCustomMethod]: {
703
+ /**
704
+ * Current invocation unique identifier.
705
+ *
706
+ * Default: () => randomReqId
707
+ */
708
+ req_id?: string;
709
+ /**
710
+ * Method name.
711
+ */
712
+ method: string;
713
+ /**
714
+ * Parameters according to method.
715
+ */
716
+ params: unknown;
717
+ };
718
+ [MethodOpenScanQrPopup]: {
719
+ /**
720
+ * Optional. Text to be displayed in the QR scanner.
721
+ */
722
+ text?: string;
723
+ /**
724
+ * [Custom] Optional. Сlose QR scanner after receiving data
725
+ */
726
+ is_close?: boolean;
727
+ };
728
+ [MethodReadTextFromClipboard]: {
729
+ /**
730
+ * Unique request identifier. Should be any unique string to handle the generated event appropriately.
731
+ *
732
+ * Default: () => randomReqId
733
+ */
734
+ req_id?: string;
735
+ };
736
+ [MethodRequestPhone]: undefined;
737
+ [MethodClose]: undefined;
738
+ [MethodCloseScanQrPopup]: undefined;
739
+ [MethodDataSend]: {
740
+ /**
741
+ ** EN: Data to send to a bot. Should not have size of more than 4096 bytes.
742
+
743
+ ** RU: Данные для отправки боту. Не должен иметь размер более 4096 байт.
744
+ */
745
+ data: string;
746
+ };
747
+ [MethodExpand]: undefined;
748
+ [MethodIframeReady]: {
749
+ /**
750
+ * Optional. True, if current Mini App supports native reloading.
751
+ */
752
+ reload_supported?: boolean;
753
+ };
754
+ [MethodIframeWillReload]: undefined;
755
+ [MethodOpenInvoice]: {
756
+ /**
757
+ * Invoice unique identifier.
758
+ */
759
+ slug: string;
760
+ };
761
+ [MethodOpenLink]: {
762
+ /**
763
+ * URL to be opened by Telegram application. Should be a full path with https protocol.
764
+ */
765
+ url: string;
766
+ /**
767
+ * Optional. Link will be opened in Instant View mode if possible.
768
+ */
769
+ try_instant_view?: boolean;
770
+ };
771
+ [MethodOpenPopup]: {
772
+ /**
773
+ * The text to be displayed in the popup title, 0-64 characters
774
+ */
775
+ title: string;
776
+ /**
777
+ * The message to be displayed in the body of the popup, 1-256 characters
778
+ */
779
+ message: string;
780
+ /**
781
+ * List of buttons to be displayed in the popup, 1-3 buttons
782
+ */
783
+ buttons: PopupButton[];
784
+ };
785
+ [MethodOpenTgLink]: {
786
+ /**
787
+ * Should be a value taken from the link of this format: https://t.me/{path_full}.
788
+ *
789
+ * Can additionally contain query parameters.
790
+ */
791
+ path_full: string;
792
+ };
793
+ [MethodReady]: undefined;
794
+ [MethodRequestTheme]: undefined;
795
+ [MethodRequestViewport]: undefined;
796
+ [MethodRequestWriteAccess]: undefined;
797
+ [MethodSetBackgroundColor]: {
798
+ /**
799
+ * The Mini App background color in #RRGGBB format.
800
+ */
801
+ color: string;
802
+ };
803
+ [MethodSetHeaderColor]: {
804
+ /**
805
+ * The Mini App header color key. Could be either bg_color or secondary_bg_color.
806
+ */
807
+ color_key: 'bg_color' | 'secondary_bg_color';
808
+ color?: undefined;
809
+ } | {
810
+ /**
811
+ * Color in HEX format.
812
+ */
813
+ color: string;
814
+ color_key?: undefined;
815
+ };
816
+ [MethodSetBottomBarColor]: {
817
+ /**
818
+ * The Mini App header color key. Could be either bg_color or secondary_bg_color.
819
+ */
820
+ color_key: 'bg_color' | 'secondary_bg_color' | 'bottom_bar_bg_color';
821
+ color?: undefined;
822
+ } | {
823
+ /**
824
+ * Color in HEX format.
825
+ */
826
+ color: string;
827
+ color_key?: undefined;
828
+ };
829
+ [MethodSetupBackButton]: {
830
+ /**
831
+ * Should the Back Button be visible.
832
+ */
833
+ is_visible: boolean;
834
+ };
835
+ [MethodSetupClosingBehavior]: {
836
+ /**
837
+ * Will user be prompted in case, an application is going to be closed.
838
+ */
839
+ need_confirmation: boolean;
840
+ };
841
+ [MethodSetupMainButton]: {
842
+ /**
843
+ * Optional. Should the Main Button be displayed.
844
+ */
845
+ is_visible?: boolean;
846
+ /**
847
+ * Optional. Should the Main Button be enabled.
848
+ */
849
+ is_active?: boolean;
850
+ /**
851
+ * Optional. Should loader inside the Main Button be displayed. Use this property in case, some operation takes time. This loader will make user notified about it.
852
+ */
853
+ is_progress_visible?: boolean;
854
+ /**
855
+ * Optional. Text inside the Main Button.
856
+ */
857
+ text?: string;
858
+ /**
859
+ * Optional. The Main Button background color in #RRGGBB format.
860
+ */
861
+ color?: string;
862
+ /**
863
+ * Optional. The Main Button text color in #RRGGBB format.
864
+ */
865
+ text_color?: string;
866
+ };
867
+ [MethodSetupSettingsButton]: {
868
+ /**
869
+ * Should the Settings Button be displayed.
870
+ */
871
+ is_visible: boolean;
872
+ };
873
+ [MethodSwitchInlineQuery]: {
874
+ /**
875
+ * Text which should be inserted in the input after the current bot name. Max length is 256 symbols.
876
+ */
877
+ query: string;
878
+ /**
879
+ * List of chat types which could be chosen to send the message. Could be empty list. Values:
880
+ *
881
+ * users, bots, groups, channels
882
+ */
883
+ chat_types: ['users', 'bots', 'groups', 'channels'];
884
+ };
885
+ [MethodTriggerHapticFeedback]: {
886
+ /**
887
+ * Type of haptic event. Values:
888
+ *
889
+ * impact - when there's a collision involving UI components.
890
+ */
891
+ type: 'impact';
892
+ /**
893
+ * Required when type is impact. Values:
894
+ *
895
+ * light - indicates a collision between small or lightweight UI objects
896
+ *
897
+ * medium - indicates a collision between medium-sized or medium-weight UI objects
898
+ *
899
+ * heavy - indicates a collision between large or heavyweight UI objects
900
+ *
901
+ * rigid - indicates a collision between hard or inflexible UI objects
902
+ *
903
+ * soft - indicates a collision between soft or flexible UI objects
904
+ */
905
+ impact_style: 'light' | 'medium' | 'heavy' | 'rigid' | 'soft';
906
+ } | {
907
+ /**
908
+ * Type of haptic event. Values:
909
+ *
910
+ * notification - when some action execution has been completed.
911
+ */
912
+ type: 'notification';
913
+ /**
914
+ * Required when type is notification. Values:
915
+ *
916
+ * error - indicates that a task or action has failed
917
+ *
918
+ * success - indicates that a task or action has completed successfully
919
+ *
920
+ * warning - indicates that a task or action produced a warning
921
+ */
922
+ notification_type: 'error' | 'success' | 'warning';
923
+ } | {
924
+ /**
925
+ * selection_change - when the user changes their selection.
926
+ */
927
+ type: 'selection_change';
928
+ impact_style?: undefined;
929
+ notification_type?: undefined;
930
+ };
931
+ [MethodSetupSwipeBehavior]: {
932
+ allow_vertical_swipe: boolean;
933
+ };
934
+ };
935
+
813
936
  type Debug = (methondName: string, errorId: number) => void;
814
937
  declare const debug: Debug;
815
938
 
939
+ type GetPlatform = () => 'phone' | 'web' | 'desktop';
940
+ declare const TG_WEB = "web";
941
+ declare const TG_PHONE = "phone";
942
+ declare const TG_DESKTOP = "desktop";
943
+ declare const getPlatform: GetPlatform;
944
+
945
+ declare const NOT_SUPPORTED = "not_supported";
946
+
816
947
  type EventsData = {
817
948
  /**
818
949
  * User clicked the Back Button.
@@ -927,50 +1058,7 @@ type EventsData = {
927
1058
  /**
928
1059
  * Map where the key is a theme stylesheet key and value is the corresponding color in #RRGGBB format.
929
1060
  */
930
- theme_params: {
931
- bg_color: string;
932
- text_color: string;
933
- hint_color: string;
934
- link_color: string;
935
- button_color: string;
936
- button_text_color: string;
937
- /**
938
- * Bot API 6.1+
939
- */
940
- secondary_bg_color: string;
941
- /**
942
- * Bot API 7.0+
943
- */
944
- header_bg_color: string;
945
- /**
946
- * Bot API 7.10+
947
- */
948
- bottom_bar_bg_color: string;
949
- /**
950
- * Bot API 7.0+
951
- */
952
- accent_text_color: string;
953
- /**
954
- * Bot API 7.0+
955
- */
956
- section_bg_color: string;
957
- /**
958
- * Bot API 7.0+
959
- */
960
- section_header_text_color: string;
961
- /**
962
- * Bot API 7.6+
963
- */
964
- section_separator_color: string;
965
- /**
966
- * Bot API 7.0+
967
- */
968
- subtitle_text_color: string;
969
- /**
970
- * Bot API 7.0+
971
- */
972
- destructive_text_color: string;
973
- };
1061
+ theme_params: ThemeParams;
974
1062
  };
975
1063
  /**
976
1064
  * Occurs whenever the viewport has been changed.
@@ -1037,42 +1125,17 @@ declare namespace listener {
1037
1125
  export { type listener_EventsData as EventsData, listener_off as off, listener_on as on, listener_once as once };
1038
1126
  }
1039
1127
 
1040
- type GetPlatform = () => 'phone' | 'web' | 'desktop';
1041
- declare const TG_WEB = "web";
1042
- declare const TG_PHONE = "phone";
1043
- declare const TG_DESKTOP = "desktop";
1044
- declare const getPlatform: GetPlatform;
1045
-
1046
- declare const NOT_SUPPORTED = "not_supported";
1047
-
1048
- declare const MethodInvokeCustomMethod = "web_app_invoke_custom_method";
1049
- declare const MethodOpenScanQrPopup = "web_app_open_scan_qr_popup";
1050
- declare const MethodReadTextFromClipboard = "web_app_read_text_from_clipboard";
1051
- declare const MethodRequestPhone = "web_app_request_phone";
1052
- declare const MethodClose = "web_app_close";
1053
- declare const MethodCloseScanQrPopup = "web_app_close_scan_qr_popup";
1054
- declare const MethodDataSend = "web_app_data_send";
1055
- declare const MethodExpand = "web_app_expand";
1056
- declare const MethodIframeReady = "iframe_ready";
1057
- declare const MethodIframeWillReload = "iframe_will_reload";
1058
- declare const MethodOpenInvoice = "web_app_open_invoice";
1059
- declare const MethodOpenLink = "web_app_open_link";
1060
- declare const MethodOpenPopup = "web_app_open_popup";
1061
- declare const MethodOpenTgLink = "web_app_open_tg_link";
1062
- declare const MethodReady = "web_app_ready";
1063
- declare const MethodRequestTheme = "web_app_request_theme";
1064
- declare const MethodRequestViewport = "web_app_request_viewport";
1065
- declare const MethodRequestWriteAccess = "web_app_request_write_access";
1066
- declare const MethodSetBackgroundColor = "web_app_set_background_color";
1067
- declare const MethodSetHeaderColor = "web_app_set_header_color";
1068
- declare const MethodSetBottomBarColor = "web_app_set_bottom_bar_color";
1069
- declare const MethodSetupBackButton = "web_app_setup_back_button";
1070
- declare const MethodSetupClosingBehavior = "web_app_setup_closing_behavior";
1071
- declare const MethodSetupMainButton = "web_app_setup_main_button";
1072
- declare const MethodSetupSettingsButton = "web_app_setup_settings_button";
1073
- declare const MethodSwitchInlineQuery = "web_app_switch_inline_query";
1074
- declare const MethodTriggerHapticFeedback = "web_app_trigger_haptic_feedback";
1075
- declare const MethodSetupSwipeBehavior = "web_app_setup_swipe_behavior";
1128
+ type Value = {
1129
+ viewport?: EventsData[typeof EventViewportChanged] & {
1130
+ safe_area_bottom: number;
1131
+ };
1132
+ theme?: EventsData[typeof EventThemeChanged];
1133
+ init?: GetInitData;
1134
+ };
1135
+ declare const ContextTwa: Context<Value>;
1136
+ interface ProviderTWA extends JSX.HTMLAttributes<HTMLDivElement> {
1137
+ }
1138
+ declare const ProviderTWA: Component<ProviderTWA>;
1076
1139
 
1077
1140
  declare const EventBackButtonPressed = "back_button_pressed";
1078
1141
  declare const EventClipboardTextReceived = "clipboard_text_received";
@@ -1090,4 +1153,4 @@ declare const EventThemeChanged = "theme_changed";
1090
1153
  declare const EventViewportChanged = "viewport_changed";
1091
1154
  declare const EventWriteAccessRequested = "write_access_requested";
1092
1155
 
1093
- export { EventBackButtonPressed, EventClipboardTextReceived, EventCustomMethodInvoked, EventInvoiceClosed, EventMainButtonPressed, EventPhoneRequested, EventPopupClosed, EventQrTextReceived, EventReloadIframe, EventScanQrPopupClosed, EventSetCustomStyle, EventSettingsButtonPressed, EventThemeChanged, EventViewportChanged, EventWriteAccessRequested, type EventsData, MethodClose, MethodCloseScanQrPopup, MethodDataSend, MethodExpand, MethodIframeReady, MethodIframeWillReload, MethodInvokeCustomMethod, MethodOpenInvoice, MethodOpenLink, MethodOpenPopup, MethodOpenScanQrPopup, MethodOpenTgLink, MethodReadTextFromClipboard, MethodReady, MethodRequestPhone, MethodRequestTheme, MethodRequestViewport, MethodRequestWriteAccess, MethodSetBackgroundColor, MethodSetBottomBarColor, MethodSetHeaderColor, MethodSetupBackButton, MethodSetupClosingBehavior, MethodSetupMainButton, MethodSetupSettingsButton, MethodSetupSwipeBehavior, MethodSwitchInlineQuery, MethodTriggerHapticFeedback, NOT_SUPPORTED, TG_DESKTOP, TG_PHONE, TG_WEB, close as bridgeClose, closeScanQrPopup as bridgeCloseScanQrPopup, dataSend as bridgeDataSend, expand as bridgeExpand, getInitData as bridgeGetInitData, iframeReady as bridgeIframeReady, iframeWillReload as bridgeIframeWillReload, invokeCustomMethod as bridgeInvokeCustomMethod, openInvoice as bridgeOpenInvoice, openLink as bridgeOpenLink, openPopup as bridgeOpenPopup, openScanQrPopup as bridgeOpenScanQrPopup, openTgLink as bridgeOpenTgLink, readTextFromClipboard as bridgeReadTextFromClipboard, ready as bridgeReady, requestPhone as bridgeRequestPhone, requestTheme as bridgeRequestTheme, requestViewport as bridgeRequestViewport, requestWriteAccess as bridgeRequestWriteAccess, sessionStorageGet as bridgeSessionStorageGet, sessionStorageSet as bridgeSessionStorageSet, setBackgroundColor as bridgeSetBackgroundColor, setBottomBarColor as bridgeSetBottomBarColor, setHeaderColor as bridgeSetHeaderColor, setupBackButton as bridgeSetupBackButton, setupClosingBehavior as bridgeSetupClosingBehavior, setupMainButton as bridgeSetupMainButton, setupSettingsButton as bridgeSetupSettingsButton, setupSwipeBehavior as bridgeSetupSwipeBehavior, switchInlineQuery as bridgeSwitchInlineQuery, triggerHapticFeedback as bridgeTriggerHapticFeedback, createIsViewportChanged, debug, getPlatform, listener, sender, supportClose, supportCloseScanQrPopup, supportDataSend, supportExpand, supportIframeReady, supportIframeWillReload, supportInvokeCustomMethod, supportOpenInvoice, supportOpenLink, supportOpenPopup, supportOpenScanQrPopup, supportOpenTgLink, supportReadTextFromClipboard, supportReady, supportRequestPhone, supportRequestTheme, supportRequestViewport, supportRequestWriteAccess, supportSessionStorageGet, supportSessionStorageSet, supportSetBackgroundColor, supportSetBottomBarColor, supportSetHeaderColor, supportSetupBackButton, supportSetupClosingBehavior, supportSetupMainButton, supportSetupSettingsButton, supportSetupSwipeBehavior, supportSwitchInlineQuery, supportTriggerHapticFeedback };
1156
+ export { ContextTwa, EventBackButtonPressed, EventClipboardTextReceived, EventCustomMethodInvoked, EventInvoiceClosed, EventMainButtonPressed, EventPhoneRequested, EventPopupClosed, EventQrTextReceived, EventReloadIframe, EventScanQrPopupClosed, EventSetCustomStyle, EventSettingsButtonPressed, EventThemeChanged, EventViewportChanged, EventWriteAccessRequested, type EventsData, type GetInitData, MethodClose, MethodCloseScanQrPopup, MethodDataSend, MethodExpand, MethodIframeReady, MethodIframeWillReload, MethodInvokeCustomMethod, MethodOpenInvoice, MethodOpenLink, MethodOpenPopup, MethodOpenScanQrPopup, MethodOpenTgLink, MethodReadTextFromClipboard, MethodReady, MethodRequestPhone, MethodRequestTheme, MethodRequestViewport, MethodRequestWriteAccess, MethodSetBackgroundColor, MethodSetBottomBarColor, MethodSetHeaderColor, MethodSetupBackButton, MethodSetupClosingBehavior, MethodSetupMainButton, MethodSetupSettingsButton, MethodSetupSwipeBehavior, MethodSwitchInlineQuery, MethodTriggerHapticFeedback, NOT_SUPPORTED, type PopupButton, ProviderTWA, type SenderData, TG_DESKTOP, TG_PHONE, TG_WEB, type ThemeParams, close as bridgeClose, closeScanQrPopup as bridgeCloseScanQrPopup, dataSend as bridgeDataSend, expand as bridgeExpand, getInitData as bridgeGetInitData, getThemeParams as bridgeGetThemeParams, iframeReady as bridgeIframeReady, iframeWillReload as bridgeIframeWillReload, invokeCustomMethod as bridgeInvokeCustomMethod, openInvoice as bridgeOpenInvoice, openLink as bridgeOpenLink, openPopup as bridgeOpenPopup, openScanQrPopup as bridgeOpenScanQrPopup, openTgLink as bridgeOpenTgLink, readTextFromClipboard as bridgeReadTextFromClipboard, ready as bridgeReady, requestPhone as bridgeRequestPhone, requestTheme as bridgeRequestTheme, requestViewport as bridgeRequestViewport, requestWriteAccess as bridgeRequestWriteAccess, sender as bridgeSend, sessionStorageGet as bridgeSessionStorageGet, sessionStorageSet as bridgeSessionStorageSet, setBackgroundColor as bridgeSetBackgroundColor, setBottomBarColor as bridgeSetBottomBarColor, setHeaderColor as bridgeSetHeaderColor, setupBackButton as bridgeSetupBackButton, setupClosingBehavior as bridgeSetupClosingBehavior, setupMainButton as bridgeSetupMainButton, setupSettingsButton as bridgeSetupSettingsButton, setupSwipeBehavior as bridgeSetupSwipeBehavior, switchInlineQuery as bridgeSwitchInlineQuery, triggerHapticFeedback as bridgeTriggerHapticFeedback, createIsViewportChanged, debug, getPlatform, listener, sender, supportClose, supportCloseScanQrPopup, supportDataSend, supportExpand, supportIframeReady, supportIframeWillReload, supportInvokeCustomMethod, supportOpenInvoice, supportOpenLink, supportOpenPopup, supportOpenScanQrPopup, supportOpenTgLink, supportReadTextFromClipboard, supportReady, supportRequestPhone, supportRequestTheme, supportRequestViewport, supportRequestWriteAccess, supportSessionStorageGet, supportSessionStorageSet, supportSetBackgroundColor, supportSetBottomBarColor, supportSetHeaderColor, supportSetupBackButton, supportSetupClosingBehavior, supportSetupMainButton, supportSetupSettingsButton, supportSetupSwipeBehavior, supportSwitchInlineQuery, supportTriggerHapticFeedback };