@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
@@ -0,0 +1,3 @@
1
+ import { Chat } from '../types.js';
2
+
3
+ export declare const chat: import('../../../parsing/ValueParser/types.js').ValueParserOptionalResult<import('../../../parsing/ValueParser/ValueParser.js').ValueParser<Chat, false>, Chat>;
@@ -0,0 +1,7 @@
1
+ import { ValueParser } from '../../../parsing/ValueParser/ValueParser.js';
2
+ import { InitDataParsed } from '../types.js';
3
+
4
+ /**
5
+ * Returns parser used to parse init data, presented as search params.
6
+ */
7
+ export declare function initData(): ValueParser<InitDataParsed, false>;
@@ -0,0 +1,3 @@
1
+ import { User } from '../types.js';
2
+
3
+ export declare const user: import('../../../parsing/ValueParser/types.js').ValueParserOptionalResult<import('../../../parsing/ValueParser/ValueParser.js').ValueParser<User, false>, User>;
@@ -64,7 +64,7 @@ export interface Chat {
64
64
  */
65
65
  photoUrl?: string;
66
66
  /**
67
- * Type of chat.
67
+ * Type of the chat.
68
68
  */
69
69
  type: 'group' | 'supergroup' | 'channel' | string;
70
70
  /**
@@ -122,8 +122,7 @@ export interface InitDataParsed {
122
122
  */
123
123
  receiver?: User;
124
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.
125
+ * The value of the `startattach` or `startapp` parameter, passed via link.
127
126
  */
128
127
  startParam?: string;
129
128
  /**
@@ -0,0 +1,31 @@
1
+ import { WithSupportsAndTrackableState } from '../../classes/WithSupportsAndTrackableState.js';
2
+ import { InvoiceStatus } from '../../bridge/events/types.js';
3
+ import { PostEvent } from '../../bridge/methods/postEvent.js';
4
+ import { Version } from '../../version/types.js';
5
+ import { InvoiceState } from './types.js';
6
+
7
+ /**
8
+ * @see API: https://docs.telegram-mini-apps.com/packages/tma-js-sdk/components/invoice
9
+ */
10
+ export declare class Invoice extends WithSupportsAndTrackableState<InvoiceState, 'open'> {
11
+ private readonly postEvent;
12
+ constructor(isOpened: boolean, version: Version, postEvent: PostEvent);
13
+ private set isOpened(value);
14
+ /**
15
+ * True if invoice is currently opened.
16
+ */
17
+ get isOpened(): boolean;
18
+ /**
19
+ * Opens an invoice using its slug.
20
+ * @param slug - invoice slug.
21
+ * @throws {Error} Invoice is already opened.
22
+ */
23
+ open(slug: string): Promise<InvoiceStatus>;
24
+ /**
25
+ * Opens an invoice using its url. It expects passing link in full format, with hostname "t.me".
26
+ * @param url - invoice URL.
27
+ * @param type - value type.
28
+ * @throws {Error} Invoice is already opened.
29
+ */
30
+ open(url: string, type: 'url'): Promise<InvoiceStatus>;
31
+ }
@@ -0,0 +1,7 @@
1
+ import { Invoice } from './Invoice.js';
2
+
3
+ /**
4
+ * @returns A new initialized instance of the `Invoice` class.
5
+ * @see Invoice
6
+ */
7
+ export declare const initInvoice: import('../../index.js').InitComponentFn<"version", Invoice, never>;
@@ -1,7 +1,20 @@
1
- import type { StateEvents } from '../../state/types.js';
1
+ import { StateEvents } from '../../classes/State/types.js';
2
+
3
+ /**
4
+ * Invoice internal state.
5
+ */
2
6
  export interface InvoiceState {
3
7
  isOpened: boolean;
4
8
  }
9
+ /**
10
+ * Invoice events.
11
+ */
5
12
  export type InvoiceEvents = StateEvents<InvoiceState>;
13
+ /**
14
+ * Invoice event name.
15
+ */
6
16
  export type InvoiceEventName = keyof InvoiceEvents;
17
+ /**
18
+ * Invoice event listener.
19
+ */
7
20
  export type InvoiceEventListener<E extends InvoiceEventName> = InvoiceEvents[E];
@@ -0,0 +1,106 @@
1
+ import { WithStateUtils } from '../../classes/WithStateUtils.js';
2
+ import { RGB } from '../../colors/types.js';
3
+ import { MainButtonEvents, MainButtonParams, MainButtonProps, MainButtonState } from './types.js';
4
+ import { EventEmitter } from '../../events/event-emitter/EventEmitter.js';
5
+
6
+ type Emitter = EventEmitter<MainButtonEvents>;
7
+ /**
8
+ * @see Usage: https://docs.telegram-mini-apps.com/platform/main-button
9
+ * @see API: https://docs.telegram-mini-apps.com/packages/tma-js-sdk/components/main-button
10
+ */
11
+ export declare class MainButton extends WithStateUtils<MainButtonState> {
12
+ private readonly postEvent;
13
+ constructor({ postEvent, ...rest }: MainButtonProps);
14
+ /**
15
+ * Sends current local state to the Telegram application.
16
+ */
17
+ private commit;
18
+ private set isEnabled(value);
19
+ /**
20
+ * True if the MainButton is enabled.
21
+ */
22
+ get isEnabled(): boolean;
23
+ private set isLoaderVisible(value);
24
+ /**
25
+ * True if the MainButton loader is visible.
26
+ */
27
+ get isLoaderVisible(): boolean;
28
+ private set isVisible(value);
29
+ /**
30
+ * True if the MainButton is visible.
31
+ */
32
+ get isVisible(): boolean;
33
+ /**
34
+ * The MainButton background color.
35
+ */
36
+ get backgroundColor(): RGB;
37
+ /**
38
+ * The MainButton text.
39
+ */
40
+ get text(): string;
41
+ /**
42
+ * The MainButton text color.
43
+ */
44
+ get textColor(): RGB;
45
+ /**
46
+ * Disables the MainButton.
47
+ * @see Does not work on Android: https://github.com/Telegram-Mini-Apps/issues/issues/1
48
+ */
49
+ disable(): this;
50
+ /**
51
+ * Enables the MainButton.
52
+ */
53
+ enable(): this;
54
+ /**
55
+ * Hides the MainButton.
56
+ */
57
+ hide(): this;
58
+ /**
59
+ * Hides the MainButton loading indicator.
60
+ */
61
+ hideLoader(): this;
62
+ /**
63
+ * Adds a new event listener.
64
+ * @param event - event to listen.
65
+ * @param listener - listener to add.
66
+ */
67
+ on: Emitter['on'];
68
+ /**
69
+ * Removes the event listener.
70
+ * @param event - event to listen.
71
+ * @param listener - listener to remove.
72
+ */
73
+ off: Emitter['off'];
74
+ /**
75
+ * Shows the MainButton.
76
+ *
77
+ * Note that opening the Mini App from the attachment menu hides the main button until the
78
+ * user interacts with the Mini App interface.
79
+ */
80
+ show(): this;
81
+ /**
82
+ * Shows a loading indicator on the Main Button.
83
+ */
84
+ showLoader(): this;
85
+ /**
86
+ * Sets a new MainButton text. Minimal length for the text is 1 symbol, and maximum is 64 symbols.
87
+ * @param text - a new text.
88
+ */
89
+ setText(text: string): this;
90
+ /**
91
+ * Sets a new Main Button text color.
92
+ * @param textColor - new text color.
93
+ */
94
+ setTextColor(textColor: RGB): this;
95
+ /**
96
+ * Updates current Main Button color.
97
+ * @param backgroundColor - color to set.
98
+ */
99
+ setBackgroundColor(backgroundColor: RGB): this;
100
+ /**
101
+ * Allows setting multiple Main Button parameters.
102
+ * @param params - Main Button parameters.
103
+ */
104
+ setParams(params: Partial<MainButtonParams>): this;
105
+ }
106
+ export {};
@@ -0,0 +1,7 @@
1
+ import { MainButton } from './MainButton.js';
2
+
3
+ /**
4
+ * @returns A new initialized instance of the `MainButton` class.
5
+ * @see MainButton
6
+ */
7
+ export declare const initMainButton: import('../../index.js').InitComponentFn<"themeParams", MainButton, import('./types.js').MainButtonState>;
@@ -0,0 +1,40 @@
1
+ import { PostEvent } from '../../bridge/methods/postEvent.js';
2
+ import { StateEvents } from '../../classes/State/types.js';
3
+ import { RGB } from '../../colors/types.js';
4
+
5
+ export interface MainButtonParams {
6
+ backgroundColor: RGB;
7
+ isEnabled: boolean;
8
+ isLoaderVisible: boolean;
9
+ isVisible: boolean;
10
+ text: string;
11
+ textColor: RGB;
12
+ }
13
+ /**
14
+ * MainButton constructor properties.
15
+ */
16
+ export interface MainButtonProps extends MainButtonParams {
17
+ postEvent: PostEvent;
18
+ }
19
+ /**
20
+ * MainButton internal state.
21
+ */
22
+ export interface MainButtonState extends MainButtonParams {
23
+ }
24
+ /**
25
+ * MainButton trackable events.
26
+ */
27
+ export interface MainButtonEvents extends StateEvents<MainButtonState> {
28
+ /**
29
+ * The MainButton was clicked.
30
+ */
31
+ click: () => void;
32
+ }
33
+ /**
34
+ * MainButton event name.
35
+ */
36
+ export type MainButtonEventName = keyof MainButtonEvents;
37
+ /**
38
+ * MainButton event listener.
39
+ */
40
+ export type MainButtonEventListener<E extends MainButtonEventName> = MainButtonEvents[E];
@@ -1,64 +1,49 @@
1
- import type { MiniAppEvents, MiniAppHeaderColor, MiniAppProps, RequestedContact } from './types.js';
2
- import type { PhoneRequestedStatus } from '../../bridge/events/parsers/phoneRequested.js';
3
- import type { WriteAccessRequestedStatus } from '../../bridge/events/parsers/writeAccessRequested.js';
4
- import type { SwitchInlineQueryChatType } from '../../bridge/methods/methods.js';
5
- import type { RGB } from '../../colors/types.js';
6
- import { EventEmitter } from '../../event-emitter/EventEmitter.js';
7
- import type { SupportsFunc } from '../../supports/types.js';
8
- import type { ExecuteWithTimeout } from '../../types/methods.js';
9
- type Emitter = EventEmitter<MiniAppEvents>;
1
+ import { WithSupportsAndTrackableState } from '../../classes/WithSupportsAndTrackableState.js';
2
+ import { PhoneRequestedStatus, WriteAccessRequestedStatus } from '../../bridge/events/types.js';
3
+ import { SwitchInlineQueryChatType } from '../../bridge/methods/types/methods.js';
4
+ import { RGB } from '../../colors/types.js';
5
+ import { MiniAppHeaderColor, MiniAppProps, MiniAppState, RequestedContact } from './types.js';
6
+ import { SupportsFn } from '../../supports/types.js';
7
+ import { ExecuteWithTimeout } from '../../types/methods.js';
8
+
10
9
  /**
11
10
  * Provides common Mini Apps functionality not covered by other system components.
12
11
  */
13
- export declare class MiniApp {
14
- private readonly ee;
15
- private readonly state;
12
+ export declare class MiniApp extends WithSupportsAndTrackableState<MiniAppState, 'requestPhoneAccess' | 'requestWriteAccess' | 'switchInlineQuery' | 'setHeaderColor' | 'setBackgroundColor'> {
16
13
  private readonly botInline;
17
14
  private readonly postEvent;
18
15
  private readonly createRequestId;
19
- private requestingPhoneAccess;
20
- private requestingWriteAccess;
21
- constructor(props: MiniAppProps);
16
+ private requestPhoneAccessPromise;
17
+ private requestWriteAccessPromise;
18
+ constructor({ postEvent, createRequestId, version, botInline, ...rest }: MiniAppProps);
22
19
  /**
23
20
  * Attempts to get requested contact.
21
+ * @param timeout - request timeout.
24
22
  */
25
23
  private getRequestedContact;
26
24
  /**
27
25
  * The Mini App background color.
26
+ * @example "#ffaabb"
28
27
  */
29
- get backgroundColor(): RGB;
28
+ get bgColor(): RGB;
30
29
  /**
31
30
  * Closes the Mini App.
32
31
  */
33
32
  close(): void;
34
33
  /**
35
- * The Mini App header color. Could either be a header color key or RGB color.
34
+ * The Mini App header color.
35
+ * @example "#ffaabb"
36
+ * @example "bg_color"
36
37
  */
37
38
  get headerColor(): MiniAppHeaderColor;
38
39
  /**
39
- * True if Mini App is currently launched in bot inline mode.
40
+ * True if the Mini App is currently launched in bot inline mode.
40
41
  */
41
42
  get isBotInline(): boolean;
42
43
  /**
43
- * True if current Mini App background color recognized as dark.
44
+ * True if current Mini App background color is recognized as dark.
44
45
  */
45
46
  get isDark(): boolean;
46
- /**
47
- * True if phone access is currently being requested.
48
- */
49
- get isRequestingPhoneAccess(): boolean;
50
- /**
51
- * True if write access is currently being requested.
52
- */
53
- get isRequestingWriteAccess(): boolean;
54
- /**
55
- * Adds new event listener.
56
- */
57
- on: Emitter['on'];
58
- /**
59
- * Removes event listener.
60
- */
61
- off: Emitter['off'];
62
47
  /**
63
48
  * Informs the Telegram app that the Mini App is ready to be displayed.
64
49
  *
@@ -81,7 +66,7 @@ export declare class MiniApp {
81
66
  * status of the request. In case, user accepted the request, Mini App bot will receive
82
67
  * the according notification.
83
68
  *
84
- * To obtain the retrieved information instead, utilize the requestContact method.
69
+ * To obtain the retrieved information instead, utilize the `requestContact` method.
85
70
  * @param options - additional options.
86
71
  * @see requestContact
87
72
  */
@@ -103,22 +88,24 @@ export declare class MiniApp {
103
88
  sendData(data: string): void;
104
89
  /**
105
90
  * Updates current Mini App header color.
91
+ *
92
+ * @see No effect on desktop: https://github.com/Telegram-Mini-Apps/tma.js/issues/9
93
+ * @see Works incorrectly in Android: https://github.com/Telegram-Mini-Apps/tma.js/issues/8
106
94
  * @param color - color key or RGB color.
107
95
  */
108
96
  setHeaderColor(color: MiniAppHeaderColor): void;
109
97
  /**
110
98
  * Updates current Mini App background color.
99
+ *
100
+ * @see No effect on desktop: https://github.com/Telegram-Mini-Apps/tma.js/issues/9
101
+ * @see Works incorrectly in Android: https://github.com/Telegram-Mini-Apps/tma.js/issues/8
111
102
  * @param color - RGB color.
112
103
  */
113
- setBackgroundColor(color: RGB): void;
114
- /**
115
- * Checks if specified method is supported by current component.
116
- */
117
- supports: SupportsFunc<'requestWriteAccess' | 'requestPhoneAccess' | 'switchInlineQuery' | 'setHeaderColor' | 'setBackgroundColor'>;
104
+ setBgColor(color: RGB): void;
118
105
  /**
119
106
  * Checks if specified method parameter is supported by current component.
120
107
  */
121
- supportsParam: SupportsFunc<'setHeaderColor.color'>;
108
+ supportsParam: SupportsFn<'setHeaderColor.color'>;
122
109
  /**
123
110
  * Inserts the bot's username and the specified inline query in the current chat's input field.
124
111
  * Query may be empty, in which case only the bot's username will be inserted. The client prompts
@@ -131,4 +118,3 @@ export declare class MiniApp {
131
118
  */
132
119
  switchInlineQuery(text: string, chatTypes?: SwitchInlineQueryChatType[]): void;
133
120
  }
134
- export {};
@@ -0,0 +1,7 @@
1
+ import { MiniApp } from './MiniApp.js';
2
+
3
+ /**
4
+ * @returns A new initialized instance of the `MiniApp` class.
5
+ * @see MiniApp
6
+ */
7
+ export declare const initMiniApp: import('../../index.js').InitComponentFn<"botInline" | "themeParams" | "version", MiniApp, import('./types.js').MiniAppState>;
@@ -0,0 +1,7 @@
1
+ import { ValueParser } from '../../../parsing/ValueParser/ValueParser.js';
2
+ import { RequestedContact } from '../types.js';
3
+
4
+ /**
5
+ * Returns function which parses incoming value as a contact information.
6
+ */
7
+ export declare function contact(): ValueParser<RequestedContact, false>;
@@ -0,0 +1,53 @@
1
+ import { PostEvent } from '../../bridge/methods/postEvent.js';
2
+ import { HeaderColorKey } from '../../bridge/methods/types/methods.js';
3
+ import { StateEvents } from '../../classes/State/types.js';
4
+ import { RGB } from '../../colors/types.js';
5
+ import { CreateRequestIdFn } from '../../request-id/types.js';
6
+ import { Version } from '../../version/types.js';
7
+
8
+ /**
9
+ * MiniApp constructor properties.
10
+ */
11
+ export interface MiniAppProps extends MiniAppState {
12
+ version: Version;
13
+ botInline: boolean;
14
+ createRequestId: CreateRequestIdFn;
15
+ postEvent: PostEvent;
16
+ }
17
+ /**
18
+ * MiniApp header color.
19
+ */
20
+ export type MiniAppHeaderColor = HeaderColorKey | RGB;
21
+ /**
22
+ * MiniApp internal state.
23
+ */
24
+ export interface MiniAppState {
25
+ bgColor: RGB;
26
+ headerColor: MiniAppHeaderColor;
27
+ }
28
+ /**
29
+ * MiniApp trackable events.
30
+ */
31
+ export interface MiniAppEvents extends StateEvents<MiniAppState> {
32
+ }
33
+ /**
34
+ * MiniApp event name.
35
+ */
36
+ export type MiniAppEventName = keyof MiniAppEvents;
37
+ /**
38
+ * MiniApp event listener.
39
+ */
40
+ export type MiniAppEventListener<E extends MiniAppEventName> = MiniAppEvents[E];
41
+ /**
42
+ * Requested contact information.
43
+ */
44
+ export interface RequestedContact {
45
+ contact: {
46
+ userId: number;
47
+ phoneNumber: string;
48
+ firstName: string;
49
+ lastName?: string;
50
+ };
51
+ authDate: Date;
52
+ hash: string;
53
+ }
@@ -0,0 +1,30 @@
1
+ import { WithSupportsAndTrackableState } from '../../classes/WithSupportsAndTrackableState.js';
2
+ import { PostEvent } from '../../bridge/methods/postEvent.js';
3
+ import { OpenPopupOptions, PopupState } from './types.js';
4
+ import { Version } from '../../version/types.js';
5
+
6
+ /**
7
+ * @see Usage: https://docs.telegram-mini-apps.com/platform/popup
8
+ * @see API: https://docs.telegram-mini-apps.com/packages/tma-js-sdk/components/popup
9
+ */
10
+ export declare class Popup extends WithSupportsAndTrackableState<PopupState, 'open'> {
11
+ private readonly postEvent;
12
+ constructor(isOpened: boolean, version: Version, postEvent: PostEvent);
13
+ private set isOpened(value);
14
+ /**
15
+ * True if the Popup is opened.
16
+ */
17
+ get isOpened(): boolean;
18
+ /**
19
+ * A method that shows a native popup described by the `params` argument.
20
+ * Promise will be resolved when popup is closed. Resolved value will have
21
+ * an identifier of pressed button.
22
+ *
23
+ * In case, user clicked outside the popup or clicked top right popup close
24
+ * button, null will be returned.
25
+ *
26
+ * @param options - popup parameters.
27
+ * @throws {Error} Popup is already opened.
28
+ */
29
+ open(options: OpenPopupOptions): Promise<string | null>;
30
+ }
@@ -0,0 +1,7 @@
1
+ import { Popup } from './Popup.js';
2
+
3
+ /**
4
+ * @returns A new initialized instance of the `Popup` class.
5
+ * @see Popup
6
+ */
7
+ export declare const initPopup: import('../../index.js').InitComponentFn<"version", Popup, never>;
@@ -1,5 +1,6 @@
1
- import type { OpenPopupOptions } from './types.js';
2
- import type { PopupParams as BridgePopupParams } from '../../bridge/methods/popup.js';
1
+ import { PopupParams as BridgePopupParams } from '../../bridge/methods/types/popup.js';
2
+ import { OpenPopupOptions } from './types.js';
3
+
3
4
  /**
4
5
  * Prepares popup parameters before sending them to native app.
5
6
  * @param params - popup parameters.
@@ -1,4 +1,5 @@
1
- import type { StateEvents } from '../../state/types.js';
1
+ import { StateEvents } from '../../classes/State/types.js';
2
+
2
3
  export interface PopupState {
3
4
  isOpened: boolean;
4
5
  }
@@ -0,0 +1,28 @@
1
+ import { WithSupportsAndTrackableState } from '../../classes/WithSupportsAndTrackableState.js';
2
+ import { PostEvent } from '../../bridge/methods/postEvent.js';
3
+ import { Version } from '../../version/types.js';
4
+ import { QRScannerState } from './types.js';
5
+
6
+ /**
7
+ * @see API: https://docs.telegram-mini-apps.com/packages/tma-js-sdk/components/qr-scanner
8
+ */
9
+ export declare class QRScanner extends WithSupportsAndTrackableState<QRScannerState, 'close' | 'open'> {
10
+ private readonly postEvent;
11
+ constructor(isOpened: boolean, version: Version, postEvent: PostEvent);
12
+ /**
13
+ * Closes scanner.
14
+ */
15
+ close(): void;
16
+ private set isOpened(value);
17
+ /**
18
+ * Returns true in case, QR scanner is currently opened.
19
+ */
20
+ get isOpened(): boolean;
21
+ /**
22
+ * Opens scanner with specified title shown to user. Method returns promise
23
+ * with scanned QR content in case, it was scanned. It will contain null in
24
+ * case, scanner was closed.
25
+ * @param text - title to display.
26
+ */
27
+ open(text?: string): Promise<string | null>;
28
+ }
@@ -0,0 +1,7 @@
1
+ import { QRScanner } from './QRScanner.js';
2
+
3
+ /**
4
+ * @returns A new initialized instance of the `QRScanner` class.
5
+ * @see QRScanner
6
+ */
7
+ export declare const initQRScanner: import('../../index.js').InitComponentFn<"version", QRScanner, never>;
@@ -1,7 +1,20 @@
1
- import type { StateEvents } from '../../state/types.js';
1
+ import { StateEvents } from '../../classes/State/types.js';
2
+
3
+ /**
4
+ * QRScanner internal state.
5
+ */
2
6
  export interface QRScannerState {
3
7
  isOpened: boolean;
4
8
  }
9
+ /**
10
+ * QRScanner trackable events.
11
+ */
5
12
  export type QRScannerEvents = StateEvents<QRScannerState>;
13
+ /**
14
+ * QRScanner event name.
15
+ */
6
16
  export type QRScannerEventName = keyof QRScannerEvents;
17
+ /**
18
+ * QRScanner event listener.
19
+ */
7
20
  export type QRScannerEventListener<E extends QRScannerEventName> = QRScannerEvents[E];
@@ -0,0 +1,37 @@
1
+ import { WithSupportsAndStateUtils } from '../../classes/WithSupportsAndStateUtils.js';
2
+ import { PostEvent } from '../../bridge/methods/postEvent.js';
3
+ import { SettingsButtonEvents, SettingsButtonState } from './types.js';
4
+ import { EventEmitter } from '../../events/event-emitter/EventEmitter.js';
5
+ import { Version } from '../../version/types.js';
6
+
7
+ type Emitter = EventEmitter<SettingsButtonEvents>;
8
+ export declare class SettingsButton extends WithSupportsAndStateUtils<SettingsButtonState, 'show' | 'hide'> {
9
+ private readonly postEvent;
10
+ constructor(isVisible: boolean, version: Version, postEvent: PostEvent);
11
+ private set isVisible(value);
12
+ /**
13
+ * True if the SettingsButton is visible.
14
+ */
15
+ get isVisible(): boolean;
16
+ /**
17
+ * Hides the SettingsButton.
18
+ */
19
+ hide(): void;
20
+ /**
21
+ * Adds a new event listener.
22
+ * @param event - event to listen.
23
+ * @param listener - listener to add.
24
+ */
25
+ on: Emitter['on'];
26
+ /**
27
+ * Removes the event listener.
28
+ * @param event - event to listen.
29
+ * @param listener - listener to remove.
30
+ */
31
+ off: Emitter['off'];
32
+ /**
33
+ * Shows the SettingsButton.
34
+ */
35
+ show(): void;
36
+ }
37
+ export {};
@@ -0,0 +1,7 @@
1
+ import { SettingsButton } from './SettingsButton.js';
2
+
3
+ /**
4
+ * @returns A new initialized instance of the `SettingsButton` class.
5
+ * @see SettingsButton
6
+ */
7
+ export declare const initSettingsButton: import('../../index.js').InitComponentFn<"version", SettingsButton, import('./types.js').SettingsButtonState>;
@@ -1,10 +1,25 @@
1
- import type { MiniAppsEventListener } from '../../bridge/events/events.js';
2
- import type { StateEvents } from '../../state/types.js';
1
+ import { StateEvents } from '../../classes/State/types.js';
2
+
3
+ /**
4
+ * SettingsButton internal state.
5
+ */
3
6
  export interface SettingsButtonState {
4
7
  isVisible: boolean;
5
8
  }
9
+ /**
10
+ * SettingsButton trackable events.
11
+ */
6
12
  export interface SettingsButtonEvents extends StateEvents<SettingsButtonState> {
7
- click: MiniAppsEventListener<'settings_button_pressed'>;
13
+ /**
14
+ * The SettingsButton was clicked.
15
+ */
16
+ click: () => void;
8
17
  }
18
+ /**
19
+ * SettingsButton event name.
20
+ */
9
21
  export type SettingsButtonEventName = keyof SettingsButtonEvents;
22
+ /**
23
+ * SettingsButton event listener.
24
+ */
10
25
  export type SettingsButtonEventListener<E extends SettingsButtonEventName> = SettingsButtonEvents[E];