@types/telegram-web-app 6.2.2 → 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.
@@ -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: Mon, 03 Oct 2022 05:32:56 GMT
11
+ * Last updated: Wed, 25 Jan 2023 19:32:42 GMT
12
12
  * Dependencies: none
13
13
  * Global values: `Telegram`
14
14
 
@@ -1,4 +1,4 @@
1
- // Type definitions for non-npm package telegram-web-app 6.2
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).
@@ -140,6 +144,10 @@ interface WebApp {
140
144
  ): void;
141
145
  onEvent(eventType: 'popupClosed', eventHandler: (eventData: { button_id: string | null }) => void): void;
142
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
+
143
151
  /** A method that deletes a previously set event handler. */
144
152
  offEvent(
145
153
  eventType: 'themeChanged' | 'mainButtonClicked' | 'backButtonClicked' | 'settingsButtonClicked',
@@ -147,6 +155,10 @@ interface WebApp {
147
155
  ): void;
148
156
  offEvent(eventType: 'popupClosed', eventHandler: (eventData: { button_id: string | null }) => void): void;
149
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
+
150
162
  /**
151
163
  * A method used to send data to the bot. When this method is called, a
152
164
  * service message is sent to the bot containing the data data of the length
@@ -157,12 +169,15 @@ interface WebApp {
157
169
  */
158
170
  sendData(data: string): void;
159
171
  /**
160
- * A method that opens a link in an external browser. The Web App will not
161
- * be closed. Note that this method can be called only in response to the
162
- * user interaction with the Web App interface (e.g. click inside the Web
163
- * App or on the main button)
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)
164
179
  */
165
- openLink(url: string): void;
180
+ openLink(url: string, options?: { try_instant_view?: boolean }): void;
166
181
  /**
167
182
  * A method that opens a telegram link inside Telegram app. The Web App will
168
183
  * be closed.
@@ -174,7 +189,7 @@ interface WebApp {
174
189
  * optional callback parameter was passed, the callback function will be
175
190
  * called and the invoice status will be passed as the first argument.
176
191
  */
177
- openInvoice(url: string, callback: () => void): void;
192
+ openInvoice(url: string, callback: (url: string, status: 'paid' | 'cancelled' | 'failed' | 'pending') => void): void;
178
193
  /**
179
194
  * A method that shows a native popup described by the params argument of the type PopupParams.
180
195
  * The Web App will receive the event popupClosed when the popup is closed. If an optional
@@ -194,6 +209,27 @@ interface WebApp {
194
209
  * pressed the 'OK' button.
195
210
  */
196
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;
197
233
  /**
198
234
  * A method that informs the Telegram app that the Web App is ready to be
199
235
  * displayed. It is recommended to call this method as early as possible, as
@@ -552,3 +588,13 @@ interface WebAppChat {
552
588
  */
553
589
  photo_url?: string;
554
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
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/telegram-web-app",
3
- "version": "6.2.2",
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": "f12ee7f0dae9d5aa5ee9b896d22a1a9485fa21ae096cc9eada73fd3d306bd94a",
29
- "typeScriptVersion": "4.1"
28
+ "typesPublisherContentHash": "4ff79fa77e93a0da90fae05afa269bbe6e8aadb86c1e717120da7975cb8b7d06",
29
+ "typeScriptVersion": "4.2"
30
30
  }