@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,431 +0,0 @@
1
- import Tokenizer from './Tokenizer.js';
2
- const formTags = new Set([
3
- 'input',
4
- 'option',
5
- 'optgroup',
6
- 'select',
7
- 'button',
8
- 'datalist',
9
- 'textarea',
10
- ]);
11
- const pTag = new Set(['p']);
12
- const openImpliesClose = {
13
- tr: new Set(['tr', 'th', 'td']),
14
- th: new Set(['th']),
15
- td: new Set(['thead', 'th', 'td']),
16
- body: new Set(['head', 'link', 'script']),
17
- li: new Set(['li']),
18
- p: pTag,
19
- h1: pTag,
20
- h2: pTag,
21
- h3: pTag,
22
- h4: pTag,
23
- h5: pTag,
24
- h6: pTag,
25
- select: formTags,
26
- input: formTags,
27
- output: formTags,
28
- button: formTags,
29
- datalist: formTags,
30
- textarea: formTags,
31
- option: new Set(['option']),
32
- optgroup: new Set(['optgroup', 'option']),
33
- dd: new Set(['dt', 'dd']),
34
- dt: new Set(['dt', 'dd']),
35
- address: pTag,
36
- article: pTag,
37
- aside: pTag,
38
- blockquote: pTag,
39
- details: pTag,
40
- div: pTag,
41
- dl: pTag,
42
- fieldset: pTag,
43
- figcaption: pTag,
44
- figure: pTag,
45
- footer: pTag,
46
- form: pTag,
47
- header: pTag,
48
- hr: pTag,
49
- main: pTag,
50
- nav: pTag,
51
- ol: pTag,
52
- pre: pTag,
53
- section: pTag,
54
- table: pTag,
55
- ul: pTag,
56
- rt: new Set(['rt', 'rp']),
57
- rp: new Set(['rt', 'rp']),
58
- tbody: new Set(['thead', 'tbody']),
59
- tfoot: new Set(['thead', 'tbody']),
60
- };
61
- const voidElements = new Set([
62
- 'area',
63
- 'base',
64
- 'basefont',
65
- 'br',
66
- 'col',
67
- 'command',
68
- 'embed',
69
- 'frame',
70
- 'hr',
71
- 'img',
72
- 'input',
73
- 'isindex',
74
- 'keygen',
75
- 'link',
76
- 'meta',
77
- 'param',
78
- 'source',
79
- 'track',
80
- 'wbr',
81
- ]);
82
- const foreignContextElements = new Set(['math', 'svg']);
83
- const htmlIntegrationElements = new Set([
84
- 'mi',
85
- 'mo',
86
- 'mn',
87
- 'ms',
88
- 'mtext',
89
- 'annotation-xml',
90
- 'foreignObject',
91
- 'desc',
92
- 'title',
93
- ]);
94
- const reNameEnd = /\s|\//;
95
- export class Parser {
96
- constructor(cbs, options = {}) {
97
- /** The start index of the last event. */
98
- Object.defineProperty(this, "startIndex", {
99
- enumerable: true,
100
- configurable: true,
101
- writable: true,
102
- value: 0
103
- });
104
- /** The end index of the last event. */
105
- Object.defineProperty(this, "endIndex", {
106
- enumerable: true,
107
- configurable: true,
108
- writable: true,
109
- value: null
110
- });
111
- Object.defineProperty(this, "tagname", {
112
- enumerable: true,
113
- configurable: true,
114
- writable: true,
115
- value: ''
116
- });
117
- Object.defineProperty(this, "attribname", {
118
- enumerable: true,
119
- configurable: true,
120
- writable: true,
121
- value: ''
122
- });
123
- Object.defineProperty(this, "attribvalue", {
124
- enumerable: true,
125
- configurable: true,
126
- writable: true,
127
- value: ''
128
- });
129
- Object.defineProperty(this, "attribs", {
130
- enumerable: true,
131
- configurable: true,
132
- writable: true,
133
- value: null
134
- });
135
- Object.defineProperty(this, "stack", {
136
- enumerable: true,
137
- configurable: true,
138
- writable: true,
139
- value: []
140
- });
141
- Object.defineProperty(this, "foreignContext", {
142
- enumerable: true,
143
- configurable: true,
144
- writable: true,
145
- value: []
146
- });
147
- Object.defineProperty(this, "cbs", {
148
- enumerable: true,
149
- configurable: true,
150
- writable: true,
151
- value: void 0
152
- });
153
- Object.defineProperty(this, "options", {
154
- enumerable: true,
155
- configurable: true,
156
- writable: true,
157
- value: void 0
158
- });
159
- Object.defineProperty(this, "lowerCaseTagNames", {
160
- enumerable: true,
161
- configurable: true,
162
- writable: true,
163
- value: void 0
164
- });
165
- Object.defineProperty(this, "lowerCaseAttributeNames", {
166
- enumerable: true,
167
- configurable: true,
168
- writable: true,
169
- value: void 0
170
- });
171
- Object.defineProperty(this, "tokenizer", {
172
- enumerable: true,
173
- configurable: true,
174
- writable: true,
175
- value: void 0
176
- });
177
- this.options = options;
178
- this.cbs = cbs ?? {};
179
- this.lowerCaseTagNames = options.lowerCaseTags ?? !options.xmlMode;
180
- this.lowerCaseAttributeNames =
181
- options.lowerCaseAttributeNames ?? !options.xmlMode;
182
- this.tokenizer = new (options.Tokenizer ?? Tokenizer)(this.options, this);
183
- this.cbs.onparserinit?.(this);
184
- }
185
- updatePosition(initialOffset) {
186
- if (this.endIndex === null) {
187
- if (this.tokenizer.sectionStart <= initialOffset) {
188
- this.startIndex = 0;
189
- }
190
- else {
191
- this.startIndex = this.tokenizer.sectionStart - initialOffset;
192
- }
193
- }
194
- else {
195
- this.startIndex = this.endIndex + 1;
196
- }
197
- this.endIndex = this.tokenizer.getAbsoluteIndex();
198
- }
199
- // Tokenizer event handlers
200
- ontext(data) {
201
- this.updatePosition(1);
202
- this.endIndex--;
203
- this.cbs.ontext?.(data);
204
- }
205
- isVoidElement(name) {
206
- return !this.options.xmlMode && voidElements.has(name);
207
- }
208
- onopentagname(name) {
209
- if (this.lowerCaseTagNames) {
210
- name = name.toLowerCase();
211
- }
212
- this.tagname = name;
213
- if (!this.options.xmlMode &&
214
- Object.prototype.hasOwnProperty.call(openImpliesClose, name)) {
215
- let el;
216
- while (this.stack.length > 0 &&
217
- openImpliesClose[name]?.has((el = this.stack[this.stack.length - 1]))) {
218
- this.onclosetag(el);
219
- }
220
- }
221
- if (!this.isVoidElement(name)) {
222
- this.stack.push(name);
223
- if (foreignContextElements.has(name)) {
224
- this.foreignContext.push(true);
225
- }
226
- else if (htmlIntegrationElements.has(name)) {
227
- this.foreignContext.push(false);
228
- }
229
- }
230
- this.cbs.onopentagname?.(name);
231
- if (this.cbs.onopentag)
232
- this.attribs = {};
233
- }
234
- onopentagend() {
235
- this.updatePosition(1);
236
- if (this.attribs) {
237
- this.cbs.onopentag?.(this.tagname, this.attribs);
238
- this.attribs = null;
239
- }
240
- if (this.cbs.onclosetag && this.isVoidElement(this.tagname)) {
241
- this.cbs.onclosetag(this.tagname);
242
- }
243
- this.tagname = '';
244
- }
245
- onclosetag(name) {
246
- this.updatePosition(1);
247
- if (this.lowerCaseTagNames) {
248
- name = name.toLowerCase();
249
- }
250
- if (foreignContextElements.has(name) ||
251
- htmlIntegrationElements.has(name)) {
252
- this.foreignContext.pop();
253
- }
254
- if (this.stack.length && !this.isVoidElement(name)) {
255
- let pos = this.stack.lastIndexOf(name);
256
- if (pos !== -1) {
257
- if (this.cbs.onclosetag) {
258
- pos = this.stack.length - pos;
259
- while (pos--) {
260
- // We know the stack has sufficient elements.
261
- this.cbs.onclosetag(this.stack.pop());
262
- }
263
- }
264
- else
265
- this.stack.length = pos;
266
- }
267
- else if (name === 'p' && !this.options.xmlMode) {
268
- this.onopentagname(name);
269
- this.closeCurrentTag();
270
- }
271
- }
272
- else if (!this.options.xmlMode && (name === 'br' || name === 'p')) {
273
- this.onopentagname(name);
274
- this.closeCurrentTag();
275
- }
276
- }
277
- onselfclosingtag() {
278
- if (this.options.xmlMode ||
279
- this.options.recognizeSelfClosing ||
280
- this.foreignContext[this.foreignContext.length - 1]) {
281
- this.closeCurrentTag();
282
- }
283
- else {
284
- this.onopentagend();
285
- }
286
- }
287
- closeCurrentTag() {
288
- const name = this.tagname;
289
- this.onopentagend();
290
- /*
291
- * Self-closing tags will be on the top of the stack
292
- * (cheaper check than in onclosetag)
293
- */
294
- if (this.stack[this.stack.length - 1] === name) {
295
- this.cbs.onclosetag?.(name);
296
- this.stack.pop();
297
- }
298
- }
299
- onattribname(name) {
300
- if (this.lowerCaseAttributeNames) {
301
- name = name.toLowerCase();
302
- }
303
- this.attribname = name;
304
- }
305
- onattribdata(value) {
306
- this.attribvalue += value;
307
- }
308
- onattribend(quote) {
309
- this.cbs.onattribute?.(this.attribname, this.attribvalue, quote);
310
- if (this.attribs &&
311
- !Object.prototype.hasOwnProperty.call(this.attribs, this.attribname)) {
312
- this.attribs[this.attribname] = this.attribvalue;
313
- }
314
- this.attribname = '';
315
- this.attribvalue = '';
316
- }
317
- getInstructionName(value) {
318
- const idx = value.search(reNameEnd);
319
- let name = idx < 0 ? value : value.substr(0, idx);
320
- if (this.lowerCaseTagNames) {
321
- name = name.toLowerCase();
322
- }
323
- return name;
324
- }
325
- ondeclaration(value) {
326
- if (this.cbs.onprocessinginstruction) {
327
- const name = this.getInstructionName(value);
328
- this.cbs.onprocessinginstruction(`!${name}`, `!${value}`);
329
- }
330
- }
331
- onprocessinginstruction(value) {
332
- if (this.cbs.onprocessinginstruction) {
333
- const name = this.getInstructionName(value);
334
- this.cbs.onprocessinginstruction(`?${name}`, `?${value}`);
335
- }
336
- }
337
- oncomment(value) {
338
- this.updatePosition(4);
339
- this.cbs.oncomment?.(value);
340
- this.cbs.oncommentend?.();
341
- }
342
- oncdata(value) {
343
- this.updatePosition(1);
344
- if (this.options.xmlMode || this.options.recognizeCDATA) {
345
- this.cbs.oncdatastart?.();
346
- this.cbs.ontext?.(value);
347
- this.cbs.oncdataend?.();
348
- }
349
- else {
350
- this.oncomment(`[CDATA[${value}]]`);
351
- }
352
- }
353
- onerror(err) {
354
- this.cbs.onerror?.(err);
355
- }
356
- onend() {
357
- if (this.cbs.onclosetag) {
358
- for (let i = this.stack.length; i > 0; this.cbs.onclosetag(this.stack[--i]))
359
- ;
360
- }
361
- this.cbs.onend?.();
362
- }
363
- /**
364
- * Resets the parser to a blank state, ready to parse a new HTML document
365
- */
366
- reset() {
367
- this.cbs.onreset?.();
368
- this.tokenizer.reset();
369
- this.tagname = '';
370
- this.attribname = '';
371
- this.attribs = null;
372
- this.stack = [];
373
- this.cbs.onparserinit?.(this);
374
- }
375
- /**
376
- * Resets the parser, then parses a complete document and
377
- * pushes it to the handler.
378
- *
379
- * @param data Document to parse.
380
- */
381
- parseComplete(data) {
382
- this.reset();
383
- this.end(data);
384
- }
385
- /**
386
- * Parses a chunk of data and calls the corresponding callbacks.
387
- *
388
- * @param chunk Chunk to parse.
389
- */
390
- write(chunk) {
391
- this.tokenizer.write(chunk);
392
- }
393
- /**
394
- * Parses the end of the buffer and clears the stack, calls onend.
395
- *
396
- * @param chunk Optional final chunk to parse.
397
- */
398
- end(chunk) {
399
- this.tokenizer.end(chunk);
400
- }
401
- /**
402
- * Pauses parsing. The parser won't emit events until `resume` is called.
403
- */
404
- pause() {
405
- this.tokenizer.pause();
406
- }
407
- /**
408
- * Resumes parsing after `pause` was called.
409
- */
410
- resume() {
411
- this.tokenizer.resume();
412
- }
413
- /**
414
- * Alias of `write`, for backwards compatibility.
415
- *
416
- * @param chunk Chunk to parse.
417
- * @deprecated
418
- */
419
- parseChunk(chunk) {
420
- this.write(chunk);
421
- }
422
- /**
423
- * Alias of `end`, for backwards compatibility.
424
- *
425
- * @param chunk Optional final chunk to parse.
426
- * @deprecated
427
- */
428
- done(chunk) {
429
- this.end(chunk);
430
- }
431
- }
@@ -1,181 +0,0 @@
1
- /** All the states the tokenizer can be in. */
2
- declare const enum State {
3
- Text = 1,
4
- BeforeTagName = 2,
5
- InTagName = 3,
6
- InSelfClosingTag = 4,
7
- BeforeClosingTagName = 5,
8
- InClosingTagName = 6,
9
- AfterClosingTagName = 7,
10
- BeforeAttributeName = 8,
11
- InAttributeName = 9,
12
- AfterAttributeName = 10,
13
- BeforeAttributeValue = 11,
14
- InAttributeValueDq = 12,
15
- InAttributeValueSq = 13,
16
- InAttributeValueNq = 14,
17
- BeforeDeclaration = 15,
18
- InDeclaration = 16,
19
- InProcessingInstruction = 17,
20
- BeforeComment = 18,
21
- InComment = 19,
22
- InSpecialComment = 20,
23
- AfterComment1 = 21,
24
- AfterComment2 = 22,
25
- BeforeCdata1 = 23,
26
- BeforeCdata2 = 24,
27
- BeforeCdata3 = 25,
28
- BeforeCdata4 = 26,
29
- BeforeCdata5 = 27,
30
- BeforeCdata6 = 28,
31
- InCdata = 29,
32
- AfterCdata1 = 30,
33
- AfterCdata2 = 31,
34
- BeforeSpecialS = 32,
35
- BeforeSpecialSEnd = 33,
36
- BeforeScript1 = 34,
37
- BeforeScript2 = 35,
38
- BeforeScript3 = 36,
39
- BeforeScript4 = 37,
40
- BeforeScript5 = 38,
41
- AfterScript1 = 39,
42
- AfterScript2 = 40,
43
- AfterScript3 = 41,
44
- AfterScript4 = 42,
45
- AfterScript5 = 43,
46
- BeforeStyle1 = 44,
47
- BeforeStyle2 = 45,
48
- BeforeStyle3 = 46,
49
- BeforeStyle4 = 47,
50
- AfterStyle1 = 48,
51
- AfterStyle2 = 49,
52
- AfterStyle3 = 50,
53
- AfterStyle4 = 51,
54
- BeforeSpecialT = 52,
55
- BeforeSpecialTEnd = 53,
56
- BeforeTitle1 = 54,
57
- BeforeTitle2 = 55,
58
- BeforeTitle3 = 56,
59
- BeforeTitle4 = 57,
60
- AfterTitle1 = 58,
61
- AfterTitle2 = 59,
62
- AfterTitle3 = 60,
63
- AfterTitle4 = 61,
64
- BeforeEntity = 62,
65
- BeforeNumericEntity = 63,
66
- InNamedEntity = 64,
67
- InNumericEntity = 65,
68
- InHexEntity = 66
69
- }
70
- export interface Callbacks {
71
- onattribdata(value: string): void;
72
- onattribend(quote: string | undefined | null): void;
73
- onattribname(name: string): void;
74
- oncdata(data: string): void;
75
- onclosetag(name: string): void;
76
- oncomment(data: string): void;
77
- ondeclaration(content: string): void;
78
- onend(): void;
79
- onerror(error: Error, state?: State): void;
80
- onopentagend(): void;
81
- onopentagname(name: string): void;
82
- onprocessinginstruction(instruction: string): void;
83
- onselfclosingtag(): void;
84
- ontext(value: string): void;
85
- }
86
- export default class Tokenizer {
87
- /** The current state the tokenizer is in. */
88
- _state: State;
89
- /** The read buffer. */
90
- private buffer;
91
- /** The beginning of the section that is currently being read. */
92
- sectionStart: number;
93
- /** The index within the buffer that we are currently looking at. */
94
- _index: number;
95
- /**
96
- * Data that has already been processed will be removed from the buffer occasionally.
97
- * `_bufferOffset` keeps track of how many characters have been removed, to make sure position information is accurate.
98
- */
99
- private bufferOffset;
100
- /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
101
- private baseState;
102
- /** For special parsing behavior inside of script and style tags. */
103
- private special;
104
- /** Indicates whether the tokenizer has been paused. */
105
- private running;
106
- /** Indicates whether the tokenizer has finished running / `.end` has been called. */
107
- private ended;
108
- private readonly cbs;
109
- private readonly xmlMode;
110
- private readonly decodeEntities;
111
- constructor(options: {
112
- xmlMode?: boolean;
113
- decodeEntities?: boolean;
114
- } | null, cbs: Callbacks);
115
- reset(): void;
116
- write(chunk: string): void;
117
- end(chunk?: string): void;
118
- pause(): void;
119
- resume(): void;
120
- /**
121
- * The current index within all of the written data.
122
- */
123
- getAbsoluteIndex(): number;
124
- private stateText;
125
- /**
126
- * HTML only allows ASCII alpha characters (a-z and A-Z) at the beginning of a tag name.
127
- *
128
- * XML allows a lot more characters here (@see https://www.w3.org/TR/REC-xml/#NT-NameStartChar).
129
- * We allow anything that wouldn't end the tag.
130
- */
131
- private isTagStartChar;
132
- private stateBeforeTagName;
133
- private stateInTagName;
134
- private stateBeforeClosingTagName;
135
- private stateInClosingTagName;
136
- private stateAfterClosingTagName;
137
- private stateBeforeAttributeName;
138
- private stateInSelfClosingTag;
139
- private stateInAttributeName;
140
- private stateAfterAttributeName;
141
- private stateBeforeAttributeValue;
142
- private handleInAttributeValue;
143
- private stateInAttributeValueDoubleQuotes;
144
- private stateInAttributeValueSingleQuotes;
145
- private stateInAttributeValueNoQuotes;
146
- private stateBeforeDeclaration;
147
- private stateInDeclaration;
148
- private stateInProcessingInstruction;
149
- private stateBeforeComment;
150
- private stateInComment;
151
- private stateInSpecialComment;
152
- private stateAfterComment1;
153
- private stateAfterComment2;
154
- private stateBeforeCdata6;
155
- private stateInCdata;
156
- private stateAfterCdata1;
157
- private stateAfterCdata2;
158
- private stateBeforeSpecialS;
159
- private stateBeforeSpecialSEnd;
160
- private stateBeforeSpecialLast;
161
- private stateAfterSpecialLast;
162
- private parseFixedEntity;
163
- private parseLegacyEntity;
164
- private stateInNamedEntity;
165
- private decodeNumericEntity;
166
- private stateInNumericEntity;
167
- private stateInHexEntity;
168
- private cleanup;
169
- /**
170
- * Iterates through the buffer, calling the function corresponding to the current state.
171
- *
172
- * States that are more likely to be hit are higher up, as a performance improvement.
173
- */
174
- private parse;
175
- private finish;
176
- private handleTrailingData;
177
- private getSection;
178
- private emitToken;
179
- private emitPartial;
180
- }
181
- export {};