@types/telegram-web-app 6.2.1 → 6.4.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 +1 -1
- telegram-web-app/index.d.ts +57 -9
- telegram-web-app/package.json +3 -3
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: Wed, 25 Jan 2023 19:32:42 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
* Global values: `Telegram`
|
|
14
14
|
|
telegram-web-app/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Type definitions for non-npm package telegram-web-app 6.
|
|
1
|
+
// Type definitions for non-npm package telegram-web-app 6.4
|
|
2
2
|
// Project: https://telegram.org/js/telegram-web-app.js
|
|
3
3
|
// Definitions by: KnorpelSenf <https://github.com/KnorpelSenf>, MKRhere <https://github.com/MKRhere>
|
|
4
4
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
@@ -28,6 +28,10 @@ interface WebApp {
|
|
|
28
28
|
* The version of the Bot API available in the user's Telegram app.
|
|
29
29
|
*/
|
|
30
30
|
version: string;
|
|
31
|
+
/**
|
|
32
|
+
* The name of the platform of the user's Telegram app.
|
|
33
|
+
*/
|
|
34
|
+
platform: string;
|
|
31
35
|
/**
|
|
32
36
|
* The color scheme currently used in the Telegram app. Either “light” or
|
|
33
37
|
* “dark”. Also available as the CSS variable var(--tg-color-scheme).
|
|
@@ -135,16 +139,26 @@ interface WebApp {
|
|
|
135
139
|
* events.
|
|
136
140
|
*/
|
|
137
141
|
onEvent(
|
|
138
|
-
eventType: 'themeChanged' | 'mainButtonClicked' | 'backButtonClicked' | 'settingsButtonClicked'
|
|
142
|
+
eventType: 'themeChanged' | 'mainButtonClicked' | 'backButtonClicked' | 'settingsButtonClicked',
|
|
139
143
|
eventHandler: () => void,
|
|
140
144
|
): void;
|
|
145
|
+
onEvent(eventType: 'popupClosed', eventHandler: (eventData: { button_id: string | null }) => void): void;
|
|
141
146
|
onEvent(eventType: 'viewportChanged', eventHandler: (eventData: { isStateStable: boolean }) => void): void;
|
|
147
|
+
onEvent(eventType: 'invoiceClosed', eventHandler: (eventData: { url: string, status: 'paid' | 'cancelled' | 'failed' | 'pending' }) => void): void;
|
|
148
|
+
onEvent(eventType: 'qrTextReceived', eventHandler: (eventData: { data: string }) => void): void;
|
|
149
|
+
onEvent(eventType: 'clipboardTextReceived', eventHandler: (eventData: { data: string | null }) => void): void;
|
|
150
|
+
|
|
142
151
|
/** A method that deletes a previously set event handler. */
|
|
143
152
|
offEvent(
|
|
144
|
-
eventType: 'themeChanged' | 'mainButtonClicked' | 'backButtonClicked' | 'settingsButtonClicked'
|
|
153
|
+
eventType: 'themeChanged' | 'mainButtonClicked' | 'backButtonClicked' | 'settingsButtonClicked',
|
|
145
154
|
eventHandler: () => void,
|
|
146
155
|
): void;
|
|
156
|
+
offEvent(eventType: 'popupClosed', eventHandler: (eventData: { button_id: string | null }) => void): void;
|
|
147
157
|
offEvent(eventType: 'viewportChanged', eventHandler: (eventData: { isStateStable: boolean }) => void): void;
|
|
158
|
+
offEvent(eventType: 'invoiceClosed', eventHandler: (eventData: { url: string, status: 'paid' | 'cancelled' | 'failed' | 'pending' }) => void): void;
|
|
159
|
+
offEvent(eventType: 'qrTextReceived', eventHandler: (eventData: { data: string }) => void): void;
|
|
160
|
+
offEvent(eventType: 'clipboardTextReceived', eventHandler: (eventData: { data: string | null }) => void): void;
|
|
161
|
+
|
|
148
162
|
/**
|
|
149
163
|
* A method used to send data to the bot. When this method is called, a
|
|
150
164
|
* service message is sent to the bot containing the data data of the length
|
|
@@ -155,12 +169,15 @@ interface WebApp {
|
|
|
155
169
|
*/
|
|
156
170
|
sendData(data: string): void;
|
|
157
171
|
/**
|
|
158
|
-
* A method that opens a link in an external browser.
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
172
|
+
* A method that opens a link in an external browser.
|
|
173
|
+
* The Web App will not be closed.
|
|
174
|
+
* If the optional options parameter is passed with the field
|
|
175
|
+
* @param try_instant_view the link will be opened in Instant View mode if possible.
|
|
176
|
+
*
|
|
177
|
+
* Note that this method can be called only in response to user interaction with
|
|
178
|
+
* the Web App interface (e.g. a click inside the Web App or on the main button)
|
|
162
179
|
*/
|
|
163
|
-
openLink(url: string): void;
|
|
180
|
+
openLink(url: string, options?: { try_instant_view?: boolean }): void;
|
|
164
181
|
/**
|
|
165
182
|
* A method that opens a telegram link inside Telegram app. The Web App will
|
|
166
183
|
* be closed.
|
|
@@ -172,7 +189,7 @@ interface WebApp {
|
|
|
172
189
|
* optional callback parameter was passed, the callback function will be
|
|
173
190
|
* called and the invoice status will be passed as the first argument.
|
|
174
191
|
*/
|
|
175
|
-
openInvoice(url: string, callback: () => void): void;
|
|
192
|
+
openInvoice(url: string, callback: (url: string, status: 'paid' | 'cancelled' | 'failed' | 'pending') => void): void;
|
|
176
193
|
/**
|
|
177
194
|
* A method that shows a native popup described by the params argument of the type PopupParams.
|
|
178
195
|
* The Web App will receive the event popupClosed when the popup is closed. If an optional
|
|
@@ -192,6 +209,27 @@ interface WebApp {
|
|
|
192
209
|
* pressed the 'OK' button.
|
|
193
210
|
*/
|
|
194
211
|
showConfirm(message: string, callback?: (ok?: boolean) => void): void;
|
|
212
|
+
/**
|
|
213
|
+
* A method that shows a native popup for scanning a QR code described by the params argument of the type ScanQrPopupParams.
|
|
214
|
+
* The Web App will receive the event qrTextReceived every time the scanner catches a code with text data.
|
|
215
|
+
* If an optional callback parameter was passed, the callback function will be called and the text from the QR
|
|
216
|
+
* code will be passed as the first argument. Returning true inside this callback function causes the popup to be closed.
|
|
217
|
+
*/
|
|
218
|
+
showScanQrPopup(params: ScanQrPopupParams, callback?: (data: string) => void): void;
|
|
219
|
+
/**
|
|
220
|
+
* A method that closes the native popup for scanning a QR code opened with the
|
|
221
|
+
* showScanQrPopup method. Run it if you received valid data in the event qrTextReceived.
|
|
222
|
+
*/
|
|
223
|
+
closeScanQrPopup(): void;
|
|
224
|
+
/**
|
|
225
|
+
* A method that requests text from the clipboard. The Web App will receive the event clipboardTextReceived.
|
|
226
|
+
* If an optional callback parameter was passed, the callback function will be
|
|
227
|
+
* called and the text from the clipboard will be passed as the first argument.
|
|
228
|
+
*
|
|
229
|
+
* Note: this method can be called only for Web Apps launched from the attachment menu and only
|
|
230
|
+
* in response to a user interaction with the Web App interface (e.g. a click inside the Web App or on the main button).
|
|
231
|
+
*/
|
|
232
|
+
readTextFromClipboard(callback?: (data: string | null) => void): void;
|
|
195
233
|
/**
|
|
196
234
|
* A method that informs the Telegram app that the Web App is ready to be
|
|
197
235
|
* displayed. It is recommended to call this method as early as possible, as
|
|
@@ -550,3 +588,13 @@ interface WebAppChat {
|
|
|
550
588
|
*/
|
|
551
589
|
photo_url?: string;
|
|
552
590
|
}
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* This object describes the native popup for scanning QR codes.
|
|
594
|
+
*/
|
|
595
|
+
interface ScanQrPopupParams {
|
|
596
|
+
/**
|
|
597
|
+
* The text to be displayed under the 'Scan QR' heading, 0-64 characters.
|
|
598
|
+
*/
|
|
599
|
+
text?: string;
|
|
600
|
+
}
|
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.4.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",
|
|
@@ -25,6 +25,6 @@
|
|
|
25
25
|
},
|
|
26
26
|
"scripts": {},
|
|
27
27
|
"dependencies": {},
|
|
28
|
-
"typesPublisherContentHash": "
|
|
29
|
-
"typeScriptVersion": "4.
|
|
28
|
+
"typesPublisherContentHash": "4ff79fa77e93a0da90fae05afa269bbe6e8aadb86c1e717120da7975cb8b7d06",
|
|
29
|
+
"typeScriptVersion": "4.2"
|
|
30
30
|
}
|