@mtkruto/node 0.1.191 → 0.1.201

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 (265) hide show
  1. package/esm/1_utilities.d.ts +1 -1
  2. package/esm/1_utilities.js +1 -1
  3. package/esm/2_tl.d.ts +6 -6
  4. package/esm/2_tl.js +6 -6
  5. package/esm/3_storage.d.ts +5 -5
  6. package/esm/3_storage.js +5 -5
  7. package/esm/3_types.d.ts +6 -5
  8. package/esm/3_types.js +6 -5
  9. package/esm/4_constants.d.ts +2 -2
  10. package/esm/4_constants.js +2 -2
  11. package/esm/5_client.d.ts +1 -1
  12. package/esm/5_client.js +1 -1
  13. package/esm/client/0_params.d.ts +7 -1
  14. package/esm/client/0_types.d.ts +1 -0
  15. package/esm/client/0_utilities.d.ts +0 -3
  16. package/esm/client/0_utilities.js +0 -20
  17. package/esm/client/1_business_connection_manager.d.ts +11 -0
  18. package/esm/client/1_business_connection_manager.js +47 -0
  19. package/esm/client/1_update_manager.d.ts +8 -1
  20. package/esm/client/1_update_manager.js +88 -8
  21. package/esm/client/2_message_manager.d.ts +7 -6
  22. package/esm/client/2_message_manager.js +48 -31
  23. package/esm/client/4_client.d.ts +426 -428
  24. package/esm/client/4_client.js +570 -530
  25. package/esm/storage/0_storage.d.ts +5 -0
  26. package/esm/storage/0_storage.js +20 -0
  27. package/esm/storage/{1_storage_indexed_db.js → 2_storage_indexed_db.js} +1 -1
  28. package/esm/storage/{1_storage_local_storage.js → 2_storage_local_storage.js} +1 -1
  29. package/{script/storage/1_storage_memory.d.ts → esm/storage/2_storage_memory.d.ts} +1 -4
  30. package/esm/storage/{1_storage_memory.js → 2_storage_memory.js} +8 -28
  31. package/esm/storage/{1_storage_session_storage.js → 2_storage_session_storage.js} +1 -1
  32. package/esm/tl/2_types.d.ts +1071 -183
  33. package/esm/tl/2_types.js +2916 -464
  34. package/esm/tl/3_functions.d.ts +381 -17
  35. package/esm/tl/3_functions.js +1002 -120
  36. package/{script/tl/4_tl_writer.d.ts → esm/tl/5_tl_writer.d.ts} +1 -1
  37. package/{script/tl/4_rpc_result.d.ts → esm/tl/6_rpc_result.d.ts} +1 -1
  38. package/esm/tl/{4_rpc_result.js → 6_rpc_result.js} +1 -1
  39. package/esm/tl/{6_message.d.ts → 7_message.d.ts} +2 -2
  40. package/esm/tl/{6_message.js → 7_message.js} +3 -3
  41. package/esm/tl/{7_message_container.d.ts → 8_message_container.d.ts} +1 -1
  42. package/esm/tl/{7_message_container.js → 8_message_container.js} +3 -3
  43. package/esm/types/0_chat_photo.js +1 -1
  44. package/esm/types/0_message_entity.d.ts +1 -1
  45. package/esm/types/0_thumbnail.js +1 -1
  46. package/esm/types/1_bot_command_scope.d.ts +1 -1
  47. package/esm/types/1_photo.js +2 -2
  48. package/esm/types/1_story_privacy.d.ts +1 -1
  49. package/esm/types/2_business_connection.d.ts +11 -0
  50. package/esm/types/2_business_connection.js +12 -0
  51. package/esm/types/2_chat_member.d.ts +1 -1
  52. package/esm/types/2_chosen_inline_result.d.ts +1 -1
  53. package/esm/types/2_game.js +1 -1
  54. package/esm/types/2_inline_keyboard_button.d.ts +1 -1
  55. package/esm/types/2_inline_query.d.ts +1 -1
  56. package/esm/types/2_invite_link.d.ts +1 -1
  57. package/esm/types/2_message_reaction_count.d.ts +1 -1
  58. package/esm/types/2_message_reactions.d.ts +1 -1
  59. package/esm/types/2_story_content.js +1 -1
  60. package/esm/types/{1_story_interactive_area.d.ts → 2_story_interactive_area.d.ts} +2 -2
  61. package/esm/types/{1_story_interactive_area.js → 2_story_interactive_area.js} +1 -1
  62. package/esm/types/3_chat_member_updated.d.ts +1 -1
  63. package/esm/types/3_reply_markup.d.ts +1 -1
  64. package/esm/types/3_story.d.ts +2 -2
  65. package/esm/types/3_story.js +1 -1
  66. package/esm/types/4_inline_query_result.d.ts +1 -1
  67. package/esm/types/4_inline_query_result.js +1 -1
  68. package/esm/types/4_message.d.ts +9 -3
  69. package/esm/types/4_message.js +22 -5
  70. package/esm/types/5_callback_query.d.ts +1 -1
  71. package/esm/types/5_chat.d.ts +1 -1
  72. package/esm/types/6_update.d.ts +12 -2
  73. package/package.json +1 -1
  74. package/script/1_utilities.d.ts +1 -1
  75. package/script/1_utilities.js +1 -1
  76. package/script/2_tl.d.ts +6 -6
  77. package/script/2_tl.js +6 -6
  78. package/script/3_storage.d.ts +5 -5
  79. package/script/3_storage.js +5 -5
  80. package/script/3_types.d.ts +6 -5
  81. package/script/3_types.js +6 -5
  82. package/script/4_constants.d.ts +2 -2
  83. package/script/4_constants.js +2 -2
  84. package/script/5_client.d.ts +1 -1
  85. package/script/5_client.js +1 -1
  86. package/script/client/0_params.d.ts +7 -1
  87. package/script/client/0_types.d.ts +1 -0
  88. package/script/client/0_utilities.d.ts +0 -3
  89. package/script/client/0_utilities.js +1 -23
  90. package/script/client/1_business_connection_manager.d.ts +11 -0
  91. package/script/client/1_business_connection_manager.js +51 -0
  92. package/script/client/1_update_manager.d.ts +8 -1
  93. package/script/client/1_update_manager.js +88 -8
  94. package/script/client/2_message_manager.d.ts +7 -6
  95. package/script/client/2_message_manager.js +47 -30
  96. package/script/client/4_client.d.ts +426 -428
  97. package/script/client/4_client.js +570 -530
  98. package/script/storage/0_storage.d.ts +5 -0
  99. package/script/storage/0_storage.js +20 -0
  100. package/script/storage/{1_storage_indexed_db.js → 2_storage_indexed_db.js} +7 -7
  101. package/script/storage/{1_storage_local_storage.js → 2_storage_local_storage.js} +10 -10
  102. package/{esm/storage/1_storage_memory.d.ts → script/storage/2_storage_memory.d.ts} +1 -4
  103. package/script/storage/{1_storage_memory.js → 2_storage_memory.js} +12 -32
  104. package/script/storage/{1_storage_session_storage.js → 2_storage_session_storage.js} +10 -10
  105. package/script/tl/2_types.d.ts +1071 -183
  106. package/script/tl/2_types.js +3028 -504
  107. package/script/tl/3_functions.d.ts +381 -17
  108. package/script/tl/3_functions.js +1047 -143
  109. package/{esm/tl/4_tl_writer.d.ts → script/tl/5_tl_writer.d.ts} +1 -1
  110. package/{esm/tl/4_rpc_result.d.ts → script/tl/6_rpc_result.d.ts} +1 -1
  111. package/script/tl/{4_rpc_result.js → 6_rpc_result.js} +2 -2
  112. package/script/tl/{6_message.d.ts → 7_message.d.ts} +2 -2
  113. package/script/tl/{6_message.js → 7_message.js} +8 -8
  114. package/script/tl/{7_message_container.d.ts → 8_message_container.d.ts} +1 -1
  115. package/script/tl/{7_message_container.js → 8_message_container.js} +7 -7
  116. package/script/types/0_chat_photo.js +9 -9
  117. package/script/types/0_message_entity.d.ts +1 -1
  118. package/script/types/0_thumbnail.js +6 -6
  119. package/script/types/1_bot_command_scope.d.ts +1 -1
  120. package/script/types/1_photo.js +7 -7
  121. package/script/types/1_story_privacy.d.ts +1 -1
  122. package/script/types/2_business_connection.d.ts +11 -0
  123. package/script/types/2_business_connection.js +16 -0
  124. package/script/types/2_chat_member.d.ts +1 -1
  125. package/script/types/2_chosen_inline_result.d.ts +1 -1
  126. package/script/types/2_game.js +3 -3
  127. package/script/types/2_inline_keyboard_button.d.ts +1 -1
  128. package/script/types/2_inline_query.d.ts +1 -1
  129. package/script/types/2_invite_link.d.ts +1 -1
  130. package/script/types/2_message_reaction_count.d.ts +1 -1
  131. package/script/types/2_message_reactions.d.ts +1 -1
  132. package/script/types/2_story_content.js +4 -4
  133. package/script/types/{1_story_interactive_area.d.ts → 2_story_interactive_area.d.ts} +2 -2
  134. package/script/types/{1_story_interactive_area.js → 2_story_interactive_area.js} +2 -2
  135. package/script/types/3_chat_member_updated.d.ts +1 -1
  136. package/script/types/3_reply_markup.d.ts +1 -1
  137. package/script/types/3_story.d.ts +2 -2
  138. package/script/types/3_story.js +2 -2
  139. package/script/types/4_inline_query_result.d.ts +1 -1
  140. package/script/types/4_inline_query_result.js +2 -2
  141. package/script/types/4_message.d.ts +9 -3
  142. package/script/types/4_message.js +37 -20
  143. package/script/types/5_callback_query.d.ts +1 -1
  144. package/script/types/5_chat.d.ts +1 -1
  145. package/script/types/6_update.d.ts +12 -2
  146. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.d.ts +0 -83
  147. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.js +0 -203
  148. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.d.ts +0 -50
  149. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.js +0 -274
  150. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.d.ts +0 -47
  151. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.js +0 -51
  152. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.d.ts +0 -66
  153. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.js +0 -191
  154. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Node.d.ts +0 -168
  155. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Node.js +0 -385
  156. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Parser.d.ts +0 -159
  157. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Parser.js +0 -431
  158. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.d.ts +0 -181
  159. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.js +0 -1046
  160. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/mod.d.ts +0 -42
  161. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/mod.js +0 -52
  162. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.d.ts +0 -11
  163. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.js +0 -122
  164. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.d.ts +0 -1
  165. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.js +0 -24
  166. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.d.ts +0 -46
  167. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.js +0 -121
  168. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.d.ts +0 -31
  169. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.js +0 -30
  170. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.d.ts +0 -2128
  171. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.js +0 -2127
  172. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.d.ts +0 -109
  173. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.js +0 -108
  174. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.d.ts +0 -8
  175. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.js +0 -1
  176. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.d.ts +0 -90
  177. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.js +0 -95
  178. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.d.ts +0 -50
  179. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.js +0 -128
  180. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.d.ts +0 -46
  181. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.js +0 -110
  182. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.d.ts +0 -42
  183. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.js +0 -120
  184. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.d.ts +0 -6
  185. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.js +0 -6
  186. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.d.ts +0 -54
  187. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.js +0 -110
  188. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.d.ts +0 -40
  189. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.js +0 -75
  190. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.d.ts +0 -58
  191. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.js +0 -101
  192. package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.d.ts +0 -83
  193. package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.js +0 -207
  194. package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.d.ts +0 -50
  195. package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.js +0 -301
  196. package/script/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.d.ts +0 -47
  197. package/script/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.js +0 -55
  198. package/script/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.d.ts +0 -66
  199. package/script/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.js +0 -222
  200. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Node.d.ts +0 -168
  201. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Node.js +0 -404
  202. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Parser.d.ts +0 -159
  203. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Parser.js +0 -438
  204. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.d.ts +0 -181
  205. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.js +0 -1052
  206. package/script/deps/deno.land/x/html_parser@v0.1.3/src/mod.d.ts +0 -42
  207. package/script/deps/deno.land/x/html_parser@v0.1.3/src/mod.js +0 -88
  208. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.d.ts +0 -11
  209. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.js +0 -128
  210. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.d.ts +0 -1
  211. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.js +0 -30
  212. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.d.ts +0 -46
  213. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.js +0 -129
  214. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.d.ts +0 -31
  215. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.js +0 -32
  216. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.d.ts +0 -2128
  217. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.js +0 -2129
  218. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.d.ts +0 -109
  219. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.js +0 -110
  220. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.d.ts +0 -8
  221. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.js +0 -3
  222. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.d.ts +0 -90
  223. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.js +0 -114
  224. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.d.ts +0 -50
  225. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.js +0 -134
  226. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.d.ts +0 -46
  227. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.js +0 -118
  228. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.d.ts +0 -42
  229. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.js +0 -129
  230. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.d.ts +0 -6
  231. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.js +0 -22
  232. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.d.ts +0 -54
  233. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.js +0 -119
  234. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.d.ts +0 -40
  235. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.js +0 -86
  236. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.d.ts +0 -58
  237. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.js +0 -112
  238. /package/esm/storage/{0_utilities.d.ts → 1_utilities.d.ts} +0 -0
  239. /package/esm/storage/{0_utilities.js → 1_utilities.js} +0 -0
  240. /package/esm/storage/{1_storage_indexed_db.d.ts → 2_storage_indexed_db.d.ts} +0 -0
  241. /package/esm/storage/{1_storage_local_storage.d.ts → 2_storage_local_storage.d.ts} +0 -0
  242. /package/esm/storage/{1_storage_session_storage.d.ts → 2_storage_session_storage.d.ts} +0 -0
  243. /package/esm/tl/{3_tl_reader.d.ts → 4_tl_reader.d.ts} +0 -0
  244. /package/esm/tl/{3_tl_reader.js → 4_tl_reader.js} +0 -0
  245. /package/esm/tl/{4_tl_writer.js → 5_tl_writer.js} +0 -0
  246. /package/esm/types/{0_venue.d.ts → 1_venue.d.ts} +0 -0
  247. /package/esm/types/{0_venue.js → 1_venue.js} +0 -0
  248. /package/esm/types/{0__file_id.d.ts → _file_id.d.ts} +0 -0
  249. /package/esm/types/{0__file_id.js → _file_id.js} +0 -0
  250. /package/esm/types/{1__getters.d.ts → _getters.d.ts} +0 -0
  251. /package/esm/types/{1__getters.js → _getters.js} +0 -0
  252. /package/script/storage/{0_utilities.d.ts → 1_utilities.d.ts} +0 -0
  253. /package/script/storage/{0_utilities.js → 1_utilities.js} +0 -0
  254. /package/script/storage/{1_storage_indexed_db.d.ts → 2_storage_indexed_db.d.ts} +0 -0
  255. /package/script/storage/{1_storage_local_storage.d.ts → 2_storage_local_storage.d.ts} +0 -0
  256. /package/script/storage/{1_storage_session_storage.d.ts → 2_storage_session_storage.d.ts} +0 -0
  257. /package/script/tl/{3_tl_reader.d.ts → 4_tl_reader.d.ts} +0 -0
  258. /package/script/tl/{3_tl_reader.js → 4_tl_reader.js} +0 -0
  259. /package/script/tl/{4_tl_writer.js → 5_tl_writer.js} +0 -0
  260. /package/script/types/{0_venue.d.ts → 1_venue.d.ts} +0 -0
  261. /package/script/types/{0_venue.js → 1_venue.js} +0 -0
  262. /package/script/types/{0__file_id.d.ts → _file_id.d.ts} +0 -0
  263. /package/script/types/{0__file_id.js → _file_id.js} +0 -0
  264. /package/script/types/{1__getters.d.ts → _getters.d.ts} +0 -0
  265. /package/script/types/{1__getters.js → _getters.js} +0 -0
@@ -1,159 +0,0 @@
1
- import Tokenizer from './Tokenizer.js';
2
- export interface ParserOptions {
3
- /**
4
- * Indicates whether special tags (`<script>`, `<style>`, and `<title>`) should get special treatment
5
- * and if "empty" tags (eg. `<br>`) can have children. If `false`, the content of special tags
6
- * will be text only. For feeds and other XML content (documents that don't consist of HTML),
7
- * set this to `true`.
8
- *
9
- * @default false
10
- */
11
- xmlMode?: boolean;
12
- /**
13
- * Decode entities within the document.
14
- *
15
- * @default true
16
- */
17
- decodeEntities?: boolean;
18
- /**
19
- * If set to true, all tags will be lowercased.
20
- *
21
- * @default !xmlMode
22
- */
23
- lowerCaseTags?: boolean;
24
- /**
25
- * If set to `true`, all attribute names will be lowercased. This has noticeable impact on speed.
26
- *
27
- * @default !xmlMode
28
- */
29
- lowerCaseAttributeNames?: boolean;
30
- /**
31
- * If set to true, CDATA sections will be recognized as text even if the xmlMode option is not enabled.
32
- * NOTE: If xmlMode is set to `true` then CDATA sections will always be recognized as text.
33
- *
34
- * @default xmlMode
35
- */
36
- recognizeCDATA?: boolean;
37
- /**
38
- * If set to `true`, self-closing tags will trigger the onclosetag event even if xmlMode is not set to `true`.
39
- * NOTE: If xmlMode is set to `true` then self-closing tags will always be recognized.
40
- *
41
- * @default xmlMode
42
- */
43
- recognizeSelfClosing?: boolean;
44
- /**
45
- * Allows the default tokenizer to be overwritten.
46
- */
47
- Tokenizer?: typeof Tokenizer;
48
- }
49
- export interface Handler {
50
- onparserinit(parser: Parser): void;
51
- /**
52
- * Resets the handler back to starting state
53
- */
54
- onreset(): void;
55
- /**
56
- * Signals the handler that parsing is done
57
- */
58
- onend(): void;
59
- onerror(error: Error): void;
60
- onclosetag(name: string): void;
61
- onopentagname(name: string): void;
62
- /**
63
- *
64
- * @param name Name of the attribute
65
- * @param value Value of the attribute.
66
- * @param quote Quotes used around the attribute. `null` if the attribute has no quotes around the value, `undefined` if the attribute has no value.
67
- */
68
- onattribute(name: string, value: string, quote?: string | undefined | null): void;
69
- onopentag(name: string, attribs: {
70
- [s: string]: string;
71
- }): void;
72
- ontext(data: string): void;
73
- oncomment(data: string): void;
74
- oncdatastart(): void;
75
- oncdataend(): void;
76
- oncommentend(): void;
77
- onprocessinginstruction(name: string, data: string): void;
78
- }
79
- export declare class Parser {
80
- /** The start index of the last event. */
81
- startIndex: number;
82
- /** The end index of the last event. */
83
- endIndex: number | null;
84
- private tagname;
85
- private attribname;
86
- private attribvalue;
87
- private attribs;
88
- private stack;
89
- private readonly foreignContext;
90
- private readonly cbs;
91
- private readonly options;
92
- private readonly lowerCaseTagNames;
93
- private readonly lowerCaseAttributeNames;
94
- private readonly tokenizer;
95
- constructor(cbs: Partial<Handler> | null, options?: ParserOptions);
96
- private updatePosition;
97
- ontext(data: string): void;
98
- isVoidElement(name: string): boolean;
99
- onopentagname(name: string): void;
100
- onopentagend(): void;
101
- onclosetag(name: string): void;
102
- onselfclosingtag(): void;
103
- private closeCurrentTag;
104
- onattribname(name: string): void;
105
- onattribdata(value: string): void;
106
- onattribend(quote: string | undefined | null): void;
107
- private getInstructionName;
108
- ondeclaration(value: string): void;
109
- onprocessinginstruction(value: string): void;
110
- oncomment(value: string): void;
111
- oncdata(value: string): void;
112
- onerror(err: Error): void;
113
- onend(): void;
114
- /**
115
- * Resets the parser to a blank state, ready to parse a new HTML document
116
- */
117
- reset(): void;
118
- /**
119
- * Resets the parser, then parses a complete document and
120
- * pushes it to the handler.
121
- *
122
- * @param data Document to parse.
123
- */
124
- parseComplete(data: string): void;
125
- /**
126
- * Parses a chunk of data and calls the corresponding callbacks.
127
- *
128
- * @param chunk Chunk to parse.
129
- */
130
- write(chunk: string): void;
131
- /**
132
- * Parses the end of the buffer and clears the stack, calls onend.
133
- *
134
- * @param chunk Optional final chunk to parse.
135
- */
136
- end(chunk?: string): void;
137
- /**
138
- * Pauses parsing. The parser won't emit events until `resume` is called.
139
- */
140
- pause(): void;
141
- /**
142
- * Resumes parsing after `pause` was called.
143
- */
144
- resume(): void;
145
- /**
146
- * Alias of `write`, for backwards compatibility.
147
- *
148
- * @param chunk Chunk to parse.
149
- * @deprecated
150
- */
151
- parseChunk(chunk: string): void;
152
- /**
153
- * Alias of `end`, for backwards compatibility.
154
- *
155
- * @param chunk Optional final chunk to parse.
156
- * @deprecated
157
- */
158
- done(chunk?: string): void;
159
- }
@@ -1,438 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Parser = void 0;
7
- const Tokenizer_js_1 = __importDefault(require("./Tokenizer.js"));
8
- const formTags = new Set([
9
- 'input',
10
- 'option',
11
- 'optgroup',
12
- 'select',
13
- 'button',
14
- 'datalist',
15
- 'textarea',
16
- ]);
17
- const pTag = new Set(['p']);
18
- const openImpliesClose = {
19
- tr: new Set(['tr', 'th', 'td']),
20
- th: new Set(['th']),
21
- td: new Set(['thead', 'th', 'td']),
22
- body: new Set(['head', 'link', 'script']),
23
- li: new Set(['li']),
24
- p: pTag,
25
- h1: pTag,
26
- h2: pTag,
27
- h3: pTag,
28
- h4: pTag,
29
- h5: pTag,
30
- h6: pTag,
31
- select: formTags,
32
- input: formTags,
33
- output: formTags,
34
- button: formTags,
35
- datalist: formTags,
36
- textarea: formTags,
37
- option: new Set(['option']),
38
- optgroup: new Set(['optgroup', 'option']),
39
- dd: new Set(['dt', 'dd']),
40
- dt: new Set(['dt', 'dd']),
41
- address: pTag,
42
- article: pTag,
43
- aside: pTag,
44
- blockquote: pTag,
45
- details: pTag,
46
- div: pTag,
47
- dl: pTag,
48
- fieldset: pTag,
49
- figcaption: pTag,
50
- figure: pTag,
51
- footer: pTag,
52
- form: pTag,
53
- header: pTag,
54
- hr: pTag,
55
- main: pTag,
56
- nav: pTag,
57
- ol: pTag,
58
- pre: pTag,
59
- section: pTag,
60
- table: pTag,
61
- ul: pTag,
62
- rt: new Set(['rt', 'rp']),
63
- rp: new Set(['rt', 'rp']),
64
- tbody: new Set(['thead', 'tbody']),
65
- tfoot: new Set(['thead', 'tbody']),
66
- };
67
- const voidElements = new Set([
68
- 'area',
69
- 'base',
70
- 'basefont',
71
- 'br',
72
- 'col',
73
- 'command',
74
- 'embed',
75
- 'frame',
76
- 'hr',
77
- 'img',
78
- 'input',
79
- 'isindex',
80
- 'keygen',
81
- 'link',
82
- 'meta',
83
- 'param',
84
- 'source',
85
- 'track',
86
- 'wbr',
87
- ]);
88
- const foreignContextElements = new Set(['math', 'svg']);
89
- const htmlIntegrationElements = new Set([
90
- 'mi',
91
- 'mo',
92
- 'mn',
93
- 'ms',
94
- 'mtext',
95
- 'annotation-xml',
96
- 'foreignObject',
97
- 'desc',
98
- 'title',
99
- ]);
100
- const reNameEnd = /\s|\//;
101
- class Parser {
102
- constructor(cbs, options = {}) {
103
- /** The start index of the last event. */
104
- Object.defineProperty(this, "startIndex", {
105
- enumerable: true,
106
- configurable: true,
107
- writable: true,
108
- value: 0
109
- });
110
- /** The end index of the last event. */
111
- Object.defineProperty(this, "endIndex", {
112
- enumerable: true,
113
- configurable: true,
114
- writable: true,
115
- value: null
116
- });
117
- Object.defineProperty(this, "tagname", {
118
- enumerable: true,
119
- configurable: true,
120
- writable: true,
121
- value: ''
122
- });
123
- Object.defineProperty(this, "attribname", {
124
- enumerable: true,
125
- configurable: true,
126
- writable: true,
127
- value: ''
128
- });
129
- Object.defineProperty(this, "attribvalue", {
130
- enumerable: true,
131
- configurable: true,
132
- writable: true,
133
- value: ''
134
- });
135
- Object.defineProperty(this, "attribs", {
136
- enumerable: true,
137
- configurable: true,
138
- writable: true,
139
- value: null
140
- });
141
- Object.defineProperty(this, "stack", {
142
- enumerable: true,
143
- configurable: true,
144
- writable: true,
145
- value: []
146
- });
147
- Object.defineProperty(this, "foreignContext", {
148
- enumerable: true,
149
- configurable: true,
150
- writable: true,
151
- value: []
152
- });
153
- Object.defineProperty(this, "cbs", {
154
- enumerable: true,
155
- configurable: true,
156
- writable: true,
157
- value: void 0
158
- });
159
- Object.defineProperty(this, "options", {
160
- enumerable: true,
161
- configurable: true,
162
- writable: true,
163
- value: void 0
164
- });
165
- Object.defineProperty(this, "lowerCaseTagNames", {
166
- enumerable: true,
167
- configurable: true,
168
- writable: true,
169
- value: void 0
170
- });
171
- Object.defineProperty(this, "lowerCaseAttributeNames", {
172
- enumerable: true,
173
- configurable: true,
174
- writable: true,
175
- value: void 0
176
- });
177
- Object.defineProperty(this, "tokenizer", {
178
- enumerable: true,
179
- configurable: true,
180
- writable: true,
181
- value: void 0
182
- });
183
- this.options = options;
184
- this.cbs = cbs ?? {};
185
- this.lowerCaseTagNames = options.lowerCaseTags ?? !options.xmlMode;
186
- this.lowerCaseAttributeNames =
187
- options.lowerCaseAttributeNames ?? !options.xmlMode;
188
- this.tokenizer = new (options.Tokenizer ?? Tokenizer_js_1.default)(this.options, this);
189
- this.cbs.onparserinit?.(this);
190
- }
191
- updatePosition(initialOffset) {
192
- if (this.endIndex === null) {
193
- if (this.tokenizer.sectionStart <= initialOffset) {
194
- this.startIndex = 0;
195
- }
196
- else {
197
- this.startIndex = this.tokenizer.sectionStart - initialOffset;
198
- }
199
- }
200
- else {
201
- this.startIndex = this.endIndex + 1;
202
- }
203
- this.endIndex = this.tokenizer.getAbsoluteIndex();
204
- }
205
- // Tokenizer event handlers
206
- ontext(data) {
207
- this.updatePosition(1);
208
- this.endIndex--;
209
- this.cbs.ontext?.(data);
210
- }
211
- isVoidElement(name) {
212
- return !this.options.xmlMode && voidElements.has(name);
213
- }
214
- onopentagname(name) {
215
- if (this.lowerCaseTagNames) {
216
- name = name.toLowerCase();
217
- }
218
- this.tagname = name;
219
- if (!this.options.xmlMode &&
220
- Object.prototype.hasOwnProperty.call(openImpliesClose, name)) {
221
- let el;
222
- while (this.stack.length > 0 &&
223
- openImpliesClose[name]?.has((el = this.stack[this.stack.length - 1]))) {
224
- this.onclosetag(el);
225
- }
226
- }
227
- if (!this.isVoidElement(name)) {
228
- this.stack.push(name);
229
- if (foreignContextElements.has(name)) {
230
- this.foreignContext.push(true);
231
- }
232
- else if (htmlIntegrationElements.has(name)) {
233
- this.foreignContext.push(false);
234
- }
235
- }
236
- this.cbs.onopentagname?.(name);
237
- if (this.cbs.onopentag)
238
- this.attribs = {};
239
- }
240
- onopentagend() {
241
- this.updatePosition(1);
242
- if (this.attribs) {
243
- this.cbs.onopentag?.(this.tagname, this.attribs);
244
- this.attribs = null;
245
- }
246
- if (this.cbs.onclosetag && this.isVoidElement(this.tagname)) {
247
- this.cbs.onclosetag(this.tagname);
248
- }
249
- this.tagname = '';
250
- }
251
- onclosetag(name) {
252
- this.updatePosition(1);
253
- if (this.lowerCaseTagNames) {
254
- name = name.toLowerCase();
255
- }
256
- if (foreignContextElements.has(name) ||
257
- htmlIntegrationElements.has(name)) {
258
- this.foreignContext.pop();
259
- }
260
- if (this.stack.length && !this.isVoidElement(name)) {
261
- let pos = this.stack.lastIndexOf(name);
262
- if (pos !== -1) {
263
- if (this.cbs.onclosetag) {
264
- pos = this.stack.length - pos;
265
- while (pos--) {
266
- // We know the stack has sufficient elements.
267
- this.cbs.onclosetag(this.stack.pop());
268
- }
269
- }
270
- else
271
- this.stack.length = pos;
272
- }
273
- else if (name === 'p' && !this.options.xmlMode) {
274
- this.onopentagname(name);
275
- this.closeCurrentTag();
276
- }
277
- }
278
- else if (!this.options.xmlMode && (name === 'br' || name === 'p')) {
279
- this.onopentagname(name);
280
- this.closeCurrentTag();
281
- }
282
- }
283
- onselfclosingtag() {
284
- if (this.options.xmlMode ||
285
- this.options.recognizeSelfClosing ||
286
- this.foreignContext[this.foreignContext.length - 1]) {
287
- this.closeCurrentTag();
288
- }
289
- else {
290
- this.onopentagend();
291
- }
292
- }
293
- closeCurrentTag() {
294
- const name = this.tagname;
295
- this.onopentagend();
296
- /*
297
- * Self-closing tags will be on the top of the stack
298
- * (cheaper check than in onclosetag)
299
- */
300
- if (this.stack[this.stack.length - 1] === name) {
301
- this.cbs.onclosetag?.(name);
302
- this.stack.pop();
303
- }
304
- }
305
- onattribname(name) {
306
- if (this.lowerCaseAttributeNames) {
307
- name = name.toLowerCase();
308
- }
309
- this.attribname = name;
310
- }
311
- onattribdata(value) {
312
- this.attribvalue += value;
313
- }
314
- onattribend(quote) {
315
- this.cbs.onattribute?.(this.attribname, this.attribvalue, quote);
316
- if (this.attribs &&
317
- !Object.prototype.hasOwnProperty.call(this.attribs, this.attribname)) {
318
- this.attribs[this.attribname] = this.attribvalue;
319
- }
320
- this.attribname = '';
321
- this.attribvalue = '';
322
- }
323
- getInstructionName(value) {
324
- const idx = value.search(reNameEnd);
325
- let name = idx < 0 ? value : value.substr(0, idx);
326
- if (this.lowerCaseTagNames) {
327
- name = name.toLowerCase();
328
- }
329
- return name;
330
- }
331
- ondeclaration(value) {
332
- if (this.cbs.onprocessinginstruction) {
333
- const name = this.getInstructionName(value);
334
- this.cbs.onprocessinginstruction(`!${name}`, `!${value}`);
335
- }
336
- }
337
- onprocessinginstruction(value) {
338
- if (this.cbs.onprocessinginstruction) {
339
- const name = this.getInstructionName(value);
340
- this.cbs.onprocessinginstruction(`?${name}`, `?${value}`);
341
- }
342
- }
343
- oncomment(value) {
344
- this.updatePosition(4);
345
- this.cbs.oncomment?.(value);
346
- this.cbs.oncommentend?.();
347
- }
348
- oncdata(value) {
349
- this.updatePosition(1);
350
- if (this.options.xmlMode || this.options.recognizeCDATA) {
351
- this.cbs.oncdatastart?.();
352
- this.cbs.ontext?.(value);
353
- this.cbs.oncdataend?.();
354
- }
355
- else {
356
- this.oncomment(`[CDATA[${value}]]`);
357
- }
358
- }
359
- onerror(err) {
360
- this.cbs.onerror?.(err);
361
- }
362
- onend() {
363
- if (this.cbs.onclosetag) {
364
- for (let i = this.stack.length; i > 0; this.cbs.onclosetag(this.stack[--i]))
365
- ;
366
- }
367
- this.cbs.onend?.();
368
- }
369
- /**
370
- * Resets the parser to a blank state, ready to parse a new HTML document
371
- */
372
- reset() {
373
- this.cbs.onreset?.();
374
- this.tokenizer.reset();
375
- this.tagname = '';
376
- this.attribname = '';
377
- this.attribs = null;
378
- this.stack = [];
379
- this.cbs.onparserinit?.(this);
380
- }
381
- /**
382
- * Resets the parser, then parses a complete document and
383
- * pushes it to the handler.
384
- *
385
- * @param data Document to parse.
386
- */
387
- parseComplete(data) {
388
- this.reset();
389
- this.end(data);
390
- }
391
- /**
392
- * Parses a chunk of data and calls the corresponding callbacks.
393
- *
394
- * @param chunk Chunk to parse.
395
- */
396
- write(chunk) {
397
- this.tokenizer.write(chunk);
398
- }
399
- /**
400
- * Parses the end of the buffer and clears the stack, calls onend.
401
- *
402
- * @param chunk Optional final chunk to parse.
403
- */
404
- end(chunk) {
405
- this.tokenizer.end(chunk);
406
- }
407
- /**
408
- * Pauses parsing. The parser won't emit events until `resume` is called.
409
- */
410
- pause() {
411
- this.tokenizer.pause();
412
- }
413
- /**
414
- * Resumes parsing after `pause` was called.
415
- */
416
- resume() {
417
- this.tokenizer.resume();
418
- }
419
- /**
420
- * Alias of `write`, for backwards compatibility.
421
- *
422
- * @param chunk Chunk to parse.
423
- * @deprecated
424
- */
425
- parseChunk(chunk) {
426
- this.write(chunk);
427
- }
428
- /**
429
- * Alias of `end`, for backwards compatibility.
430
- *
431
- * @param chunk Optional final chunk to parse.
432
- * @deprecated
433
- */
434
- done(chunk) {
435
- this.end(chunk);
436
- }
437
- }
438
- exports.Parser = Parser;