@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
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import type { RGB } from '../../colors/index.js';
|
|
2
|
+
import type { IsNever, Not, RequestId, UnionKeys } from '../../types/index.js';
|
|
3
|
+
import type { AnyHapticFeedbackParams } from './haptic.js';
|
|
4
|
+
import type { AnyInvokeCustomMethodParams } from './invoke-custom-method.js';
|
|
5
|
+
import type { PopupParams } from './popup.js';
|
|
6
|
+
/**
|
|
7
|
+
* Color key which could be used to update header color.
|
|
8
|
+
*/
|
|
9
|
+
export type HeaderColorKey = 'bg_color' | 'secondary_bg_color';
|
|
10
|
+
/**
|
|
11
|
+
* Chat type which could be used when calling `web_app_switch_inline_query` method.
|
|
12
|
+
*/
|
|
13
|
+
export type SwitchInlineQueryChatType = 'users' | 'bots' | 'groups' | 'channels';
|
|
14
|
+
interface CreateParams<Params = undefined, VersionedParam extends UnionKeys<Params> = never> {
|
|
15
|
+
params: Params;
|
|
16
|
+
versionedParams: VersionedParam;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Describes list of events and their parameters that could be posted by Bridge.
|
|
20
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods
|
|
21
|
+
*/
|
|
22
|
+
export interface MiniAppsMethods {
|
|
23
|
+
/**
|
|
24
|
+
* Notifies parent iframe about the current frame is ready. This method is only used in the Web
|
|
25
|
+
* version of Telegram. As a result, Mini App will receive `set_custom_style` event.
|
|
26
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#iframe-ready
|
|
27
|
+
*/
|
|
28
|
+
iframe_ready: CreateParams<{
|
|
29
|
+
/**
|
|
30
|
+
* True, if current Mini App supports native reloading.
|
|
31
|
+
*/
|
|
32
|
+
reload_supported?: boolean;
|
|
33
|
+
} | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Notifies parent iframe about the current iframe is going to reload.
|
|
36
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#iframe-will-reload
|
|
37
|
+
*/
|
|
38
|
+
iframe_will_reload: CreateParams;
|
|
39
|
+
/**
|
|
40
|
+
* Closes Mini App.
|
|
41
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-close
|
|
42
|
+
*/
|
|
43
|
+
web_app_close: CreateParams;
|
|
44
|
+
/**
|
|
45
|
+
* Closes a QR scanner. The Telegram application creates `scan_qr_popup_closed` event.
|
|
46
|
+
* @since v6.4
|
|
47
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-close-scan-qr-popup
|
|
48
|
+
*/
|
|
49
|
+
web_app_close_scan_qr_popup: CreateParams;
|
|
50
|
+
/**
|
|
51
|
+
* Sends data to the bot. When this method is called, a service message is sent to the bot
|
|
52
|
+
* containing the data of the length up to 4096 bytes. Then, Mini App will be closed.
|
|
53
|
+
*
|
|
54
|
+
* To get more information, take a look at `web_app_data` field in the
|
|
55
|
+
* class [Message](https://core.telegram.org/bots/api#message).
|
|
56
|
+
*
|
|
57
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-data-send
|
|
58
|
+
*/
|
|
59
|
+
web_app_data_send: CreateParams<{
|
|
60
|
+
/**
|
|
61
|
+
* Data to send to a bot. Should not have size of more than 4096 bytes.
|
|
62
|
+
*/
|
|
63
|
+
data: string;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Expands the Mini App.
|
|
67
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-expand
|
|
68
|
+
*/
|
|
69
|
+
web_app_expand: CreateParams;
|
|
70
|
+
/**
|
|
71
|
+
* Invokes custom method.
|
|
72
|
+
* @since v6.9
|
|
73
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-invoke-custom-method
|
|
74
|
+
*/
|
|
75
|
+
web_app_invoke_custom_method: CreateParams<AnyInvokeCustomMethodParams>;
|
|
76
|
+
/**
|
|
77
|
+
* Opens an invoice by its specified slug. More information about invoices in
|
|
78
|
+
* this [documentation](https://core.telegram.org/bots/payments).
|
|
79
|
+
* @since v6.1
|
|
80
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-open-invoice
|
|
81
|
+
*/
|
|
82
|
+
web_app_open_invoice: CreateParams<{
|
|
83
|
+
/**
|
|
84
|
+
* Invoice unique identifier.
|
|
85
|
+
*/
|
|
86
|
+
slug: string;
|
|
87
|
+
}>;
|
|
88
|
+
/**
|
|
89
|
+
* Opens link in the default browser. Mini App will not be closed.
|
|
90
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-open-link
|
|
91
|
+
*/
|
|
92
|
+
web_app_open_link: CreateParams<{
|
|
93
|
+
/**
|
|
94
|
+
* URL to be opened by Telegram application. Should be a full path with `https` protocol.
|
|
95
|
+
*/
|
|
96
|
+
url: string;
|
|
97
|
+
/**
|
|
98
|
+
* Link will be opened in Instant View mode if possible.
|
|
99
|
+
* @since v6.4
|
|
100
|
+
* @see https://instantview.telegram.org/
|
|
101
|
+
*/
|
|
102
|
+
try_instant_view?: boolean;
|
|
103
|
+
}, 'try_instant_view'>;
|
|
104
|
+
/**
|
|
105
|
+
* Opens a new popup. When user closes the popup, Telegram creates the `popup_closed` event.
|
|
106
|
+
* @since v6.2
|
|
107
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-open-popup
|
|
108
|
+
*/
|
|
109
|
+
web_app_open_popup: CreateParams<PopupParams>;
|
|
110
|
+
/**
|
|
111
|
+
* Opens a QR scanner. When the scanner was closed, the Telegram application creates
|
|
112
|
+
* the `scan_qr_popup_closed` event. When the scanner reads QR, Telegram creates the
|
|
113
|
+
* `qr_text_received` event.
|
|
114
|
+
* @since v6.4
|
|
115
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-open-scan-qr-popup
|
|
116
|
+
*/
|
|
117
|
+
web_app_open_scan_qr_popup: CreateParams<{
|
|
118
|
+
/**
|
|
119
|
+
* Text to be displayed in the QR scanner.
|
|
120
|
+
*/
|
|
121
|
+
text?: string;
|
|
122
|
+
}>;
|
|
123
|
+
/**
|
|
124
|
+
* Opens the Telegram link by its pathname and query parameters. The link will be opened in the
|
|
125
|
+
* Telegram app, Mini App will be closed.
|
|
126
|
+
* @since v6.1
|
|
127
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-open-tg-link
|
|
128
|
+
*/
|
|
129
|
+
web_app_open_tg_link: CreateParams<{
|
|
130
|
+
/**
|
|
131
|
+
* Should be a value taken from the link of this format: `https://t.me/{path_full}`. Can
|
|
132
|
+
* additionally contain query parameters.
|
|
133
|
+
*/
|
|
134
|
+
path_full: string;
|
|
135
|
+
}>;
|
|
136
|
+
/**
|
|
137
|
+
* Reads text from the clipboard. The method accepts a request identifier which is used to
|
|
138
|
+
* appropriately retrieve the method execution result from the `clipboard_text_received` event.
|
|
139
|
+
* @since v6.4
|
|
140
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-read-text-from-clipboard
|
|
141
|
+
*/
|
|
142
|
+
web_app_read_text_from_clipboard: CreateParams<{
|
|
143
|
+
/**
|
|
144
|
+
* Unique request identifier. Should be any unique string to handle the generated event
|
|
145
|
+
* appropriately.
|
|
146
|
+
*/
|
|
147
|
+
req_id: RequestId;
|
|
148
|
+
}>;
|
|
149
|
+
/**
|
|
150
|
+
* Notifies Telegram about current application is ready to be shown. This method will make
|
|
151
|
+
* Telegram to remove application loader and display Mini App.
|
|
152
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-ready
|
|
153
|
+
*/
|
|
154
|
+
web_app_ready: CreateParams;
|
|
155
|
+
/**
|
|
156
|
+
* Requests access to current user's phone.
|
|
157
|
+
* @since v6.9
|
|
158
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-request-phone
|
|
159
|
+
*/
|
|
160
|
+
web_app_request_phone: CreateParams;
|
|
161
|
+
/**
|
|
162
|
+
* Requests current theme from Telegram. As a result, Telegram will create `theme_changed` event.
|
|
163
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-request-theme
|
|
164
|
+
*/
|
|
165
|
+
web_app_request_theme: CreateParams;
|
|
166
|
+
/**
|
|
167
|
+
* Requests current viewport information from Telegram. As a result, Telegram will create
|
|
168
|
+
* `viewport_changed` event.
|
|
169
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-request-viewport
|
|
170
|
+
*/
|
|
171
|
+
web_app_request_viewport: CreateParams;
|
|
172
|
+
/**
|
|
173
|
+
* Requests write message access to current user.
|
|
174
|
+
* @since v6.9
|
|
175
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-rqeuest-write-access
|
|
176
|
+
*/
|
|
177
|
+
web_app_request_write_access: CreateParams;
|
|
178
|
+
/**
|
|
179
|
+
* Updates the Mini App background color.
|
|
180
|
+
* @since v6.1
|
|
181
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-set-background-color
|
|
182
|
+
*/
|
|
183
|
+
web_app_set_background_color: CreateParams<{
|
|
184
|
+
/**
|
|
185
|
+
* The Mini App background color in `#RRGGBB` format.
|
|
186
|
+
*/
|
|
187
|
+
color: RGB;
|
|
188
|
+
}>;
|
|
189
|
+
/**
|
|
190
|
+
* Updates the Mini App header color.
|
|
191
|
+
* @since v6.1
|
|
192
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-set-header-color
|
|
193
|
+
*/
|
|
194
|
+
web_app_set_header_color: CreateParams<{
|
|
195
|
+
/**
|
|
196
|
+
* The Mini App header color key.
|
|
197
|
+
*/
|
|
198
|
+
color_key: HeaderColorKey;
|
|
199
|
+
} | {
|
|
200
|
+
/**
|
|
201
|
+
* Color in RGB format.
|
|
202
|
+
* @since v6.9
|
|
203
|
+
*/
|
|
204
|
+
color: RGB;
|
|
205
|
+
}, 'color'>;
|
|
206
|
+
/**
|
|
207
|
+
* Updates the Back Button settings.
|
|
208
|
+
* @since v6.1
|
|
209
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-setup-back-button
|
|
210
|
+
*/
|
|
211
|
+
web_app_setup_back_button: CreateParams<{
|
|
212
|
+
/**
|
|
213
|
+
* Should the Back Button be visible.
|
|
214
|
+
*/
|
|
215
|
+
is_visible: boolean;
|
|
216
|
+
}>;
|
|
217
|
+
/**
|
|
218
|
+
* Updates current closing behavior.
|
|
219
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-setup-closing-behavior
|
|
220
|
+
*/
|
|
221
|
+
web_app_setup_closing_behavior: CreateParams<{
|
|
222
|
+
/**
|
|
223
|
+
* Will user be prompted in case, an application is going to be closed.
|
|
224
|
+
*/
|
|
225
|
+
need_confirmation: boolean;
|
|
226
|
+
}>;
|
|
227
|
+
/**
|
|
228
|
+
* Updates the Main Button settings.
|
|
229
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-setup-main-button
|
|
230
|
+
*/
|
|
231
|
+
web_app_setup_main_button: CreateParams<{
|
|
232
|
+
/**
|
|
233
|
+
* Should the Main Button be displayed.
|
|
234
|
+
*/
|
|
235
|
+
is_visible?: boolean;
|
|
236
|
+
/**
|
|
237
|
+
* Should the Main Button be enabled.
|
|
238
|
+
*/
|
|
239
|
+
is_active?: boolean;
|
|
240
|
+
/**
|
|
241
|
+
* Should loader inside the Main Button be displayed. Use this property in case, some
|
|
242
|
+
* operation takes time. This loader will make user notified about it.
|
|
243
|
+
*/
|
|
244
|
+
is_progress_visible?: boolean;
|
|
245
|
+
/**
|
|
246
|
+
* Text inside the Main Button.
|
|
247
|
+
*/
|
|
248
|
+
text?: string;
|
|
249
|
+
/**
|
|
250
|
+
* The Main Button background color in `#RRGGBB` format.
|
|
251
|
+
*/
|
|
252
|
+
color?: string;
|
|
253
|
+
/**
|
|
254
|
+
* The Main Button text color in `#RRGGBB` format.
|
|
255
|
+
*/
|
|
256
|
+
text_color?: string;
|
|
257
|
+
}>;
|
|
258
|
+
/**
|
|
259
|
+
* Updates current state of Settings Button.
|
|
260
|
+
* @since v6.10
|
|
261
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-setup-settings-button
|
|
262
|
+
*/
|
|
263
|
+
web_app_setup_settings_button: CreateParams<{
|
|
264
|
+
/**
|
|
265
|
+
* Should the Settings Button be displayed.
|
|
266
|
+
*/
|
|
267
|
+
is_visible: boolean;
|
|
268
|
+
}>;
|
|
269
|
+
/**
|
|
270
|
+
* Inserts the bot's username and the specified inline query in the current chat's input field.
|
|
271
|
+
* Query may be empty, in which case only the bot's username will be inserted. The client prompts
|
|
272
|
+
* the user to choose a specific chat, then opens that chat and inserts the bot's username and
|
|
273
|
+
* the specified inline query in the input field.
|
|
274
|
+
* @since v6.7
|
|
275
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-switch-inline-query
|
|
276
|
+
*/
|
|
277
|
+
web_app_switch_inline_query: CreateParams<{
|
|
278
|
+
/**
|
|
279
|
+
* Text which should be inserted in the input after the current bot name. Max length is
|
|
280
|
+
* 256 symbols.
|
|
281
|
+
*/
|
|
282
|
+
query: string;
|
|
283
|
+
/**
|
|
284
|
+
* List of chat types which could be chosen to send the message. Could be empty list.
|
|
285
|
+
*/
|
|
286
|
+
chat_types: SwitchInlineQueryChatType[];
|
|
287
|
+
}>;
|
|
288
|
+
/**
|
|
289
|
+
* Generates haptic feedback event.
|
|
290
|
+
* @since v6.1
|
|
291
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#web-app-trigger-haptic-feedback
|
|
292
|
+
*/
|
|
293
|
+
web_app_trigger_haptic_feedback: CreateParams<AnyHapticFeedbackParams>;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Any Telegram Mini Apps known method name.
|
|
297
|
+
*/
|
|
298
|
+
export type MiniAppsMethodName = keyof MiniAppsMethods;
|
|
299
|
+
/**
|
|
300
|
+
* Returns parameters for specified post-available event.
|
|
301
|
+
*/
|
|
302
|
+
export type MiniAppsMethodParams<M extends MiniAppsMethodName> = MiniAppsMethods[M]['params'];
|
|
303
|
+
/**
|
|
304
|
+
* True if specified method accepts parameters.
|
|
305
|
+
*/
|
|
306
|
+
export type MiniAppsMethodAcceptParams<M extends MiniAppsMethodName> = Not<IsNever<Exclude<MiniAppsMethodParams<M>, undefined>>>;
|
|
307
|
+
/**
|
|
308
|
+
* Any post-available event name which does not require arguments.
|
|
309
|
+
*/
|
|
310
|
+
export type MiniAppsEmptyMethodName = {
|
|
311
|
+
[M in MiniAppsMethodName]: undefined extends MiniAppsMethodParams<M> ? M : never;
|
|
312
|
+
}[MiniAppsMethodName];
|
|
313
|
+
/**
|
|
314
|
+
* Any post-available event name which require arguments.
|
|
315
|
+
*/
|
|
316
|
+
export type MiniAppsNonEmptyMethodName = {
|
|
317
|
+
[M in MiniAppsMethodName]: MiniAppsMethodAcceptParams<M> extends true ? M : never;
|
|
318
|
+
}[MiniAppsMethodName];
|
|
319
|
+
/**
|
|
320
|
+
* Method names which have versioned params.
|
|
321
|
+
*/
|
|
322
|
+
export type MiniAppsMethodWithVersionedParams = {
|
|
323
|
+
[M in MiniAppsMethodName]: IsNever<MiniAppsMethods[M]['versionedParams']> extends true ? never : M;
|
|
324
|
+
}[MiniAppsMethodName];
|
|
325
|
+
/**
|
|
326
|
+
* Method parameters which appear only in the specific Telegram Mini Apps version.
|
|
327
|
+
*/
|
|
328
|
+
export type MiniAppsMethodVersionedParams<M extends MiniAppsMethodWithVersionedParams> = MiniAppsMethods[M]['versionedParams'];
|
|
329
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Describes the native popup.
|
|
3
|
+
*/
|
|
4
|
+
export interface PopupParams {
|
|
5
|
+
/**
|
|
6
|
+
* The text to be displayed in the popup title, 0-64 characters.
|
|
7
|
+
*/
|
|
8
|
+
title: string;
|
|
9
|
+
/**
|
|
10
|
+
* The message to be displayed in the body of the popup, 1-256 characters.
|
|
11
|
+
*/
|
|
12
|
+
message: string;
|
|
13
|
+
/**
|
|
14
|
+
* List of buttons to be displayed in the popup, 1-3 buttons.
|
|
15
|
+
*/
|
|
16
|
+
buttons: PopupButton[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Describes the native popup button.
|
|
20
|
+
* @see https://docs.telegram-mini-apps.com/platform/apps-communication/methods#popupbutton
|
|
21
|
+
*/
|
|
22
|
+
export type PopupButton = {
|
|
23
|
+
/**
|
|
24
|
+
* Identifier of the button, 0-64 characters.
|
|
25
|
+
*/
|
|
26
|
+
id: string;
|
|
27
|
+
} & ({
|
|
28
|
+
/**
|
|
29
|
+
* Type of the button:
|
|
30
|
+
* - `default`, a button with the default style;
|
|
31
|
+
* - `destructive`, a button with a style that indicates a destructive
|
|
32
|
+
* action (e.g. "Remove", "Delete", etc.).
|
|
33
|
+
*
|
|
34
|
+
* @default "default"
|
|
35
|
+
*/
|
|
36
|
+
type?: 'default' | 'destructive';
|
|
37
|
+
/**
|
|
38
|
+
* The text to be displayed on the button, 0-64 characters.
|
|
39
|
+
*/
|
|
40
|
+
text: string;
|
|
41
|
+
} | {
|
|
42
|
+
/**
|
|
43
|
+
* Type of the button:
|
|
44
|
+
* - `ok`, a button with the localized text "OK";
|
|
45
|
+
* - `close`, a button with the localized text "Close";
|
|
46
|
+
* - `cancel`, a button with the localized text "Cancel".
|
|
47
|
+
*/
|
|
48
|
+
type: 'ok' | 'close' | 'cancel';
|
|
49
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { MiniAppsEmptyMethodName, MiniAppsMethodParams, MiniAppsNonEmptyMethodName } from './methods.js';
|
|
2
|
+
interface PostEventOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Origin used while posting message. This option is only used in case,
|
|
5
|
+
* current environment is browser (Web version of Telegram) and could
|
|
6
|
+
* be used for test purposes.
|
|
7
|
+
* @default 'https://web.telegram.org'
|
|
8
|
+
*/
|
|
9
|
+
targetOrigin?: string;
|
|
10
|
+
}
|
|
11
|
+
export type PostEvent = typeof postEvent;
|
|
12
|
+
/**
|
|
13
|
+
* Sends event to native application which launched Mini App. This function
|
|
14
|
+
* accepts only events, which require arguments.
|
|
15
|
+
* @param eventType - event name.
|
|
16
|
+
* @param params - event parameters.
|
|
17
|
+
* @param options - posting options.
|
|
18
|
+
* @throws {Error} Bridge could not determine current environment and possible way to send event.
|
|
19
|
+
*/
|
|
20
|
+
export declare function postEvent<E extends MiniAppsNonEmptyMethodName>(eventType: E, params: MiniAppsMethodParams<E>, options?: PostEventOptions): void;
|
|
21
|
+
/**
|
|
22
|
+
* Sends event to native application which launched Mini App. This function
|
|
23
|
+
* accepts only events, which require arguments.
|
|
24
|
+
* @param eventType - event name.
|
|
25
|
+
* @param options - posting options.
|
|
26
|
+
* @throws {Error} Bridge could not determine current environment and possible way to send event.
|
|
27
|
+
*/
|
|
28
|
+
export declare function postEvent(eventType: MiniAppsEmptyMethodName, options?: PostEventOptions): void;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { And, If, IsNever } from '../types/index.js';
|
|
2
|
+
import { type MiniAppsEventHasParams, type MiniAppsEventName, type MiniAppsEventParams } from './events/index.js';
|
|
3
|
+
import { type MiniAppsEmptyMethodName, type MiniAppsMethodAcceptParams, type MiniAppsMethodName, type MiniAppsMethodParams, type MiniAppsNonEmptyMethodName, type PostEvent } from './methods/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Names of methods, which require passing "req_id" parameter.
|
|
6
|
+
*/
|
|
7
|
+
type MethodWithRequestId = {
|
|
8
|
+
[M in MiniAppsMethodName]: If<And<MiniAppsMethodAcceptParams<M>, MiniAppsMethodParams<M> extends {
|
|
9
|
+
req_id: string;
|
|
10
|
+
} ? true : false>, M, never>;
|
|
11
|
+
}[MiniAppsMethodName];
|
|
12
|
+
/**
|
|
13
|
+
* Names of events, which contain "req_id" parameter.
|
|
14
|
+
*/
|
|
15
|
+
type EventWithRequestId = {
|
|
16
|
+
[E in MiniAppsEventName]: If<And<MiniAppsEventHasParams<E>, MiniAppsEventParams<E> extends {
|
|
17
|
+
req_id: string;
|
|
18
|
+
} ? true : false>, E, never>;
|
|
19
|
+
}[MiniAppsEventName];
|
|
20
|
+
export interface RequestOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Bridge postEvent method.
|
|
23
|
+
* @default Global postEvent method.
|
|
24
|
+
*/
|
|
25
|
+
postEvent?: PostEvent;
|
|
26
|
+
/**
|
|
27
|
+
* Execution timeout.
|
|
28
|
+
*/
|
|
29
|
+
timeout?: number;
|
|
30
|
+
}
|
|
31
|
+
export interface RequestOptionsAdvanced<EventPayload> extends RequestOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Should return true in case, this event should be captured. If not specified,
|
|
34
|
+
* request is not skipping captured events.
|
|
35
|
+
*/
|
|
36
|
+
capture?: If<IsNever<EventPayload>, () => boolean, (payload: EventPayload) => boolean>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Calls specified TWA method and captures one of the specified events. Returns promise
|
|
40
|
+
* which will be resolved in case, event with specified in method request identifier
|
|
41
|
+
* was captured.
|
|
42
|
+
* @param method - method to execute.
|
|
43
|
+
* @param params - method parameters.
|
|
44
|
+
* @param event - event or events to listen.
|
|
45
|
+
* @param options - additional execution options.
|
|
46
|
+
*/
|
|
47
|
+
export declare function request<M extends MethodWithRequestId, E extends EventWithRequestId>(method: M, params: MiniAppsMethodParams<M>, event: E | E[], options?: RequestOptions): Promise<MiniAppsEventParams<E>>;
|
|
48
|
+
/**
|
|
49
|
+
* Calls specified TWA method and captures one of the specified events. Returns promise
|
|
50
|
+
* which will be resolved in case, specified event was captured.
|
|
51
|
+
* @param method - method to execute.
|
|
52
|
+
* @param event - event or events to listen.
|
|
53
|
+
* @param options - additional execution options.
|
|
54
|
+
*/
|
|
55
|
+
export declare function request<M extends MiniAppsEmptyMethodName, E extends MiniAppsEventName>(method: M, event: E | E[], options?: RequestOptionsAdvanced<MiniAppsEventParams<E>>): Promise<MiniAppsEventParams<E>>;
|
|
56
|
+
/**
|
|
57
|
+
* Calls specified TWA method and captures one of the specified events. Returns promise
|
|
58
|
+
* which will be resolved in case, specified event was captured.
|
|
59
|
+
* @param method - method to execute
|
|
60
|
+
* @param params - method parameters.
|
|
61
|
+
* @param event - event or events to listen
|
|
62
|
+
* @param options - additional execution options.
|
|
63
|
+
*/
|
|
64
|
+
export declare function request<M extends MiniAppsNonEmptyMethodName, E extends MiniAppsEventName>(method: M, params: MiniAppsMethodParams<M>, event: E | E[], options?: RequestOptionsAdvanced<MiniAppsEventParams<E>>): Promise<MiniAppsEventParams<E>>;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function which joins passed values with space following these rules:
|
|
3
|
+
* 1. If value is non-empty string, it will be added to output.
|
|
4
|
+
* 2. If value is object, only those keys will be added, which values are truthy.
|
|
5
|
+
* 3. All other values are ignored.
|
|
6
|
+
*
|
|
7
|
+
* You can find this function to similar one from package {@link https://www.npmjs.com/package/classnames|classnames}.
|
|
8
|
+
* @param values - values array.
|
|
9
|
+
*/
|
|
10
|
+
export declare function classNames(...values: any[]): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
type FilterUnion<U> = Exclude<U, number | string | null | undefined | any[] | boolean>;
|
|
2
|
+
/**
|
|
3
|
+
* Returns union keys removing those, which values are not strings.
|
|
4
|
+
*/
|
|
5
|
+
type UnionFilteredKeys<U> = U extends U ? {
|
|
6
|
+
[K in keyof U]: U[K] extends string ? K : never;
|
|
7
|
+
}[keyof U] : never;
|
|
8
|
+
/**
|
|
9
|
+
* Returns union required keys.
|
|
10
|
+
*/
|
|
11
|
+
type UnionRequiredKeys<U> = U extends U ? {
|
|
12
|
+
[K in UnionFilteredKeys<U>]-?: ({} extends {
|
|
13
|
+
[P in K]: U[K];
|
|
14
|
+
} ? never : K);
|
|
15
|
+
}[UnionFilteredKeys<U>] : never;
|
|
16
|
+
/**
|
|
17
|
+
* Returns union optional keys.
|
|
18
|
+
*/
|
|
19
|
+
type UnionOptionalKeys<U> = Exclude<UnionFilteredKeys<U>, UnionRequiredKeys<U>>;
|
|
20
|
+
type MergeClassNames<Tuple extends any[]> = Tuple[number] extends infer Union ? FilterUnion<Union> extends infer UnionFiltered ? {
|
|
21
|
+
[K in UnionRequiredKeys<UnionFiltered>]: string;
|
|
22
|
+
} & {
|
|
23
|
+
[K in UnionOptionalKeys<UnionFiltered>]?: string;
|
|
24
|
+
} : never : never;
|
|
25
|
+
/**
|
|
26
|
+
* Merges 2 sets of parameters. Function expects passing an array of objects with values, which
|
|
27
|
+
* could be passed to `classNames` function. As the result, it returns an object with keys
|
|
28
|
+
* from all objects with merged values.
|
|
29
|
+
* @see classNames
|
|
30
|
+
*/
|
|
31
|
+
export declare function mergeClassNames<T extends any[]>(...partials: T): MergeClassNames<T>;
|
|
32
|
+
export {};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { type PostEvent } from '
|
|
1
|
+
import { type PostEvent } from '../bridge/index.js';
|
|
2
|
+
import type { ClosingBehaviorEvents } from './types.js';
|
|
2
3
|
/**
|
|
3
4
|
* Component responsible for controlling current closing confirmation
|
|
4
5
|
* status.
|
|
5
6
|
*/
|
|
6
|
-
export declare class
|
|
7
|
+
export declare class ClosingBehavior {
|
|
7
8
|
private readonly postEvent;
|
|
8
9
|
private readonly ee;
|
|
9
10
|
private readonly state;
|
|
@@ -27,9 +28,9 @@ export declare class ClosingBehaviour {
|
|
|
27
28
|
/**
|
|
28
29
|
* Adds new event listener.
|
|
29
30
|
*/
|
|
30
|
-
on:
|
|
31
|
+
on: <E extends "change" | "change:isConfirmationNeeded">(event: E, listener: import('../event-emitter/index.js').EventListener<ClosingBehaviorEvents[E]>) => import('../event-emitter/index.js').RemoveEventListener;
|
|
31
32
|
/**
|
|
32
33
|
* Removes event listener.
|
|
33
34
|
*/
|
|
34
|
-
off:
|
|
35
|
+
off: <E extends "change" | "change:isConfirmationNeeded">(event: E, listener: import('../event-emitter/index.js').EventListener<ClosingBehaviorEvents[E]>) => void;
|
|
35
36
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { StateEvents } from '../state/index.js';
|
|
2
|
+
export interface ClosingBehaviorState {
|
|
3
|
+
isConfirmationNeeded: boolean;
|
|
4
|
+
}
|
|
5
|
+
export type ClosingBehaviorEvents = StateEvents<ClosingBehaviorState>;
|
|
6
|
+
export type ClosingBehaviorEventName = keyof ClosingBehaviorEvents;
|
|
7
|
+
export type ClosingBehaviorEventListener<E extends ClosingBehaviorEventName> = ClosingBehaviorEvents[E];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { postEvent as defaultPostEvent, type RequestOptions } from '
|
|
2
|
-
import type
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
1
|
+
import { postEvent as defaultPostEvent, type RequestOptions } 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
5
|
type WiredRequestOptions = Omit<RequestOptions, 'postEvent'>;
|
|
6
6
|
export declare class CloudStorage {
|
|
7
7
|
private readonly createRequestId;
|
|
@@ -15,13 +15,13 @@ export declare class CloudStorage {
|
|
|
15
15
|
*/
|
|
16
16
|
private invokeCustomMethod;
|
|
17
17
|
/**
|
|
18
|
-
* Deletes specified keys from the
|
|
19
|
-
* @param
|
|
18
|
+
* Deletes specified key or keys from the cloud storage.
|
|
19
|
+
* @param keyOrKeys - key or keys to delete.
|
|
20
20
|
* @param options - request execution options.
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
delete(keyOrKeys: string | string[], options?: WiredRequestOptions): Promise<void>;
|
|
23
23
|
/**
|
|
24
|
-
* Returns list of all keys presented in
|
|
24
|
+
* Returns list of all keys presented in the cloud storage.
|
|
25
25
|
* @param options - request execution options.
|
|
26
26
|
*/
|
|
27
27
|
getKeys(options?: WiredRequestOptions): Promise<string[]>;
|
|
@@ -31,17 +31,25 @@ export declare class CloudStorage {
|
|
|
31
31
|
* @param keys - keys list.
|
|
32
32
|
* @param options - request execution options.
|
|
33
33
|
*/
|
|
34
|
-
|
|
34
|
+
get<K extends string>(keys: K[], options?: WiredRequestOptions): Promise<Record<K, string>>;
|
|
35
|
+
/**
|
|
36
|
+
* Returns value of the specified key.
|
|
37
|
+
* @param key - cloud storage key.
|
|
38
|
+
* @param options - request execution options.
|
|
39
|
+
* @return Value of the specified key. In case, key was not created previously, function
|
|
40
|
+
* will return empty string.
|
|
41
|
+
*/
|
|
42
|
+
get(key: string, options?: WiredRequestOptions): Promise<string>;
|
|
35
43
|
/**
|
|
36
44
|
* Saves specified value by key.
|
|
37
45
|
* @param key - storage key.
|
|
38
46
|
* @param value - storage value.
|
|
39
47
|
* @param options - request execution options.
|
|
40
48
|
*/
|
|
41
|
-
|
|
49
|
+
set(key: string, value: string, options?: WiredRequestOptions): Promise<void>;
|
|
42
50
|
/**
|
|
43
51
|
* Checks if specified method is supported by current component.
|
|
44
52
|
*/
|
|
45
|
-
supports: SupportsFunc<'
|
|
53
|
+
supports: SupportsFunc<'delete' | 'get' | 'getKeys' | 'set'>;
|
|
46
54
|
}
|
|
47
55
|
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RGB } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Converts passed value to #RRGGBB format. Accepts following color formats:
|
|
4
|
+
* - `#RGB`
|
|
5
|
+
* - `#RRGGBB`
|
|
6
|
+
* - `rgb(1,2,3)`
|
|
7
|
+
* - `rgba(1,2,3,4)`
|
|
8
|
+
* @param value - value to convert.
|
|
9
|
+
* @throws {Error} Passed value does not satisfy any of known RGB formats.
|
|
10
|
+
*/
|
|
11
|
+
export declare function toRGB(value: string): RGB;
|