@core-ease/telegram-kit 3.0.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.
- package/LICENSE +21 -0
- package/README.md +299 -0
- package/dist/animation/index.d.mts +4 -0
- package/dist/animation/index.d.ts +4 -0
- package/dist/animation/index.js +2413 -0
- package/dist/animation/index.mjs +5 -0
- package/dist/animation/lottie/index.d.mts +10 -0
- package/dist/animation/lottie/index.d.ts +10 -0
- package/dist/animation/lottie/index.js +2313 -0
- package/dist/animation/lottie/index.mjs +4 -0
- package/dist/animation/tgs/index.d.mts +18 -0
- package/dist/animation/tgs/index.d.ts +18 -0
- package/dist/animation/tgs/index.js +2402 -0
- package/dist/animation/tgs/index.mjs +4 -0
- package/dist/bot/index.d.mts +477 -0
- package/dist/bot/index.d.ts +477 -0
- package/dist/bot/index.js +870 -0
- package/dist/bot/index.mjs +847 -0
- package/dist/bot-D8BnLWIi.d.mts +2041 -0
- package/dist/bot-D8BnLWIi.d.ts +2041 -0
- package/dist/browser.global.js +23 -0
- package/dist/chunk-7AARTHNW.mjs +40 -0
- package/dist/chunk-7CVYPKAL.mjs +15 -0
- package/dist/chunk-B3PWALX5.mjs +4418 -0
- package/dist/chunk-BQEUEAVK.mjs +2262 -0
- package/dist/chunk-FPWYSKK2.mjs +3089 -0
- package/dist/chunk-JXK5HCDV.mjs +254 -0
- package/dist/chunk-OMH2JGOH.mjs +88 -0
- package/dist/chunk-PXO36YTU.mjs +38 -0
- package/dist/core/index.d.mts +151 -0
- package/dist/core/index.d.ts +151 -0
- package/dist/core/index.js +3837 -0
- package/dist/core/index.mjs +495 -0
- package/dist/dev/index.d.mts +77 -0
- package/dist/dev/index.d.ts +77 -0
- package/dist/dev/index.js +3214 -0
- package/dist/dev/index.mjs +151 -0
- package/dist/engine-BDm1_hzn.d.mts +382 -0
- package/dist/engine-BDm1_hzn.d.ts +382 -0
- package/dist/format/index.d.mts +61 -0
- package/dist/format/index.d.ts +61 -0
- package/dist/format/index.js +121 -0
- package/dist/format/index.mjs +112 -0
- package/dist/hooks/index.d.mts +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +4234 -0
- package/dist/hooks/index.mjs +3 -0
- package/dist/hooks-C5Per70R.d.mts +1066 -0
- package/dist/hooks-C5Per70R.d.ts +1066 -0
- package/dist/index.d.mts +849 -0
- package/dist/index.d.ts +849 -0
- package/dist/index.js +5026 -0
- package/dist/index.mjs +478 -0
- package/dist/keyboards/index.d.mts +50 -0
- package/dist/keyboards/index.d.ts +50 -0
- package/dist/keyboards/index.js +127 -0
- package/dist/keyboards/index.mjs +124 -0
- package/dist/links/index.d.mts +53 -0
- package/dist/links/index.d.ts +53 -0
- package/dist/links/index.js +139 -0
- package/dist/links/index.mjs +133 -0
- package/dist/lottie/index.d.mts +3 -0
- package/dist/lottie/index.d.ts +3 -0
- package/dist/lottie/index.js +2313 -0
- package/dist/lottie/index.mjs +4 -0
- package/dist/qr/index.d.mts +75 -0
- package/dist/qr/index.d.ts +75 -0
- package/dist/qr/index.js +983 -0
- package/dist/qr/index.mjs +946 -0
- package/dist/sdk/index.d.mts +322 -0
- package/dist/sdk/index.d.ts +322 -0
- package/dist/sdk/index.js +3138 -0
- package/dist/sdk/index.mjs +2 -0
- package/dist/server/index.d.mts +28 -0
- package/dist/server/index.d.ts +28 -0
- package/dist/server/index.js +254 -0
- package/dist/server/index.mjs +246 -0
- package/dist/tgs/index.d.mts +3 -0
- package/dist/tgs/index.d.ts +3 -0
- package/dist/tgs/index.js +2402 -0
- package/dist/tgs/index.mjs +4 -0
- package/dist/webapp-B-3_74nK.d.mts +842 -0
- package/dist/webapp-B-3_74nK.d.ts +842 -0
- package/dist/webapp-BDi9q3-a.d.mts +42 -0
- package/dist/webapp-YvmwFYUQ.d.ts +42 -0
- package/package.json +165 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,849 @@
|
|
|
1
|
+
import { W as WebAppKernel, S as SafeAreaInset, P as PopupParams, a as ScanQrPopupParams, H as HomeScreenStatus, D as DownloadFileParams, b as ShareToStoryParams, I as InitParams, O as OpenLinkOptions, c as OpenTelegramLinkOptions, T as TelegramWebView, d as WebApp, A as Accelerometer, e as AnyRecord, B as BackButton, f as BiometricAuthenticateParams, g as BiometricManager, h as BiometricRequestAccessParams, i as BiometricType, j as BottomButton, k as BottomButtonParams, l as BottomButtonPosition, C as CloseOptions, m as CloudStorage, n as ColorScheme, o as DebugBottomBar, p as DefaultColors, q as DeviceOrientation, r as DeviceOrientationStartParams, s as DeviceStorage, E as ErrCallback, t as EventHandler, G as Gyroscope, u as HapticFeedback, v as HapticImpactStyle, w as HapticNotificationType, x as ItemsCallback, L as LocationData, y as LocationManager, M as MotionSensorStartParams, z as PopupButton, F as PopupButtonType, J as SecureStorage, K as SettingsButton, N as ShareToStoryWidgetLink, Q as ThemeManager, R as ThemeParams, U as Utils, V as VoidCallback, X as WebAppChat, Y as WebAppInitDataUnsafe, Z as WebAppUser, _ as EmojiStatusParams, $ as TgWebApp } from './hooks-C5Per70R.js';
|
|
2
|
+
export { a0 as RuntimeMode, a1 as TgPlatform, a2 as WebAppEventType, a3 as useAccelerometer, a4 as useBiometric, a5 as useCloudStorage, a6 as useDeviceOrientation, a7 as useDeviceStorage, a8 as useDownloadFile, a9 as useGyroscope, aa as useHapticFeedback, ab as useHideKeyboard, ac as useHomeScreen, ad as useInitData, ae as useInvokeCustomMethod, af as useIsActive, ag as useLocation, ah as useOrientationLock, ai as useReadTextFromClipboard, aj as useReady, ak as useRequestChat, al as useRequestContact, am as useRequestEmojiStatusAccess, an as useRequestWriteAccess, ao as useSafeArea, ap as useScanQrPopup, aq as useSecureStorage, ar as useSetEmojiStatus, as as useShareMessage, at as useShareToStory, au as useShowAlert, av as useShowConfirm, aw as useShowPopup, ax as useSwitchInlineQuery, ay as useTelegramBackButton, az as useTelegramEvent, aA as useTelegramFullscreen, aB as useTelegramMainButton, aC as useTelegramSecondaryButton, aD as useTelegramSettingsButton, aE as useTelegramStartParam, aF as useTelegramTheme, aG as useTelegramUser, aH as useTelegramViewport, aI as useTelegramWebApp } from './hooks-C5Per70R.js';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The original SDK throws plain `Error('SomeName')` objects. We keep the
|
|
8
|
+
* exact same string names (so existing error-handling code that matches on
|
|
9
|
+
* `error.message` keeps working) but expose them as a typed enum plus a
|
|
10
|
+
* small helper so call sites read better than magic strings.
|
|
11
|
+
*/
|
|
12
|
+
declare enum WebAppErrorName {
|
|
13
|
+
MethodUnsupported = "WebAppMethodUnsupported",
|
|
14
|
+
DataInvalid = "WebAppDataInvalid",
|
|
15
|
+
InlineModeDisabled = "WebAppInlineModeDisabled",
|
|
16
|
+
InlineQueryInvalid = "WebAppInlineQueryInvalid",
|
|
17
|
+
InlineChooseChatTypesInvalid = "WebAppInlineChooseChatTypesInvalid",
|
|
18
|
+
InlineChooseChatTypeInvalid = "WebAppInlineChooseChatTypeInvalid",
|
|
19
|
+
TgUrlInvalid = "WebAppTgUrlInvalid",
|
|
20
|
+
InvoiceUrlInvalid = "WebAppInvoiceUrlInvalid",
|
|
21
|
+
InvoiceOpened = "WebAppInvoiceOpened",
|
|
22
|
+
PopupOpened = "WebAppPopupOpened",
|
|
23
|
+
PopupParamInvalid = "WebAppPopupParamInvalid",
|
|
24
|
+
ScanQrPopupOpened = "WebAppScanQrPopupOpened",
|
|
25
|
+
ScanQrPopupParamInvalid = "WebAppScanQrPopupParamInvalid",
|
|
26
|
+
WriteAccessRequested = "WebAppWriteAccessRequested",
|
|
27
|
+
ContactRequested = "WebAppContactRequested",
|
|
28
|
+
DownloadFilePopupOpened = "WebAppDownloadFilePopupOpened",
|
|
29
|
+
DownloadFileParamInvalid = "WebAppDownloadFileParamInvalid",
|
|
30
|
+
MediaUrlInvalid = "WebAppMediaUrlInvalid",
|
|
31
|
+
ShareToStoryParamInvalid = "WebAppShareToStoryParamInvalid",
|
|
32
|
+
ShareMessageOpened = "WebAppShareMessageOpened",
|
|
33
|
+
RequestChatOpened = "WebAppRequestChatOpened",
|
|
34
|
+
EmojiStatusRequested = "WebAppEmojiStatusRequested",
|
|
35
|
+
EmojiStatusAccessRequested = "WebAppEmojiStatusAccessRequested",
|
|
36
|
+
HeaderColorInvalid = "WebAppHeaderColorInvalid",
|
|
37
|
+
HeaderColorKeyInvalid = "WebAppHeaderColorKeyInvalid",
|
|
38
|
+
BackgroundColorInvalid = "WebAppBackgroundColorInvalid",
|
|
39
|
+
BottomBarColorInvalid = "WebAppBottomBarColorInvalid",
|
|
40
|
+
BottomButtonParamInvalid = "WebAppBottomButtonParamInvalid",
|
|
41
|
+
HapticImpactStyleInvalid = "WebAppHapticImpactStyleInvalid",
|
|
42
|
+
HapticNotificationTypeInvalid = "WebAppHapticNotificationTypeInvalid",
|
|
43
|
+
HapticFeedbackTypeInvalid = "WebAppHapticFeedbackTypeInvalid",
|
|
44
|
+
BiometricManagerNotInited = "WebAppBiometricManagerNotInited",
|
|
45
|
+
BiometricManagerBiometricsNotAvailable = "WebAppBiometricManagerBiometricsNotAvailable",
|
|
46
|
+
BiometricManagerAccessRequested = "WebAppBiometricManagerAccessRequested",
|
|
47
|
+
BiometricManagerBiometricAccessNotGranted = "WebAppBiometricManagerBiometricAccessNotGranted",
|
|
48
|
+
BiometricManagerAuthenticationRequested = "WebAppBiometricManagerAuthenticationRequested",
|
|
49
|
+
BiometricManagerTokenInvalid = "WebAppBiometricManagerTokenInvalid",
|
|
50
|
+
BiometricManagerTokenUpdateRequested = "WebAppBiometricManagerTokenUpdateRequested",
|
|
51
|
+
BiometricManagerBiometricsAccessNotRequested = "WebAppBiometricManagerBiometricsAccessNotRequested",
|
|
52
|
+
BiometricRequestAccessParamInvalid = "WebAppBiometricRequestAccessParamInvalid",
|
|
53
|
+
LocationManagerNotInited = "WebAppLocationManagerNotInited",
|
|
54
|
+
LocationManagerLocationNotAvailable = "WebAppLocationManagerLocationNotAvailable",
|
|
55
|
+
LocationManagerLocationAccessNotRequested = "WebAppLocationManagerLocationAccessNotRequested",
|
|
56
|
+
CallbackIdGenerateFailed = "WebAppCallbackIdGenerateFailed"
|
|
57
|
+
}
|
|
58
|
+
declare class WebAppError extends Error {
|
|
59
|
+
constructor(name: WebAppErrorName);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Viewport & window-chrome manager.
|
|
64
|
+
*
|
|
65
|
+
* Covers everything related to the app's visible area and window behavior:
|
|
66
|
+
* viewport height/expansion, safe-area insets, fullscreen state,
|
|
67
|
+
* orientation lock, the closing confirmation dialog and vertical swipe
|
|
68
|
+
* toggling. All of it was interleaved with theme code in the original
|
|
69
|
+
* single closure; split out here since it is a clearly separate concern.
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
declare class ViewportManager {
|
|
73
|
+
private readonly kernel;
|
|
74
|
+
private viewportHeightPx;
|
|
75
|
+
private viewportStableHeightPx;
|
|
76
|
+
private _isExpanded;
|
|
77
|
+
private _safeAreaInset;
|
|
78
|
+
private _contentSafeAreaInset;
|
|
79
|
+
private _isFullscreen;
|
|
80
|
+
private _isOrientationLocked;
|
|
81
|
+
private _isClosingConfirmationEnabled;
|
|
82
|
+
private _isVerticalSwipesEnabled;
|
|
83
|
+
private lastWindowHeight;
|
|
84
|
+
constructor(kernel: WebAppKernel);
|
|
85
|
+
get isExpanded(): boolean;
|
|
86
|
+
get viewportHeight(): number;
|
|
87
|
+
get viewportStableHeight(): number;
|
|
88
|
+
get safeAreaInset(): SafeAreaInset;
|
|
89
|
+
get contentSafeAreaInset(): SafeAreaInset;
|
|
90
|
+
get isFullscreen(): boolean;
|
|
91
|
+
get isOrientationLocked(): boolean;
|
|
92
|
+
get isClosingConfirmationEnabled(): boolean;
|
|
93
|
+
get isVerticalSwipesEnabled(): boolean;
|
|
94
|
+
/** Re-applies the current viewport CSS vars; call after bottom-bar height changes too. */
|
|
95
|
+
setViewportHeight(data?: {
|
|
96
|
+
height: number;
|
|
97
|
+
is_expanded?: boolean;
|
|
98
|
+
is_state_stable?: boolean;
|
|
99
|
+
}): void;
|
|
100
|
+
handleViewportChanged: (_eventType: string, eventData: any) => void;
|
|
101
|
+
onWindowResize(): void;
|
|
102
|
+
setSafeAreaInset(data?: Partial<SafeAreaInset>): void;
|
|
103
|
+
handleSafeAreaChanged: (_eventType: string, eventData: any) => void;
|
|
104
|
+
setContentSafeAreaInset(data?: Partial<SafeAreaInset>): void;
|
|
105
|
+
handleContentSafeAreaChanged: (_eventType: string, eventData: any) => void;
|
|
106
|
+
setClosingConfirmation(needConfirmation: boolean): void;
|
|
107
|
+
toggleVerticalSwipes(enableSwipes: boolean): void;
|
|
108
|
+
private setFullscreen;
|
|
109
|
+
handleFullscreenChanged: (_eventType: string, eventData: any) => void;
|
|
110
|
+
handleFullscreenFailed: (_eventType: string, eventData: any) => void;
|
|
111
|
+
requestFullscreen(): void;
|
|
112
|
+
exitFullscreen(): void;
|
|
113
|
+
private setOrientationLock;
|
|
114
|
+
toggleOrientationLock(locked: boolean): void;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* `WebApp.showPopup` / `showAlert` / `showConfirm`.
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
type PopupCallback = (buttonId: string | null) => void;
|
|
122
|
+
type AlertCallback = () => void;
|
|
123
|
+
type ConfirmCallback = (ok: boolean) => void;
|
|
124
|
+
declare class PopupManager {
|
|
125
|
+
private readonly kernel;
|
|
126
|
+
private pending;
|
|
127
|
+
constructor(kernel: WebAppKernel);
|
|
128
|
+
private handlePopupClosed;
|
|
129
|
+
showPopup(params: PopupParams, callback?: PopupCallback): void;
|
|
130
|
+
showAlert(message: string, callback?: AlertCallback): void;
|
|
131
|
+
showConfirm(message: string, callback?: ConfirmCallback): void;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* `WebApp.showScanQrPopup` / `closeScanQrPopup`.
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
/** Return `true` from the callback to close the popup automatically. */
|
|
139
|
+
type ScanQrCallback = (data: string | null) => boolean | void;
|
|
140
|
+
declare class ScanQrManager {
|
|
141
|
+
private readonly kernel;
|
|
142
|
+
private pending;
|
|
143
|
+
constructor(kernel: WebAppKernel);
|
|
144
|
+
private handleQrTextReceived;
|
|
145
|
+
private handleScanQrPopupClosed;
|
|
146
|
+
showScanQrPopup(params: ScanQrPopupParams, callback?: ScanQrCallback): void;
|
|
147
|
+
closeScanQrPopup(): void;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* `WebApp.openInvoice`.
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
type InvoiceStatus = 'paid' | 'cancelled' | 'failed' | 'pending';
|
|
155
|
+
type InvoiceCallback = (status: InvoiceStatus) => void;
|
|
156
|
+
declare class InvoiceManager {
|
|
157
|
+
private readonly kernel;
|
|
158
|
+
private openInvoices;
|
|
159
|
+
constructor(kernel: WebAppKernel);
|
|
160
|
+
private handleInvoiceClosed;
|
|
161
|
+
openInvoice(url: string, callback?: InvoiceCallback): void;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* `WebApp.readTextFromClipboard`.
|
|
166
|
+
*/
|
|
167
|
+
|
|
168
|
+
type ClipboardCallback = (data: string | null) => void;
|
|
169
|
+
declare class ClipboardManager {
|
|
170
|
+
private readonly kernel;
|
|
171
|
+
constructor(kernel: WebAppKernel);
|
|
172
|
+
private handleClipboardTextReceived;
|
|
173
|
+
readTextFromClipboard(callback?: ClipboardCallback): void;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* `WebApp.requestWriteAccess` / `WebApp.requestContact`.
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
type WriteAccessCallback = (granted: boolean) => void;
|
|
181
|
+
type ContactCallback = (sent: boolean, eventPayload: Record<string, any>) => void;
|
|
182
|
+
declare class ContactManager {
|
|
183
|
+
private readonly kernel;
|
|
184
|
+
private writeAccessRequested;
|
|
185
|
+
private contactRequested;
|
|
186
|
+
constructor(kernel: WebAppKernel);
|
|
187
|
+
private handleWriteAccessRequested;
|
|
188
|
+
private handlePhoneRequested;
|
|
189
|
+
requestWriteAccess(callback?: WriteAccessCallback): void;
|
|
190
|
+
requestContact(callback?: ContactCallback): void;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* `WebApp.addToHomeScreen` / `WebApp.checkHomeScreenStatus`.
|
|
195
|
+
*/
|
|
196
|
+
|
|
197
|
+
type StatusCallback = (status: HomeScreenStatus) => void;
|
|
198
|
+
declare class HomeScreenManager {
|
|
199
|
+
private readonly kernel;
|
|
200
|
+
private statusCallbacks;
|
|
201
|
+
constructor(kernel: WebAppKernel);
|
|
202
|
+
private handleAdded;
|
|
203
|
+
private handleChecked;
|
|
204
|
+
addToHomeScreen(): void;
|
|
205
|
+
checkHomeScreenStatus(callback?: StatusCallback): void;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* `WebApp.downloadFile`.
|
|
210
|
+
*/
|
|
211
|
+
|
|
212
|
+
type DownloadCallback = (isDownloading: boolean) => void;
|
|
213
|
+
declare class DownloadFileManager {
|
|
214
|
+
private readonly kernel;
|
|
215
|
+
private requested;
|
|
216
|
+
constructor(kernel: WebAppKernel);
|
|
217
|
+
private handleFileDownloadRequested;
|
|
218
|
+
downloadFile(params: DownloadFileParams, callback?: DownloadCallback): void;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Sharing-related surface: `shareToStory`, `shareMessage`, `requestChat`,
|
|
223
|
+
* `switchInlineQuery`.
|
|
224
|
+
*/
|
|
225
|
+
|
|
226
|
+
type SentCallback = (sent: boolean) => void;
|
|
227
|
+
declare class SharingManager {
|
|
228
|
+
private readonly kernel;
|
|
229
|
+
private shareMessageOpened;
|
|
230
|
+
private requestChatOpened;
|
|
231
|
+
constructor(kernel: WebAppKernel);
|
|
232
|
+
private handlePreparedMessageSent;
|
|
233
|
+
private handlePreparedMessageFailed;
|
|
234
|
+
private handleRequestedChatSent;
|
|
235
|
+
private handleRequestedChatFailed;
|
|
236
|
+
shareToStory(mediaUrl: string, params?: ShareToStoryParams): void;
|
|
237
|
+
shareMessage(msgId: string, callback?: SentCallback): void;
|
|
238
|
+
requestChat(reqId: string, callback?: SentCallback): void;
|
|
239
|
+
switchInlineQuery(query: string, chooseChatTypes: string[] | undefined, initParams: InitParams): void;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* `WebApp.setEmojiStatus` / `WebApp.requestEmojiStatusAccess`.
|
|
244
|
+
*/
|
|
245
|
+
|
|
246
|
+
type SetStatusCallback = (applied: boolean) => void;
|
|
247
|
+
type AccessCallback = (granted: boolean) => void;
|
|
248
|
+
declare class EmojiStatusManager {
|
|
249
|
+
private readonly kernel;
|
|
250
|
+
private setRequested;
|
|
251
|
+
private accessRequested;
|
|
252
|
+
constructor(kernel: WebAppKernel);
|
|
253
|
+
private handleSet;
|
|
254
|
+
private handleFailed;
|
|
255
|
+
private handleAccessRequested;
|
|
256
|
+
setEmojiStatus(customEmojiId: string, params?: {
|
|
257
|
+
duration?: number;
|
|
258
|
+
}, callback?: SetStatusCallback): void;
|
|
259
|
+
requestEmojiStatusAccess(callback?: AccessCallback): void;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* `WebApp.openLink` / `WebApp.openTelegramLink` + the iframe `<a href="t.me/...">`
|
|
264
|
+
* click interception (`linkHandler` in the original script).
|
|
265
|
+
*/
|
|
266
|
+
|
|
267
|
+
declare class LinkManager {
|
|
268
|
+
private readonly kernel;
|
|
269
|
+
constructor(kernel: WebAppKernel);
|
|
270
|
+
openLink(url: string, options?: OpenLinkOptions): void;
|
|
271
|
+
openTelegramLink(url: string, options?: OpenTelegramLinkOptions): void;
|
|
272
|
+
/**
|
|
273
|
+
* Intercepts clicks on in-page `t.me` links while running inside an
|
|
274
|
+
* iframe (web.telegram.org) and routes them through `openTelegramLink`
|
|
275
|
+
* instead of letting the browser navigate directly.
|
|
276
|
+
*/
|
|
277
|
+
handleDocumentClick: (e: MouseEvent) => void;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* `@core-ease/telegram-kit/sdk` - public entry point of the bundled Mini
|
|
282
|
+
* Apps SDK.
|
|
283
|
+
*
|
|
284
|
+
* Everything that actually implements the protocol lives under
|
|
285
|
+
* `./_internal/` (transport, kernel, theme, ui, features, sensors) and is
|
|
286
|
+
* considered an implementation detail - import from here, not from
|
|
287
|
+
* `./_internal/*` directly.
|
|
288
|
+
*
|
|
289
|
+
* Calling {@link bootstrapTelegramWebApp} reproduces exactly what the
|
|
290
|
+
* original `telegram-web-app.js` did when loaded as a `<script>` tag:
|
|
291
|
+
* 1. Set up `window.Telegram.WebView` (transport + event bus) and
|
|
292
|
+
* `window.Telegram.Utils`.
|
|
293
|
+
* 2. Set up `window.Telegram.WebApp` (the full public API).
|
|
294
|
+
*
|
|
295
|
+
* Unlike the very first version of this SDK, bootstrapping is **lazy**
|
|
296
|
+
* (it does not run automatically just from importing this module). This
|
|
297
|
+
* lets `core/dev.ts` seed fake init data into session storage *before* the
|
|
298
|
+
* bridge is constructed, so local/dev-mode "just works" through the exact
|
|
299
|
+
* same code path as running inside real Telegram - no parallel mock
|
|
300
|
+
* implementation needed. In practice you never have to think about this:
|
|
301
|
+
* `getWebApp()` in `core/index.ts` calls {@link bootstrapTelegramWebApp}
|
|
302
|
+
* for you on first use.
|
|
303
|
+
*/
|
|
304
|
+
|
|
305
|
+
declare const SDK_NAME = "@core-ease/telegram-kit";
|
|
306
|
+
/**
|
|
307
|
+
* Runs the SDK bootstrap exactly once (idempotent) and exposes
|
|
308
|
+
* `window.Telegram.{WebView,Utils,WebApp}`. Safe to call in non-browser
|
|
309
|
+
* contexts (returns nothing useful but never throws), so it's safe to wire
|
|
310
|
+
* into SSR code paths.
|
|
311
|
+
*
|
|
312
|
+
* This is normally called for you by `getWebApp()` in `core/index.ts` the
|
|
313
|
+
* first time any @core-ease/telegram-kit function is used - you only need to call it
|
|
314
|
+
* yourself if you want direct, typed access to the `WebApp`/`TelegramWebView`
|
|
315
|
+
* instances instead of going through the `core`/`hooks` convenience layer.
|
|
316
|
+
*/
|
|
317
|
+
declare function bootstrapTelegramWebApp(): {
|
|
318
|
+
webView: TelegramWebView;
|
|
319
|
+
webApp: WebApp;
|
|
320
|
+
};
|
|
321
|
+
/** True once {@link bootstrapTelegramWebApp} has run at least once. */
|
|
322
|
+
declare function isBootstrapped(): boolean;
|
|
323
|
+
|
|
324
|
+
declare const index_Accelerometer: typeof Accelerometer;
|
|
325
|
+
declare const index_AnyRecord: typeof AnyRecord;
|
|
326
|
+
declare const index_BackButton: typeof BackButton;
|
|
327
|
+
declare const index_BiometricAuthenticateParams: typeof BiometricAuthenticateParams;
|
|
328
|
+
declare const index_BiometricManager: typeof BiometricManager;
|
|
329
|
+
declare const index_BiometricRequestAccessParams: typeof BiometricRequestAccessParams;
|
|
330
|
+
declare const index_BiometricType: typeof BiometricType;
|
|
331
|
+
declare const index_BottomButton: typeof BottomButton;
|
|
332
|
+
declare const index_BottomButtonParams: typeof BottomButtonParams;
|
|
333
|
+
declare const index_BottomButtonPosition: typeof BottomButtonPosition;
|
|
334
|
+
type index_ClipboardManager = ClipboardManager;
|
|
335
|
+
declare const index_ClipboardManager: typeof ClipboardManager;
|
|
336
|
+
declare const index_CloseOptions: typeof CloseOptions;
|
|
337
|
+
declare const index_CloudStorage: typeof CloudStorage;
|
|
338
|
+
declare const index_ColorScheme: typeof ColorScheme;
|
|
339
|
+
type index_ContactManager = ContactManager;
|
|
340
|
+
declare const index_ContactManager: typeof ContactManager;
|
|
341
|
+
declare const index_DebugBottomBar: typeof DebugBottomBar;
|
|
342
|
+
declare const index_DefaultColors: typeof DefaultColors;
|
|
343
|
+
declare const index_DeviceOrientation: typeof DeviceOrientation;
|
|
344
|
+
declare const index_DeviceOrientationStartParams: typeof DeviceOrientationStartParams;
|
|
345
|
+
declare const index_DeviceStorage: typeof DeviceStorage;
|
|
346
|
+
type index_DownloadFileManager = DownloadFileManager;
|
|
347
|
+
declare const index_DownloadFileManager: typeof DownloadFileManager;
|
|
348
|
+
declare const index_DownloadFileParams: typeof DownloadFileParams;
|
|
349
|
+
type index_EmojiStatusManager = EmojiStatusManager;
|
|
350
|
+
declare const index_EmojiStatusManager: typeof EmojiStatusManager;
|
|
351
|
+
declare const index_ErrCallback: typeof ErrCallback;
|
|
352
|
+
declare const index_EventHandler: typeof EventHandler;
|
|
353
|
+
declare const index_Gyroscope: typeof Gyroscope;
|
|
354
|
+
declare const index_HapticFeedback: typeof HapticFeedback;
|
|
355
|
+
declare const index_HapticImpactStyle: typeof HapticImpactStyle;
|
|
356
|
+
declare const index_HapticNotificationType: typeof HapticNotificationType;
|
|
357
|
+
type index_HomeScreenManager = HomeScreenManager;
|
|
358
|
+
declare const index_HomeScreenManager: typeof HomeScreenManager;
|
|
359
|
+
declare const index_HomeScreenStatus: typeof HomeScreenStatus;
|
|
360
|
+
declare const index_InitParams: typeof InitParams;
|
|
361
|
+
type index_InvoiceManager = InvoiceManager;
|
|
362
|
+
declare const index_InvoiceManager: typeof InvoiceManager;
|
|
363
|
+
declare const index_ItemsCallback: typeof ItemsCallback;
|
|
364
|
+
type index_LinkManager = LinkManager;
|
|
365
|
+
declare const index_LinkManager: typeof LinkManager;
|
|
366
|
+
declare const index_LocationData: typeof LocationData;
|
|
367
|
+
declare const index_LocationManager: typeof LocationManager;
|
|
368
|
+
declare const index_MotionSensorStartParams: typeof MotionSensorStartParams;
|
|
369
|
+
declare const index_OpenLinkOptions: typeof OpenLinkOptions;
|
|
370
|
+
declare const index_OpenTelegramLinkOptions: typeof OpenTelegramLinkOptions;
|
|
371
|
+
declare const index_PopupButton: typeof PopupButton;
|
|
372
|
+
declare const index_PopupButtonType: typeof PopupButtonType;
|
|
373
|
+
type index_PopupManager = PopupManager;
|
|
374
|
+
declare const index_PopupManager: typeof PopupManager;
|
|
375
|
+
declare const index_PopupParams: typeof PopupParams;
|
|
376
|
+
declare const index_SDK_NAME: typeof SDK_NAME;
|
|
377
|
+
declare const index_SafeAreaInset: typeof SafeAreaInset;
|
|
378
|
+
type index_ScanQrManager = ScanQrManager;
|
|
379
|
+
declare const index_ScanQrManager: typeof ScanQrManager;
|
|
380
|
+
declare const index_ScanQrPopupParams: typeof ScanQrPopupParams;
|
|
381
|
+
declare const index_SecureStorage: typeof SecureStorage;
|
|
382
|
+
declare const index_SettingsButton: typeof SettingsButton;
|
|
383
|
+
declare const index_ShareToStoryParams: typeof ShareToStoryParams;
|
|
384
|
+
declare const index_ShareToStoryWidgetLink: typeof ShareToStoryWidgetLink;
|
|
385
|
+
type index_SharingManager = SharingManager;
|
|
386
|
+
declare const index_SharingManager: typeof SharingManager;
|
|
387
|
+
declare const index_TelegramWebView: typeof TelegramWebView;
|
|
388
|
+
declare const index_ThemeManager: typeof ThemeManager;
|
|
389
|
+
declare const index_ThemeParams: typeof ThemeParams;
|
|
390
|
+
declare const index_Utils: typeof Utils;
|
|
391
|
+
type index_ViewportManager = ViewportManager;
|
|
392
|
+
declare const index_ViewportManager: typeof ViewportManager;
|
|
393
|
+
declare const index_VoidCallback: typeof VoidCallback;
|
|
394
|
+
declare const index_WebApp: typeof WebApp;
|
|
395
|
+
declare const index_WebAppChat: typeof WebAppChat;
|
|
396
|
+
type index_WebAppError = WebAppError;
|
|
397
|
+
declare const index_WebAppError: typeof WebAppError;
|
|
398
|
+
type index_WebAppErrorName = WebAppErrorName;
|
|
399
|
+
declare const index_WebAppErrorName: typeof WebAppErrorName;
|
|
400
|
+
declare const index_WebAppInitDataUnsafe: typeof WebAppInitDataUnsafe;
|
|
401
|
+
declare const index_WebAppKernel: typeof WebAppKernel;
|
|
402
|
+
declare const index_WebAppUser: typeof WebAppUser;
|
|
403
|
+
declare const index_bootstrapTelegramWebApp: typeof bootstrapTelegramWebApp;
|
|
404
|
+
declare const index_isBootstrapped: typeof isBootstrapped;
|
|
405
|
+
declare namespace index {
|
|
406
|
+
export { index_Accelerometer as Accelerometer, index_AnyRecord as AnyRecord, index_BackButton as BackButton, index_BiometricAuthenticateParams as BiometricAuthenticateParams, index_BiometricManager as BiometricManager, index_BiometricRequestAccessParams as BiometricRequestAccessParams, index_BiometricType as BiometricType, index_BottomButton as BottomButton, index_BottomButtonParams as BottomButtonParams, index_BottomButtonPosition as BottomButtonPosition, index_ClipboardManager as ClipboardManager, index_CloseOptions as CloseOptions, index_CloudStorage as CloudStorage, index_ColorScheme as ColorScheme, index_ContactManager as ContactManager, index_DebugBottomBar as DebugBottomBar, index_DefaultColors as DefaultColors, index_DeviceOrientation as DeviceOrientation, index_DeviceOrientationStartParams as DeviceOrientationStartParams, index_DeviceStorage as DeviceStorage, index_DownloadFileManager as DownloadFileManager, index_DownloadFileParams as DownloadFileParams, index_EmojiStatusManager as EmojiStatusManager, index_ErrCallback as ErrCallback, index_EventHandler as EventHandler, index_Gyroscope as Gyroscope, index_HapticFeedback as HapticFeedback, index_HapticImpactStyle as HapticImpactStyle, index_HapticNotificationType as HapticNotificationType, index_HomeScreenManager as HomeScreenManager, index_HomeScreenStatus as HomeScreenStatus, index_InitParams as InitParams, index_InvoiceManager as InvoiceManager, index_ItemsCallback as ItemsCallback, index_LinkManager as LinkManager, index_LocationData as LocationData, index_LocationManager as LocationManager, index_MotionSensorStartParams as MotionSensorStartParams, index_OpenLinkOptions as OpenLinkOptions, index_OpenTelegramLinkOptions as OpenTelegramLinkOptions, index_PopupButton as PopupButton, index_PopupButtonType as PopupButtonType, index_PopupManager as PopupManager, index_PopupParams as PopupParams, index_SDK_NAME as SDK_NAME, index_SafeAreaInset as SafeAreaInset, index_ScanQrManager as ScanQrManager, index_ScanQrPopupParams as ScanQrPopupParams, index_SecureStorage as SecureStorage, index_SettingsButton as SettingsButton, index_ShareToStoryParams as ShareToStoryParams, index_ShareToStoryWidgetLink as ShareToStoryWidgetLink, index_SharingManager as SharingManager, index_TelegramWebView as TelegramWebView, index_ThemeManager as ThemeManager, index_ThemeParams as ThemeParams, index_Utils as Utils, index_ViewportManager as ViewportManager, index_VoidCallback as VoidCallback, index_WebApp as WebApp, index_WebAppChat as WebAppChat, index_WebAppError as WebAppError, index_WebAppErrorName as WebAppErrorName, index_WebAppInitDataUnsafe as WebAppInitDataUnsafe, index_WebAppKernel as WebAppKernel, index_WebAppUser as WebAppUser, index_bootstrapTelegramWebApp as bootstrapTelegramWebApp, index_isBootstrapped as isBootstrapped };
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Browser-native fallbacks for `@core-ease/telegram-kit`.
|
|
411
|
+
*
|
|
412
|
+
* Every wrapper in `core/index.ts` calls into the real bundled SDK first.
|
|
413
|
+
* When that isn't possible - the Mini App is opened in a plain browser tab,
|
|
414
|
+
* or the installed Telegram client is older than a feature needs - these
|
|
415
|
+
* helpers provide the closest standard Web API equivalent instead of
|
|
416
|
+
* rejecting the call or spamming the console with "not supported"
|
|
417
|
+
* warnings. Where no meaningful browser equivalent exists (biometrics,
|
|
418
|
+
* emoji status, Telegram-account actions, ...) the wrapper still resolves
|
|
419
|
+
* predictably (`false`/`null`/`[]`) instead of throwing.
|
|
420
|
+
*/
|
|
421
|
+
|
|
422
|
+
/** Swallows synchronous throws from fire-and-forget SDK calls (e.g. hard version gates). */
|
|
423
|
+
declare function safeInvoke(fn: () => void): void;
|
|
424
|
+
|
|
425
|
+
/** Returns the bundled SDK's `WebApp` instance directly (never reads `window.Telegram`). */
|
|
426
|
+
declare function getWebApp(): WebApp | null;
|
|
427
|
+
/**
|
|
428
|
+
* `true` once real Telegram init data has been observed - i.e. the Mini
|
|
429
|
+
* App was actually opened from inside Telegram, or `installDevMode()`
|
|
430
|
+
* seeded matching fake data for local testing.
|
|
431
|
+
*/
|
|
432
|
+
declare function isInTelegram(): boolean;
|
|
433
|
+
declare function isVersionAtLeast(version: string): boolean;
|
|
434
|
+
declare function getRawUserData(): WebAppUser | null;
|
|
435
|
+
declare function getUserDisplayName(user?: WebAppUser): string;
|
|
436
|
+
declare function getUserIdentifier(user?: WebAppUser): string;
|
|
437
|
+
declare function getUserAvatarUrl(user?: WebAppUser, fallback?: string): string;
|
|
438
|
+
declare function getUserInfoWithAvatar(): {
|
|
439
|
+
user: WebAppUser | undefined;
|
|
440
|
+
avatarUrl: string;
|
|
441
|
+
displayName: string;
|
|
442
|
+
identifier: string;
|
|
443
|
+
};
|
|
444
|
+
declare function openExternalLink(url: string, tryInstantView?: boolean): void;
|
|
445
|
+
declare function openTelegramLink(url: string): void;
|
|
446
|
+
/** No meaningful browser fallback exists for Telegram Payments; rejects clearly instead of hanging. */
|
|
447
|
+
declare function openInvoice(url: string): Promise<'paid' | 'cancelled' | 'failed' | 'pending'>;
|
|
448
|
+
declare function switchInlineQuery(query: string, chooseChatTypes?: Array<'users' | 'bots' | 'groups' | 'channels'>): void;
|
|
449
|
+
declare function hideKeyboard(): void;
|
|
450
|
+
declare function getTheme(): {
|
|
451
|
+
colorScheme: ColorScheme;
|
|
452
|
+
themeParams: ThemeParams;
|
|
453
|
+
};
|
|
454
|
+
declare function getViewport(): {
|
|
455
|
+
height: number;
|
|
456
|
+
stableHeight: number;
|
|
457
|
+
isExpanded: boolean;
|
|
458
|
+
};
|
|
459
|
+
declare function expand(): void;
|
|
460
|
+
declare function ready(): void;
|
|
461
|
+
declare function close(): void;
|
|
462
|
+
/** Fullscreen API fallback outside Telegram / older clients. */
|
|
463
|
+
declare const fullscreen: {
|
|
464
|
+
enter: () => Promise<boolean>;
|
|
465
|
+
exit: () => Promise<boolean>;
|
|
466
|
+
};
|
|
467
|
+
/** Screen Orientation API fallback outside Telegram / older clients. */
|
|
468
|
+
declare const orientation: {
|
|
469
|
+
lock: () => Promise<boolean>;
|
|
470
|
+
unlock: () => Promise<boolean>;
|
|
471
|
+
};
|
|
472
|
+
declare function enableClosingConfirmation(): void;
|
|
473
|
+
declare function disableClosingConfirmation(): void;
|
|
474
|
+
declare function enableVerticalSwipes(): void;
|
|
475
|
+
declare function disableVerticalSwipes(): void;
|
|
476
|
+
declare function setHeaderColor(color: string): void;
|
|
477
|
+
declare function setBackgroundColor(color: string): void;
|
|
478
|
+
declare function setBottomBarColor(color: string): void;
|
|
479
|
+
/** No meaningful browser equivalent (this adds a Telegram Mini App shortcut, specifically) - safely no-ops outside Telegram. */
|
|
480
|
+
declare function addToHomeScreen(): void;
|
|
481
|
+
declare function checkHomeScreenStatus(): Promise<'unsupported' | 'unknown' | 'added' | 'missed'>;
|
|
482
|
+
declare const haptic: {
|
|
483
|
+
light: () => void | HapticFeedback;
|
|
484
|
+
medium: () => void | HapticFeedback;
|
|
485
|
+
heavy: () => void | HapticFeedback;
|
|
486
|
+
rigid: () => void | HapticFeedback;
|
|
487
|
+
soft: () => void | HapticFeedback;
|
|
488
|
+
success: () => void | HapticFeedback;
|
|
489
|
+
warning: () => void | HapticFeedback;
|
|
490
|
+
error: () => void | HapticFeedback;
|
|
491
|
+
selection: () => void | HapticFeedback;
|
|
492
|
+
};
|
|
493
|
+
declare const cloudStorage: {
|
|
494
|
+
setItem: (key: string, value: string) => Promise<boolean>;
|
|
495
|
+
getItem: (key: string) => Promise<string | undefined>;
|
|
496
|
+
getItems: (keys: string[]) => Promise<Record<string, string>>;
|
|
497
|
+
removeItem: (key: string) => Promise<boolean>;
|
|
498
|
+
removeItems: (keys: string[]) => Promise<boolean>;
|
|
499
|
+
getKeys: () => Promise<string[]>;
|
|
500
|
+
};
|
|
501
|
+
declare const deviceStorage: {
|
|
502
|
+
setItem: (key: string, value: string) => Promise<boolean>;
|
|
503
|
+
getItem: (key: string) => Promise<string | undefined>;
|
|
504
|
+
removeItem: (key: string) => Promise<boolean>;
|
|
505
|
+
clear: () => Promise<boolean>;
|
|
506
|
+
};
|
|
507
|
+
declare const secureStorage: {
|
|
508
|
+
setItem: (key: string, value: string) => Promise<boolean>;
|
|
509
|
+
getItem: (key: string) => Promise<{
|
|
510
|
+
value: string | null | undefined;
|
|
511
|
+
canRestore: boolean;
|
|
512
|
+
}>;
|
|
513
|
+
removeItem: (key: string) => Promise<boolean>;
|
|
514
|
+
clear: () => Promise<boolean>;
|
|
515
|
+
restoreItem: (key: string) => Promise<string | undefined>;
|
|
516
|
+
};
|
|
517
|
+
declare const dialog: {
|
|
518
|
+
alert: (message: string) => Promise<void>;
|
|
519
|
+
confirm: (message: string) => Promise<boolean>;
|
|
520
|
+
popup: (params: PopupParams) => Promise<string | null>;
|
|
521
|
+
prompt: (message: string, defaultValue?: string) => Promise<string | null>;
|
|
522
|
+
};
|
|
523
|
+
declare function readClipboard(): Promise<string | null>;
|
|
524
|
+
declare function scanQr(text?: string): Promise<string | null>;
|
|
525
|
+
declare function shareToStory(mediaUrl: string, params?: ShareToStoryParams): void;
|
|
526
|
+
declare function shareMessage(msgId: string): Promise<boolean>;
|
|
527
|
+
declare function downloadFile(params: DownloadFileParams): Promise<boolean>;
|
|
528
|
+
declare function setEmojiStatus(customEmojiId: string, params?: EmojiStatusParams): Promise<boolean>;
|
|
529
|
+
declare function requestEmojiStatusAccess(): Promise<boolean>;
|
|
530
|
+
declare function requestWriteAccess(): Promise<boolean>;
|
|
531
|
+
declare function requestContact(): Promise<boolean>;
|
|
532
|
+
/**
|
|
533
|
+
* Opens Telegram's native chat-request dialog for a chat request you
|
|
534
|
+
* already created server-side, identified by `reqId`. Requires Bot API
|
|
535
|
+
* 9.6+. No browser fallback exists for this Telegram-account action.
|
|
536
|
+
*/
|
|
537
|
+
declare function requestChat(reqId: string): Promise<boolean>;
|
|
538
|
+
/** No fallback: this calls your own bot's server-side logic, which only exists via the real Telegram client. */
|
|
539
|
+
declare function invokeCustomMethod(method: string, params?: object): Promise<unknown>;
|
|
540
|
+
declare const biometric: {
|
|
541
|
+
init: () => Promise<void>;
|
|
542
|
+
requestAccess: (reason?: string) => Promise<boolean>;
|
|
543
|
+
authenticate: (reason?: string) => Promise<{
|
|
544
|
+
authenticated: boolean;
|
|
545
|
+
token?: string;
|
|
546
|
+
}>;
|
|
547
|
+
updateBiometricToken: (token: string) => Promise<boolean>;
|
|
548
|
+
openSettings: () => void;
|
|
549
|
+
};
|
|
550
|
+
declare const location: {
|
|
551
|
+
init: () => Promise<void>;
|
|
552
|
+
getLocation: () => Promise<LocationData | null>;
|
|
553
|
+
openSettings: () => void;
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
interface ChatAdministratorRights {
|
|
557
|
+
is_anonymous?: boolean;
|
|
558
|
+
can_manage_chat?: boolean;
|
|
559
|
+
can_delete_messages?: boolean;
|
|
560
|
+
can_manage_video_chats?: boolean;
|
|
561
|
+
can_restrict_members?: boolean;
|
|
562
|
+
can_promote_members?: boolean;
|
|
563
|
+
can_change_info?: boolean;
|
|
564
|
+
can_invite_users?: boolean;
|
|
565
|
+
can_post_stories?: boolean;
|
|
566
|
+
can_edit_stories?: boolean;
|
|
567
|
+
can_delete_stories?: boolean;
|
|
568
|
+
can_post_messages?: boolean;
|
|
569
|
+
can_edit_messages?: boolean;
|
|
570
|
+
can_pin_messages?: boolean;
|
|
571
|
+
can_manage_topics?: boolean;
|
|
572
|
+
}
|
|
573
|
+
interface InlineKeyboardMarkup {
|
|
574
|
+
inline_keyboard: InlineKeyboardButton[][];
|
|
575
|
+
}
|
|
576
|
+
interface InlineKeyboardButton {
|
|
577
|
+
text: string;
|
|
578
|
+
url?: string;
|
|
579
|
+
callback_data?: string;
|
|
580
|
+
web_app?: WebAppInfo;
|
|
581
|
+
login_url?: LoginUrl;
|
|
582
|
+
switch_inline_query?: string;
|
|
583
|
+
switch_inline_query_current_chat?: string;
|
|
584
|
+
switch_inline_query_chosen_chat?: SwitchInlineQueryChosenChat;
|
|
585
|
+
copy_text?: CopyTextButton;
|
|
586
|
+
callback_game?: CallbackGame;
|
|
587
|
+
pay?: boolean;
|
|
588
|
+
}
|
|
589
|
+
interface WebAppInfo {
|
|
590
|
+
url: string;
|
|
591
|
+
}
|
|
592
|
+
interface LoginUrl {
|
|
593
|
+
url: string;
|
|
594
|
+
forward_text?: string;
|
|
595
|
+
bot_username?: string;
|
|
596
|
+
request_write_access?: boolean;
|
|
597
|
+
}
|
|
598
|
+
interface SwitchInlineQueryChosenChat {
|
|
599
|
+
query?: string;
|
|
600
|
+
allow_user_chats?: boolean;
|
|
601
|
+
allow_bot_chats?: boolean;
|
|
602
|
+
allow_group_chats?: boolean;
|
|
603
|
+
allow_channel_chats?: boolean;
|
|
604
|
+
}
|
|
605
|
+
interface CopyTextButton {
|
|
606
|
+
text: string;
|
|
607
|
+
}
|
|
608
|
+
interface CallbackGame {
|
|
609
|
+
}
|
|
610
|
+
interface ReplyKeyboardMarkup {
|
|
611
|
+
keyboard: KeyboardButton[][];
|
|
612
|
+
is_persistent?: boolean;
|
|
613
|
+
resize_keyboard?: boolean;
|
|
614
|
+
one_time_keyboard?: boolean;
|
|
615
|
+
input_field_placeholder?: string;
|
|
616
|
+
selective?: boolean;
|
|
617
|
+
}
|
|
618
|
+
interface KeyboardButton {
|
|
619
|
+
text: string;
|
|
620
|
+
request_users?: KeyboardButtonRequestUsers;
|
|
621
|
+
request_chat?: KeyboardButtonRequestChat;
|
|
622
|
+
request_contact?: boolean;
|
|
623
|
+
request_location?: boolean;
|
|
624
|
+
request_poll?: KeyboardButtonPollType;
|
|
625
|
+
web_app?: WebAppInfo;
|
|
626
|
+
}
|
|
627
|
+
interface KeyboardButtonRequestUsers {
|
|
628
|
+
request_id: number;
|
|
629
|
+
user_is_bot?: boolean;
|
|
630
|
+
user_is_premium?: boolean;
|
|
631
|
+
max_quantity?: number;
|
|
632
|
+
request_name?: boolean;
|
|
633
|
+
request_username?: boolean;
|
|
634
|
+
request_photo?: boolean;
|
|
635
|
+
}
|
|
636
|
+
interface KeyboardButtonRequestChat {
|
|
637
|
+
request_id: number;
|
|
638
|
+
chat_is_channel: boolean;
|
|
639
|
+
chat_is_forum?: boolean;
|
|
640
|
+
chat_has_username?: boolean;
|
|
641
|
+
chat_is_created?: boolean;
|
|
642
|
+
user_administrator_rights?: ChatAdministratorRights;
|
|
643
|
+
bot_administrator_rights?: ChatAdministratorRights;
|
|
644
|
+
bot_is_member?: boolean;
|
|
645
|
+
request_title?: boolean;
|
|
646
|
+
request_username?: boolean;
|
|
647
|
+
request_photo?: boolean;
|
|
648
|
+
}
|
|
649
|
+
interface KeyboardButtonPollType {
|
|
650
|
+
type?: 'quiz' | 'regular';
|
|
651
|
+
}
|
|
652
|
+
interface ReplyKeyboardRemove {
|
|
653
|
+
remove_keyboard: true;
|
|
654
|
+
selective?: boolean;
|
|
655
|
+
}
|
|
656
|
+
interface ForceReply {
|
|
657
|
+
force_reply: true;
|
|
658
|
+
input_field_placeholder?: string;
|
|
659
|
+
selective?: boolean;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
interface TelegramContextValue {
|
|
663
|
+
ready: boolean;
|
|
664
|
+
inTelegram: boolean;
|
|
665
|
+
isDevBypass: boolean;
|
|
666
|
+
webApp: TgWebApp | null;
|
|
667
|
+
user: WebAppUser | null;
|
|
668
|
+
colorScheme: 'light' | 'dark';
|
|
669
|
+
startParam: string | null;
|
|
670
|
+
}
|
|
671
|
+
interface TelegramProviderOptions {
|
|
672
|
+
onUserReady?: (user: WebAppUser) => void;
|
|
673
|
+
onReady?: (wa: TgWebApp) => void;
|
|
674
|
+
loadingComponent?: ReactNode;
|
|
675
|
+
notInTelegramComponent?: ReactNode;
|
|
676
|
+
allowOutsideTelegram?: boolean;
|
|
677
|
+
autoExpand?: boolean;
|
|
678
|
+
autoDisableVerticalSwipes?: boolean;
|
|
679
|
+
autoEnableClosingConfirmation?: boolean;
|
|
680
|
+
headerColor?: string;
|
|
681
|
+
backgroundColor?: string;
|
|
682
|
+
bottomBarColor?: string;
|
|
683
|
+
}
|
|
684
|
+
declare function useTelegram(): TelegramContextValue;
|
|
685
|
+
declare function TelegramProvider({ children, options, }: {
|
|
686
|
+
children: ReactNode;
|
|
687
|
+
options?: TelegramProviderOptions;
|
|
688
|
+
}): React.JSX.Element;
|
|
689
|
+
|
|
690
|
+
declare class TelegramFormattedText {
|
|
691
|
+
readonly raw: string;
|
|
692
|
+
constructor(raw: string);
|
|
693
|
+
toString(): string;
|
|
694
|
+
}
|
|
695
|
+
type TextPart = string | TelegramFormattedText;
|
|
696
|
+
declare function escapeMarkdownV2(text: string): string;
|
|
697
|
+
declare function escapeMarkdownV2Code(text: string): string;
|
|
698
|
+
declare function escapeMarkdownV2LinkUrl(url: string): string;
|
|
699
|
+
declare function escapeHTML(text: string): string;
|
|
700
|
+
declare function escapeHTMLAttribute(text: string): string;
|
|
701
|
+
declare const md: {
|
|
702
|
+
escape: typeof escapeMarkdownV2;
|
|
703
|
+
escapeCode: typeof escapeMarkdownV2Code;
|
|
704
|
+
escapeLinkUrl: typeof escapeMarkdownV2LinkUrl;
|
|
705
|
+
text: (...parts: TextPart[]) => TelegramFormattedText;
|
|
706
|
+
bold: (...parts: TextPart[]) => TelegramFormattedText;
|
|
707
|
+
italic: (...parts: TextPart[]) => TelegramFormattedText;
|
|
708
|
+
underline: (...parts: TextPart[]) => TelegramFormattedText;
|
|
709
|
+
strikethrough: (...parts: TextPart[]) => TelegramFormattedText;
|
|
710
|
+
spoiler: (...parts: TextPart[]) => TelegramFormattedText;
|
|
711
|
+
code: (text: string) => TelegramFormattedText;
|
|
712
|
+
pre: (text: string, language?: string) => TelegramFormattedText;
|
|
713
|
+
link: (url: string, ...parts: TextPart[]) => TelegramFormattedText;
|
|
714
|
+
mentionUser: (userId: number, ...parts: TextPart[]) => TelegramFormattedText;
|
|
715
|
+
customEmoji: (emojiId: string, fallbackEmoji: string) => TelegramFormattedText;
|
|
716
|
+
raw: (raw: string) => TelegramFormattedText;
|
|
717
|
+
};
|
|
718
|
+
declare const html: {
|
|
719
|
+
escape: typeof escapeHTML;
|
|
720
|
+
escapeAttribute: typeof escapeHTMLAttribute;
|
|
721
|
+
text: (...parts: TextPart[]) => TelegramFormattedText;
|
|
722
|
+
bold: (...parts: TextPart[]) => TelegramFormattedText;
|
|
723
|
+
italic: (...parts: TextPart[]) => TelegramFormattedText;
|
|
724
|
+
underline: (...parts: TextPart[]) => TelegramFormattedText;
|
|
725
|
+
strikethrough: (...parts: TextPart[]) => TelegramFormattedText;
|
|
726
|
+
spoiler: (...parts: TextPart[]) => TelegramFormattedText;
|
|
727
|
+
code: (text: string) => TelegramFormattedText;
|
|
728
|
+
pre: (text: string, language?: string) => TelegramFormattedText;
|
|
729
|
+
link: (url: string, ...parts: TextPart[]) => TelegramFormattedText;
|
|
730
|
+
mentionUser: (userId: number, ...parts: TextPart[]) => TelegramFormattedText;
|
|
731
|
+
blockquote: (...parts: TextPart[]) => TelegramFormattedText;
|
|
732
|
+
expandableBlockquote: (...parts: TextPart[]) => TelegramFormattedText;
|
|
733
|
+
customEmoji: (emojiId: string, fallbackEmoji: string) => TelegramFormattedText;
|
|
734
|
+
raw: (rawHtml: string) => TelegramFormattedText;
|
|
735
|
+
};
|
|
736
|
+
declare const TELEGRAM_TEXT_LIMITS: {
|
|
737
|
+
readonly MESSAGE: 4096;
|
|
738
|
+
readonly CAPTION: 1024;
|
|
739
|
+
readonly BUTTON_TEXT: 64;
|
|
740
|
+
readonly CALLBACK_DATA: 64;
|
|
741
|
+
readonly START_PARAMETER: 64;
|
|
742
|
+
readonly BOT_DESCRIPTION: 512;
|
|
743
|
+
readonly BOT_SHORT_DESCRIPTION: 120;
|
|
744
|
+
readonly CHAT_TITLE: 128;
|
|
745
|
+
readonly POLL_QUESTION: 300;
|
|
746
|
+
readonly POLL_OPTION: 100;
|
|
747
|
+
};
|
|
748
|
+
declare function truncateText(text: string, maxLength: number, ellipsis?: string): string;
|
|
749
|
+
|
|
750
|
+
declare function isValidStartParam(param: string): boolean;
|
|
751
|
+
declare function encodeStartParam(value: string): string;
|
|
752
|
+
declare function decodeStartParam(param: string): string;
|
|
753
|
+
interface StartParamInput {
|
|
754
|
+
startParam?: string;
|
|
755
|
+
data?: string;
|
|
756
|
+
}
|
|
757
|
+
interface BuildStartLinkOptions extends StartParamInput {
|
|
758
|
+
botUsername: string;
|
|
759
|
+
}
|
|
760
|
+
declare function buildStartLink(options: BuildStartLinkOptions): string;
|
|
761
|
+
interface BuildStartAppLinkOptions extends StartParamInput {
|
|
762
|
+
botUsername: string;
|
|
763
|
+
appName?: string;
|
|
764
|
+
mode?: 'compact' | 'fullscreen';
|
|
765
|
+
}
|
|
766
|
+
declare function buildStartAppLink(options: BuildStartAppLinkOptions): string;
|
|
767
|
+
interface BuildShareLinkOptions {
|
|
768
|
+
url: string;
|
|
769
|
+
text?: string;
|
|
770
|
+
}
|
|
771
|
+
declare function buildShareLink(options: BuildShareLinkOptions): string;
|
|
772
|
+
type ParsedTelegramLink = {
|
|
773
|
+
type: 'profile';
|
|
774
|
+
username: string;
|
|
775
|
+
} | {
|
|
776
|
+
type: 'bot-start';
|
|
777
|
+
username: string;
|
|
778
|
+
startParam: string;
|
|
779
|
+
} | {
|
|
780
|
+
type: 'mini-app';
|
|
781
|
+
username: string;
|
|
782
|
+
appName?: string;
|
|
783
|
+
startParam?: string;
|
|
784
|
+
mode?: string;
|
|
785
|
+
} | {
|
|
786
|
+
type: 'join-chat';
|
|
787
|
+
inviteHash: string;
|
|
788
|
+
} | {
|
|
789
|
+
type: 'private-channel-post';
|
|
790
|
+
internalChatId: string;
|
|
791
|
+
messageId: number;
|
|
792
|
+
} | {
|
|
793
|
+
type: 'share';
|
|
794
|
+
url?: string;
|
|
795
|
+
text?: string;
|
|
796
|
+
} | {
|
|
797
|
+
type: 'unknown';
|
|
798
|
+
url: string;
|
|
799
|
+
};
|
|
800
|
+
declare function parseTelegramLink(link: string): ParsedTelegramLink;
|
|
801
|
+
|
|
802
|
+
declare class InlineKeyboardBuilder {
|
|
803
|
+
private rows;
|
|
804
|
+
private currentRow;
|
|
805
|
+
private add;
|
|
806
|
+
text(text: string, callbackData: string): this;
|
|
807
|
+
url(text: string, url: string): this;
|
|
808
|
+
webApp(text: string, url: string): this;
|
|
809
|
+
login(text: string, loginUrl: string | LoginUrl): this;
|
|
810
|
+
switchInline(text: string, query?: string): this;
|
|
811
|
+
switchInlineCurrentChat(text: string, query?: string): this;
|
|
812
|
+
switchInlineChosenChat(text: string, query?: SwitchInlineQueryChosenChat): this;
|
|
813
|
+
copyText(text: string, copyText: string | CopyTextButton): this;
|
|
814
|
+
pay(text?: string): this;
|
|
815
|
+
callbackGame(text: string): this;
|
|
816
|
+
button(button: InlineKeyboardButton): this;
|
|
817
|
+
row(): this;
|
|
818
|
+
static columns(buttons: InlineKeyboardButton[], perRow: number): InlineKeyboardBuilder;
|
|
819
|
+
build(): InlineKeyboardMarkup;
|
|
820
|
+
}
|
|
821
|
+
interface ReplyKeyboardBuildOptions {
|
|
822
|
+
resize?: boolean;
|
|
823
|
+
oneTime?: boolean;
|
|
824
|
+
selective?: boolean;
|
|
825
|
+
placeholder?: string;
|
|
826
|
+
persistent?: boolean;
|
|
827
|
+
}
|
|
828
|
+
declare class ReplyKeyboardBuilder {
|
|
829
|
+
private rows;
|
|
830
|
+
private currentRow;
|
|
831
|
+
private add;
|
|
832
|
+
text(label: string): this;
|
|
833
|
+
requestContact(label: string): this;
|
|
834
|
+
requestLocation(label: string): this;
|
|
835
|
+
requestPoll(label: string, type?: KeyboardButtonPollType['type']): this;
|
|
836
|
+
webApp(label: string, url: string): this;
|
|
837
|
+
requestUsers(label: string, params: KeyboardButtonRequestUsers): this;
|
|
838
|
+
requestChat(label: string, params: KeyboardButtonRequestChat): this;
|
|
839
|
+
button(button: KeyboardButton): this;
|
|
840
|
+
row(): this;
|
|
841
|
+
build(options?: ReplyKeyboardBuildOptions): ReplyKeyboardMarkup;
|
|
842
|
+
}
|
|
843
|
+
declare function removeKeyboard(selective?: boolean): ReplyKeyboardRemove;
|
|
844
|
+
declare function forceReply(options?: {
|
|
845
|
+
placeholder?: string;
|
|
846
|
+
selective?: boolean;
|
|
847
|
+
}): ForceReply;
|
|
848
|
+
|
|
849
|
+
export { type BuildShareLinkOptions, type BuildStartAppLinkOptions, type BuildStartLinkOptions, ColorScheme, SafeAreaInset as ContentSafeAreaInset, DownloadFileParams, EmojiStatusParams, HomeScreenStatus, InlineKeyboardBuilder, LocationData, type ParsedTelegramLink, PopupButton, PopupParams, type ReplyKeyboardBuildOptions, ReplyKeyboardBuilder, SafeAreaInset, ScanQrPopupParams, ShareToStoryParams as StoryShareParams, ShareToStoryWidgetLink as StoryWidgetLink, TELEGRAM_TEXT_LIMITS, type TelegramContextValue, TelegramFormattedText, TelegramProvider, type TelegramProviderOptions, ThemeParams as TgThemeParams, WebAppUser as TgUser, TgWebApp, WebAppChat as TgWebAppChat, WebAppInitDataUnsafe as WebAppInitData, addToHomeScreen, biometric, bootstrapTelegramWebApp, buildShareLink, buildStartAppLink, buildStartLink, checkHomeScreenStatus, close, cloudStorage, decodeStartParam, deviceStorage, dialog, disableClosingConfirmation, disableVerticalSwipes, downloadFile, enableClosingConfirmation, enableVerticalSwipes, encodeStartParam, escapeHTML, escapeHTMLAttribute, escapeMarkdownV2, escapeMarkdownV2Code, escapeMarkdownV2LinkUrl, expand, forceReply, fullscreen, getRawUserData, getTheme, getUserAvatarUrl, getUserDisplayName, getUserIdentifier, getUserInfoWithAvatar, getViewport, getWebApp, haptic, hideKeyboard, html, invokeCustomMethod, isInTelegram, isValidStartParam, isVersionAtLeast, location, md, openExternalLink, openInvoice, openTelegramLink, orientation, parseTelegramLink, readClipboard, ready, removeKeyboard, requestChat, requestContact, requestEmojiStatusAccess, requestWriteAccess, safeInvoke, scanQr, index as sdk, secureStorage, setBackgroundColor, setBottomBarColor, setEmojiStatus, setHeaderColor, shareMessage, shareToStory, switchInlineQuery, truncateText, useTelegram };
|