@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
package/src/index.ts
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
BackButton,
|
|
3
|
-
type BackButtonEventName,
|
|
4
|
-
type BackButtonEventListener,
|
|
5
|
-
} from './back-button/index.js';
|
|
6
|
-
export {
|
|
7
|
-
createPostEvent,
|
|
8
|
-
isIframe,
|
|
9
|
-
invokeCustomMethod,
|
|
10
|
-
on,
|
|
11
|
-
off,
|
|
12
|
-
once,
|
|
13
|
-
parseMessage,
|
|
14
|
-
postEvent,
|
|
15
|
-
request,
|
|
16
|
-
subscribe,
|
|
17
|
-
unsubscribe,
|
|
18
|
-
MethodUnsupportedError,
|
|
19
|
-
ParameterUnsupportedError,
|
|
20
|
-
type HeaderColorKey,
|
|
21
|
-
type InvoiceStatus,
|
|
22
|
-
type ImpactHapticFeedbackStyle,
|
|
23
|
-
type MiniAppsMethodName,
|
|
24
|
-
type MiniAppsEventName,
|
|
25
|
-
type MiniAppsEventParams,
|
|
26
|
-
type MiniAppsEventListener,
|
|
27
|
-
type MiniAppsGlobalEventListener,
|
|
28
|
-
type MiniAppsEmptyMethodName,
|
|
29
|
-
type MiniAppsMethodAcceptParams,
|
|
30
|
-
type MiniAppsMethodParams,
|
|
31
|
-
type MiniAppsNonEmptyMethodName,
|
|
32
|
-
type MiniAppsMethods,
|
|
33
|
-
type MiniAppsEventEmitter,
|
|
34
|
-
type MiniAppsEventHasParams,
|
|
35
|
-
type MiniAppsEvents,
|
|
36
|
-
type NotificationHapticFeedbackType,
|
|
37
|
-
type PhoneRequestedStatus,
|
|
38
|
-
type PostEvent,
|
|
39
|
-
type RequestOptions,
|
|
40
|
-
type RequestOptionsAdvanced,
|
|
41
|
-
type SwitchInlineQueryChatType,
|
|
42
|
-
type WriteAccessRequestedStatus,
|
|
43
|
-
} from './bridge/index.js';
|
|
44
|
-
export { classNames, mergeClassNames } from './classnames/index.js';
|
|
45
|
-
export {
|
|
46
|
-
ClosingBehavior,
|
|
47
|
-
type ClosingBehaviorEventListener,
|
|
48
|
-
type ClosingBehaviorEventName,
|
|
49
|
-
type ClosingBehaviorEvents,
|
|
50
|
-
} from './closing-behavior/index.js';
|
|
51
|
-
export { CloudStorage } from './cloud-storage/index.js';
|
|
52
|
-
export {
|
|
53
|
-
isRGB,
|
|
54
|
-
isRGBShort,
|
|
55
|
-
isColorDark,
|
|
56
|
-
toRGB,
|
|
57
|
-
type RGB,
|
|
58
|
-
type RGBShort,
|
|
59
|
-
} from './colors/index.js';
|
|
60
|
-
export {
|
|
61
|
-
setCSSVar,
|
|
62
|
-
bindMiniAppCSSVars,
|
|
63
|
-
bindThemeCSSVars,
|
|
64
|
-
bindViewportCSSVars,
|
|
65
|
-
} from './css/index.js';
|
|
66
|
-
export { HapticFeedback } from './haptic-feedback/index.js';
|
|
67
|
-
export {
|
|
68
|
-
init,
|
|
69
|
-
type InitOptions,
|
|
70
|
-
type InitResult,
|
|
71
|
-
} from './init/index.js';
|
|
72
|
-
export {
|
|
73
|
-
chatParser,
|
|
74
|
-
InitData,
|
|
75
|
-
initDataParser,
|
|
76
|
-
parseInitData,
|
|
77
|
-
userParser,
|
|
78
|
-
type Chat,
|
|
79
|
-
type ChatType,
|
|
80
|
-
type InitDataParsed,
|
|
81
|
-
type User,
|
|
82
|
-
} from './init-data/index.js';
|
|
83
|
-
export {
|
|
84
|
-
Invoice,
|
|
85
|
-
type InvoiceEvents,
|
|
86
|
-
type InvoiceEventListener,
|
|
87
|
-
type InvoiceEventName,
|
|
88
|
-
} from './invoice/index.js';
|
|
89
|
-
export {
|
|
90
|
-
launchParamsParser,
|
|
91
|
-
parseLaunchParams,
|
|
92
|
-
retrieveLaunchData,
|
|
93
|
-
serializeLaunchParams,
|
|
94
|
-
type LaunchParams,
|
|
95
|
-
type LaunchData,
|
|
96
|
-
} from './launch-params/index.js';
|
|
97
|
-
export {
|
|
98
|
-
MainButton,
|
|
99
|
-
type MainButtonParams,
|
|
100
|
-
type MainButtonProps,
|
|
101
|
-
type MainButtonEvents,
|
|
102
|
-
type MainButtonEventName,
|
|
103
|
-
type MainButtonEventListener,
|
|
104
|
-
} from './main-button/index.js';
|
|
105
|
-
export {
|
|
106
|
-
MiniApp,
|
|
107
|
-
type MiniAppHeaderColor,
|
|
108
|
-
type MiniAppEventName,
|
|
109
|
-
type MiniAppEventListener,
|
|
110
|
-
type MiniAppEvents,
|
|
111
|
-
type MiniAppProps,
|
|
112
|
-
} from './mini-app/index.js';
|
|
113
|
-
export { isTMA, isRecord } from './misc/index.js';
|
|
114
|
-
export {
|
|
115
|
-
getHash,
|
|
116
|
-
HashNavigator,
|
|
117
|
-
Navigator,
|
|
118
|
-
type NavigationEntry,
|
|
119
|
-
type NavigatorConEntry,
|
|
120
|
-
type NavigatorOptions,
|
|
121
|
-
type HashNavigatorOptions,
|
|
122
|
-
type HashNavigatorEventsMap,
|
|
123
|
-
type HashNavigatorEventListener,
|
|
124
|
-
type HashNavigatorEventName,
|
|
125
|
-
} from './navigation/index.js';
|
|
126
|
-
export {
|
|
127
|
-
boolean,
|
|
128
|
-
searchParams,
|
|
129
|
-
string,
|
|
130
|
-
rgb,
|
|
131
|
-
array,
|
|
132
|
-
date,
|
|
133
|
-
json,
|
|
134
|
-
number,
|
|
135
|
-
ParseError,
|
|
136
|
-
ParseSchemaFieldError,
|
|
137
|
-
} from './parsing/index.js';
|
|
138
|
-
export {
|
|
139
|
-
Popup,
|
|
140
|
-
type PopupEventName,
|
|
141
|
-
type PopupEventListener,
|
|
142
|
-
type PopupEvents,
|
|
143
|
-
type OpenPopupOptions,
|
|
144
|
-
type OpenPopupOptionsButton,
|
|
145
|
-
} from './popup/index.js';
|
|
146
|
-
export {
|
|
147
|
-
QRScanner,
|
|
148
|
-
type QRScannerEventListener,
|
|
149
|
-
type QRScannerEventName,
|
|
150
|
-
type QRScannerEvents,
|
|
151
|
-
} from './qr-scanner/index.js';
|
|
152
|
-
export {
|
|
153
|
-
SettingsButton,
|
|
154
|
-
type SettingsButtonEventName,
|
|
155
|
-
type SettingsButtonEventListener,
|
|
156
|
-
type SettingsButtonEvents,
|
|
157
|
-
} from './settings-button/index.js';
|
|
158
|
-
export { supports } from './supports/index.js';
|
|
159
|
-
export {
|
|
160
|
-
parseThemeParams,
|
|
161
|
-
requestThemeParams,
|
|
162
|
-
serializeThemeParams,
|
|
163
|
-
themeParamsParser,
|
|
164
|
-
ThemeParams,
|
|
165
|
-
type ThemeParamsEventListener,
|
|
166
|
-
type ThemeParamsEventName,
|
|
167
|
-
type ThemeParamsEvents,
|
|
168
|
-
type ThemeParamsKey,
|
|
169
|
-
type ThemeParamsParsed,
|
|
170
|
-
} from './theme-params/index.js';
|
|
171
|
-
export { withTimeout, TimeoutError, isTimeoutError } from './timeout/index.js';
|
|
172
|
-
export type { RequestId, CreateRequestIdFunc } from './types/index.js';
|
|
173
|
-
export { Utils } from './utils/index.js';
|
|
174
|
-
export { compareVersions, type Version } from './version/index.js';
|
|
175
|
-
export {
|
|
176
|
-
isStableViewportPlatform,
|
|
177
|
-
requestViewport,
|
|
178
|
-
Viewport,
|
|
179
|
-
type RequestViewportResult,
|
|
180
|
-
type ViewportProps,
|
|
181
|
-
type ViewportEventName,
|
|
182
|
-
type ViewportEventListener,
|
|
183
|
-
type ViewportEvents,
|
|
184
|
-
} from './viewport/index.js';
|
|
185
|
-
export { setTargetOrigin, setDebug } from './globals.js';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { on } from '~/bridge/index.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Creates style html element which contains styles sent from the Telegram application.
|
|
5
|
-
*/
|
|
6
|
-
export function catchCustomStyles(): void {
|
|
7
|
-
const element = document.createElement('style');
|
|
8
|
-
element.id = 'telegram-custom-styles';
|
|
9
|
-
document.head.appendChild(element);
|
|
10
|
-
|
|
11
|
-
on('set_custom_style', (html) => {
|
|
12
|
-
// It is safe to use innerHTML here as long as style tag has a special behavior related
|
|
13
|
-
// to the specified content. In case, any script will be passed here, it will not be
|
|
14
|
-
// executed.
|
|
15
|
-
element.innerHTML = html;
|
|
16
|
-
});
|
|
17
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { mockSessionStorageGetItem } from 'test-utils';
|
|
2
|
-
import type { SpyInstance } from 'vitest';
|
|
3
|
-
import { afterEach, expect, it, vi } from 'vitest';
|
|
4
|
-
|
|
5
|
-
import { createWindow } from '../../../../test-utils/createWindow';
|
|
6
|
-
import { requestViewport } from '../../../viewport/requestViewport';
|
|
7
|
-
import { createViewport } from '../createViewport';
|
|
8
|
-
|
|
9
|
-
vi.mock('../../../viewport/requestViewport', () => {
|
|
10
|
-
return {
|
|
11
|
-
requestViewport: vi.fn(),
|
|
12
|
-
};
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
type RequestViewport = typeof requestViewport;
|
|
16
|
-
|
|
17
|
-
const requestViewportMock = requestViewport as unknown as SpyInstance<Parameters<RequestViewport>, ReturnType<RequestViewport>>;
|
|
18
|
-
|
|
19
|
-
afterEach(() => {
|
|
20
|
-
vi.restoreAllMocks();
|
|
21
|
-
requestViewportMock.mockReset();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('should create Viewport from the data located in the storage if page was reloaded and storage has viewport data', () => {
|
|
25
|
-
mockSessionStorageGetItem('{"height":992,"isExpanded":false,"stableHeight":992,"width":320}');
|
|
26
|
-
expect(createViewport(true, 'macos', vi.fn(), false)).toMatchObject({
|
|
27
|
-
height: 992,
|
|
28
|
-
isExpanded: false,
|
|
29
|
-
stableHeight: 992,
|
|
30
|
-
width: 320,
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('should return viewport with window data if page was not reloaded or storage is missing required data, and platform has a stable viewport', () => {
|
|
35
|
-
createWindow({ innerHeight: 1000, innerWidth: 2000 });
|
|
36
|
-
expect(createViewport(false, 'macos', vi.fn(), false)).toMatchObject({
|
|
37
|
-
height: 1000,
|
|
38
|
-
isExpanded: true,
|
|
39
|
-
stableHeight: 1000,
|
|
40
|
-
width: 2000,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
expect(createViewport(true, 'macos', vi.fn(), false)).toMatchObject({
|
|
44
|
-
height: 1000,
|
|
45
|
-
isExpanded: true,
|
|
46
|
-
stableHeight: 1000,
|
|
47
|
-
width: 2000,
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('should create Viewport instance from the result of calling requestViewport function if page was not reloaded, platform has no stable viewport and initialization is complete', () => {
|
|
52
|
-
requestViewportMock.mockImplementation(async () => ({
|
|
53
|
-
height: 922,
|
|
54
|
-
isStateStable: false,
|
|
55
|
-
width: 800,
|
|
56
|
-
isExpanded: false,
|
|
57
|
-
}));
|
|
58
|
-
|
|
59
|
-
expect(createViewport(false, 'android', vi.fn(), true)).resolves.toMatchObject({
|
|
60
|
-
height: 922,
|
|
61
|
-
isExpanded: false,
|
|
62
|
-
stableHeight: 0,
|
|
63
|
-
width: 800,
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
requestViewportMock.mockImplementation(async () => ({
|
|
67
|
-
height: 111,
|
|
68
|
-
isStateStable: true,
|
|
69
|
-
width: 222,
|
|
70
|
-
isExpanded: true,
|
|
71
|
-
}));
|
|
72
|
-
|
|
73
|
-
expect(createViewport(false, 'android', vi.fn(), true)).resolves.toMatchObject({
|
|
74
|
-
height: 111,
|
|
75
|
-
isExpanded: true,
|
|
76
|
-
stableHeight: 111,
|
|
77
|
-
width: 222,
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('should return viewport with zeroes if page was reloaded, storage doesnt contain data, platform has no stable viewport and initialization is not complete', () => {
|
|
82
|
-
requestViewportMock.mockImplementation(async () => ({
|
|
83
|
-
height: 922,
|
|
84
|
-
isStateStable: false,
|
|
85
|
-
width: 800,
|
|
86
|
-
isExpanded: false,
|
|
87
|
-
}));
|
|
88
|
-
|
|
89
|
-
mockSessionStorageGetItem(null);
|
|
90
|
-
expect(createViewport(true, 'android', vi.fn(), false)).toMatchObject({
|
|
91
|
-
height: 0,
|
|
92
|
-
isExpanded: false,
|
|
93
|
-
stableHeight: 0,
|
|
94
|
-
width: 0,
|
|
95
|
-
});
|
|
96
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { BackButton } from '~/back-button/index.js';
|
|
2
|
-
import { getStorageValue, saveStorageValue } from '~/storage.js';
|
|
3
|
-
import type { PostEvent } from '~/bridge/index.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Creates BackButton instance using last locally saved data also saving each state in
|
|
7
|
-
* the storage.
|
|
8
|
-
* @param isPageReload - was current page reloaded.
|
|
9
|
-
* @param version - platform version.
|
|
10
|
-
* @param postEvent - Bridge postEvent function
|
|
11
|
-
*/
|
|
12
|
-
export function createBackButton(
|
|
13
|
-
isPageReload: boolean,
|
|
14
|
-
version: string,
|
|
15
|
-
postEvent: PostEvent,
|
|
16
|
-
): BackButton {
|
|
17
|
-
const { isVisible = false } = isPageReload ? getStorageValue('back-button') || {} : {};
|
|
18
|
-
const component = new BackButton(isVisible, version, postEvent);
|
|
19
|
-
|
|
20
|
-
component.on('change', () => {
|
|
21
|
-
saveStorageValue('back-button', { isVisible: component.isVisible });
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
return component;
|
|
25
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ClosingBehavior } from '~/closing-behavior/index.js';
|
|
2
|
-
import { getStorageValue, saveStorageValue } from '~/storage.js';
|
|
3
|
-
import type { PostEvent } from '~/bridge/index.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Creates ClosingBehaviour instance using last locally saved data also saving each state in
|
|
7
|
-
* the storage.
|
|
8
|
-
* @param isPageReload - was current page reloaded.
|
|
9
|
-
* @param postEvent - Bridge postEvent function
|
|
10
|
-
*/
|
|
11
|
-
export function createClosingBehavior(
|
|
12
|
-
isPageReload: boolean,
|
|
13
|
-
postEvent: PostEvent,
|
|
14
|
-
): ClosingBehavior {
|
|
15
|
-
const { isConfirmationNeeded = false } = isPageReload ? getStorageValue('closing-behavior') || {} : {};
|
|
16
|
-
|
|
17
|
-
const component = new ClosingBehavior(isConfirmationNeeded, postEvent);
|
|
18
|
-
|
|
19
|
-
component.on('change', () => saveStorageValue('closing-behavior', {
|
|
20
|
-
isConfirmationNeeded: component.isConfirmationNeeded,
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
|
-
return component;
|
|
24
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { MainButton } from '~/main-button/index.js';
|
|
2
|
-
import { getStorageValue, saveStorageValue } from '~/storage.js';
|
|
3
|
-
import type { PostEvent } from '~/bridge/index.js';
|
|
4
|
-
import type { RGB } from '~/colors/index.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Creates MainButton instance using last locally saved data also saving each state in
|
|
8
|
-
* the storage.
|
|
9
|
-
* @param isPageReload - was current page reloaded.
|
|
10
|
-
* @param backgroundColor - background color.
|
|
11
|
-
* @param textColor - text color.
|
|
12
|
-
* @param postEvent - Bridge postEvent function
|
|
13
|
-
*/
|
|
14
|
-
export function createMainButton(
|
|
15
|
-
isPageReload: boolean,
|
|
16
|
-
backgroundColor: RGB,
|
|
17
|
-
textColor: RGB,
|
|
18
|
-
postEvent: PostEvent,
|
|
19
|
-
): MainButton {
|
|
20
|
-
const {
|
|
21
|
-
backgroundColor: stateBackgroundColor = backgroundColor,
|
|
22
|
-
isEnabled = false,
|
|
23
|
-
isVisible = false,
|
|
24
|
-
isLoaderVisible = false,
|
|
25
|
-
textColor: stateTextColor = textColor,
|
|
26
|
-
text = '',
|
|
27
|
-
} = isPageReload ? getStorageValue('main-button') || {} : {};
|
|
28
|
-
|
|
29
|
-
const component = new MainButton({
|
|
30
|
-
backgroundColor: stateBackgroundColor,
|
|
31
|
-
isEnabled,
|
|
32
|
-
isLoaderVisible,
|
|
33
|
-
isVisible,
|
|
34
|
-
postEvent,
|
|
35
|
-
text,
|
|
36
|
-
textColor: stateTextColor,
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const saveState = () => saveStorageValue('main-button', {
|
|
40
|
-
backgroundColor: component.backgroundColor,
|
|
41
|
-
isEnabled: component.isEnabled,
|
|
42
|
-
isLoaderVisible: component.isLoaderVisible,
|
|
43
|
-
isVisible: component.isVisible,
|
|
44
|
-
text: component.text,
|
|
45
|
-
textColor: component.textColor,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
component.on('change', saveState);
|
|
49
|
-
|
|
50
|
-
return component;
|
|
51
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { MiniApp } from '~/mini-app/index.js';
|
|
2
|
-
import { getStorageValue, saveStorageValue } from '~/storage.js';
|
|
3
|
-
import type { PostEvent } from '~/bridge/index.js';
|
|
4
|
-
import type { RGB } from '~/colors/index.js';
|
|
5
|
-
import type { CreateRequestIdFunc } from '~/types/index.js';
|
|
6
|
-
import type { Version } from '~/version/index.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Creates MiniApp instance using last locally saved data also saving each state in
|
|
10
|
-
* the storage.
|
|
11
|
-
* @param isPageReload - was current page reloaded.
|
|
12
|
-
* @param backgroundColor - web app background color.
|
|
13
|
-
* @param version - platform version.
|
|
14
|
-
* @param botInline - is Mini App launched in inline mode.
|
|
15
|
-
* @param createRequestId - function which generates request identifiers.
|
|
16
|
-
* @param postEvent - Bridge postEvent function
|
|
17
|
-
*/
|
|
18
|
-
export function createMiniApp(
|
|
19
|
-
isPageReload: boolean,
|
|
20
|
-
backgroundColor: RGB,
|
|
21
|
-
version: Version,
|
|
22
|
-
botInline: boolean,
|
|
23
|
-
createRequestId: CreateRequestIdFunc,
|
|
24
|
-
postEvent: PostEvent,
|
|
25
|
-
): MiniApp {
|
|
26
|
-
const {
|
|
27
|
-
backgroundColor: stateBackgroundColor = backgroundColor,
|
|
28
|
-
headerColor = 'bg_color',
|
|
29
|
-
} = isPageReload ? getStorageValue('mini-app') || {} : {};
|
|
30
|
-
|
|
31
|
-
const component = new MiniApp({
|
|
32
|
-
headerColor,
|
|
33
|
-
backgroundColor: stateBackgroundColor,
|
|
34
|
-
version,
|
|
35
|
-
botInline,
|
|
36
|
-
createRequestId,
|
|
37
|
-
postEvent,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const saveState = () => saveStorageValue('mini-app', {
|
|
41
|
-
backgroundColor: component.backgroundColor,
|
|
42
|
-
headerColor: component.headerColor,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
component.on('change', saveState);
|
|
46
|
-
|
|
47
|
-
return component;
|
|
48
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { CreateRequestIdFunc } from '~/types/index.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Creates function which generated request identifiers.
|
|
5
|
-
*/
|
|
6
|
-
export function createRequestIdGenerator(): CreateRequestIdFunc {
|
|
7
|
-
let requestId = 0;
|
|
8
|
-
|
|
9
|
-
return () => {
|
|
10
|
-
requestId += 1;
|
|
11
|
-
return requestId.toString();
|
|
12
|
-
};
|
|
13
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { SettingsButton } from '~/settings-button/index.js';
|
|
2
|
-
import { getStorageValue, saveStorageValue } from '~/storage.js';
|
|
3
|
-
import type { PostEvent } from '~/bridge/index.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Creates SettingsButton instance using last locally saved data also saving each state in
|
|
7
|
-
* the storage.
|
|
8
|
-
* @param isPageReload - was current page reloaded.
|
|
9
|
-
* @param version - platform version.
|
|
10
|
-
* @param postEvent - Bridge postEvent function
|
|
11
|
-
*/
|
|
12
|
-
export function createSettingsButton(
|
|
13
|
-
isPageReload: boolean,
|
|
14
|
-
version: string,
|
|
15
|
-
postEvent: PostEvent,
|
|
16
|
-
): SettingsButton {
|
|
17
|
-
const { isVisible = false } = isPageReload ? getStorageValue('settings-button') || {} : {};
|
|
18
|
-
const component = new SettingsButton(isVisible, version, postEvent);
|
|
19
|
-
|
|
20
|
-
component.on('change', () => {
|
|
21
|
-
saveStorageValue('settings-button', { isVisible: component.isVisible });
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
return component;
|
|
25
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ThemeParams, type ThemeParamsParsed } from '~/theme-params/index.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Creates synced instance of ThemeParams.
|
|
5
|
-
* @param params - theme parameters.
|
|
6
|
-
*/
|
|
7
|
-
export function createThemeParams(params: ThemeParamsParsed): ThemeParams {
|
|
8
|
-
const themeParams = new ThemeParams(params);
|
|
9
|
-
themeParams.listen();
|
|
10
|
-
return themeParams;
|
|
11
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { getStorageValue, saveStorageValue } from '~/storage.js';
|
|
2
|
-
import {
|
|
3
|
-
isStableViewportPlatform,
|
|
4
|
-
requestViewport,
|
|
5
|
-
Viewport,
|
|
6
|
-
type ViewportProps,
|
|
7
|
-
} from '~/viewport/index.js';
|
|
8
|
-
import type { PostEvent } from '~/bridge/index.js';
|
|
9
|
-
import type { Platform } from '~/types/index.js';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Creates new bound instance of the Viewport component.
|
|
13
|
-
* @param props - properties to create new instance.
|
|
14
|
-
*/
|
|
15
|
-
function instantiate(props: ViewportProps): Viewport {
|
|
16
|
-
const viewport = new Viewport(props);
|
|
17
|
-
|
|
18
|
-
// TODO: Should probably use throttle for height.
|
|
19
|
-
viewport.on('change', () => saveStorageValue('viewport', {
|
|
20
|
-
height: viewport.height,
|
|
21
|
-
isExpanded: viewport.isExpanded,
|
|
22
|
-
stableHeight: viewport.stableHeight,
|
|
23
|
-
width: viewport.width,
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
viewport.listen();
|
|
27
|
-
|
|
28
|
-
return viewport;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Creates Viewport instance using its actual state from the Telegram application.
|
|
33
|
-
* @param isPageReload - was page reloaded.
|
|
34
|
-
* @param platform - platform identifier.
|
|
35
|
-
* @param postEvent - Bridge postEvent function.
|
|
36
|
-
* @param complete - is initialization complete.
|
|
37
|
-
*/
|
|
38
|
-
export function createViewport(
|
|
39
|
-
isPageReload: boolean,
|
|
40
|
-
platform: Platform,
|
|
41
|
-
postEvent: PostEvent,
|
|
42
|
-
complete: boolean,
|
|
43
|
-
): Viewport | Promise<Viewport> {
|
|
44
|
-
// If page was reloaded, we expect viewport to be restored from the storage.
|
|
45
|
-
const state = isPageReload ? getStorageValue('viewport') : null;
|
|
46
|
-
if (state) {
|
|
47
|
-
return instantiate({ ...state, postEvent });
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// If platform has a stable viewport, it means we could instantiate Viewport using
|
|
51
|
-
// the window global object properties.
|
|
52
|
-
if (isStableViewportPlatform(platform)) {
|
|
53
|
-
return instantiate({
|
|
54
|
-
height: window.innerHeight,
|
|
55
|
-
isExpanded: true,
|
|
56
|
-
postEvent,
|
|
57
|
-
stableHeight: window.innerHeight,
|
|
58
|
-
width: window.innerWidth,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// If initialization is complete, we have to create Viewport instance using its actual
|
|
63
|
-
// state from the Telegram application.
|
|
64
|
-
if (complete) {
|
|
65
|
-
return requestViewport({
|
|
66
|
-
postEvent,
|
|
67
|
-
timeout: 5000,
|
|
68
|
-
})
|
|
69
|
-
.then(({ height, isStateStable, ...rest }) => instantiate({
|
|
70
|
-
...rest,
|
|
71
|
-
height,
|
|
72
|
-
stableHeight: isStateStable ? height : 0,
|
|
73
|
-
}));
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Otherwise we have no sources to get viewport properties from. In this case we just
|
|
77
|
-
// return some "empty" Viewport instance and synchronize it in the background.
|
|
78
|
-
const viewport = instantiate({
|
|
79
|
-
width: 0,
|
|
80
|
-
height: 0,
|
|
81
|
-
isExpanded: false,
|
|
82
|
-
postEvent,
|
|
83
|
-
stableHeight: 0,
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
/* c8 ignore start */
|
|
87
|
-
viewport.sync({ postEvent, timeout: 5000 }).catch((e) => {
|
|
88
|
-
// eslint-disable-next-line no-console
|
|
89
|
-
console.error('Unable to actualize viewport state', e);
|
|
90
|
-
});
|
|
91
|
-
/* c8 ignore stop */
|
|
92
|
-
|
|
93
|
-
return viewport;
|
|
94
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from './createBackButton.js';
|
|
2
|
-
export * from './createClosingBehavior.js';
|
|
3
|
-
export * from './createMainButton.js';
|
|
4
|
-
export * from './createMiniApp.js';
|
|
5
|
-
export * from './createRequestIdGenerator.js';
|
|
6
|
-
export * from './createSettingsButton.js';
|
|
7
|
-
export * from './createThemeParams.js';
|
|
8
|
-
export * from './createViewport.js';
|
package/src/init/css/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './processCSSVarsOption.js';
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { bindMiniAppCSSVars, bindThemeCSSVars, bindViewportCSSVars } from '~/css/index.js';
|
|
2
|
-
import type { MiniApp } from '~/mini-app/index.js';
|
|
3
|
-
import type { ThemeParams } from '~/theme-params/index.js';
|
|
4
|
-
import type { Viewport } from '~/viewport/index.js';
|
|
5
|
-
|
|
6
|
-
import type { InitCSSVarsOption, InitCSSVarsSpecificOption } from '../types.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Converts init cssVars option to more narrow type.
|
|
10
|
-
* @param option - option value.
|
|
11
|
-
*/
|
|
12
|
-
function parseCSSVarsOptions(option: InitCSSVarsOption): InitCSSVarsSpecificOption {
|
|
13
|
-
if (typeof option === 'object') {
|
|
14
|
-
return option;
|
|
15
|
-
}
|
|
16
|
-
return option
|
|
17
|
-
? {
|
|
18
|
-
themeParams: true,
|
|
19
|
-
viewport: true,
|
|
20
|
-
miniApp: true,
|
|
21
|
-
}
|
|
22
|
-
: {};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Process initialization CSS vars option.
|
|
27
|
-
* @param option - option value.
|
|
28
|
-
* @param miniApp - MiniApp instance.
|
|
29
|
-
* @param themeParams - ThemeParams instance.
|
|
30
|
-
* @param viewportOrPromise - Viewport instance or promise resolving it.
|
|
31
|
-
*/
|
|
32
|
-
export function processCSSVars(
|
|
33
|
-
option: InitCSSVarsOption,
|
|
34
|
-
miniApp: MiniApp,
|
|
35
|
-
themeParams: ThemeParams,
|
|
36
|
-
viewportOrPromise: Viewport | Promise<Viewport>,
|
|
37
|
-
): void {
|
|
38
|
-
const cssVarsOptions = parseCSSVarsOptions(option);
|
|
39
|
-
|
|
40
|
-
if (cssVarsOptions.miniApp) {
|
|
41
|
-
bindMiniAppCSSVars(miniApp, themeParams);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (cssVarsOptions.themeParams) {
|
|
45
|
-
bindThemeCSSVars(themeParams);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (cssVarsOptions.viewport) {
|
|
49
|
-
if (viewportOrPromise instanceof Promise) {
|
|
50
|
-
viewportOrPromise.then(bindViewportCSSVars);
|
|
51
|
-
} else {
|
|
52
|
-
bindViewportCSSVars(viewportOrPromise);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
package/src/init/index.ts
DELETED