@tma.js/sdk 1.5.3 → 2.0.1

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.
Files changed (255) hide show
  1. package/dist/dts/bridge/events/event-emitter/createMiniAppsEventEmitter.d.ts +15 -0
  2. package/dist/dts/bridge/events/event-emitter/singleton.d.ts +8 -0
  3. package/dist/dts/bridge/events/event-handlers/cleanupEventHandlers.d.ts +4 -0
  4. package/dist/dts/bridge/events/event-handlers/defineEventHandlers.d.ts +6 -0
  5. package/dist/dts/bridge/events/event-handlers/emitMiniAppsEvent.d.ts +9 -0
  6. package/dist/dts/bridge/events/{off.d.ts → listening/off.d.ts} +3 -2
  7. package/dist/dts/bridge/events/listening/on.d.ts +12 -0
  8. package/dist/dts/bridge/events/listening/subscribe.d.ts +9 -0
  9. package/dist/dts/bridge/events/listening/unsubscribe.d.ts +7 -0
  10. package/dist/dts/bridge/events/types.d.ts +294 -2
  11. package/dist/dts/bridge/methods/createPostEvent.d.ts +7 -4
  12. package/dist/dts/bridge/methods/postEvent.d.ts +24 -15
  13. package/dist/dts/bridge/methods/{custom-methods.d.ts → types/custom-methods.d.ts} +2 -1
  14. package/dist/dts/bridge/methods/types/index.d.ts +4 -0
  15. package/dist/dts/bridge/methods/{methods.d.ts → types/methods.d.ts} +70 -17
  16. package/dist/dts/{globals.d.ts → bridge/target-origin.d.ts} +0 -9
  17. package/dist/dts/bridge/{invokeCustomMethod.d.ts → utils/invokeCustomMethod.d.ts} +7 -2
  18. package/dist/dts/bridge/utils/request.d.ts +35 -0
  19. package/dist/dts/classes/State/State.d.ts +46 -0
  20. package/dist/dts/classes/State/types.d.ts +29 -0
  21. package/dist/dts/classes/WithStateUtils.d.ts +18 -0
  22. package/dist/dts/classes/WithSupports.d.ts +19 -0
  23. package/dist/dts/classes/WithSupportsAndStateUtils.d.ts +24 -0
  24. package/dist/dts/classes/WithSupportsAndTrackableState.d.ts +16 -0
  25. package/dist/dts/classes/WithTrackableState.d.ts +16 -0
  26. package/dist/dts/classnames/mergeClassNames.d.ts +2 -1
  27. package/dist/dts/colors/isRGB.d.ts +2 -1
  28. package/dist/dts/colors/isRGBShort.d.ts +2 -1
  29. package/dist/dts/colors/toRGB.d.ts +2 -1
  30. package/dist/dts/components/BackButton/BackButton.d.ts +41 -0
  31. package/dist/dts/components/BackButton/initBackButton.d.ts +7 -0
  32. package/dist/dts/components/BackButton/types.d.ts +25 -0
  33. package/dist/dts/components/BiometryManager/BiometryManager.d.ts +61 -0
  34. package/dist/dts/components/BiometryManager/formatEvent.d.ts +34 -0
  35. package/dist/dts/components/BiometryManager/initBiometryManager.d.ts +7 -0
  36. package/dist/dts/components/BiometryManager/requestBiometryInfo.d.ts +8 -0
  37. package/dist/dts/components/BiometryManager/types.d.ts +40 -0
  38. package/dist/dts/components/ClosingBehavior/ClosingBehavior.d.ts +26 -0
  39. package/dist/dts/components/ClosingBehavior/initClosingBehavior.d.ts +7 -0
  40. package/dist/dts/components/{closing-behavior → ClosingBehavior}/types.d.ts +14 -1
  41. package/dist/dts/components/{cloud-storage → CloudStorage}/CloudStorage.d.ts +11 -11
  42. package/dist/dts/components/CloudStorage/initCloudStorage.d.ts +7 -0
  43. package/dist/dts/components/{haptic-feedback → HapticFeedback}/HapticFeedback.d.ts +9 -13
  44. package/dist/dts/components/HapticFeedback/initHapticFeedback.d.ts +7 -0
  45. package/dist/dts/components/{init-data → InitData}/InitData.d.ts +4 -2
  46. package/dist/dts/components/InitData/initInitData.d.ts +7 -0
  47. package/dist/dts/components/{init-data → InitData}/parseInitData.d.ts +2 -1
  48. package/dist/dts/components/InitData/parsers/chat.d.ts +3 -0
  49. package/dist/dts/components/InitData/parsers/initData.d.ts +7 -0
  50. package/dist/dts/components/InitData/parsers/user.d.ts +3 -0
  51. package/dist/dts/components/{init-data → InitData}/types.d.ts +2 -3
  52. package/dist/dts/components/Invoice/Invoice.d.ts +31 -0
  53. package/dist/dts/components/Invoice/initInvoice.d.ts +7 -0
  54. package/dist/dts/components/{invoice → Invoice}/types.d.ts +14 -1
  55. package/dist/dts/components/MainButton/MainButton.d.ts +106 -0
  56. package/dist/dts/components/MainButton/initMainButton.d.ts +7 -0
  57. package/dist/dts/components/MainButton/types.d.ts +40 -0
  58. package/dist/dts/components/{mini-app → MiniApp}/MiniApp.d.ts +29 -43
  59. package/dist/dts/components/MiniApp/initMiniApp.d.ts +7 -0
  60. package/dist/dts/components/MiniApp/parsing/contact.d.ts +7 -0
  61. package/dist/dts/components/MiniApp/types.d.ts +53 -0
  62. package/dist/dts/components/Popup/Popup.d.ts +30 -0
  63. package/dist/dts/components/Popup/initPopup.d.ts +7 -0
  64. package/dist/dts/components/{popup → Popup}/preparePopupParams.d.ts +3 -2
  65. package/dist/dts/components/{popup → Popup}/types.d.ts +2 -1
  66. package/dist/dts/components/QRScanner/QRScanner.d.ts +28 -0
  67. package/dist/dts/components/QRScanner/initQRScanner.d.ts +7 -0
  68. package/dist/dts/components/{qr-scanner → QRScanner}/types.d.ts +14 -1
  69. package/dist/dts/components/SettingsButton/SettingsButton.d.ts +37 -0
  70. package/dist/dts/components/SettingsButton/initSettingsButton.d.ts +7 -0
  71. package/dist/dts/components/{settings-button → SettingsButton}/types.d.ts +18 -3
  72. package/dist/dts/components/ThemeParams/ThemeParams.d.ts +53 -0
  73. package/dist/dts/components/ThemeParams/initThemeParams.d.ts +7 -0
  74. package/dist/dts/components/ThemeParams/keys.d.ts +11 -0
  75. package/dist/dts/components/{theme-params → ThemeParams/parsing}/parseThemeParams.d.ts +2 -1
  76. package/dist/dts/components/{theme-params → ThemeParams/parsing}/serializeThemeParams.d.ts +2 -1
  77. package/dist/dts/components/ThemeParams/parsing/themeParams.d.ts +4 -0
  78. package/dist/dts/components/ThemeParams/requestThemeParams.d.ts +8 -0
  79. package/dist/dts/components/ThemeParams/types.d.ts +29 -0
  80. package/dist/dts/components/{utils → Utils}/Utils.d.ts +10 -12
  81. package/dist/dts/components/Utils/initUtils.d.ts +7 -0
  82. package/dist/dts/components/Viewport/Viewport.d.ts +77 -0
  83. package/dist/dts/components/Viewport/initViewport.d.ts +8 -0
  84. package/dist/dts/components/Viewport/initViewportFromRequest.d.ts +10 -0
  85. package/dist/dts/components/{viewport → Viewport}/requestViewport.d.ts +3 -2
  86. package/dist/dts/components/Viewport/types.d.ts +35 -0
  87. package/dist/dts/css-vars/bindMiniAppCSSVars.d.ts +29 -0
  88. package/dist/dts/css-vars/bindThemeParamsCSSVars.d.ts +29 -0
  89. package/dist/dts/css-vars/bindViewportCSSVars.d.ts +32 -0
  90. package/dist/dts/{css → css-vars}/setCSSVar.d.ts +1 -1
  91. package/dist/dts/debug/debug.d.ts +14 -0
  92. package/dist/dts/{bridge/env → env}/hasExternalNotify.d.ts +5 -7
  93. package/dist/dts/{bridge/env → env}/hasWebviewProxy.d.ts +5 -7
  94. package/dist/dts/env/initWeb.d.ts +11 -0
  95. package/dist/dts/env/isSSR.d.ts +4 -0
  96. package/dist/dts/{misc → env}/isTMA.d.ts +1 -1
  97. package/dist/dts/errors/SDKError.d.ts +9 -0
  98. package/dist/dts/errors/createError.d.ts +10 -0
  99. package/dist/dts/errors/errors.d.ts +53 -0
  100. package/dist/dts/errors/isSDKError.d.ts +7 -0
  101. package/dist/dts/errors/isSDKErrorOfType.d.ts +8 -0
  102. package/dist/dts/{event-emitter → events/event-emitter}/EventEmitter.d.ts +20 -30
  103. package/dist/dts/{event-emitter → events/event-emitter}/types.d.ts +10 -9
  104. package/dist/dts/events/onWindow.d.ts +10 -0
  105. package/dist/dts/events/types.d.ts +6 -0
  106. package/dist/dts/index.d.ts +114 -92
  107. package/dist/dts/index.low-level.d.ts +41 -0
  108. package/dist/dts/launch-params/parseLaunchParams.d.ts +2 -1
  109. package/dist/dts/launch-params/retrieveFromLocation.d.ts +2 -1
  110. package/dist/dts/launch-params/retrieveFromPerformance.d.ts +3 -3
  111. package/dist/dts/launch-params/{storage.d.ts → retrieveFromStorage.d.ts} +2 -6
  112. package/dist/dts/launch-params/retrieveFromUrl.d.ts +2 -1
  113. package/dist/dts/launch-params/retrieveLaunchParams.d.ts +2 -1
  114. package/dist/dts/launch-params/saveToStorage.d.ts +7 -0
  115. package/dist/dts/launch-params/serializeLaunchParams.d.ts +2 -1
  116. package/dist/dts/launch-params/types.d.ts +12 -13
  117. package/dist/dts/logger/Logger.d.ts +9 -18
  118. package/dist/dts/misc/createComponentInitFn/createComponentInitFn.d.ts +15 -0
  119. package/dist/dts/misc/createComponentInitFn/types.d.ts +47 -0
  120. package/dist/dts/misc/createSingleton.d.ts +15 -0
  121. package/dist/dts/misc/objectFromKeys.d.ts +6 -0
  122. package/dist/dts/navigation/BasicNavigator/BasicNavigator.d.ts +118 -0
  123. package/dist/dts/navigation/BasicNavigator/prepareItem.d.ts +8 -0
  124. package/dist/dts/navigation/BasicNavigator/types.d.ts +37 -0
  125. package/dist/dts/navigation/BrowserNavigator/BrowserNavigator.d.ts +198 -0
  126. package/dist/dts/navigation/BrowserNavigator/basicItemToBrowser.d.ts +7 -0
  127. package/dist/dts/navigation/BrowserNavigator/createBrowserNavigatorFromLocation.d.ts +4 -0
  128. package/dist/dts/navigation/BrowserNavigator/prepareItem.d.ts +25 -0
  129. package/dist/dts/navigation/BrowserNavigator/types.d.ts +63 -0
  130. package/dist/dts/navigation/createSafeURL.d.ts +7 -0
  131. package/dist/dts/navigation/getHash.d.ts +2 -1
  132. package/dist/dts/navigation/getPathname.d.ts +7 -0
  133. package/dist/dts/navigation/initNavigator.d.ts +9 -0
  134. package/dist/dts/navigation/urlToPath.d.ts +7 -0
  135. package/dist/dts/parsing/ArrayParser/ArrayParser.d.ts +17 -0
  136. package/dist/dts/parsing/ArrayParser/types.d.ts +12 -0
  137. package/dist/dts/parsing/ValueParser/ValueParser.d.ts +17 -0
  138. package/dist/dts/parsing/{ValueParser.d.ts → ValueParser/types.d.ts} +6 -14
  139. package/dist/dts/parsing/createTypeError.d.ts +6 -0
  140. package/dist/dts/parsing/createValueParserGenerator.d.ts +3 -2
  141. package/dist/dts/parsing/parseBySchema.d.ts +2 -1
  142. package/dist/dts/parsing/parsers/array.d.ts +3 -2
  143. package/dist/dts/parsing/parsers/boolean.d.ts +2 -1
  144. package/dist/dts/parsing/parsers/date.d.ts +2 -1
  145. package/dist/dts/parsing/parsers/json.d.ts +3 -2
  146. package/dist/dts/parsing/parsers/number.d.ts +2 -1
  147. package/dist/dts/parsing/parsers/rgb.d.ts +3 -2
  148. package/dist/dts/parsing/parsers/searchParams.d.ts +3 -2
  149. package/dist/dts/parsing/parsers/string.d.ts +2 -1
  150. package/dist/dts/{init/creators → request-id}/createRequestIdGenerator.d.ts +3 -2
  151. package/dist/dts/{types/request-id.d.ts → request-id/types.d.ts} +1 -1
  152. package/dist/dts/storage/storage.d.ts +42 -0
  153. package/dist/dts/supports/createSupportsFn.d.ts +12 -0
  154. package/dist/dts/supports/{createSupportsParamFunc.d.ts → createSupportsParamFn.d.ts} +5 -4
  155. package/dist/dts/supports/supports.d.ts +3 -2
  156. package/dist/dts/supports/types.d.ts +1 -1
  157. package/dist/dts/timeout/createTimeoutError.d.ts +7 -0
  158. package/dist/dts/timeout/sleep.d.ts +1 -1
  159. package/dist/dts/timeout/withTimeout.d.ts +1 -2
  160. package/dist/dts/types/index.d.ts +6 -0
  161. package/dist/dts/types/methods.d.ts +2 -1
  162. package/dist/dts/types/misc.d.ts +12 -0
  163. package/dist/dts/types/utils.d.ts +16 -0
  164. package/dist/dts/version/compareVersions.d.ts +2 -1
  165. package/dist/index.cjs +2 -1
  166. package/dist/index.cjs.map +1 -0
  167. package/dist/index.iife.js +2 -1
  168. package/dist/index.iife.js.map +1 -0
  169. package/dist/index.js +3001 -0
  170. package/dist/index.js.map +1 -0
  171. package/dist/index.low-level.iife.js +2 -0
  172. package/dist/index.low-level.iife.js.map +1 -0
  173. package/package.json +7 -9
  174. package/dist/dts/bridge/errors/MethodUnsupportedError.d.ts +0 -8
  175. package/dist/dts/bridge/errors/ParameterUnsupportedError.d.ts +0 -8
  176. package/dist/dts/bridge/events/createEmitter.d.ts +0 -6
  177. package/dist/dts/bridge/events/events.d.ts +0 -140
  178. package/dist/dts/bridge/events/on.d.ts +0 -9
  179. package/dist/dts/bridge/events/onTelegramEvent.d.ts +0 -7
  180. package/dist/dts/bridge/events/once.d.ts +0 -8
  181. package/dist/dts/bridge/events/parsers/clipboardTextReceived.d.ts +0 -13
  182. package/dist/dts/bridge/events/parsers/customMethodInvoked.d.ts +0 -16
  183. package/dist/dts/bridge/events/parsers/invoiceClosed.d.ts +0 -12
  184. package/dist/dts/bridge/events/parsers/phoneRequested.d.ts +0 -8
  185. package/dist/dts/bridge/events/parsers/popupClosed.d.ts +0 -8
  186. package/dist/dts/bridge/events/parsers/qrTextReceived.d.ts +0 -7
  187. package/dist/dts/bridge/events/parsers/theme-changed.d.ts +0 -42
  188. package/dist/dts/bridge/events/parsers/viewportChanged.d.ts +0 -19
  189. package/dist/dts/bridge/events/parsers/writeAccessRequested.d.ts +0 -8
  190. package/dist/dts/bridge/events/singletonEmitter.d.ts +0 -6
  191. package/dist/dts/bridge/events/subscribe.d.ts +0 -8
  192. package/dist/dts/bridge/events/unsubscribe.d.ts +0 -6
  193. package/dist/dts/bridge/request.d.ts +0 -54
  194. package/dist/dts/components/back-button/BackButton.d.ts +0 -47
  195. package/dist/dts/components/back-button/types.d.ts +0 -10
  196. package/dist/dts/components/closing-behavior/ClosingBehavior.d.ts +0 -39
  197. package/dist/dts/components/init-data/chatParser.d.ts +0 -6
  198. package/dist/dts/components/init-data/initDataParser.d.ts +0 -6
  199. package/dist/dts/components/init-data/userParser.d.ts +0 -6
  200. package/dist/dts/components/invoice/Invoice.d.ts +0 -47
  201. package/dist/dts/components/main-button/MainButton.d.ts +0 -104
  202. package/dist/dts/components/main-button/types.d.ts +0 -20
  203. package/dist/dts/components/mini-app/contactParser.d.ts +0 -2
  204. package/dist/dts/components/mini-app/types.d.ts +0 -32
  205. package/dist/dts/components/popup/Popup.d.ts +0 -48
  206. package/dist/dts/components/qr-scanner/QRScanner.d.ts +0 -44
  207. package/dist/dts/components/settings-button/SettingsButton.d.ts +0 -42
  208. package/dist/dts/components/theme-params/ThemeParams.d.ts +0 -66
  209. package/dist/dts/components/theme-params/keys.d.ts +0 -11
  210. package/dist/dts/components/theme-params/requestThemeParams.d.ts +0 -7
  211. package/dist/dts/components/theme-params/themeParamsParser.d.ts +0 -3
  212. package/dist/dts/components/theme-params/types.d.ts +0 -14
  213. package/dist/dts/components/viewport/Viewport.d.ts +0 -90
  214. package/dist/dts/components/viewport/isStableViewportPlatform.d.ts +0 -7
  215. package/dist/dts/components/viewport/types.d.ts +0 -18
  216. package/dist/dts/components/viewport/utils.d.ts +0 -5
  217. package/dist/dts/css/bindMiniAppCSSVars.d.ts +0 -16
  218. package/dist/dts/css/bindThemeCSSVars.d.ts +0 -12
  219. package/dist/dts/css/bindViewportCSSVars.d.ts +0 -20
  220. package/dist/dts/init/catchCustomStyles.d.ts +0 -4
  221. package/dist/dts/init/creators/createBackButton.d.ts +0 -10
  222. package/dist/dts/init/creators/createClosingBehavior.d.ts +0 -9
  223. package/dist/dts/init/creators/createMainButton.d.ts +0 -12
  224. package/dist/dts/init/creators/createMiniApp.d.ts +0 -16
  225. package/dist/dts/init/creators/createSettingsButton.d.ts +0 -10
  226. package/dist/dts/init/creators/createThemeParams.d.ts +0 -7
  227. package/dist/dts/init/creators/createViewport.d.ts +0 -11
  228. package/dist/dts/init/css/processCSSVarsOption.d.ts +0 -12
  229. package/dist/dts/init/init.d.ts +0 -9
  230. package/dist/dts/init/types.d.ts +0 -85
  231. package/dist/dts/launch-params/launchParamsParser.d.ts +0 -6
  232. package/dist/dts/launch-params/retrieveLaunchData.d.ts +0 -7
  233. package/dist/dts/navigation/HashNavigator/HashNavigator.d.ts +0 -46
  234. package/dist/dts/navigation/HashNavigator/types.d.ts +0 -33
  235. package/dist/dts/navigation/Navigator/Navigator.d.ts +0 -104
  236. package/dist/dts/navigation/Navigator/types.d.ts +0 -44
  237. package/dist/dts/parsing/ArrayValueParser.d.ts +0 -18
  238. package/dist/dts/parsing/ParseError.d.ts +0 -22
  239. package/dist/dts/parsing/ParseSchemaFieldError.d.ts +0 -17
  240. package/dist/dts/parsing/unexpectedTypeError.d.ts +0 -4
  241. package/dist/dts/state/State.d.ts +0 -28
  242. package/dist/dts/state/types.d.ts +0 -27
  243. package/dist/dts/storage.d.ts +0 -50
  244. package/dist/dts/supports/createSupportsFunc.d.ts +0 -10
  245. package/dist/dts/timeout/TimeoutError.d.ts +0 -3
  246. package/dist/dts/timeout/isTimeoutError.d.ts +0 -6
  247. package/dist/index.mjs +0 -2813
  248. /package/dist/dts/bridge/methods/{haptic.d.ts → types/haptic.d.ts} +0 -0
  249. /package/dist/dts/bridge/methods/{popup.d.ts → types/popup.d.ts} +0 -0
  250. /package/dist/dts/bridge/{captureSameReq.d.ts → utils/captureSameReq.d.ts} +0 -0
  251. /package/dist/dts/{misc → env}/isIframe.d.ts +0 -0
  252. /package/dist/dts/navigation/{HashNavigator/drop.d.ts → drop.d.ts} +0 -0
  253. /package/dist/dts/{misc → navigation}/getFirstNavigationEntry.d.ts +0 -0
  254. /package/dist/dts/navigation/{HashNavigator/go.d.ts → go.d.ts} +0 -0
  255. /package/dist/dts/{misc → navigation}/isPageReload.d.ts +0 -0
@@ -1,42 +0,0 @@
1
- import type { RGB } from '../../../colors/types.js';
2
- export interface ThemeChangedPayload {
3
- /**
4
- * Map where the key is a theme stylesheet key and value is the corresponding color in
5
- * `#RRGGBB` format.
6
- */
7
- theme_params: {
8
- /**
9
- * @since v6.10
10
- */
11
- accent_text_color?: RGB;
12
- bg_color?: RGB;
13
- button_color?: RGB;
14
- button_text_color?: RGB;
15
- /**
16
- * @since v6.10
17
- */
18
- destructive_text_color?: RGB;
19
- /**
20
- * @since v6.10
21
- */
22
- header_bg_color?: RGB;
23
- hint_color?: RGB;
24
- link_color?: RGB;
25
- secondary_bg_color?: RGB;
26
- /**
27
- * @since v6.10
28
- */
29
- section_bg_color?: RGB;
30
- /**
31
- * @since v6.10
32
- */
33
- section_header_text_color?: RGB;
34
- /**
35
- * @since v6.10
36
- */
37
- subtitle_text_color?: RGB;
38
- text_color?: RGB;
39
- [key: string]: RGB | undefined;
40
- };
41
- }
42
- export declare function themeChanged(): import("../../../parsing/ValueParser.js").ValueParser<ThemeChangedPayload, false>;
@@ -1,19 +0,0 @@
1
- export interface ViewportChangedPayload {
2
- /**
3
- * The viewport height.
4
- */
5
- height: number;
6
- /**
7
- * The viewport width.
8
- */
9
- width: number;
10
- /**
11
- * Is the viewport currently expanded.
12
- */
13
- is_expanded: boolean;
14
- /**
15
- * Is the viewport current state stable and not going to change in the next moment.
16
- */
17
- is_state_stable: boolean;
18
- }
19
- export declare function viewportChanged(): import("../../../parsing/ValueParser.js").ValueParser<ViewportChangedPayload, false>;
@@ -1,8 +0,0 @@
1
- export type WriteAccessRequestedStatus = 'allowed' | string;
2
- export interface WriteAccessRequestedPayload {
3
- /**
4
- * Request status.
5
- */
6
- status: WriteAccessRequestedStatus;
7
- }
8
- export declare function writeAccessRequested(): import("../../../parsing/ValueParser.js").ValueParser<WriteAccessRequestedPayload, false>;
@@ -1,6 +0,0 @@
1
- import type { MiniAppsEventEmitter } from './events.js';
2
- /**
3
- * Returns singleton instance of bridge EventEmitter. Also, defines
4
- * Telegram event handlers.
5
- */
6
- export declare function singletonEmitter(): MiniAppsEventEmitter;
@@ -1,8 +0,0 @@
1
- import type { MiniAppsGlobalEventListener } from './events.js';
2
- import type { RemoveListenerFn } from './types.js';
3
- /**
4
- * Subscribes to all events sent from the native Telegram application.
5
- * Returns function used to remove added event listener.
6
- * @param listener - event listener.
7
- */
8
- export declare function subscribe(listener: MiniAppsGlobalEventListener): RemoveListenerFn;
@@ -1,6 +0,0 @@
1
- import type { MiniAppsGlobalEventListener } from './events.js';
2
- /**
3
- * Removes global event listener.
4
- * @param listener - event listener.
5
- */
6
- export declare function unsubscribe(listener: MiniAppsGlobalEventListener): void;
@@ -1,54 +0,0 @@
1
- import type { MiniAppsEventName, MiniAppsEventParams } from './events/events.js';
2
- import type { MiniAppsEmptyMethodName, MiniAppsMethodName, MiniAppsMethodParams, MiniAppsNonEmptyMethodName } from './methods/methods.js';
3
- import type { If } from '../types/logical.js';
4
- import type { ExecuteWithOptions } from '../types/methods.js';
5
- import type { IsNever } from '../types/utils.js';
6
- /**
7
- * Simple `request` method options.
8
- */
9
- export type RequestSimpleOptions<Method extends MiniAppsMethodName> = Omit<RequestCompleteOptions<Method, any>, 'method' | 'event'>;
10
- /**
11
- * Complete `request` method options.
12
- */
13
- export type RequestCompleteOptions<Method extends MiniAppsMethodName, Event extends MiniAppsEventName> = {
14
- /**
15
- * Mini Apps method name.
16
- */
17
- method: Method;
18
- /**
19
- * One or many tracked Mini Apps events.
20
- */
21
- event: Event | Event[];
22
- /**
23
- * Should return true in case, this event should be captured. If not specified,
24
- * request is not skipping captured events.
25
- */
26
- capture?: If<IsNever<MiniAppsEventParams<Event>>, () => boolean, (payload: MiniAppsEventParams<Event>) => boolean>;
27
- } & ExecuteWithOptions & If<IsNever<MiniAppsMethodParams<Method>>, {}, {
28
- /**
29
- * List of method parameters.
30
- */
31
- params: MiniAppsMethodParams<Method>;
32
- }>;
33
- /**
34
- * Calls specified Mini Apps method and captures one of the specified events. Returns promise
35
- * which will be resolved in case, specified event was captured.
36
- * @param options - method options.
37
- */
38
- export declare function request<Method extends MiniAppsEmptyMethodName, Event extends MiniAppsEventName>(options: RequestCompleteOptions<Method, Event>): Promise<MiniAppsEventParams<Event>>;
39
- /**
40
- * Calls specified Mini Apps method and captures one of the specified events. Returns promise
41
- * which will be resolved in case, specified event was captured.
42
- * @param method - method name.
43
- * @param eventOrEvents - tracked event or events.
44
- * @param options - method options.
45
- */
46
- export declare function request<Method extends MiniAppsNonEmptyMethodName, Event extends MiniAppsEventName>(method: Method, eventOrEvents: Event | Event[], options: RequestSimpleOptions<Method>): Promise<MiniAppsEventParams<Event>>;
47
- /**
48
- * Calls specified Mini Apps method and captures one of the specified events. Returns promise
49
- * which will be resolved in case, specified event was captured.
50
- * @param method - method name.
51
- * @param eventOrEvents - tracked event or events.
52
- * @param options - method options.
53
- */
54
- export declare function request<Method extends MiniAppsEmptyMethodName, Event extends MiniAppsEventName>(method: Method, eventOrEvents: Event | Event[], options?: RequestSimpleOptions<Method>): Promise<MiniAppsEventParams<Event>>;
@@ -1,47 +0,0 @@
1
- import type { BackButtonEvents } from './types.js';
2
- import type { PostEvent } from '../../bridge/methods/postEvent.js';
3
- import { EventEmitter } from '../../event-emitter/EventEmitter.js';
4
- import type { SupportsFunc } from '../../supports/types.js';
5
- import type { Version } from '../../version/types.js';
6
- type Emitter = EventEmitter<BackButtonEvents>;
7
- /**
8
- * Class which controls the back button displayed in the header of the Mini App in the Telegram
9
- * interface. It is mostly used in case, when you want to provide a way to go bach in routing
10
- * history or "rollback" some action.
11
- */
12
- export declare class BackButton {
13
- private readonly postEvent;
14
- private readonly ee;
15
- private readonly state;
16
- constructor(isVisible: boolean, version: Version, postEvent?: PostEvent);
17
- private set isVisible(value);
18
- /**
19
- * True if BackButton is currently visible.
20
- */
21
- get isVisible(): boolean;
22
- /**
23
- * Hides the BackButton.
24
- */
25
- hide(): void;
26
- /**
27
- * Adds event listener.
28
- * @param event - event name.
29
- * @param listener - event listener.
30
- */
31
- on: Emitter['on'];
32
- /**
33
- * Removes event listener.
34
- * @param event - event name.
35
- * @param listener - event listener.
36
- */
37
- off: Emitter['off'];
38
- /**
39
- * Shows the BackButton.
40
- */
41
- show(): void;
42
- /**
43
- * Checks if specified method is supported by current component.
44
- */
45
- supports: SupportsFunc<'show' | 'hide'>;
46
- }
47
- export {};
@@ -1,10 +0,0 @@
1
- import type { MiniAppsEventListener } from '../../bridge/events/events.js';
2
- import type { StateEvents } from '../../state/types.js';
3
- export interface BackButtonState {
4
- isVisible: boolean;
5
- }
6
- export interface BackButtonEvents extends StateEvents<BackButtonState> {
7
- click: MiniAppsEventListener<'main_button_pressed'>;
8
- }
9
- export type BackButtonEventName = keyof BackButtonEvents;
10
- export type BackButtonEventListener<E extends BackButtonEventName> = BackButtonEvents[E];
@@ -1,39 +0,0 @@
1
- import type { ClosingBehaviorEvents } from './types.js';
2
- import type { PostEvent } from '../../bridge/methods/postEvent.js';
3
- import { EventEmitter } from '../../event-emitter/EventEmitter.js';
4
- type Emitter = EventEmitter<ClosingBehaviorEvents>;
5
- /**
6
- * Component responsible for controlling current closing confirmation
7
- * status.
8
- */
9
- export declare class ClosingBehavior {
10
- private readonly postEvent;
11
- private readonly ee;
12
- private readonly state;
13
- constructor(isConfirmationNeeded: boolean, postEvent?: PostEvent);
14
- private set isConfirmationNeeded(value);
15
- /**
16
- * Returns true, if the confirmation dialog enabled while the user is trying
17
- * to close the Mini App.
18
- */
19
- get isConfirmationNeeded(): boolean;
20
- /**
21
- * Disables the confirmation dialog while the user is trying to close the
22
- * Mini App.
23
- */
24
- disableConfirmation(): void;
25
- /**
26
- * Enables the confirmation dialog while the user is trying to close the
27
- * Mini App.
28
- */
29
- enableConfirmation(): void;
30
- /**
31
- * Adds new event listener.
32
- */
33
- on: Emitter['on'];
34
- /**
35
- * Removes event listener.
36
- */
37
- off: Emitter['off'];
38
- }
39
- export {};
@@ -1,6 +0,0 @@
1
- import type { Chat } from './types.js';
2
- import type { ValueParser } from '../../parsing/ValueParser.js';
3
- /**
4
- * Returns parser used to parse chat data.
5
- */
6
- export declare function chatParser(): ValueParser<Chat, false>;
@@ -1,6 +0,0 @@
1
- import type { InitDataParsed } from './types.js';
2
- import type { ValueParser } from '../../parsing/ValueParser.js';
3
- /**
4
- * Returns parser used to parse init data, presented as search params.
5
- */
6
- export declare function initDataParser(): ValueParser<InitDataParsed, false>;
@@ -1,6 +0,0 @@
1
- import type { User } from './types.js';
2
- import type { ValueParser } from '../../parsing/ValueParser.js';
3
- /**
4
- * Returns parser used to parse user data.
5
- */
6
- export declare function userParser(): ValueParser<User, false>;
@@ -1,47 +0,0 @@
1
- import type { InvoiceEvents } from './types.js';
2
- import type { InvoiceStatus } from '../../bridge/events/parsers/invoiceClosed.js';
3
- import type { PostEvent } from '../../bridge/methods/postEvent.js';
4
- import { EventEmitter } from '../../event-emitter/EventEmitter.js';
5
- import type { SupportsFunc } from '../../supports/types.js';
6
- import type { Version } from '../../version/types.js';
7
- type Emitter = EventEmitter<InvoiceEvents>;
8
- /**
9
- * Controls currently displayed invoice.
10
- */
11
- export declare class Invoice {
12
- private readonly postEvent;
13
- private readonly ee;
14
- private readonly state;
15
- constructor(version: Version, postEvent?: PostEvent);
16
- private set isOpened(value);
17
- /**
18
- * True if invoice is currently opened.
19
- */
20
- get isOpened(): boolean;
21
- /**
22
- * Adds new event listener.
23
- */
24
- on: Emitter['on'];
25
- /**
26
- * Removes event listener.
27
- */
28
- off: Emitter['off'];
29
- /**
30
- * Opens an invoice using its slug.
31
- * @param slug - invoice slug.
32
- * @throws {Error} Invoice is already opened.
33
- */
34
- open(slug: string): Promise<InvoiceStatus>;
35
- /**
36
- * Opens an invoice using its url. It expects passing link in full format, with hostname "t.me".
37
- * @param url - invoice URL.
38
- * @param type - value type.
39
- * @throws {Error} Invoice is already opened.
40
- */
41
- open(url: string, type: 'url'): Promise<InvoiceStatus>;
42
- /**
43
- * Checks if specified method is supported by current component.
44
- */
45
- supports: SupportsFunc<'open'>;
46
- }
47
- export {};
@@ -1,104 +0,0 @@
1
- import type { MainButtonEvents, MainButtonParams, MainButtonProps } from './types.js';
2
- import type { RGB } from '../../colors/types.js';
3
- import { EventEmitter } from '../../event-emitter/EventEmitter.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 {};
@@ -1,20 +0,0 @@
1
- import type { PostEvent } from '../../bridge/methods/postEvent.js';
2
- import type { RGB } from '../../colors/types.js';
3
- import type { StateEvents } from '../../state/types.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];
@@ -1,2 +0,0 @@
1
- import type { RequestedContact } from './types.js';
2
- export declare const contactParser: import("../../parsing/ValueParser.js").ValueParser<RequestedContact, false>;
@@ -1,32 +0,0 @@
1
- import type { HeaderColorKey } from '../../bridge/methods/methods.js';
2
- import type { PostEvent } from '../../bridge/methods/postEvent.js';
3
- import type { RGB } from '../../colors/types.js';
4
- import type { StateEvents } from '../../state/types.js';
5
- import type { CreateRequestIdFunc } from '../../types/request-id.js';
6
- import type { Version } from '../../version/types.js';
7
- export interface MiniAppProps {
8
- headerColor: MiniAppHeaderColor;
9
- backgroundColor: RGB;
10
- version: Version;
11
- botInline: boolean;
12
- createRequestId: CreateRequestIdFunc;
13
- postEvent?: PostEvent;
14
- }
15
- export type MiniAppHeaderColor = HeaderColorKey | RGB;
16
- export interface MiniAppState {
17
- backgroundColor: RGB;
18
- headerColor: MiniAppHeaderColor;
19
- }
20
- export type MiniAppEvents = StateEvents<MiniAppState>;
21
- export type MiniAppEventName = keyof MiniAppEvents;
22
- export type MiniAppEventListener<E extends MiniAppEventName> = MiniAppEvents[E];
23
- export interface RequestedContact {
24
- contact: {
25
- userId: number;
26
- phoneNumber: string;
27
- firstName: string;
28
- lastName?: string;
29
- };
30
- authDate: Date;
31
- hash: string;
32
- }
@@ -1,48 +0,0 @@
1
- import type { OpenPopupOptions, PopupEvents } from './types.js';
2
- import type { PostEvent } from '../../bridge/methods/postEvent.js';
3
- import { EventEmitter } from '../../event-emitter/EventEmitter.js';
4
- import type { SupportsFunc } from '../../supports/types.js';
5
- import type { Version } from '../../version/types.js';
6
- type Emitter = EventEmitter<PopupEvents>;
7
- /**
8
- * Controls currently displayed application popup. It allows developers to
9
- * open new custom popups and detect popup-connected events.
10
- */
11
- export declare class Popup {
12
- private readonly postEvent;
13
- private readonly ee;
14
- private readonly state;
15
- constructor(version: Version, postEvent?: PostEvent);
16
- private set isOpened(value);
17
- /**
18
- * True if popup is currently opened.
19
- */
20
- get isOpened(): boolean;
21
- /**
22
- * Adds new event listener.
23
- */
24
- on: Emitter['on'];
25
- /**
26
- * Removes event listener.
27
- */
28
- off: Emitter['off'];
29
- /**
30
- * A method that shows a native popup described by the `params` argument.
31
- * Promise will be resolved when popup is closed. Resolved value will have
32
- * an identifier of pressed button.
33
- *
34
- * In case, user clicked outside the popup or clicked top right popup close
35
- * button, null will be returned.
36
- *
37
- * FIXME: In desktop, this function may work incorrectly.
38
- * Issue: https://github.com/Telegram-Mini-Apps/tma.js/issues/7
39
- * @param options - popup parameters.
40
- * @throws {Error} Popup is already opened.
41
- */
42
- open(options: OpenPopupOptions): Promise<string | null>;
43
- /**
44
- * Checks if specified method is supported by current component.
45
- */
46
- supports: SupportsFunc<'open'>;
47
- }
48
- export {};
@@ -1,44 +0,0 @@
1
- import type { QRScannerEvents } from './types.js';
2
- import type { PostEvent } from '../../bridge/methods/postEvent.js';
3
- import { EventEmitter } from '../../event-emitter/EventEmitter.js';
4
- import type { SupportsFunc } from '../../supports/types.js';
5
- import type { Version } from '../../version/types.js';
6
- type Emitter = EventEmitter<QRScannerEvents>;
7
- /**
8
- * Provides QR scanner functionality.
9
- */
10
- export declare class QRScanner {
11
- private readonly postEvent;
12
- private readonly ee;
13
- private readonly state;
14
- constructor(version: Version, postEvent?: PostEvent);
15
- /**
16
- * Closes scanner.
17
- */
18
- close(): void;
19
- private set isOpened(value);
20
- /**
21
- * Returns true in case, QR scanner is currently opened.
22
- */
23
- get isOpened(): boolean;
24
- /**
25
- * Opens scanner with specified title shown to user. Method returns promise
26
- * with scanned QR content in case, it was scanned. It will contain null in
27
- * case, scanner was closed.
28
- * @param text - title to display.
29
- */
30
- open(text?: string): Promise<string | null>;
31
- /**
32
- * Adds new event listener.
33
- */
34
- on: Emitter['on'];
35
- /**
36
- * Removes event listener.
37
- */
38
- off: Emitter['off'];
39
- /**
40
- * Checks if specified method is supported by current component.
41
- */
42
- supports: SupportsFunc<'open' | 'close'>;
43
- }
44
- export {};
@@ -1,42 +0,0 @@
1
- import type { SettingsButtonEvents } from './types.js';
2
- import type { PostEvent } from '../../bridge/methods/postEvent.js';
3
- import { EventEmitter } from '../../event-emitter/EventEmitter.js';
4
- import type { SupportsFunc } from '../../supports/types.js';
5
- import type { Version } from '../../version/types.js';
6
- type Emitter = EventEmitter<SettingsButtonEvents>;
7
- export declare class SettingsButton {
8
- private readonly postEvent;
9
- private readonly ee;
10
- private readonly state;
11
- constructor(isVisible: boolean, version: Version, postEvent?: PostEvent);
12
- private set isVisible(value);
13
- /**
14
- * True if SettingsButton is currently visible.
15
- */
16
- get isVisible(): boolean;
17
- /**
18
- * Hides the SettingsButton.
19
- */
20
- hide(): void;
21
- /**
22
- * Adds event listener.
23
- * @param event - event name.
24
- * @param listener - event listener.
25
- */
26
- on: Emitter['on'];
27
- /**
28
- * Removes event listener.
29
- * @param event - event name.
30
- * @param listener - event listener.
31
- */
32
- off: Emitter['off'];
33
- /**
34
- * Shows the SettingsButton.
35
- */
36
- show(): void;
37
- /**
38
- * Checks if specified method is supported by current component.
39
- */
40
- supports: SupportsFunc<'show' | 'hide'>;
41
- }
42
- export {};