@tma.js/sdk 0.13.2 → 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 -6
- 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 +2249 -1036
- 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 +30 -16
- 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 -73
- package/dist/dts/components/ThemeParams/index.d.ts +0 -2
- package/dist/dts/components/ThemeParams/types.d.ts +0 -9
- 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 -57
- 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 -166
- package/src/components/ThemeParams/index.ts +0 -2
- package/src/components/ThemeParams/types.ts +0 -18
- 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 -166
- 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
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Known type of chat.
|
|
3
|
+
*/
|
|
4
|
+
export type ChatType = 'sender' | 'private' | 'group' | 'supergroup' | 'channel' | string;
|
|
5
|
+
/**
|
|
6
|
+
* Describes Telegram Mini Apps [User](https://docs.telegram-mini-apps.com/platform/launch-parameters/init-data#user) type.
|
|
7
|
+
*/
|
|
8
|
+
export interface User {
|
|
9
|
+
/**
|
|
10
|
+
* True, if this user added the bot to the attachment menu.
|
|
11
|
+
*/
|
|
12
|
+
addedToAttachmentMenu?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* True, if this user allowed the bot to message them.
|
|
15
|
+
*/
|
|
16
|
+
allowsWriteToPm?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* First name of the user or bot.
|
|
19
|
+
*/
|
|
20
|
+
firstName: string;
|
|
21
|
+
/**
|
|
22
|
+
* A unique identifier for the user or bot.
|
|
23
|
+
*/
|
|
24
|
+
id: number;
|
|
25
|
+
/**
|
|
26
|
+
* True, if this user is a bot. Returned in the `receiver` field only.
|
|
27
|
+
* @see InitDataParsed.receiver
|
|
28
|
+
*/
|
|
29
|
+
isBot?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* True, if this user is a Telegram Premium user.
|
|
32
|
+
*/
|
|
33
|
+
isPremium?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Last name of the user or bot.
|
|
36
|
+
*/
|
|
37
|
+
lastName?: string;
|
|
38
|
+
/**
|
|
39
|
+
* [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) of the user's language.
|
|
40
|
+
* Returns in user field only.
|
|
41
|
+
*/
|
|
42
|
+
languageCode?: string;
|
|
43
|
+
/**
|
|
44
|
+
* URL of the user’s profile photo. The photo can be in .jpeg or .svg
|
|
45
|
+
* formats. Only returned for Mini Apps launched from the attachment menu.
|
|
46
|
+
*/
|
|
47
|
+
photoUrl?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Username of the user or bot.
|
|
50
|
+
*/
|
|
51
|
+
username?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Describes Telegram Mini Apps [Chat](https://docs.telegram-mini-apps.com/platform/launch-parameters/init-data#chat) type.
|
|
55
|
+
*/
|
|
56
|
+
export interface Chat {
|
|
57
|
+
/**
|
|
58
|
+
* Unique identifier for this chat.
|
|
59
|
+
*/
|
|
60
|
+
id: number;
|
|
61
|
+
/**
|
|
62
|
+
* URL of the chat’s photo. The photo can be in .jpeg or .svg formats.
|
|
63
|
+
* Only returned for Mini Apps launched from the attachment menu.
|
|
64
|
+
*/
|
|
65
|
+
photoUrl?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Type of chat.
|
|
68
|
+
*/
|
|
69
|
+
type: 'group' | 'supergroup' | 'channel' | string;
|
|
70
|
+
/**
|
|
71
|
+
* Title of the chat.
|
|
72
|
+
*/
|
|
73
|
+
title: string;
|
|
74
|
+
/**
|
|
75
|
+
* Username of the chat.
|
|
76
|
+
*/
|
|
77
|
+
username?: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Describes Telegram Mini Apps [InitData](https://docs.telegram-mini-apps.com/platform/launch-parameters/init-data#parameters-list)
|
|
81
|
+
* type.
|
|
82
|
+
*/
|
|
83
|
+
export interface InitDataParsed {
|
|
84
|
+
/**
|
|
85
|
+
* Init data generation date.
|
|
86
|
+
*/
|
|
87
|
+
authDate: Date;
|
|
88
|
+
/**
|
|
89
|
+
* The number of seconds after which a message can be sent via the method [answerWebAppQuery](https://core.telegram.org/bots/api#answerwebappquery).
|
|
90
|
+
*/
|
|
91
|
+
canSendAfter?: number;
|
|
92
|
+
/**
|
|
93
|
+
* An object containing data about the chat where the bot was launched via
|
|
94
|
+
* the attachment menu. Returned for supergroups, channels and group
|
|
95
|
+
* chats – only for Mini Apps launched via the attachment menu.
|
|
96
|
+
*/
|
|
97
|
+
chat?: Chat;
|
|
98
|
+
/**
|
|
99
|
+
* The type of chat from which Mini App was opened.
|
|
100
|
+
*/
|
|
101
|
+
chatType?: ChatType;
|
|
102
|
+
/**
|
|
103
|
+
* A global identifier indicating the chat from which Mini App was opened. Returned only for
|
|
104
|
+
* applications opened by direct link.
|
|
105
|
+
*/
|
|
106
|
+
chatInstance?: string;
|
|
107
|
+
/**
|
|
108
|
+
* A hash of all passed parameters, which the bot server can use to
|
|
109
|
+
* check their [validity](https://core.telegram.org/bots/webapps#validating-data-received-via-the-web-app).
|
|
110
|
+
*/
|
|
111
|
+
hash: string;
|
|
112
|
+
/**
|
|
113
|
+
* A unique identifier for the Mini App session, required for sending
|
|
114
|
+
* messages via the [answerWebAppQuery](https://core.telegram.org/bots/api#answerwebappquery) method.
|
|
115
|
+
*/
|
|
116
|
+
queryId?: string;
|
|
117
|
+
/**
|
|
118
|
+
* An object containing data about the chat partner of the current user in
|
|
119
|
+
* the chat where the bot was launched via the attachment menu.
|
|
120
|
+
* Returned only for private chats and only for Mini Apps launched
|
|
121
|
+
* via the attachment menu.
|
|
122
|
+
*/
|
|
123
|
+
receiver?: User;
|
|
124
|
+
/**
|
|
125
|
+
* The value of the `startattach` parameter, passed via link. Only returned for
|
|
126
|
+
* Mini Apps when launched from the attachment menu via link.
|
|
127
|
+
*/
|
|
128
|
+
startParam?: string;
|
|
129
|
+
/**
|
|
130
|
+
* An object containing data about the current user.
|
|
131
|
+
*/
|
|
132
|
+
user?: User;
|
|
133
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type InvoiceStatus, type PostEvent } from '../bridge/index.js';
|
|
2
|
+
import { type SupportsFunc } from '../supports/index.js';
|
|
3
|
+
import type { Version } from '../version/index.js';
|
|
4
|
+
import type { InvoiceEvents } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Controls currently displayed invoice.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Invoice {
|
|
9
|
+
private readonly postEvent;
|
|
10
|
+
private readonly ee;
|
|
11
|
+
private readonly state;
|
|
12
|
+
constructor(version: Version, postEvent?: PostEvent);
|
|
13
|
+
private set isOpened(value);
|
|
14
|
+
/**
|
|
15
|
+
* True if invoice is currently opened.
|
|
16
|
+
*/
|
|
17
|
+
get isOpened(): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Adds new event listener.
|
|
20
|
+
*/
|
|
21
|
+
on: <E extends "change" | "change:isOpened">(event: E, listener: import('../event-emitter/index.js').EventListener<InvoiceEvents[E]>) => import('../event-emitter/index.js').RemoveEventListener;
|
|
22
|
+
/**
|
|
23
|
+
* Removes event listener.
|
|
24
|
+
*/
|
|
25
|
+
off: <E extends "change" | "change:isOpened">(event: E, listener: import('../event-emitter/index.js').EventListener<InvoiceEvents[E]>) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Opens an invoice using its slug.
|
|
28
|
+
* @param slug - invoice slug.
|
|
29
|
+
* @throws {Error} Invoice is already opened.
|
|
30
|
+
*/
|
|
31
|
+
open(slug: string): Promise<InvoiceStatus>;
|
|
32
|
+
/**
|
|
33
|
+
* Opens an invoice using its url. It expects passing link in full format, with hostname "t.me".
|
|
34
|
+
* @param url - invoice URL.
|
|
35
|
+
* @param type - value type.
|
|
36
|
+
* @throws {Error} Invoice is already opened.
|
|
37
|
+
*/
|
|
38
|
+
open(url: string, type: 'url'): Promise<InvoiceStatus>;
|
|
39
|
+
/**
|
|
40
|
+
* Checks if specified method is supported by current component.
|
|
41
|
+
*/
|
|
42
|
+
supports: SupportsFunc<'open'>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { StateEvents } from '../state/index.js';
|
|
2
|
+
export interface InvoiceState {
|
|
3
|
+
isOpened: boolean;
|
|
4
|
+
}
|
|
5
|
+
export type InvoiceEvents = StateEvents<InvoiceState>;
|
|
6
|
+
export type InvoiceEventName = keyof InvoiceEvents;
|
|
7
|
+
export type InvoiceEventListener<E extends InvoiceEventName> = InvoiceEvents[E];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { LaunchData } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Computes launch data information. Extracts both previous and current launch parameters
|
|
4
|
+
* to compute current list of them. Additionally, computes if page was reloaded.
|
|
5
|
+
*/
|
|
6
|
+
export declare function computeLaunchData(): LaunchData;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the first navigation entry from window.performance.
|
|
3
|
+
* @returns First navigation entry or null, in case performance functionality is not supported
|
|
4
|
+
* or navigation entry was not found.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getFirstNavigationEntry(): PerformanceNavigationTiming | null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './computeLaunchData.js';
|
|
2
|
+
export * from './computePageReload.js';
|
|
3
|
+
export * from './getFirstNavigationEntry.js';
|
|
4
|
+
export * from './launchParamsParser.js';
|
|
5
|
+
export * from './parseLaunchParams.js';
|
|
6
|
+
export * from './retrieveCurrent.js';
|
|
7
|
+
export * from './retrieveFromLocation.js';
|
|
8
|
+
export * from './retrieveFromPerformance.js';
|
|
9
|
+
export * from './retrieveLaunchData.js';
|
|
10
|
+
export * from './serializeLaunchParams.js';
|
|
11
|
+
export * from './storage.js';
|
|
12
|
+
export * from './types.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { LaunchParams } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Attempts to read launch parameters using window.performance data.
|
|
4
|
+
* @throws {Error} Unable to get first navigation entry.
|
|
5
|
+
* @throws {Error} First navigation entry does not contain hash part.
|
|
6
|
+
* @throws {TypeError} Unable to parse value.
|
|
7
|
+
*/
|
|
8
|
+
export declare function retrieveFromPerformance(): LaunchParams;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { LaunchParams } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Attempts to extract launch parameters directly from the session storage.
|
|
4
|
+
* @returns Launch parameters in case, they were stored before or null, if there is no launch
|
|
5
|
+
* parameters key in the session storage.
|
|
6
|
+
* @throws {Error} Data stored in the session storage is invalid.
|
|
7
|
+
*/
|
|
8
|
+
export declare function retrieveFromStorage(): LaunchParams | null;
|
|
9
|
+
/**
|
|
10
|
+
* Saves specified launch parameters in the session storage.
|
|
11
|
+
* @param value - launch params to save.
|
|
12
|
+
*/
|
|
13
|
+
export declare function saveToStorage(value: LaunchParams): void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { InitDataParsed } from '../init-data/index.js';
|
|
2
|
+
import type { ThemeParamsParsed } from '../theme-params/index.js';
|
|
3
|
+
import type { Platform } from '../types/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Telegram Mini Apps launch parameters.
|
|
6
|
+
* @see https://docs.telegram-mini-apps.com/platform/launch-parameters/common-information
|
|
7
|
+
*/
|
|
8
|
+
export interface LaunchParams {
|
|
9
|
+
/**
|
|
10
|
+
* Current Mini Apps version.
|
|
11
|
+
*/
|
|
12
|
+
version: string;
|
|
13
|
+
/**
|
|
14
|
+
* Current launch init data. Can be missing in case, application was launched via
|
|
15
|
+
* KeyboardButton.
|
|
16
|
+
*/
|
|
17
|
+
initData?: InitDataParsed;
|
|
18
|
+
/**
|
|
19
|
+
* The same as initData but in initial, raw format.
|
|
20
|
+
*/
|
|
21
|
+
initDataRaw?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Current Telegram application identifier.
|
|
24
|
+
*/
|
|
25
|
+
platform: Platform;
|
|
26
|
+
/**
|
|
27
|
+
* Mini App palette settings.
|
|
28
|
+
*/
|
|
29
|
+
themeParams: ThemeParamsParsed;
|
|
30
|
+
/**
|
|
31
|
+
* True if Mini App is currently launched in inline mode.
|
|
32
|
+
*/
|
|
33
|
+
botInline?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* True if application is required to show the Settings Button.
|
|
36
|
+
*/
|
|
37
|
+
showSettings?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface LaunchData {
|
|
40
|
+
/**
|
|
41
|
+
* Was current application reloaded.
|
|
42
|
+
*/
|
|
43
|
+
isPageReload: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Current application launch parameters.
|
|
46
|
+
*/
|
|
47
|
+
launchParams: LaunchParams;
|
|
48
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message log level.
|
|
3
|
+
*/
|
|
4
|
+
export type LogLevel = 'log' | 'error' | 'warn';
|
|
5
|
+
export declare class Logger {
|
|
6
|
+
private readonly prefix;
|
|
7
|
+
private enabled;
|
|
8
|
+
constructor(prefix: string, enabled: boolean);
|
|
9
|
+
/**
|
|
10
|
+
* Prints message into a console in case, logger is currently enabled.
|
|
11
|
+
* @param level - log level.
|
|
12
|
+
* @param args - arguments.
|
|
13
|
+
*/
|
|
14
|
+
private print;
|
|
15
|
+
/**
|
|
16
|
+
* Disables the logger.
|
|
17
|
+
*/
|
|
18
|
+
disable(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Prints error message into a console.
|
|
21
|
+
* @param args
|
|
22
|
+
*/
|
|
23
|
+
error(...args: any[]): void;
|
|
24
|
+
/**
|
|
25
|
+
* Enables the logger.
|
|
26
|
+
*/
|
|
27
|
+
enable(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Prints log message into a console.
|
|
30
|
+
* @param args
|
|
31
|
+
*/
|
|
32
|
+
log(...args: any[]): void;
|
|
33
|
+
/**
|
|
34
|
+
* Prints warning message into a console.
|
|
35
|
+
* @param args
|
|
36
|
+
*/
|
|
37
|
+
warn(...args: any[]): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Logger.js';
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { EventEmitter } from '../event-emitter/index.js';
|
|
2
|
+
import type { RGB } from '../colors/index.js';
|
|
3
|
+
import type { MainButtonEvents, MainButtonParams, MainButtonProps } from './types.js';
|
|
4
|
+
type Emitter = EventEmitter<MainButtonEvents>;
|
|
5
|
+
/**
|
|
6
|
+
* Controls the main button, which is displayed at the bottom
|
|
7
|
+
* of the Mini App in the Telegram interface.
|
|
8
|
+
*/
|
|
9
|
+
export declare class MainButton {
|
|
10
|
+
private readonly ee;
|
|
11
|
+
private readonly state;
|
|
12
|
+
private readonly postEvent;
|
|
13
|
+
constructor(props: MainButtonProps);
|
|
14
|
+
/**
|
|
15
|
+
* Sends current local state to Telegram application.
|
|
16
|
+
*/
|
|
17
|
+
private commit;
|
|
18
|
+
private set isEnabled(value);
|
|
19
|
+
/**
|
|
20
|
+
* True if the Main Button is currently enabled.
|
|
21
|
+
*/
|
|
22
|
+
get isEnabled(): boolean;
|
|
23
|
+
private set isLoaderVisible(value);
|
|
24
|
+
/**
|
|
25
|
+
* True if the Main Button loader is currently visible.
|
|
26
|
+
*/
|
|
27
|
+
get isLoaderVisible(): boolean;
|
|
28
|
+
private set isVisible(value);
|
|
29
|
+
/**
|
|
30
|
+
* True if the Main Button is currently visible.
|
|
31
|
+
*/
|
|
32
|
+
get isVisible(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* The Main Button background color.
|
|
35
|
+
*/
|
|
36
|
+
get backgroundColor(): RGB;
|
|
37
|
+
/**
|
|
38
|
+
* The Main Button text.
|
|
39
|
+
*/
|
|
40
|
+
get text(): string;
|
|
41
|
+
/**
|
|
42
|
+
* The Main Button text color.
|
|
43
|
+
*/
|
|
44
|
+
get textColor(): RGB;
|
|
45
|
+
/**
|
|
46
|
+
* Disables the Main Button.
|
|
47
|
+
*/
|
|
48
|
+
disable(): this;
|
|
49
|
+
/**
|
|
50
|
+
* Enables the Main Button.
|
|
51
|
+
*/
|
|
52
|
+
enable(): this;
|
|
53
|
+
/**
|
|
54
|
+
* Hides the Main Button.
|
|
55
|
+
*/
|
|
56
|
+
hide(): this;
|
|
57
|
+
/**
|
|
58
|
+
* Hides the Main Button loader.
|
|
59
|
+
*/
|
|
60
|
+
hideLoader(): this;
|
|
61
|
+
/**
|
|
62
|
+
* Adds new event listener.
|
|
63
|
+
* @param event - event name.
|
|
64
|
+
* @param listener - event listener.
|
|
65
|
+
*/
|
|
66
|
+
on: Emitter['on'];
|
|
67
|
+
/**
|
|
68
|
+
* Removes event listener.
|
|
69
|
+
* @param event - event name.
|
|
70
|
+
* @param listener - event listener.
|
|
71
|
+
*/
|
|
72
|
+
off: Emitter['off'];
|
|
73
|
+
/**
|
|
74
|
+
* Shows the Main Button. Note that opening the Mini App from the attachment menu hides the
|
|
75
|
+
* main button until the user interacts with the Mini App interface.
|
|
76
|
+
*/
|
|
77
|
+
show(): this;
|
|
78
|
+
/**
|
|
79
|
+
* A method to show a loading indicator on the Main Button. It is recommended to display
|
|
80
|
+
* loader if the action tied to the button may take a long time.
|
|
81
|
+
*/
|
|
82
|
+
showLoader(): this;
|
|
83
|
+
/**
|
|
84
|
+
* Sets new Main Button text. Minimal length for text is 1 symbol, and maximum is 64 symbols.
|
|
85
|
+
* @param text - new text.
|
|
86
|
+
*/
|
|
87
|
+
setText(text: string): this;
|
|
88
|
+
/**
|
|
89
|
+
* Sets new Main Button text color.
|
|
90
|
+
* @param textColor - new text color.
|
|
91
|
+
*/
|
|
92
|
+
setTextColor(textColor: RGB): this;
|
|
93
|
+
/**
|
|
94
|
+
* Updates current Main Button color.
|
|
95
|
+
* @param backgroundColor - color to set.
|
|
96
|
+
*/
|
|
97
|
+
setBackgroundColor(backgroundColor: RGB): this;
|
|
98
|
+
/**
|
|
99
|
+
* Allows setting multiple Main Button parameters.
|
|
100
|
+
* @param params - Main Button parameters.
|
|
101
|
+
*/
|
|
102
|
+
setParams(params: MainButtonParams): this;
|
|
103
|
+
}
|
|
104
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PostEvent } from '../bridge/index.js';
|
|
2
|
+
import type { RGB } from '../colors/index.js';
|
|
3
|
+
import type { StateEvents } from '../state/index.js';
|
|
4
|
+
export interface MainButtonParams {
|
|
5
|
+
backgroundColor?: RGB;
|
|
6
|
+
isEnabled?: boolean;
|
|
7
|
+
isLoaderVisible?: boolean;
|
|
8
|
+
isVisible?: boolean;
|
|
9
|
+
text?: string;
|
|
10
|
+
textColor?: RGB;
|
|
11
|
+
}
|
|
12
|
+
export interface MainButtonProps extends Required<MainButtonParams> {
|
|
13
|
+
postEvent?: PostEvent;
|
|
14
|
+
}
|
|
15
|
+
export type MainButtonState = Required<MainButtonParams>;
|
|
16
|
+
export interface MainButtonEvents extends StateEvents<MainButtonState> {
|
|
17
|
+
click: () => void;
|
|
18
|
+
}
|
|
19
|
+
export type MainButtonEventName = keyof MainButtonEvents;
|
|
20
|
+
export type MainButtonEventListener<E extends MainButtonEventName> = MainButtonEvents[E];
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { type PhoneRequestedStatus, type SwitchInlineQueryChatType, type WriteAccessRequestedStatus } from '../bridge/index.js';
|
|
2
|
+
import { type RGB } from '../colors/index.js';
|
|
3
|
+
import { type SupportsFunc } from '../supports/index.js';
|
|
4
|
+
import type { MiniAppEvents, MiniAppHeaderColor, MiniAppProps } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Provides common Mini Apps functionality not covered by other system components.
|
|
7
|
+
*/
|
|
8
|
+
export declare class MiniApp {
|
|
9
|
+
private readonly ee;
|
|
10
|
+
private readonly state;
|
|
11
|
+
private readonly botInline;
|
|
12
|
+
private readonly postEvent;
|
|
13
|
+
constructor(props: MiniAppProps);
|
|
14
|
+
/**
|
|
15
|
+
* The Mini App background color.
|
|
16
|
+
*/
|
|
17
|
+
get backgroundColor(): RGB;
|
|
18
|
+
/**
|
|
19
|
+
* Closes the Mini App.
|
|
20
|
+
*/
|
|
21
|
+
close(): void;
|
|
22
|
+
/**
|
|
23
|
+
* The Mini App header color. Could either be a header color key or RGB color.
|
|
24
|
+
*/
|
|
25
|
+
get headerColor(): MiniAppHeaderColor;
|
|
26
|
+
/**
|
|
27
|
+
* True if Mini App is currently launched in bot inline mode.
|
|
28
|
+
*/
|
|
29
|
+
get isBotInline(): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* True if current Mini App background color recognized as dark.
|
|
32
|
+
*/
|
|
33
|
+
get isDark(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Adds new event listener.
|
|
36
|
+
*/
|
|
37
|
+
on: <E extends "change" | "change:backgroundColor" | "change:headerColor">(event: E, listener: import('../event-emitter/index.js').EventListener<MiniAppEvents[E]>) => import('../event-emitter/index.js').RemoveEventListener;
|
|
38
|
+
/**
|
|
39
|
+
* Removes event listener.
|
|
40
|
+
*/
|
|
41
|
+
off: <E extends "change" | "change:backgroundColor" | "change:headerColor">(event: E, listener: import('../event-emitter/index.js').EventListener<MiniAppEvents[E]>) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Informs the Telegram app that the Mini App is ready to be displayed.
|
|
44
|
+
*
|
|
45
|
+
* It is recommended to call this method as early as possible, as soon as all essential
|
|
46
|
+
* interface elements loaded. Once this method called, the loading placeholder is hidden
|
|
47
|
+
* and the Mini App shown.
|
|
48
|
+
*
|
|
49
|
+
* If the method not called, the placeholder will be hidden only when the page fully loaded.
|
|
50
|
+
*/
|
|
51
|
+
ready(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Requests current user phone access.
|
|
54
|
+
*/
|
|
55
|
+
requestPhoneAccess(): Promise<PhoneRequestedStatus>;
|
|
56
|
+
/**
|
|
57
|
+
* Requests write message access to current user.
|
|
58
|
+
*/
|
|
59
|
+
requestWriteAccess(): Promise<WriteAccessRequestedStatus>;
|
|
60
|
+
/**
|
|
61
|
+
* A method used to send data to the bot. When this method called, a service message sent to
|
|
62
|
+
* the bot containing the data of the length up to 4096 bytes, and the Mini App closed. See the
|
|
63
|
+
* field `web_app_data` in the class [Message](https://core.telegram.org/bots/api#message).
|
|
64
|
+
*
|
|
65
|
+
* This method is only available for Mini Apps launched via a Keyboard button.
|
|
66
|
+
* @param data - data to send to bot.
|
|
67
|
+
* @throws {Error} data has incorrect size.
|
|
68
|
+
*/
|
|
69
|
+
sendData(data: string): void;
|
|
70
|
+
/**
|
|
71
|
+
* Updates current Mini App header color.
|
|
72
|
+
* @param color - color key or RGB color.
|
|
73
|
+
*/
|
|
74
|
+
setHeaderColor(color: MiniAppHeaderColor): void;
|
|
75
|
+
/**
|
|
76
|
+
* Updates current Mini App background color.
|
|
77
|
+
* @param color - RGB color.
|
|
78
|
+
*/
|
|
79
|
+
setBackgroundColor(color: RGB): void;
|
|
80
|
+
/**
|
|
81
|
+
* Checks if specified method is supported by current component.
|
|
82
|
+
*/
|
|
83
|
+
supports: SupportsFunc<'requestWriteAccess' | 'requestPhoneAccess' | 'switchInlineQuery' | 'setHeaderColor' | 'setBackgroundColor'>;
|
|
84
|
+
/**
|
|
85
|
+
* Checks if specified method parameter is supported by current component.
|
|
86
|
+
*/
|
|
87
|
+
supportsParam: SupportsFunc<'setHeaderColor.color'>;
|
|
88
|
+
/**
|
|
89
|
+
* Inserts the bot's username and the specified inline query in the current chat's input field.
|
|
90
|
+
* Query may be empty, in which case only the bot's username will be inserted. The client prompts
|
|
91
|
+
* the user to choose a specific chat, then opens that chat and inserts the bot's username and
|
|
92
|
+
* the specified inline query in the input field.
|
|
93
|
+
* @param text - text which should be inserted in the input after the current bot name. Max
|
|
94
|
+
* length is 256 symbols.
|
|
95
|
+
* @param chatTypes - List of chat types which could be chosen to send the message. Could be
|
|
96
|
+
* empty list.
|
|
97
|
+
*/
|
|
98
|
+
switchInlineQuery(text: string, chatTypes?: SwitchInlineQueryChatType[]): void;
|
|
99
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { HeaderColorKey, PostEvent } from '../bridge/index.js';
|
|
2
|
+
import type { RGB } from '../colors/index.js';
|
|
3
|
+
import type { StateEvents } from '../state/index.js';
|
|
4
|
+
import type { Version } from '../version/index.js';
|
|
5
|
+
export interface MiniAppProps {
|
|
6
|
+
headerColor: MiniAppHeaderColor;
|
|
7
|
+
backgroundColor: RGB;
|
|
8
|
+
version: Version;
|
|
9
|
+
botInline: boolean;
|
|
10
|
+
postEvent?: PostEvent;
|
|
11
|
+
}
|
|
12
|
+
export type MiniAppHeaderColor = HeaderColorKey | RGB;
|
|
13
|
+
export interface MiniAppState {
|
|
14
|
+
backgroundColor: RGB;
|
|
15
|
+
headerColor: MiniAppHeaderColor;
|
|
16
|
+
}
|
|
17
|
+
export type MiniAppEvents = StateEvents<MiniAppState>;
|
|
18
|
+
export type MiniAppEventName = keyof MiniAppEvents;
|
|
19
|
+
export type MiniAppEventListener<E extends MiniAppEventName> = MiniAppEvents[E];
|