@types/telegram-web-app 6.7.1 → 6.9.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/LICENSE +0 -0
- telegram-web-app/README.md +1 -1
- telegram-web-app/index.d.ts +178 -64
- telegram-web-app/package.json +3 -3
telegram-web-app/LICENSE
CHANGED
|
File without changes
|
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: Tue,
|
|
11
|
+
* Last updated: Tue, 26 Sep 2023 22:35:04 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.9
|
|
2
2
|
// Project: https://telegram.org/js/telegram-web-app.js
|
|
3
3
|
// Definitions by: KnorpelSenf <https://github.com/KnorpelSenf>
|
|
4
4
|
// MKRhere <https://github.com/MKRhere>
|
|
@@ -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
|
*/
|
|
@@ -111,23 +111,25 @@ interface WebApp {
|
|
|
111
111
|
* An object for controlling haptic feedback.
|
|
112
112
|
*/
|
|
113
113
|
HapticFeedback: HapticFeedback;
|
|
114
|
+
/**
|
|
115
|
+
* An object for controlling cloud storage.
|
|
116
|
+
*/
|
|
117
|
+
CloudStorage: CloudStorage;
|
|
114
118
|
/**
|
|
115
119
|
* Returns true if the user's app supports a version of the Bot API that is
|
|
116
120
|
* equal to or higher than the version passed as the parameter.
|
|
117
121
|
*/
|
|
118
122
|
isVersionAtLeast(version: string): boolean;
|
|
119
123
|
/**
|
|
120
|
-
* A method that sets the app header color
|
|
121
|
-
*
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
*/
|
|
125
|
-
setHeaderColor(color: "bg_color" | "secondary_bg_color"): void;
|
|
124
|
+
* A method that sets the app header color in the `#RRGGBB` format.
|
|
125
|
+
* 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;
|
|
126
128
|
/**
|
|
127
|
-
* A method that sets the app background color in the
|
|
128
|
-
* can use keywords bg_color, secondary_bg_color instead.
|
|
129
|
+
* A method that sets the app background color in the `#RRGGBB` format or
|
|
130
|
+
* you can use keywords bg_color, secondary_bg_color instead.
|
|
129
131
|
*/
|
|
130
|
-
setBackgroundColor(color:
|
|
132
|
+
setBackgroundColor(color: 'bg_color' | 'secondary_bg_color' | (string & {})): void;
|
|
131
133
|
/**
|
|
132
134
|
* A method that enables a confirmation dialog while the user is trying to close the Web App.
|
|
133
135
|
*/
|
|
@@ -141,31 +143,41 @@ interface WebApp {
|
|
|
141
143
|
* events.
|
|
142
144
|
*/
|
|
143
145
|
onEvent(
|
|
144
|
-
eventType:
|
|
146
|
+
eventType: 'themeChanged' | 'mainButtonClicked' | 'backButtonClicked' | 'settingsButtonClicked',
|
|
145
147
|
eventHandler: () => void,
|
|
146
148
|
): void;
|
|
147
|
-
onEvent(eventType:
|
|
148
|
-
onEvent(eventType:
|
|
149
|
+
onEvent(eventType: 'popupClosed', eventHandler: (eventData: { button_id: string | null }) => void): void;
|
|
150
|
+
onEvent(eventType: 'viewportChanged', eventHandler: (eventData: { isStateStable: boolean }) => void): void;
|
|
151
|
+
onEvent(
|
|
152
|
+
eventType: 'invoiceClosed',
|
|
153
|
+
eventHandler: (eventData: { url: string; status: 'paid' | 'cancelled' | 'failed' | 'pending' }) => void,
|
|
154
|
+
): void;
|
|
155
|
+
onEvent(eventType: 'qrTextReceived', eventHandler: (eventData: { data: string }) => void): void;
|
|
156
|
+
onEvent(eventType: 'clipboardTextReceived', eventHandler: (eventData: { data: string | null }) => void): void;
|
|
149
157
|
onEvent(
|
|
150
|
-
eventType:
|
|
151
|
-
eventHandler: (eventData: {
|
|
158
|
+
eventType: 'writeAccessRequested',
|
|
159
|
+
eventHandler: (eventData: { status: 'allowed' | 'cancelled' }) => void,
|
|
152
160
|
): void;
|
|
153
|
-
onEvent(eventType:
|
|
154
|
-
onEvent(eventType: "clipboardTextReceived", eventHandler: (eventData: { data: string | null }) => void): void;
|
|
161
|
+
onEvent(eventType: 'contactRequested', eventHandler: (eventData: { status: 'sent' | 'cancelled' }) => void): void;
|
|
155
162
|
|
|
156
163
|
/** A method that deletes a previously set event handler. */
|
|
157
164
|
offEvent(
|
|
158
|
-
eventType:
|
|
165
|
+
eventType: 'themeChanged' | 'mainButtonClicked' | 'backButtonClicked' | 'settingsButtonClicked',
|
|
159
166
|
eventHandler: () => void,
|
|
160
167
|
): void;
|
|
161
|
-
offEvent(eventType:
|
|
162
|
-
offEvent(eventType:
|
|
168
|
+
offEvent(eventType: 'popupClosed', eventHandler: (eventData: { button_id: string | null }) => void): void;
|
|
169
|
+
offEvent(eventType: 'viewportChanged', eventHandler: (eventData: { isStateStable: boolean }) => void): void;
|
|
163
170
|
offEvent(
|
|
164
|
-
eventType:
|
|
165
|
-
eventHandler: (eventData: { url: string; status:
|
|
171
|
+
eventType: 'invoiceClosed',
|
|
172
|
+
eventHandler: (eventData: { url: string; status: 'paid' | 'cancelled' | 'failed' | 'pending' }) => void,
|
|
166
173
|
): void;
|
|
167
|
-
offEvent(eventType:
|
|
168
|
-
offEvent(eventType:
|
|
174
|
+
offEvent(eventType: 'qrTextReceived', eventHandler: (eventData: { data: string }) => void): void;
|
|
175
|
+
offEvent(eventType: 'clipboardTextReceived', eventHandler: (eventData: { data: string | null }) => void): void;
|
|
176
|
+
offEvent(
|
|
177
|
+
eventType: 'writeAccessRequested',
|
|
178
|
+
eventHandler: (eventData: { status: 'allowed' | 'cancelled' }) => void,
|
|
179
|
+
): void;
|
|
180
|
+
offEvent(eventType: 'contactRequested', eventHandler: (eventData: { status: 'sent' | 'cancelled' }) => void): void;
|
|
169
181
|
|
|
170
182
|
/**
|
|
171
183
|
* A method used to send data to the bot. When this method is called, a
|
|
@@ -184,7 +196,7 @@ interface WebApp {
|
|
|
184
196
|
* You can specify which types of chats the user will be able to choose from.
|
|
185
197
|
* It can be one or more of the following types: users, bots, groups, channels.
|
|
186
198
|
*/
|
|
187
|
-
switchInlineQuery(query: string, choose_chat_types?: Array<
|
|
199
|
+
switchInlineQuery(query: string, choose_chat_types?: Array<'users' | 'bots' | 'groups' | 'channels'>): void;
|
|
188
200
|
/**
|
|
189
201
|
* A method that opens a link in an external browser.
|
|
190
202
|
* The Web App will not be closed.
|
|
@@ -208,7 +220,7 @@ interface WebApp {
|
|
|
208
220
|
*/
|
|
209
221
|
openInvoice(
|
|
210
222
|
url: string,
|
|
211
|
-
callback: (url: string, status:
|
|
223
|
+
callback: (url: string, status: 'paid' | 'cancelled' | 'failed' | 'pending') => void,
|
|
212
224
|
): void;
|
|
213
225
|
/**
|
|
214
226
|
* A method that shows a native popup described by the params argument of the type PopupParams.
|
|
@@ -250,6 +262,26 @@ interface WebApp {
|
|
|
250
262
|
* in response to a user interaction with the Web App interface (e.g. a click inside the Web App or on the main button).
|
|
251
263
|
*/
|
|
252
264
|
readTextFromClipboard(callback?: (data: string | null) => void): void;
|
|
265
|
+
/**
|
|
266
|
+
* A method that shows a native popup requesting permission for the bot to
|
|
267
|
+
* send messages to the user.
|
|
268
|
+
*
|
|
269
|
+
* @param callback If an optional callback parameter was passed, the
|
|
270
|
+
* callback function will be called when the popup is closed and the first
|
|
271
|
+
* argument will be a boolean indicating whether the user granted this
|
|
272
|
+
* access.
|
|
273
|
+
*/
|
|
274
|
+
requestWriteAccess(callback?: (success: boolean) => void): void;
|
|
275
|
+
/**
|
|
276
|
+
* A method that shows a native popup prompting the user for their phone
|
|
277
|
+
* number.
|
|
278
|
+
*
|
|
279
|
+
* @param callback If an optional callback parameter was passed, the
|
|
280
|
+
* callback function will be called when the popup is closed and the first
|
|
281
|
+
* argument will be a boolean indicating whether the user shared its
|
|
282
|
+
* phone number.
|
|
283
|
+
*/
|
|
284
|
+
requestContact(callback?: (success: boolean) => void): void;
|
|
253
285
|
/**
|
|
254
286
|
* A method that informs the Telegram app that the Web App is ready to be
|
|
255
287
|
* displayed. It is recommended to call this method as early as possible, as
|
|
@@ -333,39 +365,37 @@ interface PopupParams {
|
|
|
333
365
|
/**
|
|
334
366
|
* This object describes the native popup button.
|
|
335
367
|
*/
|
|
336
|
-
type PopupButton =
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
}
|
|
368
|
-
);
|
|
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
|
+
);
|
|
369
399
|
|
|
370
400
|
/**
|
|
371
401
|
* This object controls the back button, which can be displayed in the header of
|
|
@@ -485,7 +515,7 @@ interface HapticFeedback {
|
|
|
485
515
|
* - rigid, indicates a collision between hard or inflexible UI objects,
|
|
486
516
|
* - soft, indicates a collision between soft or flexible UI objects.
|
|
487
517
|
*/
|
|
488
|
-
impactOccurred(style:
|
|
518
|
+
impactOccurred(style: 'light' | 'medium' | 'heavy' | 'rigid' | 'soft'): () => void;
|
|
489
519
|
/**
|
|
490
520
|
* A method tells that a task or action has succeeded, failed, or produced a
|
|
491
521
|
* warning. The Telegram app may play the appropriate haptics based on type
|
|
@@ -494,7 +524,7 @@ interface HapticFeedback {
|
|
|
494
524
|
* - success, indicates that a task or action has completed successfully,
|
|
495
525
|
* - warning, indicates that a task or action produced a warning.
|
|
496
526
|
*/
|
|
497
|
-
notificationOccurred(type:
|
|
527
|
+
notificationOccurred(type: 'error' | 'success' | 'warning'): () => void;
|
|
498
528
|
/**
|
|
499
529
|
* A method tells that the user has changed a selection. The Telegram app
|
|
500
530
|
* may play the appropriate haptics.
|
|
@@ -505,6 +535,86 @@ interface HapticFeedback {
|
|
|
505
535
|
selectionChanged(): void;
|
|
506
536
|
}
|
|
507
537
|
|
|
538
|
+
interface CloudStorage {
|
|
539
|
+
/**
|
|
540
|
+
* A method that stores a value in the cloud storage using the
|
|
541
|
+
* specified key.
|
|
542
|
+
*
|
|
543
|
+
* @param key The key should contain 1-128 characters, only A-Z, a-z, 0-9,
|
|
544
|
+
* _ and - are allowed.
|
|
545
|
+
* @param value The value should contain 0-4096 characters. You can store
|
|
546
|
+
* up to 1024 keys in the cloud storage.
|
|
547
|
+
* @param callback If an optional callback parameter was passed, the
|
|
548
|
+
* callback function will be called. In case of an error, the first argument
|
|
549
|
+
* will contain the error. In case of success, the first argument will be
|
|
550
|
+
* null and the second argument will be a boolean indicating whether the
|
|
551
|
+
* value was stored.
|
|
552
|
+
*/
|
|
553
|
+
setItem(key: string, value: string, callback?: (error: string | null, success: null | true) => void): CloudStorage;
|
|
554
|
+
/**
|
|
555
|
+
* A method that receives a value from the cloud storage using
|
|
556
|
+
* the specified key.
|
|
557
|
+
*
|
|
558
|
+
* @param key The key should contain 1-128 characters, only A-Z, a-z, 0-9,
|
|
559
|
+
* _ and - are allowed.
|
|
560
|
+
* @param callback In case of an error, the callback function will
|
|
561
|
+
* be called and the first argument will contain the error. In case of
|
|
562
|
+
* success, the first argument will be null and the value will be passed
|
|
563
|
+
* as the second argument.
|
|
564
|
+
*/
|
|
565
|
+
getItem(key: string, callback?: (error: string | null, value: null | string) => void): CloudStorage;
|
|
566
|
+
/**
|
|
567
|
+
* A method that receives values from the cloud storage using the specified
|
|
568
|
+
* keys.
|
|
569
|
+
*
|
|
570
|
+
* @param key The keys should contain 1-128 characters, only A-Z, a-z, 0-9,
|
|
571
|
+
* _ and - are allowed.
|
|
572
|
+
* @param callback In case of an error, the callback? function will be
|
|
573
|
+
* called and the first argument will contain the error. In case of
|
|
574
|
+
* success, the first argument will be null and the values will be passed
|
|
575
|
+
* as the second argument.
|
|
576
|
+
*/
|
|
577
|
+
getItems(
|
|
578
|
+
keys: string[],
|
|
579
|
+
callback?: (error: string | null, values: null | Record<string, string>) => void,
|
|
580
|
+
): CloudStorage;
|
|
581
|
+
/**
|
|
582
|
+
* A method that removes a value from the cloud storage using the specified
|
|
583
|
+
* key.
|
|
584
|
+
*
|
|
585
|
+
* @param key The key should contain 1-128 characters, only A-Z, a-z, 0-9,
|
|
586
|
+
* _ and - are allowed.
|
|
587
|
+
* @param callback If an optional callback parameter was passed, the
|
|
588
|
+
* callback function will be called. In case of an error, the first
|
|
589
|
+
* argument will contain the error. In case of success, the first
|
|
590
|
+
* argument will be null and the second argument will be a boolean
|
|
591
|
+
* indicating whether the value was removed.
|
|
592
|
+
*/
|
|
593
|
+
removeItem(key: string, callback?: (error: string | null, success: null | true) => void): CloudStorage;
|
|
594
|
+
/**
|
|
595
|
+
* A method that removes values from the cloud storage using the specified
|
|
596
|
+
* keys.
|
|
597
|
+
*
|
|
598
|
+
* @param key The keys should contain 1-128 characters, only A-Z, a-z, 0-9,
|
|
599
|
+
* _ and - are allowed.
|
|
600
|
+
* @param callback If an optional callback parameter was passed, the
|
|
601
|
+
* callback function will be called. In case of an error, the first
|
|
602
|
+
* argument will contain the error. In case of success, the first
|
|
603
|
+
* argument will be null and the second argument will be a boolean
|
|
604
|
+
* indicating whether the values were removed.
|
|
605
|
+
*/
|
|
606
|
+
removeItems(keys: string[], callback?: (error: string | null, success: null | true) => void): CloudStorage;
|
|
607
|
+
/**
|
|
608
|
+
* A method that receives the list of all keys stored in the cloud storage.
|
|
609
|
+
*
|
|
610
|
+
* @param callback In case of an error, the callback function will be called
|
|
611
|
+
* and the first argument will contain the error. In case of success, the
|
|
612
|
+
* first argument will be null and the list of keys will be passed as the
|
|
613
|
+
* second argument.
|
|
614
|
+
*/
|
|
615
|
+
getKeys(callback?: (error: string | null, keys: null | string[]) => void): CloudStorage;
|
|
616
|
+
}
|
|
617
|
+
|
|
508
618
|
/**
|
|
509
619
|
* This object contains data that is transferred to the Web App when it is
|
|
510
620
|
* opened. It is empty if the Web App was launched from a keyboard button.
|
|
@@ -535,7 +645,7 @@ interface WebAppInitData {
|
|
|
535
645
|
* “private”, “group”, “supergroup”, or “channel”.
|
|
536
646
|
* Returned only for Web Apps launched from direct links.
|
|
537
647
|
*/
|
|
538
|
-
chat_type?:
|
|
648
|
+
chat_type?: 'sender' | 'private' | 'group' | 'supergroup' | 'channel';
|
|
539
649
|
/**
|
|
540
650
|
* Global identifier, uniquely corresponding to the chat from which the Web App was opened.
|
|
541
651
|
* Returned only for Web Apps launched from a direct link.
|
|
@@ -585,6 +695,10 @@ interface WebAppUser {
|
|
|
585
695
|
language_code?: string;
|
|
586
696
|
/** True, if this user is a Telegram Premium user. */
|
|
587
697
|
is_premium?: true;
|
|
698
|
+
/** True, if this user added the bot to the attachment menu. */
|
|
699
|
+
added_to_attachment_menu?: true;
|
|
700
|
+
/** True, if this user allowed the bot to message them. */
|
|
701
|
+
allows_write_to_pm?: true;
|
|
588
702
|
/**
|
|
589
703
|
* URL of the user’s profile photo. The photo can be in .jpeg or .svg formats.
|
|
590
704
|
* Only returned for Web Apps launched from the attachment menu.
|
|
@@ -607,7 +721,7 @@ interface WebAppChat {
|
|
|
607
721
|
/**
|
|
608
722
|
* Type of chat, can be either “group”, “supergroup” or “channel”
|
|
609
723
|
*/
|
|
610
|
-
type:
|
|
724
|
+
type: 'group' | 'supergroup' | 'channel';
|
|
611
725
|
/**
|
|
612
726
|
* Title of the chat
|
|
613
727
|
*/
|
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.9.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",
|
|
@@ -30,6 +30,6 @@
|
|
|
30
30
|
},
|
|
31
31
|
"scripts": {},
|
|
32
32
|
"dependencies": {},
|
|
33
|
-
"typesPublisherContentHash": "
|
|
34
|
-
"typeScriptVersion": "4.
|
|
33
|
+
"typesPublisherContentHash": "2f5a5fcf817fe0bf0a0e10016c001674a72d56fe50e45e2ee126f9db11c37afb",
|
|
34
|
+
"typeScriptVersion": "4.5"
|
|
35
35
|
}
|