@types/telegram-web-app 6.2.2 → 6.7.0
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 +77 -8
- 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: Wed, 26 Apr 2023 21:02:48 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;
|
|
@@ -28,6 +30,10 @@ interface WebApp {
|
|
|
28
30
|
* The version of the Bot API available in the user's Telegram app.
|
|
29
31
|
*/
|
|
30
32
|
version: string;
|
|
33
|
+
/**
|
|
34
|
+
* The name of the platform of the user's Telegram app.
|
|
35
|
+
*/
|
|
36
|
+
platform: string;
|
|
31
37
|
/**
|
|
32
38
|
* The color scheme currently used in the Telegram app. Either “light” or
|
|
33
39
|
* “dark”. Also available as the CSS variable var(--tg-color-scheme).
|
|
@@ -140,6 +146,10 @@ interface WebApp {
|
|
|
140
146
|
): void;
|
|
141
147
|
onEvent(eventType: 'popupClosed', eventHandler: (eventData: { button_id: string | null }) => void): void;
|
|
142
148
|
onEvent(eventType: 'viewportChanged', eventHandler: (eventData: { isStateStable: boolean }) => void): void;
|
|
149
|
+
onEvent(eventType: 'invoiceClosed', eventHandler: (eventData: { url: string, status: 'paid' | 'cancelled' | 'failed' | 'pending' }) => void): void;
|
|
150
|
+
onEvent(eventType: 'qrTextReceived', eventHandler: (eventData: { data: string }) => void): void;
|
|
151
|
+
onEvent(eventType: 'clipboardTextReceived', eventHandler: (eventData: { data: string | null }) => void): void;
|
|
152
|
+
|
|
143
153
|
/** A method that deletes a previously set event handler. */
|
|
144
154
|
offEvent(
|
|
145
155
|
eventType: 'themeChanged' | 'mainButtonClicked' | 'backButtonClicked' | 'settingsButtonClicked',
|
|
@@ -147,6 +157,10 @@ interface WebApp {
|
|
|
147
157
|
): void;
|
|
148
158
|
offEvent(eventType: 'popupClosed', eventHandler: (eventData: { button_id: string | null }) => void): void;
|
|
149
159
|
offEvent(eventType: 'viewportChanged', eventHandler: (eventData: { isStateStable: boolean }) => void): void;
|
|
160
|
+
offEvent(eventType: 'invoiceClosed', eventHandler: (eventData: { url: string, status: 'paid' | 'cancelled' | 'failed' | 'pending' }) => void): void;
|
|
161
|
+
offEvent(eventType: 'qrTextReceived', eventHandler: (eventData: { data: string }) => void): void;
|
|
162
|
+
offEvent(eventType: 'clipboardTextReceived', eventHandler: (eventData: { data: string | null }) => void): void;
|
|
163
|
+
|
|
150
164
|
/**
|
|
151
165
|
* A method used to send data to the bot. When this method is called, a
|
|
152
166
|
* service message is sent to the bot containing the data data of the length
|
|
@@ -157,12 +171,24 @@ interface WebApp {
|
|
|
157
171
|
*/
|
|
158
172
|
sendData(data: string): void;
|
|
159
173
|
/**
|
|
160
|
-
* A method that
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
174
|
+
* A method that inserts the bot's username and the specified inline query in the current chat's input field.
|
|
175
|
+
* Query may be empty, in which case only the bot's username will be inserted.
|
|
176
|
+
* If an optional choose_chat_types parameter was passed, the client prompts the user to choose a specific chat,
|
|
177
|
+
* then opens that chat and inserts the bot's username and the specified inline query in the input field.
|
|
178
|
+
* You can specify which types of chats the user will be able to choose from.
|
|
179
|
+
* It can be one or more of the following types: users, bots, groups, channels.
|
|
180
|
+
*/
|
|
181
|
+
switchInlineQuery(query: string, choose_chat_types?: Array<'users' | 'bots' | 'groups' | 'channels'>): void;
|
|
182
|
+
/**
|
|
183
|
+
* A method that opens a link in an external browser.
|
|
184
|
+
* The Web App will not be closed.
|
|
185
|
+
* If the optional options parameter is passed with the field
|
|
186
|
+
* @param try_instant_view the link will be opened in Instant View mode if possible.
|
|
187
|
+
*
|
|
188
|
+
* Note that this method can be called only in response to user interaction with
|
|
189
|
+
* the Web App interface (e.g. a click inside the Web App or on the main button)
|
|
164
190
|
*/
|
|
165
|
-
openLink(url: string): void;
|
|
191
|
+
openLink(url: string, options?: { try_instant_view?: boolean }): void;
|
|
166
192
|
/**
|
|
167
193
|
* A method that opens a telegram link inside Telegram app. The Web App will
|
|
168
194
|
* be closed.
|
|
@@ -174,7 +200,7 @@ interface WebApp {
|
|
|
174
200
|
* optional callback parameter was passed, the callback function will be
|
|
175
201
|
* called and the invoice status will be passed as the first argument.
|
|
176
202
|
*/
|
|
177
|
-
openInvoice(url: string, callback: () => void): void;
|
|
203
|
+
openInvoice(url: string, callback: (url: string, status: 'paid' | 'cancelled' | 'failed' | 'pending') => void): void;
|
|
178
204
|
/**
|
|
179
205
|
* A method that shows a native popup described by the params argument of the type PopupParams.
|
|
180
206
|
* The Web App will receive the event popupClosed when the popup is closed. If an optional
|
|
@@ -194,6 +220,27 @@ interface WebApp {
|
|
|
194
220
|
* pressed the 'OK' button.
|
|
195
221
|
*/
|
|
196
222
|
showConfirm(message: string, callback?: (ok?: boolean) => void): void;
|
|
223
|
+
/**
|
|
224
|
+
* A method that shows a native popup for scanning a QR code described by the params argument of the type ScanQrPopupParams.
|
|
225
|
+
* The Web App will receive the event qrTextReceived every time the scanner catches a code with text data.
|
|
226
|
+
* If an optional callback parameter was passed, the callback function will be called and the text from the QR
|
|
227
|
+
* code will be passed as the first argument. Returning true inside this callback function causes the popup to be closed.
|
|
228
|
+
*/
|
|
229
|
+
showScanQrPopup(params: ScanQrPopupParams, callback?: (data: string) => void): void;
|
|
230
|
+
/**
|
|
231
|
+
* A method that closes the native popup for scanning a QR code opened with the
|
|
232
|
+
* showScanQrPopup method. Run it if you received valid data in the event qrTextReceived.
|
|
233
|
+
*/
|
|
234
|
+
closeScanQrPopup(): void;
|
|
235
|
+
/**
|
|
236
|
+
* A method that requests text from the clipboard. The Web App will receive the event clipboardTextReceived.
|
|
237
|
+
* If an optional callback parameter was passed, the callback function will be
|
|
238
|
+
* called and the text from the clipboard will be passed as the first argument.
|
|
239
|
+
*
|
|
240
|
+
* Note: this method can be called only for Web Apps launched from the attachment menu and only
|
|
241
|
+
* in response to a user interaction with the Web App interface (e.g. a click inside the Web App or on the main button).
|
|
242
|
+
*/
|
|
243
|
+
readTextFromClipboard(callback?: (data: string | null) => void): void;
|
|
197
244
|
/**
|
|
198
245
|
* A method that informs the Telegram app that the Web App is ready to be
|
|
199
246
|
* displayed. It is recommended to call this method as early as possible, as
|
|
@@ -471,6 +518,18 @@ interface WebAppInitData {
|
|
|
471
518
|
* only for Web Apps launched via the attachment menu.
|
|
472
519
|
*/
|
|
473
520
|
chat?: WebAppChat;
|
|
521
|
+
/**
|
|
522
|
+
* Type of the chat from which the Web App was opened.
|
|
523
|
+
* Can be either “sender” for a private chat with the user opening the link,
|
|
524
|
+
* “private”, “group”, “supergroup”, or “channel”.
|
|
525
|
+
* Returned only for Web Apps launched from direct links.
|
|
526
|
+
*/
|
|
527
|
+
chat_type?: 'sender' | 'private' | 'group' | 'supergroup' | 'channel';
|
|
528
|
+
/**
|
|
529
|
+
* Global identifier, uniquely corresponding to the chat from which the Web App was opened.
|
|
530
|
+
* Returned only for Web Apps launched from a direct link.
|
|
531
|
+
*/
|
|
532
|
+
chat_instance?: string;
|
|
474
533
|
/**
|
|
475
534
|
* The value of the startattach parameter, passed via link. Only returned for
|
|
476
535
|
* Web Apps when launched from the attachment menu via link. The value of the
|
|
@@ -552,3 +611,13 @@ interface WebAppChat {
|
|
|
552
611
|
*/
|
|
553
612
|
photo_url?: string;
|
|
554
613
|
}
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* This object describes the native popup for scanning QR codes.
|
|
617
|
+
*/
|
|
618
|
+
interface ScanQrPopupParams {
|
|
619
|
+
/**
|
|
620
|
+
* The text to be displayed under the 'Scan QR' heading, 0-64 characters.
|
|
621
|
+
*/
|
|
622
|
+
text?: string;
|
|
623
|
+
}
|
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.0",
|
|
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": "087c84405ec21f5ea2663c05b6ff92799f58e740cd633c419e95f197342d36bc",
|
|
34
|
+
"typeScriptVersion": "4.3"
|
|
30
35
|
}
|