@tma.js/sdk 2.6.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 -1
  121. package/dist/index.cjs.map +1 -1
  122. package/dist/index.iife.js +3 -1
  123. package/dist/index.iife.js.map +1 -1
  124. package/dist/index.js +3824 -2925
  125. package/dist/index.js.map +1 -1
  126. package/package.json +19 -9
  127. package/dist/dts/bridge/events/event-emitter/createMiniAppsEventEmitter.d.ts +0 -15
  128. package/dist/dts/bridge/events/event-emitter/singleton.d.ts +0 -8
  129. package/dist/dts/bridge/events/event-handlers/cleanupEventHandlers.d.ts +0 -4
  130. package/dist/dts/bridge/events/event-handlers/defineEventHandlers.d.ts +0 -6
  131. package/dist/dts/bridge/events/event-handlers/emitMiniAppsEvent.d.ts +0 -9
  132. package/dist/dts/bridge/events/listening/off.d.ts +0 -8
  133. package/dist/dts/bridge/events/listening/on.d.ts +0 -12
  134. package/dist/dts/bridge/events/listening/subscribe.d.ts +0 -9
  135. package/dist/dts/bridge/events/listening/unsubscribe.d.ts +0 -7
  136. package/dist/dts/bridge/events/types.d.ts +0 -302
  137. package/dist/dts/bridge/methods/createPostEvent.d.ts +0 -13
  138. package/dist/dts/bridge/methods/postEvent.d.ts +0 -38
  139. package/dist/dts/bridge/methods/types/custom-methods.d.ts +0 -57
  140. package/dist/dts/bridge/methods/types/haptic.d.ts +0 -40
  141. package/dist/dts/bridge/methods/types/index.d.ts +0 -4
  142. package/dist/dts/bridge/methods/types/methods.d.ts +0 -392
  143. package/dist/dts/bridge/methods/types/popup.d.ts +0 -49
  144. package/dist/dts/bridge/parseMessage.d.ts +0 -18
  145. package/dist/dts/bridge/target-origin.d.ts +0 -13
  146. package/dist/dts/bridge/utils/captureSameReq.d.ts +0 -10
  147. package/dist/dts/bridge/utils/invokeCustomMethod.d.ts +0 -23
  148. package/dist/dts/bridge/utils/request.d.ts +0 -47
  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 -120
  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 -54
  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 -2
  310. package/dist/index.low-level.iife.js.map +0 -1
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@tma.js/sdk",
3
- "version": "2.6.1",
3
+ "version": "3.0.0",
4
4
  "description": "TypeScript Source Development Kit for Telegram Mini Apps client application.",
5
5
  "author": "Vladislav Kibenko <wolfram.deus@gmail.com>",
6
- "homepage": "https://github.com/Telegram-Mini-Apps/tma.js#readme",
6
+ "homepage": "https://github.com/Telegram-Mini-Apps/telegram-apps#readme",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git@github.com:Telegram-Mini-Apps/tma.js.git",
10
- "directory": "packages/sdk"
9
+ "url": "git@github.com:Telegram-Mini-Apps/telegram-apps.git",
10
+ "directory": "tma.js/sdk"
11
11
  },
12
12
  "bugs": {
13
- "url": "https://github.com/Telegram-Mini-Apps/tma.js/issues"
13
+ "url": "https://github.com/Telegram-Mini-Apps/telegram-apps/issues"
14
14
  },
15
15
  "keywords": [
16
16
  "telegram-mini-apps",
@@ -34,6 +34,17 @@
34
34
  "default": "./dist/index.cjs"
35
35
  }
36
36
  },
37
+ "dependencies": {
38
+ "better-promises": "^1.0.0",
39
+ "error-kid": "^1.0.2",
40
+ "fp-ts": "^2.16.11",
41
+ "valibot": "^1.1.0",
42
+ "@tma.js/bridge": "^2.1.0",
43
+ "@tma.js/signals": "^1.0.0",
44
+ "@tma.js/toolkit": "^1.0.1",
45
+ "@tma.js/transformers": "^1.1.0",
46
+ "@tma.js/types": "^1.0.1"
47
+ },
37
48
  "devDependencies": {
38
49
  "test-utils": "0.0.1",
39
50
  "tsconfig": "0.0.2"
@@ -43,12 +54,11 @@
43
54
  },
44
55
  "scripts": {
45
56
  "test": "vitest --run",
46
- "lint": "cd ../.. && eslint packages/sdk/src --ignore-pattern **/*.test.ts",
57
+ "lint": "cd ../.. && eslint tma.js/sdk/src --ignore-pattern **/*.test.ts",
47
58
  "lint:fix": "pnpm run lint --fix",
48
59
  "typecheck": "tsc --noEmit -p tsconfig.build.json",
49
- "build": "rimraf dist && pnpm run build:default && pnpm run build:iife && pnpm run build:iife:low-level",
60
+ "build": "rimraf dist && pnpm run build:default && pnpm run build:iife",
50
61
  "build:default": "vite build -c vite.config.ts",
51
- "build:iife": "vite build -c vite.iife.config.ts",
52
- "build:iife:low-level": "vite build -c vite.iife.low-level.config.ts"
62
+ "build:iife": "vite build -c vite.iife.config.ts"
53
63
  }
54
64
  }
@@ -1,15 +0,0 @@
1
- import { MiniAppsEventEmitter } from '../types.js';
2
-
3
- /**
4
- * Creates new event emitter, which handles events from the Telegram application.
5
- */
6
- export declare function createMiniAppsEventEmitter(): [
7
- /**
8
- * Created event emitter.
9
- */
10
- emitter: MiniAppsEventEmitter,
11
- /**
12
- * Function to dispose created emitter.
13
- */
14
- dispose: () => void
15
- ];
@@ -1,8 +0,0 @@
1
- import { MiniAppsEventEmitter } from '../types.js';
2
-
3
- declare const resetMiniAppsEventEmitter: () => void;
4
- /**
5
- * Returns Mini Apps event emitter singleton.
6
- */
7
- export declare function miniAppsEventEmitter(): MiniAppsEventEmitter;
8
- export { resetMiniAppsEventEmitter };
@@ -1,4 +0,0 @@
1
- /**
2
- * Removes global event handlers, used by the package.
3
- */
4
- export declare function cleanupEventHandlers(): void;
@@ -1,6 +0,0 @@
1
- /**
2
- * Defines special handlers by known paths, which are recognized by
3
- * Telegram as ports to receive events. This function also sets special
4
- * function in global window object to prevent duplicate declaration.
5
- */
6
- export declare function defineEventHandlers(): void;
@@ -1,9 +0,0 @@
1
- /**
2
- * Emits event sent from Telegram native application like it was sent in
3
- * default web environment between 2 iframes. It dispatches new MessageEvent
4
- * and expects it to be handled via `window.addEventListener('message', ...)`
5
- * as developer would do it to handle messages sent from the parent iframe.
6
- * @param eventType - event name.
7
- * @param eventData - event payload.
8
- */
9
- export declare function emitMiniAppsEvent(eventType: string, eventData: unknown): void;
@@ -1,8 +0,0 @@
1
- import { MiniAppsEventListener, MiniAppsEventName } from '../types.js';
2
-
3
- /**
4
- * Removes listener from specified event.
5
- * @param event - event to listen.
6
- * @param listener - event listener to remove.
7
- */
8
- export declare function off<E extends MiniAppsEventName>(event: E, listener: MiniAppsEventListener<E>): void;
@@ -1,12 +0,0 @@
1
- import { RemoveEventListenerFn } from '../../../events/types.js';
2
- import { MiniAppsEventListener, MiniAppsEventName } from '../types.js';
3
-
4
- /**
5
- * Adds new listener to the specified event. Returns handler
6
- * which allows to stop listening to event.
7
- * @param event - event name.
8
- * @param listener - event listener.
9
- * @param once - should listener be called only once.
10
- * @returns Function to remove bound event listener.
11
- */
12
- export declare function on<E extends MiniAppsEventName>(event: E, listener: MiniAppsEventListener<E>, once?: boolean): RemoveEventListenerFn;
@@ -1,9 +0,0 @@
1
- import { RemoveEventListenerFn } from '../../../events/types.js';
2
- import { MiniAppsSubscribeListener } from '../types.js';
3
-
4
- /**
5
- * Subscribes to all events sent from the native Telegram application.
6
- * @param listener - event listener to bind.
7
- * @returns Function to remove bound event listener.
8
- */
9
- export declare function subscribe(listener: MiniAppsSubscribeListener): RemoveEventListenerFn;
@@ -1,7 +0,0 @@
1
- import { MiniAppsSubscribeListener } from '../types.js';
2
-
3
- /**
4
- * Removes global event listener.
5
- * @param listener - event listener.
6
- */
7
- export declare function unsubscribe(listener: MiniAppsSubscribeListener): void;
@@ -1,302 +0,0 @@
1
- import { RGB } from '../../colors/types.js';
2
- import { EventListener } from '../../events/event-emitter/types.js';
3
- import { RemoveEventListenerFn } from '../../events/types.js';
4
- import { EventEmitter } from '../../events/event-emitter/EventEmitter.js';
5
- import { RequestId } from '../../request-id/types.js';
6
-
7
- export type InvoiceStatus = 'paid' | 'failed' | 'pending' | 'cancelled' | string;
8
- export type PhoneRequestedStatus = 'sent' | 'cancelled' | string;
9
- export type WriteAccessRequestedStatus = 'allowed' | string;
10
- export type BiometryType = 'finger' | 'face' | string;
11
- export type BiometryTokenUpdateStatus = 'updated' | 'removed' | string;
12
- export type BiometryAuthRequestStatus = 'failed' | 'authorized' | string;
13
- /**
14
- * Map where key is known event name, and value is its listener.
15
- * @see https://docs.telegram-mini-apps.com/platform/events
16
- */
17
- export interface MiniAppsEvents {
18
- /**
19
- * User clicked the BackButton.
20
- * @since v6.1
21
- * @see https://docs.telegram-mini-apps.com/platform/events#back-button-pressed
22
- */
23
- back_button_pressed: never;
24
- /**
25
- * Biometry authentication request completed.
26
- * @since 7.2
27
- * @see https://docs.telegram-mini-apps.com/platform/events#biometry-auth-requested
28
- */
29
- biometry_auth_requested: {
30
- /**
31
- * Authentication status.
32
- */
33
- status: BiometryAuthRequestStatus;
34
- /**
35
- * Token from the local secure storage saved previously.
36
- */
37
- token?: string;
38
- };
39
- /**
40
- * Biometry settings were received.
41
- * @since 7.2
42
- * @see https://docs.telegram-mini-apps.com/platform/events#biometry-info-received
43
- */
44
- biometry_info_received: {
45
- /**
46
- * Shows whether biometry is available.
47
- */
48
- available: false;
49
- } | {
50
- /**
51
- * Shows whether biometry is available.
52
- */
53
- available: true;
54
- /**
55
- * Shows whether permission to use biometrics has been requested.
56
- */
57
- access_requested: boolean;
58
- /**
59
- * Shows whether permission to use biometrics has been granted.
60
- */
61
- access_granted: boolean;
62
- /**
63
- * A unique device identifier that can be used to match the token to the device.
64
- */
65
- device_id: string;
66
- /**
67
- * Show whether local storage contains previously saved token.
68
- */
69
- token_saved: boolean;
70
- /**
71
- * The type of biometrics currently available on the device.
72
- */
73
- type: BiometryType;
74
- };
75
- /**
76
- * Biometry token was updated.
77
- * @since 7.2
78
- * @see https://docs.telegram-mini-apps.com/platform/events#biometry-token-updated
79
- */
80
- biometry_token_updated: {
81
- /**
82
- * Update status.
83
- */
84
- status: BiometryTokenUpdateStatus;
85
- };
86
- /**
87
- * Telegram application attempted to extract text from clipboard.
88
- * @since v6.4
89
- * @see https://docs.telegram-mini-apps.com/platform/events#clipboard-text-received
90
- */
91
- clipboard_text_received: {
92
- /**
93
- * Passed during the `web_app_read_text_from_clipboard` method invocation `req_id` value.
94
- */
95
- req_id: RequestId;
96
- /**
97
- * Data extracted from the clipboard. The returned value will have the type `string` only in
98
- * the case, application has access to the clipboard.
99
- */
100
- data?: string | null;
101
- };
102
- /**
103
- * Custom method invocation completed.
104
- * @since v6.9
105
- * @see https://docs.telegram-mini-apps.com/platform/events#custom-method-invoked
106
- */
107
- custom_method_invoked: {
108
- /**
109
- * Unique identifier of this invocation.
110
- */
111
- req_id: RequestId;
112
- /**
113
- * Method invocation successful result.
114
- */
115
- result?: unknown;
116
- /**
117
- * Method invocation error code.
118
- */
119
- error?: string;
120
- };
121
- /**
122
- * An invoice was closed.
123
- * @see https://docs.telegram-mini-apps.com/platform/events#invoice-closed
124
- */
125
- invoice_closed: {
126
- /**
127
- * Passed during the `web_app_open_invoice` method invocation `slug` value.
128
- */
129
- slug: string;
130
- /**
131
- * Invoice status.
132
- */
133
- status: InvoiceStatus;
134
- };
135
- /**
136
- * User clicked the Main Button.
137
- * @see https://docs.telegram-mini-apps.com/platform/events#main-button-pressed
138
- */
139
- main_button_pressed: never;
140
- /**
141
- * Application received phone access request status.
142
- * @since v6.9
143
- * @see https://docs.telegram-mini-apps.com/platform/events#phone-requested
144
- */
145
- phone_requested: {
146
- /**
147
- * Request status.
148
- */
149
- status: PhoneRequestedStatus;
150
- };
151
- /**
152
- * Popup was closed.
153
- * @see https://docs.telegram-mini-apps.com/platform/events#popup-closed
154
- */
155
- popup_closed: {
156
- /**
157
- * Identifier of the clicked button. In case, the popup was closed without clicking any button,
158
- * this property will be omitted.
159
- */
160
- button_id?: string;
161
- };
162
- /**
163
- * The QR scanner scanned some QR and extracted its content.
164
- * @param payload - event payload.
165
- * @since v6.4
166
- * @see https://docs.telegram-mini-apps.com/platform/events#qr-text-received
167
- */
168
- qr_text_received: {
169
- /**
170
- * Data extracted from the QR.
171
- */
172
- data?: string;
173
- };
174
- /**
175
- * Parent iframe requested current iframe reload.
176
- * @see https://docs.telegram-mini-apps.com/platform/events#reload-iframe
177
- */
178
- reload_iframe: never;
179
- /**
180
- * QR scanner was closed.
181
- * @since v6.4
182
- * @see https://docs.telegram-mini-apps.com/platform/events#scan-qr-popup-closed
183
- */
184
- scan_qr_popup_closed: never;
185
- /**
186
- * The event which is usually sent by the Telegram web application. Its payload represents
187
- * `<style/>` tag html content, a developer could use. The stylesheet described in the payload
188
- * will help the developer to stylize the app scrollbar (but he is still able to do it himself).
189
- * @see https://docs.telegram-mini-apps.com/platform/events#set-custom-style
190
- */
191
- set_custom_style: string;
192
- /**
193
- * Occurs when the Settings Button was pressed.
194
- * @since v6.1
195
- * @see https://docs.telegram-mini-apps.com/platform/events#settings-button-pressed
196
- */
197
- settings_button_pressed: never;
198
- /**
199
- * Occurs whenever theme settings are changed in the user's Telegram app
200
- * (including switching to night mode).
201
- * @see https://docs.telegram-mini-apps.com/platform/events#theme-changed
202
- */
203
- theme_changed: {
204
- /**
205
- * Map where the key is a theme stylesheet key and value is the corresponding color in
206
- * `#RRGGBB` format.
207
- */
208
- theme_params: {
209
- /**
210
- * @since v6.10
211
- */
212
- accent_text_color?: RGB;
213
- bg_color?: RGB;
214
- button_color?: RGB;
215
- button_text_color?: RGB;
216
- /**
217
- * @since v6.10
218
- */
219
- destructive_text_color?: RGB;
220
- /**
221
- * @since v6.10
222
- */
223
- header_bg_color?: RGB;
224
- hint_color?: RGB;
225
- link_color?: RGB;
226
- secondary_bg_color?: RGB;
227
- /**
228
- * @since v6.10
229
- */
230
- section_bg_color?: RGB;
231
- /**
232
- * @since v6.10
233
- */
234
- section_header_text_color?: RGB;
235
- /**
236
- * @since v6.10
237
- */
238
- subtitle_text_color?: RGB;
239
- text_color?: RGB;
240
- [key: string]: RGB | undefined;
241
- };
242
- };
243
- /**
244
- * Occurs whenever the viewport has been changed. For example, when the user started
245
- * dragging the application or called the expansion method.
246
- * @see https://docs.telegram-mini-apps.com/platform/events#viewport-changed
247
- */
248
- viewport_changed: {
249
- /**
250
- * The viewport height.
251
- */
252
- height: number;
253
- /**
254
- * The viewport width.
255
- */
256
- width: number;
257
- /**
258
- * Is the viewport currently expanded.
259
- */
260
- is_expanded: boolean;
261
- /**
262
- * Is the viewport current state stable and not going to change in the next moment.
263
- */
264
- is_state_stable: boolean;
265
- };
266
- /**
267
- * Application received write access request status.
268
- * @since v6.9
269
- * @see https://docs.telegram-mini-apps.com/platform/events#write-access-requested
270
- */
271
- write_access_requested: {
272
- /**
273
- * Request status.
274
- */
275
- status: WriteAccessRequestedStatus;
276
- };
277
- }
278
- /**
279
- * Mini Apps event name.
280
- */
281
- export type MiniAppsEventName = keyof MiniAppsEvents;
282
- /**
283
- * Payload of the specified Mini Apps event.
284
- */
285
- export type MiniAppsEventPayload<E extends MiniAppsEventName> = MiniAppsEvents[E];
286
- /**
287
- * Returns event listener for the specified Mini Apps event.
288
- */
289
- export type MiniAppsEventListener<E extends MiniAppsEventName> = EventListener<MiniAppsEvents[E]>;
290
- export interface MiniAppsEventEmitter extends Pick<EventEmitter<MiniAppsEvents>, 'on' | 'off' | 'count'> {
291
- subscribe(listener: MiniAppsSubscribeListener): RemoveEventListenerFn;
292
- unsubscribe(listener: MiniAppsSubscribeListener): void;
293
- }
294
- /**
295
- * Mini Apps event listener used in `subscribe` and `unsubscribe` functions.
296
- */
297
- export type MiniAppsSubscribeListener = (payload: {
298
- [E in MiniAppsEventName]: {
299
- name: E;
300
- payload: MiniAppsEventPayload<E>;
301
- };
302
- }[MiniAppsEventName]) => void;
@@ -1,13 +0,0 @@
1
- import { Version } from '../../version/types.js';
2
- import { PostEvent } from './postEvent.js';
3
-
4
- /**
5
- * Creates function which checks if specified method and parameters are supported. In case,
6
- * method or parameters are unsupported, an error will be thrown.
7
- * @param version - Telegram Mini Apps version.
8
- * @throws {SDKError} ERR_METHOD_UNSUPPORTED
9
- * @throws {SDKError} ERR_METHOD_PARAMETER_UNSUPPORTED
10
- * @see ERR_METHOD_UNSUPPORTED
11
- * @see ERR_METHOD_PARAMETER_UNSUPPORTED
12
- */
13
- export declare function createPostEvent(version: Version): PostEvent;
@@ -1,38 +0,0 @@
1
- import { MiniAppsMethodParams, MiniAppsMethodWithOptionalParams, MiniAppsMethodWithoutParams, MiniAppsMethodWithRequiredParams } from './types/methods.js';
2
-
3
- interface PostEventOptions {
4
- /**
5
- * Origin used while posting message. This option is only used in case, current environment
6
- * is browser (Web version of Telegram) and could be used for test purposes.
7
- * @default 'https://web.telegram.org'
8
- */
9
- targetOrigin?: string;
10
- }
11
- export type PostEvent = typeof postEvent;
12
- /**
13
- * Calls Mini Apps method with optional parameters.
14
- * @param method - method name.
15
- * @param params - method parameters.
16
- * @param options - posting options.
17
- * @throws {SDKError} ERR_UNKNOWN_ENV
18
- * @see ERR_UNKNOWN_ENV
19
- */
20
- export declare function postEvent<Method extends MiniAppsMethodWithOptionalParams>(method: Method, params?: MiniAppsMethodParams<Method>, options?: PostEventOptions): void;
21
- /**
22
- * Calls Mini Apps method without parameters.
23
- * @param method - method name.
24
- * @param options - posting options.
25
- * @throws {SDKError} ERR_UNKNOWN_ENV
26
- * @see ERR_UNKNOWN_ENV
27
- */
28
- export declare function postEvent(method: MiniAppsMethodWithoutParams, options?: PostEventOptions): void;
29
- /**
30
- * Calls Mini Apps method with parameters.
31
- * @param method - method name.
32
- * @param params - method parameters.
33
- * @param options - posting options.
34
- * @throws {SDKError} ERR_UNKNOWN_ENV
35
- * @see ERR_UNKNOWN_ENV
36
- */
37
- export declare function postEvent<Method extends MiniAppsMethodWithRequiredParams>(method: Method, params: MiniAppsMethodParams<Method>, options?: PostEventOptions): void;
38
- export {};
@@ -1,57 +0,0 @@
1
- import { RequestId } from '../../../request-id/types.js';
2
-
3
- interface CreateInvokeCustomMethodParams<M extends string, Params extends object> {
4
- /**
5
- * Unique request identifier.
6
- */
7
- req_id: RequestId;
8
- /**
9
- * Method name.
10
- */
11
- method: M;
12
- /**
13
- * Method specific parameters.
14
- */
15
- params: Params;
16
- }
17
- export interface CustomMethodsParams {
18
- /**
19
- * Deletes storage values by their keys.
20
- */
21
- deleteStorageValues: {
22
- keys: string | string[];
23
- };
24
- /**
25
- * Gets current user contact in case, Mini has access to it.
26
- */
27
- getRequestedContact: {};
28
- /**
29
- * Gets all registered storage keys.
30
- */
31
- getStorageKeys: {};
32
- /**
33
- * Gets storage values by their keys.
34
- */
35
- getStorageValues: {
36
- keys: string | string[];
37
- };
38
- /**
39
- * Saves value by specified key in the storage.
40
- */
41
- saveStorageValue: {
42
- key: string;
43
- value: string;
44
- };
45
- }
46
- /**
47
- * Known custom method name.
48
- */
49
- export type CustomMethodName = keyof CustomMethodsParams;
50
- /**
51
- * Custom method parameters.
52
- */
53
- export type CustomMethodParams<M extends CustomMethodName> = CustomMethodsParams[M];
54
- export type AnyInvokeCustomMethodParams = CreateInvokeCustomMethodParams<string, any> | {
55
- [M in CustomMethodName]: CreateInvokeCustomMethodParams<M, CustomMethodParams<M>>;
56
- }[CustomMethodName];
57
- export {};
@@ -1,40 +0,0 @@
1
- /**
2
- * Generic type which creates new types of haptic feedback.
3
- */
4
- type CreateHapticFeedbackParams<T extends string, P> = {
5
- type: T;
6
- } & P;
7
- /**
8
- * Style of impact occurred haptic event.
9
- * - `light`, indicates a collision between small or lightweight UI objects,
10
- * - `medium`, indicates a collision between medium-sized or medium-weight UI objects,
11
- * - `heavy`, indicates a collision between large or heavyweight UI objects,
12
- * - `rigid`, indicates a collision between hard or inflexible UI objects,
13
- * - `soft`, indicates a collision between soft or flexible UI objects.
14
- */
15
- export type ImpactHapticFeedbackStyle = 'light' | 'medium' | 'heavy' | 'rigid' | 'soft';
16
- /**
17
- * Type of notification occurred type event.
18
- * - `error`, indicates that a task or action has failed,
19
- * - `success`, indicates that a task or action has completed successfully,
20
- * - `warning`, indicates that a task or action produced a warning.
21
- */
22
- export type NotificationHapticFeedbackType = 'error' | 'success' | 'warning';
23
- /**
24
- * `impactOccurred` haptic feedback.
25
- */
26
- export type ImpactHapticFeedbackParams = CreateHapticFeedbackParams<'impact', {
27
- impact_style: ImpactHapticFeedbackStyle;
28
- }>;
29
- /**
30
- * `notificationOccurred` haptic feedback.
31
- */
32
- export type NotificationHapticFeedbackParams = CreateHapticFeedbackParams<'notification', {
33
- notification_type: NotificationHapticFeedbackType;
34
- }>;
35
- /**
36
- * `selectionChanged` haptic feedback.
37
- */
38
- export type SelectionHapticFeedbackParams = CreateHapticFeedbackParams<'selection_change', {}>;
39
- export type AnyHapticFeedbackParams = ImpactHapticFeedbackParams | NotificationHapticFeedbackParams | SelectionHapticFeedbackParams;
40
- export {};
@@ -1,4 +0,0 @@
1
- export * from './custom-methods.js';
2
- export * from './haptic.js';
3
- export * from './methods.js';
4
- export * from './popup.js';