@types/telegram-web-app 6.7.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 +1 -1
- telegram-web-app/index.d.ts +63 -52
- telegram-web-app/package.json +2 -2
telegram-web-app/README.md
CHANGED
|
@@ -8,7 +8,7 @@ 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
|
|
telegram-web-app/index.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ interface WebApp {
|
|
|
38
38
|
* The color scheme currently used in the Telegram app. Either “light” or
|
|
39
39
|
* “dark”. Also available as the CSS variable var(--tg-color-scheme).
|
|
40
40
|
*/
|
|
41
|
-
colorScheme:
|
|
41
|
+
colorScheme: "light" | "dark";
|
|
42
42
|
/**
|
|
43
43
|
* An object containing the current theme settings used in the Telegram app.
|
|
44
44
|
*/
|
|
@@ -122,12 +122,12 @@ interface WebApp {
|
|
|
122
122
|
* Telegram.WebApp.themeParams.secondary_bg_colo as a color or you can use
|
|
123
123
|
* keywords bg_color, secondary_bg_color instead.
|
|
124
124
|
*/
|
|
125
|
-
setHeaderColor(color:
|
|
125
|
+
setHeaderColor(color: "bg_color" | "secondary_bg_color"): void;
|
|
126
126
|
/**
|
|
127
127
|
* A method that sets the app background color in the #RRGGBB format or you
|
|
128
128
|
* can use keywords bg_color, secondary_bg_color instead.
|
|
129
129
|
*/
|
|
130
|
-
setBackgroundColor(color:
|
|
130
|
+
setBackgroundColor(color: "bg_color" | "secondary_bg_color" | string): void;
|
|
131
131
|
/**
|
|
132
132
|
* A method that enables a confirmation dialog while the user is trying to close the Web App.
|
|
133
133
|
*/
|
|
@@ -141,25 +141,31 @@ interface WebApp {
|
|
|
141
141
|
* events.
|
|
142
142
|
*/
|
|
143
143
|
onEvent(
|
|
144
|
-
eventType:
|
|
144
|
+
eventType: "themeChanged" | "mainButtonClicked" | "backButtonClicked" | "settingsButtonClicked",
|
|
145
145
|
eventHandler: () => void,
|
|
146
146
|
): void;
|
|
147
|
-
onEvent(eventType:
|
|
148
|
-
onEvent(eventType:
|
|
149
|
-
onEvent(
|
|
150
|
-
|
|
151
|
-
|
|
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;
|
|
152
155
|
|
|
153
156
|
/** A method that deletes a previously set event handler. */
|
|
154
157
|
offEvent(
|
|
155
|
-
eventType:
|
|
158
|
+
eventType: "themeChanged" | "mainButtonClicked" | "backButtonClicked" | "settingsButtonClicked",
|
|
156
159
|
eventHandler: () => void,
|
|
157
160
|
): void;
|
|
158
|
-
offEvent(eventType:
|
|
159
|
-
offEvent(eventType:
|
|
160
|
-
offEvent(
|
|
161
|
-
|
|
162
|
-
|
|
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;
|
|
163
169
|
|
|
164
170
|
/**
|
|
165
171
|
* A method used to send data to the bot. When this method is called, a
|
|
@@ -178,7 +184,7 @@ interface WebApp {
|
|
|
178
184
|
* You can specify which types of chats the user will be able to choose from.
|
|
179
185
|
* It can be one or more of the following types: users, bots, groups, channels.
|
|
180
186
|
*/
|
|
181
|
-
switchInlineQuery(query: string, choose_chat_types?: Array<
|
|
187
|
+
switchInlineQuery(query: string, choose_chat_types?: Array<"users" | "bots" | "groups" | "channels">): void;
|
|
182
188
|
/**
|
|
183
189
|
* A method that opens a link in an external browser.
|
|
184
190
|
* The Web App will not be closed.
|
|
@@ -200,7 +206,10 @@ interface WebApp {
|
|
|
200
206
|
* optional callback parameter was passed, the callback function will be
|
|
201
207
|
* called and the invoice status will be passed as the first argument.
|
|
202
208
|
*/
|
|
203
|
-
openInvoice(
|
|
209
|
+
openInvoice(
|
|
210
|
+
url: string,
|
|
211
|
+
callback: (url: string, status: "paid" | "cancelled" | "failed" | "pending") => void,
|
|
212
|
+
): void;
|
|
204
213
|
/**
|
|
205
214
|
* A method that shows a native popup described by the params argument of the type PopupParams.
|
|
206
215
|
* The Web App will receive the event popupClosed when the popup is closed. If an optional
|
|
@@ -324,37 +333,39 @@ interface PopupParams {
|
|
|
324
333
|
/**
|
|
325
334
|
* This object describes the native popup button.
|
|
326
335
|
*/
|
|
327
|
-
type PopupButton =
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
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
|
+
);
|
|
358
369
|
|
|
359
370
|
/**
|
|
360
371
|
* This object controls the back button, which can be displayed in the header of
|
|
@@ -474,7 +485,7 @@ interface HapticFeedback {
|
|
|
474
485
|
* - rigid, indicates a collision between hard or inflexible UI objects,
|
|
475
486
|
* - soft, indicates a collision between soft or flexible UI objects.
|
|
476
487
|
*/
|
|
477
|
-
impactOccurred(style:
|
|
488
|
+
impactOccurred(style: "light" | "medium" | "heavy" | "rigid" | "soft"): () => void;
|
|
478
489
|
/**
|
|
479
490
|
* A method tells that a task or action has succeeded, failed, or produced a
|
|
480
491
|
* warning. The Telegram app may play the appropriate haptics based on type
|
|
@@ -483,7 +494,7 @@ interface HapticFeedback {
|
|
|
483
494
|
* - success, indicates that a task or action has completed successfully,
|
|
484
495
|
* - warning, indicates that a task or action produced a warning.
|
|
485
496
|
*/
|
|
486
|
-
notificationOccurred(type:
|
|
497
|
+
notificationOccurred(type: "error" | "success" | "warning"): () => void;
|
|
487
498
|
/**
|
|
488
499
|
* A method tells that the user has changed a selection. The Telegram app
|
|
489
500
|
* may play the appropriate haptics.
|
|
@@ -524,7 +535,7 @@ interface WebAppInitData {
|
|
|
524
535
|
* “private”, “group”, “supergroup”, or “channel”.
|
|
525
536
|
* Returned only for Web Apps launched from direct links.
|
|
526
537
|
*/
|
|
527
|
-
chat_type?:
|
|
538
|
+
chat_type?: "sender" | "private" | "group" | "supergroup" | "channel";
|
|
528
539
|
/**
|
|
529
540
|
* Global identifier, uniquely corresponding to the chat from which the Web App was opened.
|
|
530
541
|
* Returned only for Web Apps launched from a direct link.
|
|
@@ -596,7 +607,7 @@ interface WebAppChat {
|
|
|
596
607
|
/**
|
|
597
608
|
* Type of chat, can be either “group”, “supergroup” or “channel”
|
|
598
609
|
*/
|
|
599
|
-
type:
|
|
610
|
+
type: "group" | "supergroup" | "channel";
|
|
600
611
|
/**
|
|
601
612
|
* Title of the chat
|
|
602
613
|
*/
|
telegram-web-app/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/telegram-web-app",
|
|
3
|
-
"version": "6.7.
|
|
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",
|
|
@@ -30,6 +30,6 @@
|
|
|
30
30
|
},
|
|
31
31
|
"scripts": {},
|
|
32
32
|
"dependencies": {},
|
|
33
|
-
"typesPublisherContentHash": "
|
|
33
|
+
"typesPublisherContentHash": "121c0c4b99c08541e5f9b652ced6919485d51a54f491b4c08c9e73099e80e2b6",
|
|
34
34
|
"typeScriptVersion": "4.3"
|
|
35
35
|
}
|