@tma.js/sdk 1.4.3 → 1.4.6
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/README.md +2 -2
- package/dist/dts/bridge/events/events.d.ts +16 -16
- package/dist/dts/bridge/methods/methods.d.ts +27 -27
- package/dist/dts/bridge/methods/popup.d.ts +1 -1
- package/dist/dts/{init/css → css}/bindMiniAppCSSVars.d.ts +2 -2
- package/dist/dts/{init/css → css}/bindThemeCSSVars.d.ts +1 -1
- package/dist/dts/{init/css → css}/bindViewportCSSVars.d.ts +1 -1
- package/dist/dts/css/index.d.ts +4 -0
- package/dist/dts/index.d.ts +1 -0
- package/dist/dts/init-data/types.d.ts +3 -3
- package/dist/dts/launch-params/types.d.ts +1 -1
- package/dist/dts/theme-params/types.d.ts +1 -1
- package/dist/index.cjs +1 -2
- package/dist/index.iife.js +1 -2
- package/dist/index.mjs +126 -115
- package/package.json +2 -3
- package/dist/index.cjs.map +0 -1
- package/dist/index.iife.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/src/__tests__/globals.ts +0 -39
- package/src/back-button/BackButton.ts +0 -90
- package/src/back-button/__tests__/BackButton.ts +0 -129
- package/src/back-button/index.ts +0 -2
- package/src/back-button/types.ts +0 -14
- package/src/bridge/__tests__/parseMessage.ts +0 -23
- package/src/bridge/__tests__/request.ts +0 -236
- package/src/bridge/env/__tests__/hasExternalNotify.ts +0 -15
- package/src/bridge/env/__tests__/hasWebviewProxy.ts +0 -15
- package/src/bridge/env/__tests__/isIframe.ts +0 -30
- package/src/bridge/env/hasExternalNotify.ts +0 -19
- package/src/bridge/env/hasWebviewProxy.ts +0 -19
- package/src/bridge/env/index.ts +0 -3
- package/src/bridge/env/isIframe.ts +0 -11
- package/src/bridge/errors/MethodUnsupportedError.ts +0 -13
- package/src/bridge/errors/ParameterUnsupportedError.ts +0 -13
- package/src/bridge/errors/index.ts +0 -2
- package/src/bridge/events/__tests__/createEmitter.ts +0 -143
- package/src/bridge/events/__tests__/off.ts +0 -34
- package/src/bridge/events/__tests__/on.ts +0 -49
- package/src/bridge/events/__tests__/onTelegramEvent.ts +0 -49
- package/src/bridge/events/__tests__/once.ts +0 -64
- package/src/bridge/events/__tests__/singletonEmitter.ts +0 -22
- package/src/bridge/events/__tests__/subscribe.ts +0 -49
- package/src/bridge/events/__tests__/unsubscribe.ts +0 -34
- package/src/bridge/events/createEmitter.ts +0 -108
- package/src/bridge/events/events.ts +0 -170
- package/src/bridge/events/index.ts +0 -9
- package/src/bridge/events/off.ts +0 -14
- package/src/bridge/events/on.ts +0 -19
- package/src/bridge/events/onTelegramEvent.ts +0 -81
- package/src/bridge/events/once.ts +0 -18
- package/src/bridge/events/parsers/__tests__/clipboardTextReceived.ts +0 -21
- package/src/bridge/events/parsers/__tests__/invoiceClosed.ts +0 -12
- package/src/bridge/events/parsers/__tests__/popupClosed.ts +0 -10
- package/src/bridge/events/parsers/__tests__/qrTextReceived.ts +0 -9
- package/src/bridge/events/parsers/__tests__/theme-changed.ts +0 -42
- package/src/bridge/events/parsers/__tests__/viewportChanged.ts +0 -49
- package/src/bridge/events/parsers/clipboardTextReceived.ts +0 -26
- package/src/bridge/events/parsers/customMethodInvoked.ts +0 -25
- package/src/bridge/events/parsers/index.ts +0 -9
- package/src/bridge/events/parsers/invoiceClosed.ts +0 -26
- package/src/bridge/events/parsers/phoneRequested.ts +0 -14
- package/src/bridge/events/parsers/popupClosed.ts +0 -19
- package/src/bridge/events/parsers/qrTextReceived.ts +0 -14
- package/src/bridge/events/parsers/theme-changed.ts +0 -58
- package/src/bridge/events/parsers/viewportChanged.ts +0 -33
- package/src/bridge/events/parsers/writeAccessRequested.ts +0 -14
- package/src/bridge/events/singletonEmitter.ts +0 -19
- package/src/bridge/events/subscribe.ts +0 -15
- package/src/bridge/events/unsubscribe.ts +0 -10
- package/src/bridge/index.ts +0 -7
- package/src/bridge/invokeCustomMethod.ts +0 -56
- package/src/bridge/methods/__tests__/createPostEvent.ts +0 -37
- package/src/bridge/methods/__tests__/postEvent.ts +0 -137
- package/src/bridge/methods/createPostEvent.ts +0 -40
- package/src/bridge/methods/custom-methods.ts +0 -68
- package/src/bridge/methods/haptic.ts +0 -52
- package/src/bridge/methods/index.ts +0 -6
- package/src/bridge/methods/methods.ts +0 -370
- package/src/bridge/methods/popup.ts +0 -53
- package/src/bridge/methods/postEvent.ts +0 -101
- package/src/bridge/parseMessage.ts +0 -28
- package/src/bridge/request.ts +0 -176
- package/src/classnames/__tests__/classNames.ts +0 -20
- package/src/classnames/__tests__/mergeClassNames.ts +0 -21
- package/src/classnames/classNames.ts +0 -34
- package/src/classnames/index.ts +0 -2
- package/src/classnames/mergeClassNames.ts +0 -60
- package/src/closing-behavior/ClosingBehavior.ts +0 -64
- package/src/closing-behavior/__tests__/ClosingBehavior.ts +0 -86
- package/src/closing-behavior/index.ts +0 -2
- package/src/closing-behavior/types.ts +0 -12
- package/src/cloud-storage/CloudStorage.ts +0 -138
- package/src/cloud-storage/index.ts +0 -1
- package/src/colors/__tests__/isColorDark.ts +0 -12
- package/src/colors/__tests__/isRGB.ts +0 -13
- package/src/colors/__tests__/isRGBShort.ts +0 -13
- package/src/colors/__tests__/toRGB.ts +0 -23
- package/src/colors/index.ts +0 -5
- package/src/colors/isColorDark.ts +0 -22
- package/src/colors/isRGB.ts +0 -9
- package/src/colors/isRGBShort.ts +0 -9
- package/src/colors/toRGB.ts +0 -49
- package/src/colors/types.ts +0 -9
- package/src/event-emitter/EventEmitter.ts +0 -146
- package/src/event-emitter/__tests__/EventEmitter.ts +0 -145
- package/src/event-emitter/index.ts +0 -2
- package/src/event-emitter/types.ts +0 -60
- package/src/globals.ts +0 -38
- package/src/haptic-feedback/HapticFeedback.ts +0 -70
- package/src/haptic-feedback/__tests__/HapticFeedback.ts +0 -68
- package/src/haptic-feedback/index.ts +0 -1
- package/src/index.ts +0 -179
- package/src/init/catchCustomStyles.ts +0 -17
- package/src/init/creators/__tests__/createViewport.ts +0 -96
- package/src/init/creators/createBackButton.ts +0 -25
- package/src/init/creators/createClosingBehavior.ts +0 -24
- package/src/init/creators/createMainButton.ts +0 -51
- package/src/init/creators/createMiniApp.ts +0 -48
- package/src/init/creators/createRequestIdGenerator.ts +0 -13
- package/src/init/creators/createSettingsButton.ts +0 -25
- package/src/init/creators/createThemeParams.ts +0 -11
- package/src/init/creators/createViewport.ts +0 -94
- package/src/init/creators/index.ts +0 -8
- package/src/init/css/bindMiniAppCSSVars.ts +0 -48
- package/src/init/css/bindThemeCSSVars.ts +0 -31
- package/src/init/css/bindViewportCSSVars.ts +0 -36
- package/src/init/css/index.ts +0 -1
- package/src/init/css/processCSSVarsOption.ts +0 -57
- package/src/init/css/setCSSVar.ts +0 -8
- package/src/init/index.ts +0 -2
- package/src/init/init.ts +0 -134
- package/src/init/types.ts +0 -94
- package/src/init-data/InitData.ts +0 -96
- package/src/init-data/__tests__/InitData.ts +0 -98
- package/src/init-data/__tests__/chatParser.ts +0 -102
- package/src/init-data/__tests__/initDataParser.ts +0 -136
- package/src/init-data/__tests__/parseInitData.ts +0 -136
- package/src/init-data/__tests__/userParser.ts +0 -96
- package/src/init-data/chatParser.ts +0 -19
- package/src/init-data/index.ts +0 -6
- package/src/init-data/initDataParser.ts +0 -41
- package/src/init-data/parseInitData.ts +0 -10
- package/src/init-data/types.ts +0 -164
- package/src/init-data/userParser.ts +0 -45
- package/src/invoice/Invoice.ts +0 -123
- package/src/invoice/index.ts +0 -2
- package/src/invoice/types.ts +0 -11
- package/src/launch-params/__tests__/retrieveFromUrl.ts +0 -19
- package/src/launch-params/computeLaunchData.ts +0 -81
- package/src/launch-params/computePageReload.ts +0 -13
- package/src/launch-params/getFirstNavigationEntry.ts +0 -10
- package/src/launch-params/index.ts +0 -13
- package/src/launch-params/launchParamsParser.ts +0 -45
- package/src/launch-params/parseLaunchParams.ts +0 -10
- package/src/launch-params/retrieveCurrent.ts +0 -27
- package/src/launch-params/retrieveFromLocation.ts +0 -10
- package/src/launch-params/retrieveFromPerformance.ts +0 -18
- package/src/launch-params/retrieveFromUrl.ts +0 -19
- package/src/launch-params/retrieveLaunchData.ts +0 -30
- package/src/launch-params/serializeLaunchParams.ts +0 -37
- package/src/launch-params/storage.ts +0 -33
- package/src/launch-params/types.ts +0 -62
- package/src/logger/Logger.ts +0 -72
- package/src/logger/__tests__/Logger.ts +0 -107
- package/src/logger/index.ts +0 -1
- package/src/main-button/MainButton.ts +0 -239
- package/src/main-button/__tests__/MainButton.ts +0 -346
- package/src/main-button/index.ts +0 -2
- package/src/main-button/types.ts +0 -26
- package/src/mini-app/MiniApp.ts +0 -348
- package/src/mini-app/__tests__/MiniApp.ts +0 -140
- package/src/mini-app/contactParser.ts +0 -29
- package/src/mini-app/index.ts +0 -2
- package/src/mini-app/types.ts +0 -38
- package/src/misc/__tests__/isRecord.ts +0 -21
- package/src/misc/index.ts +0 -2
- package/src/misc/isRecord.ts +0 -7
- package/src/misc/isTMA.ts +0 -13
- package/src/navigation/HashNavigator/HashNavigator.ts +0 -220
- package/src/navigation/HashNavigator/__tests__/HashNavigator.ts +0 -144
- package/src/navigation/HashNavigator/__tests__/drop.ts +0 -42
- package/src/navigation/HashNavigator/__tests__/go.ts +0 -9
- package/src/navigation/HashNavigator/drop.ts +0 -36
- package/src/navigation/HashNavigator/go.ts +0 -28
- package/src/navigation/HashNavigator/index.ts +0 -2
- package/src/navigation/HashNavigator/types.ts +0 -41
- package/src/navigation/Navigator/Navigator.ts +0 -282
- package/src/navigation/Navigator/index.ts +0 -2
- package/src/navigation/Navigator/types.ts +0 -55
- package/src/navigation/ensurePrefix.ts +0 -9
- package/src/navigation/getHash.ts +0 -17
- package/src/navigation/index.ts +0 -4
- package/src/parsing/ArrayValueParser.ts +0 -79
- package/src/parsing/ParseError.ts +0 -27
- package/src/parsing/ParseSchemaFieldError.ts +0 -21
- package/src/parsing/ValueParser.ts +0 -71
- package/src/parsing/__tests__/ArrayValueParser.ts +0 -18
- package/src/parsing/__tests__/toRecord.ts +0 -10
- package/src/parsing/createValueParserGenerator.ts +0 -16
- package/src/parsing/index.ts +0 -10
- package/src/parsing/parseBySchema.ts +0 -65
- package/src/parsing/parsers/__tests__/array.ts +0 -39
- package/src/parsing/parsers/__tests__/boolean.ts +0 -31
- package/src/parsing/parsers/__tests__/date.ts +0 -25
- package/src/parsing/parsers/__tests__/json.ts +0 -80
- package/src/parsing/parsers/__tests__/number.ts +0 -23
- package/src/parsing/parsers/__tests__/rgb.ts +0 -22
- package/src/parsing/parsers/__tests__/searchParams.ts +0 -105
- package/src/parsing/parsers/__tests__/string.ts +0 -25
- package/src/parsing/parsers/array.ts +0 -9
- package/src/parsing/parsers/boolean.ts +0 -22
- package/src/parsing/parsers/date.ts +0 -11
- package/src/parsing/parsers/index.ts +0 -8
- package/src/parsing/parsers/json.ts +0 -17
- package/src/parsing/parsers/number.ts +0 -21
- package/src/parsing/parsers/rgb.ts +0 -10
- package/src/parsing/parsers/searchParams.ts +0 -24
- package/src/parsing/parsers/string.ts +0 -12
- package/src/parsing/toRecord.ts +0 -27
- package/src/parsing/types.ts +0 -32
- package/src/parsing/unexpectedTypeError.ts +0 -6
- package/src/popup/Popup.ts +0 -91
- package/src/popup/__tests__/Popup.ts +0 -130
- package/src/popup/__tests__/preparePopupParams.ts +0 -85
- package/src/popup/index.ts +0 -2
- package/src/popup/preparePopupParams.ts +0 -59
- package/src/popup/types.ts +0 -69
- package/src/qr-scanner/QRScanner.ts +0 -95
- package/src/qr-scanner/index.ts +0 -2
- package/src/qr-scanner/types.ts +0 -11
- package/src/settings-button/SettingsButton.ts +0 -85
- package/src/settings-button/index.ts +0 -2
- package/src/settings-button/types.ts +0 -15
- package/src/state/State.ts +0 -67
- package/src/state/index.ts +0 -2
- package/src/state/types.ts +0 -31
- package/src/storage.ts +0 -69
- package/src/supports/__tests__/supports.ts +0 -123
- package/src/supports/createSupportsFunc.ts +0 -18
- package/src/supports/createSupportsParamFunc.ts +0 -27
- package/src/supports/index.ts +0 -4
- package/src/supports/supports.ts +0 -84
- package/src/supports/types.ts +0 -1
- package/src/theme-params/ThemeParams.ts +0 -131
- package/src/theme-params/__tests__/keys.ts +0 -19
- package/src/theme-params/__tests__/parseThemeParams.ts +0 -29
- package/src/theme-params/__tests__/serializeThemeParams.ts +0 -29
- package/src/theme-params/__tests__/themeParamsParser.ts +0 -29
- package/src/theme-params/index.ts +0 -6
- package/src/theme-params/keys.ts +0 -24
- package/src/theme-params/parseThemeParams.ts +0 -10
- package/src/theme-params/requestThemeParams.ts +0 -13
- package/src/theme-params/serializeThemeParams.ts +0 -20
- package/src/theme-params/themeParamsParser.ts +0 -22
- package/src/theme-params/types.ts +0 -33
- package/src/timeout/TimeoutError.ts +0 -6
- package/src/timeout/__tests__/isTimeoutError.ts +0 -9
- package/src/timeout/__tests__/withTimeout.ts +0 -28
- package/src/timeout/index.ts +0 -4
- package/src/timeout/isTimeoutError.ts +0 -9
- package/src/timeout/sleep.ts +0 -10
- package/src/timeout/withTimeout.ts +0 -24
- package/src/types/index.ts +0 -4
- package/src/types/methods.ts +0 -18
- package/src/types/platform.ts +0 -14
- package/src/types/request-id.ts +0 -10
- package/src/types/utils.ts +0 -50
- package/src/utils/Utils.ts +0 -107
- package/src/utils/index.ts +0 -1
- package/src/version/__tests__/compareVersions.ts +0 -19
- package/src/version/compareVersions.ts +0 -28
- package/src/version/index.ts +0 -2
- package/src/version/types.ts +0 -4
- package/src/viewport/Viewport.ts +0 -171
- package/src/viewport/__tests__/isStableViewportPlatform.ts +0 -15
- package/src/viewport/__tests__/utils.ts +0 -12
- package/src/viewport/index.ts +0 -4
- package/src/viewport/isStableViewportPlatform.ts +0 -10
- package/src/viewport/requestViewport.ts +0 -23
- package/src/viewport/types.ts +0 -23
- package/src/viewport/utils.ts +0 -7
- /package/dist/dts/{init/css → css}/setCSSVar.d.ts +0 -0
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
[sdk-code-link]: https://github.com/Telegram-Mini-Apps/tma.js/tree/master/packages/sdk
|
|
8
8
|
|
|
9
|
-
[sdk-docs-link]: https://docs.telegram-mini-apps.com/packages/
|
|
9
|
+
[sdk-docs-link]: https://docs.telegram-mini-apps.com/packages/tma-js-sdk
|
|
10
10
|
|
|
11
11
|
[sdk-npm-link]: https://npmjs.com/package/@tma.js/sdk
|
|
12
12
|
|
|
@@ -27,5 +27,5 @@ Mini Apps. It consists of several individual components, each responsible for a
|
|
|
27
27
|
the Telegram Mini Apps ecosystem.
|
|
28
28
|
|
|
29
29
|
Before you begin using the SDK, we highly recommend familiarizing yourself with the Telegram Mini
|
|
30
|
-
Apps [documentation](https://docs.telegram-mini-apps.com/platform/about
|
|
30
|
+
Apps [documentation](https://docs.telegram-mini-apps.com/platform/about)
|
|
31
31
|
to grasp the fundamental concepts of the platform.
|
|
@@ -3,69 +3,69 @@ import type { IsNever, Not } from '../../types/index.js';
|
|
|
3
3
|
import type { ClipboardTextReceivedPayload, CustomMethodInvokedPayload, InvoiceClosedPayload, PhoneRequestedPayload, PopupClosedPayload, QrTextReceivedPayload, ThemeChangedPayload, ViewportChangedPayload, WriteAccessRequestedPayload } from './parsers/index.js';
|
|
4
4
|
/**
|
|
5
5
|
* Map where key is known event name, and value is its listener.
|
|
6
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
6
|
+
* @see https://docs.telegram-mini-apps.com/platform/events
|
|
7
7
|
*/
|
|
8
8
|
export interface MiniAppsEvents {
|
|
9
9
|
/**
|
|
10
10
|
* User clicked back button.
|
|
11
11
|
* @since v6.1
|
|
12
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
12
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#back-button-pressed
|
|
13
13
|
*/
|
|
14
14
|
back_button_pressed: () => void;
|
|
15
15
|
/**
|
|
16
16
|
* Telegram application attempted to extract text from clipboard.
|
|
17
17
|
* @param payload - event payload.
|
|
18
18
|
* @since v6.4
|
|
19
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
19
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#clipboard-text-received
|
|
20
20
|
*/
|
|
21
21
|
clipboard_text_received: (payload: ClipboardTextReceivedPayload) => void;
|
|
22
22
|
/**
|
|
23
23
|
* Custom method invocation completed.
|
|
24
24
|
* @param payload - event payload.
|
|
25
25
|
* @since v6.9
|
|
26
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
26
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#custom-method-invoked
|
|
27
27
|
*/
|
|
28
28
|
custom_method_invoked: (payload: CustomMethodInvokedPayload) => void;
|
|
29
29
|
/**
|
|
30
30
|
* An invoice was closed.
|
|
31
31
|
* @param payload - invoice close information.
|
|
32
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
32
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#invoice-closed
|
|
33
33
|
*/
|
|
34
34
|
invoice_closed: (payload: InvoiceClosedPayload) => void;
|
|
35
35
|
/**
|
|
36
36
|
* User clicked the Main Button.
|
|
37
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
37
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#main-button-pressed
|
|
38
38
|
*/
|
|
39
39
|
main_button_pressed: () => void;
|
|
40
40
|
/**
|
|
41
41
|
* Application received phone access request status.
|
|
42
42
|
* @param payload - event payload.
|
|
43
43
|
* @since v6.9
|
|
44
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
44
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#phone-requested
|
|
45
45
|
*/
|
|
46
46
|
phone_requested: (payload: PhoneRequestedPayload) => void;
|
|
47
47
|
/**
|
|
48
48
|
* Popup was closed.
|
|
49
49
|
* @param payload - event payload.
|
|
50
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
50
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#popup-closed
|
|
51
51
|
*/
|
|
52
52
|
popup_closed: (payload: PopupClosedPayload) => void;
|
|
53
53
|
/**
|
|
54
54
|
* Parent iframe requested current iframe reload.
|
|
55
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
55
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#reload-iframe
|
|
56
56
|
*/
|
|
57
57
|
reload_iframe: () => void;
|
|
58
58
|
/**
|
|
59
59
|
* The QR scanner scanned some QR and extracted its content.
|
|
60
60
|
* @param payload - event payload.
|
|
61
61
|
* @since v6.4
|
|
62
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
62
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#qr-text-received
|
|
63
63
|
*/
|
|
64
64
|
qr_text_received: (payload: QrTextReceivedPayload) => void;
|
|
65
65
|
/**
|
|
66
66
|
* QR scanner was closed.
|
|
67
67
|
* @since v6.4
|
|
68
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
68
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#scan-qr-popup-closed
|
|
69
69
|
*/
|
|
70
70
|
scan_qr_popup_closed: () => void;
|
|
71
71
|
/**
|
|
@@ -73,34 +73,34 @@ export interface MiniAppsEvents {
|
|
|
73
73
|
* `<style/>` tag html content, a developer could use. The stylesheet described in the payload
|
|
74
74
|
* will help the developer to stylize the app scrollbar (but he is still able to do it himself).
|
|
75
75
|
* @param html - `style` tag inner HTML.
|
|
76
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
76
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#set-custom-style
|
|
77
77
|
*/
|
|
78
78
|
set_custom_style: (html: string) => void;
|
|
79
79
|
/**
|
|
80
80
|
* Occurs when the Settings Button was pressed.
|
|
81
81
|
* @since v6.1
|
|
82
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
82
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#settings-button-pressed
|
|
83
83
|
*/
|
|
84
84
|
settings_button_pressed: () => void;
|
|
85
85
|
/**
|
|
86
86
|
* Occurs whenever theme settings are changed in the user's Telegram app
|
|
87
87
|
* (including switching to night mode).
|
|
88
88
|
* @param payload - event payload.
|
|
89
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
89
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#theme-changed
|
|
90
90
|
*/
|
|
91
91
|
theme_changed: (payload: ThemeChangedPayload) => void;
|
|
92
92
|
/**
|
|
93
93
|
* Occurs whenever the viewport has been changed. For example, when the user started
|
|
94
94
|
* dragging the application or called the expansion method.
|
|
95
95
|
* @param payload - event payload.
|
|
96
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
96
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#viewport-changed
|
|
97
97
|
*/
|
|
98
98
|
viewport_changed: (payload: ViewportChangedPayload) => void;
|
|
99
99
|
/**
|
|
100
100
|
* Application received write access request status.
|
|
101
101
|
* @param payload - event payload.
|
|
102
102
|
* @since v6.9
|
|
103
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
103
|
+
* @see https://docs.telegram-mini-apps.com/platform/events#write-access-requested
|
|
104
104
|
*/
|
|
105
105
|
write_access_requested: (payload: WriteAccessRequestedPayload) => void;
|
|
106
106
|
}
|
|
@@ -17,13 +17,13 @@ interface CreateParams<Params = undefined, VersionedParam extends UnionKeys<Para
|
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Describes list of events and their parameters that could be posted by Bridge.
|
|
20
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
20
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods
|
|
21
21
|
*/
|
|
22
22
|
export interface MiniAppsMethods {
|
|
23
23
|
/**
|
|
24
24
|
* Notifies parent iframe about the current frame is ready. This method is only used in the Web
|
|
25
25
|
* version of Telegram. As a result, Mini App will receive `set_custom_style` event.
|
|
26
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
26
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#iframe-ready
|
|
27
27
|
*/
|
|
28
28
|
iframe_ready: CreateParams<{
|
|
29
29
|
/**
|
|
@@ -33,18 +33,18 @@ export interface MiniAppsMethods {
|
|
|
33
33
|
} | undefined>;
|
|
34
34
|
/**
|
|
35
35
|
* Notifies parent iframe about the current iframe is going to reload.
|
|
36
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
36
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#iframe-will-reload
|
|
37
37
|
*/
|
|
38
38
|
iframe_will_reload: CreateParams;
|
|
39
39
|
/**
|
|
40
40
|
* Closes Mini App.
|
|
41
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
41
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-close
|
|
42
42
|
*/
|
|
43
43
|
web_app_close: CreateParams;
|
|
44
44
|
/**
|
|
45
45
|
* Closes a QR scanner. The Telegram application creates `scan_qr_popup_closed` event.
|
|
46
46
|
* @since v6.4
|
|
47
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
47
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-close-scan-qr-popup
|
|
48
48
|
*/
|
|
49
49
|
web_app_close_scan_qr_popup: CreateParams;
|
|
50
50
|
/**
|
|
@@ -54,7 +54,7 @@ export interface MiniAppsMethods {
|
|
|
54
54
|
* To get more information, take a look at `web_app_data` field in the
|
|
55
55
|
* class [Message](https://core.telegram.org/bots/api#message).
|
|
56
56
|
*
|
|
57
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
57
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-data-send
|
|
58
58
|
*/
|
|
59
59
|
web_app_data_send: CreateParams<{
|
|
60
60
|
/**
|
|
@@ -64,20 +64,20 @@ export interface MiniAppsMethods {
|
|
|
64
64
|
}>;
|
|
65
65
|
/**
|
|
66
66
|
* Expands the Mini App.
|
|
67
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
67
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-expand
|
|
68
68
|
*/
|
|
69
69
|
web_app_expand: CreateParams;
|
|
70
70
|
/**
|
|
71
71
|
* Invokes custom method.
|
|
72
72
|
* @since v6.9
|
|
73
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
73
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-invoke-custom-method
|
|
74
74
|
*/
|
|
75
75
|
web_app_invoke_custom_method: CreateParams<AnyInvokeCustomMethodParams>;
|
|
76
76
|
/**
|
|
77
77
|
* Opens an invoice by its specified slug. More information about invoices in
|
|
78
78
|
* this [documentation](https://core.telegram.org/bots/payments).
|
|
79
79
|
* @since v6.1
|
|
80
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
80
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-open-invoice
|
|
81
81
|
*/
|
|
82
82
|
web_app_open_invoice: CreateParams<{
|
|
83
83
|
/**
|
|
@@ -87,7 +87,7 @@ export interface MiniAppsMethods {
|
|
|
87
87
|
}>;
|
|
88
88
|
/**
|
|
89
89
|
* Opens link in the default browser. Mini App will not be closed.
|
|
90
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
90
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-open-link
|
|
91
91
|
*/
|
|
92
92
|
web_app_open_link: CreateParams<{
|
|
93
93
|
/**
|
|
@@ -104,7 +104,7 @@ export interface MiniAppsMethods {
|
|
|
104
104
|
/**
|
|
105
105
|
* Opens a new popup. When user closes the popup, Telegram creates the `popup_closed` event.
|
|
106
106
|
* @since v6.2
|
|
107
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
107
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-open-popup
|
|
108
108
|
*/
|
|
109
109
|
web_app_open_popup: CreateParams<PopupParams>;
|
|
110
110
|
/**
|
|
@@ -112,7 +112,7 @@ export interface MiniAppsMethods {
|
|
|
112
112
|
* the `scan_qr_popup_closed` event. When the scanner reads QR, Telegram creates the
|
|
113
113
|
* `qr_text_received` event.
|
|
114
114
|
* @since v6.4
|
|
115
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
115
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-open-scan-qr-popup
|
|
116
116
|
*/
|
|
117
117
|
web_app_open_scan_qr_popup: CreateParams<{
|
|
118
118
|
/**
|
|
@@ -124,7 +124,7 @@ export interface MiniAppsMethods {
|
|
|
124
124
|
* Opens the Telegram link by its pathname and query parameters. The link will be opened in the
|
|
125
125
|
* Telegram app, Mini App will be closed.
|
|
126
126
|
* @since v6.1
|
|
127
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
127
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-open-tg-link
|
|
128
128
|
*/
|
|
129
129
|
web_app_open_tg_link: CreateParams<{
|
|
130
130
|
/**
|
|
@@ -137,7 +137,7 @@ export interface MiniAppsMethods {
|
|
|
137
137
|
* Reads text from the clipboard. The method accepts a request identifier which is used to
|
|
138
138
|
* appropriately retrieve the method execution result from the `clipboard_text_received` event.
|
|
139
139
|
* @since v6.4
|
|
140
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
140
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-read-text-from-clipboard
|
|
141
141
|
*/
|
|
142
142
|
web_app_read_text_from_clipboard: CreateParams<{
|
|
143
143
|
/**
|
|
@@ -149,36 +149,36 @@ export interface MiniAppsMethods {
|
|
|
149
149
|
/**
|
|
150
150
|
* Notifies Telegram about current application is ready to be shown. This method will make
|
|
151
151
|
* Telegram to remove application loader and display Mini App.
|
|
152
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
152
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-ready
|
|
153
153
|
*/
|
|
154
154
|
web_app_ready: CreateParams;
|
|
155
155
|
/**
|
|
156
156
|
* Requests access to current user's phone.
|
|
157
157
|
* @since v6.9
|
|
158
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
158
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-request-phone
|
|
159
159
|
*/
|
|
160
160
|
web_app_request_phone: CreateParams;
|
|
161
161
|
/**
|
|
162
162
|
* Requests current theme from Telegram. As a result, Telegram will create `theme_changed` event.
|
|
163
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
163
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-request-theme
|
|
164
164
|
*/
|
|
165
165
|
web_app_request_theme: CreateParams;
|
|
166
166
|
/**
|
|
167
167
|
* Requests current viewport information from Telegram. As a result, Telegram will create
|
|
168
168
|
* `viewport_changed` event.
|
|
169
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
169
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-request-viewport
|
|
170
170
|
*/
|
|
171
171
|
web_app_request_viewport: CreateParams;
|
|
172
172
|
/**
|
|
173
173
|
* Requests write message access to current user.
|
|
174
174
|
* @since v6.9
|
|
175
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
175
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-rqeuest-write-access
|
|
176
176
|
*/
|
|
177
177
|
web_app_request_write_access: CreateParams;
|
|
178
178
|
/**
|
|
179
179
|
* Updates the Mini App background color.
|
|
180
180
|
* @since v6.1
|
|
181
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
181
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-set-background-color
|
|
182
182
|
*/
|
|
183
183
|
web_app_set_background_color: CreateParams<{
|
|
184
184
|
/**
|
|
@@ -189,7 +189,7 @@ export interface MiniAppsMethods {
|
|
|
189
189
|
/**
|
|
190
190
|
* Updates the Mini App header color.
|
|
191
191
|
* @since v6.1
|
|
192
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
192
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-set-header-color
|
|
193
193
|
*/
|
|
194
194
|
web_app_set_header_color: CreateParams<{
|
|
195
195
|
/**
|
|
@@ -206,7 +206,7 @@ export interface MiniAppsMethods {
|
|
|
206
206
|
/**
|
|
207
207
|
* Updates the Back Button settings.
|
|
208
208
|
* @since v6.1
|
|
209
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
209
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-setup-back-button
|
|
210
210
|
*/
|
|
211
211
|
web_app_setup_back_button: CreateParams<{
|
|
212
212
|
/**
|
|
@@ -216,7 +216,7 @@ export interface MiniAppsMethods {
|
|
|
216
216
|
}>;
|
|
217
217
|
/**
|
|
218
218
|
* Updates current closing behavior.
|
|
219
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
219
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-setup-closing-behavior
|
|
220
220
|
*/
|
|
221
221
|
web_app_setup_closing_behavior: CreateParams<{
|
|
222
222
|
/**
|
|
@@ -226,7 +226,7 @@ export interface MiniAppsMethods {
|
|
|
226
226
|
}>;
|
|
227
227
|
/**
|
|
228
228
|
* Updates the Main Button settings.
|
|
229
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
229
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-setup-main-button
|
|
230
230
|
*/
|
|
231
231
|
web_app_setup_main_button: CreateParams<{
|
|
232
232
|
/**
|
|
@@ -258,7 +258,7 @@ export interface MiniAppsMethods {
|
|
|
258
258
|
/**
|
|
259
259
|
* Updates current state of Settings Button.
|
|
260
260
|
* @since v6.10
|
|
261
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
261
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-setup-settings-button
|
|
262
262
|
*/
|
|
263
263
|
web_app_setup_settings_button: CreateParams<{
|
|
264
264
|
/**
|
|
@@ -272,7 +272,7 @@ export interface MiniAppsMethods {
|
|
|
272
272
|
* the user to choose a specific chat, then opens that chat and inserts the bot's username and
|
|
273
273
|
* the specified inline query in the input field.
|
|
274
274
|
* @since v6.7
|
|
275
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
275
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-switch-inline-query
|
|
276
276
|
*/
|
|
277
277
|
web_app_switch_inline_query: CreateParams<{
|
|
278
278
|
/**
|
|
@@ -288,7 +288,7 @@ export interface MiniAppsMethods {
|
|
|
288
288
|
/**
|
|
289
289
|
* Generates haptic feedback event.
|
|
290
290
|
* @since v6.1
|
|
291
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
291
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#web-app-trigger-haptic-feedback
|
|
292
292
|
*/
|
|
293
293
|
web_app_trigger_haptic_feedback: CreateParams<AnyHapticFeedbackParams>;
|
|
294
294
|
}
|
|
@@ -17,7 +17,7 @@ export interface PopupParams {
|
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Describes the native popup button.
|
|
20
|
-
* @see https://docs.telegram-mini-apps.com/platform/
|
|
20
|
+
* @see https://docs.telegram-mini-apps.com/platform/methods#popupbutton
|
|
21
21
|
*/
|
|
22
22
|
export type PopupButton = {
|
|
23
23
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MiniApp } from '
|
|
2
|
-
import type { ThemeParams } from '
|
|
1
|
+
import type { MiniApp } from '../mini-app/index.js';
|
|
2
|
+
import type { ThemeParams } from '../theme-params/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Creates CSS variables connected with WebApp background and header colors based on
|
|
5
5
|
* passed WebApp and ThemeParams instances.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ThemeParams } from '
|
|
1
|
+
import type { ThemeParams } from '../theme-params/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Creates CSS variables connected with theme parameters. Created CSS variables names are
|
|
4
4
|
* following the pattern "--tg-theme-{name}". {name} is a theme parameters key name converted
|
package/dist/dts/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { classNames, mergeClassNames } from './classnames/index.js';
|
|
|
4
4
|
export { ClosingBehavior, type ClosingBehaviorEventListener, type ClosingBehaviorEventName, type ClosingBehaviorEvents, } from './closing-behavior/index.js';
|
|
5
5
|
export { CloudStorage } from './cloud-storage/index.js';
|
|
6
6
|
export { isRGB, isRGBShort, isColorDark, toRGB, type RGB, type RGBShort, } from './colors/index.js';
|
|
7
|
+
export { setCSSVar, bindMiniAppCSSVars, bindThemeCSSVars, bindViewportCSSVars, } from './css/index.js';
|
|
7
8
|
export { HapticFeedback } from './haptic-feedback/index.js';
|
|
8
9
|
export { init, type InitOptions, type InitResult, } from './init/index.js';
|
|
9
10
|
export { chatParser, InitData, initDataParser, parseInitData, userParser, type Chat, type ChatType, type InitDataParsed, type User, } from './init-data/index.js';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export type ChatType = 'sender' | 'private' | 'group' | 'supergroup' | 'channel' | string;
|
|
5
5
|
/**
|
|
6
|
-
* Describes Telegram Mini Apps [User](https://docs.telegram-mini-apps.com/platform/
|
|
6
|
+
* Describes Telegram Mini Apps [User](https://docs.telegram-mini-apps.com/platform/init-data#user) type.
|
|
7
7
|
*/
|
|
8
8
|
export interface User {
|
|
9
9
|
/**
|
|
@@ -51,7 +51,7 @@ export interface User {
|
|
|
51
51
|
username?: string;
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
|
-
* Describes Telegram Mini Apps [Chat](https://docs.telegram-mini-apps.com/platform/
|
|
54
|
+
* Describes Telegram Mini Apps [Chat](https://docs.telegram-mini-apps.com/platform/init-data#chat) type.
|
|
55
55
|
*/
|
|
56
56
|
export interface Chat {
|
|
57
57
|
/**
|
|
@@ -77,7 +77,7 @@ export interface Chat {
|
|
|
77
77
|
username?: string;
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
|
-
* Describes Telegram Mini Apps [InitData](https://docs.telegram-mini-apps.com/platform/
|
|
80
|
+
* Describes Telegram Mini Apps [InitData](https://docs.telegram-mini-apps.com/platform/init-data#parameters-list)
|
|
81
81
|
* type.
|
|
82
82
|
*/
|
|
83
83
|
export interface InitDataParsed {
|
|
@@ -3,7 +3,7 @@ import type { ThemeParamsParsed } from '../theme-params/index.js';
|
|
|
3
3
|
import type { Platform } from '../types/index.js';
|
|
4
4
|
/**
|
|
5
5
|
* Telegram Mini Apps launch parameters.
|
|
6
|
-
* @see https://docs.telegram-mini-apps.com/platform/launch-parameters
|
|
6
|
+
* @see https://docs.telegram-mini-apps.com/platform/launch-parameters
|
|
7
7
|
*/
|
|
8
8
|
export interface LaunchParams {
|
|
9
9
|
/**
|
|
@@ -2,7 +2,7 @@ import type { RGB } from '../colors/index.js';
|
|
|
2
2
|
import type { StateEvents } from '../state/index.js';
|
|
3
3
|
export type ThemeParamsKey = 'accentTextColor' | 'backgroundColor' | 'buttonColor' | 'buttonTextColor' | 'destructiveTextColor' | 'headerBackgroundColor' | 'hintColor' | 'linkColor' | 'secondaryBackgroundColor' | 'sectionBackgroundColor' | 'sectionHeaderTextColor' | 'subtitleTextColor' | 'textColor';
|
|
4
4
|
/**
|
|
5
|
-
* Application [theme parameters](https://docs.telegram-mini-apps.com/platform/
|
|
5
|
+
* Application [theme parameters](https://docs.telegram-mini-apps.com/platform/theming).
|
|
6
6
|
* Defines palette used by the Telegram application.
|
|
7
7
|
*/
|
|
8
8
|
export interface ThemeParamsParsed {
|