@tma.js/sdk 1.5.2 → 2.0.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.
- package/dist/dts/bridge/events/event-emitter/createMiniAppsEventEmitter.d.ts +15 -0
- package/dist/dts/bridge/events/event-emitter/singleton.d.ts +8 -0
- package/dist/dts/bridge/events/event-handlers/cleanupEventHandlers.d.ts +4 -0
- package/dist/dts/bridge/events/event-handlers/defineEventHandlers.d.ts +6 -0
- package/dist/dts/bridge/events/event-handlers/emitMiniAppsEvent.d.ts +9 -0
- package/dist/dts/bridge/events/{off.d.ts → listening/off.d.ts} +3 -2
- package/dist/dts/bridge/events/listening/on.d.ts +12 -0
- package/dist/dts/bridge/events/listening/subscribe.d.ts +9 -0
- package/dist/dts/bridge/events/listening/unsubscribe.d.ts +7 -0
- package/dist/dts/bridge/events/types.d.ts +294 -2
- package/dist/dts/bridge/methods/createPostEvent.d.ts +7 -4
- package/dist/dts/bridge/methods/postEvent.d.ts +24 -15
- package/dist/dts/bridge/methods/{custom-methods.d.ts → types/custom-methods.d.ts} +2 -1
- package/dist/dts/bridge/methods/types/index.d.ts +4 -0
- package/dist/dts/bridge/methods/{methods.d.ts → types/methods.d.ts} +70 -17
- package/dist/dts/{globals.d.ts → bridge/target-origin.d.ts} +0 -9
- package/dist/dts/bridge/{invokeCustomMethod.d.ts → utils/invokeCustomMethod.d.ts} +7 -2
- package/dist/dts/bridge/utils/request.d.ts +35 -0
- package/dist/dts/classes/State/State.d.ts +46 -0
- package/dist/dts/classes/State/types.d.ts +29 -0
- package/dist/dts/classes/WithStateUtils.d.ts +18 -0
- package/dist/dts/classes/WithSupports.d.ts +19 -0
- package/dist/dts/classes/WithSupportsAndStateUtils.d.ts +24 -0
- package/dist/dts/classes/WithSupportsAndTrackableState.d.ts +16 -0
- package/dist/dts/classes/WithTrackableState.d.ts +16 -0
- package/dist/dts/classnames/mergeClassNames.d.ts +2 -1
- package/dist/dts/colors/isRGB.d.ts +2 -1
- package/dist/dts/colors/isRGBShort.d.ts +2 -1
- package/dist/dts/colors/toRGB.d.ts +2 -1
- package/dist/dts/components/BackButton/BackButton.d.ts +41 -0
- package/dist/dts/components/BackButton/initBackButton.d.ts +7 -0
- package/dist/dts/components/BackButton/types.d.ts +25 -0
- package/dist/dts/components/BiometryManager/BiometryManager.d.ts +61 -0
- package/dist/dts/components/BiometryManager/formatEvent.d.ts +34 -0
- package/dist/dts/components/BiometryManager/initBiometryManager.d.ts +7 -0
- package/dist/dts/components/BiometryManager/requestBiometryInfo.d.ts +8 -0
- package/dist/dts/components/BiometryManager/types.d.ts +40 -0
- package/dist/dts/components/ClosingBehavior/ClosingBehavior.d.ts +26 -0
- package/dist/dts/components/ClosingBehavior/initClosingBehavior.d.ts +7 -0
- package/dist/dts/components/{closing-behavior → ClosingBehavior}/types.d.ts +14 -1
- package/dist/dts/components/{cloud-storage → CloudStorage}/CloudStorage.d.ts +11 -11
- package/dist/dts/components/CloudStorage/initCloudStorage.d.ts +7 -0
- package/dist/dts/components/{haptic-feedback → HapticFeedback}/HapticFeedback.d.ts +9 -13
- package/dist/dts/components/HapticFeedback/initHapticFeedback.d.ts +7 -0
- package/dist/dts/components/{init-data → InitData}/InitData.d.ts +4 -2
- package/dist/dts/components/InitData/initInitData.d.ts +7 -0
- package/dist/dts/components/{init-data → InitData}/parseInitData.d.ts +2 -1
- package/dist/dts/components/InitData/parsers/chat.d.ts +3 -0
- package/dist/dts/components/InitData/parsers/initData.d.ts +7 -0
- package/dist/dts/components/InitData/parsers/user.d.ts +3 -0
- package/dist/dts/components/{init-data → InitData}/types.d.ts +2 -3
- package/dist/dts/components/Invoice/Invoice.d.ts +31 -0
- package/dist/dts/components/Invoice/initInvoice.d.ts +7 -0
- package/dist/dts/components/{invoice → Invoice}/types.d.ts +14 -1
- package/dist/dts/components/MainButton/MainButton.d.ts +106 -0
- package/dist/dts/components/MainButton/initMainButton.d.ts +7 -0
- package/dist/dts/components/MainButton/types.d.ts +40 -0
- package/dist/dts/components/{mini-app → MiniApp}/MiniApp.d.ts +29 -43
- package/dist/dts/components/MiniApp/initMiniApp.d.ts +7 -0
- package/dist/dts/components/MiniApp/parsing/contact.d.ts +7 -0
- package/dist/dts/components/MiniApp/types.d.ts +53 -0
- package/dist/dts/components/Popup/Popup.d.ts +30 -0
- package/dist/dts/components/Popup/initPopup.d.ts +7 -0
- package/dist/dts/components/{popup → Popup}/preparePopupParams.d.ts +3 -2
- package/dist/dts/components/{popup → Popup}/types.d.ts +2 -1
- package/dist/dts/components/QRScanner/QRScanner.d.ts +28 -0
- package/dist/dts/components/QRScanner/initQRScanner.d.ts +7 -0
- package/dist/dts/components/{qr-scanner → QRScanner}/types.d.ts +14 -1
- package/dist/dts/components/SettingsButton/SettingsButton.d.ts +37 -0
- package/dist/dts/components/SettingsButton/initSettingsButton.d.ts +7 -0
- package/dist/dts/components/{settings-button → SettingsButton}/types.d.ts +18 -3
- package/dist/dts/components/ThemeParams/ThemeParams.d.ts +53 -0
- package/dist/dts/components/ThemeParams/initThemeParams.d.ts +7 -0
- package/dist/dts/components/ThemeParams/keys.d.ts +11 -0
- package/dist/dts/components/{theme-params → ThemeParams/parsing}/parseThemeParams.d.ts +2 -1
- package/dist/dts/components/{theme-params → ThemeParams/parsing}/serializeThemeParams.d.ts +2 -1
- package/dist/dts/components/ThemeParams/parsing/themeParams.d.ts +4 -0
- package/dist/dts/components/ThemeParams/requestThemeParams.d.ts +8 -0
- package/dist/dts/components/ThemeParams/types.d.ts +29 -0
- package/dist/dts/components/{utils → Utils}/Utils.d.ts +10 -12
- package/dist/dts/components/Utils/initUtils.d.ts +7 -0
- package/dist/dts/components/Viewport/Viewport.d.ts +77 -0
- package/dist/dts/components/Viewport/initViewport.d.ts +8 -0
- package/dist/dts/components/Viewport/initViewportFromRequest.d.ts +10 -0
- package/dist/dts/components/{viewport → Viewport}/requestViewport.d.ts +3 -2
- package/dist/dts/components/Viewport/types.d.ts +35 -0
- package/dist/dts/css-vars/bindMiniAppCSSVars.d.ts +29 -0
- package/dist/dts/css-vars/bindThemeParamsCSSVars.d.ts +29 -0
- package/dist/dts/css-vars/bindViewportCSSVars.d.ts +32 -0
- package/dist/dts/{css → css-vars}/setCSSVar.d.ts +1 -1
- package/dist/dts/debug/debug.d.ts +14 -0
- package/dist/dts/{bridge/env → env}/hasExternalNotify.d.ts +5 -7
- package/dist/dts/{bridge/env → env}/hasWebviewProxy.d.ts +5 -7
- package/dist/dts/env/initWeb.d.ts +11 -0
- package/dist/dts/env/isSSR.d.ts +4 -0
- package/dist/dts/{misc → env}/isTMA.d.ts +1 -1
- package/dist/dts/errors/SDKError.d.ts +9 -0
- package/dist/dts/errors/createError.d.ts +10 -0
- package/dist/dts/errors/errors.d.ts +53 -0
- package/dist/dts/errors/isSDKError.d.ts +7 -0
- package/dist/dts/errors/isSDKErrorOfType.d.ts +8 -0
- package/dist/dts/{event-emitter → events/event-emitter}/EventEmitter.d.ts +20 -30
- package/dist/dts/{event-emitter → events/event-emitter}/types.d.ts +10 -9
- package/dist/dts/events/onWindow.d.ts +10 -0
- package/dist/dts/events/types.d.ts +6 -0
- package/dist/dts/index.d.ts +113 -92
- package/dist/dts/index.low-level.d.ts +41 -0
- package/dist/dts/launch-params/parseLaunchParams.d.ts +2 -1
- package/dist/dts/launch-params/retrieveFromLocation.d.ts +2 -1
- package/dist/dts/launch-params/retrieveFromPerformance.d.ts +3 -3
- package/dist/dts/launch-params/{storage.d.ts → retrieveFromStorage.d.ts} +2 -6
- package/dist/dts/launch-params/retrieveFromUrl.d.ts +2 -1
- package/dist/dts/launch-params/retrieveLaunchParams.d.ts +2 -1
- package/dist/dts/launch-params/saveToStorage.d.ts +7 -0
- package/dist/dts/launch-params/serializeLaunchParams.d.ts +2 -1
- package/dist/dts/launch-params/types.d.ts +12 -13
- package/dist/dts/logger/Logger.d.ts +9 -18
- package/dist/dts/misc/createComponentInitFn/createComponentInitFn.d.ts +15 -0
- package/dist/dts/misc/createComponentInitFn/types.d.ts +47 -0
- package/dist/dts/misc/createSingleton.d.ts +15 -0
- package/dist/dts/misc/objectFromKeys.d.ts +6 -0
- package/dist/dts/navigation/BasicNavigator/BasicNavigator.d.ts +118 -0
- package/dist/dts/navigation/BasicNavigator/prepareItem.d.ts +8 -0
- package/dist/dts/navigation/BasicNavigator/types.d.ts +37 -0
- package/dist/dts/navigation/BrowserNavigator/BrowserNavigator.d.ts +198 -0
- package/dist/dts/navigation/BrowserNavigator/basicItemToBrowser.d.ts +7 -0
- package/dist/dts/navigation/BrowserNavigator/createBrowserNavigatorFromLocation.d.ts +4 -0
- package/dist/dts/navigation/BrowserNavigator/prepareItem.d.ts +25 -0
- package/dist/dts/navigation/BrowserNavigator/types.d.ts +63 -0
- package/dist/dts/navigation/createSafeURL.d.ts +7 -0
- package/dist/dts/navigation/getHash.d.ts +2 -1
- package/dist/dts/navigation/getPathname.d.ts +7 -0
- package/dist/dts/navigation/initNavigator.d.ts +9 -0
- package/dist/dts/navigation/urlToPath.d.ts +7 -0
- package/dist/dts/parsing/ArrayParser/ArrayParser.d.ts +17 -0
- package/dist/dts/parsing/ArrayParser/types.d.ts +12 -0
- package/dist/dts/parsing/ValueParser/ValueParser.d.ts +17 -0
- package/dist/dts/parsing/{ValueParser.d.ts → ValueParser/types.d.ts} +6 -14
- package/dist/dts/parsing/createTypeError.d.ts +6 -0
- package/dist/dts/parsing/createValueParserGenerator.d.ts +3 -2
- package/dist/dts/parsing/parseBySchema.d.ts +2 -1
- package/dist/dts/parsing/parsers/array.d.ts +3 -2
- package/dist/dts/parsing/parsers/boolean.d.ts +2 -1
- package/dist/dts/parsing/parsers/date.d.ts +2 -1
- package/dist/dts/parsing/parsers/json.d.ts +3 -2
- package/dist/dts/parsing/parsers/number.d.ts +2 -1
- package/dist/dts/parsing/parsers/rgb.d.ts +3 -2
- package/dist/dts/parsing/parsers/searchParams.d.ts +3 -2
- package/dist/dts/parsing/parsers/string.d.ts +2 -1
- package/dist/dts/{init/creators → request-id}/createRequestIdGenerator.d.ts +3 -2
- package/dist/dts/{types/request-id.d.ts → request-id/types.d.ts} +1 -1
- package/dist/dts/storage/storage.d.ts +42 -0
- package/dist/dts/supports/createSupportsFn.d.ts +12 -0
- package/dist/dts/supports/{createSupportsParamFunc.d.ts → createSupportsParamFn.d.ts} +5 -4
- package/dist/dts/supports/supports.d.ts +3 -2
- package/dist/dts/supports/types.d.ts +1 -1
- package/dist/dts/timeout/createTimeoutError.d.ts +7 -0
- package/dist/dts/timeout/sleep.d.ts +1 -1
- package/dist/dts/timeout/withTimeout.d.ts +1 -2
- package/dist/dts/types/index.d.ts +6 -0
- package/dist/dts/types/methods.d.ts +2 -1
- package/dist/dts/types/misc.d.ts +12 -0
- package/dist/dts/types/utils.d.ts +16 -0
- package/dist/dts/version/compareVersions.d.ts +2 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -0
- package/dist/index.iife.js +2 -1
- package/dist/index.iife.js.map +1 -0
- package/dist/index.js +2998 -0
- package/dist/index.js.map +1 -0
- package/dist/index.low-level.iife.js +2 -0
- package/dist/index.low-level.iife.js.map +1 -0
- package/package.json +7 -9
- package/dist/dts/bridge/errors/MethodUnsupportedError.d.ts +0 -8
- package/dist/dts/bridge/errors/ParameterUnsupportedError.d.ts +0 -8
- package/dist/dts/bridge/events/createEmitter.d.ts +0 -6
- package/dist/dts/bridge/events/events.d.ts +0 -140
- package/dist/dts/bridge/events/on.d.ts +0 -9
- package/dist/dts/bridge/events/onTelegramEvent.d.ts +0 -7
- package/dist/dts/bridge/events/once.d.ts +0 -8
- package/dist/dts/bridge/events/parsers/clipboardTextReceived.d.ts +0 -13
- package/dist/dts/bridge/events/parsers/customMethodInvoked.d.ts +0 -16
- package/dist/dts/bridge/events/parsers/invoiceClosed.d.ts +0 -12
- package/dist/dts/bridge/events/parsers/phoneRequested.d.ts +0 -8
- package/dist/dts/bridge/events/parsers/popupClosed.d.ts +0 -8
- package/dist/dts/bridge/events/parsers/qrTextReceived.d.ts +0 -7
- package/dist/dts/bridge/events/parsers/theme-changed.d.ts +0 -42
- package/dist/dts/bridge/events/parsers/viewportChanged.d.ts +0 -19
- package/dist/dts/bridge/events/parsers/writeAccessRequested.d.ts +0 -8
- package/dist/dts/bridge/events/singletonEmitter.d.ts +0 -6
- package/dist/dts/bridge/events/subscribe.d.ts +0 -8
- package/dist/dts/bridge/events/unsubscribe.d.ts +0 -6
- package/dist/dts/bridge/request.d.ts +0 -54
- package/dist/dts/components/back-button/BackButton.d.ts +0 -47
- package/dist/dts/components/back-button/types.d.ts +0 -10
- package/dist/dts/components/closing-behavior/ClosingBehavior.d.ts +0 -39
- package/dist/dts/components/init-data/chatParser.d.ts +0 -6
- package/dist/dts/components/init-data/initDataParser.d.ts +0 -6
- package/dist/dts/components/init-data/userParser.d.ts +0 -6
- package/dist/dts/components/invoice/Invoice.d.ts +0 -47
- package/dist/dts/components/main-button/MainButton.d.ts +0 -104
- package/dist/dts/components/main-button/types.d.ts +0 -20
- package/dist/dts/components/mini-app/contactParser.d.ts +0 -2
- package/dist/dts/components/mini-app/types.d.ts +0 -32
- package/dist/dts/components/popup/Popup.d.ts +0 -48
- package/dist/dts/components/qr-scanner/QRScanner.d.ts +0 -44
- package/dist/dts/components/settings-button/SettingsButton.d.ts +0 -42
- package/dist/dts/components/theme-params/ThemeParams.d.ts +0 -66
- package/dist/dts/components/theme-params/keys.d.ts +0 -11
- package/dist/dts/components/theme-params/requestThemeParams.d.ts +0 -7
- package/dist/dts/components/theme-params/themeParamsParser.d.ts +0 -3
- package/dist/dts/components/theme-params/types.d.ts +0 -14
- package/dist/dts/components/viewport/Viewport.d.ts +0 -90
- package/dist/dts/components/viewport/isStableViewportPlatform.d.ts +0 -7
- package/dist/dts/components/viewport/types.d.ts +0 -18
- package/dist/dts/components/viewport/utils.d.ts +0 -5
- package/dist/dts/css/bindMiniAppCSSVars.d.ts +0 -16
- package/dist/dts/css/bindThemeCSSVars.d.ts +0 -12
- package/dist/dts/css/bindViewportCSSVars.d.ts +0 -20
- package/dist/dts/init/catchCustomStyles.d.ts +0 -4
- package/dist/dts/init/creators/createBackButton.d.ts +0 -10
- package/dist/dts/init/creators/createClosingBehavior.d.ts +0 -9
- package/dist/dts/init/creators/createMainButton.d.ts +0 -12
- package/dist/dts/init/creators/createMiniApp.d.ts +0 -16
- package/dist/dts/init/creators/createSettingsButton.d.ts +0 -10
- package/dist/dts/init/creators/createThemeParams.d.ts +0 -7
- package/dist/dts/init/creators/createViewport.d.ts +0 -11
- package/dist/dts/init/css/processCSSVarsOption.d.ts +0 -12
- package/dist/dts/init/init.d.ts +0 -9
- package/dist/dts/init/types.d.ts +0 -85
- package/dist/dts/launch-params/launchParamsParser.d.ts +0 -6
- package/dist/dts/launch-params/retrieveLaunchData.d.ts +0 -7
- package/dist/dts/navigation/HashNavigator/HashNavigator.d.ts +0 -46
- package/dist/dts/navigation/HashNavigator/types.d.ts +0 -33
- package/dist/dts/navigation/Navigator/Navigator.d.ts +0 -104
- package/dist/dts/navigation/Navigator/types.d.ts +0 -44
- package/dist/dts/parsing/ArrayValueParser.d.ts +0 -18
- package/dist/dts/parsing/ParseError.d.ts +0 -22
- package/dist/dts/parsing/ParseSchemaFieldError.d.ts +0 -17
- package/dist/dts/parsing/unexpectedTypeError.d.ts +0 -4
- package/dist/dts/state/State.d.ts +0 -28
- package/dist/dts/state/types.d.ts +0 -27
- package/dist/dts/storage.d.ts +0 -50
- package/dist/dts/supports/createSupportsFunc.d.ts +0 -10
- package/dist/dts/timeout/TimeoutError.d.ts +0 -3
- package/dist/dts/timeout/isTimeoutError.d.ts +0 -6
- package/dist/index.mjs +0 -2813
- /package/dist/dts/bridge/methods/{haptic.d.ts → types/haptic.d.ts} +0 -0
- /package/dist/dts/bridge/methods/{popup.d.ts → types/popup.d.ts} +0 -0
- /package/dist/dts/bridge/{captureSameReq.d.ts → utils/captureSameReq.d.ts} +0 -0
- /package/dist/dts/{misc → env}/isIframe.d.ts +0 -0
- /package/dist/dts/navigation/{HashNavigator/drop.d.ts → drop.d.ts} +0 -0
- /package/dist/dts/{misc → navigation}/getFirstNavigationEntry.d.ts +0 -0
- /package/dist/dts/navigation/{HashNavigator/go.d.ts → go.d.ts} +0 -0
- /package/dist/dts/{misc → navigation}/isPageReload.d.ts +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MiniAppsEventEmitter } from '../types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates new event emitter, which handles events from the Telegram application.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createMiniAppsEventEmitter(): [
|
|
7
|
+
/**
|
|
8
|
+
* Created event emitter.
|
|
9
|
+
*/
|
|
10
|
+
emitter: MiniAppsEventEmitter,
|
|
11
|
+
/**
|
|
12
|
+
* Function to dispose created emitter.
|
|
13
|
+
*/
|
|
14
|
+
dispose: () => void
|
|
15
|
+
];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MiniAppsEventEmitter } from '../types.js';
|
|
2
|
+
|
|
3
|
+
declare const resetMiniAppsEventEmitter: () => void;
|
|
4
|
+
/**
|
|
5
|
+
* Returns Mini Apps event emitter singleton.
|
|
6
|
+
*/
|
|
7
|
+
export declare function miniAppsEventEmitter(): MiniAppsEventEmitter;
|
|
8
|
+
export { resetMiniAppsEventEmitter };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines special handlers by known paths, which are recognized by
|
|
3
|
+
* Telegram as ports to receive events. This function also sets special
|
|
4
|
+
* function in global window object to prevent duplicate declaration.
|
|
5
|
+
*/
|
|
6
|
+
export declare function defineEventHandlers(): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Emits event sent from Telegram native application like it was sent in
|
|
3
|
+
* default web environment between 2 iframes. It dispatches new MessageEvent
|
|
4
|
+
* and expects it to be handled via `window.addEventListener('message', ...)`
|
|
5
|
+
* as developer would do it to handle messages sent from the parent iframe.
|
|
6
|
+
* @param eventType - event name.
|
|
7
|
+
* @param eventData - event payload.
|
|
8
|
+
*/
|
|
9
|
+
export declare function emitMiniAppsEvent(eventType: string, eventData: unknown): void;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { MiniAppsEventListener, MiniAppsEventName } from '../types.js';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* Removes listener from specified event.
|
|
4
5
|
* @param event - event to listen.
|
|
5
|
-
* @param listener - event listener.
|
|
6
|
+
* @param listener - event listener to remove.
|
|
6
7
|
*/
|
|
7
8
|
export declare function off<E extends MiniAppsEventName>(event: E, listener: MiniAppsEventListener<E>): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RemoveEventListenerFn } from '../../../events/types.js';
|
|
2
|
+
import { MiniAppsEventListener, MiniAppsEventName } from '../types.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Adds new listener to the specified event. Returns handler
|
|
6
|
+
* which allows to stop listening to event.
|
|
7
|
+
* @param event - event name.
|
|
8
|
+
* @param listener - event listener.
|
|
9
|
+
* @param once - should listener be called only once.
|
|
10
|
+
* @returns Function to remove bound event listener.
|
|
11
|
+
*/
|
|
12
|
+
export declare function on<E extends MiniAppsEventName>(event: E, listener: MiniAppsEventListener<E>, once?: boolean): RemoveEventListenerFn;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RemoveEventListenerFn } from '../../../events/types.js';
|
|
2
|
+
import { MiniAppsSubscribeListener } from '../types.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Subscribes to all events sent from the native Telegram application.
|
|
6
|
+
* @param listener - event listener to bind.
|
|
7
|
+
* @returns Function to remove bound event listener.
|
|
8
|
+
*/
|
|
9
|
+
export declare function subscribe(listener: MiniAppsSubscribeListener): RemoveEventListenerFn;
|
|
@@ -1,4 +1,296 @@
|
|
|
1
|
+
import { RGB } from '../../colors/types.js';
|
|
2
|
+
import { EventEmitter } from '../../events/event-emitter/EventEmitter.js';
|
|
3
|
+
import { EventListener, SubscribeListener } from '../../events/event-emitter/types.js';
|
|
4
|
+
import { RequestId } from '../../request-id/types.js';
|
|
5
|
+
|
|
6
|
+
export type InvoiceStatus = 'paid' | 'failed' | 'pending' | 'cancelled' | string;
|
|
7
|
+
export type PhoneRequestedStatus = 'sent' | 'cancelled' | string;
|
|
8
|
+
export type WriteAccessRequestedStatus = 'allowed' | string;
|
|
9
|
+
export type BiometryType = 'finger' | 'face' | string;
|
|
10
|
+
export type BiometryTokenUpdateStatus = 'updated' | 'removed' | string;
|
|
11
|
+
export type BiometryAuthRequestStatus = 'failed' | 'authorized' | string;
|
|
1
12
|
/**
|
|
2
|
-
*
|
|
13
|
+
* Map where key is known event name, and value is its listener.
|
|
14
|
+
* @see https://docs.telegram-mini-apps.com/platform/events
|
|
3
15
|
*/
|
|
4
|
-
export
|
|
16
|
+
export interface MiniAppsEvents {
|
|
17
|
+
/**
|
|
18
|
+
* User clicked the BackButton.
|
|
19
|
+
* @since v6.1
|
|
20
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#back-button-pressed
|
|
21
|
+
*/
|
|
22
|
+
back_button_pressed: never;
|
|
23
|
+
/**
|
|
24
|
+
* Biometry authentication request completed.
|
|
25
|
+
* @since 7.2
|
|
26
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#biometry-auth-requested
|
|
27
|
+
*/
|
|
28
|
+
biometry_auth_requested: {
|
|
29
|
+
/**
|
|
30
|
+
* Authentication status.
|
|
31
|
+
*/
|
|
32
|
+
status: BiometryAuthRequestStatus;
|
|
33
|
+
/**
|
|
34
|
+
* Token from the local secure storage saved previously.
|
|
35
|
+
*/
|
|
36
|
+
token?: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Biometry settings were received.
|
|
40
|
+
* @since 7.2
|
|
41
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#biometry-info-received
|
|
42
|
+
*/
|
|
43
|
+
biometry_info_received: {
|
|
44
|
+
/**
|
|
45
|
+
* Shows whether biometry is available.
|
|
46
|
+
*/
|
|
47
|
+
available: false;
|
|
48
|
+
} | {
|
|
49
|
+
/**
|
|
50
|
+
* Shows whether biometry is available.
|
|
51
|
+
*/
|
|
52
|
+
available: true;
|
|
53
|
+
/**
|
|
54
|
+
* Shows whether permission to use biometrics has been requested.
|
|
55
|
+
*/
|
|
56
|
+
access_requested: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Shows whether permission to use biometrics has been granted.
|
|
59
|
+
*/
|
|
60
|
+
access_granted: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* A unique device identifier that can be used to match the token to the device.
|
|
63
|
+
*/
|
|
64
|
+
device_id: string;
|
|
65
|
+
/**
|
|
66
|
+
* Show whether local storage contains previously saved token.
|
|
67
|
+
*/
|
|
68
|
+
token_saved: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* The type of biometrics currently available on the device.
|
|
71
|
+
*/
|
|
72
|
+
type: BiometryType;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Biometry token was updated.
|
|
76
|
+
* @since 7.2
|
|
77
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#biometry-token-updated
|
|
78
|
+
*/
|
|
79
|
+
biometry_token_updated: {
|
|
80
|
+
/**
|
|
81
|
+
* Update status.
|
|
82
|
+
*/
|
|
83
|
+
status: BiometryTokenUpdateStatus;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Telegram application attempted to extract text from clipboard.
|
|
87
|
+
* @since v6.4
|
|
88
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#clipboard-text-received
|
|
89
|
+
*/
|
|
90
|
+
clipboard_text_received: {
|
|
91
|
+
/**
|
|
92
|
+
* Passed during the `web_app_read_text_from_clipboard` method invocation `req_id` value.
|
|
93
|
+
*/
|
|
94
|
+
req_id: RequestId;
|
|
95
|
+
/**
|
|
96
|
+
* Data extracted from the clipboard. The returned value will have the type `string` only in
|
|
97
|
+
* the case, application has access to the clipboard.
|
|
98
|
+
*/
|
|
99
|
+
data?: string | null;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Custom method invocation completed.
|
|
103
|
+
* @since v6.9
|
|
104
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#custom-method-invoked
|
|
105
|
+
*/
|
|
106
|
+
custom_method_invoked: {
|
|
107
|
+
/**
|
|
108
|
+
* Unique identifier of this invocation.
|
|
109
|
+
*/
|
|
110
|
+
req_id: RequestId;
|
|
111
|
+
/**
|
|
112
|
+
* Method invocation successful result.
|
|
113
|
+
*/
|
|
114
|
+
result?: unknown;
|
|
115
|
+
/**
|
|
116
|
+
* Method invocation error code.
|
|
117
|
+
*/
|
|
118
|
+
error?: string;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* An invoice was closed.
|
|
122
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#invoice-closed
|
|
123
|
+
*/
|
|
124
|
+
invoice_closed: {
|
|
125
|
+
/**
|
|
126
|
+
* Passed during the `web_app_open_invoice` method invocation `slug` value.
|
|
127
|
+
*/
|
|
128
|
+
slug: string;
|
|
129
|
+
/**
|
|
130
|
+
* Invoice status.
|
|
131
|
+
*/
|
|
132
|
+
status: InvoiceStatus;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* User clicked the Main Button.
|
|
136
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#main-button-pressed
|
|
137
|
+
*/
|
|
138
|
+
main_button_pressed: never;
|
|
139
|
+
/**
|
|
140
|
+
* Application received phone access request status.
|
|
141
|
+
* @since v6.9
|
|
142
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#phone-requested
|
|
143
|
+
*/
|
|
144
|
+
phone_requested: {
|
|
145
|
+
/**
|
|
146
|
+
* Request status.
|
|
147
|
+
*/
|
|
148
|
+
status: PhoneRequestedStatus;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Popup was closed.
|
|
152
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#popup-closed
|
|
153
|
+
*/
|
|
154
|
+
popup_closed: {
|
|
155
|
+
/**
|
|
156
|
+
* Identifier of the clicked button. In case, the popup was closed without clicking any button,
|
|
157
|
+
* this property will be omitted.
|
|
158
|
+
*/
|
|
159
|
+
button_id?: string;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* The QR scanner scanned some QR and extracted its content.
|
|
163
|
+
* @param payload - event payload.
|
|
164
|
+
* @since v6.4
|
|
165
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#qr-text-received
|
|
166
|
+
*/
|
|
167
|
+
qr_text_received: {
|
|
168
|
+
/**
|
|
169
|
+
* Data extracted from the QR.
|
|
170
|
+
*/
|
|
171
|
+
data?: string;
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* Parent iframe requested current iframe reload.
|
|
175
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#reload-iframe
|
|
176
|
+
*/
|
|
177
|
+
reload_iframe: never;
|
|
178
|
+
/**
|
|
179
|
+
* QR scanner was closed.
|
|
180
|
+
* @since v6.4
|
|
181
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#scan-qr-popup-closed
|
|
182
|
+
*/
|
|
183
|
+
scan_qr_popup_closed: never;
|
|
184
|
+
/**
|
|
185
|
+
* The event which is usually sent by the Telegram web application. Its payload represents
|
|
186
|
+
* `<style/>` tag html content, a developer could use. The stylesheet described in the payload
|
|
187
|
+
* will help the developer to stylize the app scrollbar (but he is still able to do it himself).
|
|
188
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#set-custom-style
|
|
189
|
+
*/
|
|
190
|
+
set_custom_style: string;
|
|
191
|
+
/**
|
|
192
|
+
* Occurs when the Settings Button was pressed.
|
|
193
|
+
* @since v6.1
|
|
194
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#settings-button-pressed
|
|
195
|
+
*/
|
|
196
|
+
settings_button_pressed: never;
|
|
197
|
+
/**
|
|
198
|
+
* Occurs whenever theme settings are changed in the user's Telegram app
|
|
199
|
+
* (including switching to night mode).
|
|
200
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#theme-changed
|
|
201
|
+
*/
|
|
202
|
+
theme_changed: {
|
|
203
|
+
/**
|
|
204
|
+
* Map where the key is a theme stylesheet key and value is the corresponding color in
|
|
205
|
+
* `#RRGGBB` format.
|
|
206
|
+
*/
|
|
207
|
+
theme_params: {
|
|
208
|
+
/**
|
|
209
|
+
* @since v6.10
|
|
210
|
+
*/
|
|
211
|
+
accent_text_color?: RGB;
|
|
212
|
+
bg_color?: RGB;
|
|
213
|
+
button_color?: RGB;
|
|
214
|
+
button_text_color?: RGB;
|
|
215
|
+
/**
|
|
216
|
+
* @since v6.10
|
|
217
|
+
*/
|
|
218
|
+
destructive_text_color?: RGB;
|
|
219
|
+
/**
|
|
220
|
+
* @since v6.10
|
|
221
|
+
*/
|
|
222
|
+
header_bg_color?: RGB;
|
|
223
|
+
hint_color?: RGB;
|
|
224
|
+
link_color?: RGB;
|
|
225
|
+
secondary_bg_color?: RGB;
|
|
226
|
+
/**
|
|
227
|
+
* @since v6.10
|
|
228
|
+
*/
|
|
229
|
+
section_bg_color?: RGB;
|
|
230
|
+
/**
|
|
231
|
+
* @since v6.10
|
|
232
|
+
*/
|
|
233
|
+
section_header_text_color?: RGB;
|
|
234
|
+
/**
|
|
235
|
+
* @since v6.10
|
|
236
|
+
*/
|
|
237
|
+
subtitle_text_color?: RGB;
|
|
238
|
+
text_color?: RGB;
|
|
239
|
+
[key: string]: RGB | undefined;
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Occurs whenever the viewport has been changed. For example, when the user started
|
|
244
|
+
* dragging the application or called the expansion method.
|
|
245
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#viewport-changed
|
|
246
|
+
*/
|
|
247
|
+
viewport_changed: {
|
|
248
|
+
/**
|
|
249
|
+
* The viewport height.
|
|
250
|
+
*/
|
|
251
|
+
height: number;
|
|
252
|
+
/**
|
|
253
|
+
* The viewport width.
|
|
254
|
+
*/
|
|
255
|
+
width: number;
|
|
256
|
+
/**
|
|
257
|
+
* Is the viewport currently expanded.
|
|
258
|
+
*/
|
|
259
|
+
is_expanded: boolean;
|
|
260
|
+
/**
|
|
261
|
+
* Is the viewport current state stable and not going to change in the next moment.
|
|
262
|
+
*/
|
|
263
|
+
is_state_stable: boolean;
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* Application received write access request status.
|
|
267
|
+
* @since v6.9
|
|
268
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#write-access-requested
|
|
269
|
+
*/
|
|
270
|
+
write_access_requested: {
|
|
271
|
+
/**
|
|
272
|
+
* Request status.
|
|
273
|
+
*/
|
|
274
|
+
status: WriteAccessRequestedStatus;
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Mini Apps event name.
|
|
279
|
+
*/
|
|
280
|
+
export type MiniAppsEventName = keyof MiniAppsEvents;
|
|
281
|
+
/**
|
|
282
|
+
* Payload of the specified Mini Apps event.
|
|
283
|
+
*/
|
|
284
|
+
export type MiniAppsEventPayload<E extends MiniAppsEventName> = MiniAppsEvents[E];
|
|
285
|
+
/**
|
|
286
|
+
* Returns event listener for the specified Mini Apps event.
|
|
287
|
+
*/
|
|
288
|
+
export type MiniAppsEventListener<E extends MiniAppsEventName> = EventListener<MiniAppsEvents[E]>;
|
|
289
|
+
/**
|
|
290
|
+
* Mini Apps event listener used in `subscribe` and `unsubscribe` functions.
|
|
291
|
+
*/
|
|
292
|
+
export type MiniAppsSubscribeListener = SubscribeListener<MiniAppsEvents>;
|
|
293
|
+
/**
|
|
294
|
+
* Mini Apps event emitter.
|
|
295
|
+
*/
|
|
296
|
+
export type MiniAppsEventEmitter = EventEmitter<MiniAppsEvents>;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Version } from '../../version/types.js';
|
|
2
|
+
import { PostEvent } from './postEvent.js';
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* Creates function which checks if specified method and parameters are supported. In case,
|
|
5
6
|
* method or parameters are unsupported, an error will be thrown.
|
|
6
7
|
* @param version - Telegram Mini Apps version.
|
|
7
|
-
* @throws {
|
|
8
|
-
* @throws {
|
|
8
|
+
* @throws {SDKError} ERR_METHOD_UNSUPPORTED
|
|
9
|
+
* @throws {SDKError} ERR_METHOD_PARAMETER_UNSUPPORTED
|
|
10
|
+
* @see ERR_METHOD_UNSUPPORTED
|
|
11
|
+
* @see ERR_METHOD_PARAMETER_UNSUPPORTED
|
|
9
12
|
*/
|
|
10
13
|
export declare function createPostEvent(version: Version): PostEvent;
|
|
@@ -1,29 +1,38 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { MiniAppsMethodParams, MiniAppsMethodWithOptionalParams, MiniAppsMethodWithoutParams, MiniAppsMethodWithRequiredParams } from './types/methods.js';
|
|
2
|
+
|
|
2
3
|
interface PostEventOptions {
|
|
3
4
|
/**
|
|
4
|
-
* Origin used while posting message. This option is only used in case,
|
|
5
|
-
*
|
|
6
|
-
* be used for test purposes.
|
|
5
|
+
* Origin used while posting message. This option is only used in case, current environment
|
|
6
|
+
* is browser (Web version of Telegram) and could be used for test purposes.
|
|
7
7
|
* @default 'https://web.telegram.org'
|
|
8
8
|
*/
|
|
9
9
|
targetOrigin?: string;
|
|
10
10
|
}
|
|
11
11
|
export type PostEvent = typeof postEvent;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @param
|
|
16
|
-
* @param params - event parameters.
|
|
13
|
+
* Calls Mini Apps method with optional parameters.
|
|
14
|
+
* @param method - method name.
|
|
15
|
+
* @param params - method parameters.
|
|
17
16
|
* @param options - posting options.
|
|
18
|
-
* @throws {
|
|
17
|
+
* @throws {SDKError} ERR_UNKNOWN_ENV
|
|
18
|
+
* @see ERR_UNKNOWN_ENV
|
|
19
19
|
*/
|
|
20
|
-
export declare function postEvent<
|
|
20
|
+
export declare function postEvent<Method extends MiniAppsMethodWithOptionalParams>(method: Method, params?: MiniAppsMethodParams<Method>, options?: PostEventOptions): void;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @param eventType - event name.
|
|
22
|
+
* Calls Mini Apps method without parameters.
|
|
23
|
+
* @param method - method name.
|
|
25
24
|
* @param options - posting options.
|
|
26
|
-
* @throws {
|
|
25
|
+
* @throws {SDKError} ERR_UNKNOWN_ENV
|
|
26
|
+
* @see ERR_UNKNOWN_ENV
|
|
27
27
|
*/
|
|
28
|
-
export declare function postEvent(
|
|
28
|
+
export declare function postEvent(method: MiniAppsMethodWithoutParams, options?: PostEventOptions): void;
|
|
29
|
+
/**
|
|
30
|
+
* Calls Mini Apps method with parameters.
|
|
31
|
+
* @param method - method name.
|
|
32
|
+
* @param params - method parameters.
|
|
33
|
+
* @param options - posting options.
|
|
34
|
+
* @throws {SDKError} ERR_UNKNOWN_ENV
|
|
35
|
+
* @see ERR_UNKNOWN_ENV
|
|
36
|
+
*/
|
|
37
|
+
export declare function postEvent<Method extends MiniAppsMethodWithRequiredParams>(method: Method, params: MiniAppsMethodParams<Method>, options?: PostEventOptions): void;
|
|
29
38
|
export {};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import type { IsNever } from '../../types/utils.js';
|
|
1
|
+
import { RGB } from '../../../colors/types.js';
|
|
2
|
+
import { RequestId } from '../../../request-id/types.js';
|
|
3
|
+
import { If, IsNever, UnionKeys } from '../../../types/index.js';
|
|
4
|
+
import { AnyInvokeCustomMethodParams } from './custom-methods.js';
|
|
5
|
+
import { AnyHapticFeedbackParams } from './haptic.js';
|
|
6
|
+
import { PopupParams } from './popup.js';
|
|
7
|
+
|
|
9
8
|
/**
|
|
10
9
|
* Color key which could be used to update header color.
|
|
11
10
|
*/
|
|
@@ -39,6 +38,58 @@ export interface MiniAppsMethods {
|
|
|
39
38
|
* @see https://docs.telegram-mini-apps.com/platform/methods#iframe-will-reload
|
|
40
39
|
*/
|
|
41
40
|
iframe_will_reload: CreateParams;
|
|
41
|
+
/**
|
|
42
|
+
* Request current biometry settings.
|
|
43
|
+
* @since 7.2
|
|
44
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-biometry-get-info
|
|
45
|
+
*/
|
|
46
|
+
web_app_biometry_get_info: CreateParams;
|
|
47
|
+
/**
|
|
48
|
+
* Opens the biometric access settings for bots. Useful when you need to request biometrics
|
|
49
|
+
* access to users who haven't granted it yet.
|
|
50
|
+
*
|
|
51
|
+
* _Note that this method can be called only in response to user interaction with the Mini
|
|
52
|
+
* App interface (e.g. a click inside the Mini App or on the main button)_.
|
|
53
|
+
* @since 7.2
|
|
54
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-biometry-open-settings
|
|
55
|
+
*/
|
|
56
|
+
web_app_biometry_open_settings: CreateParams;
|
|
57
|
+
/**
|
|
58
|
+
* Requests access to use biometrics.
|
|
59
|
+
* @since 7.2
|
|
60
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-biometry-request-access
|
|
61
|
+
*/
|
|
62
|
+
web_app_biometry_request_access: CreateParams<{
|
|
63
|
+
/**
|
|
64
|
+
* Reason to request biometry access. Should be at least 1 symbol length, but not
|
|
65
|
+
* more than 128 symbols.
|
|
66
|
+
*/
|
|
67
|
+
reason?: string;
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* Authenticates the user using biometrics.
|
|
71
|
+
* @since 7.2
|
|
72
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-biometry-request-auth
|
|
73
|
+
*/
|
|
74
|
+
web_app_biometry_request_auth: CreateParams<{
|
|
75
|
+
/**
|
|
76
|
+
* Reason to request biometry data. Should be at least 1 symbol length, but not more than
|
|
77
|
+
* 128 symbols.
|
|
78
|
+
*/
|
|
79
|
+
reason?: string;
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* Updates the biometric token in secure storage on the device. To remove the token, pass
|
|
83
|
+
* an empty string.
|
|
84
|
+
* @since 7.2
|
|
85
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-biometry-update-token
|
|
86
|
+
*/
|
|
87
|
+
web_app_biometry_update_token: CreateParams<{
|
|
88
|
+
/**
|
|
89
|
+
* Token to store. Has max length of 1024 symbols.
|
|
90
|
+
*/
|
|
91
|
+
token: string;
|
|
92
|
+
}>;
|
|
42
93
|
/**
|
|
43
94
|
* Closes Mini App.
|
|
44
95
|
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-close
|
|
@@ -296,27 +347,29 @@ export interface MiniAppsMethods {
|
|
|
296
347
|
web_app_trigger_haptic_feedback: CreateParams<AnyHapticFeedbackParams>;
|
|
297
348
|
}
|
|
298
349
|
/**
|
|
299
|
-
*
|
|
350
|
+
* Mini Apps method name.
|
|
300
351
|
*/
|
|
301
352
|
export type MiniAppsMethodName = keyof MiniAppsMethods;
|
|
302
353
|
/**
|
|
303
|
-
*
|
|
354
|
+
* Parameters of the specified Mini Apps method.
|
|
304
355
|
*/
|
|
305
356
|
export type MiniAppsMethodParams<M extends MiniAppsMethodName> = MiniAppsMethods[M]['params'];
|
|
306
357
|
/**
|
|
307
|
-
*
|
|
358
|
+
* Methods with optional parameters.
|
|
308
359
|
*/
|
|
309
|
-
export type
|
|
360
|
+
export type MiniAppsMethodWithOptionalParams = {
|
|
361
|
+
[Method in MiniAppsMethodName]: undefined extends MiniAppsMethodParams<Method> ? Method : never;
|
|
362
|
+
}[MiniAppsMethodName];
|
|
310
363
|
/**
|
|
311
|
-
*
|
|
364
|
+
* Methods without parameters.
|
|
312
365
|
*/
|
|
313
|
-
export type
|
|
314
|
-
[Method in MiniAppsMethodName]: If<
|
|
366
|
+
export type MiniAppsMethodWithoutParams = {
|
|
367
|
+
[Method in MiniAppsMethodName]: If<IsNever<MiniAppsMethodParams<Method>>, Method, never>;
|
|
315
368
|
}[MiniAppsMethodName];
|
|
316
369
|
/**
|
|
317
|
-
*
|
|
370
|
+
* Methods with parameters.
|
|
318
371
|
*/
|
|
319
|
-
export type
|
|
372
|
+
export type MiniAppsMethodWithRequiredParams = Exclude<MiniAppsMethodName, MiniAppsMethodWithoutParams | MiniAppsMethodWithOptionalParams>;
|
|
320
373
|
/**
|
|
321
374
|
* Method names which have versioned params.
|
|
322
375
|
*/
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import { Logger } from './logger/Logger.js';
|
|
2
|
-
export declare const logger: Logger;
|
|
3
|
-
/**
|
|
4
|
-
* Sets new debug mode. Enabling debug mode leads to printing
|
|
5
|
-
* additional messages in console, related to the processes
|
|
6
|
-
* inside the package.
|
|
7
|
-
* @param value - should debug mode be enabled.
|
|
8
|
-
*/
|
|
9
|
-
export declare function setDebug(value: boolean): void;
|
|
10
1
|
/**
|
|
11
2
|
* Sets new global targetOrigin, used by `postEvent` method.
|
|
12
3
|
* Default value is "https://web.telegram.org". You don't need to
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { ExecuteWithOptions } from '../../types/index.js';
|
|
2
|
+
import { CustomMethodName, CustomMethodParams } from '../methods/types/custom-methods.js';
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* Invokes known custom method. Returns method execution result.
|
|
5
6
|
* @param method - method name.
|
|
6
7
|
* @param params - method parameters.
|
|
7
8
|
* @param requestId - request identifier.
|
|
8
9
|
* @param options - additional options.
|
|
10
|
+
* @throws {SDKError} ERR_INVOKE_CUSTOM_METHOD_RESPONSE
|
|
11
|
+
* @see ERR_INVOKE_CUSTOM_METHOD_RESPONSE
|
|
9
12
|
*/
|
|
10
13
|
export declare function invokeCustomMethod<M extends CustomMethodName>(method: M, params: CustomMethodParams<M>, requestId: string, options?: ExecuteWithOptions): Promise<unknown>;
|
|
11
14
|
/**
|
|
@@ -14,5 +17,7 @@ export declare function invokeCustomMethod<M extends CustomMethodName>(method: M
|
|
|
14
17
|
* @param params - method parameters.
|
|
15
18
|
* @param requestId - request identifier.
|
|
16
19
|
* @param options - additional options.
|
|
20
|
+
* @throws {SDKError} ERR_INVOKE_CUSTOM_METHOD_RESPONSE
|
|
21
|
+
* @see ERR_INVOKE_CUSTOM_METHOD_RESPONSE
|
|
17
22
|
*/
|
|
18
23
|
export declare function invokeCustomMethod(method: string, params: object, requestId: string, options?: ExecuteWithOptions): Promise<unknown>;
|