@types/telegram-web-app 6.4.0 → 6.7.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.
- telegram-web-app/README.md +2 -2
- telegram-web-app/index.d.ts +86 -52
- telegram-web-app/package.json +8 -3
telegram-web-app/README.md
CHANGED
|
@@ -8,9 +8,9 @@ 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:
|
|
11
|
+
* Last updated: Tue, 12 Sep 2023 12:34:33 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
* Global values: `Telegram`
|
|
14
14
|
|
|
15
15
|
# Credits
|
|
16
|
-
These definitions were written by [KnorpelSenf](https://github.com/KnorpelSenf),
|
|
16
|
+
These definitions were written by [KnorpelSenf](https://github.com/KnorpelSenf), [MKRhere](https://github.com/MKRhere), and [deptyped](https://github.com/deptyped).
|
telegram-web-app/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
// Type definitions for non-npm package telegram-web-app 6.
|
|
1
|
+
// Type definitions for non-npm package telegram-web-app 6.7
|
|
2
2
|
// Project: https://telegram.org/js/telegram-web-app.js
|
|
3
|
-
// Definitions by: KnorpelSenf <https://github.com/KnorpelSenf
|
|
3
|
+
// Definitions by: KnorpelSenf <https://github.com/KnorpelSenf>
|
|
4
|
+
// MKRhere <https://github.com/MKRhere>
|
|
5
|
+
// deptyped <https://github.com/deptyped>
|
|
4
6
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
5
7
|
|
|
6
8
|
declare var Telegram: Telegram;
|
|
@@ -36,7 +38,7 @@ interface WebApp {
|
|
|
36
38
|
* The color scheme currently used in the Telegram app. Either “light” or
|
|
37
39
|
* “dark”. Also available as the CSS variable var(--tg-color-scheme).
|
|
38
40
|
*/
|
|
39
|
-
colorScheme:
|
|
41
|
+
colorScheme: "light" | "dark";
|
|
40
42
|
/**
|
|
41
43
|
* An object containing the current theme settings used in the Telegram app.
|
|
42
44
|
*/
|
|
@@ -120,12 +122,12 @@ interface WebApp {
|
|
|
120
122
|
* Telegram.WebApp.themeParams.secondary_bg_colo as a color or you can use
|
|
121
123
|
* keywords bg_color, secondary_bg_color instead.
|
|
122
124
|
*/
|
|
123
|
-
setHeaderColor(color:
|
|
125
|
+
setHeaderColor(color: "bg_color" | "secondary_bg_color"): void;
|
|
124
126
|
/**
|
|
125
127
|
* A method that sets the app background color in the #RRGGBB format or you
|
|
126
128
|
* can use keywords bg_color, secondary_bg_color instead.
|
|
127
129
|
*/
|
|
128
|
-
setBackgroundColor(color:
|
|
130
|
+
setBackgroundColor(color: "bg_color" | "secondary_bg_color" | string): void;
|
|
129
131
|
/**
|
|
130
132
|
* A method that enables a confirmation dialog while the user is trying to close the Web App.
|
|
131
133
|
*/
|
|
@@ -139,25 +141,31 @@ interface WebApp {
|
|
|
139
141
|
* events.
|
|
140
142
|
*/
|
|
141
143
|
onEvent(
|
|
142
|
-
eventType:
|
|
144
|
+
eventType: "themeChanged" | "mainButtonClicked" | "backButtonClicked" | "settingsButtonClicked",
|
|
143
145
|
eventHandler: () => void,
|
|
144
146
|
): void;
|
|
145
|
-
onEvent(eventType:
|
|
146
|
-
onEvent(eventType:
|
|
147
|
-
onEvent(
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
onEvent(eventType: "popupClosed", eventHandler: (eventData: { button_id: string | null }) => void): void;
|
|
148
|
+
onEvent(eventType: "viewportChanged", eventHandler: (eventData: { isStateStable: boolean }) => void): void;
|
|
149
|
+
onEvent(
|
|
150
|
+
eventType: "invoiceClosed",
|
|
151
|
+
eventHandler: (eventData: { url: string; status: "paid" | "cancelled" | "failed" | "pending" }) => void,
|
|
152
|
+
): void;
|
|
153
|
+
onEvent(eventType: "qrTextReceived", eventHandler: (eventData: { data: string }) => void): void;
|
|
154
|
+
onEvent(eventType: "clipboardTextReceived", eventHandler: (eventData: { data: string | null }) => void): void;
|
|
150
155
|
|
|
151
156
|
/** A method that deletes a previously set event handler. */
|
|
152
157
|
offEvent(
|
|
153
|
-
eventType:
|
|
158
|
+
eventType: "themeChanged" | "mainButtonClicked" | "backButtonClicked" | "settingsButtonClicked",
|
|
154
159
|
eventHandler: () => void,
|
|
155
160
|
): void;
|
|
156
|
-
offEvent(eventType:
|
|
157
|
-
offEvent(eventType:
|
|
158
|
-
offEvent(
|
|
159
|
-
|
|
160
|
-
|
|
161
|
+
offEvent(eventType: "popupClosed", eventHandler: (eventData: { button_id: string | null }) => void): void;
|
|
162
|
+
offEvent(eventType: "viewportChanged", eventHandler: (eventData: { isStateStable: boolean }) => void): void;
|
|
163
|
+
offEvent(
|
|
164
|
+
eventType: "invoiceClosed",
|
|
165
|
+
eventHandler: (eventData: { url: string; status: "paid" | "cancelled" | "failed" | "pending" }) => void,
|
|
166
|
+
): void;
|
|
167
|
+
offEvent(eventType: "qrTextReceived", eventHandler: (eventData: { data: string }) => void): void;
|
|
168
|
+
offEvent(eventType: "clipboardTextReceived", eventHandler: (eventData: { data: string | null }) => void): void;
|
|
161
169
|
|
|
162
170
|
/**
|
|
163
171
|
* A method used to send data to the bot. When this method is called, a
|
|
@@ -168,6 +176,15 @@ interface WebApp {
|
|
|
168
176
|
* This method is only available for Web Apps launched via a Keyboard button.
|
|
169
177
|
*/
|
|
170
178
|
sendData(data: string): void;
|
|
179
|
+
/**
|
|
180
|
+
* A method that inserts the bot's username and the specified inline query in the current chat's input field.
|
|
181
|
+
* Query may be empty, in which case only the bot's username will be inserted.
|
|
182
|
+
* If an optional choose_chat_types parameter was passed, the client prompts the user to choose a specific chat,
|
|
183
|
+
* then opens that chat and inserts the bot's username and the specified inline query in the input field.
|
|
184
|
+
* You can specify which types of chats the user will be able to choose from.
|
|
185
|
+
* It can be one or more of the following types: users, bots, groups, channels.
|
|
186
|
+
*/
|
|
187
|
+
switchInlineQuery(query: string, choose_chat_types?: Array<"users" | "bots" | "groups" | "channels">): void;
|
|
171
188
|
/**
|
|
172
189
|
* A method that opens a link in an external browser.
|
|
173
190
|
* The Web App will not be closed.
|
|
@@ -189,7 +206,10 @@ interface WebApp {
|
|
|
189
206
|
* optional callback parameter was passed, the callback function will be
|
|
190
207
|
* called and the invoice status will be passed as the first argument.
|
|
191
208
|
*/
|
|
192
|
-
openInvoice(
|
|
209
|
+
openInvoice(
|
|
210
|
+
url: string,
|
|
211
|
+
callback: (url: string, status: "paid" | "cancelled" | "failed" | "pending") => void,
|
|
212
|
+
): void;
|
|
193
213
|
/**
|
|
194
214
|
* A method that shows a native popup described by the params argument of the type PopupParams.
|
|
195
215
|
* The Web App will receive the event popupClosed when the popup is closed. If an optional
|
|
@@ -313,37 +333,39 @@ interface PopupParams {
|
|
|
313
333
|
/**
|
|
314
334
|
* This object describes the native popup button.
|
|
315
335
|
*/
|
|
316
|
-
type PopupButton =
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
336
|
+
type PopupButton =
|
|
337
|
+
& {
|
|
338
|
+
/**
|
|
339
|
+
* Identifier of the button, 0-64 characters. Set to empty string by default.
|
|
340
|
+
* If the button is pressed, its id is returned in the callback and the popupClosed event.
|
|
341
|
+
*/
|
|
342
|
+
id?: string;
|
|
343
|
+
/**
|
|
344
|
+
* Type of the button. Set to default by default.
|
|
345
|
+
* Can be one of these values:
|
|
346
|
+
* - `default`, a button with the default style,
|
|
347
|
+
* - `ok`, a button with the localized text “OK”,
|
|
348
|
+
* - `close`, a button with the localized text “Close”,
|
|
349
|
+
* - `cancel`, a button with the localized text “Cancel”,
|
|
350
|
+
* - `destructive`, a button with a style that indicates a destructive action (e.g. “Remove”, “Delete”, etc.).
|
|
351
|
+
*/
|
|
352
|
+
type?: "default" | "ok" | "close" | "cancel" | "destructive";
|
|
353
|
+
/**
|
|
354
|
+
* The text to be displayed on the button, 0-64 characters.
|
|
355
|
+
* Required if type is default or destructive. Irrelevant for other types.
|
|
356
|
+
*/
|
|
357
|
+
text?: string;
|
|
358
|
+
}
|
|
359
|
+
& (
|
|
360
|
+
| {
|
|
361
|
+
type: "default" | "destructive";
|
|
362
|
+
text: string;
|
|
363
|
+
}
|
|
364
|
+
| {
|
|
365
|
+
type: "ok" | "close" | "cancel";
|
|
366
|
+
text?: string;
|
|
367
|
+
}
|
|
368
|
+
);
|
|
347
369
|
|
|
348
370
|
/**
|
|
349
371
|
* This object controls the back button, which can be displayed in the header of
|
|
@@ -463,7 +485,7 @@ interface HapticFeedback {
|
|
|
463
485
|
* - rigid, indicates a collision between hard or inflexible UI objects,
|
|
464
486
|
* - soft, indicates a collision between soft or flexible UI objects.
|
|
465
487
|
*/
|
|
466
|
-
impactOccurred(style:
|
|
488
|
+
impactOccurred(style: "light" | "medium" | "heavy" | "rigid" | "soft"): () => void;
|
|
467
489
|
/**
|
|
468
490
|
* A method tells that a task or action has succeeded, failed, or produced a
|
|
469
491
|
* warning. The Telegram app may play the appropriate haptics based on type
|
|
@@ -472,7 +494,7 @@ interface HapticFeedback {
|
|
|
472
494
|
* - success, indicates that a task or action has completed successfully,
|
|
473
495
|
* - warning, indicates that a task or action produced a warning.
|
|
474
496
|
*/
|
|
475
|
-
notificationOccurred(type:
|
|
497
|
+
notificationOccurred(type: "error" | "success" | "warning"): () => void;
|
|
476
498
|
/**
|
|
477
499
|
* A method tells that the user has changed a selection. The Telegram app
|
|
478
500
|
* may play the appropriate haptics.
|
|
@@ -507,6 +529,18 @@ interface WebAppInitData {
|
|
|
507
529
|
* only for Web Apps launched via the attachment menu.
|
|
508
530
|
*/
|
|
509
531
|
chat?: WebAppChat;
|
|
532
|
+
/**
|
|
533
|
+
* Type of the chat from which the Web App was opened.
|
|
534
|
+
* Can be either “sender” for a private chat with the user opening the link,
|
|
535
|
+
* “private”, “group”, “supergroup”, or “channel”.
|
|
536
|
+
* Returned only for Web Apps launched from direct links.
|
|
537
|
+
*/
|
|
538
|
+
chat_type?: "sender" | "private" | "group" | "supergroup" | "channel";
|
|
539
|
+
/**
|
|
540
|
+
* Global identifier, uniquely corresponding to the chat from which the Web App was opened.
|
|
541
|
+
* Returned only for Web Apps launched from a direct link.
|
|
542
|
+
*/
|
|
543
|
+
chat_instance?: string;
|
|
510
544
|
/**
|
|
511
545
|
* The value of the startattach parameter, passed via link. Only returned for
|
|
512
546
|
* Web Apps when launched from the attachment menu via link. The value of the
|
|
@@ -573,7 +607,7 @@ interface WebAppChat {
|
|
|
573
607
|
/**
|
|
574
608
|
* Type of chat, can be either “group”, “supergroup” or “channel”
|
|
575
609
|
*/
|
|
576
|
-
type:
|
|
610
|
+
type: "group" | "supergroup" | "channel";
|
|
577
611
|
/**
|
|
578
612
|
* Title of the chat
|
|
579
613
|
*/
|
telegram-web-app/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/telegram-web-app",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.7.1",
|
|
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",
|
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
"name": "MKRhere",
|
|
15
15
|
"url": "https://github.com/MKRhere",
|
|
16
16
|
"githubUsername": "MKRhere"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "deptyped",
|
|
20
|
+
"url": "https://github.com/deptyped",
|
|
21
|
+
"githubUsername": "deptyped"
|
|
17
22
|
}
|
|
18
23
|
],
|
|
19
24
|
"main": "",
|
|
@@ -25,6 +30,6 @@
|
|
|
25
30
|
},
|
|
26
31
|
"scripts": {},
|
|
27
32
|
"dependencies": {},
|
|
28
|
-
"typesPublisherContentHash": "
|
|
29
|
-
"typeScriptVersion": "4.
|
|
33
|
+
"typesPublisherContentHash": "121c0c4b99c08541e5f9b652ced6919485d51a54f491b4c08c9e73099e80e2b6",
|
|
34
|
+
"typeScriptVersion": "4.3"
|
|
30
35
|
}
|