@types/telegram-web-app 6.7.1 → 6.9.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/LICENSE +0 -0
- telegram-web-app/README.md +1 -1
- telegram-web-app/index.d.ts +126 -9
- 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:
|
|
11
|
+
* Last updated: Wed, 27 Sep 2023 20:35:06 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>
|
|
@@ -111,23 +111,26 @@ 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
|
-
* Telegram.WebApp.themeParams.secondary_bg_colo as a color or you can use
|
|
123
|
-
* keywords bg_color, secondary_bg_color instead.
|
|
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.
|
|
124
126
|
*/
|
|
125
|
-
|
|
127
|
+
// string & {} prevents this from eagerly collapsing into just string
|
|
128
|
+
setHeaderColor(color: "bg_color" | "secondary_bg_color" | (string & {})): void;
|
|
126
129
|
/**
|
|
127
|
-
* A method that sets the app background color in the
|
|
128
|
-
* can use keywords bg_color, secondary_bg_color instead.
|
|
130
|
+
* A method that sets the app background color in the `#RRGGBB` format or
|
|
131
|
+
* you can use keywords bg_color, secondary_bg_color instead.
|
|
129
132
|
*/
|
|
130
|
-
setBackgroundColor(color: "bg_color" | "secondary_bg_color" | string): void;
|
|
133
|
+
setBackgroundColor(color: "bg_color" | "secondary_bg_color" | (string & {})): void;
|
|
131
134
|
/**
|
|
132
135
|
* A method that enables a confirmation dialog while the user is trying to close the Web App.
|
|
133
136
|
*/
|
|
@@ -152,6 +155,11 @@ interface WebApp {
|
|
|
152
155
|
): void;
|
|
153
156
|
onEvent(eventType: "qrTextReceived", eventHandler: (eventData: { data: string }) => void): void;
|
|
154
157
|
onEvent(eventType: "clipboardTextReceived", eventHandler: (eventData: { data: string | null }) => void): void;
|
|
158
|
+
onEvent(
|
|
159
|
+
eventType: "writeAccessRequested",
|
|
160
|
+
eventHandler: (eventData: { status: "allowed" | "cancelled" }) => void,
|
|
161
|
+
): void;
|
|
162
|
+
onEvent(eventType: "contactRequested", eventHandler: (eventData: { status: "sent" | "cancelled" }) => void): void;
|
|
155
163
|
|
|
156
164
|
/** A method that deletes a previously set event handler. */
|
|
157
165
|
offEvent(
|
|
@@ -166,6 +174,11 @@ interface WebApp {
|
|
|
166
174
|
): void;
|
|
167
175
|
offEvent(eventType: "qrTextReceived", eventHandler: (eventData: { data: string }) => void): void;
|
|
168
176
|
offEvent(eventType: "clipboardTextReceived", eventHandler: (eventData: { data: string | null }) => void): void;
|
|
177
|
+
offEvent(
|
|
178
|
+
eventType: "writeAccessRequested",
|
|
179
|
+
eventHandler: (eventData: { status: "allowed" | "cancelled" }) => void,
|
|
180
|
+
): void;
|
|
181
|
+
offEvent(eventType: "contactRequested", eventHandler: (eventData: { status: "sent" | "cancelled" }) => void): void;
|
|
169
182
|
|
|
170
183
|
/**
|
|
171
184
|
* A method used to send data to the bot. When this method is called, a
|
|
@@ -250,6 +263,26 @@ interface WebApp {
|
|
|
250
263
|
* 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
264
|
*/
|
|
252
265
|
readTextFromClipboard(callback?: (data: string | null) => void): void;
|
|
266
|
+
/**
|
|
267
|
+
* A method that shows a native popup requesting permission for the bot to
|
|
268
|
+
* send messages to the user.
|
|
269
|
+
*
|
|
270
|
+
* @param callback If an optional callback parameter was passed, the
|
|
271
|
+
* callback function will be called when the popup is closed and the first
|
|
272
|
+
* argument will be a boolean indicating whether the user granted this
|
|
273
|
+
* access.
|
|
274
|
+
*/
|
|
275
|
+
requestWriteAccess(callback?: (success: boolean) => void): void;
|
|
276
|
+
/**
|
|
277
|
+
* A method that shows a native popup prompting the user for their phone
|
|
278
|
+
* number.
|
|
279
|
+
*
|
|
280
|
+
* @param callback If an optional callback parameter was passed, the
|
|
281
|
+
* callback function will be called when the popup is closed and the first
|
|
282
|
+
* argument will be a boolean indicating whether the user shared its
|
|
283
|
+
* phone number.
|
|
284
|
+
*/
|
|
285
|
+
requestContact(callback?: (success: boolean) => void): void;
|
|
253
286
|
/**
|
|
254
287
|
* A method that informs the Telegram app that the Web App is ready to be
|
|
255
288
|
* displayed. It is recommended to call this method as early as possible, as
|
|
@@ -505,6 +538,86 @@ interface HapticFeedback {
|
|
|
505
538
|
selectionChanged(): void;
|
|
506
539
|
}
|
|
507
540
|
|
|
541
|
+
interface CloudStorage {
|
|
542
|
+
/**
|
|
543
|
+
* A method that stores a value in the cloud storage using the
|
|
544
|
+
* specified key.
|
|
545
|
+
*
|
|
546
|
+
* @param key The key should contain 1-128 characters, only A-Z, a-z, 0-9,
|
|
547
|
+
* _ and - are allowed.
|
|
548
|
+
* @param value The value should contain 0-4096 characters. You can store
|
|
549
|
+
* up to 1024 keys in the cloud storage.
|
|
550
|
+
* @param callback If an optional callback parameter was passed, the
|
|
551
|
+
* callback function will be called. In case of an error, the first argument
|
|
552
|
+
* will contain the error. In case of success, the first argument will be
|
|
553
|
+
* null and the second argument will be a boolean indicating whether the
|
|
554
|
+
* value was stored.
|
|
555
|
+
*/
|
|
556
|
+
setItem(key: string, value: string, callback?: (error: string | null, success: null | true) => void): CloudStorage;
|
|
557
|
+
/**
|
|
558
|
+
* A method that receives a value from the cloud storage using
|
|
559
|
+
* the specified key.
|
|
560
|
+
*
|
|
561
|
+
* @param key The key should contain 1-128 characters, only A-Z, a-z, 0-9,
|
|
562
|
+
* _ and - are allowed.
|
|
563
|
+
* @param callback In case of an error, the callback function will
|
|
564
|
+
* be called and the first argument will contain the error. In case of
|
|
565
|
+
* success, the first argument will be null and the value will be passed
|
|
566
|
+
* as the second argument.
|
|
567
|
+
*/
|
|
568
|
+
getItem(key: string, callback?: (error: string | null, value: null | string) => void): CloudStorage;
|
|
569
|
+
/**
|
|
570
|
+
* A method that receives values from the cloud storage using the specified
|
|
571
|
+
* keys.
|
|
572
|
+
*
|
|
573
|
+
* @param key The keys should contain 1-128 characters, only A-Z, a-z, 0-9,
|
|
574
|
+
* _ and - are allowed.
|
|
575
|
+
* @param callback In case of an error, the callback? function will be
|
|
576
|
+
* called and the first argument will contain the error. In case of
|
|
577
|
+
* success, the first argument will be null and the values will be passed
|
|
578
|
+
* as the second argument.
|
|
579
|
+
*/
|
|
580
|
+
getItems(
|
|
581
|
+
keys: string[],
|
|
582
|
+
callback?: (error: string | null, values: null | Record<string, string>) => void,
|
|
583
|
+
): CloudStorage;
|
|
584
|
+
/**
|
|
585
|
+
* A method that removes a value from the cloud storage using the specified
|
|
586
|
+
* key.
|
|
587
|
+
*
|
|
588
|
+
* @param key The key should contain 1-128 characters, only A-Z, a-z, 0-9,
|
|
589
|
+
* _ and - are allowed.
|
|
590
|
+
* @param callback If an optional callback parameter was passed, the
|
|
591
|
+
* callback function will be called. In case of an error, the first
|
|
592
|
+
* argument will contain the error. In case of success, the first
|
|
593
|
+
* argument will be null and the second argument will be a boolean
|
|
594
|
+
* indicating whether the value was removed.
|
|
595
|
+
*/
|
|
596
|
+
removeItem(key: string, callback?: (error: string | null, success: null | true) => void): CloudStorage;
|
|
597
|
+
/**
|
|
598
|
+
* A method that removes values from the cloud storage using the specified
|
|
599
|
+
* keys.
|
|
600
|
+
*
|
|
601
|
+
* @param key The keys should contain 1-128 characters, only A-Z, a-z, 0-9,
|
|
602
|
+
* _ and - are allowed.
|
|
603
|
+
* @param callback If an optional callback parameter was passed, the
|
|
604
|
+
* callback function will be called. In case of an error, the first
|
|
605
|
+
* argument will contain the error. In case of success, the first
|
|
606
|
+
* argument will be null and the second argument will be a boolean
|
|
607
|
+
* indicating whether the values were removed.
|
|
608
|
+
*/
|
|
609
|
+
removeItems(keys: string[], callback?: (error: string | null, success: null | true) => void): CloudStorage;
|
|
610
|
+
/**
|
|
611
|
+
* A method that receives the list of all keys stored in the cloud storage.
|
|
612
|
+
*
|
|
613
|
+
* @param callback In case of an error, the callback function will be called
|
|
614
|
+
* and the first argument will contain the error. In case of success, the
|
|
615
|
+
* first argument will be null and the list of keys will be passed as the
|
|
616
|
+
* second argument.
|
|
617
|
+
*/
|
|
618
|
+
getKeys(callback?: (error: string | null, keys: null | string[]) => void): CloudStorage;
|
|
619
|
+
}
|
|
620
|
+
|
|
508
621
|
/**
|
|
509
622
|
* This object contains data that is transferred to the Web App when it is
|
|
510
623
|
* opened. It is empty if the Web App was launched from a keyboard button.
|
|
@@ -585,6 +698,10 @@ interface WebAppUser {
|
|
|
585
698
|
language_code?: string;
|
|
586
699
|
/** True, if this user is a Telegram Premium user. */
|
|
587
700
|
is_premium?: true;
|
|
701
|
+
/** True, if this user added the bot to the attachment menu. */
|
|
702
|
+
added_to_attachment_menu?: true;
|
|
703
|
+
/** True, if this user allowed the bot to message them. */
|
|
704
|
+
allows_write_to_pm?: true;
|
|
588
705
|
/**
|
|
589
706
|
* URL of the user’s profile photo. The photo can be in .jpeg or .svg formats.
|
|
590
707
|
* Only returned for Web Apps launched from the attachment menu.
|
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.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": "
|
|
34
|
-
"typeScriptVersion": "4.
|
|
33
|
+
"typesPublisherContentHash": "67938d52e1a927d86e06017fc2dc4f2f6ea2de9687d39499f507a66459d8f059",
|
|
34
|
+
"typeScriptVersion": "4.5"
|
|
35
35
|
}
|