@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
@@ -1,198 +0,0 @@
1
- import { EventEmitter } from '../../events/event-emitter/EventEmitter.js';
2
- import { BrowserNavigatorAnyHistoryItem, BrowserNavigatorConOptions, BrowserNavigatorEvents, BrowserNavigatorHashMode, BrowserNavigatorHistoryItem, URLLike } from './types.js';
3
-
4
- type Emitter<State> = EventEmitter<BrowserNavigatorEvents<State>>;
5
- export declare class BrowserNavigator<State = {}> {
6
- private readonly navigator;
7
- private readonly ee;
8
- readonly hashMode: BrowserNavigatorHashMode | null;
9
- readonly base: string;
10
- constructor(
11
- /**
12
- * Navigation history.
13
- */
14
- history: readonly BrowserNavigatorAnyHistoryItem<State>[],
15
- /**
16
- * Currently active history item index.
17
- */
18
- index: number, { postEvent, hashMode, base }?: BrowserNavigatorConOptions);
19
- /**
20
- * Shows whether the navigator is currently attached to the browser history.
21
- */
22
- private attached;
23
- /**
24
- * Attaches current navigator to the browser history allowing navigator to manipulate it.
25
- */
26
- attach(): Promise<void>;
27
- /**
28
- * Goes back in history by 1.
29
- */
30
- back(): void;
31
- /**
32
- * Detaches current navigator from the browser history.
33
- */
34
- detach(): void;
35
- /**
36
- * Goes forward in history.
37
- */
38
- forward(): void;
39
- /**
40
- * Current history cursor.
41
- */
42
- get index(): number;
43
- /**
44
- * Current history item identifier.
45
- */
46
- get id(): string;
47
- /**
48
- * Changes currently active history item index by the specified delta. This method doesn't
49
- * change index in case, the updated index points to the non-existing history item. This behavior
50
- * is preserved until the `fit` argument is specified.
51
- * @param delta - index delta.
52
- * @param fit - cuts the delta argument to fit the bounds `[0, history.length - 1]`.
53
- */
54
- go(delta: number, fit?: boolean): void;
55
- /**
56
- * Goes to the specified index. Method does nothing in case, passed index is out of bounds.
57
- *
58
- * If "fit" option was specified and index is out of bounds, it will be cut to the nearest
59
- * bound.
60
- * @param index - target index.
61
- * @param fit - cuts the index argument to fit the bounds `[0, history.length - 1]`.
62
- */
63
- goTo(index: number, fit?: boolean): void;
64
- /**
65
- * Current history item hash.
66
- * @see URL.hash
67
- * @example
68
- * "", "#my-hash"
69
- */
70
- get hash(): string;
71
- /**
72
- * True if navigator has items before the current item.
73
- */
74
- get hasPrev(): boolean;
75
- /**
76
- * True if navigator has items after the current item.
77
- */
78
- get hasNext(): boolean;
79
- /**
80
- * Navigation history.
81
- */
82
- get history(): BrowserNavigatorHistoryItem<State>[];
83
- /**
84
- * Handles the window "popstate" event.
85
- * @param state - event state.
86
- */
87
- private onPopState;
88
- /**
89
- * Underlying navigator change event listener.
90
- */
91
- private onNavigatorChange;
92
- /**
93
- * Adds new event listener.
94
- */
95
- on: Emitter<State>['on'];
96
- /**
97
- * Removes event listener.
98
- */
99
- off: Emitter<State>['off'];
100
- /**
101
- * Path, including pathname, search and hash.
102
- * @example Pathname only.
103
- * "/pathname"
104
- * @example Pathname + search.
105
- * "/pathname?search"
106
- * @example Pathname + hash.
107
- * "/pathname#hash"
108
- * @example Pathname + search + hash.
109
- * "/pathname?search#hash"
110
- */
111
- get path(): string;
112
- /**
113
- * Current pathname. Always starts with the slash.
114
- * @see URL.pathname
115
- * @example
116
- * "/", "/abc"
117
- */
118
- get pathname(): string;
119
- /**
120
- * Depending on the current navigation type, parses incoming path and returns it presented as
121
- * an object. In other words, this method parses the passed path and returns object, describing
122
- * how the navigator "sees" it.
123
- *
124
- * @example Hash mode is omitted.
125
- * parsePath('/abc?a=1#hash');
126
- * // { pathname: '/abc', search: '?a=1', hash: '#hash' }
127
- * parsePath('http://example.com/abc?a=1#hash');
128
- * // { pathname: '/abc', search: '?a=1', hash: '#hash' }
129
- *
130
- * @example Hash mode is enabled.
131
- * parsePath('/abc?a=1#tma?is=cool#yeah');
132
- * // { pathname: '/tma', search: '?is=cool', hash: '#yeah' }
133
- * parsePath('http://example.com/abc?a=1#tma?is=cool#yeah');
134
- * // { pathname: '/tma', search: '?is=cool', hash: '#yeah' }
135
- */
136
- parsePath(path: string | URL): URLLike;
137
- /**
138
- * Pushes new history item. Method replaces all entries after the current one with the one
139
- * being pushed. Take a note, that passed item is always relative. In case, you want to use
140
- * it as an absolute one, use the "/" prefix. Example: "/absolute", { pathname: "/absolute" }.
141
- *
142
- * To create a final path, navigator uses a method, used in the URL class constructor, resolving
143
- * a path based on the current one.
144
- * @param path - entry path.
145
- * @param state - entry state.
146
- *
147
- * @example Pushing an absolute path.
148
- * push("/absolute"); // "/absolute"
149
- *
150
- * @example Pushing a relative path.
151
- * push("relative"); // "/home/root" -> "/home/relative"
152
- *
153
- * @example Pushing query parameters.
154
- * push("/absolute?my-param=1"); // "/home/root" -> "/absolute?my-param=1"
155
- * push("relative?my-param=1"); // "/home/root" -> "/home/relative?my-param=1"
156
- * push("?my-param=1"); // "/home" -> "/home?my-param=1"
157
- *
158
- * @example Pushing hash.
159
- * push("#my-hash"); // "/home" -> "/home#my-hash"
160
- * push("relative#my-hash"); // "/home/root" -> "/home/relative#my-hash"
161
- *
162
- * @example Pushing state.
163
- * push("", { state: 'my-state' }); "/home/root" -> "/home/root"
164
- * push({ state: 'my-state' }); "/home/root" -> "/home/root"
165
- */
166
- push(path: string, state?: State): void;
167
- push(item: BrowserNavigatorAnyHistoryItem<State>): void;
168
- /**
169
- * Replaces the current history item. Has the same logic as the `push` method.
170
- * @param path - entry path.
171
- * @param state - entry state.
172
- * @see push
173
- */
174
- replace(path: string, state?: State): void;
175
- replace(item: BrowserNavigatorAnyHistoryItem<State>): void;
176
- /**
177
- * Combines the navigator `base` property with the passed path data applying the navigator
178
- * navigation mode.
179
- * @param value - path presented as string or URLLike.
180
- */
181
- renderPath(value: string | URLLike): string;
182
- /**
183
- * Synchronizes current navigator state with browser history.
184
- */
185
- private syncHistory;
186
- /**
187
- * Current query parameters.
188
- * @see URL.search
189
- * @example
190
- * "", "?", "?a=1"
191
- */
192
- get search(): string;
193
- /**
194
- * Current history item state.
195
- */
196
- get state(): State | undefined;
197
- }
198
- export {};
@@ -1,7 +0,0 @@
1
- import { BasicNavigatorHistoryItem } from '../BasicNavigator/types.js';
2
- import { BrowserNavigatorHistoryItem, BrowserNavigatorHistoryItemParams } from './types.js';
3
-
4
- /**
5
- * Converts basic navigator entry to browser navigator entry.
6
- */
7
- export declare function basicItemToBrowser<State>({ params, ...rest }: BasicNavigatorHistoryItem<BrowserNavigatorHistoryItemParams<State>>): BrowserNavigatorHistoryItem<State>;
@@ -1,4 +0,0 @@
1
- import { BrowserNavigator } from './BrowserNavigator.js';
2
- import { BrowserNavigatorConOptions } from './types.js';
3
-
4
- export declare function createBrowserNavigatorFromLocation<State>(options?: BrowserNavigatorConOptions): BrowserNavigator<State>;
@@ -1,25 +0,0 @@
1
- import { BrowserNavigatorAnyHistoryItem } from './types.js';
2
-
3
- interface PrepareItemResult<State> {
4
- id?: string;
5
- pathname: string;
6
- params: {
7
- hash: string;
8
- search: string;
9
- state?: State;
10
- };
11
- }
12
- /**
13
- * Converts a path, presented as a string to a basic navigator appropriate form.
14
- * @param path - full path.
15
- * @param relativePath - relative path.
16
- * @param state - history item state.
17
- */
18
- export declare function prepareItem<State>(path: string, relativePath: string, state?: State): PrepareItemResult<State>;
19
- /**
20
- * Converts a path, presented as an object to a basic navigator appropriate form.
21
- * @param item - history item data.
22
- * @param relativePath - relative path.
23
- */
24
- export declare function prepareItem<State>(item: BrowserNavigatorAnyHistoryItem<State>, relativePath: string): PrepareItemResult<State>;
25
- export {};
@@ -1,64 +0,0 @@
1
- import { PostEvent } from '../../bridge/methods/postEvent.js';
2
- import { BrowserNavigator } from './BrowserNavigator.js';
3
-
4
- /**
5
- * Minimal set of properties we are working with in this library.
6
- */
7
- export interface URLLike extends Pick<URL, 'pathname' | 'search' | 'hash'> {
8
- }
9
- export interface BrowserNavigatorConOptions {
10
- /**
11
- * Base navigator URL.
12
- * @default ""
13
- */
14
- base?: string;
15
- /**
16
- * Hash navigation mode. Pass null to enable MPA (Multi Page Application) navigation.
17
- * @default 'classic'
18
- */
19
- hashMode?: BrowserNavigatorHashMode | null;
20
- /**
21
- * Function to call Mini Apps methods.
22
- * @default Global postEvent function.
23
- */
24
- postEvent?: PostEvent;
25
- }
26
- export interface BrowserNavigatorHistoryItemParams<State> extends Pick<URLLike, 'search' | 'hash'> {
27
- state?: State;
28
- }
29
- export interface BrowserNavigatorHistoryItem<State> extends URLLike {
30
- id: string;
31
- state?: State;
32
- }
33
- export type BrowserNavigatorAnyHistoryItem<State> = string | Partial<BrowserNavigatorHistoryItem<State>>;
34
- /**
35
- * Hash navigation mode.
36
- * @example 'classic'
37
- * '#pathname?search'
38
- * @example 'slash'
39
- * '#/pathname?search'
40
- */
41
- export type BrowserNavigatorHashMode = 'classic' | 'slash';
42
- /**
43
- * Events supported by `BrowserNavigator`.
44
- */
45
- export interface BrowserNavigatorEvents<State> {
46
- change: {
47
- /**
48
- * Navigator instance.
49
- */
50
- navigator: BrowserNavigator<State>;
51
- /**
52
- * Navigator cursor delta.
53
- */
54
- delta: number;
55
- /**
56
- * Previous active history item.
57
- */
58
- from: BrowserNavigatorHistoryItem<State>;
59
- /**
60
- * Currently active history item.
61
- */
62
- to: BrowserNavigatorHistoryItem<State>;
63
- };
64
- }
@@ -1,7 +0,0 @@
1
- import { URLLike } from './BrowserNavigator/types.js';
2
-
3
- /**
4
- * Safely creates new instance of URL with some predefined protocol and hostname.
5
- * @param urlOrPath - URL instance or path.
6
- */
7
- export declare function createSafeURL(urlOrPath: string | Partial<URLLike>): URL;
@@ -1,4 +0,0 @@
1
- /**
2
- * Drops current browser history switching browser history cursor to the first one entry.
3
- */
4
- export declare function drop(): Promise<void>;
@@ -1,7 +0,0 @@
1
- /**
2
- * Ensures, that specified value starts with the specified prefix. If it doesn't, function appends
3
- * prefix.
4
- * @param value - value to check.
5
- * @param prefix - prefix to add.
6
- */
7
- export declare function ensurePrefix(value: string, prefix: string): string;
@@ -1,6 +0,0 @@
1
- /**
2
- * Returns the first navigation entry from window.performance.
3
- * @returns First navigation entry or null, in case performance functionality is not supported
4
- * or navigation entry was not found.
5
- */
6
- export declare function getFirstNavigationEntry(): PerformanceNavigationTiming | undefined;
@@ -1,15 +0,0 @@
1
- /**
2
- * @param value - string to take hash part from.
3
- * @returns String after the first met "#" symbol. In case, value doesn't contain hashtag, the
4
- * function will return null.
5
- *
6
- * @example No hash.
7
- * getHash('/path'); // null
8
- *
9
- * @example Has hash.
10
- * getHash('/path#abc'); // 'abc'
11
- *
12
- * @example Has double hash.
13
- * getHash('/path#abc#another'); // 'abc#another'
14
- */
15
- export declare function getHash(value: string): string | null;
@@ -1,7 +0,0 @@
1
- import { URLLike } from './BrowserNavigator/types.js';
2
-
3
- /**
4
- * Extracts pathname from the value.
5
- * @param value - source value.
6
- */
7
- export declare function getPathname(value: string | Partial<URLLike>): string;
@@ -1,5 +0,0 @@
1
- /**
2
- * Performs window.history.go operation waiting for it to be completed.
3
- * @param delta - history change delta.
4
- */
5
- export declare function go(delta: number): Promise<boolean>;
@@ -1,9 +0,0 @@
1
- import { BrowserNavigatorConOptions } from './BrowserNavigator/types.js';
2
- import { BrowserNavigator } from './BrowserNavigator/BrowserNavigator.js';
3
-
4
- /**
5
- * Initializes a standard Mini Apps navigator.
6
- * @param sessionStorageKey - session storage key, containing the navigator state.
7
- * @param options - additional BrowserNavigator options.
8
- */
9
- export declare function initNavigator<State>(sessionStorageKey: string, options?: BrowserNavigatorConOptions): BrowserNavigator<State>;
@@ -1,7 +0,0 @@
1
- import { URLLike } from './BrowserNavigator/types.js';
2
-
3
- /**
4
- * Extracts path part from a URL.
5
- * @param urlOrPath - URL instance or path.
6
- */
7
- export declare function urlToPath(urlOrPath: string | Partial<URLLike>): string;
@@ -1,17 +0,0 @@
1
- import { ValueParser } from '../ValueParser/ValueParser.js';
2
- import { ArrayParserOfResult } from '../ArrayParser/types.js';
3
- import { AnyParser } from '../types.js';
4
- import { ValueParserParseResult } from '../ValueParser/types.js';
5
-
6
- export declare class ArrayParser<ItemType, IsOptional extends boolean> extends ValueParser<unknown[], IsOptional> {
7
- private itemParser;
8
- constructor(itemParser: AnyParser<ItemType>, isOptional: IsOptional, type?: string);
9
- /**
10
- * Attempts to parse passed value
11
- * @param value - value to parse.
12
- * @throws {SDKError} ERR_PARSE
13
- * @see ERR_PARSE
14
- */
15
- parse(value: unknown): ValueParserParseResult<ItemType[], IsOptional>;
16
- of<Item>(itemParser: AnyParser<Item>): ArrayParserOfResult<this, Item, IsOptional>;
17
- }
@@ -1,12 +0,0 @@
1
- import { AnyParser } from '../types.js';
2
- import { ValueParserOverrides } from '../ValueParser/types.js';
3
-
4
- export type ArrayParserOfResult<BaseClass, ItemType, IsOptional extends boolean> = ArrayParserType<BaseClass, ItemType, IsOptional>;
5
- export interface ArrayParserOverrides<BaseClass, ItemType, IsOptional extends boolean> extends ValueParserOverrides<BaseClass, ItemType[], IsOptional> {
6
- /**
7
- * Specifies parser for each array item.
8
- * @param parser - item parser.
9
- */
10
- of<Item>(parser: AnyParser<Item>): ArrayParserOfResult<BaseClass, Item, IsOptional>;
11
- }
12
- export type ArrayParserType<BaseClass, ItemType, IsOptional extends boolean> = Omit<BaseClass, keyof ArrayParserOverrides<any, any, any>> & ArrayParserOverrides<BaseClass, ItemType, IsOptional>;
@@ -1,17 +0,0 @@
1
- import { Parser } from '../types.js';
2
- import { ValueParserOptionalResult, ValueParserParseResult } from './types.js';
3
-
4
- export declare class ValueParser<ResultType, IsOptional extends boolean> {
5
- protected parser: Parser<ResultType>;
6
- protected isOptional: IsOptional;
7
- protected type?: string | undefined;
8
- constructor(parser: Parser<ResultType>, isOptional: IsOptional, type?: string | undefined);
9
- /**
10
- * Attempts to parse passed value
11
- * @param value - value to parse.
12
- * @throws {SDKError} ERR_PARSE
13
- * @see ERR_PARSE
14
- */
15
- parse(value: unknown): ValueParserParseResult<ResultType, IsOptional>;
16
- optional(): ValueParserOptionalResult<this, ResultType>;
17
- }
@@ -1,28 +0,0 @@
1
- import { If } from '../../types/logical.js';
2
-
3
- /**
4
- * Result of "parse" function.
5
- */
6
- export type ValueParserParseResult<ResultType, IsOptional extends boolean> = ResultType | If<IsOptional, undefined, never>;
7
- /**
8
- * Result of "optional" function in ValueParser.
9
- */
10
- export type ValueParserOptionalResult<BaseClass, ResultType> = ValueParserType<BaseClass, ResultType, true>;
11
- export interface ValueParserOverrides<BaseClass, ResultType, IsOptional extends boolean> {
12
- /**
13
- * Parses incoming value applying parsing function passed via constructor.
14
- * @param value - value to parse.
15
- */
16
- parse(value: unknown): ValueParserParseResult<ResultType, IsOptional>;
17
- /**
18
- * Marks this parser result as optional. This makes the parser to check if passed value
19
- * is empty. If so, parser will return undefined value instead of passing it to the actual
20
- * parser.
21
- */
22
- optional(): ValueParserOptionalResult<BaseClass, ResultType>;
23
- }
24
- /**
25
- * Describes generated ValueParser interface. Shortly saying, this type overrides BaseClass
26
- * properties defined in ValueParser.
27
- */
28
- export type ValueParserType<BaseClass, ResultType, IsOptional extends boolean> = Omit<BaseClass, keyof ValueParserOverrides<any, any, any>> & ValueParserOverrides<BaseClass, ResultType, IsOptional>;
@@ -1,6 +0,0 @@
1
- import { SDKError } from '../errors/SDKError.js';
2
-
3
- /**
4
- * Creates instance of TypeError stating, that value has unexpected type.
5
- */
6
- export declare function createTypeError(): SDKError;
@@ -1,10 +0,0 @@
1
- import { ValueParser } from './ValueParser/ValueParser.js';
2
- import { Parser } from './types.js';
3
-
4
- export type ValueParserGenerator<T> = () => ValueParser<T, false>;
5
- /**
6
- * Creates function which generates new scalar value parser based on the specified one.
7
- * @param parser - parser to use as basic.
8
- * @param type - type name.
9
- */
10
- export declare function createValueParserGenerator<T>(parser: Parser<T>, type?: string): ValueParserGenerator<T>;
@@ -1,9 +0,0 @@
1
- import { Schema } from './types.js';
2
-
3
- /**
4
- * Parses external value by specified schema. Functions iterates over each schema field
5
- * and uses getField function to get its value from the external source.
6
- * @param schema - object schema.
7
- * @param getField - function which gets external value by its field name.
8
- */
9
- export declare function parseBySchema<T>(schema: Schema<T>, getField: (field: string) => unknown): T;
@@ -1,7 +0,0 @@
1
- import { ArrayParser } from '../ArrayParser/ArrayParser.js';
2
-
3
- /**
4
- * Parses incoming value as an array.
5
- * @param parserTypeName - parser type name.
6
- */
7
- export declare function array(parserTypeName?: string): ArrayParser<unknown, false>;
@@ -1,6 +0,0 @@
1
- import { ValueParserGenerator } from '../createValueParserGenerator.js';
2
-
3
- /**
4
- * Returns parser to parse value as boolean.
5
- */
6
- export declare const boolean: ValueParserGenerator<boolean>;
@@ -1,6 +0,0 @@
1
- import { ValueParserGenerator } from '../createValueParserGenerator.js';
2
-
3
- /**
4
- * Returns parser to parse value as Date.
5
- */
6
- export declare const date: ValueParserGenerator<Date>;
@@ -1,9 +0,0 @@
1
- import { ValueParser } from '../ValueParser/ValueParser.js';
2
- import { Schema } from '../types.js';
3
-
4
- /**
5
- * Creates new Json parser according to passed schema.
6
- * @param schema - object schema.
7
- * @param type - parser type name.
8
- */
9
- export declare function json<T>(schema: Schema<T>, type?: string): ValueParser<T, false>;
@@ -1,6 +0,0 @@
1
- import { ValueParserGenerator } from '../createValueParserGenerator.js';
2
-
3
- /**
4
- * Returns parser to parse value as number.
5
- */
6
- export declare const number: ValueParserGenerator<number>;
@@ -1,7 +0,0 @@
1
- import { RGB } from '../../colors/types.js';
2
- import { ValueParserGenerator } from '../createValueParserGenerator.js';
3
-
4
- /**
5
- * Returns parser to parse value as RGB color.
6
- */
7
- export declare const rgb: ValueParserGenerator<RGB>;
@@ -1,9 +0,0 @@
1
- import { ValueParser } from '../ValueParser/ValueParser.js';
2
- import { Schema } from '../types.js';
3
-
4
- /**
5
- * Creates new search params parser according to passed schema.
6
- * @param schema - object schema.
7
- * @param type - parser type name.
8
- */
9
- export declare function searchParams<T>(schema: Schema<T>, type?: string): ValueParser<T, false>;
@@ -1,6 +0,0 @@
1
- import { ValueParserGenerator } from '../createValueParserGenerator.js';
2
-
3
- /**
4
- * Returns parser to parse value as string.
5
- */
6
- export declare const string: ValueParserGenerator<string>;
@@ -1,7 +0,0 @@
1
- /**
2
- * Converts value to record.
3
- * @param value - value to convert.
4
- * @throws {Error} Value passed as a string does not represent JSON object.
5
- * @throws {Error} Value is not convertable.
6
- */
7
- export declare function toRecord(value: unknown): Record<string, unknown>;
@@ -1,30 +0,0 @@
1
- /**
2
- * Represents any known parser.
3
- */
4
- export type AnyParser<T> = Parser<T> | {
5
- parse: Parser<T>;
6
- };
7
- /**
8
- * Detailed schema field options.
9
- */
10
- export interface SchemaFieldDetailed<T> {
11
- /**
12
- * Source property name.
13
- * @default Original property name in schema.
14
- */
15
- from?: string;
16
- /**
17
- * Function which should parse incoming value and return expected type.
18
- */
19
- type: AnyParser<T>;
20
- }
21
- /**
22
- * Function which parses incoming value.
23
- */
24
- export type Parser<T> = (value: unknown) => T;
25
- /**
26
- * Object schema definition.
27
- */
28
- export type Schema<T> = {
29
- [K in keyof T]: AnyParser<T[K]> | SchemaFieldDetailed<T[K]>;
30
- };
@@ -1,6 +0,0 @@
1
- import { CreateRequestIdFn } from './types.js';
2
-
3
- /**
4
- * Creates function which generated request identifiers.
5
- */
6
- export declare function createRequestIdGenerator(): CreateRequestIdFn;
@@ -1,9 +0,0 @@
1
- /**
2
- * Request identifier which should be generated locally. Native Telegram application
3
- * uses it to generate a response to called method.
4
- */
5
- export type RequestId = string;
6
- /**
7
- * Function which generates unique request identifiers.
8
- */
9
- export type CreateRequestIdFn = () => RequestId;