@mtkruto/node 0.62.1 → 0.63.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 (511) hide show
  1. package/esm/2_tl.d.ts +6 -6
  2. package/esm/2_tl.d.ts.map +1 -1
  3. package/esm/2_tl.js +6 -6
  4. package/esm/3_errors.d.ts +1 -2
  5. package/esm/3_errors.d.ts.map +1 -1
  6. package/esm/3_errors.js +2 -1
  7. package/esm/4_constants.d.ts +0 -1
  8. package/esm/4_constants.d.ts.map +1 -1
  9. package/esm/4_constants.js +0 -1
  10. package/esm/4_errors.d.ts +2 -2
  11. package/esm/4_errors.d.ts.map +1 -1
  12. package/esm/4_session.d.ts +24 -0
  13. package/esm/4_session.d.ts.map +1 -0
  14. package/esm/4_session.js +23 -0
  15. package/esm/5_client.d.ts +1 -1
  16. package/esm/5_client.js +1 -1
  17. package/esm/client/0_client_abstract.d.ts +28 -26
  18. package/esm/client/0_client_abstract.d.ts.map +1 -1
  19. package/esm/client/0_client_abstract.js +16 -88
  20. package/esm/client/0_params.d.ts +5 -0
  21. package/esm/client/0_params.d.ts.map +1 -1
  22. package/esm/client/0_password.d.ts.map +1 -1
  23. package/esm/client/0_password.js +2 -2
  24. package/esm/client/0_storage_operations.d.ts +4 -4
  25. package/esm/client/0_storage_operations.d.ts.map +1 -1
  26. package/esm/client/0_storage_operations.js +14 -14
  27. package/esm/client/0_update_processor.d.ts +19 -0
  28. package/esm/client/0_update_processor.d.ts.map +1 -1
  29. package/esm/client/0_update_processor.js +19 -0
  30. package/esm/client/0_utilities.d.ts +6 -2
  31. package/esm/client/0_utilities.d.ts.map +1 -1
  32. package/esm/client/0_utilities.js +21 -23
  33. package/esm/client/1_client_plain.d.ts +9 -6
  34. package/esm/client/1_client_plain.d.ts.map +1 -1
  35. package/esm/client/1_client_plain.js +26 -41
  36. package/esm/client/1_types.d.ts +4 -23
  37. package/esm/client/1_types.d.ts.map +1 -1
  38. package/esm/client/2_account_manager.js +10 -10
  39. package/esm/client/2_business_connection_manager.d.ts.map +1 -1
  40. package/esm/client/2_business_connection_manager.js +4 -4
  41. package/esm/client/2_client_encrypted.d.ts +58 -0
  42. package/esm/client/2_client_encrypted.d.ts.map +1 -0
  43. package/esm/client/2_client_encrypted.js +265 -0
  44. package/esm/client/2_file_manager.d.ts.map +1 -1
  45. package/esm/client/2_file_manager.js +54 -74
  46. package/esm/client/2_network_statistics_manager.d.ts +1 -1
  47. package/esm/client/2_network_statistics_manager.d.ts.map +1 -1
  48. package/esm/client/2_network_statistics_manager.js +3 -3
  49. package/esm/client/2_payment_manager.d.ts.map +1 -1
  50. package/esm/client/2_payment_manager.js +3 -3
  51. package/esm/client/2_reaction_manager.d.ts.map +1 -1
  52. package/esm/client/2_reaction_manager.js +10 -10
  53. package/esm/client/2_translations_manager.d.ts +19 -0
  54. package/esm/client/2_translations_manager.d.ts.map +1 -1
  55. package/esm/client/2_translations_manager.js +24 -5
  56. package/esm/client/2_update_manager.d.ts +4 -4
  57. package/esm/client/2_update_manager.d.ts.map +1 -1
  58. package/esm/client/2_update_manager.js +69 -79
  59. package/esm/client/3_client_encrypted_pool.d.ts +30 -0
  60. package/esm/client/3_client_encrypted_pool.d.ts.map +1 -0
  61. package/esm/client/3_client_encrypted_pool.js +70 -0
  62. package/esm/client/3_message_manager.d.ts.map +1 -1
  63. package/esm/client/3_message_manager.js +96 -70
  64. package/esm/client/3_video_chat_manager.d.ts.map +1 -1
  65. package/esm/client/3_video_chat_manager.js +15 -20
  66. package/esm/client/4_callback_query_manager.d.ts.map +1 -1
  67. package/esm/client/4_callback_query_manager.js +2 -2
  68. package/esm/client/4_chat_list_manager.d.ts.map +1 -1
  69. package/esm/client/4_chat_list_manager.js +33 -33
  70. package/esm/client/4_chat_manager.d.ts.map +1 -1
  71. package/esm/client/4_chat_manager.js +25 -25
  72. package/esm/client/4_gift_manager.js +2 -2
  73. package/esm/client/4_inline_query_manager.d.ts.map +1 -1
  74. package/esm/client/4_inline_query_manager.js +4 -4
  75. package/esm/client/4_poll_manager.d.ts.map +1 -1
  76. package/esm/client/4_poll_manager.js +5 -5
  77. package/esm/client/4_story_manager.d.ts.map +1 -1
  78. package/esm/client/4_story_manager.js +10 -10
  79. package/esm/client/5_client.d.ts +3 -9
  80. package/esm/client/5_client.d.ts.map +1 -1
  81. package/esm/client/5_client.js +290 -306
  82. package/esm/connection/0_connection.d.ts +5 -4
  83. package/esm/connection/0_connection.d.ts.map +1 -1
  84. package/esm/connection/1_connection_web_socket.js +2 -2
  85. package/esm/mod.d.ts +1 -1
  86. package/esm/mod.d.ts.map +1 -1
  87. package/esm/mod.js +1 -1
  88. package/{script/tl/2_tl_reader.d.ts → esm/session/0_session_error.d.ts} +4 -7
  89. package/esm/session/0_session_error.d.ts.map +1 -0
  90. package/esm/{tl/2_tl_reader.d.ts → session/0_session_error.js} +5 -7
  91. package/esm/{tl/2_tl_writer.d.ts → session/0_session_state.d.ts} +7 -5
  92. package/esm/session/0_session_state.d.ts.map +1 -0
  93. package/esm/session/0_session_state.js +77 -0
  94. package/esm/session/1_session.d.ts +31 -0
  95. package/esm/session/1_session.d.ts.map +1 -0
  96. package/esm/session/1_session.js +149 -0
  97. package/esm/session/2_session_encrypted.d.ts +40 -0
  98. package/esm/session/2_session_encrypted.d.ts.map +1 -0
  99. package/esm/session/2_session_encrypted.js +416 -0
  100. package/esm/session/2_session_plain.d.ts +25 -0
  101. package/esm/session/2_session_plain.d.ts.map +1 -0
  102. package/esm/session/2_session_plain.js +56 -0
  103. package/esm/tl/0_tl_error.d.ts +22 -0
  104. package/esm/tl/0_tl_error.d.ts.map +1 -0
  105. package/esm/tl/0_tl_error.js +21 -0
  106. package/esm/tl/0_types.d.ts +25 -0
  107. package/esm/tl/0_types.d.ts.map +1 -0
  108. package/esm/tl/0_types.js +20 -0
  109. package/esm/tl/0_utilities.d.ts +32 -0
  110. package/esm/tl/0_utilities.d.ts.map +1 -0
  111. package/esm/tl/0_utilities.js +51 -0
  112. package/esm/tl/0_utilities_test.d.ts.map +1 -0
  113. package/esm/tl/1_mtproto_api.d.ts +371 -0
  114. package/esm/tl/1_mtproto_api.d.ts.map +1 -0
  115. package/esm/tl/1_mtproto_api.js +416 -0
  116. package/esm/tl/{0_api.d.ts → 1_telegram_api.d.ts} +23 -340
  117. package/esm/tl/1_telegram_api.d.ts.map +1 -0
  118. package/esm/tl/{0_api.js → 1_telegram_api.js} +4945 -11109
  119. package/{script/tl/0_tl_raw_reader.d.ts → esm/tl/1_tl_reader.d.ts} +5 -2
  120. package/esm/tl/1_tl_reader.d.ts.map +1 -0
  121. package/esm/tl/{2_tl_reader.js → 1_tl_reader.js} +107 -40
  122. package/esm/tl/1_tl_reader_test.d.ts.map +1 -0
  123. package/esm/tl/{0_tl_raw_writer.d.ts → 1_tl_writer.d.ts} +5 -2
  124. package/esm/tl/1_tl_writer.d.ts.map +1 -0
  125. package/esm/tl/{2_tl_writer.js → 1_tl_writer.js} +80 -23
  126. package/esm/tl/1_tl_writer_test.d.ts.map +1 -0
  127. package/esm/tl/1_utilities.d.ts +9 -24
  128. package/esm/tl/1_utilities.d.ts.map +1 -1
  129. package/esm/tl/1_utilities.js +18 -64
  130. package/esm/tl/2_message.d.ts +2 -2
  131. package/esm/tl/2_message.d.ts.map +1 -1
  132. package/esm/tl/2_message.js +7 -7
  133. package/esm/tl/2_mtproto.d.ts +33 -0
  134. package/esm/tl/2_mtproto.d.ts.map +1 -0
  135. package/esm/tl/2_mtproto.js +53 -0
  136. package/{script/tl/2_utilities.d.ts → esm/tl/2_telegram.d.ts} +16 -2
  137. package/esm/tl/2_telegram.d.ts.map +1 -0
  138. package/esm/tl/{2_utilities.js → 2_telegram.js} +46 -1
  139. package/esm/transport/0_transport.d.ts +1 -1
  140. package/esm/transport/0_transport.d.ts.map +1 -1
  141. package/esm/types/0_chat_photo.d.ts.map +1 -1
  142. package/esm/types/0_chat_photo.js +2 -2
  143. package/esm/types/0_giveaway_parameters.d.ts.map +1 -1
  144. package/esm/types/0_giveaway_parameters.js +3 -3
  145. package/esm/types/0_location.d.ts.map +1 -1
  146. package/esm/types/0_location.js +5 -5
  147. package/esm/types/0_message_entity.d.ts.map +1 -1
  148. package/esm/types/0_message_entity.js +20 -20
  149. package/esm/types/0_reaction.d.ts.map +1 -1
  150. package/esm/types/0_reaction.js +4 -4
  151. package/esm/types/0_slow_mode_duration.d.ts +19 -0
  152. package/esm/types/0_slow_mode_duration.d.ts.map +1 -1
  153. package/esm/types/0_slow_mode_duration.js +19 -0
  154. package/esm/types/0_thumbnail.d.ts.map +1 -1
  155. package/esm/types/0_thumbnail.js +3 -3
  156. package/esm/types/0_translation.d.ts +19 -0
  157. package/esm/types/0_translation.d.ts.map +1 -1
  158. package/esm/types/0_translation.js +22 -3
  159. package/esm/types/0_video_chat.d.ts.map +1 -1
  160. package/esm/types/0_video_chat.js +2 -2
  161. package/esm/types/1_animation.d.ts.map +1 -1
  162. package/esm/types/1_animation.js +2 -2
  163. package/esm/types/1_audio.d.ts.map +1 -1
  164. package/esm/types/1_audio.js +2 -2
  165. package/esm/types/1_bot_command_scope.d.ts.map +1 -1
  166. package/esm/types/1_bot_command_scope.js +2 -2
  167. package/esm/types/1_chat_p.d.ts.map +1 -1
  168. package/esm/types/1_chat_p.js +6 -6
  169. package/esm/types/1_document.d.ts.map +1 -1
  170. package/esm/types/1_document.js +2 -2
  171. package/esm/types/1_keyboard_button.d.ts.map +1 -1
  172. package/esm/types/1_keyboard_button.js +10 -10
  173. package/esm/types/1_message_reaction.d.ts.map +1 -1
  174. package/esm/types/1_message_reaction.js +6 -6
  175. package/esm/types/1_photo.d.ts.map +1 -1
  176. package/esm/types/1_photo.js +3 -3
  177. package/esm/types/1_sticker.d.ts.map +1 -1
  178. package/esm/types/1_sticker.js +8 -8
  179. package/esm/types/1_story_privacy.d.ts.map +1 -1
  180. package/esm/types/1_story_privacy.js +7 -7
  181. package/esm/types/1_user.d.ts.map +1 -1
  182. package/esm/types/1_user.js +2 -2
  183. package/esm/types/1_venue.d.ts.map +1 -1
  184. package/esm/types/1_venue.js +2 -2
  185. package/esm/types/1_video.d.ts.map +1 -1
  186. package/esm/types/1_video.js +2 -2
  187. package/esm/types/1_video_note.d.ts.map +1 -1
  188. package/esm/types/1_video_note.js +2 -2
  189. package/esm/types/2_chat.d.ts.map +1 -1
  190. package/esm/types/2_chat.js +8 -8
  191. package/esm/types/2_chat_member.d.ts.map +1 -1
  192. package/esm/types/2_chat_member.js +10 -10
  193. package/esm/types/2_chat_settings.d.ts +19 -0
  194. package/esm/types/2_chat_settings.d.ts.map +1 -1
  195. package/esm/types/2_chat_settings.js +21 -2
  196. package/esm/types/2_chosen_inline_result.d.ts.map +1 -1
  197. package/esm/types/2_chosen_inline_result.js +4 -4
  198. package/esm/types/2_game.d.ts.map +1 -1
  199. package/esm/types/2_game.js +4 -4
  200. package/esm/types/2_gift_upgraded_component.d.ts.map +1 -1
  201. package/esm/types/2_gift_upgraded_component.js +3 -3
  202. package/esm/types/2_inactive_chat.d.ts.map +1 -1
  203. package/esm/types/2_inactive_chat.js +2 -2
  204. package/esm/types/2_inline_keyboard_button.d.ts.map +1 -1
  205. package/esm/types/2_inline_keyboard_button.js +10 -10
  206. package/esm/types/2_inline_query.d.ts.map +1 -1
  207. package/esm/types/2_inline_query.js +7 -7
  208. package/esm/types/2_message_reactions.d.ts.map +1 -1
  209. package/esm/types/2_message_reactions.js +2 -2
  210. package/esm/types/2_story_content.d.ts.map +1 -1
  211. package/esm/types/2_story_content.js +6 -6
  212. package/esm/types/2_story_interactive_area.d.ts.map +1 -1
  213. package/esm/types/2_story_interactive_area.js +9 -9
  214. package/esm/types/3_chat_member_updated.d.ts.map +1 -1
  215. package/esm/types/3_chat_member_updated.js +2 -2
  216. package/esm/types/3_gift.d.ts.map +1 -1
  217. package/esm/types/3_gift.js +3 -3
  218. package/esm/types/3_join_request.d.ts.map +1 -1
  219. package/esm/types/3_join_request.js +2 -2
  220. package/esm/types/3_reply_markup.d.ts.map +1 -1
  221. package/esm/types/3_reply_markup.js +5 -5
  222. package/esm/types/4_claimed_gift.d.ts.map +1 -1
  223. package/esm/types/4_claimed_gift.js +2 -2
  224. package/esm/types/4_inline_query_result.d.ts.map +1 -1
  225. package/esm/types/4_inline_query_result.js +14 -14
  226. package/esm/types/4_message.d.ts.map +1 -1
  227. package/esm/types/4_message.js +57 -57
  228. package/esm/types/5_callback_query.d.ts.map +1 -1
  229. package/esm/types/5_callback_query.js +6 -7
  230. package/esm/types/5_chat_list_item.d.ts.map +1 -1
  231. package/esm/types/5_chat_list_item.js +5 -5
  232. package/esm/types/5_claimed_gifts.d.ts.map +1 -1
  233. package/esm/types/5_claimed_gifts.js +6 -6
  234. package/esm/types/_file_id.d.ts.map +1 -1
  235. package/esm/types/_file_id.js +3 -3
  236. package/package.json +1 -1
  237. package/script/2_tl.d.ts +6 -6
  238. package/script/2_tl.d.ts.map +1 -1
  239. package/script/2_tl.js +11 -11
  240. package/script/3_errors.d.ts +1 -2
  241. package/script/3_errors.d.ts.map +1 -1
  242. package/script/3_errors.js +2 -1
  243. package/script/4_constants.d.ts +0 -1
  244. package/script/4_constants.d.ts.map +1 -1
  245. package/script/4_constants.js +1 -2
  246. package/script/4_errors.d.ts +2 -2
  247. package/script/4_errors.d.ts.map +1 -1
  248. package/script/4_session.d.ts +24 -0
  249. package/script/4_session.d.ts.map +1 -0
  250. package/script/4_session.js +39 -0
  251. package/script/5_client.d.ts +1 -1
  252. package/script/5_client.js +1 -1
  253. package/script/client/0_client_abstract.d.ts +28 -26
  254. package/script/client/0_client_abstract.d.ts.map +1 -1
  255. package/script/client/0_client_abstract.js +18 -113
  256. package/script/client/0_params.d.ts +5 -0
  257. package/script/client/0_params.d.ts.map +1 -1
  258. package/script/client/0_password.d.ts.map +1 -1
  259. package/script/client/0_password.js +1 -1
  260. package/script/client/0_storage_operations.d.ts +4 -4
  261. package/script/client/0_storage_operations.d.ts.map +1 -1
  262. package/script/client/0_storage_operations.js +13 -13
  263. package/script/client/0_update_processor.d.ts +19 -0
  264. package/script/client/0_update_processor.d.ts.map +1 -1
  265. package/script/client/0_update_processor.js +19 -0
  266. package/script/client/0_utilities.d.ts +6 -2
  267. package/script/client/0_utilities.d.ts.map +1 -1
  268. package/script/client/0_utilities.js +22 -24
  269. package/script/client/1_client_plain.d.ts +9 -6
  270. package/script/client/1_client_plain.d.ts.map +1 -1
  271. package/script/client/1_client_plain.js +25 -40
  272. package/script/client/1_types.d.ts +4 -23
  273. package/script/client/1_types.d.ts.map +1 -1
  274. package/script/client/2_account_manager.js +9 -9
  275. package/script/client/2_business_connection_manager.d.ts.map +1 -1
  276. package/script/client/2_business_connection_manager.js +3 -3
  277. package/script/client/2_client_encrypted.d.ts +58 -0
  278. package/script/client/2_client_encrypted.d.ts.map +1 -0
  279. package/script/client/2_client_encrypted.js +269 -0
  280. package/script/client/2_file_manager.d.ts.map +1 -1
  281. package/script/client/2_file_manager.js +52 -72
  282. package/script/client/2_network_statistics_manager.d.ts +1 -1
  283. package/script/client/2_network_statistics_manager.d.ts.map +1 -1
  284. package/script/client/2_network_statistics_manager.js +3 -3
  285. package/script/client/2_payment_manager.d.ts.map +1 -1
  286. package/script/client/2_payment_manager.js +2 -2
  287. package/script/client/2_reaction_manager.d.ts.map +1 -1
  288. package/script/client/2_reaction_manager.js +9 -9
  289. package/script/client/2_translations_manager.d.ts +19 -0
  290. package/script/client/2_translations_manager.d.ts.map +1 -1
  291. package/script/client/2_translations_manager.js +23 -4
  292. package/script/client/2_update_manager.d.ts +4 -4
  293. package/script/client/2_update_manager.d.ts.map +1 -1
  294. package/script/client/2_update_manager.js +68 -78
  295. package/script/client/3_client_encrypted_pool.d.ts +30 -0
  296. package/script/client/3_client_encrypted_pool.d.ts.map +1 -0
  297. package/script/client/3_client_encrypted_pool.js +74 -0
  298. package/script/client/3_message_manager.d.ts.map +1 -1
  299. package/script/client/3_message_manager.js +95 -69
  300. package/script/client/3_video_chat_manager.d.ts.map +1 -1
  301. package/script/client/3_video_chat_manager.js +14 -19
  302. package/script/client/4_callback_query_manager.d.ts.map +1 -1
  303. package/script/client/4_callback_query_manager.js +1 -1
  304. package/script/client/4_chat_list_manager.d.ts.map +1 -1
  305. package/script/client/4_chat_list_manager.js +32 -32
  306. package/script/client/4_chat_manager.d.ts.map +1 -1
  307. package/script/client/4_chat_manager.js +24 -24
  308. package/script/client/4_gift_manager.js +1 -1
  309. package/script/client/4_inline_query_manager.d.ts.map +1 -1
  310. package/script/client/4_inline_query_manager.js +3 -3
  311. package/script/client/4_poll_manager.d.ts.map +1 -1
  312. package/script/client/4_poll_manager.js +4 -4
  313. package/script/client/4_story_manager.d.ts.map +1 -1
  314. package/script/client/4_story_manager.js +9 -9
  315. package/script/client/5_client.d.ts +3 -9
  316. package/script/client/5_client.d.ts.map +1 -1
  317. package/script/client/5_client.js +284 -300
  318. package/script/connection/0_connection.d.ts +5 -4
  319. package/script/connection/0_connection.d.ts.map +1 -1
  320. package/script/connection/1_connection_web_socket.js +2 -2
  321. package/script/mod.d.ts +1 -1
  322. package/script/mod.d.ts.map +1 -1
  323. package/script/mod.js +1 -2
  324. package/script/session/0_session_error.d.ts +24 -0
  325. package/script/session/0_session_error.d.ts.map +1 -0
  326. package/script/session/0_session_error.js +29 -0
  327. package/script/{tl/2_tl_writer.d.ts → session/0_session_state.d.ts} +7 -5
  328. package/script/session/0_session_state.d.ts.map +1 -0
  329. package/script/session/0_session_state.js +81 -0
  330. package/script/session/1_session.d.ts +31 -0
  331. package/script/session/1_session.d.ts.map +1 -0
  332. package/script/session/1_session.js +176 -0
  333. package/script/session/2_session_encrypted.d.ts +40 -0
  334. package/script/session/2_session_encrypted.d.ts.map +1 -0
  335. package/script/session/2_session_encrypted.js +420 -0
  336. package/script/session/2_session_plain.d.ts +25 -0
  337. package/script/session/2_session_plain.d.ts.map +1 -0
  338. package/script/session/2_session_plain.js +60 -0
  339. package/script/tl/0_tl_error.d.ts +22 -0
  340. package/script/tl/0_tl_error.d.ts.map +1 -0
  341. package/script/tl/0_tl_error.js +25 -0
  342. package/script/tl/0_types.d.ts +25 -0
  343. package/script/tl/0_types.d.ts.map +1 -0
  344. package/script/tl/0_types.js +21 -0
  345. package/script/tl/0_utilities.d.ts +32 -0
  346. package/script/tl/0_utilities.d.ts.map +1 -0
  347. package/script/tl/0_utilities.js +59 -0
  348. package/script/tl/0_utilities_test.d.ts.map +1 -0
  349. package/script/tl/1_mtproto_api.d.ts +371 -0
  350. package/script/tl/1_mtproto_api.d.ts.map +1 -0
  351. package/script/tl/1_mtproto_api.js +419 -0
  352. package/script/tl/{0_api.d.ts → 1_telegram_api.d.ts} +23 -340
  353. package/script/tl/1_telegram_api.d.ts.map +1 -0
  354. package/script/tl/{0_api.js → 1_telegram_api.js} +4947 -11134
  355. package/{esm/tl/0_tl_raw_reader.d.ts → script/tl/1_tl_reader.d.ts} +5 -2
  356. package/script/tl/1_tl_reader.d.ts.map +1 -0
  357. package/script/tl/1_tl_reader.js +218 -0
  358. package/script/tl/1_tl_reader_test.d.ts.map +1 -0
  359. package/script/tl/{0_tl_raw_writer.d.ts → 1_tl_writer.d.ts} +5 -2
  360. package/script/tl/1_tl_writer.d.ts.map +1 -0
  361. package/script/tl/{2_tl_writer.js → 1_tl_writer.js} +102 -45
  362. package/script/tl/1_tl_writer_test.d.ts.map +1 -0
  363. package/script/tl/1_utilities.d.ts +9 -24
  364. package/script/tl/1_utilities.d.ts.map +1 -1
  365. package/script/tl/1_utilities.js +19 -72
  366. package/script/tl/2_message.d.ts +2 -2
  367. package/script/tl/2_message.d.ts.map +1 -1
  368. package/script/tl/2_message.js +7 -7
  369. package/script/tl/2_mtproto.d.ts +33 -0
  370. package/script/tl/2_mtproto.d.ts.map +1 -0
  371. package/script/tl/2_mtproto.js +78 -0
  372. package/{esm/tl/2_utilities.d.ts → script/tl/2_telegram.d.ts} +16 -2
  373. package/script/tl/2_telegram.d.ts.map +1 -0
  374. package/script/tl/2_telegram.js +167 -0
  375. package/script/transport/0_transport.d.ts +1 -1
  376. package/script/transport/0_transport.d.ts.map +1 -1
  377. package/script/types/0_chat_photo.d.ts.map +1 -1
  378. package/script/types/0_chat_photo.js +1 -1
  379. package/script/types/0_giveaway_parameters.d.ts.map +1 -1
  380. package/script/types/0_giveaway_parameters.js +2 -2
  381. package/script/types/0_location.d.ts.map +1 -1
  382. package/script/types/0_location.js +4 -4
  383. package/script/types/0_message_entity.d.ts.map +1 -1
  384. package/script/types/0_message_entity.js +19 -19
  385. package/script/types/0_reaction.d.ts.map +1 -1
  386. package/script/types/0_reaction.js +3 -3
  387. package/script/types/0_slow_mode_duration.d.ts +19 -0
  388. package/script/types/0_slow_mode_duration.d.ts.map +1 -1
  389. package/script/types/0_slow_mode_duration.js +19 -0
  390. package/script/types/0_thumbnail.d.ts.map +1 -1
  391. package/script/types/0_thumbnail.js +2 -2
  392. package/script/types/0_translation.d.ts +19 -0
  393. package/script/types/0_translation.d.ts.map +1 -1
  394. package/script/types/0_translation.js +21 -2
  395. package/script/types/0_video_chat.d.ts.map +1 -1
  396. package/script/types/0_video_chat.js +1 -1
  397. package/script/types/1_animation.d.ts.map +1 -1
  398. package/script/types/1_animation.js +1 -1
  399. package/script/types/1_audio.d.ts.map +1 -1
  400. package/script/types/1_audio.js +1 -1
  401. package/script/types/1_bot_command_scope.d.ts.map +1 -1
  402. package/script/types/1_bot_command_scope.js +1 -1
  403. package/script/types/1_chat_p.d.ts.map +1 -1
  404. package/script/types/1_chat_p.js +5 -5
  405. package/script/types/1_document.d.ts.map +1 -1
  406. package/script/types/1_document.js +1 -1
  407. package/script/types/1_keyboard_button.d.ts.map +1 -1
  408. package/script/types/1_keyboard_button.js +9 -9
  409. package/script/types/1_message_reaction.d.ts.map +1 -1
  410. package/script/types/1_message_reaction.js +5 -5
  411. package/script/types/1_photo.d.ts.map +1 -1
  412. package/script/types/1_photo.js +2 -2
  413. package/script/types/1_sticker.d.ts.map +1 -1
  414. package/script/types/1_sticker.js +7 -7
  415. package/script/types/1_story_privacy.d.ts.map +1 -1
  416. package/script/types/1_story_privacy.js +6 -6
  417. package/script/types/1_user.d.ts.map +1 -1
  418. package/script/types/1_user.js +1 -1
  419. package/script/types/1_venue.d.ts.map +1 -1
  420. package/script/types/1_venue.js +1 -1
  421. package/script/types/1_video.d.ts.map +1 -1
  422. package/script/types/1_video.js +1 -1
  423. package/script/types/1_video_note.d.ts.map +1 -1
  424. package/script/types/1_video_note.js +1 -1
  425. package/script/types/2_chat.d.ts.map +1 -1
  426. package/script/types/2_chat.js +7 -7
  427. package/script/types/2_chat_member.d.ts.map +1 -1
  428. package/script/types/2_chat_member.js +9 -9
  429. package/script/types/2_chat_settings.d.ts +19 -0
  430. package/script/types/2_chat_settings.d.ts.map +1 -1
  431. package/script/types/2_chat_settings.js +20 -1
  432. package/script/types/2_chosen_inline_result.d.ts.map +1 -1
  433. package/script/types/2_chosen_inline_result.js +3 -3
  434. package/script/types/2_game.d.ts.map +1 -1
  435. package/script/types/2_game.js +3 -3
  436. package/script/types/2_gift_upgraded_component.d.ts.map +1 -1
  437. package/script/types/2_gift_upgraded_component.js +2 -2
  438. package/script/types/2_inactive_chat.d.ts.map +1 -1
  439. package/script/types/2_inactive_chat.js +1 -1
  440. package/script/types/2_inline_keyboard_button.d.ts.map +1 -1
  441. package/script/types/2_inline_keyboard_button.js +9 -9
  442. package/script/types/2_inline_query.d.ts.map +1 -1
  443. package/script/types/2_inline_query.js +6 -6
  444. package/script/types/2_message_reactions.d.ts.map +1 -1
  445. package/script/types/2_message_reactions.js +1 -1
  446. package/script/types/2_story_content.d.ts.map +1 -1
  447. package/script/types/2_story_content.js +5 -5
  448. package/script/types/2_story_interactive_area.d.ts.map +1 -1
  449. package/script/types/2_story_interactive_area.js +8 -8
  450. package/script/types/3_chat_member_updated.d.ts.map +1 -1
  451. package/script/types/3_chat_member_updated.js +1 -1
  452. package/script/types/3_gift.d.ts.map +1 -1
  453. package/script/types/3_gift.js +2 -2
  454. package/script/types/3_join_request.d.ts.map +1 -1
  455. package/script/types/3_join_request.js +1 -1
  456. package/script/types/3_reply_markup.d.ts.map +1 -1
  457. package/script/types/3_reply_markup.js +4 -4
  458. package/script/types/4_claimed_gift.d.ts.map +1 -1
  459. package/script/types/4_claimed_gift.js +1 -1
  460. package/script/types/4_inline_query_result.d.ts.map +1 -1
  461. package/script/types/4_inline_query_result.js +13 -13
  462. package/script/types/4_message.d.ts.map +1 -1
  463. package/script/types/4_message.js +56 -56
  464. package/script/types/5_callback_query.d.ts.map +1 -1
  465. package/script/types/5_callback_query.js +5 -6
  466. package/script/types/5_chat_list_item.d.ts.map +1 -1
  467. package/script/types/5_chat_list_item.js +4 -4
  468. package/script/types/5_claimed_gifts.d.ts.map +1 -1
  469. package/script/types/5_claimed_gifts.js +5 -5
  470. package/script/types/_file_id.d.ts.map +1 -1
  471. package/script/types/_file_id.js +2 -2
  472. package/esm/client/0_message.d.ts +0 -29
  473. package/esm/client/0_message.d.ts.map +0 -1
  474. package/esm/client/0_message.js +0 -83
  475. package/esm/client/1_client_encrypted.d.ts +0 -52
  476. package/esm/client/1_client_encrypted.d.ts.map +0 -1
  477. package/esm/client/1_client_encrypted.js +0 -381
  478. package/esm/tl/0_api.d.ts.map +0 -1
  479. package/esm/tl/0_tl_raw_reader.d.ts.map +0 -1
  480. package/esm/tl/0_tl_raw_reader.js +0 -97
  481. package/esm/tl/0_tl_raw_reader_test.d.ts.map +0 -1
  482. package/esm/tl/0_tl_raw_writer.d.ts.map +0 -1
  483. package/esm/tl/0_tl_raw_writer.js +0 -86
  484. package/esm/tl/0_tl_raw_writer_test.d.ts.map +0 -1
  485. package/esm/tl/1_utilities_test.d.ts.map +0 -1
  486. package/esm/tl/2_tl_reader.d.ts.map +0 -1
  487. package/esm/tl/2_tl_reader_test.d.ts.map +0 -1
  488. package/esm/tl/2_tl_writer.d.ts.map +0 -1
  489. package/esm/tl/2_tl_writer_test.d.ts.map +0 -1
  490. package/esm/tl/2_utilities.d.ts.map +0 -1
  491. package/script/client/0_message.d.ts +0 -29
  492. package/script/client/0_message.d.ts.map +0 -1
  493. package/script/client/0_message.js +0 -90
  494. package/script/client/1_client_encrypted.d.ts +0 -52
  495. package/script/client/1_client_encrypted.d.ts.map +0 -1
  496. package/script/client/1_client_encrypted.js +0 -385
  497. package/script/tl/0_api.d.ts.map +0 -1
  498. package/script/tl/0_tl_raw_reader.d.ts.map +0 -1
  499. package/script/tl/0_tl_raw_reader.js +0 -102
  500. package/script/tl/0_tl_raw_reader_test.d.ts.map +0 -1
  501. package/script/tl/0_tl_raw_writer.d.ts.map +0 -1
  502. package/script/tl/0_tl_raw_writer.js +0 -90
  503. package/script/tl/0_tl_raw_writer_test.d.ts.map +0 -1
  504. package/script/tl/1_utilities_test.d.ts.map +0 -1
  505. package/script/tl/2_tl_reader.d.ts.map +0 -1
  506. package/script/tl/2_tl_reader.js +0 -150
  507. package/script/tl/2_tl_reader_test.d.ts.map +0 -1
  508. package/script/tl/2_tl_writer.d.ts.map +0 -1
  509. package/script/tl/2_tl_writer_test.d.ts.map +0 -1
  510. package/script/tl/2_utilities.d.ts.map +0 -1
  511. package/script/tl/2_utilities.js +0 -98
@@ -17,9 +17,11 @@
17
17
  * You should have received a copy of the GNU Lesser General Public License
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
+ import { Schema } from "./0_types.js";
20
21
  export declare class TLError extends Error {
21
22
  }
22
- export declare class TLRawReader {
23
+ export declare class TLReader {
24
+ #private;
23
25
  protected _buffer: Uint8Array;
24
26
  constructor(_buffer: Uint8Array);
25
27
  get buffer(): Uint8Array;
@@ -34,5 +36,6 @@ export declare class TLRawReader {
34
36
  readInt256(signed?: boolean): bigint;
35
37
  readBytes(): Uint8Array;
36
38
  readString(): string;
39
+ readType(name: string, schema: Schema): Promise<any>;
37
40
  }
38
- //# sourceMappingURL=0_tl_raw_reader.d.ts.map
41
+ //# sourceMappingURL=1_tl_reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"1_tl_reader.d.ts","sourceRoot":"","sources":["../../src/tl/1_tl_reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAoB,MAAM,EAAE,MAAM,cAAc,CAAC;AAGxD,qBAAa,OAAQ,SAAQ,KAAK;CAEjC;AAED,qBAAa,QAAQ;;IACP,SAAS,CAAC,OAAO,EAAE,UAAU;gBAAnB,OAAO,EAAE,UAAU;IAGzC,IAAI,MAAM,IAAI,UAAU,CAEvB;IAED,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU;IAS/B,MAAM,CAAC,KAAK,EAAE,MAAM;IAQpB,SAAS,CAAC,MAAM,UAAO,GAAG,MAAM;IAKhC,SAAS,CAAC,MAAM,UAAO,GAAG,MAAM;IAKhC,WAAW;IAIX,SAAS,CAAC,MAAM,UAAO,GAAG,MAAM;IAKhC,UAAU,IAAI,MAAM;IAKpB,UAAU,CAAC,MAAM,UAAO,GAAG,MAAM;IAKjC,UAAU,CAAC,MAAM,UAAO,GAAG,MAAM;IAKjC,SAAS,IAAI,UAAU;IAiBvB,UAAU,IAAI,MAAM;IAId,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;CAmH3D"}
@@ -0,0 +1,218 @@
1
+ "use strict";
2
+ /**
3
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
4
+ * Copyright (C) 2023-2025 Roj <https://roj.im/>
5
+ *
6
+ * This file is part of MTKruto.
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU Lesser General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU Lesser General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU Lesser General Public License
19
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+ */
21
+ // deno-lint-ignore-file no-explicit-any
22
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
23
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
24
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
25
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
26
+ };
27
+ var _TLReader_instances, _TLReader_deserializeEnum, _TLReader_deserializeType, _TLReader_deserializeVector, _TLReader_deserializePrimitive;
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.TLReader = exports.TLError = void 0;
30
+ const _1_utilities_js_1 = require("../1_utilities.js");
31
+ const _0_utilities_js_1 = require("./0_utilities.js");
32
+ class TLError extends Error {
33
+ }
34
+ exports.TLError = TLError;
35
+ class TLReader {
36
+ constructor(_buffer) {
37
+ _TLReader_instances.add(this);
38
+ Object.defineProperty(this, "_buffer", {
39
+ enumerable: true,
40
+ configurable: true,
41
+ writable: true,
42
+ value: _buffer
43
+ });
44
+ }
45
+ get buffer() {
46
+ return this._buffer;
47
+ }
48
+ read(count) {
49
+ if (this._buffer.length < count) {
50
+ throw new TLError("No data remaining");
51
+ }
52
+ const buffer = this._buffer.slice(0, count);
53
+ this._buffer = this._buffer.subarray(count);
54
+ return buffer;
55
+ }
56
+ unread(count) {
57
+ const newOffest = this._buffer.byteOffset - count;
58
+ if (newOffest < 0) {
59
+ throw new TLError("No data has been read");
60
+ }
61
+ this._buffer = new Uint8Array(this._buffer.buffer, newOffest);
62
+ }
63
+ readInt24(signed = true) {
64
+ const buffer = this.read(24 / 8);
65
+ return Number((0, _1_utilities_js_1.bigIntFromBuffer)(buffer, true, signed));
66
+ }
67
+ readInt32(signed = true) {
68
+ const buffer = this.read(32 / 8);
69
+ return Number((0, _1_utilities_js_1.bigIntFromBuffer)(buffer, true, signed));
70
+ }
71
+ unreadInt32() {
72
+ this.unread(32 / 8);
73
+ }
74
+ readInt64(signed = true) {
75
+ const buffer = this.read(64 / 8);
76
+ return (0, _1_utilities_js_1.bigIntFromBuffer)(buffer, true, signed);
77
+ }
78
+ readDouble() {
79
+ const buffer = this.read(8);
80
+ return new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).getFloat64(0, true);
81
+ }
82
+ readInt128(signed = true) {
83
+ const buffer = this.read(128 / 8);
84
+ return (0, _1_utilities_js_1.bigIntFromBuffer)(buffer, true, signed);
85
+ }
86
+ readInt256(signed = true) {
87
+ const buffer = this.read(256 / 8);
88
+ return (0, _1_utilities_js_1.bigIntFromBuffer)(buffer, true, signed);
89
+ }
90
+ readBytes() {
91
+ let L = this.read(1)[0];
92
+ let padding;
93
+ if (L > 253) {
94
+ L = this.readInt24();
95
+ padding = L % 4;
96
+ }
97
+ else {
98
+ padding = (L + 1) % 4;
99
+ }
100
+ const bytes = this.read(L);
101
+ if (padding > 0) {
102
+ padding = 4 - padding;
103
+ this.read(padding);
104
+ }
105
+ return bytes;
106
+ }
107
+ readString() {
108
+ return new TextDecoder().decode(this.readBytes());
109
+ }
110
+ async readType(name, schema) {
111
+ if ((0, _0_utilities_js_1.isOptionalParam)(name)) {
112
+ name = (0, _0_utilities_js_1.getOptionalParamInnerType)(name);
113
+ }
114
+ const primitive = __classPrivateFieldGet(this, _TLReader_instances, "m", _TLReader_deserializePrimitive).call(this, name);
115
+ if (primitive !== undefined) {
116
+ return primitive;
117
+ }
118
+ const id = this.readInt32(false);
119
+ if (name == _0_utilities_js_1.X) {
120
+ const typeName = schema.identifierToName[id];
121
+ if (!typeName) {
122
+ throw new TLError(`Unknown constructor: ${id.toString(16)}`);
123
+ }
124
+ this.unreadInt32();
125
+ return await this.readType(typeName, schema);
126
+ }
127
+ if (id == _0_utilities_js_1.VECTOR) {
128
+ return await __classPrivateFieldGet(this, _TLReader_instances, "m", _TLReader_deserializeVector).call(this, name, schema);
129
+ }
130
+ const definition = schema.definitions[name];
131
+ if (definition) {
132
+ return await __classPrivateFieldGet(this, _TLReader_instances, "m", _TLReader_deserializeType).call(this, name, definition, id, schema);
133
+ }
134
+ const deserializedEnum = await __classPrivateFieldGet(this, _TLReader_instances, "m", _TLReader_deserializeEnum).call(this, name, id, schema);
135
+ if (deserializedEnum !== undefined) {
136
+ return deserializedEnum;
137
+ }
138
+ throw new TLError(`Unknown type: ${name} ID ${id}`);
139
+ }
140
+ }
141
+ exports.TLReader = TLReader;
142
+ _TLReader_instances = new WeakSet(), _TLReader_deserializeEnum = async function _TLReader_deserializeEnum(type, id, schema) {
143
+ const name = schema.identifierToName[id];
144
+ if (!name) {
145
+ return;
146
+ }
147
+ const definition = schema.definitions[name];
148
+ if (definition[2] != type) {
149
+ return;
150
+ }
151
+ return await __classPrivateFieldGet(this, _TLReader_instances, "m", _TLReader_deserializeType).call(this, name, definition, id, schema);
152
+ }, _TLReader_deserializeType = async function _TLReader_deserializeType(type, desc, id, schema) {
153
+ if (desc[0] != id) {
154
+ throw new TLError(`Expected constructor ${desc[0].toString(16)} but got ${id}`);
155
+ }
156
+ const type_ = { _: type };
157
+ const flagFields = {};
158
+ for (const [name, type] of desc[1]) {
159
+ if ((0, _0_utilities_js_1.isOptionalParam)(type)) {
160
+ const { flagField, bitIndex } = (0, _0_utilities_js_1.analyzeOptionalParam)(type);
161
+ const bits = flagFields[flagField];
162
+ if ((bits & (1 << bitIndex)) == 0) {
163
+ continue;
164
+ }
165
+ }
166
+ if (type == "#") {
167
+ flagFields[name] = this.readInt32();
168
+ continue;
169
+ }
170
+ const value = await this.readType(type, schema);
171
+ if (typeof value !== "boolean" || value) {
172
+ type_[name] = value;
173
+ }
174
+ }
175
+ return type_;
176
+ }, _TLReader_deserializeVector = async function _TLReader_deserializeVector(type, schema) {
177
+ const itemType = (0, _0_utilities_js_1.getVectorItemType)(type);
178
+ if (!itemType) {
179
+ throw new TLError(`Expected Vector but received ${type}`);
180
+ }
181
+ const size = this.readInt32();
182
+ const array = new Array();
183
+ for (let i = 0; i < size; ++i) {
184
+ array.push(await this.readType(itemType, schema));
185
+ }
186
+ return array;
187
+ }, _TLReader_deserializePrimitive = function _TLReader_deserializePrimitive(type) {
188
+ switch (type) {
189
+ case "bytes":
190
+ return this.readBytes();
191
+ case "int128":
192
+ return this.readInt128();
193
+ case "int256":
194
+ return this.readInt256();
195
+ case "double":
196
+ return this.readDouble();
197
+ case "long":
198
+ return this.readInt64();
199
+ case "true":
200
+ return true;
201
+ case "int":
202
+ return this.readInt32();
203
+ case "Bool": {
204
+ const id = this.readInt32(false);
205
+ if (id == _0_utilities_js_1.BOOL_TRUE) {
206
+ return true;
207
+ }
208
+ else if (id == _0_utilities_js_1.BOOL_FALSE) {
209
+ return false;
210
+ }
211
+ else {
212
+ throw new TLError(`Expected boolTrue or boolFalse but got ${id}`);
213
+ }
214
+ }
215
+ case "string":
216
+ return this.readString();
217
+ }
218
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"1_tl_reader_test.d.ts","sourceRoot":"","sources":["../../src/tl/1_tl_reader_test.ts"],"names":[],"mappings":""}
@@ -17,7 +17,9 @@
17
17
  * You should have received a copy of the GNU Lesser General Public License
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
- export declare class TLRawWriter {
20
+ import { Schema } from "./0_types.js";
21
+ export declare class TLWriter {
22
+ #private;
21
23
  protected _buffer: Uint8Array;
22
24
  constructor();
23
25
  get buffer(): Uint8Array;
@@ -30,5 +32,6 @@ export declare class TLRawWriter {
30
32
  writeInt256(int: bigint, signed?: boolean): typeof this;
31
33
  writeBytes(bytes: Uint8Array): typeof this;
32
34
  writeString(string: string): typeof this;
35
+ writeObject(value: any, schema: Schema): typeof this;
33
36
  }
34
- //# sourceMappingURL=0_tl_raw_writer.d.ts.map
37
+ //# sourceMappingURL=1_tl_writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"1_tl_writer.d.ts","sourceRoot":"","sources":["../../src/tl/1_tl_writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtC,qBAAa,QAAQ;;IACnB,SAAS,CAAC,OAAO,EAAE,UAAU,CAAoB;;IAKjD,IAAI,MAAM,IAAI,UAAU,CAEvB;IAED,KAAK,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,IAAI;IAKtC,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,UAAO,GAAG,OAAO,IAAI;IAKnD,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,UAAO,GAAG,OAAO,IAAI;IAKnD,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,UAAO,GAAG,OAAO,IAAI;IAKnD,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,IAAI;IAOxC,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,UAAO,GAAG,OAAO,IAAI;IAKpD,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,UAAO,GAAG,OAAO,IAAI;IAKpD,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,IAAI;IAkB1C,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,IAAI;IAKxC,WAAW,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,IAAI;CAkLrD"}
@@ -18,6 +18,7 @@
18
18
  * You should have received a copy of the GNU Lesser General Public License
19
19
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
20
  */
21
+ // deno-lint-ignore-file no-explicit-any
21
22
  var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
22
23
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
23
24
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
@@ -26,43 +27,100 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
26
27
  var _TLWriter_instances, _TLWriter_serialize, _TLWriter_serializeVector, _TLWriter_serializePrimitive, _TLWriter_isTypeValid;
27
28
  Object.defineProperty(exports, "__esModule", { value: true });
28
29
  exports.TLWriter = void 0;
29
- // deno-lint-ignore-file no-explicit-any
30
- const _0_api_js_1 = require("./0_api.js");
31
- const _0_tl_raw_reader_js_1 = require("./0_tl_raw_reader.js");
32
- const _0_tl_raw_writer_js_1 = require("./0_tl_raw_writer.js");
33
- const _1_utilities_js_1 = require("./1_utilities.js");
34
- class TLWriter extends _0_tl_raw_writer_js_1.TLRawWriter {
30
+ const _0_deps_js_1 = require("../0_deps.js");
31
+ const _0_tl_error_js_1 = require("./0_tl_error.js");
32
+ const _0_utilities_js_1 = require("./0_utilities.js");
33
+ const _0_buffer_js_1 = require("../utilities/0_buffer.js");
34
+ class TLWriter {
35
35
  constructor() {
36
- super(...arguments);
37
36
  _TLWriter_instances.add(this);
37
+ Object.defineProperty(this, "_buffer", {
38
+ enumerable: true,
39
+ configurable: true,
40
+ writable: true,
41
+ value: new Uint8Array()
42
+ });
43
+ }
44
+ get buffer() {
45
+ return this._buffer;
46
+ }
47
+ write(buffer) {
48
+ this._buffer = (0, _0_deps_js_1.concat)([this._buffer, buffer]);
49
+ return this;
50
+ }
51
+ writeInt24(int, signed = true) {
52
+ this.write((0, _0_buffer_js_1.bufferFromBigInt)(int, 24 / 8, true, signed));
53
+ return this;
54
+ }
55
+ writeInt32(int, signed = true) {
56
+ this.write((0, _0_buffer_js_1.bufferFromBigInt)(int, 32 / 8, true, signed));
57
+ return this;
58
+ }
59
+ writeInt64(int, signed = true) {
60
+ this.write((0, _0_buffer_js_1.bufferFromBigInt)(int, 64 / 8, true, signed));
61
+ return this;
62
+ }
63
+ writeDouble(double) {
64
+ const buffer = new Uint8Array(8);
65
+ new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength).setFloat64(0, double, true);
66
+ this.write(buffer);
67
+ return this;
68
+ }
69
+ writeInt128(int, signed = true) {
70
+ this.write((0, _0_buffer_js_1.bufferFromBigInt)(int, 128 / 8, true, signed));
71
+ return this;
72
+ }
73
+ writeInt256(int, signed = true) {
74
+ this.write((0, _0_buffer_js_1.bufferFromBigInt)(int, 256 / 8, true, signed));
75
+ return this;
76
+ }
77
+ writeBytes(bytes) {
78
+ let padding;
79
+ if (bytes.length > 253) {
80
+ this.write(new Uint8Array([254]));
81
+ this.writeInt24(bytes.length);
82
+ padding = bytes.length % 4;
83
+ }
84
+ else {
85
+ this.write(new Uint8Array([bytes.length]));
86
+ padding = (bytes.length + 1) % 4;
87
+ }
88
+ this.write(bytes);
89
+ if (padding > 0) {
90
+ padding = 4 - padding;
91
+ this.write(new Uint8Array(padding));
92
+ }
93
+ return this;
94
+ }
95
+ writeString(string) {
96
+ this.writeBytes(new TextEncoder().encode(string));
97
+ return this;
38
98
  }
39
- serialize(value) {
40
- (0, _1_utilities_js_1.assertIsValidType)(value);
41
- __classPrivateFieldGet(this, _TLWriter_instances, "m", _TLWriter_serialize).call(this, value._, value, "");
99
+ writeObject(value, schema) {
100
+ __classPrivateFieldGet(this, _TLWriter_instances, "m", _TLWriter_serialize).call(this, value._, value, "", schema);
42
101
  return this;
43
102
  }
44
103
  }
45
104
  exports.TLWriter = TLWriter;
46
- _TLWriter_instances = new WeakSet(), _TLWriter_serialize = function _TLWriter_serialize(type, value, debugInfo) {
105
+ _TLWriter_instances = new WeakSet(), _TLWriter_serialize = function _TLWriter_serialize(type, value, debugInfo, schema) {
47
106
  if (__classPrivateFieldGet(this, _TLWriter_instances, "m", _TLWriter_serializePrimitive).call(this, type, value, debugInfo)) {
48
107
  return;
49
108
  }
50
- if (__classPrivateFieldGet(this, _TLWriter_instances, "m", _TLWriter_serializeVector).call(this, type, value, debugInfo)) {
109
+ if (__classPrivateFieldGet(this, _TLWriter_instances, "m", _TLWriter_serializeVector).call(this, type, value, debugInfo, schema)) {
51
110
  return;
52
111
  }
53
- (0, _1_utilities_js_1.assertIsValidType)(value);
54
- const maybeParameters = (0, _0_api_js_1.getType)(value._);
55
- if (!maybeParameters) {
56
- throw new _0_tl_raw_reader_js_1.TLError(`Unknown type: ${value._}`);
112
+ const maybeDefinition = schema.definitions[value._];
113
+ if (!maybeDefinition) {
114
+ throw new _0_tl_error_js_1.TLError(`Unknown type: ${value._}`);
57
115
  }
58
- if (type != "!X" && !__classPrivateFieldGet(this, _TLWriter_instances, "m", _TLWriter_isTypeValid).call(this, type, value)) {
59
- throw new _0_tl_raw_reader_js_1.TLError(`Expected ${type} but got ${value._}`);
116
+ if (type != "!X" && !__classPrivateFieldGet(this, _TLWriter_instances, "m", _TLWriter_isTypeValid).call(this, type, value, schema)) {
117
+ throw new _0_tl_error_js_1.TLError(`Expected ${type} but got ${value._}`);
60
118
  }
61
119
  const type__ = value;
62
- const [id, parameters_] = maybeParameters;
120
+ const [id, parameters_] = maybeDefinition;
63
121
  this.writeInt32(id, false);
64
122
  for (let [i, [name, type]] of parameters_.entries()) {
65
- if ((0, _1_utilities_js_1.isOptionalParam)(type) && type__[name] === undefined) {
123
+ if ((0, _0_utilities_js_1.isOptionalParam)(type) && type__[name] === undefined) {
66
124
  continue;
67
125
  }
68
126
  const debugInfo = ` [0x${id.toString(16).toUpperCase()}::${i}]`;
@@ -70,8 +128,8 @@ _TLWriter_instances = new WeakSet(), _TLWriter_serialize = function _TLWriter_se
70
128
  let flags = 0;
71
129
  const flagField_ = name;
72
130
  for (const [name, type] of parameters_) {
73
- if ((0, _1_utilities_js_1.isOptionalParam)(type)) {
74
- const { flagField, bitIndex } = (0, _1_utilities_js_1.analyzeOptionalParam)(type);
131
+ if ((0, _0_utilities_js_1.isOptionalParam)(type)) {
132
+ const { flagField, bitIndex } = (0, _0_utilities_js_1.analyzeOptionalParam)(type);
75
133
  if (flagField == flagField_) {
76
134
  if (type__[name] !== undefined) {
77
135
  flags |= 1 << bitIndex;
@@ -82,38 +140,38 @@ _TLWriter_instances = new WeakSet(), _TLWriter_serialize = function _TLWriter_se
82
140
  this.writeInt32(flags);
83
141
  continue;
84
142
  }
85
- if (type__[name] === undefined && !(0, _1_utilities_js_1.isOptionalParam)(type)) {
143
+ if (type__[name] === undefined && !(0, _0_utilities_js_1.isOptionalParam)(type)) {
86
144
  throw new Error(`Missing required parameter: ${name}`);
87
145
  }
88
- if ((0, _1_utilities_js_1.isOptionalParam)(type)) {
89
- type = (0, _1_utilities_js_1.getOptionalParamInnerType)(type);
146
+ if ((0, _0_utilities_js_1.isOptionalParam)(type)) {
147
+ type = (0, _0_utilities_js_1.getOptionalParamInnerType)(type);
90
148
  }
91
- __classPrivateFieldGet(this, _TLWriter_instances, "m", _TLWriter_serialize).call(this, type, type__[name], debugInfo);
149
+ __classPrivateFieldGet(this, _TLWriter_instances, "m", _TLWriter_serialize).call(this, type, type__[name], debugInfo, schema);
92
150
  }
93
151
  return;
94
- }, _TLWriter_serializeVector = function _TLWriter_serializeVector(type, value, debugInfo) {
95
- const itemType = (0, _1_utilities_js_1.getVectorItemType)(type);
152
+ }, _TLWriter_serializeVector = function _TLWriter_serializeVector(type, value, debugInfo, schema) {
153
+ const itemType = (0, _0_utilities_js_1.getVectorItemType)(type);
96
154
  if (!itemType) {
97
155
  return false;
98
156
  }
99
157
  if (!Array.isArray(value)) {
100
- throw new TypeError(`Expected array but received ${(0, _1_utilities_js_1.repr)(value)}${debugInfo}`);
158
+ throw new TypeError(`Expected array but received ${(0, _0_utilities_js_1.repr)(value)}${debugInfo}`);
101
159
  }
102
- this.writeInt32(_1_utilities_js_1.VECTOR, false);
160
+ this.writeInt32(_0_utilities_js_1.VECTOR, false);
103
161
  this.writeInt32(value.length);
104
162
  for (const item of value) {
105
- __classPrivateFieldGet(this, _TLWriter_instances, "m", _TLWriter_serialize).call(this, itemType, item, debugInfo);
163
+ __classPrivateFieldGet(this, _TLWriter_instances, "m", _TLWriter_serialize).call(this, itemType, item, debugInfo, schema);
106
164
  }
107
165
  return true;
108
166
  }, _TLWriter_serializePrimitive = function _TLWriter_serializePrimitive(type, value, debugInfo) {
109
- const valueRepr = (0, _1_utilities_js_1.repr)(value);
167
+ const valueRepr = (0, _0_utilities_js_1.repr)(value);
110
168
  switch (type) {
111
169
  case "bytes":
112
170
  if ((value instanceof Uint8Array)) {
113
171
  this.writeBytes(value);
114
172
  }
115
173
  else {
116
- throw new _0_tl_raw_reader_js_1.TLError(`Expected Uint8Array but received ${valueRepr}${debugInfo}`);
174
+ throw new _0_tl_error_js_1.TLError(`Expected Uint8Array but received ${valueRepr}${debugInfo}`);
117
175
  }
118
176
  return true;
119
177
  case "int128":
@@ -121,7 +179,7 @@ _TLWriter_instances = new WeakSet(), _TLWriter_serialize = function _TLWriter_se
121
179
  this.writeInt128(value);
122
180
  }
123
181
  else {
124
- throw new _0_tl_raw_reader_js_1.TLError(`Expected bigint but received ${valueRepr}${debugInfo}`);
182
+ throw new _0_tl_error_js_1.TLError(`Expected bigint but received ${valueRepr}${debugInfo}`);
125
183
  }
126
184
  return true;
127
185
  case "int256":
@@ -129,7 +187,7 @@ _TLWriter_instances = new WeakSet(), _TLWriter_serialize = function _TLWriter_se
129
187
  this.writeInt256(value);
130
188
  }
131
189
  else {
132
- throw new _0_tl_raw_reader_js_1.TLError(`Expected bigint but received ${valueRepr}${debugInfo}`);
190
+ throw new _0_tl_error_js_1.TLError(`Expected bigint but received ${valueRepr}${debugInfo}`);
133
191
  }
134
192
  return true;
135
193
  case "long":
@@ -137,20 +195,20 @@ _TLWriter_instances = new WeakSet(), _TLWriter_serialize = function _TLWriter_se
137
195
  this.writeInt64(value);
138
196
  }
139
197
  else {
140
- throw new _0_tl_raw_reader_js_1.TLError(`Expected bigint but received ${valueRepr}${debugInfo}`);
198
+ throw new _0_tl_error_js_1.TLError(`Expected bigint but received ${valueRepr}${debugInfo}`);
141
199
  }
142
200
  return true;
143
201
  case "Bool":
144
202
  if (typeof value === "boolean") {
145
203
  if (value) {
146
- this.writeInt32(_1_utilities_js_1.BOOL_TRUE);
204
+ this.writeInt32(_0_utilities_js_1.BOOL_TRUE);
147
205
  }
148
206
  else {
149
- this.writeInt32(_1_utilities_js_1.BOOL_FALSE);
207
+ this.writeInt32(_0_utilities_js_1.BOOL_FALSE);
150
208
  }
151
209
  }
152
210
  else {
153
- throw new _0_tl_raw_reader_js_1.TLError(`Expected boolean but received ${valueRepr}${debugInfo}`);
211
+ throw new _0_tl_error_js_1.TLError(`Expected boolean but received ${valueRepr}${debugInfo}`);
154
212
  }
155
213
  return true;
156
214
  case "int":
@@ -163,7 +221,7 @@ _TLWriter_instances = new WeakSet(), _TLWriter_serialize = function _TLWriter_se
163
221
  this.writeInt32(value);
164
222
  }
165
223
  else {
166
- throw new _0_tl_raw_reader_js_1.TLError(`Expected number but received ${valueRepr}${debugInfo}`);
224
+ throw new _0_tl_error_js_1.TLError(`Expected number but received ${valueRepr}${debugInfo}`);
167
225
  }
168
226
  return true;
169
227
  case "double":
@@ -176,7 +234,7 @@ _TLWriter_instances = new WeakSet(), _TLWriter_serialize = function _TLWriter_se
176
234
  this.writeDouble(value);
177
235
  }
178
236
  else {
179
- throw new _0_tl_raw_reader_js_1.TLError(`Expected number but received ${valueRepr}${debugInfo}`);
237
+ throw new _0_tl_error_js_1.TLError(`Expected number but received ${valueRepr}${debugInfo}`);
180
238
  }
181
239
  return true;
182
240
  case "string":
@@ -195,16 +253,15 @@ _TLWriter_instances = new WeakSet(), _TLWriter_serialize = function _TLWriter_se
195
253
  return true;
196
254
  case "true":
197
255
  if (value !== true) {
198
- throw new _0_tl_raw_reader_js_1.TLError(`Expected true but received ${valueRepr}${debugInfo}`);
256
+ throw new _0_tl_error_js_1.TLError(`Expected true but received ${valueRepr}${debugInfo}`);
199
257
  }
200
258
  return true;
201
259
  default:
202
260
  return false;
203
261
  }
204
- }, _TLWriter_isTypeValid = function _TLWriter_isTypeValid(type, value) {
262
+ }, _TLWriter_isTypeValid = function _TLWriter_isTypeValid(type, value, schema) {
205
263
  if (type == value._) {
206
264
  return true;
207
265
  }
208
- const enum_ = (0, _0_api_js_1.getEnum)(type);
209
- return enum_?.includes(value._) || false;
266
+ return schema.definitions[value._]?.[2] === type;
210
267
  };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"1_tl_writer_test.d.ts","sourceRoot":"","sources":["../../src/tl/1_tl_writer_test.ts"],"names":[],"mappings":""}
@@ -7,7 +7,7 @@
7
7
  * This program is free software: you can redistribute it and/or modify
8
8
  * it under the terms of the GNU Lesser General Public License as published by
9
9
  * the Free Software Foundation, either version 3 of the License, or
10
- * (at your option) any later version.,,
10
+ * (at your option) any later version.
11
11
  *
12
12
  * This program is distributed in the hope that it will be useful,
13
13
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -17,27 +17,12 @@
17
17
  * You should have received a copy of the GNU Lesser General Public License
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
- import { AnyType, Enums, Functions, Types } from "./0_api.js";
21
- export declare function isOptionalParam(ntype: string): boolean;
22
- export declare function getOptionalParamInnerType(ntype: string): string;
23
- export declare function analyzeOptionalParam(ntype: string): {
24
- flagField: string;
25
- bitIndex: number;
26
- };
27
- export declare function isValidType(object: any): object is AnyType;
28
- export declare function assertIsValidType(object: any): void;
29
- export declare function is<S extends keyof (Types & Functions)>(typeName: S, value: unknown): value is S extends keyof Types ? Types[S] : S extends keyof Functions ? Functions[S] : never;
30
- export declare function isOneOf<S extends keyof (Types & Functions)>(typeNames: S[] | readonly S[], value: unknown): value is S extends keyof Types ? Types[S] : S extends keyof Functions ? Functions[S] : never;
31
- export declare function isOfEnum<S extends keyof Enums>(enumName: S, value: unknown): value is Enums[S];
32
- export declare function as<S extends keyof Types>(typeName: S, value: unknown): Types[S];
33
- export declare function isGenericFunction(value: unknown): boolean;
34
- export declare function mustGetReturnType(name: string): string;
35
- export declare function repr(value: unknown): string | null;
36
- export declare function getVectorItemType(type: string): string | null;
37
- export declare const X = "X";
38
- export declare const VECTOR = 481674261;
39
- export declare const BOOL_TRUE = 2574415285;
40
- export declare const BOOL_FALSE = 3162085175;
41
- export declare const GZIP_PACKED = 812830625;
42
- export declare const RPC_RESULT = 4082920705;
20
+ import { Schema } from "./0_types.js";
21
+ export declare function isValidObject(object: any, schema: Schema): boolean;
22
+ export declare function assertIsValidObject(object: any, schema: Schema): void;
23
+ export declare function is(typeName: string, value: any, schema: Schema): boolean;
24
+ export declare function isOneOf(names: string[], value: unknown, schema: Schema): boolean;
25
+ export declare function isOfEnum(name: string, value: any, schema: Schema): boolean;
26
+ export declare function as(name: string, value: unknown, schema: Schema): unknown;
27
+ export declare function mustGetReturnType(name: string, schema: Schema): string;
43
28
  //# sourceMappingURL=1_utilities.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"1_utilities.d.ts","sourceRoot":"","sources":["../../src/tl/1_utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAoB,KAAK,EAAE,MAAM,YAAY,CAAC;AAEhF,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEtD;AACD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/D;AACD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAY3F;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,OAAO,CAE1D;AACD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,GAAG,QAI5C;AAED,wBAAgB,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,CAAC,SAAS,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,CAMjL;AACD,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,CAAC,SAAS,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,CAExM;AACD,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,CAE9F;AACD,wBAAgB,EAAE,CAAC,CAAC,SAAS,MAAM,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAM/E;AAWD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEzD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMtD;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAElD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK7D;AAID,eAAO,MAAM,CAAC,MAAM,CAAC;AACrB,eAAO,MAAM,MAAM,YAAa,CAAC;AACjC,eAAO,MAAM,SAAS,aAAa,CAAC;AACpC,eAAO,MAAM,UAAU,aAAa,CAAC;AACrC,eAAO,MAAM,WAAW,YAAa,CAAC;AACtC,eAAO,MAAM,UAAU,aAAa,CAAC"}
1
+ {"version":3,"file":"1_utilities.d.ts","sourceRoot":"","sources":["../../src/tl/1_utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,wBAAgB,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,WAExD;AACD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,QAI9D;AAED,wBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,WAM9D;AACD,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAEtE;AACD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,WAEhE;AACD,wBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAM9D;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMtE"}