@tma.js/sdk 0.13.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dts/{components/BackButton → back-button}/BackButton.d.ts +12 -9
- package/dist/dts/back-button/index.d.ts +2 -0
- package/dist/dts/{components/BackButton → back-button}/types.d.ts +3 -2
- package/dist/dts/bridge/env/hasExternalNotify.d.ts +12 -0
- package/dist/dts/bridge/env/hasWebviewProxy.d.ts +12 -0
- package/dist/dts/bridge/env/index.d.ts +3 -0
- package/dist/dts/bridge/env/isIframe.d.ts +5 -0
- package/dist/dts/bridge/errors/MethodUnsupportedError.d.ts +8 -0
- package/dist/dts/bridge/errors/ParameterUnsupportedError.d.ts +8 -0
- package/dist/dts/bridge/errors/index.d.ts +2 -0
- package/dist/dts/bridge/events/createEmitter.d.ts +6 -0
- package/dist/dts/bridge/events/events.d.ts +130 -0
- package/dist/dts/bridge/events/index.d.ts +9 -0
- package/dist/dts/bridge/events/off.d.ts +7 -0
- package/dist/dts/bridge/events/on.d.ts +10 -0
- package/dist/dts/bridge/events/onTelegramEvent.d.ts +7 -0
- package/dist/dts/bridge/events/once.d.ts +9 -0
- package/dist/dts/bridge/events/parsers/clipboardTextReceived.d.ts +13 -0
- package/dist/dts/bridge/events/parsers/customMethodInvoked.d.ts +16 -0
- package/dist/dts/bridge/events/parsers/index.d.ts +9 -0
- package/dist/dts/bridge/events/parsers/invoiceClosed.d.ts +12 -0
- package/dist/dts/bridge/events/parsers/phoneRequested.d.ts +8 -0
- package/dist/dts/bridge/events/parsers/popupClosed.d.ts +8 -0
- package/dist/dts/bridge/events/parsers/qrTextReceived.d.ts +7 -0
- package/dist/dts/bridge/events/parsers/theme-changed.d.ts +42 -0
- package/dist/dts/bridge/events/parsers/viewportChanged.d.ts +19 -0
- package/dist/dts/bridge/events/parsers/writeAccessRequested.d.ts +8 -0
- package/dist/dts/bridge/events/singletonEmitter.d.ts +6 -0
- package/dist/dts/bridge/events/subscribe.d.ts +9 -0
- package/dist/dts/bridge/events/unsubscribe.d.ts +6 -0
- package/dist/dts/bridge/index.d.ts +5 -0
- package/dist/dts/bridge/methods/createPostEvent.d.ts +10 -0
- package/dist/dts/bridge/methods/haptic.d.ts +40 -0
- package/dist/dts/bridge/methods/index.d.ts +6 -0
- package/dist/dts/bridge/methods/invoke-custom-method.d.ts +24 -0
- package/dist/dts/bridge/methods/methods.d.ts +329 -0
- package/dist/dts/bridge/methods/popup.d.ts +49 -0
- package/dist/dts/bridge/methods/postEvent.d.ts +29 -0
- package/dist/dts/bridge/request.d.ts +65 -0
- package/dist/dts/classnames/classNames.d.ts +10 -0
- package/dist/dts/classnames/index.d.ts +2 -0
- package/dist/dts/classnames/mergeClassNames.d.ts +32 -0
- package/dist/dts/{components/ClosingBehaviour/ClosingBehaviour.d.ts → closing-behavior/ClosingBehavior.d.ts} +5 -4
- package/dist/dts/closing-behavior/index.d.ts +2 -0
- package/dist/dts/closing-behavior/types.d.ts +7 -0
- package/dist/dts/{components/CloudStorage → cloud-storage}/CloudStorage.d.ts +19 -11
- package/dist/dts/colors/index.d.ts +5 -0
- package/dist/dts/colors/isColorDark.d.ts +6 -0
- package/dist/dts/colors/isRGB.d.ts +6 -0
- package/dist/dts/colors/isRGBShort.d.ts +6 -0
- package/dist/dts/colors/toRGB.d.ts +11 -0
- package/dist/dts/colors/types.d.ts +8 -0
- package/dist/dts/event-emitter/EventEmitter.d.ts +64 -0
- package/dist/dts/event-emitter/index.d.ts +2 -0
- package/dist/dts/event-emitter/types.d.ts +44 -0
- package/dist/dts/globals.d.ts +22 -0
- package/dist/dts/{components/HapticFeedback → haptic-feedback}/HapticFeedback.d.ts +3 -3
- package/dist/dts/index.d.ts +24 -6
- package/dist/dts/init/catchCustomStyles.d.ts +4 -0
- package/dist/dts/init/creators/createBackButton.d.ts +2 -2
- package/dist/dts/init/creators/createClosingBehavior.d.ts +3 -3
- package/dist/dts/init/creators/createMainButton.d.ts +3 -3
- package/dist/dts/init/creators/createMiniApp.d.ts +14 -0
- package/dist/dts/init/creators/createRequestIdGenerator.d.ts +1 -1
- package/dist/dts/init/creators/createThemeParams.d.ts +2 -3
- package/dist/dts/init/creators/createViewport.d.ts +16 -9
- package/dist/dts/init/creators/index.d.ts +1 -1
- package/dist/dts/init/css/bindMiniAppCSSVars.d.ts +16 -0
- package/dist/dts/init/css/bindThemeCSSVars.d.ts +12 -0
- package/dist/dts/init/css/bindViewportCSSVars.d.ts +20 -0
- package/dist/dts/init/css/index.d.ts +1 -0
- package/dist/dts/init/css/processCSSVarsOption.d.ts +12 -0
- package/dist/dts/init/css/setCSSVar.d.ts +6 -0
- package/dist/dts/init/init.d.ts +5 -5
- package/dist/dts/init/types.d.ts +42 -69
- package/dist/dts/init-data/InitData.d.ts +53 -0
- package/dist/dts/init-data/chatParser.d.ts +5 -0
- package/dist/dts/init-data/index.d.ts +6 -0
- package/dist/dts/init-data/initDataParser.d.ts +5 -0
- package/dist/dts/init-data/parseInitData.d.ts +6 -0
- package/dist/dts/init-data/types.d.ts +133 -0
- package/dist/dts/init-data/userParser.d.ts +5 -0
- package/dist/dts/invoice/Invoice.d.ts +43 -0
- package/dist/dts/invoice/index.d.ts +2 -0
- package/dist/dts/invoice/types.d.ts +7 -0
- package/dist/dts/launch-params/computeLaunchData.d.ts +6 -0
- package/dist/dts/launch-params/computePageReload.d.ts +6 -0
- package/dist/dts/launch-params/getFirstNavigationEntry.d.ts +6 -0
- package/dist/dts/launch-params/index.d.ts +12 -0
- package/dist/dts/launch-params/launchParamsParser.d.ts +5 -0
- package/dist/dts/launch-params/parseLaunchParams.d.ts +6 -0
- package/dist/dts/launch-params/retrieveCurrent.d.ts +5 -0
- package/dist/dts/launch-params/retrieveFromLocation.d.ts +6 -0
- package/dist/dts/launch-params/retrieveFromPerformance.d.ts +8 -0
- package/dist/dts/launch-params/retrieveLaunchData.d.ts +6 -0
- package/dist/dts/launch-params/serializeLaunchParams.d.ts +6 -0
- package/dist/dts/launch-params/storage.d.ts +13 -0
- package/dist/dts/launch-params/types.d.ts +48 -0
- package/dist/dts/logger/Logger.d.ts +38 -0
- package/dist/dts/logger/index.d.ts +1 -0
- package/dist/dts/main-button/MainButton.d.ts +104 -0
- package/dist/dts/main-button/index.d.ts +2 -0
- package/dist/dts/main-button/types.d.ts +20 -0
- package/dist/dts/mini-app/MiniApp.d.ts +99 -0
- package/dist/dts/mini-app/index.d.ts +2 -0
- package/dist/dts/mini-app/types.d.ts +19 -0
- package/dist/dts/misc/index.d.ts +2 -0
- package/dist/dts/misc/isRecord.d.ts +5 -0
- package/dist/dts/misc/isTMA.d.ts +4 -0
- package/dist/dts/navigation/HashNavigator/HashNavigator.d.ts +43 -0
- package/dist/dts/navigation/HashNavigator/drop.d.ts +4 -0
- package/dist/dts/navigation/HashNavigator/go.d.ts +5 -0
- package/dist/dts/navigation/HashNavigator/index.d.ts +2 -0
- package/dist/dts/navigation/HashNavigator/types.d.ts +34 -0
- package/dist/dts/navigation/Navigator/Navigator.d.ts +104 -0
- package/dist/dts/navigation/Navigator/index.d.ts +2 -0
- package/dist/dts/navigation/Navigator/types.d.ts +44 -0
- package/dist/dts/navigation/ensurePrefix.d.ts +7 -0
- package/dist/dts/navigation/getHash.d.ts +14 -0
- package/dist/dts/navigation/index.d.ts +4 -0
- package/dist/dts/parsing/ArrayValueParser.d.ts +18 -0
- package/dist/dts/parsing/ParseError.d.ts +22 -0
- package/dist/dts/parsing/ParseSchemaFieldError.d.ts +17 -0
- package/dist/dts/parsing/ValueParser.d.ts +36 -0
- package/dist/dts/parsing/createValueParserGenerator.d.ts +9 -0
- package/dist/dts/parsing/index.d.ts +10 -0
- package/dist/dts/parsing/parseBySchema.d.ts +8 -0
- package/dist/dts/parsing/parsers/array.d.ts +6 -0
- package/dist/dts/parsing/parsers/boolean.d.ts +4 -0
- package/dist/dts/parsing/parsers/date.d.ts +4 -0
- package/dist/dts/parsing/parsers/index.d.ts +8 -0
- package/dist/dts/parsing/parsers/json.d.ts +8 -0
- package/dist/dts/parsing/parsers/number.d.ts +4 -0
- package/dist/dts/parsing/parsers/rgb.d.ts +4 -0
- package/dist/dts/parsing/parsers/searchParams.d.ts +8 -0
- package/dist/dts/parsing/parsers/string.d.ts +4 -0
- package/dist/dts/parsing/toRecord.d.ts +7 -0
- package/dist/dts/parsing/types.d.ts +30 -0
- package/dist/dts/parsing/unexpectedTypeError.d.ts +4 -0
- package/dist/dts/{components/Popup → popup}/Popup.d.ts +10 -9
- package/dist/dts/popup/index.d.ts +2 -0
- package/dist/dts/popup/preparePopupParams.d.ts +7 -0
- package/dist/dts/{components/Popup → popup}/types.d.ts +4 -4
- package/dist/dts/{components/QRScanner → qr-scanner}/QRScanner.d.ts +6 -5
- package/dist/dts/qr-scanner/index.d.ts +2 -0
- package/dist/dts/{components/QRScanner → qr-scanner}/types.d.ts +1 -1
- package/dist/dts/state/State.d.ts +19 -7
- package/dist/dts/state/types.d.ts +4 -7
- package/dist/dts/storage.d.ts +4 -4
- package/dist/dts/supports/createSupportsFunc.d.ts +10 -0
- package/dist/dts/supports/createSupportsParamFunc.d.ts +15 -0
- package/dist/dts/supports/index.d.ts +4 -0
- package/dist/dts/supports/supports.d.ts +15 -0
- package/dist/dts/supports/types.d.ts +1 -0
- package/dist/dts/theme-params/ThemeParams.d.ts +62 -0
- package/dist/dts/theme-params/index.d.ts +6 -0
- package/dist/dts/theme-params/keys.d.ts +11 -0
- package/dist/dts/theme-params/parseThemeParams.d.ts +6 -0
- package/dist/dts/theme-params/requestThemeParams.d.ts +7 -0
- package/dist/dts/theme-params/serializeThemeParams.d.ts +5 -0
- package/dist/dts/theme-params/themeParamsParser.d.ts +2 -0
- package/dist/dts/theme-params/types.d.ts +14 -0
- package/dist/dts/timeout/TimeoutError.d.ts +3 -0
- package/dist/dts/timeout/index.d.ts +3 -0
- package/dist/dts/timeout/isTimeoutError.d.ts +6 -0
- package/dist/dts/timeout/withTimeout.d.ts +14 -0
- package/dist/dts/types/index.d.ts +3 -0
- package/dist/dts/types/platform.d.ts +4 -0
- package/dist/dts/types/request-id.d.ts +9 -0
- package/dist/dts/types/utils.d.ts +36 -0
- package/dist/dts/utils/Utils.d.ts +45 -0
- package/dist/dts/utils/index.d.ts +1 -0
- package/dist/dts/version/compareVersions.d.ts +8 -0
- package/dist/dts/version/index.d.ts +2 -0
- package/dist/dts/version/types.d.ts +4 -0
- package/dist/dts/{components/Viewport → viewport}/Viewport.d.ts +16 -38
- package/dist/dts/viewport/index.d.ts +3 -0
- package/dist/dts/viewport/requestViewport.d.ts +12 -0
- package/dist/dts/{components/Viewport → viewport}/types.d.ts +9 -1
- package/dist/dts/viewport/utils.d.ts +5 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/index.mjs +2245 -1025
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -16
- package/src/{components/BackButton → back-button}/BackButton.ts +23 -21
- package/src/back-button/index.ts +2 -0
- package/src/{components/BackButton → back-button}/types.ts +3 -2
- package/src/bridge/env/hasExternalNotify.ts +19 -0
- package/src/bridge/env/hasWebviewProxy.ts +19 -0
- package/src/bridge/env/index.ts +3 -0
- package/src/bridge/env/isIframe.ts +11 -0
- package/src/bridge/errors/MethodUnsupportedError.ts +13 -0
- package/src/bridge/errors/ParameterUnsupportedError.ts +13 -0
- package/src/bridge/errors/index.ts +2 -0
- package/src/bridge/events/createEmitter.ts +108 -0
- package/src/bridge/events/events.ts +170 -0
- package/src/bridge/events/index.ts +9 -0
- package/src/bridge/events/off.ts +14 -0
- package/src/bridge/events/on.ts +19 -0
- package/src/bridge/events/onTelegramEvent.ts +83 -0
- package/src/bridge/events/once.ts +18 -0
- package/src/bridge/events/parsers/clipboardTextReceived.ts +26 -0
- package/src/bridge/events/parsers/customMethodInvoked.ts +25 -0
- package/src/bridge/events/parsers/index.ts +9 -0
- package/src/bridge/events/parsers/invoiceClosed.ts +26 -0
- package/src/bridge/events/parsers/phoneRequested.ts +14 -0
- package/src/bridge/events/parsers/popupClosed.ts +19 -0
- package/src/bridge/events/parsers/qrTextReceived.ts +14 -0
- package/src/bridge/events/parsers/theme-changed.ts +58 -0
- package/src/bridge/events/parsers/viewportChanged.ts +33 -0
- package/src/bridge/events/parsers/writeAccessRequested.ts +14 -0
- package/src/bridge/events/singletonEmitter.ts +19 -0
- package/src/bridge/events/subscribe.ts +15 -0
- package/src/bridge/events/unsubscribe.ts +10 -0
- package/src/bridge/index.ts +5 -0
- package/src/bridge/methods/createPostEvent.ts +40 -0
- package/src/bridge/methods/haptic.ts +52 -0
- package/src/bridge/methods/index.ts +6 -0
- package/src/bridge/methods/invoke-custom-method.ts +25 -0
- package/src/bridge/methods/methods.ts +372 -0
- package/src/bridge/methods/popup.ts +53 -0
- package/src/bridge/methods/postEvent.ts +101 -0
- package/src/bridge/request.ts +185 -0
- package/src/classnames/classNames.ts +34 -0
- package/src/classnames/index.ts +2 -0
- package/src/classnames/mergeClassNames.ts +68 -0
- package/src/{components/ClosingBehaviour/ClosingBehaviour.ts → closing-behavior/ClosingBehavior.ts} +12 -10
- package/src/closing-behavior/index.ts +2 -0
- package/src/closing-behavior/types.ts +12 -0
- package/src/{components/CloudStorage → cloud-storage}/CloudStorage.ts +50 -28
- package/src/colors/index.ts +5 -0
- package/src/colors/isColorDark.ts +22 -0
- package/src/colors/isRGB.ts +9 -0
- package/src/colors/isRGBShort.ts +9 -0
- package/src/colors/toRGB.ts +49 -0
- package/src/colors/types.ts +9 -0
- package/src/event-emitter/EventEmitter.ts +146 -0
- package/src/event-emitter/index.ts +2 -0
- package/src/event-emitter/types.ts +60 -0
- package/src/globals.ts +38 -0
- package/src/{components/HapticFeedback → haptic-feedback}/HapticFeedback.ts +16 -8
- package/src/index.ts +171 -6
- package/src/init/catchCustomStyles.ts +17 -0
- package/src/init/creators/createBackButton.ts +4 -6
- package/src/init/creators/createClosingBehavior.ts +6 -8
- package/src/init/creators/createMainButton.ts +13 -20
- package/src/init/creators/createMiniApp.ts +44 -0
- package/src/init/creators/createRequestIdGenerator.ts +1 -1
- package/src/init/creators/createThemeParams.ts +3 -6
- package/src/init/creators/createViewport.ts +92 -42
- package/src/init/creators/index.ts +1 -1
- package/src/init/css/bindMiniAppCSSVars.ts +48 -0
- package/src/init/css/bindThemeCSSVars.ts +31 -0
- package/src/init/css/bindViewportCSSVars.ts +36 -0
- package/src/init/css/index.ts +1 -0
- package/src/init/css/processCSSVarsOption.ts +57 -0
- package/src/init/css/setCSSVar.ts +8 -0
- package/src/init/init.ts +96 -138
- package/src/init/types.ts +42 -87
- package/src/init-data/InitData.ts +96 -0
- package/src/init-data/chatParser.ts +19 -0
- package/src/init-data/index.ts +6 -0
- package/src/init-data/initDataParser.ts +41 -0
- package/src/init-data/parseInitData.ts +10 -0
- package/src/init-data/types.ts +164 -0
- package/src/init-data/userParser.ts +45 -0
- package/src/invoice/Invoice.ts +123 -0
- package/src/invoice/index.ts +2 -0
- package/src/invoice/types.ts +11 -0
- package/src/launch-params/computeLaunchData.ts +81 -0
- package/src/launch-params/computePageReload.ts +13 -0
- package/src/launch-params/getFirstNavigationEntry.ts +10 -0
- package/src/launch-params/index.ts +12 -0
- package/src/launch-params/launchParamsParser.ts +41 -0
- package/src/launch-params/parseLaunchParams.ts +10 -0
- package/src/launch-params/retrieveCurrent.ts +27 -0
- package/src/launch-params/retrieveFromLocation.ts +10 -0
- package/src/launch-params/retrieveFromPerformance.ts +23 -0
- package/src/launch-params/retrieveLaunchData.ts +30 -0
- package/src/launch-params/serializeLaunchParams.ts +37 -0
- package/src/launch-params/storage.ts +33 -0
- package/src/launch-params/types.ts +57 -0
- package/src/logger/Logger.ts +72 -0
- package/src/logger/index.ts +1 -0
- package/src/main-button/MainButton.ts +239 -0
- package/src/main-button/index.ts +2 -0
- package/src/main-button/types.ts +26 -0
- package/src/mini-app/MiniApp.ts +237 -0
- package/src/mini-app/index.ts +2 -0
- package/src/mini-app/types.ts +25 -0
- package/src/misc/index.ts +2 -0
- package/src/misc/isRecord.ts +7 -0
- package/src/misc/isTMA.ts +13 -0
- package/src/navigation/HashNavigator/HashNavigator.ts +220 -0
- package/src/navigation/HashNavigator/drop.ts +36 -0
- package/src/navigation/HashNavigator/go.ts +28 -0
- package/src/navigation/HashNavigator/index.ts +2 -0
- package/src/navigation/HashNavigator/types.ts +41 -0
- package/src/navigation/Navigator/Navigator.ts +282 -0
- package/src/navigation/Navigator/index.ts +2 -0
- package/src/navigation/Navigator/types.ts +55 -0
- package/src/navigation/ensurePrefix.ts +9 -0
- package/src/navigation/getHash.ts +17 -0
- package/src/navigation/index.ts +4 -0
- package/src/parsing/ArrayValueParser.ts +79 -0
- package/src/parsing/ParseError.ts +27 -0
- package/src/parsing/ParseSchemaFieldError.ts +21 -0
- package/src/parsing/ValueParser.ts +71 -0
- package/src/parsing/createValueParserGenerator.ts +16 -0
- package/src/parsing/index.ts +10 -0
- package/src/parsing/parseBySchema.ts +65 -0
- package/src/parsing/parsers/array.ts +9 -0
- package/src/parsing/parsers/boolean.ts +22 -0
- package/src/parsing/parsers/date.ts +13 -0
- package/src/parsing/parsers/index.ts +8 -0
- package/src/parsing/parsers/json.ts +17 -0
- package/src/parsing/parsers/number.ts +21 -0
- package/src/parsing/parsers/rgb.ts +12 -0
- package/src/parsing/parsers/searchParams.ts +24 -0
- package/src/parsing/parsers/string.ts +12 -0
- package/src/parsing/toRecord.ts +27 -0
- package/src/parsing/types.ts +32 -0
- package/src/parsing/unexpectedTypeError.ts +6 -0
- package/src/{components/Popup → popup}/Popup.ts +38 -28
- package/src/popup/index.ts +2 -0
- package/src/{components/Popup/utils.ts → popup/preparePopupParams.ts} +3 -3
- package/src/{components/Popup → popup}/types.ts +4 -4
- package/src/{components/QRScanner → qr-scanner}/QRScanner.ts +18 -10
- package/src/qr-scanner/index.ts +2 -0
- package/src/{components/QRScanner → qr-scanner}/types.ts +1 -1
- package/src/state/State.ts +31 -21
- package/src/state/types.ts +5 -8
- package/src/storage.ts +6 -4
- package/src/supports/createSupportsFunc.ts +18 -0
- package/src/supports/createSupportsParamFunc.ts +27 -0
- package/src/supports/index.ts +4 -0
- package/src/supports/supports.ts +84 -0
- package/src/supports/types.ts +1 -0
- package/src/theme-params/ThemeParams.ts +131 -0
- package/src/theme-params/index.ts +6 -0
- package/src/theme-params/keys.ts +24 -0
- package/src/theme-params/parseThemeParams.ts +10 -0
- package/src/theme-params/requestThemeParams.ts +13 -0
- package/src/theme-params/serializeThemeParams.ts +20 -0
- package/src/theme-params/themeParamsParser.ts +20 -0
- package/src/theme-params/types.ts +33 -0
- package/src/timeout/TimeoutError.ts +6 -0
- package/src/timeout/index.ts +3 -0
- package/src/timeout/isTimeoutError.ts +9 -0
- package/src/timeout/withTimeout.ts +36 -0
- package/src/types/index.ts +3 -0
- package/src/types/platform.ts +14 -0
- package/src/types/request-id.ts +10 -0
- package/src/types/utils.ts +50 -0
- package/src/utils/Utils.ts +107 -0
- package/src/utils/index.ts +1 -0
- package/src/version/compareVersions.ts +28 -0
- package/src/version/index.ts +2 -0
- package/src/version/types.ts +4 -0
- package/src/{components/Viewport → viewport}/Viewport.ts +72 -98
- package/src/viewport/index.ts +3 -0
- package/src/viewport/requestViewport.ts +23 -0
- package/src/{components/Viewport → viewport}/types.ts +10 -1
- package/src/viewport/utils.ts +7 -0
- package/dist/dts/components/BackButton/index.d.ts +0 -2
- package/dist/dts/components/ClosingBehaviour/index.d.ts +0 -2
- package/dist/dts/components/ClosingBehaviour/types.d.ts +0 -7
- package/dist/dts/components/InitData/InitData.d.ts +0 -60
- package/dist/dts/components/InitData/index.d.ts +0 -1
- package/dist/dts/components/MainButton/MainButton.d.ts +0 -114
- package/dist/dts/components/MainButton/index.d.ts +0 -2
- package/dist/dts/components/MainButton/types.d.ts +0 -15
- package/dist/dts/components/Popup/index.d.ts +0 -2
- package/dist/dts/components/Popup/utils.d.ts +0 -7
- package/dist/dts/components/QRScanner/index.d.ts +0 -2
- package/dist/dts/components/ThemeParams/ThemeParams.d.ts +0 -85
- package/dist/dts/components/ThemeParams/index.d.ts +0 -2
- package/dist/dts/components/ThemeParams/types.d.ts +0 -6
- package/dist/dts/components/Viewport/index.d.ts +0 -2
- package/dist/dts/components/WebApp/WebApp.d.ts +0 -146
- package/dist/dts/components/WebApp/index.d.ts +0 -2
- package/dist/dts/components/WebApp/types.d.ts +0 -11
- package/dist/dts/components/index.d.ts +0 -11
- package/dist/dts/env.d.ts +0 -10
- package/dist/dts/errors/MethodNotSupportedError.d.ts +0 -6
- package/dist/dts/errors/ParameterNotSupportedError.d.ts +0 -6
- package/dist/dts/errors/index.d.ts +0 -2
- package/dist/dts/init/creators/createWebApp.d.ts +0 -16
- package/dist/dts/init/css.d.ts +0 -50
- package/dist/dts/supports.d.ts +0 -22
- package/dist/dts/types.d.ts +0 -10
- package/dist/dts/url.d.ts +0 -7
- package/src/components/BackButton/index.ts +0 -2
- package/src/components/ClosingBehaviour/index.ts +0 -6
- package/src/components/ClosingBehaviour/types.ts +0 -12
- package/src/components/InitData/InitData.ts +0 -139
- package/src/components/InitData/index.ts +0 -1
- package/src/components/MainButton/MainButton.ts +0 -242
- package/src/components/MainButton/index.ts +0 -2
- package/src/components/MainButton/types.ts +0 -20
- package/src/components/Popup/index.ts +0 -8
- package/src/components/QRScanner/index.ts +0 -2
- package/src/components/ThemeParams/ThemeParams.ts +0 -168
- package/src/components/ThemeParams/index.ts +0 -2
- package/src/components/ThemeParams/types.ts +0 -11
- package/src/components/Viewport/index.ts +0 -2
- package/src/components/WebApp/WebApp.ts +0 -311
- package/src/components/WebApp/index.ts +0 -2
- package/src/components/WebApp/types.ts +0 -17
- package/src/components/index.ts +0 -11
- package/src/env.ts +0 -22
- package/src/errors/MethodNotSupportedError.ts +0 -9
- package/src/errors/ParameterNotSupportedError.ts +0 -9
- package/src/errors/index.ts +0 -2
- package/src/init/creators/createWebApp.ts +0 -52
- package/src/init/css.ts +0 -142
- package/src/supports.ts +0 -44
- package/src/types.ts +0 -13
- package/src/url.ts +0 -23
- /package/dist/dts/{components/CloudStorage → cloud-storage}/index.d.ts +0 -0
- /package/dist/dts/{components/HapticFeedback → haptic-feedback}/index.d.ts +0 -0
- /package/src/{components/CloudStorage → cloud-storage}/index.ts +0 -0
- /package/src/{components/HapticFeedback → haptic-feedback}/index.ts +0 -0
|
@@ -1,16 +1,28 @@
|
|
|
1
|
-
import type { EventEmitter } from '
|
|
1
|
+
import type { EventEmitter } from '../event-emitter/index.js';
|
|
2
|
+
import type { StringKeys } from '../types/index.js';
|
|
2
3
|
import type { StateEvents } from './types.js';
|
|
3
4
|
/**
|
|
4
5
|
* Represents state which is observable via passed EventEmitter.
|
|
5
6
|
*/
|
|
6
7
|
export declare class State<S extends object> {
|
|
7
8
|
private readonly state;
|
|
8
|
-
private readonly ee
|
|
9
|
-
constructor(state: S, ee
|
|
10
|
-
private emit;
|
|
9
|
+
private readonly ee;
|
|
10
|
+
constructor(state: S, ee: Pick<EventEmitter<StateEvents<S>>, 'on' | 'off' | 'emit'>);
|
|
11
11
|
private internalSet;
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Returns copy of current state.
|
|
14
|
+
*/
|
|
15
|
+
clone(): S;
|
|
16
|
+
/**
|
|
17
|
+
* Sets value by key.
|
|
18
|
+
* @param key - state key.
|
|
19
|
+
* @param value - value to set.
|
|
20
|
+
*/
|
|
21
|
+
set<K extends StringKeys<S>>(key: K, value: S[K]): void;
|
|
13
22
|
set(state: Partial<S>): void;
|
|
14
|
-
|
|
15
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Returns value by specified key.
|
|
25
|
+
* @param key - state key.
|
|
26
|
+
*/
|
|
27
|
+
get<K extends StringKeys<S>>(key: K): S[K];
|
|
16
28
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
+
import type { StringKeys } from '../types/index.js';
|
|
1
2
|
/**
|
|
2
3
|
* Computes state property changed event.
|
|
3
4
|
*/
|
|
4
|
-
export type PropChangedEvent<K extends string> =
|
|
5
|
-
/**
|
|
6
|
-
* Returns object string keys.
|
|
7
|
-
*/
|
|
8
|
-
export type StringKeys<T extends object> = Extract<keyof T, string>;
|
|
5
|
+
export type PropChangedEvent<K extends string> = `change:${K}`;
|
|
9
6
|
/**
|
|
10
7
|
* Extracts state property type by its computed change event name.
|
|
11
8
|
*/
|
|
@@ -17,7 +14,7 @@ export type PropertyType<State extends object, Event extends string> = {
|
|
|
17
14
|
* Value is according listener.
|
|
18
15
|
*/
|
|
19
16
|
export type PropChangedEventsMap<State extends object> = {
|
|
20
|
-
[Event in
|
|
17
|
+
[Event in PropChangedEvent<StringKeys<State>>]: (value: PropertyType<State, Event>) => void;
|
|
21
18
|
};
|
|
22
19
|
/**
|
|
23
20
|
* Creates map with all events emitted by state.
|
|
@@ -26,5 +23,5 @@ export type StateEvents<State extends object> = PropChangedEventsMap<State> & {
|
|
|
26
23
|
/**
|
|
27
24
|
* Being called whenever any property was updated.
|
|
28
25
|
*/
|
|
29
|
-
|
|
26
|
+
change: () => void;
|
|
30
27
|
};
|
package/dist/dts/storage.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { HeaderColorKey } from '
|
|
2
|
-
import type { RGB } from '
|
|
1
|
+
import type { HeaderColorKey } from './bridge/index.js';
|
|
2
|
+
import type { RGB } from './colors/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Describes storage keys and according values.
|
|
5
5
|
*/
|
|
@@ -13,8 +13,8 @@ interface StorageParams {
|
|
|
13
13
|
'main-button': {
|
|
14
14
|
backgroundColor: RGB;
|
|
15
15
|
isEnabled: boolean;
|
|
16
|
+
isLoaderVisible: boolean;
|
|
16
17
|
isVisible: boolean;
|
|
17
|
-
isProgressVisible: boolean;
|
|
18
18
|
text: string;
|
|
19
19
|
textColor: RGB;
|
|
20
20
|
};
|
|
@@ -24,7 +24,7 @@ interface StorageParams {
|
|
|
24
24
|
stableHeight: number;
|
|
25
25
|
width: number;
|
|
26
26
|
};
|
|
27
|
-
'
|
|
27
|
+
'mini-app': {
|
|
28
28
|
backgroundColor: RGB;
|
|
29
29
|
headerColor: HeaderColorKey | RGB;
|
|
30
30
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MiniAppsMethodName } from '../bridge/index.js';
|
|
2
|
+
import type { Version } from '../version/index.js';
|
|
3
|
+
import type { SupportsFunc } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Returns function, which accepts predefined method name and checks if it is supported
|
|
6
|
+
* via passed schema and version.
|
|
7
|
+
* @param schema - object which contains methods names and TWA method as a dependency.
|
|
8
|
+
* @param version - platform version.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createSupportsFunc<M extends string>(version: Version, schema: Record<M, MiniAppsMethodName>): SupportsFunc<M>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MiniAppsMethodVersionedParams, MiniAppsMethodWithVersionedParams } from '../bridge/index.js';
|
|
2
|
+
import type { Version } from '../version/index.js';
|
|
3
|
+
import type { SupportsFunc } from './types.js';
|
|
4
|
+
type HasCheckSupportMethodTuple = {
|
|
5
|
+
[M in MiniAppsMethodWithVersionedParams]: [M, MiniAppsMethodVersionedParams<M>];
|
|
6
|
+
}[MiniAppsMethodWithVersionedParams];
|
|
7
|
+
/**
|
|
8
|
+
* Returns function, which accepts predefined method name and checks if it is supported
|
|
9
|
+
* via passed schema and version.
|
|
10
|
+
* @param schema - object which contains methods names and TWA methods with specified parameter
|
|
11
|
+
* as a dependency.
|
|
12
|
+
* @param version - platform version.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createSupportsParamFunc<P extends string>(version: Version, schema: Record<P, HasCheckSupportMethodTuple>): SupportsFunc<P>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Version } from '../version/index.js';
|
|
2
|
+
import type { MiniAppsMethodName, MiniAppsMethodVersionedParams, MiniAppsMethodWithVersionedParams } from '../bridge/methods/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Returns true in case, passed parameter in specified method is supported.
|
|
5
|
+
* @param method - method name
|
|
6
|
+
* @param param - method parameter
|
|
7
|
+
* @param inVersion - platform version.
|
|
8
|
+
*/
|
|
9
|
+
export declare function supports<M extends MiniAppsMethodWithVersionedParams>(method: M, param: MiniAppsMethodVersionedParams<M>, inVersion: Version): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Returns true in case, specified method is supported in passed version.
|
|
12
|
+
* @param method - method name.
|
|
13
|
+
* @param inVersion - platform version.
|
|
14
|
+
*/
|
|
15
|
+
export declare function supports(method: MiniAppsMethodName, inVersion: Version): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type SupportsFunc<M extends string> = (method: M) => boolean;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type RGB } from '../colors/index.js';
|
|
2
|
+
import type { ThemeParamsEvents, ThemeParamsParsed } from './types.js';
|
|
3
|
+
export declare class ThemeParams {
|
|
4
|
+
private readonly ee;
|
|
5
|
+
private readonly state;
|
|
6
|
+
constructor(params: ThemeParamsParsed);
|
|
7
|
+
/**
|
|
8
|
+
* @since v6.10
|
|
9
|
+
*/
|
|
10
|
+
get accentTextColor(): RGB | undefined;
|
|
11
|
+
get backgroundColor(): RGB | undefined;
|
|
12
|
+
get buttonColor(): RGB | undefined;
|
|
13
|
+
get buttonTextColor(): RGB | undefined;
|
|
14
|
+
get destructiveTextColor(): RGB | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves palette color value by its name.
|
|
17
|
+
* @param key - palette key name.
|
|
18
|
+
*/
|
|
19
|
+
get(key: Extract<keyof ThemeParamsParsed, string>): RGB | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the copy of the internal state of the current component instance.
|
|
22
|
+
*/
|
|
23
|
+
getState(): ThemeParamsParsed;
|
|
24
|
+
/**
|
|
25
|
+
* @since v6.10
|
|
26
|
+
*/
|
|
27
|
+
get headerBackgroundColor(): RGB | undefined;
|
|
28
|
+
get hintColor(): RGB | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Returns true in case, current color scheme is recognized as dark. This
|
|
31
|
+
* value is calculated according to theme background color.
|
|
32
|
+
*/
|
|
33
|
+
get isDark(): boolean;
|
|
34
|
+
get linkColor(): RGB | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Adds new event listener.
|
|
37
|
+
*/
|
|
38
|
+
on: <E extends `change:${string}` | "change">(event: E, listener: import('../event-emitter/index.js').EventListener<ThemeParamsEvents[E]>) => import('../event-emitter/index.js').RemoveEventListener;
|
|
39
|
+
/**
|
|
40
|
+
* Removes event listener.
|
|
41
|
+
*/
|
|
42
|
+
off: <E extends `change:${string}` | "change">(event: E, listener: import('../event-emitter/index.js').EventListener<ThemeParamsEvents[E]>) => void;
|
|
43
|
+
get secondaryBackgroundColor(): RGB | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* @since v6.10
|
|
46
|
+
*/
|
|
47
|
+
get sectionBackgroundColor(): RGB | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* @since v6.10
|
|
50
|
+
*/
|
|
51
|
+
get sectionHeaderTextColor(): RGB | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Starts listening to theme changes and applies them.
|
|
54
|
+
* @returns Function to stop listening.
|
|
55
|
+
*/
|
|
56
|
+
listen(): () => void;
|
|
57
|
+
/**
|
|
58
|
+
* @since v6.10
|
|
59
|
+
*/
|
|
60
|
+
get subtitleTextColor(): RGB | undefined;
|
|
61
|
+
get textColor(): RGB | undefined;
|
|
62
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts palette key from Telegram application to representation used by the package.
|
|
3
|
+
* @param key - palette key.
|
|
4
|
+
*/
|
|
5
|
+
export declare function keyToLocal(key: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Converts palette key from local representation to representation sent from the Telegram
|
|
8
|
+
* application.
|
|
9
|
+
* @param key - palette key.
|
|
10
|
+
*/
|
|
11
|
+
export declare function keyToExternal(key: string): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type RequestOptions } from '../bridge/index.js';
|
|
2
|
+
import type { ThemeParamsParsed } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Requests current theme parameters from the Telegram application.
|
|
5
|
+
* @param options - request options.
|
|
6
|
+
*/
|
|
7
|
+
export declare function requestThemeParams(options?: RequestOptions): Promise<ThemeParamsParsed>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RGB } from '../colors/index.js';
|
|
2
|
+
import type { StateEvents } from '../state/index.js';
|
|
3
|
+
export type ThemeParamsKey = 'accentTextColor' | 'backgroundColor' | 'buttonColor' | 'buttonTextColor' | 'destructiveTextColor' | 'headerBackgroundColor' | 'hintColor' | 'linkColor' | 'secondaryBackgroundColor' | 'sectionBackgroundColor' | 'sectionHeaderTextColor' | 'subtitleTextColor' | 'textColor';
|
|
4
|
+
/**
|
|
5
|
+
* Application [theme parameters](https://docs.telegram-mini-apps.com/platform/functionality/theming).
|
|
6
|
+
* Defines palette used by the Telegram application.
|
|
7
|
+
*/
|
|
8
|
+
export interface ThemeParamsParsed {
|
|
9
|
+
[key: ThemeParamsKey | string]: RGB | undefined;
|
|
10
|
+
}
|
|
11
|
+
export type ThemeParamsState = ThemeParamsParsed;
|
|
12
|
+
export type ThemeParamsEvents = StateEvents<ThemeParamsState>;
|
|
13
|
+
export type ThemeParamsEventName = keyof ThemeParamsEvents;
|
|
14
|
+
export type ThemeParamsEventListener<E extends ThemeParamsEventName> = ThemeParamsEvents[E];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type AnyAsyncFunction = (...args: any[]) => Promise<any>;
|
|
2
|
+
/**
|
|
3
|
+
* Rejects specified promise in case, it is processed more than timeout seconds.
|
|
4
|
+
* @param promise - wrapped promise.
|
|
5
|
+
* @param timeout - timeout in milliseconds.
|
|
6
|
+
*/
|
|
7
|
+
export declare function withTimeout<P extends Promise<any>>(promise: P, timeout: number): P;
|
|
8
|
+
/**
|
|
9
|
+
* Wraps async function in function using timeout.
|
|
10
|
+
* @param func - wrapped function.
|
|
11
|
+
* @param timeout - async function timeout.
|
|
12
|
+
*/
|
|
13
|
+
export declare function withTimeout<F extends AnyAsyncFunction>(func: F, timeout: number): F;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request identifier which should be generated locally. Native Telegram application
|
|
3
|
+
* uses it to generate a response to called method.
|
|
4
|
+
*/
|
|
5
|
+
export type RequestId = string;
|
|
6
|
+
/**
|
|
7
|
+
* Function which generates unique request identifiers.
|
|
8
|
+
*/
|
|
9
|
+
export type CreateRequestIdFunc = () => RequestId;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true in case, T is never.
|
|
3
|
+
*/
|
|
4
|
+
export type IsNever<T> = [T] extends [never] ? true : false;
|
|
5
|
+
/**
|
|
6
|
+
* Represents classic "if" condition.
|
|
7
|
+
*/
|
|
8
|
+
export type If<Cond extends boolean, True, False> = Cond extends true ? True : False;
|
|
9
|
+
/**
|
|
10
|
+
* Represents classic "not" bitwise operation.
|
|
11
|
+
*/
|
|
12
|
+
export type Not<Cond extends boolean> = If<Cond, false, true>;
|
|
13
|
+
/**
|
|
14
|
+
* Represents classic "and" bitwise operation.
|
|
15
|
+
*/
|
|
16
|
+
export type And<A extends boolean, B extends boolean> = A extends true ? B extends true ? true : false : false;
|
|
17
|
+
/**
|
|
18
|
+
* Represents classic "or" bitwise operation.
|
|
19
|
+
*/
|
|
20
|
+
export type Or<A extends boolean, B extends boolean> = A extends true ? true : (B extends true ? true : false);
|
|
21
|
+
/**
|
|
22
|
+
* True if value includes undefined.
|
|
23
|
+
*/
|
|
24
|
+
export type HasUndefined<T> = undefined extends T ? true : false;
|
|
25
|
+
/**
|
|
26
|
+
* Returns true if specified property in type is marked as optional.
|
|
27
|
+
*/
|
|
28
|
+
export type IsOptional<Type, Key extends keyof Type> = {} extends Pick<Type, Key> ? true : false;
|
|
29
|
+
/**
|
|
30
|
+
* Returns union object keys.
|
|
31
|
+
*/
|
|
32
|
+
export type UnionKeys<T> = T extends T ? keyof T : never;
|
|
33
|
+
/**
|
|
34
|
+
* Returns object string keys.
|
|
35
|
+
*/
|
|
36
|
+
export type StringKeys<T extends object> = Extract<keyof T, string>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type PostEvent } from '../bridge/index.js';
|
|
2
|
+
import { type SupportsFunc } from '../supports/index.js';
|
|
3
|
+
import type { CreateRequestIdFunc } from '../types/index.js';
|
|
4
|
+
import type { Version } from '../version/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* Provides common Mini Apps functionality not covered by other system components.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Utils {
|
|
9
|
+
private readonly version;
|
|
10
|
+
private readonly createRequestId;
|
|
11
|
+
private readonly postEvent;
|
|
12
|
+
constructor(version: Version, createRequestId: CreateRequestIdFunc, postEvent?: PostEvent);
|
|
13
|
+
/**
|
|
14
|
+
* Opens a link in an external browser. The Mini App will not be closed.
|
|
15
|
+
*
|
|
16
|
+
* Note that this method can be called only in response to the user
|
|
17
|
+
* interaction with the Mini App interface (e.g. click inside the Mini App
|
|
18
|
+
* or on the main button).
|
|
19
|
+
* @param url - URL to be opened.
|
|
20
|
+
* @param tryInstantView
|
|
21
|
+
*/
|
|
22
|
+
openLink(url: string, tryInstantView?: boolean): void;
|
|
23
|
+
/**
|
|
24
|
+
* Opens a Telegram link inside Telegram app. The Mini App will be closed. It expects passing
|
|
25
|
+
* link in full format, with hostname "t.me".
|
|
26
|
+
* @param url - URL to be opened.
|
|
27
|
+
* @throws {Error} URL has not allowed hostname.
|
|
28
|
+
*/
|
|
29
|
+
openTelegramLink(url: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Reads text from clipboard and returns string or null. null is returned
|
|
32
|
+
* in cases:
|
|
33
|
+
* - Value in clipboard is not text
|
|
34
|
+
* - Access to clipboard is not allowed
|
|
35
|
+
*/
|
|
36
|
+
readTextFromClipboard(): Promise<string | null>;
|
|
37
|
+
/**
|
|
38
|
+
* Checks if specified method is supported by current component.
|
|
39
|
+
*/
|
|
40
|
+
supports: SupportsFunc<'readTextFromClipboard'>;
|
|
41
|
+
/**
|
|
42
|
+
* Checks if specified method parameter is supported by current component.
|
|
43
|
+
*/
|
|
44
|
+
supportsParam: SupportsFunc<'openLink.tryInstantView'>;
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Utils.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns 1 in case, version "a" is greater than "b".
|
|
3
|
+
* Returns 0 in case, version "a" equal to "b".
|
|
4
|
+
* Returns -1 in case, version "a" is lower than "b".
|
|
5
|
+
* @param a - first version.
|
|
6
|
+
* @param b - second version.
|
|
7
|
+
*/
|
|
8
|
+
export declare function compareVersions(a: string, b: string): number;
|
|
@@ -1,39 +1,20 @@
|
|
|
1
|
-
import { type RequestOptions
|
|
2
|
-
|
|
3
|
-
height: number;
|
|
4
|
-
isStateStable: boolean;
|
|
5
|
-
isExpanded: boolean;
|
|
6
|
-
width: number;
|
|
7
|
-
}
|
|
1
|
+
import { type RequestOptions } from '../bridge/index.js';
|
|
2
|
+
import type { ViewportEvents, ViewportProps } from './types.js';
|
|
8
3
|
/**
|
|
9
4
|
* Contains information about current WebApp device viewport, its dimensions
|
|
10
5
|
* and state.
|
|
11
6
|
*/
|
|
12
7
|
export declare class Viewport {
|
|
8
|
+
private readonly ee;
|
|
9
|
+
private readonly state;
|
|
13
10
|
private readonly postEvent;
|
|
11
|
+
constructor(props: ViewportProps);
|
|
14
12
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @see Issue: https://github.com/Telegram-Mini-Apps/tma.js/issues/5
|
|
19
|
-
* @param options - method options.
|
|
20
|
-
*/
|
|
21
|
-
static request(options?: RequestOptions): Promise<RequestViewportResult>;
|
|
22
|
-
/**
|
|
23
|
-
* Synchronizes specified instance of Viewport with the actual value in the native
|
|
24
|
-
* application.
|
|
25
|
-
* @param viewport - Viewport instance.
|
|
13
|
+
* Request viewport information from the Telegram application and updates current Viewport
|
|
14
|
+
* instance.
|
|
15
|
+
* @param options - options to request fresh data.
|
|
26
16
|
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Returns initialized instance of Viewport which is synchronized with
|
|
30
|
-
* its actual state in Mini Apps.
|
|
31
|
-
* @param options - method options.
|
|
32
|
-
*/
|
|
33
|
-
static synced(options?: RequestOptions): Promise<Viewport>;
|
|
34
|
-
private readonly ee;
|
|
35
|
-
private readonly state;
|
|
36
|
-
constructor(height: number, width: number, stableHeight: number, isExpanded: boolean, postEvent?: PostEvent);
|
|
17
|
+
sync(options?: RequestOptions): Promise<void>;
|
|
37
18
|
/**
|
|
38
19
|
* The current height of the visible area of the Mini App.
|
|
39
20
|
*
|
|
@@ -49,10 +30,6 @@ export declare class Viewport {
|
|
|
49
30
|
* used to pin interface elements to the bottom of the visible area. It's
|
|
50
31
|
* more appropriate to use the value of the `stableHeight`
|
|
51
32
|
* field for this purpose.
|
|
52
|
-
*
|
|
53
|
-
* @see init
|
|
54
|
-
* @see expand
|
|
55
|
-
* @see stableHeight
|
|
56
33
|
*/
|
|
57
34
|
get height(): number;
|
|
58
35
|
/**
|
|
@@ -68,12 +45,13 @@ export declare class Viewport {
|
|
|
68
45
|
* gestures or during animations. The value of `stableHeight`
|
|
69
46
|
* will be updated after all gestures and animations are completed and
|
|
70
47
|
* the Mini App reaches its final size.
|
|
71
|
-
*
|
|
72
|
-
* @see init
|
|
73
|
-
* @see expand
|
|
74
|
-
* @see height
|
|
75
48
|
*/
|
|
76
49
|
get stableHeight(): number;
|
|
50
|
+
/**
|
|
51
|
+
* Starts listening to viewport changes and applies them.
|
|
52
|
+
* @returns Function to stop listening.
|
|
53
|
+
*/
|
|
54
|
+
listen(): () => void;
|
|
77
55
|
/**
|
|
78
56
|
* Returns true if the Mini App is expanded to the maximum available height.
|
|
79
57
|
* Otherwise, if the Mini App occupies part of the screen and can be expanded
|
|
@@ -100,9 +78,9 @@ export declare class Viewport {
|
|
|
100
78
|
/**
|
|
101
79
|
* Adds new event listener.
|
|
102
80
|
*/
|
|
103
|
-
on:
|
|
81
|
+
on: <E extends "change" | "change:height" | "change:width" | "change:isExpanded" | "change:stableHeight">(event: E, listener: import('../event-emitter/index.js').EventListener<ViewportEvents[E]>) => import('../event-emitter/index.js').RemoveEventListener;
|
|
104
82
|
/**
|
|
105
83
|
* Removes event listener.
|
|
106
84
|
*/
|
|
107
|
-
off:
|
|
85
|
+
off: <E extends "change" | "change:height" | "change:width" | "change:isExpanded" | "change:stableHeight">(event: E, listener: import('../event-emitter/index.js').EventListener<ViewportEvents[E]>) => void;
|
|
108
86
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type RequestOptions } from '../bridge/index.js';
|
|
2
|
+
export interface RequestViewportResult {
|
|
3
|
+
height: number;
|
|
4
|
+
isStateStable: boolean;
|
|
5
|
+
isExpanded: boolean;
|
|
6
|
+
width: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Requests viewport actual information from the Telegram application.
|
|
10
|
+
* @param options - request options.
|
|
11
|
+
*/
|
|
12
|
+
export declare function requestViewport(options?: RequestOptions): Promise<RequestViewportResult>;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PostEvent } from '../bridge/index.js';
|
|
2
|
+
import type { StateEvents } from '../state/index.js';
|
|
3
|
+
export interface ViewportProps {
|
|
4
|
+
height: number;
|
|
5
|
+
width: number;
|
|
6
|
+
stableHeight: number;
|
|
7
|
+
isExpanded: boolean;
|
|
8
|
+
postEvent?: PostEvent;
|
|
9
|
+
}
|
|
2
10
|
export interface ViewportState {
|
|
3
11
|
height: number;
|
|
4
12
|
isExpanded: boolean;
|