@tma.js/sdk 1.4.8 → 1.5.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/captureSameReq.d.ts +10 -0
- package/dist/dts/bridge/errors/MethodUnsupportedError.d.ts +2 -2
- package/dist/dts/bridge/errors/ParameterUnsupportedError.d.ts +2 -2
- package/dist/dts/bridge/events/events.d.ts +13 -3
- package/dist/dts/bridge/events/on.d.ts +2 -3
- package/dist/dts/bridge/events/once.d.ts +2 -3
- package/dist/dts/bridge/events/parsers/clipboardTextReceived.d.ts +2 -2
- package/dist/dts/bridge/events/parsers/customMethodInvoked.d.ts +2 -2
- package/dist/dts/bridge/events/parsers/invoiceClosed.d.ts +1 -1
- package/dist/dts/bridge/events/parsers/phoneRequested.d.ts +1 -1
- package/dist/dts/bridge/events/parsers/popupClosed.d.ts +1 -1
- package/dist/dts/bridge/events/parsers/qrTextReceived.d.ts +1 -1
- package/dist/dts/bridge/events/parsers/theme-changed.d.ts +2 -2
- package/dist/dts/bridge/events/parsers/viewportChanged.d.ts +1 -1
- package/dist/dts/bridge/events/parsers/writeAccessRequested.d.ts +1 -1
- package/dist/dts/bridge/events/singletonEmitter.d.ts +1 -1
- package/dist/dts/bridge/events/subscribe.d.ts +2 -3
- package/dist/dts/bridge/events/types.d.ts +4 -0
- package/dist/dts/bridge/invokeCustomMethod.d.ts +2 -2
- package/dist/dts/bridge/methods/createPostEvent.d.ts +1 -1
- package/dist/dts/bridge/methods/custom-methods.d.ts +1 -1
- package/dist/dts/bridge/methods/methods.d.ts +9 -8
- package/dist/dts/bridge/request.d.ts +38 -40
- package/dist/dts/classnames/mergeClassNames.d.ts +2 -18
- package/dist/dts/{back-button → components/back-button}/BackButton.d.ts +4 -4
- package/dist/dts/{back-button → components/back-button}/types.d.ts +2 -2
- package/dist/dts/{closing-behavior → components/closing-behavior}/ClosingBehavior.d.ts +6 -3
- package/dist/dts/{closing-behavior → components/closing-behavior}/types.d.ts +1 -1
- package/dist/dts/{cloud-storage → components/cloud-storage}/CloudStorage.d.ts +5 -4
- package/dist/dts/{haptic-feedback → components/haptic-feedback}/HapticFeedback.d.ts +4 -3
- package/dist/dts/components/init-data/chatParser.d.ts +6 -0
- package/dist/dts/components/init-data/initDataParser.d.ts +6 -0
- package/dist/dts/components/init-data/userParser.d.ts +6 -0
- package/dist/dts/{invoice → components/invoice}/Invoice.d.ts +9 -5
- package/dist/dts/{invoice → components/invoice}/types.d.ts +1 -1
- package/dist/dts/{main-button → components/main-button}/MainButton.d.ts +2 -2
- package/dist/dts/{main-button → components/main-button}/types.d.ts +3 -3
- package/dist/dts/{mini-app → components/mini-app}/MiniApp.d.ts +11 -6
- package/dist/dts/components/mini-app/contactParser.d.ts +2 -0
- package/dist/dts/{mini-app → components/mini-app}/types.d.ts +6 -5
- package/dist/dts/{popup → components/popup}/Popup.d.ts +8 -5
- package/dist/dts/{popup → components/popup}/preparePopupParams.d.ts +1 -1
- package/dist/dts/{popup → components/popup}/types.d.ts +1 -1
- package/dist/dts/{qr-scanner → components/qr-scanner}/QRScanner.d.ts +8 -5
- package/dist/dts/{qr-scanner → components/qr-scanner}/types.d.ts +1 -1
- package/dist/dts/{settings-button → components/settings-button}/SettingsButton.d.ts +4 -4
- package/dist/dts/{settings-button → components/settings-button}/types.d.ts +2 -2
- package/dist/dts/{theme-params → components/theme-params}/ThemeParams.d.ts +8 -4
- package/dist/dts/components/theme-params/requestThemeParams.d.ts +7 -0
- package/dist/dts/components/theme-params/themeParamsParser.d.ts +3 -0
- package/dist/dts/{theme-params → components/theme-params}/types.d.ts +2 -2
- package/dist/dts/{utils → components/utils}/Utils.d.ts +4 -4
- package/dist/dts/{viewport → components/viewport}/Viewport.d.ts +9 -5
- package/dist/dts/{viewport → components/viewport}/isStableViewportPlatform.d.ts +1 -1
- package/dist/dts/{viewport → components/viewport}/requestViewport.d.ts +2 -2
- package/dist/dts/{viewport → components/viewport}/types.d.ts +2 -2
- package/dist/dts/css/bindMiniAppCSSVars.d.ts +2 -2
- package/dist/dts/css/bindThemeCSSVars.d.ts +1 -1
- package/dist/dts/css/bindViewportCSSVars.d.ts +1 -1
- package/dist/dts/event-emitter/types.d.ts +1 -1
- package/dist/dts/globals.d.ts +1 -1
- package/dist/dts/index.d.ts +144 -27
- package/dist/dts/init/creators/createBackButton.d.ts +2 -2
- package/dist/dts/init/creators/createClosingBehavior.d.ts +2 -2
- package/dist/dts/init/creators/createMainButton.d.ts +3 -3
- package/dist/dts/init/creators/createMiniApp.d.ts +5 -5
- package/dist/dts/init/creators/createRequestIdGenerator.d.ts +1 -1
- package/dist/dts/init/creators/createSettingsButton.d.ts +2 -2
- package/dist/dts/init/creators/createThemeParams.d.ts +2 -1
- package/dist/dts/init/creators/createViewport.d.ts +3 -3
- package/dist/dts/init/css/processCSSVarsOption.d.ts +3 -3
- package/dist/dts/init/types.d.ts +16 -16
- package/dist/dts/launch-params/launchParamsParser.d.ts +2 -1
- package/dist/dts/launch-params/types.d.ts +3 -3
- package/dist/dts/navigation/HashNavigator/HashNavigator.d.ts +6 -3
- package/dist/dts/navigation/HashNavigator/types.d.ts +1 -2
- package/dist/dts/navigation/Navigator/Navigator.d.ts +1 -1
- package/dist/dts/parsing/ValueParser.d.ts +1 -1
- package/dist/dts/parsing/parsers/array.d.ts +2 -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/number.d.ts +2 -1
- package/dist/dts/parsing/parsers/rgb.d.ts +3 -1
- package/dist/dts/parsing/parsers/string.d.ts +2 -1
- package/dist/dts/state/State.d.ts +2 -2
- package/dist/dts/state/types.d.ts +1 -1
- package/dist/dts/storage.d.ts +2 -2
- package/dist/dts/supports/createSupportsFunc.d.ts +2 -2
- package/dist/dts/supports/createSupportsParamFunc.d.ts +2 -2
- package/dist/dts/supports/supports.d.ts +2 -2
- package/dist/dts/supports/types.d.ts +3 -0
- package/dist/dts/timeout/withTimeout.d.ts +2 -2
- package/dist/dts/types/logical.d.ts +16 -0
- package/dist/dts/types/methods.d.ts +1 -1
- package/dist/dts/types/unions.d.ts +20 -0
- package/dist/dts/types/utils.d.ts +0 -28
- package/dist/dts/version/compareVersions.d.ts +2 -1
- package/dist/dts/version/types.d.ts +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.mjs +1714 -1702
- package/package.json +1 -1
- package/dist/dts/back-button/index.d.ts +0 -2
- package/dist/dts/bridge/env/index.d.ts +0 -2
- package/dist/dts/bridge/errors/index.d.ts +0 -2
- package/dist/dts/bridge/events/index.d.ts +0 -9
- package/dist/dts/bridge/events/parsers/index.d.ts +0 -9
- package/dist/dts/bridge/index.d.ts +0 -7
- package/dist/dts/bridge/methods/index.d.ts +0 -6
- package/dist/dts/classnames/index.d.ts +0 -2
- package/dist/dts/closing-behavior/index.d.ts +0 -2
- package/dist/dts/cloud-storage/index.d.ts +0 -1
- package/dist/dts/colors/index.d.ts +0 -5
- package/dist/dts/css/index.d.ts +0 -4
- package/dist/dts/event-emitter/index.d.ts +0 -2
- package/dist/dts/haptic-feedback/index.d.ts +0 -1
- package/dist/dts/init/creators/index.d.ts +0 -8
- package/dist/dts/init/css/index.d.ts +0 -1
- package/dist/dts/init/index.d.ts +0 -2
- package/dist/dts/init-data/chatParser.d.ts +0 -5
- package/dist/dts/init-data/index.d.ts +0 -6
- package/dist/dts/init-data/initDataParser.d.ts +0 -5
- package/dist/dts/init-data/userParser.d.ts +0 -5
- package/dist/dts/invoice/index.d.ts +0 -2
- package/dist/dts/launch-params/index.d.ts +0 -10
- package/dist/dts/logger/index.d.ts +0 -1
- package/dist/dts/main-button/index.d.ts +0 -2
- package/dist/dts/mini-app/contactParser.d.ts +0 -2
- package/dist/dts/mini-app/index.d.ts +0 -2
- package/dist/dts/misc/index.d.ts +0 -5
- package/dist/dts/navigation/HashNavigator/index.d.ts +0 -2
- package/dist/dts/navigation/Navigator/index.d.ts +0 -2
- package/dist/dts/navigation/index.d.ts +0 -4
- package/dist/dts/parsing/index.d.ts +0 -10
- package/dist/dts/parsing/parsers/index.d.ts +0 -8
- package/dist/dts/popup/index.d.ts +0 -2
- package/dist/dts/qr-scanner/index.d.ts +0 -2
- package/dist/dts/settings-button/index.d.ts +0 -2
- package/dist/dts/state/index.d.ts +0 -2
- package/dist/dts/supports/index.d.ts +0 -4
- package/dist/dts/theme-params/index.d.ts +0 -6
- package/dist/dts/theme-params/requestThemeParams.d.ts +0 -7
- package/dist/dts/theme-params/themeParamsParser.d.ts +0 -2
- package/dist/dts/timeout/index.d.ts +0 -4
- package/dist/dts/types/index.d.ts +0 -4
- package/dist/dts/utils/index.d.ts +0 -1
- package/dist/dts/version/index.d.ts +0 -2
- package/dist/dts/viewport/index.d.ts +0 -4
- /package/dist/dts/{init-data → components/init-data}/InitData.d.ts +0 -0
- /package/dist/dts/{init-data → components/init-data}/parseInitData.d.ts +0 -0
- /package/dist/dts/{init-data → components/init-data}/types.d.ts +0 -0
- /package/dist/dts/{theme-params → components/theme-params}/keys.d.ts +0 -0
- /package/dist/dts/{theme-params → components/theme-params}/parseThemeParams.d.ts +0 -0
- /package/dist/dts/{theme-params → components/theme-params}/serializeThemeParams.d.ts +0 -0
- /package/dist/dts/{viewport → components/viewport}/utils.d.ts +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type CaptureSameReqFn = (payload: {
|
|
2
|
+
req_id: string;
|
|
3
|
+
}) => boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Returns a function which can be used in `request` function `capture` property to capture
|
|
6
|
+
* the event with the same request identifier.
|
|
7
|
+
* @param reqId - request identifier.
|
|
8
|
+
*/
|
|
9
|
+
export declare function captureSameReq(reqId: string): CaptureSameReqFn;
|
|
10
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Version } from '../../version/
|
|
2
|
-
import type { MiniAppsMethodName } from '../methods/
|
|
1
|
+
import type { Version } from '../../version/types.js';
|
|
2
|
+
import type { MiniAppsMethodName } from '../methods/methods.js';
|
|
3
3
|
/**
|
|
4
4
|
* Error thrown in case, unsupported method was called.
|
|
5
5
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Version } from '../../version/
|
|
2
|
-
import type { MiniAppsMethodName } from '../methods/
|
|
1
|
+
import type { Version } from '../../version/types.js';
|
|
2
|
+
import type { MiniAppsMethodName } from '../methods/methods.js';
|
|
3
3
|
/**
|
|
4
4
|
* Error thrown in case, unsupported parameter was used.
|
|
5
5
|
*/
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { ClipboardTextReceivedPayload } from './parsers/clipboardTextReceived.js';
|
|
2
|
+
import type { CustomMethodInvokedPayload } from './parsers/customMethodInvoked.js';
|
|
3
|
+
import type { InvoiceClosedPayload } from './parsers/invoiceClosed.js';
|
|
4
|
+
import type { PhoneRequestedPayload } from './parsers/phoneRequested.js';
|
|
5
|
+
import type { PopupClosedPayload } from './parsers/popupClosed.js';
|
|
6
|
+
import type { QrTextReceivedPayload } from './parsers/qrTextReceived.js';
|
|
7
|
+
import type { ThemeChangedPayload } from './parsers/theme-changed.js';
|
|
8
|
+
import type { ViewportChangedPayload } from './parsers/viewportChanged.js';
|
|
9
|
+
import type { WriteAccessRequestedPayload } from './parsers/writeAccessRequested.js';
|
|
10
|
+
import type { EventEmitter } from '../../event-emitter/EventEmitter.js';
|
|
11
|
+
import type { AnySubscribeListener, EventListener, EventParams } from '../../event-emitter/types.js';
|
|
12
|
+
import type { Not } from '../../types/logical.js';
|
|
13
|
+
import type { IsNever } from '../../types/utils.js';
|
|
4
14
|
/**
|
|
5
15
|
* Map where key is known event name, and value is its listener.
|
|
6
16
|
* @see https://docs.telegram-mini-apps.com/platform/events
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { MiniAppsEventListener, MiniAppsEventName } from './events.js';
|
|
2
|
-
type
|
|
2
|
+
import type { RemoveListenerFn } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Adds new listener to the specified event. Returns handler
|
|
5
5
|
* which allows to stop listening to event.
|
|
6
6
|
* @param event - event name.
|
|
7
7
|
* @param listener - event listener.
|
|
8
8
|
*/
|
|
9
|
-
export declare function on<E extends MiniAppsEventName>(event: E, listener: MiniAppsEventListener<E>):
|
|
10
|
-
export {};
|
|
9
|
+
export declare function on<E extends MiniAppsEventName>(event: E, listener: MiniAppsEventListener<E>): RemoveListenerFn;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { MiniAppsEventListener, MiniAppsEventName } from './events.js';
|
|
2
|
-
type
|
|
2
|
+
import type { RemoveListenerFn } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Works the same as "on" method, but after catching the event, will remove event listener.
|
|
5
5
|
* @param event - event name.
|
|
6
6
|
* @param listener - event listener.
|
|
7
7
|
*/
|
|
8
|
-
export declare function once<E extends MiniAppsEventName>(event: E, listener: MiniAppsEventListener<E>):
|
|
9
|
-
export {};
|
|
8
|
+
export declare function once<E extends MiniAppsEventName>(event: E, listener: MiniAppsEventListener<E>): RemoveListenerFn;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RequestId } from '../../../types/
|
|
1
|
+
import type { RequestId } from '../../../types/request-id.js';
|
|
2
2
|
export interface ClipboardTextReceivedPayload {
|
|
3
3
|
/**
|
|
4
4
|
* Passed during the `web_app_read_text_from_clipboard` method invocation `req_id` value.
|
|
@@ -10,4 +10,4 @@ export interface ClipboardTextReceivedPayload {
|
|
|
10
10
|
*/
|
|
11
11
|
data?: string | null;
|
|
12
12
|
}
|
|
13
|
-
export declare function clipboardTextReceived(): import(
|
|
13
|
+
export declare function clipboardTextReceived(): import("../../../parsing/ValueParser.js").ValueParser<ClipboardTextReceivedPayload, false>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RequestId } from '../../../types/
|
|
1
|
+
import type { RequestId } from '../../../types/request-id.js';
|
|
2
2
|
export interface CustomMethodInvokedPayload<R = unknown> {
|
|
3
3
|
/**
|
|
4
4
|
* Unique identifier of this invocation.
|
|
@@ -13,4 +13,4 @@ export interface CustomMethodInvokedPayload<R = unknown> {
|
|
|
13
13
|
*/
|
|
14
14
|
error?: string;
|
|
15
15
|
}
|
|
16
|
-
export declare function customMethodInvoked(): import(
|
|
16
|
+
export declare function customMethodInvoked(): import("../../../parsing/ValueParser.js").ValueParser<CustomMethodInvokedPayload<unknown>, false>;
|
|
@@ -9,4 +9,4 @@ export interface InvoiceClosedPayload {
|
|
|
9
9
|
*/
|
|
10
10
|
status: InvoiceStatus;
|
|
11
11
|
}
|
|
12
|
-
export declare function invoiceClosed(): import(
|
|
12
|
+
export declare function invoiceClosed(): import("../../../parsing/ValueParser.js").ValueParser<InvoiceClosedPayload, false>;
|
|
@@ -5,4 +5,4 @@ export interface PhoneRequestedPayload {
|
|
|
5
5
|
*/
|
|
6
6
|
status: PhoneRequestedStatus;
|
|
7
7
|
}
|
|
8
|
-
export declare function phoneRequested(): import(
|
|
8
|
+
export declare function phoneRequested(): import("../../../parsing/ValueParser.js").ValueParser<PhoneRequestedPayload, false>;
|
|
@@ -5,4 +5,4 @@ export interface PopupClosedPayload {
|
|
|
5
5
|
*/
|
|
6
6
|
button_id?: string;
|
|
7
7
|
}
|
|
8
|
-
export declare function popupClosed(): import(
|
|
8
|
+
export declare function popupClosed(): import("../../../parsing/ValueParser.js").ValueParser<PopupClosedPayload, false>;
|
|
@@ -4,4 +4,4 @@ export interface QrTextReceivedPayload {
|
|
|
4
4
|
*/
|
|
5
5
|
data?: string;
|
|
6
6
|
}
|
|
7
|
-
export declare function qrTextReceived(): import(
|
|
7
|
+
export declare function qrTextReceived(): import("../../../parsing/ValueParser.js").ValueParser<QrTextReceivedPayload, false>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RGB } from '../../../colors/
|
|
1
|
+
import type { RGB } from '../../../colors/types.js';
|
|
2
2
|
export interface ThemeChangedPayload {
|
|
3
3
|
/**
|
|
4
4
|
* Map where the key is a theme stylesheet key and value is the corresponding color in
|
|
@@ -39,4 +39,4 @@ export interface ThemeChangedPayload {
|
|
|
39
39
|
[key: string]: RGB | undefined;
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
export declare function themeChanged(): import(
|
|
42
|
+
export declare function themeChanged(): import("../../../parsing/ValueParser.js").ValueParser<ThemeChangedPayload, false>;
|
|
@@ -16,4 +16,4 @@ export interface ViewportChangedPayload {
|
|
|
16
16
|
*/
|
|
17
17
|
is_state_stable: boolean;
|
|
18
18
|
}
|
|
19
|
-
export declare function viewportChanged(): import(
|
|
19
|
+
export declare function viewportChanged(): import("../../../parsing/ValueParser.js").ValueParser<ViewportChangedPayload, false>;
|
|
@@ -5,4 +5,4 @@ export interface WriteAccessRequestedPayload {
|
|
|
5
5
|
*/
|
|
6
6
|
status: WriteAccessRequestedStatus;
|
|
7
7
|
}
|
|
8
|
-
export declare function writeAccessRequested(): import(
|
|
8
|
+
export declare function writeAccessRequested(): import("../../../parsing/ValueParser.js").ValueParser<WriteAccessRequestedPayload, false>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { MiniAppsGlobalEventListener } from './events.js';
|
|
2
|
-
type
|
|
2
|
+
import type { RemoveListenerFn } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Subscribes to all events sent from the native Telegram application.
|
|
5
5
|
* Returns function used to remove added event listener.
|
|
6
6
|
* @param listener - event listener.
|
|
7
7
|
*/
|
|
8
|
-
export declare function subscribe(listener: MiniAppsGlobalEventListener):
|
|
9
|
-
export {};
|
|
8
|
+
export declare function subscribe(listener: MiniAppsGlobalEventListener): RemoveListenerFn;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { CustomMethodName, CustomMethodParams } from './methods/custom-methods.js';
|
|
2
|
+
import type { ExecuteWithOptions } from '../types/methods.js';
|
|
3
3
|
/**
|
|
4
4
|
* Invokes known custom method. Returns method execution result.
|
|
5
5
|
* @param method - method name.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Version } from '../../version/index.js';
|
|
2
1
|
import { type PostEvent } from './postEvent.js';
|
|
2
|
+
import type { Version } from '../../version/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Creates function which checks if specified method and parameters are supported. In case,
|
|
5
5
|
* method or parameters are unsupported, an error will be thrown.
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import type { RGB } from '../../colors/index.js';
|
|
2
|
-
import type { IsNever, Not, RequestId, UnionKeys } from '../../types/index.js';
|
|
3
1
|
import type { AnyInvokeCustomMethodParams } from './custom-methods.js';
|
|
4
2
|
import type { AnyHapticFeedbackParams } from './haptic.js';
|
|
5
3
|
import type { PopupParams } from './popup.js';
|
|
4
|
+
import type { RGB } from '../../colors/types.js';
|
|
5
|
+
import type { If, Not } from '../../types/logical.js';
|
|
6
|
+
import type { RequestId } from '../../types/request-id.js';
|
|
7
|
+
import type { UnionKeys } from '../../types/unions.js';
|
|
8
|
+
import type { IsNever } from '../../types/utils.js';
|
|
6
9
|
/**
|
|
7
10
|
* Color key which could be used to update header color.
|
|
8
11
|
*/
|
|
@@ -11,7 +14,7 @@ export type HeaderColorKey = 'bg_color' | 'secondary_bg_color';
|
|
|
11
14
|
* Chat type which could be used when calling `web_app_switch_inline_query` method.
|
|
12
15
|
*/
|
|
13
16
|
export type SwitchInlineQueryChatType = 'users' | 'bots' | 'groups' | 'channels';
|
|
14
|
-
interface CreateParams<Params =
|
|
17
|
+
interface CreateParams<Params = never, VersionedParam extends UnionKeys<Params> = never> {
|
|
15
18
|
params: Params;
|
|
16
19
|
versionedParams: VersionedParam;
|
|
17
20
|
}
|
|
@@ -303,19 +306,17 @@ export type MiniAppsMethodParams<M extends MiniAppsMethodName> = MiniAppsMethods
|
|
|
303
306
|
/**
|
|
304
307
|
* True if specified method accepts parameters.
|
|
305
308
|
*/
|
|
306
|
-
export type MiniAppsMethodAcceptParams<M extends MiniAppsMethodName> = Not<IsNever<
|
|
309
|
+
export type MiniAppsMethodAcceptParams<M extends MiniAppsMethodName> = Not<IsNever<MiniAppsMethodParams<M>>>;
|
|
307
310
|
/**
|
|
308
311
|
* Any post-available event name which does not require arguments.
|
|
309
312
|
*/
|
|
310
313
|
export type MiniAppsEmptyMethodName = {
|
|
311
|
-
[
|
|
314
|
+
[Method in MiniAppsMethodName]: If<MiniAppsMethodAcceptParams<Method>, never, Method>;
|
|
312
315
|
}[MiniAppsMethodName];
|
|
313
316
|
/**
|
|
314
317
|
* Any post-available event name which require arguments.
|
|
315
318
|
*/
|
|
316
|
-
export type MiniAppsNonEmptyMethodName =
|
|
317
|
-
[M in MiniAppsMethodName]: MiniAppsMethodAcceptParams<M> extends true ? M : never;
|
|
318
|
-
}[MiniAppsMethodName];
|
|
319
|
+
export type MiniAppsNonEmptyMethodName = Exclude<MiniAppsMethodName, MiniAppsEmptyMethodName>;
|
|
319
320
|
/**
|
|
320
321
|
* Method names which have versioned params.
|
|
321
322
|
*/
|
|
@@ -1,56 +1,54 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import type { MiniAppsEventName, MiniAppsEventParams } from './events/events.js';
|
|
2
|
+
import type { MiniAppsEmptyMethodName, MiniAppsMethodName, MiniAppsMethodParams, MiniAppsNonEmptyMethodName } from './methods/methods.js';
|
|
3
|
+
import type { If } from '../types/logical.js';
|
|
4
|
+
import type { ExecuteWithOptions } from '../types/methods.js';
|
|
5
|
+
import type { IsNever } from '../types/utils.js';
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
7
|
+
* Simple `request` method options.
|
|
6
8
|
*/
|
|
7
|
-
type
|
|
8
|
-
[M in MiniAppsMethodName]: If<And<MiniAppsMethodAcceptParams<M>, MiniAppsMethodParams<M> extends {
|
|
9
|
-
req_id: string;
|
|
10
|
-
} ? true : false>, M, never>;
|
|
11
|
-
}[MiniAppsMethodName];
|
|
9
|
+
export type RequestSimpleOptions<Method extends MiniAppsMethodName> = Omit<RequestCompleteOptions<Method, any>, 'method' | 'event'>;
|
|
12
10
|
/**
|
|
13
|
-
*
|
|
11
|
+
* Complete `request` method options.
|
|
14
12
|
*/
|
|
15
|
-
type
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
export type RequestCompleteOptions<Method extends MiniAppsMethodName, Event extends MiniAppsEventName> = {
|
|
14
|
+
/**
|
|
15
|
+
* Mini Apps method name.
|
|
16
|
+
*/
|
|
17
|
+
method: Method;
|
|
18
|
+
/**
|
|
19
|
+
* One or many tracked Mini Apps events.
|
|
20
|
+
*/
|
|
21
|
+
event: Event | Event[];
|
|
23
22
|
/**
|
|
24
23
|
* Should return true in case, this event should be captured. If not specified,
|
|
25
24
|
* request is not skipping captured events.
|
|
26
25
|
*/
|
|
27
|
-
capture?: If<IsNever<
|
|
28
|
-
}
|
|
26
|
+
capture?: If<IsNever<MiniAppsEventParams<Event>>, () => boolean, (payload: MiniAppsEventParams<Event>) => boolean>;
|
|
27
|
+
} & ExecuteWithOptions & If<IsNever<MiniAppsMethodParams<Method>>, {}, {
|
|
28
|
+
/**
|
|
29
|
+
* List of method parameters.
|
|
30
|
+
*/
|
|
31
|
+
params: MiniAppsMethodParams<Method>;
|
|
32
|
+
}>;
|
|
29
33
|
/**
|
|
30
|
-
* Calls specified
|
|
31
|
-
* which will be resolved in case,
|
|
32
|
-
*
|
|
33
|
-
* @param method - method to execute.
|
|
34
|
-
* @param params - method parameters.
|
|
35
|
-
* @param event - event or events to listen.
|
|
36
|
-
* @param options - additional execution options.
|
|
34
|
+
* Calls specified Mini Apps method and captures one of the specified events. Returns promise
|
|
35
|
+
* which will be resolved in case, specified event was captured.
|
|
36
|
+
* @param options - method options.
|
|
37
37
|
*/
|
|
38
|
-
export declare function request<
|
|
38
|
+
export declare function request<Method extends MiniAppsEmptyMethodName, Event extends MiniAppsEventName>(options: RequestCompleteOptions<Method, Event>): Promise<MiniAppsEventParams<Event>>;
|
|
39
39
|
/**
|
|
40
|
-
* Calls specified
|
|
40
|
+
* Calls specified Mini Apps method and captures one of the specified events. Returns promise
|
|
41
41
|
* which will be resolved in case, specified event was captured.
|
|
42
|
-
* @param method - method
|
|
43
|
-
* @param
|
|
44
|
-
* @param options -
|
|
42
|
+
* @param method - method name.
|
|
43
|
+
* @param eventOrEvents - tracked event or events.
|
|
44
|
+
* @param options - method options.
|
|
45
45
|
*/
|
|
46
|
-
export declare function request<
|
|
46
|
+
export declare function request<Method extends MiniAppsNonEmptyMethodName, Event extends MiniAppsEventName>(method: Method, eventOrEvents: Event | Event[], options: RequestSimpleOptions<Method>): Promise<MiniAppsEventParams<Event>>;
|
|
47
47
|
/**
|
|
48
|
-
* Calls specified
|
|
48
|
+
* Calls specified Mini Apps method and captures one of the specified events. Returns promise
|
|
49
49
|
* which will be resolved in case, specified event was captured.
|
|
50
|
-
* @param method - method
|
|
51
|
-
* @param
|
|
52
|
-
* @param
|
|
53
|
-
* @param options - additional execution options.
|
|
50
|
+
* @param method - method name.
|
|
51
|
+
* @param eventOrEvents - tracked event or events.
|
|
52
|
+
* @param options - method options.
|
|
54
53
|
*/
|
|
55
|
-
export declare function request<
|
|
56
|
-
export {};
|
|
54
|
+
export declare function request<Method extends MiniAppsEmptyMethodName, Event extends MiniAppsEventName>(method: Method, eventOrEvents: Event | Event[], options?: RequestSimpleOptions<Method>): Promise<MiniAppsEventParams<Event>>;
|
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
type UnionStringKeys<U> = U extends U ? {
|
|
5
|
-
[K in keyof U]-?: U[K] extends string | undefined ? K : never;
|
|
6
|
-
}[keyof U] : never;
|
|
7
|
-
/**
|
|
8
|
-
* Returns union required keys.
|
|
9
|
-
*/
|
|
10
|
-
type UnionRequiredKeys<U> = U extends U ? {
|
|
11
|
-
[K in UnionStringKeys<U>]: ({} extends Pick<U, K> ? never : K);
|
|
12
|
-
}[UnionStringKeys<U>] : never;
|
|
13
|
-
/**
|
|
14
|
-
* Returns union optional keys.
|
|
15
|
-
*/
|
|
16
|
-
type UnionOptionalKeys<U> = Exclude<UnionStringKeys<U>, UnionRequiredKeys<U>>;
|
|
17
|
-
type MergeClassNames<Tuple extends any[]> = Exclude<Tuple[number], number | string | null | undefined | any[] | boolean> extends infer Union ? {
|
|
1
|
+
import type { UnionOptionalKeys, UnionRequiredKeys } from '../types/unions.js';
|
|
2
|
+
export type MergeClassNames<Tuple extends any[]> = Exclude<Tuple[number], number | string | null | undefined | any[] | boolean> extends infer Union ? {
|
|
18
3
|
[K in UnionRequiredKeys<Union>]: string;
|
|
19
4
|
} & {
|
|
20
5
|
[K in UnionOptionalKeys<Union>]?: string;
|
|
@@ -26,4 +11,3 @@ type MergeClassNames<Tuple extends any[]> = Exclude<Tuple[number], number | stri
|
|
|
26
11
|
* @see classNames
|
|
27
12
|
*/
|
|
28
13
|
export declare function mergeClassNames<T extends any[]>(...partials: T): MergeClassNames<T>;
|
|
29
|
-
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type PostEvent } from '../bridge/index.js';
|
|
2
|
-
import { EventEmitter } from '../event-emitter/index.js';
|
|
3
|
-
import { type SupportsFunc } from '../supports/index.js';
|
|
4
|
-
import type { Version } from '../version/index.js';
|
|
5
1
|
import type { BackButtonEvents } from './types.js';
|
|
2
|
+
import type { PostEvent } from '../../bridge/methods/postEvent.js';
|
|
3
|
+
import { EventEmitter } from '../../event-emitter/EventEmitter.js';
|
|
4
|
+
import type { SupportsFunc } from '../../supports/types.js';
|
|
5
|
+
import type { Version } from '../../version/types.js';
|
|
6
6
|
type Emitter = EventEmitter<BackButtonEvents>;
|
|
7
7
|
/**
|
|
8
8
|
* Class which controls the back button displayed in the header of the Mini App in the Telegram
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MiniAppsEventListener } from '
|
|
2
|
-
import type { StateEvents } from '
|
|
1
|
+
import type { MiniAppsEventListener } from '../../bridge/events/events.js';
|
|
2
|
+
import type { StateEvents } from '../../state/types.js';
|
|
3
3
|
export interface BackButtonState {
|
|
4
4
|
isVisible: boolean;
|
|
5
5
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { type PostEvent } from '../bridge/index.js';
|
|
2
1
|
import type { ClosingBehaviorEvents } from './types.js';
|
|
2
|
+
import type { PostEvent } from '../../bridge/methods/postEvent.js';
|
|
3
|
+
import { EventEmitter } from '../../event-emitter/EventEmitter.js';
|
|
4
|
+
type Emitter = EventEmitter<ClosingBehaviorEvents>;
|
|
3
5
|
/**
|
|
4
6
|
* Component responsible for controlling current closing confirmation
|
|
5
7
|
* status.
|
|
@@ -28,9 +30,10 @@ export declare class ClosingBehavior {
|
|
|
28
30
|
/**
|
|
29
31
|
* Adds new event listener.
|
|
30
32
|
*/
|
|
31
|
-
on:
|
|
33
|
+
on: Emitter['on'];
|
|
32
34
|
/**
|
|
33
35
|
* Removes event listener.
|
|
34
36
|
*/
|
|
35
|
-
off:
|
|
37
|
+
off: Emitter['off'];
|
|
36
38
|
}
|
|
39
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { postEvent as defaultPostEvent } from '
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
1
|
+
import { postEvent as defaultPostEvent } from '../../bridge/methods/postEvent.js';
|
|
2
|
+
import type { SupportsFunc } from '../../supports/types.js';
|
|
3
|
+
import type { ExecuteWithTimeout } from '../../types/methods.js';
|
|
4
|
+
import type { CreateRequestIdFunc } from '../../types/request-id.js';
|
|
5
|
+
import type { Version } from '../../version/types.js';
|
|
5
6
|
export declare class CloudStorage {
|
|
6
7
|
private readonly createRequestId;
|
|
7
8
|
private readonly postEvent;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
1
|
+
import type { ImpactHapticFeedbackStyle, NotificationHapticFeedbackType } from '../../bridge/methods/haptic.js';
|
|
2
|
+
import type { PostEvent } from '../../bridge/methods/postEvent.js';
|
|
3
|
+
import type { SupportsFunc } from '../../supports/types.js';
|
|
4
|
+
import type { Version } from '../../version/types.js';
|
|
4
5
|
/**
|
|
5
6
|
* Class which controls haptic feedback. It allows calling different types of
|
|
6
7
|
* haptic notifications which usually occur after user interaction with
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { InitDataParsed } from './types.js';
|
|
2
|
+
import type { ValueParser } from '../../parsing/ValueParser.js';
|
|
3
|
+
/**
|
|
4
|
+
* Returns parser used to parse init data, presented as search params.
|
|
5
|
+
*/
|
|
6
|
+
export declare function initDataParser(): ValueParser<InitDataParsed, false>;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { type InvoiceStatus, type PostEvent } from '../bridge/index.js';
|
|
2
|
-
import { type SupportsFunc } from '../supports/index.js';
|
|
3
|
-
import type { Version } from '../version/index.js';
|
|
4
1
|
import type { InvoiceEvents } from './types.js';
|
|
2
|
+
import type { InvoiceStatus } from '../../bridge/events/parsers/invoiceClosed.js';
|
|
3
|
+
import type { PostEvent } from '../../bridge/methods/postEvent.js';
|
|
4
|
+
import { EventEmitter } from '../../event-emitter/EventEmitter.js';
|
|
5
|
+
import type { SupportsFunc } from '../../supports/types.js';
|
|
6
|
+
import type { Version } from '../../version/types.js';
|
|
7
|
+
type Emitter = EventEmitter<InvoiceEvents>;
|
|
5
8
|
/**
|
|
6
9
|
* Controls currently displayed invoice.
|
|
7
10
|
*/
|
|
@@ -18,11 +21,11 @@ export declare class Invoice {
|
|
|
18
21
|
/**
|
|
19
22
|
* Adds new event listener.
|
|
20
23
|
*/
|
|
21
|
-
on:
|
|
24
|
+
on: Emitter['on'];
|
|
22
25
|
/**
|
|
23
26
|
* Removes event listener.
|
|
24
27
|
*/
|
|
25
|
-
off:
|
|
28
|
+
off: Emitter['off'];
|
|
26
29
|
/**
|
|
27
30
|
* Opens an invoice using its slug.
|
|
28
31
|
* @param slug - invoice slug.
|
|
@@ -41,3 +44,4 @@ export declare class Invoice {
|
|
|
41
44
|
*/
|
|
42
45
|
supports: SupportsFunc<'open'>;
|
|
43
46
|
}
|
|
47
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EventEmitter } from '../event-emitter/index.js';
|
|
2
|
-
import type { RGB } from '../colors/index.js';
|
|
3
1
|
import type { MainButtonEvents, MainButtonParams, MainButtonProps } from './types.js';
|
|
2
|
+
import type { RGB } from '../../colors/types.js';
|
|
3
|
+
import { EventEmitter } from '../../event-emitter/EventEmitter.js';
|
|
4
4
|
type Emitter = EventEmitter<MainButtonEvents>;
|
|
5
5
|
/**
|
|
6
6
|
* Controls the main button, which is displayed at the bottom
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { PostEvent } from '
|
|
2
|
-
import type { RGB } from '
|
|
3
|
-
import type { StateEvents } from '
|
|
1
|
+
import type { PostEvent } from '../../bridge/methods/postEvent.js';
|
|
2
|
+
import type { RGB } from '../../colors/types.js';
|
|
3
|
+
import type { StateEvents } from '../../state/types.js';
|
|
4
4
|
export interface MainButtonParams {
|
|
5
5
|
backgroundColor?: RGB;
|
|
6
6
|
isEnabled?: boolean;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { type PhoneRequestedStatus, type SwitchInlineQueryChatType, type WriteAccessRequestedStatus } from '../bridge/index.js';
|
|
2
|
-
import { type RGB } from '../colors/index.js';
|
|
3
|
-
import { type SupportsFunc } from '../supports/index.js';
|
|
4
|
-
import type { ExecuteWithTimeout } from '../types/index.js';
|
|
5
1
|
import type { MiniAppEvents, MiniAppHeaderColor, MiniAppProps, RequestedContact } from './types.js';
|
|
2
|
+
import type { PhoneRequestedStatus } from '../../bridge/events/parsers/phoneRequested.js';
|
|
3
|
+
import type { WriteAccessRequestedStatus } from '../../bridge/events/parsers/writeAccessRequested.js';
|
|
4
|
+
import type { SwitchInlineQueryChatType } from '../../bridge/methods/methods.js';
|
|
5
|
+
import type { RGB } from '../../colors/types.js';
|
|
6
|
+
import { EventEmitter } from '../../event-emitter/EventEmitter.js';
|
|
7
|
+
import type { SupportsFunc } from '../../supports/types.js';
|
|
8
|
+
import type { ExecuteWithTimeout } from '../../types/methods.js';
|
|
9
|
+
type Emitter = EventEmitter<MiniAppEvents>;
|
|
6
10
|
/**
|
|
7
11
|
* Provides common Mini Apps functionality not covered by other system components.
|
|
8
12
|
*/
|
|
@@ -50,11 +54,11 @@ export declare class MiniApp {
|
|
|
50
54
|
/**
|
|
51
55
|
* Adds new event listener.
|
|
52
56
|
*/
|
|
53
|
-
on:
|
|
57
|
+
on: Emitter['on'];
|
|
54
58
|
/**
|
|
55
59
|
* Removes event listener.
|
|
56
60
|
*/
|
|
57
|
-
off:
|
|
61
|
+
off: Emitter['off'];
|
|
58
62
|
/**
|
|
59
63
|
* Informs the Telegram app that the Mini App is ready to be displayed.
|
|
60
64
|
*
|
|
@@ -127,3 +131,4 @@ export declare class MiniApp {
|
|
|
127
131
|
*/
|
|
128
132
|
switchInlineQuery(text: string, chatTypes?: SwitchInlineQueryChatType[]): void;
|
|
129
133
|
}
|
|
134
|
+
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { HeaderColorKey
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
1
|
+
import type { HeaderColorKey } from '../../bridge/methods/methods.js';
|
|
2
|
+
import type { PostEvent } from '../../bridge/methods/postEvent.js';
|
|
3
|
+
import type { RGB } from '../../colors/types.js';
|
|
4
|
+
import type { StateEvents } from '../../state/types.js';
|
|
5
|
+
import type { CreateRequestIdFunc } from '../../types/request-id.js';
|
|
6
|
+
import type { Version } from '../../version/types.js';
|
|
6
7
|
export interface MiniAppProps {
|
|
7
8
|
headerColor: MiniAppHeaderColor;
|
|
8
9
|
backgroundColor: RGB;
|