@mtkruto/node 0.1.201 → 0.1.299

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 (742) hide show
  1. package/COPYING +674 -0
  2. package/README.md +77 -1
  3. package/esm/0_deps.d.ts +20 -1
  4. package/esm/0_deps.js +21 -1
  5. package/esm/0_errors.d.ts +19 -0
  6. package/esm/0_errors.js +19 -0
  7. package/esm/1_utilities.d.ts +20 -1
  8. package/esm/1_utilities.js +20 -1
  9. package/esm/2_connection.d.ts +19 -0
  10. package/esm/2_connection.js +19 -0
  11. package/esm/2_tl.d.ts +19 -0
  12. package/esm/2_tl.js +19 -0
  13. package/esm/3_errors.d.ts +19 -0
  14. package/esm/3_errors.js +19 -0
  15. package/esm/3_storage.d.ts +19 -0
  16. package/esm/3_storage.js +19 -0
  17. package/esm/3_transport.d.ts +19 -0
  18. package/esm/3_transport.js +19 -0
  19. package/esm/3_types.d.ts +19 -0
  20. package/esm/3_types.js +19 -0
  21. package/esm/4_constants.js +19 -0
  22. package/esm/4_errors.d.ts +19 -0
  23. package/esm/4_errors.js +22 -3
  24. package/esm/5_client.d.ts +19 -0
  25. package/esm/5_client.js +19 -0
  26. package/esm/client/0_client_abstract.d.ts +19 -0
  27. package/esm/client/0_client_abstract.js +19 -0
  28. package/esm/client/0_filters.d.ts +19 -0
  29. package/esm/client/0_filters.js +19 -0
  30. package/esm/client/0_html.d.ts +19 -0
  31. package/esm/client/0_html.js +19 -0
  32. package/esm/client/0_markdown.js +5 -5
  33. package/esm/client/0_message.d.ts +19 -0
  34. package/esm/client/0_message.js +19 -0
  35. package/esm/client/0_params.d.ts +19 -0
  36. package/esm/client/0_params.js +19 -0
  37. package/esm/client/0_password.js +19 -0
  38. package/esm/client/0_types.d.ts +19 -0
  39. package/esm/client/0_types.js +19 -0
  40. package/esm/client/0_utilities.d.ts +7 -0
  41. package/esm/client/0_utilities.js +66 -4
  42. package/esm/client/1_account_manager.d.ts +19 -0
  43. package/esm/client/1_account_manager.js +23 -4
  44. package/esm/client/1_bot_info_manager.d.ts +19 -0
  45. package/esm/client/1_bot_info_manager.js +19 -0
  46. package/esm/client/1_business_connection_manager.d.ts +19 -0
  47. package/esm/client/1_business_connection_manager.js +19 -0
  48. package/esm/client/1_client_encrypted.d.ts +19 -0
  49. package/esm/client/1_client_encrypted.js +23 -4
  50. package/esm/client/1_client_plain.d.ts +19 -0
  51. package/esm/client/1_client_plain.js +22 -3
  52. package/esm/client/1_composer.d.ts +19 -0
  53. package/esm/client/1_composer.js +19 -0
  54. package/esm/client/1_file_manager.d.ts +19 -0
  55. package/esm/client/1_file_manager.js +25 -5
  56. package/esm/client/1_network_statistics_manager.d.ts +19 -0
  57. package/esm/client/1_network_statistics_manager.js +19 -0
  58. package/esm/client/1_reaction_manager.d.ts +19 -0
  59. package/esm/client/1_reaction_manager.js +21 -2
  60. package/esm/client/1_update_manager.d.ts +19 -0
  61. package/esm/client/1_update_manager.js +28 -8
  62. package/esm/client/2_message_manager.d.ts +19 -0
  63. package/esm/client/2_message_manager.js +66 -24
  64. package/esm/client/3_callback_query_manager.d.ts +19 -0
  65. package/esm/client/3_callback_query_manager.js +21 -0
  66. package/esm/client/3_chat_list_manager.d.ts +19 -0
  67. package/esm/client/3_chat_list_manager.js +32 -12
  68. package/esm/client/3_inline_query_manager.d.ts +19 -0
  69. package/esm/client/3_inline_query_manager.js +23 -2
  70. package/esm/client/3_story_manager.d.ts +19 -0
  71. package/esm/client/3_story_manager.js +26 -5
  72. package/esm/client/4_client.d.ts +19 -0
  73. package/esm/client/4_client.js +37 -17
  74. package/esm/connection/0_connection.d.ts +19 -0
  75. package/esm/connection/0_connection.js +19 -0
  76. package/esm/connection/1_connection_web_socket.js +22 -2
  77. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.d.ts +83 -0
  78. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.js +203 -0
  79. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.d.ts +50 -0
  80. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.js +274 -0
  81. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.d.ts +47 -0
  82. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.js +51 -0
  83. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.d.ts +66 -0
  84. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.js +191 -0
  85. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Node.d.ts +168 -0
  86. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Node.js +385 -0
  87. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Parser.d.ts +159 -0
  88. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Parser.js +431 -0
  89. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.d.ts +181 -0
  90. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.js +1046 -0
  91. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/mod.d.ts +42 -0
  92. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/mod.js +52 -0
  93. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.d.ts +11 -0
  94. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.js +122 -0
  95. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.d.ts +1 -0
  96. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.js +24 -0
  97. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.d.ts +46 -0
  98. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.js +121 -0
  99. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.d.ts +31 -0
  100. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.js +30 -0
  101. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.d.ts +2128 -0
  102. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.js +2127 -0
  103. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.d.ts +109 -0
  104. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.js +108 -0
  105. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.d.ts +8 -0
  106. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.js +1 -0
  107. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.d.ts +90 -0
  108. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.js +95 -0
  109. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.d.ts +50 -0
  110. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.js +128 -0
  111. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.d.ts +46 -0
  112. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.js +110 -0
  113. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.d.ts +42 -0
  114. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.js +120 -0
  115. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.d.ts +6 -0
  116. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.js +6 -0
  117. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.d.ts +54 -0
  118. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.js +110 -0
  119. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.d.ts +40 -0
  120. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.js +75 -0
  121. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.d.ts +58 -0
  122. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.js +101 -0
  123. package/{script/deps/deno.land/x/tgcrypto@0.3.3 → esm/deps/deno.land/x/tgcrypto@0.4.0}/mod.d.ts +0 -1
  124. package/esm/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/mod.js +0 -11
  125. package/esm/deps/deno.land/x/tgcrypto@0.4.0/tgcrypto.js +308 -0
  126. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/deflate.d.ts +2 -0
  127. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/deflate.js +5 -1
  128. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/inflate.d.ts +2 -2
  129. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/inflate.js +5 -1
  130. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/zlib/crc32.js +1 -1
  131. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/zlib/deflate.js +8 -8
  132. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/zlib/inffast.js +2 -2
  133. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/zlib/inflate.js +19 -21
  134. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/zlib/trees.js +3 -3
  135. package/esm/mod.d.ts +20 -1
  136. package/esm/mod.js +20 -1
  137. package/esm/storage/0_storage.d.ts +19 -0
  138. package/esm/storage/0_storage.js +25 -5
  139. package/esm/storage/1_utilities.d.ts +19 -1
  140. package/esm/storage/1_utilities.js +21 -3
  141. package/esm/storage/2_storage_indexed_db.d.ts +19 -0
  142. package/esm/storage/2_storage_indexed_db.js +19 -0
  143. package/esm/storage/2_storage_local_storage.d.ts +19 -0
  144. package/esm/storage/2_storage_local_storage.js +20 -4
  145. package/esm/storage/2_storage_memory.d.ts +19 -0
  146. package/esm/storage/2_storage_memory.js +19 -0
  147. package/esm/storage/2_storage_session_storage.d.ts +19 -0
  148. package/esm/storage/2_storage_session_storage.js +20 -4
  149. package/esm/tl/0_tl_raw_reader.d.ts +19 -0
  150. package/esm/tl/0_tl_raw_reader.js +19 -0
  151. package/esm/tl/0_tl_raw_writer.d.ts +19 -0
  152. package/esm/tl/0_tl_raw_writer.js +19 -0
  153. package/esm/tl/1_tl_object.d.ts +19 -0
  154. package/esm/tl/1_tl_object.js +19 -0
  155. package/esm/tl/2_types.d.ts +19 -0
  156. package/esm/tl/2_types.js +19 -0
  157. package/esm/tl/3_deserialize.d.ts +19 -0
  158. package/esm/tl/3_deserialize.js +19 -0
  159. package/esm/tl/3_functions.d.ts +19 -0
  160. package/esm/tl/3_functions.js +19 -0
  161. package/esm/tl/3_utilities.d.ts +19 -0
  162. package/esm/tl/3_utilities.js +24 -4
  163. package/esm/tl/4_tl_reader.d.ts +19 -0
  164. package/esm/tl/4_tl_reader.js +19 -0
  165. package/esm/tl/5_tl_writer.d.ts +19 -0
  166. package/esm/tl/5_tl_writer.js +19 -0
  167. package/esm/tl/6_rpc_result.d.ts +19 -0
  168. package/esm/tl/6_rpc_result.js +19 -0
  169. package/esm/tl/7_message.d.ts +19 -0
  170. package/esm/tl/7_message.js +19 -0
  171. package/esm/tl/8_message_container.d.ts +19 -0
  172. package/esm/tl/8_message_container.js +19 -0
  173. package/esm/transport/0_obfuscation.js +19 -0
  174. package/esm/transport/0_transport.d.ts +19 -0
  175. package/esm/transport/0_transport.js +19 -0
  176. package/esm/transport/1_transport_abridged.d.ts +19 -0
  177. package/esm/transport/1_transport_abridged.js +19 -0
  178. package/esm/transport/1_transport_intermediate.d.ts +19 -0
  179. package/esm/transport/1_transport_intermediate.js +19 -0
  180. package/esm/transport/2_transport_provider.d.ts +19 -0
  181. package/esm/transport/2_transport_provider.js +23 -4
  182. package/esm/transport/3_transport_provider_web_socket.d.ts +19 -0
  183. package/esm/transport/3_transport_provider_web_socket.js +19 -0
  184. package/esm/types/0_authorization_state.d.ts +19 -0
  185. package/esm/types/0_authorization_state.js +19 -0
  186. package/esm/types/0_bot_command.d.ts +19 -0
  187. package/esm/types/0_bot_command.js +19 -0
  188. package/esm/types/0_chat_action.d.ts +19 -0
  189. package/esm/types/0_chat_action.js +19 -0
  190. package/esm/types/0_chat_administrator_rights.d.ts +19 -0
  191. package/esm/types/0_chat_administrator_rights.js +19 -0
  192. package/esm/types/0_chat_member_rights.d.ts +19 -0
  193. package/esm/types/0_chat_member_rights.js +19 -0
  194. package/esm/types/0_chat_photo.d.ts +19 -1
  195. package/esm/types/0_chat_photo.js +19 -2
  196. package/esm/types/0_connection_state.d.ts +19 -0
  197. package/esm/types/0_connection_state.js +19 -0
  198. package/esm/types/0_contact.d.ts +19 -0
  199. package/esm/types/0_contact.js +19 -0
  200. package/esm/types/0_dice.d.ts +19 -0
  201. package/esm/types/0_dice.js +19 -0
  202. package/esm/types/0_file_source.d.ts +19 -0
  203. package/esm/types/0_file_source.js +19 -0
  204. package/esm/types/0_giveaway_parameters.d.ts +19 -0
  205. package/esm/types/0_giveaway_parameters.js +19 -0
  206. package/esm/types/0_id.d.ts +19 -0
  207. package/esm/types/0_id.js +19 -0
  208. package/esm/types/0_keyboard_button_poll_type.d.ts +19 -0
  209. package/esm/types/0_keyboard_button_poll_type.js +19 -0
  210. package/esm/types/0_link_preview.d.ts +19 -0
  211. package/esm/types/0_link_preview.js +19 -0
  212. package/esm/types/0_location.d.ts +19 -0
  213. package/esm/types/0_location.js +19 -0
  214. package/esm/types/0_login_url.d.ts +19 -0
  215. package/esm/types/0_login_url.js +19 -0
  216. package/esm/types/0_mask_position.d.ts +19 -0
  217. package/esm/types/0_mask_position.js +19 -0
  218. package/esm/types/0_message_entity.d.ts +19 -0
  219. package/esm/types/0_message_entity.js +22 -3
  220. package/esm/types/0_message_reference.d.ts +19 -0
  221. package/esm/types/0_message_reference.js +19 -0
  222. package/esm/types/0_message_search_filter.d.ts +19 -0
  223. package/esm/types/0_message_search_filter.js +21 -2
  224. package/esm/types/0_mini_app_info.d.ts +19 -0
  225. package/esm/types/0_mini_app_info.js +19 -0
  226. package/esm/types/0_network_statistics_entry.d.ts +19 -0
  227. package/esm/types/0_network_statistics_entry.js +19 -0
  228. package/esm/types/0_parse_mode.d.ts +19 -0
  229. package/esm/types/0_parse_mode.js +19 -0
  230. package/esm/types/0_poll_option.d.ts +19 -0
  231. package/esm/types/0_poll_option.js +19 -0
  232. package/esm/types/0_price_tag.d.ts +19 -0
  233. package/esm/types/0_price_tag.js +19 -0
  234. package/esm/types/0_reaction.d.ts +19 -0
  235. package/esm/types/0_reaction.js +21 -2
  236. package/esm/types/0_restriction_reason.d.ts +19 -0
  237. package/esm/types/0_restriction_reason.js +19 -0
  238. package/esm/types/0_story_reference.d.ts +19 -0
  239. package/esm/types/0_story_reference.js +19 -0
  240. package/esm/types/0_thumbnail.d.ts +19 -0
  241. package/esm/types/0_thumbnail.js +19 -0
  242. package/esm/types/0_voice.d.ts +19 -0
  243. package/esm/types/0_voice.js +19 -0
  244. package/esm/types/1_animation.d.ts +19 -0
  245. package/esm/types/1_animation.js +19 -0
  246. package/esm/types/1_audio.d.ts +19 -0
  247. package/esm/types/1_audio.js +19 -0
  248. package/esm/types/1_bot_command_scope.d.ts +19 -0
  249. package/esm/types/1_bot_command_scope.js +22 -3
  250. package/esm/types/1_chat_p.d.ts +19 -0
  251. package/esm/types/1_chat_p.js +22 -2
  252. package/esm/types/1_document.d.ts +19 -0
  253. package/esm/types/1_document.js +19 -0
  254. package/esm/types/1_giveaway.d.ts +19 -0
  255. package/esm/types/1_giveaway.js +19 -0
  256. package/esm/types/1_inline_query_result_button.d.ts +19 -0
  257. package/esm/types/1_inline_query_result_button.js +19 -0
  258. package/esm/types/1_input_message_content.d.ts +19 -0
  259. package/esm/types/1_input_message_content.js +19 -0
  260. package/esm/types/1_input_story_content.d.ts +19 -0
  261. package/esm/types/1_input_story_content.js +19 -0
  262. package/esm/types/1_keyboard_button.d.ts +19 -0
  263. package/esm/types/1_keyboard_button.js +22 -3
  264. package/esm/types/1_message_reaction.d.ts +19 -0
  265. package/esm/types/1_message_reaction.js +21 -2
  266. package/esm/types/1_network_statistics.d.ts +19 -0
  267. package/esm/types/1_network_statistics.js +19 -0
  268. package/esm/types/1_photo.d.ts +19 -0
  269. package/esm/types/1_photo.js +19 -0
  270. package/esm/types/1_poll.d.ts +19 -0
  271. package/esm/types/1_poll.js +19 -0
  272. package/esm/types/1_reaction_count.d.ts +19 -0
  273. package/esm/types/1_reaction_count.js +19 -0
  274. package/esm/types/1_reply_quote.d.ts +19 -0
  275. package/esm/types/1_reply_quote.js +19 -0
  276. package/esm/types/1_sticker.d.ts +19 -0
  277. package/esm/types/1_sticker.js +19 -0
  278. package/esm/types/1_story_privacy.d.ts +19 -0
  279. package/esm/types/1_story_privacy.js +22 -3
  280. package/esm/types/1_story_reaction.d.ts +19 -0
  281. package/esm/types/1_story_reaction.js +19 -0
  282. package/esm/types/1_user.d.ts +19 -0
  283. package/esm/types/1_user.js +19 -0
  284. package/esm/types/1_venue.d.ts +19 -0
  285. package/esm/types/1_venue.js +19 -0
  286. package/esm/types/1_video.d.ts +19 -0
  287. package/esm/types/1_video.js +19 -0
  288. package/esm/types/1_video_note.d.ts +19 -0
  289. package/esm/types/1_video_note.js +19 -0
  290. package/esm/types/2_business_connection.d.ts +19 -0
  291. package/esm/types/2_business_connection.js +19 -0
  292. package/esm/types/2_chat_member.d.ts +19 -0
  293. package/esm/types/2_chat_member.js +25 -5
  294. package/esm/types/2_chosen_inline_result.d.ts +19 -0
  295. package/esm/types/2_chosen_inline_result.js +22 -2
  296. package/esm/types/2_game.d.ts +19 -0
  297. package/esm/types/2_game.js +19 -0
  298. package/esm/types/2_inactive_chat.d.ts +19 -0
  299. package/esm/types/2_inactive_chat.js +22 -2
  300. package/esm/types/2_inline_keyboard_button.d.ts +19 -0
  301. package/esm/types/2_inline_keyboard_button.js +22 -3
  302. package/esm/types/2_inline_query.d.ts +19 -0
  303. package/esm/types/2_inline_query.js +22 -3
  304. package/esm/types/2_invite_link.d.ts +19 -0
  305. package/esm/types/2_invite_link.js +22 -2
  306. package/esm/types/2_message_interactions.d.ts +19 -0
  307. package/esm/types/2_message_interactions.js +19 -0
  308. package/esm/types/2_message_reaction_count.d.ts +19 -0
  309. package/esm/types/2_message_reaction_count.js +19 -0
  310. package/esm/types/2_message_reactions.d.ts +19 -0
  311. package/esm/types/2_message_reactions.js +19 -0
  312. package/esm/types/2_story_content.d.ts +19 -0
  313. package/esm/types/2_story_content.js +24 -5
  314. package/esm/types/2_story_interactions.d.ts +19 -0
  315. package/esm/types/2_story_interactions.js +19 -0
  316. package/esm/types/2_story_interactive_area.d.ts +19 -0
  317. package/esm/types/2_story_interactive_area.js +24 -5
  318. package/esm/types/3_chat_member_updated.d.ts +19 -0
  319. package/esm/types/3_chat_member_updated.js +23 -3
  320. package/esm/types/3_reply_markup.d.ts +19 -0
  321. package/esm/types/3_reply_markup.js +23 -3
  322. package/esm/types/3_story.d.ts +19 -0
  323. package/esm/types/3_story.js +22 -2
  324. package/esm/types/4_inline_query_result.d.ts +19 -0
  325. package/esm/types/4_inline_query_result.js +24 -5
  326. package/esm/types/4_message.d.ts +19 -0
  327. package/esm/types/4_message.js +36 -16
  328. package/esm/types/5_callback_query.d.ts +19 -0
  329. package/esm/types/5_callback_query.js +23 -3
  330. package/esm/types/5_chat.d.ts +19 -0
  331. package/esm/types/5_chat.js +27 -7
  332. package/esm/types/6_update.d.ts +19 -0
  333. package/esm/types/6_update.js +19 -0
  334. package/esm/types/_file_id.d.ts +19 -0
  335. package/esm/types/_file_id.js +28 -8
  336. package/esm/types/_getters.d.ts +19 -0
  337. package/esm/types/_getters.js +19 -0
  338. package/esm/utilities/0_bigint.d.ts +1 -0
  339. package/esm/utilities/0_bigint.js +44 -0
  340. package/esm/utilities/0_buffer.d.ts +19 -0
  341. package/esm/utilities/0_buffer.js +19 -0
  342. package/esm/utilities/0_cache_map.d.ts +19 -0
  343. package/esm/utilities/0_cache_map.js +19 -0
  344. package/esm/utilities/0_color.d.ts +19 -0
  345. package/esm/utilities/0_color.js +19 -0
  346. package/esm/utilities/0_crypto.d.ts +19 -0
  347. package/esm/utilities/0_crypto.js +19 -0
  348. package/esm/utilities/0_hash.js +19 -0
  349. package/esm/utilities/0_logger.d.ts +27 -0
  350. package/esm/utilities/0_logger.js +28 -5
  351. package/esm/utilities/0_mutex.d.ts +19 -0
  352. package/esm/utilities/0_mutex.js +19 -0
  353. package/esm/utilities/0_object.d.ts +19 -0
  354. package/esm/utilities/0_object.js +19 -0
  355. package/esm/utilities/0_rle.d.ts +19 -0
  356. package/esm/utilities/0_rle.js +19 -0
  357. package/esm/utilities/0_types.d.ts +19 -0
  358. package/esm/utilities/0_types.js +19 -0
  359. package/esm/utilities/1_auth.js +19 -0
  360. package/esm/utilities/1_base64.d.ts +19 -0
  361. package/esm/utilities/1_base64.js +19 -0
  362. package/esm/utilities/1_math.d.ts +20 -0
  363. package/esm/utilities/1_math.js +70 -0
  364. package/esm/utilities/1_misc.d.ts +19 -0
  365. package/esm/utilities/1_misc.js +21 -2
  366. package/esm/utilities/1_queue.d.ts +19 -0
  367. package/esm/utilities/1_queue.js +19 -0
  368. package/package.json +1 -1
  369. package/script/0_deps.d.ts +20 -1
  370. package/script/0_deps.js +22 -3
  371. package/script/0_errors.d.ts +19 -0
  372. package/script/0_errors.js +19 -0
  373. package/script/1_utilities.d.ts +20 -1
  374. package/script/1_utilities.js +20 -1
  375. package/script/2_connection.d.ts +19 -0
  376. package/script/2_connection.js +19 -0
  377. package/script/2_tl.d.ts +19 -0
  378. package/script/2_tl.js +19 -0
  379. package/script/3_errors.d.ts +19 -0
  380. package/script/3_errors.js +19 -0
  381. package/script/3_storage.d.ts +19 -0
  382. package/script/3_storage.js +19 -0
  383. package/script/3_transport.d.ts +19 -0
  384. package/script/3_transport.js +19 -0
  385. package/script/3_types.d.ts +19 -0
  386. package/script/3_types.js +19 -0
  387. package/script/4_constants.js +19 -0
  388. package/script/4_errors.d.ts +19 -0
  389. package/script/4_errors.js +22 -3
  390. package/script/5_client.d.ts +19 -0
  391. package/script/5_client.js +19 -0
  392. package/script/client/0_client_abstract.d.ts +19 -0
  393. package/script/client/0_client_abstract.js +19 -0
  394. package/script/client/0_filters.d.ts +19 -0
  395. package/script/client/0_filters.js +19 -0
  396. package/script/client/0_html.d.ts +19 -0
  397. package/script/client/0_html.js +19 -0
  398. package/script/client/0_markdown.js +5 -5
  399. package/script/client/0_message.d.ts +19 -0
  400. package/script/client/0_message.js +19 -0
  401. package/script/client/0_params.d.ts +19 -0
  402. package/script/client/0_params.js +19 -0
  403. package/script/client/0_password.js +19 -0
  404. package/script/client/0_types.d.ts +19 -0
  405. package/script/client/0_types.js +19 -0
  406. package/script/client/0_utilities.d.ts +7 -0
  407. package/script/client/0_utilities.js +73 -4
  408. package/script/client/1_account_manager.d.ts +19 -0
  409. package/script/client/1_account_manager.js +23 -4
  410. package/script/client/1_bot_info_manager.d.ts +19 -0
  411. package/script/client/1_bot_info_manager.js +19 -0
  412. package/script/client/1_business_connection_manager.d.ts +19 -0
  413. package/script/client/1_business_connection_manager.js +19 -0
  414. package/script/client/1_client_encrypted.d.ts +19 -0
  415. package/script/client/1_client_encrypted.js +21 -2
  416. package/script/client/1_client_plain.d.ts +19 -0
  417. package/script/client/1_client_plain.js +21 -2
  418. package/script/client/1_composer.d.ts +19 -0
  419. package/script/client/1_composer.js +19 -0
  420. package/script/client/1_file_manager.d.ts +19 -0
  421. package/script/client/1_file_manager.js +24 -4
  422. package/script/client/1_network_statistics_manager.d.ts +19 -0
  423. package/script/client/1_network_statistics_manager.js +19 -0
  424. package/script/client/1_reaction_manager.d.ts +19 -0
  425. package/script/client/1_reaction_manager.js +21 -2
  426. package/script/client/1_update_manager.d.ts +19 -0
  427. package/script/client/1_update_manager.js +27 -7
  428. package/script/client/2_message_manager.d.ts +19 -0
  429. package/script/client/2_message_manager.js +70 -28
  430. package/script/client/3_callback_query_manager.d.ts +19 -0
  431. package/script/client/3_callback_query_manager.js +21 -0
  432. package/script/client/3_chat_list_manager.d.ts +19 -0
  433. package/script/client/3_chat_list_manager.js +31 -11
  434. package/script/client/3_inline_query_manager.d.ts +19 -0
  435. package/script/client/3_inline_query_manager.js +23 -2
  436. package/script/client/3_story_manager.d.ts +19 -0
  437. package/script/client/3_story_manager.js +23 -2
  438. package/script/client/4_client.d.ts +19 -0
  439. package/script/client/4_client.js +35 -15
  440. package/script/connection/0_connection.d.ts +19 -0
  441. package/script/connection/0_connection.js +19 -0
  442. package/script/connection/1_connection_web_socket.js +21 -1
  443. package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.d.ts +83 -0
  444. package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.js +207 -0
  445. package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.d.ts +50 -0
  446. package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.js +301 -0
  447. package/script/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.d.ts +47 -0
  448. package/script/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.js +55 -0
  449. package/script/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.d.ts +66 -0
  450. package/script/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.js +222 -0
  451. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Node.d.ts +168 -0
  452. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Node.js +404 -0
  453. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Parser.d.ts +159 -0
  454. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Parser.js +438 -0
  455. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.d.ts +181 -0
  456. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.js +1052 -0
  457. package/script/deps/deno.land/x/html_parser@v0.1.3/src/mod.d.ts +42 -0
  458. package/script/deps/deno.land/x/html_parser@v0.1.3/src/mod.js +88 -0
  459. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.d.ts +11 -0
  460. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.js +128 -0
  461. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.d.ts +1 -0
  462. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.js +30 -0
  463. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.d.ts +46 -0
  464. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.js +129 -0
  465. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.d.ts +31 -0
  466. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.js +32 -0
  467. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.d.ts +2128 -0
  468. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.js +2129 -0
  469. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.d.ts +109 -0
  470. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.js +110 -0
  471. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.d.ts +8 -0
  472. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.js +3 -0
  473. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.d.ts +90 -0
  474. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.js +114 -0
  475. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.d.ts +50 -0
  476. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.js +134 -0
  477. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.d.ts +46 -0
  478. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.js +118 -0
  479. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.d.ts +42 -0
  480. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.js +129 -0
  481. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.d.ts +6 -0
  482. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.js +22 -0
  483. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.d.ts +54 -0
  484. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.js +119 -0
  485. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.d.ts +40 -0
  486. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.js +86 -0
  487. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.d.ts +58 -0
  488. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.js +112 -0
  489. package/{esm/deps/deno.land/x/tgcrypto@0.3.3 → script/deps/deno.land/x/tgcrypto@0.4.0}/mod.d.ts +0 -1
  490. package/script/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/mod.js +1 -13
  491. package/script/deps/deno.land/x/tgcrypto@0.4.0/tgcrypto.js +310 -0
  492. package/script/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/deflate.d.ts +2 -0
  493. package/script/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/deflate.js +7 -1
  494. package/script/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/inflate.d.ts +2 -2
  495. package/script/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/inflate.js +7 -1
  496. package/script/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/zlib/crc32.js +1 -1
  497. package/script/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/zlib/deflate.js +8 -8
  498. package/script/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/zlib/inffast.js +2 -2
  499. package/script/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/zlib/inflate.js +19 -21
  500. package/script/deps/raw.githubusercontent.com/MTKruto/compress/main/zlib/zlib/trees.js +3 -3
  501. package/script/mod.d.ts +20 -1
  502. package/script/mod.js +21 -1
  503. package/script/storage/0_storage.d.ts +19 -0
  504. package/script/storage/0_storage.js +24 -4
  505. package/script/storage/1_utilities.d.ts +19 -1
  506. package/script/storage/1_utilities.js +22 -4
  507. package/script/storage/2_storage_indexed_db.d.ts +19 -0
  508. package/script/storage/2_storage_indexed_db.js +19 -0
  509. package/script/storage/2_storage_local_storage.d.ts +19 -0
  510. package/script/storage/2_storage_local_storage.js +19 -3
  511. package/script/storage/2_storage_memory.d.ts +19 -0
  512. package/script/storage/2_storage_memory.js +19 -0
  513. package/script/storage/2_storage_session_storage.d.ts +19 -0
  514. package/script/storage/2_storage_session_storage.js +19 -3
  515. package/script/tl/0_tl_raw_reader.d.ts +19 -0
  516. package/script/tl/0_tl_raw_reader.js +19 -0
  517. package/script/tl/0_tl_raw_writer.d.ts +19 -0
  518. package/script/tl/0_tl_raw_writer.js +19 -0
  519. package/script/tl/1_tl_object.d.ts +19 -0
  520. package/script/tl/1_tl_object.js +19 -0
  521. package/script/tl/2_types.d.ts +19 -0
  522. package/script/tl/2_types.js +19 -0
  523. package/script/tl/3_deserialize.d.ts +19 -0
  524. package/script/tl/3_deserialize.js +19 -0
  525. package/script/tl/3_functions.d.ts +19 -0
  526. package/script/tl/3_functions.js +19 -0
  527. package/script/tl/3_utilities.d.ts +19 -0
  528. package/script/tl/3_utilities.js +23 -3
  529. package/script/tl/4_tl_reader.d.ts +19 -0
  530. package/script/tl/4_tl_reader.js +19 -0
  531. package/script/tl/5_tl_writer.d.ts +19 -0
  532. package/script/tl/5_tl_writer.js +19 -0
  533. package/script/tl/6_rpc_result.d.ts +19 -0
  534. package/script/tl/6_rpc_result.js +19 -0
  535. package/script/tl/7_message.d.ts +19 -0
  536. package/script/tl/7_message.js +19 -0
  537. package/script/tl/8_message_container.d.ts +19 -0
  538. package/script/tl/8_message_container.js +19 -0
  539. package/script/transport/0_obfuscation.js +19 -0
  540. package/script/transport/0_transport.d.ts +19 -0
  541. package/script/transport/0_transport.js +19 -0
  542. package/script/transport/1_transport_abridged.d.ts +19 -0
  543. package/script/transport/1_transport_abridged.js +19 -0
  544. package/script/transport/1_transport_intermediate.d.ts +19 -0
  545. package/script/transport/1_transport_intermediate.js +19 -0
  546. package/script/transport/2_transport_provider.d.ts +19 -0
  547. package/script/transport/2_transport_provider.js +23 -4
  548. package/script/transport/3_transport_provider_web_socket.d.ts +19 -0
  549. package/script/transport/3_transport_provider_web_socket.js +19 -0
  550. package/script/types/0_authorization_state.d.ts +19 -0
  551. package/script/types/0_authorization_state.js +19 -0
  552. package/script/types/0_bot_command.d.ts +19 -0
  553. package/script/types/0_bot_command.js +19 -0
  554. package/script/types/0_chat_action.d.ts +19 -0
  555. package/script/types/0_chat_action.js +19 -0
  556. package/script/types/0_chat_administrator_rights.d.ts +19 -0
  557. package/script/types/0_chat_administrator_rights.js +19 -0
  558. package/script/types/0_chat_member_rights.d.ts +19 -0
  559. package/script/types/0_chat_member_rights.js +19 -0
  560. package/script/types/0_chat_photo.d.ts +19 -1
  561. package/script/types/0_chat_photo.js +19 -2
  562. package/script/types/0_connection_state.d.ts +19 -0
  563. package/script/types/0_connection_state.js +19 -0
  564. package/script/types/0_contact.d.ts +19 -0
  565. package/script/types/0_contact.js +19 -0
  566. package/script/types/0_dice.d.ts +19 -0
  567. package/script/types/0_dice.js +19 -0
  568. package/script/types/0_file_source.d.ts +19 -0
  569. package/script/types/0_file_source.js +19 -0
  570. package/script/types/0_giveaway_parameters.d.ts +19 -0
  571. package/script/types/0_giveaway_parameters.js +19 -0
  572. package/script/types/0_id.d.ts +19 -0
  573. package/script/types/0_id.js +19 -0
  574. package/script/types/0_keyboard_button_poll_type.d.ts +19 -0
  575. package/script/types/0_keyboard_button_poll_type.js +19 -0
  576. package/script/types/0_link_preview.d.ts +19 -0
  577. package/script/types/0_link_preview.js +19 -0
  578. package/script/types/0_location.d.ts +19 -0
  579. package/script/types/0_location.js +19 -0
  580. package/script/types/0_login_url.d.ts +19 -0
  581. package/script/types/0_login_url.js +19 -0
  582. package/script/types/0_mask_position.d.ts +19 -0
  583. package/script/types/0_mask_position.js +19 -0
  584. package/script/types/0_message_entity.d.ts +19 -0
  585. package/script/types/0_message_entity.js +22 -3
  586. package/script/types/0_message_reference.d.ts +19 -0
  587. package/script/types/0_message_reference.js +19 -0
  588. package/script/types/0_message_search_filter.d.ts +19 -0
  589. package/script/types/0_message_search_filter.js +21 -2
  590. package/script/types/0_mini_app_info.d.ts +19 -0
  591. package/script/types/0_mini_app_info.js +19 -0
  592. package/script/types/0_network_statistics_entry.d.ts +19 -0
  593. package/script/types/0_network_statistics_entry.js +19 -0
  594. package/script/types/0_parse_mode.d.ts +19 -0
  595. package/script/types/0_parse_mode.js +19 -0
  596. package/script/types/0_poll_option.d.ts +19 -0
  597. package/script/types/0_poll_option.js +19 -0
  598. package/script/types/0_price_tag.d.ts +19 -0
  599. package/script/types/0_price_tag.js +19 -0
  600. package/script/types/0_reaction.d.ts +19 -0
  601. package/script/types/0_reaction.js +21 -2
  602. package/script/types/0_restriction_reason.d.ts +19 -0
  603. package/script/types/0_restriction_reason.js +19 -0
  604. package/script/types/0_story_reference.d.ts +19 -0
  605. package/script/types/0_story_reference.js +19 -0
  606. package/script/types/0_thumbnail.d.ts +19 -0
  607. package/script/types/0_thumbnail.js +19 -0
  608. package/script/types/0_voice.d.ts +19 -0
  609. package/script/types/0_voice.js +19 -0
  610. package/script/types/1_animation.d.ts +19 -0
  611. package/script/types/1_animation.js +19 -0
  612. package/script/types/1_audio.d.ts +19 -0
  613. package/script/types/1_audio.js +19 -0
  614. package/script/types/1_bot_command_scope.d.ts +19 -0
  615. package/script/types/1_bot_command_scope.js +22 -3
  616. package/script/types/1_chat_p.d.ts +19 -0
  617. package/script/types/1_chat_p.js +21 -1
  618. package/script/types/1_document.d.ts +19 -0
  619. package/script/types/1_document.js +19 -0
  620. package/script/types/1_giveaway.d.ts +19 -0
  621. package/script/types/1_giveaway.js +19 -0
  622. package/script/types/1_inline_query_result_button.d.ts +19 -0
  623. package/script/types/1_inline_query_result_button.js +19 -0
  624. package/script/types/1_input_message_content.d.ts +19 -0
  625. package/script/types/1_input_message_content.js +19 -0
  626. package/script/types/1_input_story_content.d.ts +19 -0
  627. package/script/types/1_input_story_content.js +19 -0
  628. package/script/types/1_keyboard_button.d.ts +19 -0
  629. package/script/types/1_keyboard_button.js +22 -3
  630. package/script/types/1_message_reaction.d.ts +19 -0
  631. package/script/types/1_message_reaction.js +21 -2
  632. package/script/types/1_network_statistics.d.ts +19 -0
  633. package/script/types/1_network_statistics.js +19 -0
  634. package/script/types/1_photo.d.ts +19 -0
  635. package/script/types/1_photo.js +19 -0
  636. package/script/types/1_poll.d.ts +19 -0
  637. package/script/types/1_poll.js +19 -0
  638. package/script/types/1_reaction_count.d.ts +19 -0
  639. package/script/types/1_reaction_count.js +19 -0
  640. package/script/types/1_reply_quote.d.ts +19 -0
  641. package/script/types/1_reply_quote.js +19 -0
  642. package/script/types/1_sticker.d.ts +19 -0
  643. package/script/types/1_sticker.js +19 -0
  644. package/script/types/1_story_privacy.d.ts +19 -0
  645. package/script/types/1_story_privacy.js +22 -3
  646. package/script/types/1_story_reaction.d.ts +19 -0
  647. package/script/types/1_story_reaction.js +19 -0
  648. package/script/types/1_user.d.ts +19 -0
  649. package/script/types/1_user.js +19 -0
  650. package/script/types/1_venue.d.ts +19 -0
  651. package/script/types/1_venue.js +19 -0
  652. package/script/types/1_video.d.ts +19 -0
  653. package/script/types/1_video.js +19 -0
  654. package/script/types/1_video_note.d.ts +19 -0
  655. package/script/types/1_video_note.js +19 -0
  656. package/script/types/2_business_connection.d.ts +19 -0
  657. package/script/types/2_business_connection.js +19 -0
  658. package/script/types/2_chat_member.d.ts +19 -0
  659. package/script/types/2_chat_member.js +24 -4
  660. package/script/types/2_chosen_inline_result.d.ts +19 -0
  661. package/script/types/2_chosen_inline_result.js +21 -1
  662. package/script/types/2_game.d.ts +19 -0
  663. package/script/types/2_game.js +19 -0
  664. package/script/types/2_inactive_chat.d.ts +19 -0
  665. package/script/types/2_inactive_chat.js +21 -1
  666. package/script/types/2_inline_keyboard_button.d.ts +19 -0
  667. package/script/types/2_inline_keyboard_button.js +22 -3
  668. package/script/types/2_inline_query.d.ts +19 -0
  669. package/script/types/2_inline_query.js +22 -3
  670. package/script/types/2_invite_link.d.ts +19 -0
  671. package/script/types/2_invite_link.js +21 -1
  672. package/script/types/2_message_interactions.d.ts +19 -0
  673. package/script/types/2_message_interactions.js +19 -0
  674. package/script/types/2_message_reaction_count.d.ts +19 -0
  675. package/script/types/2_message_reaction_count.js +19 -0
  676. package/script/types/2_message_reactions.d.ts +19 -0
  677. package/script/types/2_message_reactions.js +19 -0
  678. package/script/types/2_story_content.d.ts +19 -0
  679. package/script/types/2_story_content.js +24 -5
  680. package/script/types/2_story_interactions.d.ts +19 -0
  681. package/script/types/2_story_interactions.js +19 -0
  682. package/script/types/2_story_interactive_area.d.ts +19 -0
  683. package/script/types/2_story_interactive_area.js +24 -5
  684. package/script/types/3_chat_member_updated.d.ts +19 -0
  685. package/script/types/3_chat_member_updated.js +22 -2
  686. package/script/types/3_reply_markup.d.ts +19 -0
  687. package/script/types/3_reply_markup.js +22 -2
  688. package/script/types/3_story.d.ts +19 -0
  689. package/script/types/3_story.js +21 -1
  690. package/script/types/4_inline_query_result.d.ts +19 -0
  691. package/script/types/4_inline_query_result.js +24 -5
  692. package/script/types/4_message.d.ts +19 -0
  693. package/script/types/4_message.js +35 -15
  694. package/script/types/5_callback_query.d.ts +19 -0
  695. package/script/types/5_callback_query.js +22 -2
  696. package/script/types/5_chat.d.ts +19 -0
  697. package/script/types/5_chat.js +26 -6
  698. package/script/types/6_update.d.ts +19 -0
  699. package/script/types/6_update.js +19 -0
  700. package/script/types/_file_id.d.ts +19 -0
  701. package/script/types/_file_id.js +27 -7
  702. package/script/types/_getters.d.ts +19 -0
  703. package/script/types/_getters.js +19 -0
  704. package/script/utilities/0_bigint.d.ts +1 -0
  705. package/script/utilities/0_bigint.js +46 -1
  706. package/script/utilities/0_buffer.d.ts +19 -0
  707. package/script/utilities/0_buffer.js +19 -0
  708. package/script/utilities/0_cache_map.d.ts +19 -0
  709. package/script/utilities/0_cache_map.js +19 -0
  710. package/script/utilities/0_color.d.ts +19 -0
  711. package/script/utilities/0_color.js +19 -0
  712. package/script/utilities/0_crypto.d.ts +19 -0
  713. package/script/utilities/0_crypto.js +19 -0
  714. package/script/utilities/0_hash.js +19 -0
  715. package/script/utilities/0_logger.d.ts +27 -0
  716. package/script/utilities/0_logger.js +30 -6
  717. package/script/utilities/0_mutex.d.ts +19 -0
  718. package/script/utilities/0_mutex.js +19 -0
  719. package/script/utilities/0_object.d.ts +19 -0
  720. package/script/utilities/0_object.js +19 -0
  721. package/script/utilities/0_rle.d.ts +19 -0
  722. package/script/utilities/0_rle.js +19 -0
  723. package/script/utilities/0_types.d.ts +19 -0
  724. package/script/utilities/0_types.js +19 -0
  725. package/script/utilities/1_auth.js +19 -0
  726. package/script/utilities/1_base64.d.ts +19 -0
  727. package/script/utilities/1_base64.js +19 -0
  728. package/script/utilities/1_math.d.ts +20 -0
  729. package/script/utilities/1_math.js +74 -0
  730. package/script/utilities/1_misc.d.ts +19 -0
  731. package/script/utilities/1_misc.js +21 -2
  732. package/script/utilities/1_queue.d.ts +19 -0
  733. package/script/utilities/1_queue.js +19 -0
  734. package/esm/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +0 -324
  735. package/esm/utilities/0_control.d.ts +0 -1
  736. package/esm/utilities/0_control.js +0 -3
  737. package/script/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +0 -326
  738. package/script/utilities/0_control.d.ts +0 -1
  739. package/script/utilities/0_control.js +0 -7
  740. /package/{LICENSE → COPYING.LESSER} +0 -0
  741. /package/esm/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/tgcrypto.d.ts +0 -0
  742. /package/script/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/tgcrypto.d.ts +0 -0
@@ -0,0 +1,1046 @@
1
+ import decodeCodePoint from './utils/entities/decode_codepoint.js';
2
+ import entityMap from './utils/entities/maps/entities.js';
3
+ import legacyMap from './utils/entities/maps/legacy.js';
4
+ import xmlMap from './utils/entities/maps/xml.js';
5
+ /** All the states the tokenizer can be in. */
6
+ var State;
7
+ (function (State) {
8
+ State[State["Text"] = 1] = "Text";
9
+ State[State["BeforeTagName"] = 2] = "BeforeTagName";
10
+ State[State["InTagName"] = 3] = "InTagName";
11
+ State[State["InSelfClosingTag"] = 4] = "InSelfClosingTag";
12
+ State[State["BeforeClosingTagName"] = 5] = "BeforeClosingTagName";
13
+ State[State["InClosingTagName"] = 6] = "InClosingTagName";
14
+ State[State["AfterClosingTagName"] = 7] = "AfterClosingTagName";
15
+ // Attributes
16
+ State[State["BeforeAttributeName"] = 8] = "BeforeAttributeName";
17
+ State[State["InAttributeName"] = 9] = "InAttributeName";
18
+ State[State["AfterAttributeName"] = 10] = "AfterAttributeName";
19
+ State[State["BeforeAttributeValue"] = 11] = "BeforeAttributeValue";
20
+ State[State["InAttributeValueDq"] = 12] = "InAttributeValueDq";
21
+ State[State["InAttributeValueSq"] = 13] = "InAttributeValueSq";
22
+ State[State["InAttributeValueNq"] = 14] = "InAttributeValueNq";
23
+ // Declarations
24
+ State[State["BeforeDeclaration"] = 15] = "BeforeDeclaration";
25
+ State[State["InDeclaration"] = 16] = "InDeclaration";
26
+ // Processing instructions
27
+ State[State["InProcessingInstruction"] = 17] = "InProcessingInstruction";
28
+ // Comments
29
+ State[State["BeforeComment"] = 18] = "BeforeComment";
30
+ State[State["InComment"] = 19] = "InComment";
31
+ State[State["InSpecialComment"] = 20] = "InSpecialComment";
32
+ State[State["AfterComment1"] = 21] = "AfterComment1";
33
+ State[State["AfterComment2"] = 22] = "AfterComment2";
34
+ // Cdata
35
+ State[State["BeforeCdata1"] = 23] = "BeforeCdata1";
36
+ State[State["BeforeCdata2"] = 24] = "BeforeCdata2";
37
+ State[State["BeforeCdata3"] = 25] = "BeforeCdata3";
38
+ State[State["BeforeCdata4"] = 26] = "BeforeCdata4";
39
+ State[State["BeforeCdata5"] = 27] = "BeforeCdata5";
40
+ State[State["BeforeCdata6"] = 28] = "BeforeCdata6";
41
+ State[State["InCdata"] = 29] = "InCdata";
42
+ State[State["AfterCdata1"] = 30] = "AfterCdata1";
43
+ State[State["AfterCdata2"] = 31] = "AfterCdata2";
44
+ // Special tags
45
+ State[State["BeforeSpecialS"] = 32] = "BeforeSpecialS";
46
+ State[State["BeforeSpecialSEnd"] = 33] = "BeforeSpecialSEnd";
47
+ State[State["BeforeScript1"] = 34] = "BeforeScript1";
48
+ State[State["BeforeScript2"] = 35] = "BeforeScript2";
49
+ State[State["BeforeScript3"] = 36] = "BeforeScript3";
50
+ State[State["BeforeScript4"] = 37] = "BeforeScript4";
51
+ State[State["BeforeScript5"] = 38] = "BeforeScript5";
52
+ State[State["AfterScript1"] = 39] = "AfterScript1";
53
+ State[State["AfterScript2"] = 40] = "AfterScript2";
54
+ State[State["AfterScript3"] = 41] = "AfterScript3";
55
+ State[State["AfterScript4"] = 42] = "AfterScript4";
56
+ State[State["AfterScript5"] = 43] = "AfterScript5";
57
+ State[State["BeforeStyle1"] = 44] = "BeforeStyle1";
58
+ State[State["BeforeStyle2"] = 45] = "BeforeStyle2";
59
+ State[State["BeforeStyle3"] = 46] = "BeforeStyle3";
60
+ State[State["BeforeStyle4"] = 47] = "BeforeStyle4";
61
+ State[State["AfterStyle1"] = 48] = "AfterStyle1";
62
+ State[State["AfterStyle2"] = 49] = "AfterStyle2";
63
+ State[State["AfterStyle3"] = 50] = "AfterStyle3";
64
+ State[State["AfterStyle4"] = 51] = "AfterStyle4";
65
+ State[State["BeforeSpecialT"] = 52] = "BeforeSpecialT";
66
+ State[State["BeforeSpecialTEnd"] = 53] = "BeforeSpecialTEnd";
67
+ State[State["BeforeTitle1"] = 54] = "BeforeTitle1";
68
+ State[State["BeforeTitle2"] = 55] = "BeforeTitle2";
69
+ State[State["BeforeTitle3"] = 56] = "BeforeTitle3";
70
+ State[State["BeforeTitle4"] = 57] = "BeforeTitle4";
71
+ State[State["AfterTitle1"] = 58] = "AfterTitle1";
72
+ State[State["AfterTitle2"] = 59] = "AfterTitle2";
73
+ State[State["AfterTitle3"] = 60] = "AfterTitle3";
74
+ State[State["AfterTitle4"] = 61] = "AfterTitle4";
75
+ State[State["BeforeEntity"] = 62] = "BeforeEntity";
76
+ State[State["BeforeNumericEntity"] = 63] = "BeforeNumericEntity";
77
+ State[State["InNamedEntity"] = 64] = "InNamedEntity";
78
+ State[State["InNumericEntity"] = 65] = "InNumericEntity";
79
+ State[State["InHexEntity"] = 66] = "InHexEntity";
80
+ })(State || (State = {}));
81
+ var Special;
82
+ (function (Special) {
83
+ Special[Special["None"] = 1] = "None";
84
+ Special[Special["Script"] = 2] = "Script";
85
+ Special[Special["Style"] = 3] = "Style";
86
+ Special[Special["Title"] = 4] = "Title";
87
+ })(Special || (Special = {}));
88
+ function whitespace(c) {
89
+ return c === ' ' || c === '\n' || c === '\t' || c === '\f' || c === '\r';
90
+ }
91
+ function isASCIIAlpha(c) {
92
+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
93
+ }
94
+ function ifElseState(upper, SUCCESS, FAILURE) {
95
+ const lower = upper.toLowerCase();
96
+ if (upper === lower) {
97
+ return (t, c) => {
98
+ if (c === lower) {
99
+ t._state = SUCCESS;
100
+ }
101
+ else {
102
+ t._state = FAILURE;
103
+ t._index--;
104
+ }
105
+ };
106
+ }
107
+ return (t, c) => {
108
+ if (c === lower || c === upper) {
109
+ t._state = SUCCESS;
110
+ }
111
+ else {
112
+ t._state = FAILURE;
113
+ t._index--;
114
+ }
115
+ };
116
+ }
117
+ function consumeSpecialNameChar(upper, NEXT_STATE) {
118
+ const lower = upper.toLowerCase();
119
+ return (t, c) => {
120
+ if (c === lower || c === upper) {
121
+ t._state = NEXT_STATE;
122
+ }
123
+ else {
124
+ t._state = State.InTagName;
125
+ t._index--; // Consume the token again
126
+ }
127
+ };
128
+ }
129
+ const stateBeforeCdata1 = ifElseState('C', State.BeforeCdata2, State.InDeclaration);
130
+ const stateBeforeCdata2 = ifElseState('D', State.BeforeCdata3, State.InDeclaration);
131
+ const stateBeforeCdata3 = ifElseState('A', State.BeforeCdata4, State.InDeclaration);
132
+ const stateBeforeCdata4 = ifElseState('T', State.BeforeCdata5, State.InDeclaration);
133
+ const stateBeforeCdata5 = ifElseState('A', State.BeforeCdata6, State.InDeclaration);
134
+ const stateBeforeScript1 = consumeSpecialNameChar('R', State.BeforeScript2);
135
+ const stateBeforeScript2 = consumeSpecialNameChar('I', State.BeforeScript3);
136
+ const stateBeforeScript3 = consumeSpecialNameChar('P', State.BeforeScript4);
137
+ const stateBeforeScript4 = consumeSpecialNameChar('T', State.BeforeScript5);
138
+ const stateAfterScript1 = ifElseState('R', State.AfterScript2, State.Text);
139
+ const stateAfterScript2 = ifElseState('I', State.AfterScript3, State.Text);
140
+ const stateAfterScript3 = ifElseState('P', State.AfterScript4, State.Text);
141
+ const stateAfterScript4 = ifElseState('T', State.AfterScript5, State.Text);
142
+ const stateBeforeStyle1 = consumeSpecialNameChar('Y', State.BeforeStyle2);
143
+ const stateBeforeStyle2 = consumeSpecialNameChar('L', State.BeforeStyle3);
144
+ const stateBeforeStyle3 = consumeSpecialNameChar('E', State.BeforeStyle4);
145
+ const stateAfterStyle1 = ifElseState('Y', State.AfterStyle2, State.Text);
146
+ const stateAfterStyle2 = ifElseState('L', State.AfterStyle3, State.Text);
147
+ const stateAfterStyle3 = ifElseState('E', State.AfterStyle4, State.Text);
148
+ const stateBeforeSpecialT = consumeSpecialNameChar('I', State.BeforeTitle1);
149
+ const stateBeforeTitle1 = consumeSpecialNameChar('T', State.BeforeTitle2);
150
+ const stateBeforeTitle2 = consumeSpecialNameChar('L', State.BeforeTitle3);
151
+ const stateBeforeTitle3 = consumeSpecialNameChar('E', State.BeforeTitle4);
152
+ const stateAfterSpecialTEnd = ifElseState('I', State.AfterTitle1, State.Text);
153
+ const stateAfterTitle1 = ifElseState('T', State.AfterTitle2, State.Text);
154
+ const stateAfterTitle2 = ifElseState('L', State.AfterTitle3, State.Text);
155
+ const stateAfterTitle3 = ifElseState('E', State.AfterTitle4, State.Text);
156
+ const stateBeforeEntity = ifElseState('#', State.BeforeNumericEntity, State.InNamedEntity);
157
+ const stateBeforeNumericEntity = ifElseState('X', State.InHexEntity, State.InNumericEntity);
158
+ export default class Tokenizer {
159
+ constructor(options, cbs) {
160
+ /** The current state the tokenizer is in. */
161
+ Object.defineProperty(this, "_state", {
162
+ enumerable: true,
163
+ configurable: true,
164
+ writable: true,
165
+ value: State.Text
166
+ });
167
+ /** The read buffer. */
168
+ Object.defineProperty(this, "buffer", {
169
+ enumerable: true,
170
+ configurable: true,
171
+ writable: true,
172
+ value: ''
173
+ });
174
+ /** The beginning of the section that is currently being read. */
175
+ Object.defineProperty(this, "sectionStart", {
176
+ enumerable: true,
177
+ configurable: true,
178
+ writable: true,
179
+ value: 0
180
+ });
181
+ /** The index within the buffer that we are currently looking at. */
182
+ Object.defineProperty(this, "_index", {
183
+ enumerable: true,
184
+ configurable: true,
185
+ writable: true,
186
+ value: 0
187
+ });
188
+ /**
189
+ * Data that has already been processed will be removed from the buffer occasionally.
190
+ * `_bufferOffset` keeps track of how many characters have been removed, to make sure position information is accurate.
191
+ */
192
+ Object.defineProperty(this, "bufferOffset", {
193
+ enumerable: true,
194
+ configurable: true,
195
+ writable: true,
196
+ value: 0
197
+ });
198
+ /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
199
+ Object.defineProperty(this, "baseState", {
200
+ enumerable: true,
201
+ configurable: true,
202
+ writable: true,
203
+ value: State.Text
204
+ });
205
+ /** For special parsing behavior inside of script and style tags. */
206
+ Object.defineProperty(this, "special", {
207
+ enumerable: true,
208
+ configurable: true,
209
+ writable: true,
210
+ value: Special.None
211
+ });
212
+ /** Indicates whether the tokenizer has been paused. */
213
+ Object.defineProperty(this, "running", {
214
+ enumerable: true,
215
+ configurable: true,
216
+ writable: true,
217
+ value: true
218
+ });
219
+ /** Indicates whether the tokenizer has finished running / `.end` has been called. */
220
+ Object.defineProperty(this, "ended", {
221
+ enumerable: true,
222
+ configurable: true,
223
+ writable: true,
224
+ value: false
225
+ });
226
+ Object.defineProperty(this, "cbs", {
227
+ enumerable: true,
228
+ configurable: true,
229
+ writable: true,
230
+ value: void 0
231
+ });
232
+ Object.defineProperty(this, "xmlMode", {
233
+ enumerable: true,
234
+ configurable: true,
235
+ writable: true,
236
+ value: void 0
237
+ });
238
+ Object.defineProperty(this, "decodeEntities", {
239
+ enumerable: true,
240
+ configurable: true,
241
+ writable: true,
242
+ value: void 0
243
+ });
244
+ this.cbs = cbs;
245
+ this.xmlMode = !!options?.xmlMode;
246
+ this.decodeEntities = options?.decodeEntities ?? true;
247
+ }
248
+ reset() {
249
+ this._state = State.Text;
250
+ this.buffer = '';
251
+ this.sectionStart = 0;
252
+ this._index = 0;
253
+ this.bufferOffset = 0;
254
+ this.baseState = State.Text;
255
+ this.special = Special.None;
256
+ this.running = true;
257
+ this.ended = false;
258
+ }
259
+ write(chunk) {
260
+ if (this.ended)
261
+ this.cbs.onerror(Error('.write() after done!'));
262
+ this.buffer += chunk;
263
+ this.parse();
264
+ }
265
+ end(chunk) {
266
+ if (this.ended)
267
+ this.cbs.onerror(Error('.end() after done!'));
268
+ if (chunk)
269
+ this.write(chunk);
270
+ this.ended = true;
271
+ if (this.running)
272
+ this.finish();
273
+ }
274
+ pause() {
275
+ this.running = false;
276
+ }
277
+ resume() {
278
+ this.running = true;
279
+ if (this._index < this.buffer.length) {
280
+ this.parse();
281
+ }
282
+ if (this.ended) {
283
+ this.finish();
284
+ }
285
+ }
286
+ /**
287
+ * The current index within all of the written data.
288
+ */
289
+ getAbsoluteIndex() {
290
+ return this.bufferOffset + this._index;
291
+ }
292
+ stateText(c) {
293
+ if (c === '<') {
294
+ if (this._index > this.sectionStart) {
295
+ this.cbs.ontext(this.getSection());
296
+ }
297
+ this._state = State.BeforeTagName;
298
+ this.sectionStart = this._index;
299
+ }
300
+ else if (this.decodeEntities &&
301
+ c === '&' &&
302
+ (this.special === Special.None || this.special === Special.Title)) {
303
+ if (this._index > this.sectionStart) {
304
+ this.cbs.ontext(this.getSection());
305
+ }
306
+ this.baseState = State.Text;
307
+ this._state = State.BeforeEntity;
308
+ this.sectionStart = this._index;
309
+ }
310
+ }
311
+ /**
312
+ * HTML only allows ASCII alpha characters (a-z and A-Z) at the beginning of a tag name.
313
+ *
314
+ * XML allows a lot more characters here (@see https://www.w3.org/TR/REC-xml/#NT-NameStartChar).
315
+ * We allow anything that wouldn't end the tag.
316
+ */
317
+ isTagStartChar(c) {
318
+ return (isASCIIAlpha(c) ||
319
+ (this.xmlMode && !whitespace(c) && c !== '/' && c !== '>'));
320
+ }
321
+ stateBeforeTagName(c) {
322
+ if (c === '/') {
323
+ this._state = State.BeforeClosingTagName;
324
+ }
325
+ else if (c === '<') {
326
+ this.cbs.ontext(this.getSection());
327
+ this.sectionStart = this._index;
328
+ }
329
+ else if (c === '>' ||
330
+ this.special !== Special.None ||
331
+ whitespace(c)) {
332
+ this._state = State.Text;
333
+ }
334
+ else if (c === '!') {
335
+ this._state = State.BeforeDeclaration;
336
+ this.sectionStart = this._index + 1;
337
+ }
338
+ else if (c === '?') {
339
+ this._state = State.InProcessingInstruction;
340
+ this.sectionStart = this._index + 1;
341
+ }
342
+ else if (!this.isTagStartChar(c)) {
343
+ this._state = State.Text;
344
+ }
345
+ else {
346
+ this._state =
347
+ !this.xmlMode && (c === 's' || c === 'S')
348
+ ? State.BeforeSpecialS
349
+ : !this.xmlMode && (c === 't' || c === 'T')
350
+ ? State.BeforeSpecialT
351
+ : State.InTagName;
352
+ this.sectionStart = this._index;
353
+ }
354
+ }
355
+ stateInTagName(c) {
356
+ if (c === '/' || c === '>' || whitespace(c)) {
357
+ this.emitToken('onopentagname');
358
+ this._state = State.BeforeAttributeName;
359
+ this._index--;
360
+ }
361
+ }
362
+ stateBeforeClosingTagName(c) {
363
+ if (whitespace(c)) {
364
+ // Ignore
365
+ }
366
+ else if (c === '>') {
367
+ this._state = State.Text;
368
+ }
369
+ else if (this.special !== Special.None) {
370
+ if (this.special !== Special.Title && (c === 's' || c === 'S')) {
371
+ this._state = State.BeforeSpecialSEnd;
372
+ }
373
+ else if (this.special === Special.Title &&
374
+ (c === 't' || c === 'T')) {
375
+ this._state = State.BeforeSpecialTEnd;
376
+ }
377
+ else {
378
+ this._state = State.Text;
379
+ this._index--;
380
+ }
381
+ }
382
+ else if (!this.isTagStartChar(c)) {
383
+ this._state = State.InSpecialComment;
384
+ this.sectionStart = this._index;
385
+ }
386
+ else {
387
+ this._state = State.InClosingTagName;
388
+ this.sectionStart = this._index;
389
+ }
390
+ }
391
+ stateInClosingTagName(c) {
392
+ if (c === '>' || whitespace(c)) {
393
+ this.emitToken('onclosetag');
394
+ this._state = State.AfterClosingTagName;
395
+ this._index--;
396
+ }
397
+ }
398
+ stateAfterClosingTagName(c) {
399
+ // Skip everything until ">"
400
+ if (c === '>') {
401
+ this._state = State.Text;
402
+ this.sectionStart = this._index + 1;
403
+ }
404
+ }
405
+ stateBeforeAttributeName(c) {
406
+ if (c === '>') {
407
+ this.cbs.onopentagend();
408
+ this._state = State.Text;
409
+ this.sectionStart = this._index + 1;
410
+ }
411
+ else if (c === '/') {
412
+ this._state = State.InSelfClosingTag;
413
+ }
414
+ else if (!whitespace(c)) {
415
+ this._state = State.InAttributeName;
416
+ this.sectionStart = this._index;
417
+ }
418
+ }
419
+ stateInSelfClosingTag(c) {
420
+ if (c === '>') {
421
+ this.cbs.onselfclosingtag();
422
+ this._state = State.Text;
423
+ this.sectionStart = this._index + 1;
424
+ this.special = Special.None; // Reset special state, in case of self-closing special tags
425
+ }
426
+ else if (!whitespace(c)) {
427
+ this._state = State.BeforeAttributeName;
428
+ this._index--;
429
+ }
430
+ }
431
+ stateInAttributeName(c) {
432
+ if (c === '=' || c === '/' || c === '>' || whitespace(c)) {
433
+ this.cbs.onattribname(this.getSection());
434
+ this.sectionStart = -1;
435
+ this._state = State.AfterAttributeName;
436
+ this._index--;
437
+ }
438
+ }
439
+ stateAfterAttributeName(c) {
440
+ if (c === '=') {
441
+ this._state = State.BeforeAttributeValue;
442
+ }
443
+ else if (c === '/' || c === '>') {
444
+ this.cbs.onattribend(undefined);
445
+ this._state = State.BeforeAttributeName;
446
+ this._index--;
447
+ }
448
+ else if (!whitespace(c)) {
449
+ this.cbs.onattribend(undefined);
450
+ this._state = State.InAttributeName;
451
+ this.sectionStart = this._index;
452
+ }
453
+ }
454
+ stateBeforeAttributeValue(c) {
455
+ if (c === '"') {
456
+ this._state = State.InAttributeValueDq;
457
+ this.sectionStart = this._index + 1;
458
+ }
459
+ else if (c === "'") {
460
+ this._state = State.InAttributeValueSq;
461
+ this.sectionStart = this._index + 1;
462
+ }
463
+ else if (!whitespace(c)) {
464
+ this._state = State.InAttributeValueNq;
465
+ this.sectionStart = this._index;
466
+ this._index--; // Reconsume token
467
+ }
468
+ }
469
+ handleInAttributeValue(c, quote) {
470
+ if (c === quote) {
471
+ this.emitToken('onattribdata');
472
+ this.cbs.onattribend(quote);
473
+ this._state = State.BeforeAttributeName;
474
+ }
475
+ else if (this.decodeEntities && c === '&') {
476
+ this.emitToken('onattribdata');
477
+ this.baseState = this._state;
478
+ this._state = State.BeforeEntity;
479
+ this.sectionStart = this._index;
480
+ }
481
+ }
482
+ stateInAttributeValueDoubleQuotes(c) {
483
+ this.handleInAttributeValue(c, '"');
484
+ }
485
+ stateInAttributeValueSingleQuotes(c) {
486
+ this.handleInAttributeValue(c, "'");
487
+ }
488
+ stateInAttributeValueNoQuotes(c) {
489
+ if (whitespace(c) || c === '>') {
490
+ this.emitToken('onattribdata');
491
+ this.cbs.onattribend(null);
492
+ this._state = State.BeforeAttributeName;
493
+ this._index--;
494
+ }
495
+ else if (this.decodeEntities && c === '&') {
496
+ this.emitToken('onattribdata');
497
+ this.baseState = this._state;
498
+ this._state = State.BeforeEntity;
499
+ this.sectionStart = this._index;
500
+ }
501
+ }
502
+ stateBeforeDeclaration(c) {
503
+ this._state =
504
+ c === '['
505
+ ? State.BeforeCdata1
506
+ : c === '-'
507
+ ? State.BeforeComment
508
+ : State.InDeclaration;
509
+ }
510
+ stateInDeclaration(c) {
511
+ if (c === '>') {
512
+ this.cbs.ondeclaration(this.getSection());
513
+ this._state = State.Text;
514
+ this.sectionStart = this._index + 1;
515
+ }
516
+ }
517
+ stateInProcessingInstruction(c) {
518
+ if (c === '>') {
519
+ this.cbs.onprocessinginstruction(this.getSection());
520
+ this._state = State.Text;
521
+ this.sectionStart = this._index + 1;
522
+ }
523
+ }
524
+ stateBeforeComment(c) {
525
+ if (c === '-') {
526
+ this._state = State.InComment;
527
+ this.sectionStart = this._index + 1;
528
+ }
529
+ else {
530
+ this._state = State.InDeclaration;
531
+ }
532
+ }
533
+ stateInComment(c) {
534
+ if (c === '-')
535
+ this._state = State.AfterComment1;
536
+ }
537
+ stateInSpecialComment(c) {
538
+ if (c === '>') {
539
+ this.cbs.oncomment(this.buffer.substring(this.sectionStart, this._index));
540
+ this._state = State.Text;
541
+ this.sectionStart = this._index + 1;
542
+ }
543
+ }
544
+ stateAfterComment1(c) {
545
+ if (c === '-') {
546
+ this._state = State.AfterComment2;
547
+ }
548
+ else {
549
+ this._state = State.InComment;
550
+ }
551
+ }
552
+ stateAfterComment2(c) {
553
+ if (c === '>') {
554
+ // Remove 2 trailing chars
555
+ this.cbs.oncomment(this.buffer.substring(this.sectionStart, this._index - 2));
556
+ this._state = State.Text;
557
+ this.sectionStart = this._index + 1;
558
+ }
559
+ else if (c !== '-') {
560
+ this._state = State.InComment;
561
+ }
562
+ // Else: stay in AFTER_COMMENT_2 (`--->`)
563
+ }
564
+ stateBeforeCdata6(c) {
565
+ if (c === '[') {
566
+ this._state = State.InCdata;
567
+ this.sectionStart = this._index + 1;
568
+ }
569
+ else {
570
+ this._state = State.InDeclaration;
571
+ this._index--;
572
+ }
573
+ }
574
+ stateInCdata(c) {
575
+ if (c === ']')
576
+ this._state = State.AfterCdata1;
577
+ }
578
+ stateAfterCdata1(c) {
579
+ if (c === ']')
580
+ this._state = State.AfterCdata2;
581
+ else
582
+ this._state = State.InCdata;
583
+ }
584
+ stateAfterCdata2(c) {
585
+ if (c === '>') {
586
+ // Remove 2 trailing chars
587
+ this.cbs.oncdata(this.buffer.substring(this.sectionStart, this._index - 2));
588
+ this._state = State.Text;
589
+ this.sectionStart = this._index + 1;
590
+ }
591
+ else if (c !== ']') {
592
+ this._state = State.InCdata;
593
+ }
594
+ // Else: stay in AFTER_CDATA_2 (`]]]>`)
595
+ }
596
+ stateBeforeSpecialS(c) {
597
+ if (c === 'c' || c === 'C') {
598
+ this._state = State.BeforeScript1;
599
+ }
600
+ else if (c === 't' || c === 'T') {
601
+ this._state = State.BeforeStyle1;
602
+ }
603
+ else {
604
+ this._state = State.InTagName;
605
+ this._index--; // Consume the token again
606
+ }
607
+ }
608
+ stateBeforeSpecialSEnd(c) {
609
+ if (this.special === Special.Script && (c === 'c' || c === 'C')) {
610
+ this._state = State.AfterScript1;
611
+ }
612
+ else if (this.special === Special.Style && (c === 't' || c === 'T')) {
613
+ this._state = State.AfterStyle1;
614
+ }
615
+ else
616
+ this._state = State.Text;
617
+ }
618
+ stateBeforeSpecialLast(c, special) {
619
+ if (c === '/' || c === '>' || whitespace(c)) {
620
+ this.special = special;
621
+ }
622
+ this._state = State.InTagName;
623
+ this._index--; // Consume the token again
624
+ }
625
+ stateAfterSpecialLast(c, sectionStartOffset) {
626
+ if (c === '>' || whitespace(c)) {
627
+ this.special = Special.None;
628
+ this._state = State.InClosingTagName;
629
+ this.sectionStart = this._index - sectionStartOffset;
630
+ this._index--; // Reconsume the token
631
+ }
632
+ else
633
+ this._state = State.Text;
634
+ }
635
+ // For entities terminated with a semicolon
636
+ parseFixedEntity(map = this.xmlMode ? xmlMap : entityMap) {
637
+ // Offset = 1
638
+ if (this.sectionStart + 1 < this._index) {
639
+ const entity = this.buffer.substring(this.sectionStart + 1, this._index);
640
+ if (Object.prototype.hasOwnProperty.call(map, entity)) {
641
+ this.emitPartial(map[entity]);
642
+ this.sectionStart = this._index + 1;
643
+ }
644
+ }
645
+ }
646
+ // Parses legacy entities (without trailing semicolon)
647
+ parseLegacyEntity() {
648
+ const start = this.sectionStart + 1;
649
+ // The max length of legacy entities is 6
650
+ let limit = Math.min(this._index - start, 6);
651
+ while (limit >= 2) {
652
+ // The min length of legacy entities is 2
653
+ const entity = this.buffer.substr(start, limit);
654
+ if (Object.prototype.hasOwnProperty.call(legacyMap, entity)) {
655
+ this.emitPartial(legacyMap[entity]);
656
+ this.sectionStart += limit + 1;
657
+ return;
658
+ }
659
+ limit--;
660
+ }
661
+ }
662
+ stateInNamedEntity(c) {
663
+ if (c === ';') {
664
+ this.parseFixedEntity();
665
+ // Retry as legacy entity if entity wasn't parsed
666
+ if (this.baseState === State.Text &&
667
+ this.sectionStart + 1 < this._index &&
668
+ !this.xmlMode) {
669
+ this.parseLegacyEntity();
670
+ }
671
+ this._state = this.baseState;
672
+ }
673
+ else if ((c < '0' || c > '9') && !isASCIIAlpha(c)) {
674
+ if (this.xmlMode || this.sectionStart + 1 === this._index) {
675
+ // Ignore
676
+ }
677
+ else if (this.baseState !== State.Text) {
678
+ if (c !== '=') {
679
+ // Parse as legacy entity, without allowing additional characters.
680
+ this.parseFixedEntity(legacyMap);
681
+ }
682
+ }
683
+ else {
684
+ this.parseLegacyEntity();
685
+ }
686
+ this._state = this.baseState;
687
+ this._index--;
688
+ }
689
+ }
690
+ decodeNumericEntity(offset, base, strict) {
691
+ const sectionStart = this.sectionStart + offset;
692
+ if (sectionStart !== this._index) {
693
+ // Parse entity
694
+ const entity = this.buffer.substring(sectionStart, this._index);
695
+ const parsed = parseInt(entity, base);
696
+ this.emitPartial(decodeCodePoint(parsed));
697
+ this.sectionStart = strict ? this._index + 1 : this._index;
698
+ }
699
+ this._state = this.baseState;
700
+ }
701
+ stateInNumericEntity(c) {
702
+ if (c === ';') {
703
+ this.decodeNumericEntity(2, 10, true);
704
+ }
705
+ else if (c < '0' || c > '9') {
706
+ if (!this.xmlMode) {
707
+ this.decodeNumericEntity(2, 10, false);
708
+ }
709
+ else {
710
+ this._state = this.baseState;
711
+ }
712
+ this._index--;
713
+ }
714
+ }
715
+ stateInHexEntity(c) {
716
+ if (c === ';') {
717
+ this.decodeNumericEntity(3, 16, true);
718
+ }
719
+ else if ((c < 'a' || c > 'f') &&
720
+ (c < 'A' || c > 'F') &&
721
+ (c < '0' || c > '9')) {
722
+ if (!this.xmlMode) {
723
+ this.decodeNumericEntity(3, 16, false);
724
+ }
725
+ else {
726
+ this._state = this.baseState;
727
+ }
728
+ this._index--;
729
+ }
730
+ }
731
+ cleanup() {
732
+ if (this.sectionStart < 0) {
733
+ this.buffer = '';
734
+ this.bufferOffset += this._index;
735
+ this._index = 0;
736
+ }
737
+ else if (this.running) {
738
+ if (this._state === State.Text) {
739
+ if (this.sectionStart !== this._index) {
740
+ this.cbs.ontext(this.buffer.substr(this.sectionStart));
741
+ }
742
+ this.buffer = '';
743
+ this.bufferOffset += this._index;
744
+ this._index = 0;
745
+ }
746
+ else if (this.sectionStart === this._index) {
747
+ // The section just started
748
+ this.buffer = '';
749
+ this.bufferOffset += this._index;
750
+ this._index = 0;
751
+ }
752
+ else {
753
+ // Remove everything unnecessary
754
+ this.buffer = this.buffer.substr(this.sectionStart);
755
+ this._index -= this.sectionStart;
756
+ this.bufferOffset += this.sectionStart;
757
+ }
758
+ this.sectionStart = 0;
759
+ }
760
+ }
761
+ /**
762
+ * Iterates through the buffer, calling the function corresponding to the current state.
763
+ *
764
+ * States that are more likely to be hit are higher up, as a performance improvement.
765
+ */
766
+ parse() {
767
+ while (this._index < this.buffer.length && this.running) {
768
+ const c = this.buffer.charAt(this._index);
769
+ if (this._state === State.Text) {
770
+ this.stateText(c);
771
+ }
772
+ else if (this._state === State.InAttributeValueDq) {
773
+ this.stateInAttributeValueDoubleQuotes(c);
774
+ }
775
+ else if (this._state === State.InAttributeName) {
776
+ this.stateInAttributeName(c);
777
+ }
778
+ else if (this._state === State.InComment) {
779
+ this.stateInComment(c);
780
+ }
781
+ else if (this._state === State.InSpecialComment) {
782
+ this.stateInSpecialComment(c);
783
+ }
784
+ else if (this._state === State.BeforeAttributeName) {
785
+ this.stateBeforeAttributeName(c);
786
+ }
787
+ else if (this._state === State.InTagName) {
788
+ this.stateInTagName(c);
789
+ }
790
+ else if (this._state === State.InClosingTagName) {
791
+ this.stateInClosingTagName(c);
792
+ }
793
+ else if (this._state === State.BeforeTagName) {
794
+ this.stateBeforeTagName(c);
795
+ }
796
+ else if (this._state === State.AfterAttributeName) {
797
+ this.stateAfterAttributeName(c);
798
+ }
799
+ else if (this._state === State.InAttributeValueSq) {
800
+ this.stateInAttributeValueSingleQuotes(c);
801
+ }
802
+ else if (this._state === State.BeforeAttributeValue) {
803
+ this.stateBeforeAttributeValue(c);
804
+ }
805
+ else if (this._state === State.BeforeClosingTagName) {
806
+ this.stateBeforeClosingTagName(c);
807
+ }
808
+ else if (this._state === State.AfterClosingTagName) {
809
+ this.stateAfterClosingTagName(c);
810
+ }
811
+ else if (this._state === State.BeforeSpecialS) {
812
+ this.stateBeforeSpecialS(c);
813
+ }
814
+ else if (this._state === State.AfterComment1) {
815
+ this.stateAfterComment1(c);
816
+ }
817
+ else if (this._state === State.InAttributeValueNq) {
818
+ this.stateInAttributeValueNoQuotes(c);
819
+ }
820
+ else if (this._state === State.InSelfClosingTag) {
821
+ this.stateInSelfClosingTag(c);
822
+ }
823
+ else if (this._state === State.InDeclaration) {
824
+ this.stateInDeclaration(c);
825
+ }
826
+ else if (this._state === State.BeforeDeclaration) {
827
+ this.stateBeforeDeclaration(c);
828
+ }
829
+ else if (this._state === State.AfterComment2) {
830
+ this.stateAfterComment2(c);
831
+ }
832
+ else if (this._state === State.BeforeComment) {
833
+ this.stateBeforeComment(c);
834
+ }
835
+ else if (this._state === State.BeforeSpecialSEnd) {
836
+ this.stateBeforeSpecialSEnd(c);
837
+ }
838
+ else if (this._state === State.BeforeSpecialTEnd) {
839
+ stateAfterSpecialTEnd(this, c);
840
+ }
841
+ else if (this._state === State.AfterScript1) {
842
+ stateAfterScript1(this, c);
843
+ }
844
+ else if (this._state === State.AfterScript2) {
845
+ stateAfterScript2(this, c);
846
+ }
847
+ else if (this._state === State.AfterScript3) {
848
+ stateAfterScript3(this, c);
849
+ }
850
+ else if (this._state === State.BeforeScript1) {
851
+ stateBeforeScript1(this, c);
852
+ }
853
+ else if (this._state === State.BeforeScript2) {
854
+ stateBeforeScript2(this, c);
855
+ }
856
+ else if (this._state === State.BeforeScript3) {
857
+ stateBeforeScript3(this, c);
858
+ }
859
+ else if (this._state === State.BeforeScript4) {
860
+ stateBeforeScript4(this, c);
861
+ }
862
+ else if (this._state === State.BeforeScript5) {
863
+ this.stateBeforeSpecialLast(c, Special.Script);
864
+ }
865
+ else if (this._state === State.AfterScript4) {
866
+ stateAfterScript4(this, c);
867
+ }
868
+ else if (this._state === State.AfterScript5) {
869
+ this.stateAfterSpecialLast(c, 6);
870
+ }
871
+ else if (this._state === State.BeforeStyle1) {
872
+ stateBeforeStyle1(this, c);
873
+ }
874
+ else if (this._state === State.InCdata) {
875
+ this.stateInCdata(c);
876
+ }
877
+ else if (this._state === State.BeforeStyle2) {
878
+ stateBeforeStyle2(this, c);
879
+ }
880
+ else if (this._state === State.BeforeStyle3) {
881
+ stateBeforeStyle3(this, c);
882
+ }
883
+ else if (this._state === State.BeforeStyle4) {
884
+ this.stateBeforeSpecialLast(c, Special.Style);
885
+ }
886
+ else if (this._state === State.AfterStyle1) {
887
+ stateAfterStyle1(this, c);
888
+ }
889
+ else if (this._state === State.AfterStyle2) {
890
+ stateAfterStyle2(this, c);
891
+ }
892
+ else if (this._state === State.AfterStyle3) {
893
+ stateAfterStyle3(this, c);
894
+ }
895
+ else if (this._state === State.AfterStyle4) {
896
+ this.stateAfterSpecialLast(c, 5);
897
+ }
898
+ else if (this._state === State.BeforeSpecialT) {
899
+ stateBeforeSpecialT(this, c);
900
+ }
901
+ else if (this._state === State.BeforeTitle1) {
902
+ stateBeforeTitle1(this, c);
903
+ }
904
+ else if (this._state === State.BeforeTitle2) {
905
+ stateBeforeTitle2(this, c);
906
+ }
907
+ else if (this._state === State.BeforeTitle3) {
908
+ stateBeforeTitle3(this, c);
909
+ }
910
+ else if (this._state === State.BeforeTitle4) {
911
+ this.stateBeforeSpecialLast(c, Special.Title);
912
+ }
913
+ else if (this._state === State.AfterTitle1) {
914
+ stateAfterTitle1(this, c);
915
+ }
916
+ else if (this._state === State.AfterTitle2) {
917
+ stateAfterTitle2(this, c);
918
+ }
919
+ else if (this._state === State.AfterTitle3) {
920
+ stateAfterTitle3(this, c);
921
+ }
922
+ else if (this._state === State.AfterTitle4) {
923
+ this.stateAfterSpecialLast(c, 5);
924
+ }
925
+ else if (this._state === State.InProcessingInstruction) {
926
+ this.stateInProcessingInstruction(c);
927
+ }
928
+ else if (this._state === State.InNamedEntity) {
929
+ this.stateInNamedEntity(c);
930
+ }
931
+ else if (this._state === State.BeforeCdata1) {
932
+ stateBeforeCdata1(this, c);
933
+ }
934
+ else if (this._state === State.BeforeEntity) {
935
+ stateBeforeEntity(this, c);
936
+ }
937
+ else if (this._state === State.BeforeCdata2) {
938
+ stateBeforeCdata2(this, c);
939
+ }
940
+ else if (this._state === State.BeforeCdata3) {
941
+ stateBeforeCdata3(this, c);
942
+ }
943
+ else if (this._state === State.AfterCdata1) {
944
+ this.stateAfterCdata1(c);
945
+ }
946
+ else if (this._state === State.AfterCdata2) {
947
+ this.stateAfterCdata2(c);
948
+ }
949
+ else if (this._state === State.BeforeCdata4) {
950
+ stateBeforeCdata4(this, c);
951
+ }
952
+ else if (this._state === State.BeforeCdata5) {
953
+ stateBeforeCdata5(this, c);
954
+ }
955
+ else if (this._state === State.BeforeCdata6) {
956
+ this.stateBeforeCdata6(c);
957
+ }
958
+ else if (this._state === State.InHexEntity) {
959
+ this.stateInHexEntity(c);
960
+ }
961
+ else if (this._state === State.InNumericEntity) {
962
+ this.stateInNumericEntity(c);
963
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
964
+ }
965
+ else if (this._state === State.BeforeNumericEntity) {
966
+ stateBeforeNumericEntity(this, c);
967
+ }
968
+ else {
969
+ this.cbs.onerror(Error('unknown _state'), this._state);
970
+ }
971
+ this._index++;
972
+ }
973
+ this.cleanup();
974
+ }
975
+ finish() {
976
+ // If there is remaining data, emit it in a reasonable way
977
+ if (this.sectionStart < this._index) {
978
+ this.handleTrailingData();
979
+ }
980
+ this.cbs.onend();
981
+ }
982
+ handleTrailingData() {
983
+ const data = this.buffer.substr(this.sectionStart);
984
+ if (this._state === State.InCdata ||
985
+ this._state === State.AfterCdata1 ||
986
+ this._state === State.AfterCdata2) {
987
+ this.cbs.oncdata(data);
988
+ }
989
+ else if (this._state === State.InComment ||
990
+ this._state === State.AfterComment1 ||
991
+ this._state === State.AfterComment2) {
992
+ this.cbs.oncomment(data);
993
+ }
994
+ else if (this._state === State.InNamedEntity && !this.xmlMode) {
995
+ this.parseLegacyEntity();
996
+ if (this.sectionStart < this._index) {
997
+ this._state = this.baseState;
998
+ this.handleTrailingData();
999
+ }
1000
+ }
1001
+ else if (this._state === State.InNumericEntity && !this.xmlMode) {
1002
+ this.decodeNumericEntity(2, 10, false);
1003
+ if (this.sectionStart < this._index) {
1004
+ this._state = this.baseState;
1005
+ this.handleTrailingData();
1006
+ }
1007
+ }
1008
+ else if (this._state === State.InHexEntity && !this.xmlMode) {
1009
+ this.decodeNumericEntity(3, 16, false);
1010
+ if (this.sectionStart < this._index) {
1011
+ this._state = this.baseState;
1012
+ this.handleTrailingData();
1013
+ }
1014
+ }
1015
+ else if (this._state !== State.InTagName &&
1016
+ this._state !== State.BeforeAttributeName &&
1017
+ this._state !== State.BeforeAttributeValue &&
1018
+ this._state !== State.AfterAttributeName &&
1019
+ this._state !== State.InAttributeName &&
1020
+ this._state !== State.InAttributeValueSq &&
1021
+ this._state !== State.InAttributeValueDq &&
1022
+ this._state !== State.InAttributeValueNq &&
1023
+ this._state !== State.InClosingTagName) {
1024
+ this.cbs.ontext(data);
1025
+ }
1026
+ /*
1027
+ * Else, ignore remaining data
1028
+ * TODO add a way to remove current tag
1029
+ */
1030
+ }
1031
+ getSection() {
1032
+ return this.buffer.substring(this.sectionStart, this._index);
1033
+ }
1034
+ emitToken(name) {
1035
+ this.cbs[name](this.getSection());
1036
+ this.sectionStart = -1;
1037
+ }
1038
+ emitPartial(value) {
1039
+ if (this.baseState !== State.Text) {
1040
+ this.cbs.onattribdata(value); // TODO implement the new event
1041
+ }
1042
+ else {
1043
+ this.cbs.ontext(value);
1044
+ }
1045
+ }
1046
+ }