@tma.js/sdk 2.7.0 → 3.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 (310) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +9 -9
  3. package/dist/dts/composables/AsyncMountable.d.ts +44 -0
  4. package/dist/dts/composables/Button.d.ts +140 -0
  5. package/dist/dts/composables/Mountable.d.ts +43 -0
  6. package/dist/dts/composables/Stateful.d.ts +35 -0
  7. package/dist/dts/errors.d.ts +41 -0
  8. package/dist/dts/features/BackButton/BackButton.d.ts +96 -0
  9. package/dist/dts/features/BackButton/exports.d.ts +2 -0
  10. package/dist/dts/features/BackButton/instance.d.ts +2 -0
  11. package/dist/dts/features/Biometry/Biometry.d.ts +122 -0
  12. package/dist/dts/features/Biometry/exports.d.ts +3 -0
  13. package/dist/dts/features/Biometry/instance.d.ts +2 -0
  14. package/dist/dts/features/Biometry/types.d.ts +84 -0
  15. package/dist/dts/features/ClosingBehavior/ClosingBehavior.d.ts +51 -0
  16. package/dist/dts/features/ClosingBehavior/exports.d.ts +2 -0
  17. package/dist/dts/features/ClosingBehavior/instance.d.ts +2 -0
  18. package/dist/dts/features/CloudStorage/CloudStorage.d.ts +90 -0
  19. package/dist/dts/features/CloudStorage/exports.d.ts +2 -0
  20. package/dist/dts/features/CloudStorage/instance.d.ts +2 -0
  21. package/dist/dts/features/HapticFeedback/HapticFeedback.d.ts +57 -0
  22. package/dist/dts/features/HapticFeedback/exports.d.ts +2 -0
  23. package/dist/dts/features/HapticFeedback/instance.d.ts +2 -0
  24. package/dist/dts/features/InitData/InitData.d.ts +84 -0
  25. package/dist/dts/features/InitData/exports.d.ts +2 -0
  26. package/dist/dts/features/InitData/instance.d.ts +2 -0
  27. package/dist/dts/features/Invoice/Invoice.d.ts +54 -0
  28. package/dist/dts/features/Invoice/exports.d.ts +2 -0
  29. package/dist/dts/features/Invoice/instance.d.ts +2 -0
  30. package/dist/dts/features/LocationManager/LocationManager.d.ts +74 -0
  31. package/dist/dts/features/LocationManager/exports.d.ts +3 -0
  32. package/dist/dts/features/LocationManager/instance.d.ts +2 -0
  33. package/dist/dts/features/LocationManager/types.d.ts +65 -0
  34. package/dist/dts/features/MainButton/MainButton.d.ts +214 -0
  35. package/dist/dts/features/MainButton/exports.d.ts +2 -0
  36. package/dist/dts/features/MainButton/instance.d.ts +2 -0
  37. package/dist/dts/features/MiniApp/MiniApp.d.ts +192 -0
  38. package/dist/dts/features/MiniApp/exports.d.ts +2 -0
  39. package/dist/dts/features/MiniApp/instance.d.ts +2 -0
  40. package/dist/dts/features/Popup/Popup.d.ts +56 -0
  41. package/dist/dts/features/Popup/exports.d.ts +3 -0
  42. package/dist/dts/features/Popup/instance.d.ts +2 -0
  43. package/dist/dts/features/Popup/prepareParams.d.ts +9 -0
  44. package/dist/dts/{components → features}/Popup/types.d.ts +5 -12
  45. package/dist/dts/features/QrScanner/QrScanner.d.ts +132 -0
  46. package/dist/dts/features/QrScanner/exports.d.ts +2 -0
  47. package/dist/dts/features/QrScanner/instance.d.ts +2 -0
  48. package/dist/dts/features/SecondaryButton/SecondaryButton.d.ts +253 -0
  49. package/dist/dts/features/SecondaryButton/exports.d.ts +2 -0
  50. package/dist/dts/features/SecondaryButton/instance.d.ts +2 -0
  51. package/dist/dts/features/SettingsButton/SettingsButton.d.ts +96 -0
  52. package/dist/dts/features/SettingsButton/exports.d.ts +2 -0
  53. package/dist/dts/features/SettingsButton/instance.d.ts +2 -0
  54. package/dist/dts/features/SwipeBehavior/SwipeBehavior.d.ts +62 -0
  55. package/dist/dts/features/SwipeBehavior/exports.d.ts +2 -0
  56. package/dist/dts/features/SwipeBehavior/instance.d.ts +2 -0
  57. package/dist/dts/features/ThemeParams/ThemeParams.d.ts +127 -0
  58. package/dist/dts/features/ThemeParams/exports.d.ts +2 -0
  59. package/dist/dts/features/ThemeParams/instance.d.ts +2 -0
  60. package/dist/dts/features/Viewport/Viewport.d.ts +220 -0
  61. package/dist/dts/features/Viewport/exports.d.ts +2 -0
  62. package/dist/dts/features/Viewport/instance.d.ts +2 -0
  63. package/dist/dts/features/emoji-status/exports.d.ts +2 -0
  64. package/dist/dts/features/emoji-status/requestEmojiStatusAccess.d.ts +16 -0
  65. package/dist/dts/features/emoji-status/setEmojiStatus.d.ts +28 -0
  66. package/dist/dts/features/home-screen/addToHomeScreen.d.ts +11 -0
  67. package/dist/dts/features/home-screen/checkHomeScreenStatus.d.ts +14 -0
  68. package/dist/dts/features/home-screen/exports.d.ts +2 -0
  69. package/dist/dts/features/links/exports.d.ts +3 -0
  70. package/dist/dts/features/links/openLink.d.ts +31 -0
  71. package/dist/dts/features/links/openTelegramLink.d.ts +18 -0
  72. package/dist/dts/features/links/shareURL.d.ts +18 -0
  73. package/dist/dts/features/privacy/exports.d.ts +3 -0
  74. package/dist/dts/features/privacy/requestContact.d.ts +59 -0
  75. package/dist/dts/features/privacy/requestPhoneAccess.d.ts +19 -0
  76. package/dist/dts/features/privacy/requestWriteAccess.d.ts +14 -0
  77. package/dist/dts/features/uncategorized/copyTextToClipboard.d.ts +5 -0
  78. package/dist/dts/features/uncategorized/downloadFile.d.ts +21 -0
  79. package/dist/dts/features/uncategorized/exports.d.ts +11 -0
  80. package/dist/dts/features/uncategorized/getCurrentTime.d.ts +15 -0
  81. package/dist/dts/features/uncategorized/hideKeyboard.d.ts +13 -0
  82. package/dist/dts/features/uncategorized/readTextFromClipboard.d.ts +13 -0
  83. package/dist/dts/features/uncategorized/retrieveAndroidDeviceData.d.ts +6 -0
  84. package/dist/dts/features/uncategorized/retrieveAndroidDeviceDataFrom.d.ts +14 -0
  85. package/dist/dts/features/uncategorized/sendData.d.ts +20 -0
  86. package/dist/dts/features/uncategorized/shareMessage.d.ts +14 -0
  87. package/dist/dts/features/uncategorized/shareStory.d.ts +50 -0
  88. package/dist/dts/features/uncategorized/switchInlineQuery.d.ts +28 -0
  89. package/dist/dts/fn-options/bottomButtonOptions.d.ts +11 -0
  90. package/dist/dts/fn-options/buttonOptions.d.ts +10 -0
  91. package/dist/dts/fn-options/createFnOption.d.ts +2 -0
  92. package/dist/dts/fn-options/sharedFeatureOptions.d.ts +8 -0
  93. package/dist/dts/fn-options/withInvokeCustomMethod.d.ts +11 -0
  94. package/dist/dts/fn-options/withPostEvent.d.ts +8 -0
  95. package/dist/dts/fn-options/withRequest.d.ts +8 -0
  96. package/dist/dts/fn-options/withStateRestore.d.ts +13 -0
  97. package/dist/dts/fn-options/withVersion.d.ts +9 -0
  98. package/dist/dts/globals/createRequestId.d.ts +4 -0
  99. package/dist/dts/globals/inline-mode.d.ts +4 -0
  100. package/dist/dts/globals/invokeCustomMethod.d.ts +16 -0
  101. package/dist/dts/globals/post-event.d.ts +4 -0
  102. package/dist/dts/globals/request.d.ts +3 -0
  103. package/dist/dts/globals/resetGlobals.d.ts +4 -0
  104. package/dist/dts/globals/signals-registry.d.ts +39 -0
  105. package/dist/dts/globals/themeParams.d.ts +4 -0
  106. package/dist/dts/globals/version.d.ts +4 -0
  107. package/dist/dts/helpers/access.d.ts +2 -0
  108. package/dist/dts/helpers/component-storage.d.ts +9 -0
  109. package/dist/dts/helpers/createIsSupportedSignal.d.ts +5 -0
  110. package/dist/dts/helpers/css-vars.d.ts +11 -0
  111. package/dist/dts/helpers/isColorDark.d.ts +11 -0
  112. package/dist/dts/{navigation/isPageReload.d.ts → helpers/navigation.d.ts} +1 -1
  113. package/dist/dts/helpers/removeUndefined.d.ts +10 -0
  114. package/dist/dts/helpers/shallowEqual.d.ts +1 -0
  115. package/dist/dts/index.d.ts +33 -168
  116. package/dist/dts/init.d.ts +42 -0
  117. package/dist/dts/types.d.ts +6 -0
  118. package/dist/dts/with-checks/throwifyWithChecksFp.d.ts +3 -0
  119. package/dist/dts/with-checks/withChecksFp.d.ts +172 -0
  120. package/dist/index.cjs +1 -3
  121. package/dist/index.cjs.map +1 -1
  122. package/dist/index.iife.js +3 -3
  123. package/dist/index.iife.js.map +1 -1
  124. package/dist/index.js +3811 -2897
  125. package/dist/index.js.map +1 -1
  126. package/package.json +15 -5
  127. package/dist/dts/bridge/captureSameReq.d.ts +0 -10
  128. package/dist/dts/bridge/events/event-emitter/createMiniAppsEventEmitter.d.ts +0 -15
  129. package/dist/dts/bridge/events/event-emitter/singleton.d.ts +0 -8
  130. package/dist/dts/bridge/events/event-handlers/cleanupEventHandlers.d.ts +0 -4
  131. package/dist/dts/bridge/events/event-handlers/defineEventHandlers.d.ts +0 -6
  132. package/dist/dts/bridge/events/event-handlers/emitMiniAppsEvent.d.ts +0 -9
  133. package/dist/dts/bridge/events/listening/off.d.ts +0 -8
  134. package/dist/dts/bridge/events/listening/on.d.ts +0 -12
  135. package/dist/dts/bridge/events/listening/subscribe.d.ts +0 -9
  136. package/dist/dts/bridge/events/listening/unsubscribe.d.ts +0 -7
  137. package/dist/dts/bridge/events/types.d.ts +0 -302
  138. package/dist/dts/bridge/invokeCustomMethod.d.ts +0 -23
  139. package/dist/dts/bridge/methods/createPostEvent.d.ts +0 -14
  140. package/dist/dts/bridge/methods/postEvent.d.ts +0 -40
  141. package/dist/dts/bridge/methods/types/custom-methods.d.ts +0 -57
  142. package/dist/dts/bridge/methods/types/haptic.d.ts +0 -40
  143. package/dist/dts/bridge/methods/types/index.d.ts +0 -4
  144. package/dist/dts/bridge/methods/types/methods.d.ts +0 -392
  145. package/dist/dts/bridge/methods/types/popup.d.ts +0 -49
  146. package/dist/dts/bridge/parseMessage.d.ts +0 -18
  147. package/dist/dts/bridge/request.d.ts +0 -53
  148. package/dist/dts/bridge/target-origin.d.ts +0 -18
  149. package/dist/dts/classes/State/State.d.ts +0 -46
  150. package/dist/dts/classes/State/types.d.ts +0 -29
  151. package/dist/dts/classes/WithStateUtils.d.ts +0 -18
  152. package/dist/dts/classes/WithSupports.d.ts +0 -19
  153. package/dist/dts/classes/WithSupportsAndStateUtils.d.ts +0 -24
  154. package/dist/dts/classes/WithSupportsAndTrackableState.d.ts +0 -16
  155. package/dist/dts/classes/WithTrackableState.d.ts +0 -16
  156. package/dist/dts/classnames/classNames.d.ts +0 -12
  157. package/dist/dts/classnames/mergeClassNames.d.ts +0 -14
  158. package/dist/dts/colors/isColorDark.d.ts +0 -6
  159. package/dist/dts/colors/isRGB.d.ts +0 -7
  160. package/dist/dts/colors/isRGBShort.d.ts +0 -7
  161. package/dist/dts/colors/toRGB.d.ts +0 -12
  162. package/dist/dts/colors/types.d.ts +0 -8
  163. package/dist/dts/components/BackButton/BackButton.d.ts +0 -41
  164. package/dist/dts/components/BackButton/initBackButton.d.ts +0 -7
  165. package/dist/dts/components/BackButton/types.d.ts +0 -25
  166. package/dist/dts/components/BiometryManager/BiometryManager.d.ts +0 -61
  167. package/dist/dts/components/BiometryManager/formatEvent.d.ts +0 -34
  168. package/dist/dts/components/BiometryManager/initBiometryManager.d.ts +0 -7
  169. package/dist/dts/components/BiometryManager/requestBiometryInfo.d.ts +0 -8
  170. package/dist/dts/components/BiometryManager/types.d.ts +0 -40
  171. package/dist/dts/components/ClosingBehavior/ClosingBehavior.d.ts +0 -26
  172. package/dist/dts/components/ClosingBehavior/initClosingBehavior.d.ts +0 -7
  173. package/dist/dts/components/ClosingBehavior/types.d.ts +0 -20
  174. package/dist/dts/components/CloudStorage/CloudStorage.d.ts +0 -47
  175. package/dist/dts/components/CloudStorage/initCloudStorage.d.ts +0 -7
  176. package/dist/dts/components/HapticFeedback/HapticFeedback.d.ts +0 -34
  177. package/dist/dts/components/HapticFeedback/initHapticFeedback.d.ts +0 -7
  178. package/dist/dts/components/InitData/InitData.d.ts +0 -55
  179. package/dist/dts/components/InitData/initInitData.d.ts +0 -7
  180. package/dist/dts/components/InitData/parseInitData.d.ts +0 -7
  181. package/dist/dts/components/InitData/parsers/chat.d.ts +0 -3
  182. package/dist/dts/components/InitData/parsers/initData.d.ts +0 -7
  183. package/dist/dts/components/InitData/parsers/user.d.ts +0 -3
  184. package/dist/dts/components/InitData/types.d.ts +0 -132
  185. package/dist/dts/components/Invoice/Invoice.d.ts +0 -31
  186. package/dist/dts/components/Invoice/initInvoice.d.ts +0 -7
  187. package/dist/dts/components/Invoice/types.d.ts +0 -20
  188. package/dist/dts/components/MainButton/MainButton.d.ts +0 -106
  189. package/dist/dts/components/MainButton/initMainButton.d.ts +0 -7
  190. package/dist/dts/components/MainButton/types.d.ts +0 -40
  191. package/dist/dts/components/MiniApp/MiniApp.d.ts +0 -121
  192. package/dist/dts/components/MiniApp/initMiniApp.d.ts +0 -7
  193. package/dist/dts/components/MiniApp/parsing/contact.d.ts +0 -7
  194. package/dist/dts/components/MiniApp/types.d.ts +0 -53
  195. package/dist/dts/components/Popup/Popup.d.ts +0 -30
  196. package/dist/dts/components/Popup/initPopup.d.ts +0 -7
  197. package/dist/dts/components/Popup/preparePopupParams.d.ts +0 -8
  198. package/dist/dts/components/QRScanner/QRScanner.d.ts +0 -33
  199. package/dist/dts/components/QRScanner/initQRScanner.d.ts +0 -7
  200. package/dist/dts/components/QRScanner/types.d.ts +0 -31
  201. package/dist/dts/components/SettingsButton/SettingsButton.d.ts +0 -37
  202. package/dist/dts/components/SettingsButton/initSettingsButton.d.ts +0 -7
  203. package/dist/dts/components/SettingsButton/types.d.ts +0 -25
  204. package/dist/dts/components/ThemeParams/ThemeParams.d.ts +0 -57
  205. package/dist/dts/components/ThemeParams/initThemeParams.d.ts +0 -7
  206. package/dist/dts/components/ThemeParams/keys.d.ts +0 -11
  207. package/dist/dts/components/ThemeParams/parsing/parseThemeParams.d.ts +0 -7
  208. package/dist/dts/components/ThemeParams/parsing/serializeThemeParams.d.ts +0 -6
  209. package/dist/dts/components/ThemeParams/parsing/themeParams.d.ts +0 -4
  210. package/dist/dts/components/ThemeParams/requestThemeParams.d.ts +0 -8
  211. package/dist/dts/components/ThemeParams/types.d.ts +0 -29
  212. package/dist/dts/components/Utils/Utils.d.ts +0 -77
  213. package/dist/dts/components/Utils/initUtils.d.ts +0 -7
  214. package/dist/dts/components/Viewport/Viewport.d.ts +0 -77
  215. package/dist/dts/components/Viewport/initViewport.d.ts +0 -7
  216. package/dist/dts/components/Viewport/requestViewport.d.ts +0 -13
  217. package/dist/dts/components/Viewport/types.d.ts +0 -35
  218. package/dist/dts/css-vars/bindMiniAppCSSVars.d.ts +0 -29
  219. package/dist/dts/css-vars/bindThemeParamsCSSVars.d.ts +0 -29
  220. package/dist/dts/css-vars/bindViewportCSSVars.d.ts +0 -32
  221. package/dist/dts/css-vars/setCSSVar.d.ts +0 -6
  222. package/dist/dts/debug/debug.d.ts +0 -14
  223. package/dist/dts/env/hasExternalNotify.d.ts +0 -10
  224. package/dist/dts/env/hasWebviewProxy.d.ts +0 -10
  225. package/dist/dts/env/initWeb.d.ts +0 -11
  226. package/dist/dts/env/isIframe.d.ts +0 -5
  227. package/dist/dts/env/isSSR.d.ts +0 -4
  228. package/dist/dts/env/isTMA.d.ts +0 -4
  229. package/dist/dts/env/mockTelegramEnv.d.ts +0 -7
  230. package/dist/dts/errors/SDKError.d.ts +0 -9
  231. package/dist/dts/errors/createError.d.ts +0 -10
  232. package/dist/dts/errors/errors.d.ts +0 -49
  233. package/dist/dts/errors/isSDKError.d.ts +0 -7
  234. package/dist/dts/errors/isSDKErrorOfType.d.ts +0 -8
  235. package/dist/dts/events/event-emitter/EventEmitter.d.ts +0 -54
  236. package/dist/dts/events/event-emitter/types.d.ts +0 -45
  237. package/dist/dts/events/onWindow.d.ts +0 -10
  238. package/dist/dts/events/types.d.ts +0 -6
  239. package/dist/dts/index.low-level.d.ts +0 -41
  240. package/dist/dts/launch-params/parseLaunchParams.d.ts +0 -7
  241. package/dist/dts/launch-params/retrieveFromLocation.d.ts +0 -7
  242. package/dist/dts/launch-params/retrieveFromPerformance.d.ts +0 -7
  243. package/dist/dts/launch-params/retrieveFromStorage.d.ts +0 -7
  244. package/dist/dts/launch-params/retrieveFromUrl.d.ts +0 -8
  245. package/dist/dts/launch-params/retrieveLaunchParams.d.ts +0 -7
  246. package/dist/dts/launch-params/saveToStorage.d.ts +0 -7
  247. package/dist/dts/launch-params/serializeLaunchParams.d.ts +0 -7
  248. package/dist/dts/launch-params/types.d.ts +0 -51
  249. package/dist/dts/logger/Logger.d.ts +0 -29
  250. package/dist/dts/misc/createCleanup.d.ts +0 -11
  251. package/dist/dts/misc/createComponentInitFn/createComponentInitFn.d.ts +0 -16
  252. package/dist/dts/misc/createComponentInitFn/types.d.ts +0 -54
  253. package/dist/dts/misc/createSingleton.d.ts +0 -15
  254. package/dist/dts/misc/isRecord.d.ts +0 -5
  255. package/dist/dts/misc/objectFromKeys.d.ts +0 -6
  256. package/dist/dts/navigation/BasicNavigator/BasicNavigator.d.ts +0 -118
  257. package/dist/dts/navigation/BasicNavigator/prepareItem.d.ts +0 -8
  258. package/dist/dts/navigation/BasicNavigator/types.d.ts +0 -37
  259. package/dist/dts/navigation/BrowserNavigator/BrowserNavigator.d.ts +0 -198
  260. package/dist/dts/navigation/BrowserNavigator/basicItemToBrowser.d.ts +0 -7
  261. package/dist/dts/navigation/BrowserNavigator/createBrowserNavigatorFromLocation.d.ts +0 -4
  262. package/dist/dts/navigation/BrowserNavigator/prepareItem.d.ts +0 -25
  263. package/dist/dts/navigation/BrowserNavigator/types.d.ts +0 -64
  264. package/dist/dts/navigation/createSafeURL.d.ts +0 -7
  265. package/dist/dts/navigation/drop.d.ts +0 -4
  266. package/dist/dts/navigation/ensurePrefix.d.ts +0 -7
  267. package/dist/dts/navigation/getFirstNavigationEntry.d.ts +0 -6
  268. package/dist/dts/navigation/getHash.d.ts +0 -15
  269. package/dist/dts/navigation/getPathname.d.ts +0 -7
  270. package/dist/dts/navigation/go.d.ts +0 -5
  271. package/dist/dts/navigation/initNavigator.d.ts +0 -9
  272. package/dist/dts/navigation/urlToPath.d.ts +0 -7
  273. package/dist/dts/parsing/ArrayParser/ArrayParser.d.ts +0 -17
  274. package/dist/dts/parsing/ArrayParser/types.d.ts +0 -12
  275. package/dist/dts/parsing/ValueParser/ValueParser.d.ts +0 -17
  276. package/dist/dts/parsing/ValueParser/types.d.ts +0 -28
  277. package/dist/dts/parsing/createTypeError.d.ts +0 -6
  278. package/dist/dts/parsing/createValueParserGenerator.d.ts +0 -10
  279. package/dist/dts/parsing/parseBySchema.d.ts +0 -9
  280. package/dist/dts/parsing/parsers/array.d.ts +0 -7
  281. package/dist/dts/parsing/parsers/boolean.d.ts +0 -6
  282. package/dist/dts/parsing/parsers/date.d.ts +0 -6
  283. package/dist/dts/parsing/parsers/json.d.ts +0 -9
  284. package/dist/dts/parsing/parsers/number.d.ts +0 -6
  285. package/dist/dts/parsing/parsers/rgb.d.ts +0 -7
  286. package/dist/dts/parsing/parsers/searchParams.d.ts +0 -9
  287. package/dist/dts/parsing/parsers/string.d.ts +0 -6
  288. package/dist/dts/parsing/toRecord.d.ts +0 -7
  289. package/dist/dts/parsing/types.d.ts +0 -30
  290. package/dist/dts/request-id/createRequestIdGenerator.d.ts +0 -6
  291. package/dist/dts/request-id/types.d.ts +0 -9
  292. package/dist/dts/storage/storage.d.ts +0 -42
  293. package/dist/dts/supports/createSupportsFn.d.ts +0 -12
  294. package/dist/dts/supports/createSupportsParamFn.d.ts +0 -16
  295. package/dist/dts/supports/supports.d.ts +0 -16
  296. package/dist/dts/supports/types.d.ts +0 -4
  297. package/dist/dts/timeout/createTimeoutError.d.ts +0 -7
  298. package/dist/dts/timeout/sleep.d.ts +0 -5
  299. package/dist/dts/timeout/withTimeout.d.ts +0 -6
  300. package/dist/dts/types/index.d.ts +0 -6
  301. package/dist/dts/types/logical.d.ts +0 -16
  302. package/dist/dts/types/methods.d.ts +0 -16
  303. package/dist/dts/types/misc.d.ts +0 -12
  304. package/dist/dts/types/platform.d.ts +0 -4
  305. package/dist/dts/types/unions.d.ts +0 -20
  306. package/dist/dts/types/utils.d.ts +0 -24
  307. package/dist/dts/version/compareVersions.d.ts +0 -10
  308. package/dist/dts/version/types.d.ts +0 -5
  309. package/dist/index.low-level.iife.js +0 -4
  310. package/dist/index.low-level.iife.js.map +0 -1
@@ -0,0 +1,214 @@
1
+ import { Computed } from '@tma.js/signals';
2
+ import { RGB } from '@tma.js/types';
3
+ import { PostEventError } from '@tma.js/bridge';
4
+ import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
5
+ import { ButtonOptions } from '../../composables/Button.js';
6
+ import { MaybeAccessor } from '../../types.js';
7
+ import * as E from 'fp-ts/Either';
8
+ type MainButtonEither = E.Either<PostEventError, void>;
9
+ export interface MainButtonState {
10
+ isVisible: boolean;
11
+ bgColor?: RGB;
12
+ hasShineEffect: boolean;
13
+ isEnabled: boolean;
14
+ isLoaderVisible: boolean;
15
+ text: string;
16
+ textColor?: RGB;
17
+ }
18
+ export interface MainButtonOptions extends Omit<ButtonOptions<MainButtonState, 'web_app_setup_main_button'>, 'initialState' | 'method' | 'payload' | 'version'> {
19
+ /**
20
+ * Default values for different kinds of the button properties.
21
+ */
22
+ defaults: {
23
+ bgColor: MaybeAccessor<RGB>;
24
+ textColor: MaybeAccessor<RGB>;
25
+ };
26
+ }
27
+ export declare class MainButton {
28
+ constructor({ defaults, ...options }: MainButtonOptions);
29
+ /**
30
+ * The button background color.
31
+ */
32
+ readonly bgColor: Computed<RGB>;
33
+ /**
34
+ * True if the button has a shining effect.
35
+ */
36
+ readonly hasShineEffect: Computed<boolean>;
37
+ /**
38
+ * True if the button is clickable.
39
+ */
40
+ readonly isEnabled: Computed<boolean>;
41
+ /**
42
+ * True if the button loader is visible.
43
+ */
44
+ readonly isLoaderVisible: Computed<boolean>;
45
+ /**
46
+ * True if the button is visible.
47
+ */
48
+ readonly isVisible: Computed<boolean>;
49
+ /**
50
+ * Signal indicating if the component is currently mounted.
51
+ */
52
+ readonly isMounted: Computed<boolean>;
53
+ /**
54
+ * The complete button state.
55
+ */
56
+ readonly state: Computed<MainButtonState>;
57
+ /**
58
+ * The button displayed text.
59
+ */
60
+ readonly text: Computed<string>;
61
+ /**
62
+ * The button text color.
63
+ *
64
+ * Note that this value is computed based on the external defaults. For
65
+ * example, if not explicitly set, this value may be equal to one of theme
66
+ * params colors.
67
+ */
68
+ readonly textColor: Computed<RGB>;
69
+ /**
70
+ * Shows the button.
71
+ */
72
+ readonly showFp: WithChecksFp<() => MainButtonEither, false>;
73
+ /**
74
+ * @see showFp
75
+ */
76
+ readonly show: WithChecks<() => void, false>;
77
+ /**
78
+ * Hides the button.
79
+ */
80
+ readonly hideFp: WithChecksFp<() => MainButtonEither, false>;
81
+ /**
82
+ * @see hideFp
83
+ */
84
+ readonly hide: WithChecks<() => void, false>;
85
+ /**
86
+ * Enables the button.
87
+ */
88
+ readonly enableFp: WithChecksFp<() => MainButtonEither, false>;
89
+ /**
90
+ * @see enableFp
91
+ */
92
+ readonly enable: WithChecks<() => void, false>;
93
+ /**
94
+ * Enables the button.
95
+ */
96
+ readonly enableShineEffectFp: WithChecksFp<() => MainButtonEither, false>;
97
+ /**
98
+ * @see enableShineEffectFp
99
+ */
100
+ readonly enableShineEffect: WithChecks<() => void, false>;
101
+ /**
102
+ * Disables the button.
103
+ */
104
+ readonly disableFp: WithChecksFp<() => MainButtonEither, false>;
105
+ /**
106
+ * @see disableFp
107
+ */
108
+ readonly disable: WithChecks<() => void, false>;
109
+ /**
110
+ * Enables the button.
111
+ */
112
+ readonly disableShineEffectFp: WithChecksFp<() => MainButtonEither, false>;
113
+ /**
114
+ * @see disableShineEffectFp
115
+ */
116
+ readonly disableShineEffect: WithChecks<() => void, false>;
117
+ /**
118
+ * Updates the button background color.
119
+ */
120
+ readonly setBgColorFp: WithChecksFp<(value: RGB) => MainButtonEither, false>;
121
+ /**
122
+ * @see setBgColorFp
123
+ */
124
+ readonly setBgColor: WithChecks<(value: RGB) => void, false>;
125
+ /**
126
+ * Updates the button text color.
127
+ */
128
+ readonly setTextColorFp: WithChecksFp<(value: RGB) => MainButtonEither, false>;
129
+ /**
130
+ * @see setTextColorFp
131
+ */
132
+ readonly setTextColor: WithChecks<(value: RGB) => void, false>;
133
+ /**
134
+ * Updates the button text.
135
+ */
136
+ readonly setTextFp: WithChecksFp<(value: string) => MainButtonEither, false>;
137
+ /**
138
+ * @see setTextFp
139
+ */
140
+ readonly setText: WithChecks<(value: string) => void, false>;
141
+ /**
142
+ * Shows the button loader.
143
+ */
144
+ readonly showLoaderFp: WithChecksFp<() => MainButtonEither, false>;
145
+ /**
146
+ * @see showLoaderFp
147
+ */
148
+ readonly showLoader: WithChecks<() => void, false>;
149
+ /**
150
+ * Hides the button loader.
151
+ */
152
+ readonly hideLoaderFp: WithChecksFp<() => MainButtonEither, false>;
153
+ /**
154
+ * @see hideLoaderFp
155
+ */
156
+ readonly hideLoader: WithChecks<() => void, false>;
157
+ /**
158
+ * Updates the button state.
159
+ * @param state - updates to apply.
160
+ * @example
161
+ * button.setParams({
162
+ * text: 'Submit',
163
+ * isEnabled: true,
164
+ * hasShineEffect: true,
165
+ * });
166
+ */
167
+ readonly setParamsFp: WithChecksFp<(state: Partial<MainButtonState>) => MainButtonEither, false>;
168
+ readonly setParams: WithChecks<(state: Partial<MainButtonState>) => void, false>;
169
+ /**
170
+ * Mounts the component restoring its state.
171
+ */
172
+ readonly mountFp: WithChecksFp<() => void, false>;
173
+ /**
174
+ * @see mountFp
175
+ */
176
+ readonly mount: WithChecks<() => void, false>;
177
+ /**
178
+ * Unmounts the component.
179
+ */
180
+ readonly unmount: () => void;
181
+ /**
182
+ * Adds a new button listener.
183
+ * @param listener - event listener.
184
+ * @param once - should the listener be called only once.
185
+ * @returns A function to remove bound listener.
186
+ * @example
187
+ * const off = button.onClick(() => {
188
+ * console.log('User clicked the button');
189
+ * off();
190
+ * });
191
+ */
192
+ readonly onClickFp: WithChecksFp<(listener: VoidFunction, once?: boolean) => VoidFunction, false>;
193
+ /**
194
+ * @see onClickFp
195
+ */
196
+ readonly onClick: WithChecks<(listener: VoidFunction, once?: boolean) => VoidFunction, false>;
197
+ /**
198
+ * Removes the button click listener.
199
+ * @param listener - event listener.
200
+ * @param once - should the listener be called only once.
201
+ * @example
202
+ * function listener() {
203
+ * console.log('User clicked the button');
204
+ * button.offClick(listener);
205
+ * }
206
+ * button.onClick(listener);
207
+ */
208
+ readonly offClickFp: WithChecksFp<(listener: VoidFunction, once?: boolean) => void, false>;
209
+ /**
210
+ * @see offClickFp
211
+ */
212
+ readonly offClick: WithChecks<(listener: VoidFunction, once?: boolean) => void, false>;
213
+ }
214
+ export {};
@@ -0,0 +1,2 @@
1
+ export { mainButton } from './instance.js';
2
+ export { type MainButtonOptions, MainButton, type MainButtonState } from './MainButton.js';
@@ -0,0 +1,2 @@
1
+ import { MainButton } from './MainButton.js';
2
+ export declare const mainButton: MainButton;
@@ -0,0 +1,192 @@
1
+ import { KnownThemeParamsKey, RGB, ThemeParams } from '@tma.js/types';
2
+ import { Computed } from '@tma.js/signals';
3
+ import { PostEventError, EventPayload } from '@tma.js/bridge';
4
+ import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
5
+ import { CSSVarsBoundError, UnknownThemeParamsKeyError } from '../../errors.js';
6
+ import { WithPostEvent } from '../../fn-options/withPostEvent.js';
7
+ import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
8
+ import { WithVersion } from '../../fn-options/withVersion.js';
9
+ import { WithStateRestore } from '../../fn-options/withStateRestore.js';
10
+ import * as E from 'fp-ts/Either';
11
+ type AnyColor = RGB | KnownThemeParamsKey | string;
12
+ export interface MiniAppState {
13
+ bgColor: AnyColor;
14
+ bottomBarColor: AnyColor;
15
+ headerColor: AnyColor;
16
+ isActive: boolean;
17
+ }
18
+ export interface MiniAppGetCssVarNameFn {
19
+ /**
20
+ * @param property - mini app property.
21
+ * @returns Computed complete CSS variable name.
22
+ */
23
+ (property: 'bgColor' | 'bottomBarColor' | 'headerColor'): string;
24
+ }
25
+ type WithListeners<Handlers extends string, Payload> = {
26
+ [K in Handlers]: (listener: (payload: Payload) => void) => void;
27
+ };
28
+ export interface MiniAppOptions extends WithPostEvent, WithVersion, WithStateRestore<MiniAppState>, WithListeners<'onVisibilityChanged' | 'offVisibilityChanged', EventPayload<'visibility_changed'>>, SharedFeatureOptions {
29
+ /**
30
+ * The current theme parameters.
31
+ */
32
+ theme: Computed<ThemeParams>;
33
+ }
34
+ /**
35
+ * @since Mini Apps v6.1
36
+ */
37
+ export declare class MiniApp {
38
+ constructor({ storage, isPageReload, version, postEvent, isTma, theme, onVisibilityChanged, offVisibilityChanged, }: MiniAppOptions);
39
+ /**
40
+ * Signal indicating if the component is supported.
41
+ */
42
+ readonly isSupported: Computed<boolean>;
43
+ /**
44
+ * True if the current Mini App background color is recognized as dark.
45
+ */
46
+ readonly isDark: Computed<boolean>;
47
+ /**
48
+ * Signal indicating if the mini app is currently active.
49
+ */
50
+ readonly isActive: Computed<boolean>;
51
+ /**
52
+ * Complete component state.
53
+ */
54
+ readonly state: Computed<MiniAppState>;
55
+ /**
56
+ * True if the CSS variables are currently bound.
57
+ */
58
+ readonly isCssVarsBound: Computed<boolean>;
59
+ /**
60
+ * Creates CSS variables connected with the mini app.
61
+ *
62
+ * Default variables:
63
+ * - `--tg-bg-color`
64
+ * - `--tg-header-color`
65
+ * - `--tg-bottom-bar-color`
66
+ *
67
+ * Variables are being automatically updated if theme parameters were changed.
68
+ *
69
+ * @param getCSSVarName - function, returning complete CSS variable name for the specified
70
+ * mini app key.
71
+ * @returns Function to stop updating variables.
72
+ * @example Using no arguments
73
+ * miniApp.bindCssVars();
74
+ * @example Using custom CSS vars generator
75
+ * miniApp.bindCssVars(key => `--my-prefix-${key}`);
76
+ */
77
+ readonly bindCssVarsFp: WithChecksFp<(getCssVarName?: MiniAppGetCssVarNameFn) => E.Either<CSSVarsBoundError, VoidFunction>, false>;
78
+ readonly bindCssVars: WithChecks<(getCssVarName?: MiniAppGetCssVarNameFn) => VoidFunction, false>;
79
+ /**
80
+ * Signal indicating if the component is mounted.
81
+ */
82
+ readonly isMounted: Computed<boolean>;
83
+ /**
84
+ * Mounts the component.
85
+ *
86
+ * This function restores the component state and is automatically saving it in the local storage
87
+ * if it changed.
88
+ * @since Mini Apps v6.1
89
+ */
90
+ readonly mountFp: WithChecksFp<() => void, false>;
91
+ /**
92
+ * @see mount
93
+ */
94
+ readonly mount: WithChecks<() => void, false>;
95
+ /**
96
+ * Unmounts the component.
97
+ */
98
+ readonly unmount: () => void;
99
+ /**
100
+ * The Mini App background color.
101
+ *
102
+ * Represents an RGB color, or theme parameters key, like "bg_color", "secondary_bg_color", etc.
103
+ *
104
+ * Note that using a theme parameters key, background color becomes bound to the current
105
+ * theme parameters, making it automatically being updated whenever theme parameters change.
106
+ * In order to remove this bind, use an explicit RGB color.
107
+ */
108
+ readonly bgColor: Computed<AnyColor>;
109
+ /**
110
+ * RGB representation of the background color.
111
+ *
112
+ * This value requires the Theme Params component to be mounted to extract a valid RGB value
113
+ * of the color key.
114
+ */
115
+ readonly bgColorRgb: Computed<RGB | undefined>;
116
+ /**
117
+ * Updates the mini app background color.
118
+ * @since Mini Apps v6.1
119
+ */
120
+ readonly setBgColorFp: WithChecksFp<(color: AnyColor) => E.Either<PostEventError | UnknownThemeParamsKeyError, void>, true>;
121
+ /**
122
+ * @see setBgColorFp
123
+ */
124
+ readonly setBgColor: WithChecks<(color: AnyColor) => void, true>;
125
+ /**
126
+ * The Mini App header color.
127
+ */
128
+ readonly headerColor: Computed<AnyColor>;
129
+ /**
130
+ * RGB representation of the header color.
131
+ *
132
+ * This value requires the Theme Params component to be mounted to extract a valid RGB value
133
+ * of the color key.
134
+ */
135
+ readonly headerColorRgb: Computed<RGB | undefined>;
136
+ /**
137
+ * Updates the mini app header color.
138
+ * @since Mini Apps v6.1
139
+ */
140
+ readonly setHeaderColorFp: WithChecksFp<(color: AnyColor) => E.Either<PostEventError | UnknownThemeParamsKeyError, void>, true, 'rgb'>;
141
+ /**
142
+ * @see setHeaderColorFp
143
+ */
144
+ readonly setHeaderColor: WithChecks<(color: AnyColor) => void, true, 'rgb'>;
145
+ /**
146
+ * The Mini App bottom bar background color.
147
+ */
148
+ readonly bottomBarColor: Computed<AnyColor>;
149
+ /**
150
+ * RGB representation of the bottom bar background color.
151
+ *
152
+ * This value requires the Theme Params component to be mounted to extract a valid RGB value
153
+ * of the color key.
154
+ */
155
+ readonly bottomBarColorRgb: Computed<RGB | undefined>;
156
+ /**
157
+ * Updates the mini app bottom bar bg color.
158
+ * @since Mini Apps v7.10
159
+ */
160
+ readonly setBottomBarColorFp: WithChecksFp<(color: AnyColor) => E.Either<PostEventError | UnknownThemeParamsKeyError, void>, true>;
161
+ /**
162
+ * @see setBottomBarColorFp
163
+ */
164
+ readonly setBottomBarColor: WithChecks<(color: AnyColor) => void, true>;
165
+ /**
166
+ * Closes the Mini App.
167
+ * @param returnBack - should the client return to the previous activity.
168
+ */
169
+ readonly closeFp: WithChecksFp<(returnBack?: boolean) => E.Either<PostEventError, void>, false>;
170
+ /**
171
+ * @see closeFp
172
+ */
173
+ readonly close: WithChecks<(returnBack?: boolean) => void, false>;
174
+ /**
175
+ * Informs the Telegram app that the Mini App is ready to be displayed.
176
+ *
177
+ * It is recommended to call this method as early as possible, as soon as all
178
+ * essential interface elements loaded.
179
+ *
180
+ * Once this method is called, the loading placeholder is hidden and the Mini
181
+ * App shown.
182
+ *
183
+ * If the method is not called, the placeholder will be hidden only when the
184
+ * page was fully loaded.
185
+ */
186
+ readonly readyFp: WithChecksFp<() => E.Either<PostEventError, void>, false>;
187
+ /**
188
+ * @see readyFp
189
+ */
190
+ readonly ready: WithChecks<() => void, false>;
191
+ }
192
+ export {};
@@ -0,0 +1,2 @@
1
+ export { type MiniAppState, MiniApp, type MiniAppOptions, type MiniAppGetCssVarNameFn, } from './MiniApp.js';
2
+ export { miniApp } from './instance.js';
@@ -0,0 +1,2 @@
1
+ import { MiniApp } from './MiniApp.js';
2
+ export declare const miniApp: MiniApp;
@@ -0,0 +1,56 @@
1
+ import { RequestError } from '@tma.js/bridge';
2
+ import { Computed } from '@tma.js/signals';
3
+ import { BetterPromise } from 'better-promises';
4
+ import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
5
+ import { WithChecksFp, WithChecks } from '../../with-checks/withChecksFp.js';
6
+ import { ShowOptions } from './types.js';
7
+ import { ConcurrentCallError, InvalidArgumentsError } from '../../errors.js';
8
+ import { WithVersion } from '../../fn-options/withVersion.js';
9
+ import { WithRequest } from '../../fn-options/withRequest.js';
10
+ import * as TE from 'fp-ts/TaskEither';
11
+ export interface PopupOptions extends SharedFeatureOptions, WithVersion, WithRequest {
12
+ }
13
+ /**
14
+ * @since Mini Apps v6.2
15
+ */
16
+ export declare class Popup {
17
+ constructor({ version, isTma, request }: PopupOptions);
18
+ /**
19
+ * Signal indicating if any popup is currently opened.
20
+ */
21
+ readonly isOpened: Computed<boolean>;
22
+ /**
23
+ * Signal indicating if the component is supported.
24
+ */
25
+ readonly isSupported: Computed<boolean>;
26
+ /**
27
+ * A method that shows a native popup described by the `params` argument.
28
+ * The promise will be resolved when the popup is closed. Resolved value will have
29
+ * an identifier of the pressed button.
30
+ *
31
+ * If a user clicked outside the popup or clicked the top right popup close
32
+ * button, null will be resolved.
33
+ *
34
+ * @param options - popup parameters.
35
+ * @since Mini Apps v6.2
36
+ * @example
37
+ * pipe(
38
+ * popup.showFp({
39
+ * title: 'Confirm action',
40
+ * message: 'Do you really want to buy this burger?',
41
+ * buttons: [
42
+ * { id: 'yes', text: 'Yes' },
43
+ * { id: 'no', type: 'destructive', text: 'No' },
44
+ * ],
45
+ * }),
46
+ * TE.map(buttonId => {
47
+ * console.log('User clicked a button with ID', buttonId);
48
+ * }),
49
+ * );
50
+ */
51
+ readonly showFp: WithChecksFp<(options: ShowOptions) => TE.TaskEither<RequestError | InvalidArgumentsError | ConcurrentCallError, string | undefined>, true>;
52
+ /**
53
+ * @see showFp
54
+ */
55
+ readonly show: WithChecks<(options: ShowOptions) => BetterPromise<string | undefined>, true>;
56
+ }
@@ -0,0 +1,3 @@
1
+ export { popup } from './instance.js';
2
+ export { Popup, type PopupOptions } from './Popup.js';
3
+ export type { ShowOptions, ShowOptionsButton } from './types.js';
@@ -0,0 +1,2 @@
1
+ import { Popup } from './Popup.js';
2
+ export declare const popup: Popup;
@@ -0,0 +1,9 @@
1
+ import { PopupParams } from '@tma.js/bridge';
2
+ import { InvalidArgumentsError } from '../../errors.js';
3
+ import { ShowOptions } from './types.js';
4
+ import * as E from 'fp-ts/Either';
5
+ /**
6
+ * Prepares popup parameters before sending them to native app.
7
+ * @param params - popup parameters.
8
+ */
9
+ export declare function prepareParams(params: ShowOptions): E.Either<InvalidArgumentsError, PopupParams>;
@@ -1,16 +1,9 @@
1
- import { StateEvents } from '../../classes/State/types.js';
2
-
3
- export interface PopupState {
4
- isOpened: boolean;
5
- }
6
- export type PopupEvents = StateEvents<PopupState>;
7
- export type PopupEventName = keyof PopupEvents;
8
- export type PopupEventListener<E extends PopupEventName> = PopupEvents[E];
1
+ import { AsyncOptions } from '../../types.js';
9
2
  /**
10
3
  * This object describes the native popup.
11
4
  * @see https://core.telegram.org/bots/webapps#popupparams
12
5
  */
13
- export interface OpenPopupOptions {
6
+ export interface ShowOptions extends AsyncOptions {
14
7
  /**
15
8
  * The text to be displayed in the popup title, 0-64 characters.
16
9
  * @default ""
@@ -22,15 +15,15 @@ export interface OpenPopupOptions {
22
15
  message: string;
23
16
  /**
24
17
  * List of buttons to be displayed in the popup, 1-3 buttons.
25
- * @default [{type: 'close'}]
18
+ * @default [{ type: 'close' }]
26
19
  */
27
- buttons?: OpenPopupOptionsButton[];
20
+ buttons?: ShowOptionsButton[];
28
21
  }
29
22
  /**
30
23
  * This object describes the native popup button.
31
24
  * @see https://core.telegram.org/bots/webapps#popupbutton
32
25
  */
33
- export type OpenPopupOptionsButton = {
26
+ export type ShowOptionsButton = {
34
27
  /**
35
28
  * Identifier of the button, 0-64 characters.
36
29
  * @default ""
@@ -0,0 +1,132 @@
1
+ import { Computed } from '@tma.js/signals';
2
+ import { BetterTaskEitherError } from '@tma.js/toolkit';
3
+ import { BetterPromise } from 'better-promises';
4
+ import { PostEventError } from '@tma.js/bridge';
5
+ import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
6
+ import { AsyncOptions } from '../../types.js';
7
+ import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
8
+ import { WithVersion } from '../../fn-options/withVersion.js';
9
+ import { WithPostEvent } from '../../fn-options/withPostEvent.js';
10
+ import * as E from 'fp-ts/Either';
11
+ import * as TE from 'fp-ts/TaskEither';
12
+ export interface QrScannerOptions extends WithVersion, WithPostEvent, SharedFeatureOptions {
13
+ /**
14
+ * A function to add a listener to the event determining if the QR scanner
15
+ * was closed.
16
+ * @param listener - a listener to add.
17
+ * @returns A function to remove the listener.
18
+ */
19
+ onClosed: (listener: VoidFunction) => VoidFunction;
20
+ /**
21
+ * A function to add a listener to the event containing a scanned QR content.
22
+ * @param listener - a listener to add.
23
+ * @returns A function to remove the listener.
24
+ */
25
+ onTextReceived: (listener: (data: string) => void) => VoidFunction;
26
+ }
27
+ interface SharedOptions extends AsyncOptions {
28
+ /**
29
+ * Title to be displayed in the scanner.
30
+ */
31
+ text?: string;
32
+ }
33
+ interface CaptureOptions extends SharedOptions {
34
+ /**
35
+ * @returns True if the passed QR code should be captured.
36
+ * @param qr - scanned QR content.
37
+ */
38
+ capture: (qr: string) => boolean;
39
+ }
40
+ interface OpenOptions extends SharedOptions {
41
+ /**
42
+ * Function which will be called if a QR code was scanned.
43
+ * @param qr - scanned QR content.
44
+ */
45
+ onCaptured: (qr: string) => void;
46
+ }
47
+ /**
48
+ * @since Mini Apps v6.4
49
+ */
50
+ export declare class QrScanner {
51
+ constructor({ version, onClosed, onTextReceived, isTma, postEvent, }: QrScannerOptions);
52
+ /**
53
+ * Signal indicating if the scanner is currently opened.
54
+ */
55
+ readonly isOpened: Computed<boolean>;
56
+ /**
57
+ * Signal indicating if the component is supported.
58
+ */
59
+ readonly isSupported: Computed<boolean>;
60
+ /**
61
+ * Opens the scanner and returns a task which will be completed with the QR content if the
62
+ * passed `capture` function returned true.
63
+ *
64
+ * Task may also be completed with undefined if the scanner was closed.
65
+ * @param options - method options.
66
+ * @returns A promise with QR content presented as string or undefined if the scanner was closed.
67
+ * @since Mini Apps v6.4
68
+ * @example
69
+ * pipe(
70
+ * qrScanner.captureOneFp({
71
+ * capture(scannedQr) {
72
+ * return scannedQr === 'any expected by me qr';
73
+ * }
74
+ * }),
75
+ * TE.match(
76
+ * error => {
77
+ * console.error(error);
78
+ * },
79
+ * qr => {
80
+ * console.log('My QR:'), qr;
81
+ * }
82
+ * ),
83
+ * );
84
+ */
85
+ readonly captureFp: WithChecksFp<(options: CaptureOptions) => (TE.TaskEither<PostEventError | BetterTaskEitherError, string | undefined>), true>;
86
+ /**
87
+ * @see captureFp
88
+ */
89
+ readonly capture: WithChecks<(options: CaptureOptions) => BetterPromise<string | undefined>, true>;
90
+ /**
91
+ * Closes the scanner.
92
+ * @since Mini Apps v6.4
93
+ */
94
+ readonly closeFp: WithChecksFp<() => E.Either<PostEventError, void>, true>;
95
+ /**
96
+ * @see close
97
+ */
98
+ readonly close: WithChecks<() => void, true>;
99
+ /**
100
+ * Opens the scanner and returns a task which will be completed when the scanner was closed.
101
+ * @param options - method options.
102
+ * @since Mini Apps v6.4
103
+ * @example Without `capture` option
104
+ * if (qrScanner.open.isAvailable()) {
105
+ * const qr = await qrScanner.open({ text: 'Scan any QR' });
106
+ * }
107
+ * @example
108
+ * pipe(
109
+ * qrScanner.openFp({
110
+ * onCaptured(scannedQr) {
111
+ * if (scannedQr === 'any expected by me qr') {
112
+ * qrScanner.close();
113
+ * }
114
+ * }
115
+ * }),
116
+ * TE.match(
117
+ * error => {
118
+ * console.error(error);
119
+ * },
120
+ * () => {
121
+ * console.log('The scanner was closed');
122
+ * }
123
+ * ),
124
+ * );
125
+ */
126
+ readonly openFp: WithChecksFp<(options: OpenOptions) => TE.TaskEither<PostEventError, void>, true>;
127
+ /**
128
+ * @see openFp
129
+ */
130
+ readonly open: WithChecks<(options: OpenOptions) => BetterPromise<void>, true>;
131
+ }
132
+ export {};
@@ -0,0 +1,2 @@
1
+ export { QrScanner, type QrScannerOptions } from './QrScanner.js';
2
+ export { qrScanner } from './instance.js';
@@ -0,0 +1,2 @@
1
+ import { QrScanner } from './QrScanner.js';
2
+ export declare const qrScanner: QrScanner;