@types/telegram-web-app 6.9.0 → 6.9.2

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,9 +8,8 @@ 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: Tue, 26 Sep 2023 22:35:04 GMT
11
+ * Last updated: Wed, 18 Oct 2023 11:45:06 GMT
12
12
  * Dependencies: none
13
- * Global values: `Telegram`
14
13
 
15
14
  # Credits
16
15
  These definitions were written by [KnorpelSenf](https://github.com/KnorpelSenf), [MKRhere](https://github.com/MKRhere), and [deptyped](https://github.com/deptyped).
@@ -1,10 +1,3 @@
1
- // Type definitions for non-npm package telegram-web-app 6.9
2
- // Project: https://telegram.org/js/telegram-web-app.js
3
- // Definitions by: KnorpelSenf <https://github.com/KnorpelSenf>
4
- // MKRhere <https://github.com/MKRhere>
5
- // deptyped <https://github.com/deptyped>
6
- // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
7
-
8
1
  declare var Telegram: Telegram;
9
2
 
10
3
  type Color = string | false;
@@ -38,7 +31,7 @@ interface WebApp {
38
31
  * The color scheme currently used in the Telegram app. Either “light” or
39
32
  * “dark”. Also available as the CSS variable var(--tg-color-scheme).
40
33
  */
41
- colorScheme: 'light' | 'dark';
34
+ colorScheme: "light" | "dark";
42
35
  /**
43
36
  * An object containing the current theme settings used in the Telegram app.
44
37
  */
@@ -123,13 +116,14 @@ interface WebApp {
123
116
  /**
124
117
  * A method that sets the app header color in the `#RRGGBB` format.
125
118
  * You can also use keywords bg_color and secondary_bg_color.
126
- */ // string & {} prevents this from eagerly collapsing into just string
127
- setHeaderColor(color: 'bg_color' | 'secondary_bg_color' | (string & {})): void;
119
+ */
120
+ // string & {} prevents this from eagerly collapsing into just string
121
+ setHeaderColor(color: "bg_color" | "secondary_bg_color" | (string & {})): void;
128
122
  /**
129
123
  * A method that sets the app background color in the `#RRGGBB` format or
130
124
  * you can use keywords bg_color, secondary_bg_color instead.
131
125
  */
132
- setBackgroundColor(color: 'bg_color' | 'secondary_bg_color' | (string & {})): void;
126
+ setBackgroundColor(color: "bg_color" | "secondary_bg_color" | (string & {})): void;
133
127
  /**
134
128
  * A method that enables a confirmation dialog while the user is trying to close the Web App.
135
129
  */
@@ -143,41 +137,41 @@ interface WebApp {
143
137
  * events.
144
138
  */
145
139
  onEvent(
146
- eventType: 'themeChanged' | 'mainButtonClicked' | 'backButtonClicked' | 'settingsButtonClicked',
140
+ eventType: "themeChanged" | "mainButtonClicked" | "backButtonClicked" | "settingsButtonClicked",
147
141
  eventHandler: () => void,
148
142
  ): void;
149
- onEvent(eventType: 'popupClosed', eventHandler: (eventData: { button_id: string | null }) => void): void;
150
- onEvent(eventType: 'viewportChanged', eventHandler: (eventData: { isStateStable: boolean }) => void): void;
143
+ onEvent(eventType: "popupClosed", eventHandler: (eventData: { button_id: string | null }) => void): void;
144
+ onEvent(eventType: "viewportChanged", eventHandler: (eventData: { isStateStable: boolean }) => void): void;
151
145
  onEvent(
152
- eventType: 'invoiceClosed',
153
- eventHandler: (eventData: { url: string; status: 'paid' | 'cancelled' | 'failed' | 'pending' }) => void,
146
+ eventType: "invoiceClosed",
147
+ eventHandler: (eventData: { url: string; status: "paid" | "cancelled" | "failed" | "pending" }) => void,
154
148
  ): void;
155
- onEvent(eventType: 'qrTextReceived', eventHandler: (eventData: { data: string }) => void): void;
156
- onEvent(eventType: 'clipboardTextReceived', eventHandler: (eventData: { data: string | null }) => void): void;
149
+ onEvent(eventType: "qrTextReceived", eventHandler: (eventData: { data: string }) => void): void;
150
+ onEvent(eventType: "clipboardTextReceived", eventHandler: (eventData: { data: string | null }) => void): void;
157
151
  onEvent(
158
- eventType: 'writeAccessRequested',
159
- eventHandler: (eventData: { status: 'allowed' | 'cancelled' }) => void,
152
+ eventType: "writeAccessRequested",
153
+ eventHandler: (eventData: { status: "allowed" | "cancelled" }) => void,
160
154
  ): void;
161
- onEvent(eventType: 'contactRequested', eventHandler: (eventData: { status: 'sent' | 'cancelled' }) => void): void;
155
+ onEvent(eventType: "contactRequested", eventHandler: (eventData: { status: "sent" | "cancelled" }) => void): void;
162
156
 
163
157
  /** A method that deletes a previously set event handler. */
164
158
  offEvent(
165
- eventType: 'themeChanged' | 'mainButtonClicked' | 'backButtonClicked' | 'settingsButtonClicked',
159
+ eventType: "themeChanged" | "mainButtonClicked" | "backButtonClicked" | "settingsButtonClicked",
166
160
  eventHandler: () => void,
167
161
  ): void;
168
- offEvent(eventType: 'popupClosed', eventHandler: (eventData: { button_id: string | null }) => void): void;
169
- offEvent(eventType: 'viewportChanged', eventHandler: (eventData: { isStateStable: boolean }) => void): void;
162
+ offEvent(eventType: "popupClosed", eventHandler: (eventData: { button_id: string | null }) => void): void;
163
+ offEvent(eventType: "viewportChanged", eventHandler: (eventData: { isStateStable: boolean }) => void): void;
170
164
  offEvent(
171
- eventType: 'invoiceClosed',
172
- eventHandler: (eventData: { url: string; status: 'paid' | 'cancelled' | 'failed' | 'pending' }) => void,
165
+ eventType: "invoiceClosed",
166
+ eventHandler: (eventData: { url: string; status: "paid" | "cancelled" | "failed" | "pending" }) => void,
173
167
  ): void;
174
- offEvent(eventType: 'qrTextReceived', eventHandler: (eventData: { data: string }) => void): void;
175
- offEvent(eventType: 'clipboardTextReceived', eventHandler: (eventData: { data: string | null }) => void): void;
168
+ offEvent(eventType: "qrTextReceived", eventHandler: (eventData: { data: string }) => void): void;
169
+ offEvent(eventType: "clipboardTextReceived", eventHandler: (eventData: { data: string | null }) => void): void;
176
170
  offEvent(
177
- eventType: 'writeAccessRequested',
178
- eventHandler: (eventData: { status: 'allowed' | 'cancelled' }) => void,
171
+ eventType: "writeAccessRequested",
172
+ eventHandler: (eventData: { status: "allowed" | "cancelled" }) => void,
179
173
  ): void;
180
- offEvent(eventType: 'contactRequested', eventHandler: (eventData: { status: 'sent' | 'cancelled' }) => void): void;
174
+ offEvent(eventType: "contactRequested", eventHandler: (eventData: { status: "sent" | "cancelled" }) => void): void;
181
175
 
182
176
  /**
183
177
  * A method used to send data to the bot. When this method is called, a
@@ -196,7 +190,7 @@ interface WebApp {
196
190
  * You can specify which types of chats the user will be able to choose from.
197
191
  * It can be one or more of the following types: users, bots, groups, channels.
198
192
  */
199
- switchInlineQuery(query: string, choose_chat_types?: Array<'users' | 'bots' | 'groups' | 'channels'>): void;
193
+ switchInlineQuery(query: string, choose_chat_types?: Array<"users" | "bots" | "groups" | "channels">): void;
200
194
  /**
201
195
  * A method that opens a link in an external browser.
202
196
  * The Web App will not be closed.
@@ -220,7 +214,7 @@ interface WebApp {
220
214
  */
221
215
  openInvoice(
222
216
  url: string,
223
- callback: (url: string, status: 'paid' | 'cancelled' | 'failed' | 'pending') => void,
217
+ callback: (url: string, status: "paid" | "cancelled" | "failed" | "pending") => void,
224
218
  ): void;
225
219
  /**
226
220
  * A method that shows a native popup described by the params argument of the type PopupParams.
@@ -365,37 +359,39 @@ interface PopupParams {
365
359
  /**
366
360
  * This object describes the native popup button.
367
361
  */
368
- type PopupButton = {
369
- /**
370
- * Identifier of the button, 0-64 characters. Set to empty string by default.
371
- * If the button is pressed, its id is returned in the callback and the popupClosed event.
372
- */
373
- id?: string;
374
- /**
375
- * Type of the button. Set to default by default.
376
- * Can be one of these values:
377
- * - `default`, a button with the default style,
378
- * - `ok`, a button with the localized text “OK”,
379
- * - `close`, a button with the localized text “Close”,
380
- * - `cancel`, a button with the localized text “Cancel”,
381
- * - `destructive`, a button with a style that indicates a destructive action (e.g. Remove”, “Delete”, etc.).
382
- */
383
- type?: 'default' | 'ok' | 'close' | 'cancel' | 'destructive';
384
- /**
385
- * The text to be displayed on the button, 0-64 characters.
386
- * Required if type is default or destructive. Irrelevant for other types.
387
- */
388
- text?: string;
389
- } & (
390
- | {
391
- type: 'default' | 'destructive';
392
- text: string;
393
- }
394
- | {
395
- type: 'ok' | 'close' | 'cancel';
396
- text?: string;
397
- }
398
- );
362
+ type PopupButton =
363
+ & {
364
+ /**
365
+ * Identifier of the button, 0-64 characters. Set to empty string by default.
366
+ * If the button is pressed, its id is returned in the callback and the popupClosed event.
367
+ */
368
+ id?: string;
369
+ /**
370
+ * Type of the button. Set to default by default.
371
+ * Can be one of these values:
372
+ * - `default`, a button with the default style,
373
+ * - `ok`, a button with the localized text “OK”,
374
+ * - `close`, a button with the localized text “Close”,
375
+ * - `cancel`, a button with the localized textCancel”,
376
+ * - `destructive`, a button with a style that indicates a destructive action (e.g. “Remove”, “Delete”, etc.).
377
+ */
378
+ type?: "default" | "ok" | "close" | "cancel" | "destructive";
379
+ /**
380
+ * The text to be displayed on the button, 0-64 characters.
381
+ * Required if type is default or destructive. Irrelevant for other types.
382
+ */
383
+ text?: string;
384
+ }
385
+ & (
386
+ | {
387
+ type: "default" | "destructive";
388
+ text: string;
389
+ }
390
+ | {
391
+ type: "ok" | "close" | "cancel";
392
+ text?: string;
393
+ }
394
+ );
399
395
 
400
396
  /**
401
397
  * This object controls the back button, which can be displayed in the header of
@@ -515,7 +511,7 @@ interface HapticFeedback {
515
511
  * - rigid, indicates a collision between hard or inflexible UI objects,
516
512
  * - soft, indicates a collision between soft or flexible UI objects.
517
513
  */
518
- impactOccurred(style: 'light' | 'medium' | 'heavy' | 'rigid' | 'soft'): () => void;
514
+ impactOccurred(style: "light" | "medium" | "heavy" | "rigid" | "soft"): () => void;
519
515
  /**
520
516
  * A method tells that a task or action has succeeded, failed, or produced a
521
517
  * warning. The Telegram app may play the appropriate haptics based on type
@@ -524,7 +520,7 @@ interface HapticFeedback {
524
520
  * - success, indicates that a task or action has completed successfully,
525
521
  * - warning, indicates that a task or action produced a warning.
526
522
  */
527
- notificationOccurred(type: 'error' | 'success' | 'warning'): () => void;
523
+ notificationOccurred(type: "error" | "success" | "warning"): () => void;
528
524
  /**
529
525
  * A method tells that the user has changed a selection. The Telegram app
530
526
  * may play the appropriate haptics.
@@ -645,7 +641,7 @@ interface WebAppInitData {
645
641
  * “private”, “group”, “supergroup”, or “channel”.
646
642
  * Returned only for Web Apps launched from direct links.
647
643
  */
648
- chat_type?: 'sender' | 'private' | 'group' | 'supergroup' | 'channel';
644
+ chat_type?: "sender" | "private" | "group" | "supergroup" | "channel";
649
645
  /**
650
646
  * Global identifier, uniquely corresponding to the chat from which the Web App was opened.
651
647
  * Returned only for Web Apps launched from a direct link.
@@ -721,7 +717,7 @@ interface WebAppChat {
721
717
  /**
722
718
  * Type of chat, can be either “group”, “supergroup” or “channel”
723
719
  */
724
- type: 'group' | 'supergroup' | 'channel';
720
+ type: "group" | "supergroup" | "channel";
725
721
  /**
726
722
  * Title of the chat
727
723
  */
@@ -1,24 +1,24 @@
1
1
  {
2
2
  "name": "@types/telegram-web-app",
3
- "version": "6.9.0",
3
+ "version": "6.9.2",
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",
7
7
  "contributors": [
8
8
  {
9
9
  "name": "KnorpelSenf",
10
- "url": "https://github.com/KnorpelSenf",
11
- "githubUsername": "KnorpelSenf"
10
+ "githubUsername": "KnorpelSenf",
11
+ "url": "https://github.com/KnorpelSenf"
12
12
  },
13
13
  {
14
14
  "name": "MKRhere",
15
- "url": "https://github.com/MKRhere",
16
- "githubUsername": "MKRhere"
15
+ "githubUsername": "MKRhere",
16
+ "url": "https://github.com/MKRhere"
17
17
  },
18
18
  {
19
19
  "name": "deptyped",
20
- "url": "https://github.com/deptyped",
21
- "githubUsername": "deptyped"
20
+ "githubUsername": "deptyped",
21
+ "url": "https://github.com/deptyped"
22
22
  }
23
23
  ],
24
24
  "main": "",
@@ -30,6 +30,7 @@
30
30
  },
31
31
  "scripts": {},
32
32
  "dependencies": {},
33
- "typesPublisherContentHash": "2f5a5fcf817fe0bf0a0e10016c001674a72d56fe50e45e2ee126f9db11c37afb",
34
- "typeScriptVersion": "4.5"
33
+ "typesPublisherContentHash": "25b2b56b11187ec72ca3fa8108771402627c68a695f775eaeed8e82b04e8785d",
34
+ "typeScriptVersion": "4.5",
35
+ "nonNpm": true
35
36
  }