@tma.js/sdk 1.4.4 → 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-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 +0 -1
- package/dist/index.iife.js +0 -1
- package/dist/index.mjs +0 -1
- 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/css/__tests__/bindMiniAppCSSVars.ts +0 -175
- package/src/css/__tests__/bindThemeCSSVars.ts +0 -52
- package/src/css/__tests__/bindViewportCSSVars.ts +0 -55
- package/src/css/__tests__/setCSSVar.ts +0 -14
- package/src/css/bindMiniAppCSSVars.ts +0 -51
- package/src/css/bindThemeCSSVars.ts +0 -31
- package/src/css/bindViewportCSSVars.ts +0 -36
- package/src/css/index.ts +0 -4
- package/src/css/setCSSVar.ts +0 -8
- 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 -185
- 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/index.ts +0 -1
- package/src/init/css/processCSSVarsOption.ts +0 -55
- 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
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AnySubscribeListener,
|
|
3
|
-
EventEmitter,
|
|
4
|
-
EventListener,
|
|
5
|
-
EventParams,
|
|
6
|
-
} from '~/event-emitter/index.js';
|
|
7
|
-
import type { IsNever, Not } from '~/types/index.js';
|
|
8
|
-
|
|
9
|
-
import type {
|
|
10
|
-
ClipboardTextReceivedPayload,
|
|
11
|
-
CustomMethodInvokedPayload,
|
|
12
|
-
InvoiceClosedPayload,
|
|
13
|
-
PhoneRequestedPayload,
|
|
14
|
-
PopupClosedPayload,
|
|
15
|
-
QrTextReceivedPayload,
|
|
16
|
-
ThemeChangedPayload,
|
|
17
|
-
ViewportChangedPayload,
|
|
18
|
-
WriteAccessRequestedPayload,
|
|
19
|
-
} from './parsers/index.js';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Map where key is known event name, and value is its listener.
|
|
23
|
-
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/events
|
|
24
|
-
*/
|
|
25
|
-
export interface MiniAppsEvents {
|
|
26
|
-
/**
|
|
27
|
-
* User clicked back button.
|
|
28
|
-
* @since v6.1
|
|
29
|
-
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/events#back-button-pressed
|
|
30
|
-
*/
|
|
31
|
-
back_button_pressed: () => void;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Telegram application attempted to extract text from clipboard.
|
|
35
|
-
* @param payload - event payload.
|
|
36
|
-
* @since v6.4
|
|
37
|
-
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/events#clipboard-text-received
|
|
38
|
-
*/
|
|
39
|
-
clipboard_text_received: (payload: ClipboardTextReceivedPayload) => void;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Custom method invocation completed.
|
|
43
|
-
* @param payload - event payload.
|
|
44
|
-
* @since v6.9
|
|
45
|
-
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/events#custom-method-invoked
|
|
46
|
-
*/
|
|
47
|
-
custom_method_invoked: (payload: CustomMethodInvokedPayload) => void;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* An invoice was closed.
|
|
51
|
-
* @param payload - invoice close information.
|
|
52
|
-
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/events#invoice-closed
|
|
53
|
-
*/
|
|
54
|
-
invoice_closed: (payload: InvoiceClosedPayload) => void;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* User clicked the Main Button.
|
|
58
|
-
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/events#main-button-pressed
|
|
59
|
-
*/
|
|
60
|
-
main_button_pressed: () => void;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Application received phone access request status.
|
|
64
|
-
* @param payload - event payload.
|
|
65
|
-
* @since v6.9
|
|
66
|
-
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/events#phone-requested
|
|
67
|
-
*/
|
|
68
|
-
phone_requested: (payload: PhoneRequestedPayload) => void;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Popup was closed.
|
|
72
|
-
* @param payload - event payload.
|
|
73
|
-
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/events#popup-closed
|
|
74
|
-
*/
|
|
75
|
-
popup_closed: (payload: PopupClosedPayload) => void;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Parent iframe requested current iframe reload.
|
|
79
|
-
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/events#reload-iframe
|
|
80
|
-
*/
|
|
81
|
-
reload_iframe: () => void;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* The QR scanner scanned some QR and extracted its content.
|
|
85
|
-
* @param payload - event payload.
|
|
86
|
-
* @since v6.4
|
|
87
|
-
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/events#qr-text-received
|
|
88
|
-
*/
|
|
89
|
-
qr_text_received: (payload: QrTextReceivedPayload) => void;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* QR scanner was closed.
|
|
93
|
-
* @since v6.4
|
|
94
|
-
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/events#scan-qr-popup-closed
|
|
95
|
-
*/
|
|
96
|
-
scan_qr_popup_closed: () => void;
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* The event which is usually sent by the Telegram web application. Its payload represents
|
|
100
|
-
* `<style/>` tag html content, a developer could use. The stylesheet described in the payload
|
|
101
|
-
* will help the developer to stylize the app scrollbar (but he is still able to do it himself).
|
|
102
|
-
* @param html - `style` tag inner HTML.
|
|
103
|
-
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/events#set-custom-style
|
|
104
|
-
*/
|
|
105
|
-
set_custom_style: (html: string) => void;
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Occurs when the Settings Button was pressed.
|
|
109
|
-
* @since v6.1
|
|
110
|
-
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/events#settings-button-pressed
|
|
111
|
-
*/
|
|
112
|
-
settings_button_pressed: () => void;
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Occurs whenever theme settings are changed in the user's Telegram app
|
|
116
|
-
* (including switching to night mode).
|
|
117
|
-
* @param payload - event payload.
|
|
118
|
-
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/events#theme-changed
|
|
119
|
-
*/
|
|
120
|
-
theme_changed: (payload: ThemeChangedPayload) => void;
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Occurs whenever the viewport has been changed. For example, when the user started
|
|
124
|
-
* dragging the application or called the expansion method.
|
|
125
|
-
* @param payload - event payload.
|
|
126
|
-
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/events#viewport-changed
|
|
127
|
-
*/
|
|
128
|
-
viewport_changed: (payload: ViewportChangedPayload) => void;
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Application received write access request status.
|
|
132
|
-
* @param payload - event payload.
|
|
133
|
-
* @since v6.9
|
|
134
|
-
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/events#write-access-requested
|
|
135
|
-
*/
|
|
136
|
-
write_access_requested: (payload: WriteAccessRequestedPayload) => void;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Any known event name.
|
|
141
|
-
*/
|
|
142
|
-
export type MiniAppsEventName = keyof MiniAppsEvents;
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Parameters of specified event.
|
|
146
|
-
*/
|
|
147
|
-
export type MiniAppsEventParams<E extends MiniAppsEventName> = EventParams<MiniAppsEvents[E]>[0];
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Returns event listener for specified event name.
|
|
151
|
-
*/
|
|
152
|
-
export type MiniAppsEventListener<E extends MiniAppsEventName> = EventListener<MiniAppsEvents[E]>;
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Event emitter, based describe events map.
|
|
156
|
-
*/
|
|
157
|
-
export type MiniAppsEventEmitter = EventEmitter<MiniAppsEvents>;
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Returns true in case, event has parameters.
|
|
161
|
-
*/
|
|
162
|
-
export type MiniAppsEventHasParams<E extends MiniAppsEventName> =
|
|
163
|
-
Not<IsNever<MiniAppsEventParams<E>>>;
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Event listener used in `subscribe` and `unsubscribe` functions.
|
|
167
|
-
*/
|
|
168
|
-
export type MiniAppsGlobalEventListener =
|
|
169
|
-
| AnySubscribeListener<MiniAppsEvents>
|
|
170
|
-
| ((event: string, data: unknown) => void);
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from './createEmitter.js';
|
|
2
|
-
export * from './events.js';
|
|
3
|
-
export * from './off.js';
|
|
4
|
-
export * from './on.js';
|
|
5
|
-
export * from './once.js';
|
|
6
|
-
export * from './parsers/index.js';
|
|
7
|
-
export * from './singletonEmitter.js';
|
|
8
|
-
export * from './subscribe.js';
|
|
9
|
-
export * from './unsubscribe.js';
|
package/src/bridge/events/off.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { MiniAppsEventListener, MiniAppsEventName } from './events.js';
|
|
2
|
-
import { singletonEmitter } from './singletonEmitter.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Removes listener from specified event.
|
|
6
|
-
* @param event - event to listen.
|
|
7
|
-
* @param listener - event listener.
|
|
8
|
-
*/
|
|
9
|
-
export function off<E extends MiniAppsEventName>(
|
|
10
|
-
event: E,
|
|
11
|
-
listener: MiniAppsEventListener<E>,
|
|
12
|
-
): void {
|
|
13
|
-
singletonEmitter().off(event, listener);
|
|
14
|
-
}
|
package/src/bridge/events/on.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { MiniAppsEventListener, MiniAppsEventName } from './events.js';
|
|
2
|
-
import { off } from './off.js';
|
|
3
|
-
import { singletonEmitter } from './singletonEmitter.js';
|
|
4
|
-
|
|
5
|
-
type StopListening = () => void;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Adds new listener to the specified event. Returns handler
|
|
9
|
-
* which allows to stop listening to event.
|
|
10
|
-
* @param event - event name.
|
|
11
|
-
* @param listener - event listener.
|
|
12
|
-
*/
|
|
13
|
-
export function on<E extends MiniAppsEventName>(
|
|
14
|
-
event: E,
|
|
15
|
-
listener: MiniAppsEventListener<E>,
|
|
16
|
-
): StopListening {
|
|
17
|
-
singletonEmitter().on(event, listener);
|
|
18
|
-
return () => off(event, listener);
|
|
19
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { parseMessage } from '~/bridge/parseMessage.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Emits event sent from Telegram native application like it was sent in
|
|
5
|
-
* default web environment between 2 iframes. It dispatches new MessageEvent
|
|
6
|
-
* and expects it to be handled via `window.addEventListener('message', ...)`
|
|
7
|
-
* as developer would do it to handle messages sent from the parent iframe.
|
|
8
|
-
* @param eventType - event name.
|
|
9
|
-
* @param eventData - event payload.
|
|
10
|
-
*/
|
|
11
|
-
function emitEvent(eventType: string, eventData: unknown): void {
|
|
12
|
-
window.dispatchEvent(new MessageEvent('message', {
|
|
13
|
-
data: JSON.stringify({ eventType, eventData }),
|
|
14
|
-
// We specify window.parent to imitate the case, it sent us this event.
|
|
15
|
-
source: window.parent,
|
|
16
|
-
}));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Defines special handlers by known paths, which are recognized by
|
|
21
|
-
* Telegram as ports to receive events. This function also sets special
|
|
22
|
-
* function in global window object to prevent duplicate declaration.
|
|
23
|
-
*/
|
|
24
|
-
function defineEventHandlers(): void {
|
|
25
|
-
const wnd: any = window;
|
|
26
|
-
|
|
27
|
-
// Prevent from duplicate event handlers definition.
|
|
28
|
-
if ('TelegramGameProxy_receiveEvent' in wnd) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Iterate over each path, where "receiveEvent" function should be
|
|
33
|
-
// defined. This function is called by external environment in case,
|
|
34
|
-
// it wants to emit some event.
|
|
35
|
-
[
|
|
36
|
-
['TelegramGameProxy_receiveEvent'], // Windows Phone.
|
|
37
|
-
['TelegramGameProxy', 'receiveEvent'], // Desktop.
|
|
38
|
-
['Telegram', 'WebView', 'receiveEvent'], // Android and iOS.
|
|
39
|
-
].forEach((path) => {
|
|
40
|
-
// Path starts from "window" object.
|
|
41
|
-
let pointer = wnd;
|
|
42
|
-
|
|
43
|
-
path.forEach((item, idx, arr) => {
|
|
44
|
-
// We are on the last iteration, where function property name is passed.
|
|
45
|
-
if (idx === arr.length - 1) {
|
|
46
|
-
pointer[item] = emitEvent;
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (!(item in pointer)) {
|
|
51
|
-
pointer[item] = {};
|
|
52
|
-
}
|
|
53
|
-
pointer = pointer[item];
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Adds listener to window "message" event assuming, that this event could
|
|
60
|
-
* be sent by Telegram native application. Calls passed callback with event
|
|
61
|
-
* type and data.
|
|
62
|
-
* @param cb - callback to call.
|
|
63
|
-
*/
|
|
64
|
-
export function onTelegramEvent(cb: (eventType: string, eventData: unknown) => void): void {
|
|
65
|
-
// Define event handlers to make sure, message handler will work correctly.
|
|
66
|
-
defineEventHandlers();
|
|
67
|
-
|
|
68
|
-
// We expect Telegram to send us new event through "message" event.
|
|
69
|
-
window.addEventListener('message', (event) => {
|
|
70
|
-
if (event.source !== window.parent) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
try {
|
|
75
|
-
const { eventType, eventData } = parseMessage(event.data);
|
|
76
|
-
cb(eventType, eventData);
|
|
77
|
-
} catch {
|
|
78
|
-
// We ignore incorrect messages as they could be generated by any other code.
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { MiniAppsEventListener, MiniAppsEventName } from './events.js';
|
|
2
|
-
import { off } from './off.js';
|
|
3
|
-
import { singletonEmitter } from './singletonEmitter.js';
|
|
4
|
-
|
|
5
|
-
type StopListening = () => void;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Works the same as "on" method, but after catching the event, will remove event listener.
|
|
9
|
-
* @param event - event name.
|
|
10
|
-
* @param listener - event listener.
|
|
11
|
-
*/
|
|
12
|
-
export function once<E extends MiniAppsEventName>(
|
|
13
|
-
event: E,
|
|
14
|
-
listener: MiniAppsEventListener<E>,
|
|
15
|
-
): StopListening {
|
|
16
|
-
singletonEmitter().once(event, listener);
|
|
17
|
-
return () => off(event, listener);
|
|
18
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { expect, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { clipboardTextReceived } from '../clipboardTextReceived';
|
|
4
|
-
|
|
5
|
-
it('should return parsed value in case, passed value satisfies schema', () => {
|
|
6
|
-
const cases = [
|
|
7
|
-
{ req_id: 'abc', data: 'ok' },
|
|
8
|
-
{ req_id: 'abc' },
|
|
9
|
-
{ req_id: 'abc', data: null },
|
|
10
|
-
];
|
|
11
|
-
|
|
12
|
-
cases.forEach((value) => {
|
|
13
|
-
expect(clipboardTextReceived().parse(value)).toStrictEqual(value);
|
|
14
|
-
expect(clipboardTextReceived().parse(JSON.stringify(value)))
|
|
15
|
-
.toStrictEqual(value);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('should throw an error in case, passed value does not satisfy schema', () => {
|
|
20
|
-
expect(() => clipboardTextReceived().parse({})).toThrow();
|
|
21
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { expect, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { invoiceClosed } from '../invoiceClosed';
|
|
4
|
-
|
|
5
|
-
it('should return parsed value in case, passed value satisfies schema', () => {
|
|
6
|
-
const value = { slug: 'abc', status: 'def' };
|
|
7
|
-
expect(invoiceClosed().parse(value)).toStrictEqual(value);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('should throw an error in case, passed value does not satisfy schema', () => {
|
|
11
|
-
expect(() => invoiceClosed().parse({})).toThrow();
|
|
12
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { expect, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { popupClosed } from '../popupClosed';
|
|
4
|
-
|
|
5
|
-
it('should return parsed value in case, passed value satisfies schema', () => {
|
|
6
|
-
expect(popupClosed().parse({ button_id: 'ok' })).toStrictEqual({ button_id: 'ok' });
|
|
7
|
-
expect(popupClosed().parse({})).toStrictEqual({});
|
|
8
|
-
expect(popupClosed().parse({ button_id: null })).toStrictEqual({});
|
|
9
|
-
expect(popupClosed().parse({ button_id: 100 })).toStrictEqual({ button_id: '100' });
|
|
10
|
-
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { expect, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { qrTextReceived } from '../qrTextReceived';
|
|
4
|
-
|
|
5
|
-
it('should return parsed value in case, passed value satisfies schema', () => {
|
|
6
|
-
expect(qrTextReceived().parse({ data: 'ok' })).toStrictEqual({ data: 'ok' });
|
|
7
|
-
expect(qrTextReceived().parse({})).toStrictEqual({});
|
|
8
|
-
expect(qrTextReceived().parse({ data: 100 })).toStrictEqual({ data: '100' });
|
|
9
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { expect, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { themeChanged } from '../theme-changed';
|
|
4
|
-
|
|
5
|
-
it('should return parsed value in case, passed value satisfies schema', () => {
|
|
6
|
-
const values = [
|
|
7
|
-
{
|
|
8
|
-
theme_params: {
|
|
9
|
-
accent_text_color: '#aaccbb',
|
|
10
|
-
bg_color: '#ffaabb',
|
|
11
|
-
button_color: '#faaafa',
|
|
12
|
-
button_text_color: '#666271',
|
|
13
|
-
destructive_text_color: '#111332',
|
|
14
|
-
header_bg_color: '#aab133',
|
|
15
|
-
hint_color: '#113322',
|
|
16
|
-
link_color: '#882133',
|
|
17
|
-
secondary_bg_color: '#2231aa',
|
|
18
|
-
section_bg_color: '#111332',
|
|
19
|
-
section_header_text_color: '#111332',
|
|
20
|
-
subtitle_text_color: '#111332',
|
|
21
|
-
text_color: '#bbaadd',
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
theme_params: {},
|
|
26
|
-
},
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
values.forEach((value) => {
|
|
30
|
-
expect(themeChanged().parse(value)).toStrictEqual(value);
|
|
31
|
-
expect(themeChanged().parse(JSON.stringify(value))).toStrictEqual(value);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('should throw an error in case, passed value does not satisfy schema', () => {
|
|
36
|
-
expect(() => themeChanged().parse({})).toThrow();
|
|
37
|
-
expect(() => themeChanged().parse({
|
|
38
|
-
theme_params: {
|
|
39
|
-
bg_color: 'Hello there!',
|
|
40
|
-
},
|
|
41
|
-
})).toThrow();
|
|
42
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, expect, it, vi } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { viewportChanged } from '../viewportChanged';
|
|
4
|
-
|
|
5
|
-
const windowSpy = vi.spyOn(window, 'window', 'get');
|
|
6
|
-
// const innerWidth = 2000;
|
|
7
|
-
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
windowSpy.mockImplementation(() => ({ innerWidth: 2000 }) as any);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
afterEach(() => {
|
|
13
|
-
windowSpy.mockRestore();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('should return parsed value in case, passed value satisfies schema', () => {
|
|
17
|
-
const values = [
|
|
18
|
-
{
|
|
19
|
-
height: 900,
|
|
20
|
-
is_state_stable: true,
|
|
21
|
-
is_expanded: true,
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
width: null,
|
|
25
|
-
height: 900,
|
|
26
|
-
is_state_stable: true,
|
|
27
|
-
is_expanded: true,
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
height: 900,
|
|
31
|
-
width: 100,
|
|
32
|
-
is_state_stable: true,
|
|
33
|
-
is_expanded: true,
|
|
34
|
-
},
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
values.forEach((value) => {
|
|
38
|
-
const width = !value.width ? window.innerWidth : value.width;
|
|
39
|
-
expect(viewportChanged().parse(value)).toStrictEqual({ ...value, width });
|
|
40
|
-
expect(viewportChanged().parse(JSON.stringify(value))).toStrictEqual({
|
|
41
|
-
...value,
|
|
42
|
-
width,
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('should throw an error in case, passed value does not satisfy schema', () => {
|
|
48
|
-
expect(() => viewportChanged().parse({})).toThrow();
|
|
49
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { json, string } from '~/parsing/index.js';
|
|
2
|
-
import type { RequestId } from '~/types/index.js';
|
|
3
|
-
|
|
4
|
-
export interface ClipboardTextReceivedPayload {
|
|
5
|
-
/**
|
|
6
|
-
* Passed during the `web_app_read_text_from_clipboard` method invocation `req_id` value.
|
|
7
|
-
*/
|
|
8
|
-
req_id: RequestId;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Data extracted from the clipboard. The returned value will have the type `string` only in
|
|
12
|
-
* the case, application has access to the clipboard.
|
|
13
|
-
*/
|
|
14
|
-
data?: string | null;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function clipboardTextReceived() {
|
|
18
|
-
return json<ClipboardTextReceivedPayload>({
|
|
19
|
-
req_id: string(),
|
|
20
|
-
data: (value) => (
|
|
21
|
-
value === null
|
|
22
|
-
? value
|
|
23
|
-
: string().optional().parse(value)
|
|
24
|
-
),
|
|
25
|
-
});
|
|
26
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { json, string } from '~/parsing/index.js';
|
|
2
|
-
import type { RequestId } from '~/types/index.js';
|
|
3
|
-
|
|
4
|
-
export interface CustomMethodInvokedPayload<R = unknown> {
|
|
5
|
-
/**
|
|
6
|
-
* Unique identifier of this invocation.
|
|
7
|
-
*/
|
|
8
|
-
req_id: RequestId;
|
|
9
|
-
/**
|
|
10
|
-
* Method invocation successful result.
|
|
11
|
-
*/
|
|
12
|
-
result?: R;
|
|
13
|
-
/**
|
|
14
|
-
* Method invocation error code.
|
|
15
|
-
*/
|
|
16
|
-
error?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function customMethodInvoked() {
|
|
20
|
-
return json<CustomMethodInvokedPayload>({
|
|
21
|
-
req_id: string(),
|
|
22
|
-
result: (value) => value,
|
|
23
|
-
error: string().optional(),
|
|
24
|
-
});
|
|
25
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from './clipboardTextReceived.js';
|
|
2
|
-
export * from './customMethodInvoked.js';
|
|
3
|
-
export * from './invoiceClosed.js';
|
|
4
|
-
export * from './phoneRequested.js';
|
|
5
|
-
export * from './popupClosed.js';
|
|
6
|
-
export * from './qrTextReceived.js';
|
|
7
|
-
export * from './theme-changed.js';
|
|
8
|
-
export * from './viewportChanged.js';
|
|
9
|
-
export * from './writeAccessRequested.js';
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { json, string } from '~/parsing/index.js';
|
|
2
|
-
|
|
3
|
-
export type InvoiceStatus =
|
|
4
|
-
| 'paid'
|
|
5
|
-
| 'failed'
|
|
6
|
-
| 'pending'
|
|
7
|
-
| 'cancelled'
|
|
8
|
-
| string;
|
|
9
|
-
|
|
10
|
-
export interface InvoiceClosedPayload {
|
|
11
|
-
/**
|
|
12
|
-
* Passed during the `web_app_open_invoice` method invocation `slug` value.
|
|
13
|
-
*/
|
|
14
|
-
slug: string;
|
|
15
|
-
/**
|
|
16
|
-
* Invoice status
|
|
17
|
-
*/
|
|
18
|
-
status: InvoiceStatus;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function invoiceClosed() {
|
|
22
|
-
return json<InvoiceClosedPayload>({
|
|
23
|
-
slug: string(),
|
|
24
|
-
status: string(),
|
|
25
|
-
});
|
|
26
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { json, string } from '~/parsing/index.js';
|
|
2
|
-
|
|
3
|
-
export type PhoneRequestedStatus = 'sent' | 'cancelled' | string;
|
|
4
|
-
|
|
5
|
-
export interface PhoneRequestedPayload {
|
|
6
|
-
/**
|
|
7
|
-
* Request status.
|
|
8
|
-
*/
|
|
9
|
-
status: PhoneRequestedStatus;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function phoneRequested() {
|
|
13
|
-
return json<PhoneRequestedPayload>({ status: string() });
|
|
14
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { json, string } from '~/parsing/index.js';
|
|
2
|
-
|
|
3
|
-
export interface PopupClosedPayload {
|
|
4
|
-
/**
|
|
5
|
-
* Identifier of the clicked button. In case, the popup was closed without clicking any button,
|
|
6
|
-
* this property will be omitted.
|
|
7
|
-
*/
|
|
8
|
-
button_id?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function popupClosed() {
|
|
12
|
-
return json<PopupClosedPayload>({
|
|
13
|
-
button_id: (value) => (
|
|
14
|
-
value === null || value === undefined
|
|
15
|
-
? undefined
|
|
16
|
-
: string().parse(value)
|
|
17
|
-
),
|
|
18
|
-
});
|
|
19
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { json, string } from '~/parsing/index.js';
|
|
2
|
-
|
|
3
|
-
export interface QrTextReceivedPayload {
|
|
4
|
-
/**
|
|
5
|
-
* Data extracted from the QR.
|
|
6
|
-
*/
|
|
7
|
-
data?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function qrTextReceived() {
|
|
11
|
-
return json<QrTextReceivedPayload>({
|
|
12
|
-
data: string().optional(),
|
|
13
|
-
});
|
|
14
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { json, rgb, toRecord } from '~/parsing/index.js';
|
|
2
|
-
import type { RGB } from '~/colors/index.js';
|
|
3
|
-
|
|
4
|
-
export interface ThemeChangedPayload {
|
|
5
|
-
/**
|
|
6
|
-
* Map where the key is a theme stylesheet key and value is the corresponding color in
|
|
7
|
-
* `#RRGGBB` format.
|
|
8
|
-
*/
|
|
9
|
-
theme_params: {
|
|
10
|
-
/**
|
|
11
|
-
* @since v6.10
|
|
12
|
-
*/
|
|
13
|
-
accent_text_color?: RGB;
|
|
14
|
-
bg_color?: RGB;
|
|
15
|
-
button_color?: RGB;
|
|
16
|
-
button_text_color?: RGB;
|
|
17
|
-
/**
|
|
18
|
-
* @since v6.10
|
|
19
|
-
*/
|
|
20
|
-
destructive_text_color?: RGB;
|
|
21
|
-
/**
|
|
22
|
-
* @since v6.10
|
|
23
|
-
*/
|
|
24
|
-
header_bg_color?: RGB;
|
|
25
|
-
hint_color?: RGB;
|
|
26
|
-
link_color?: RGB;
|
|
27
|
-
secondary_bg_color?: RGB;
|
|
28
|
-
/**
|
|
29
|
-
* @since v6.10
|
|
30
|
-
*/
|
|
31
|
-
section_bg_color?: RGB;
|
|
32
|
-
/**
|
|
33
|
-
* @since v6.10
|
|
34
|
-
*/
|
|
35
|
-
section_header_text_color?: RGB;
|
|
36
|
-
/**
|
|
37
|
-
* @since v6.10
|
|
38
|
-
*/
|
|
39
|
-
subtitle_text_color?: RGB;
|
|
40
|
-
text_color?: RGB;
|
|
41
|
-
[key: string]: RGB | undefined; // Future unknown palette keys.
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function themeChanged() {
|
|
46
|
-
return json<ThemeChangedPayload>({
|
|
47
|
-
theme_params: (value) => {
|
|
48
|
-
const parser = rgb().optional();
|
|
49
|
-
|
|
50
|
-
return Object
|
|
51
|
-
.entries(toRecord(value))
|
|
52
|
-
.reduce<Partial<Record<string, RGB>>>((acc, [k, v]) => {
|
|
53
|
-
acc[k] = parser.parse(v);
|
|
54
|
-
return acc;
|
|
55
|
-
}, {});
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
}
|