@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,301 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.attributeNames = exports.elementNames = void 0;
27
- /*
28
- * Module dependencies
29
- */
30
- const ElementType = __importStar(require("./ElementType.js"));
31
- const mod_js_1 = require("./utils/entities/mod.js");
32
- /**
33
- * Mixed-case SVG and MathML tags & attributes
34
- * recognized by the HTML parser.
35
- *
36
- * @see https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inforeign
37
- */
38
- exports.elementNames = new Map([
39
- ['altglyph', 'altGlyph'],
40
- ['altglyphdef', 'altGlyphDef'],
41
- ['altglyphitem', 'altGlyphItem'],
42
- ['animatecolor', 'animateColor'],
43
- ['animatemotion', 'animateMotion'],
44
- ['animatetransform', 'animateTransform'],
45
- ['clippath', 'clipPath'],
46
- ['feblend', 'feBlend'],
47
- ['fecolormatrix', 'feColorMatrix'],
48
- ['fecomponenttransfer', 'feComponentTransfer'],
49
- ['fecomposite', 'feComposite'],
50
- ['feconvolvematrix', 'feConvolveMatrix'],
51
- ['fediffuselighting', 'feDiffuseLighting'],
52
- ['fedisplacementmap', 'feDisplacementMap'],
53
- ['fedistantlight', 'feDistantLight'],
54
- ['fedropshadow', 'feDropShadow'],
55
- ['feflood', 'feFlood'],
56
- ['fefunca', 'feFuncA'],
57
- ['fefuncb', 'feFuncB'],
58
- ['fefuncg', 'feFuncG'],
59
- ['fefuncr', 'feFuncR'],
60
- ['fegaussianblur', 'feGaussianBlur'],
61
- ['feimage', 'feImage'],
62
- ['femerge', 'feMerge'],
63
- ['femergenode', 'feMergeNode'],
64
- ['femorphology', 'feMorphology'],
65
- ['feoffset', 'feOffset'],
66
- ['fepointlight', 'fePointLight'],
67
- ['fespecularlighting', 'feSpecularLighting'],
68
- ['fespotlight', 'feSpotLight'],
69
- ['fetile', 'feTile'],
70
- ['feturbulence', 'feTurbulence'],
71
- ['foreignobject', 'foreignObject'],
72
- ['glyphref', 'glyphRef'],
73
- ['lineargradient', 'linearGradient'],
74
- ['radialgradient', 'radialGradient'],
75
- ['textpath', 'textPath'],
76
- ]);
77
- exports.attributeNames = new Map([
78
- ['definitionurl', 'definitionURL'],
79
- ['attributename', 'attributeName'],
80
- ['attributetype', 'attributeType'],
81
- ['basefrequency', 'baseFrequency'],
82
- ['baseprofile', 'baseProfile'],
83
- ['calcmode', 'calcMode'],
84
- ['clippathunits', 'clipPathUnits'],
85
- ['diffuseconstant', 'diffuseConstant'],
86
- ['edgemode', 'edgeMode'],
87
- ['filterunits', 'filterUnits'],
88
- ['glyphref', 'glyphRef'],
89
- ['gradienttransform', 'gradientTransform'],
90
- ['gradientunits', 'gradientUnits'],
91
- ['kernelmatrix', 'kernelMatrix'],
92
- ['kernelunitlength', 'kernelUnitLength'],
93
- ['keypoints', 'keyPoints'],
94
- ['keysplines', 'keySplines'],
95
- ['keytimes', 'keyTimes'],
96
- ['lengthadjust', 'lengthAdjust'],
97
- ['limitingconeangle', 'limitingConeAngle'],
98
- ['markerheight', 'markerHeight'],
99
- ['markerunits', 'markerUnits'],
100
- ['markerwidth', 'markerWidth'],
101
- ['maskcontentunits', 'maskContentUnits'],
102
- ['maskunits', 'maskUnits'],
103
- ['numoctaves', 'numOctaves'],
104
- ['pathlength', 'pathLength'],
105
- ['patterncontentunits', 'patternContentUnits'],
106
- ['patterntransform', 'patternTransform'],
107
- ['patternunits', 'patternUnits'],
108
- ['pointsatx', 'pointsAtX'],
109
- ['pointsaty', 'pointsAtY'],
110
- ['pointsatz', 'pointsAtZ'],
111
- ['preservealpha', 'preserveAlpha'],
112
- ['preserveaspectratio', 'preserveAspectRatio'],
113
- ['primitiveunits', 'primitiveUnits'],
114
- ['refx', 'refX'],
115
- ['refy', 'refY'],
116
- ['repeatcount', 'repeatCount'],
117
- ['repeatdur', 'repeatDur'],
118
- ['requiredextensions', 'requiredExtensions'],
119
- ['requiredfeatures', 'requiredFeatures'],
120
- ['specularconstant', 'specularConstant'],
121
- ['specularexponent', 'specularExponent'],
122
- ['spreadmethod', 'spreadMethod'],
123
- ['startoffset', 'startOffset'],
124
- ['stddeviation', 'stdDeviation'],
125
- ['stitchtiles', 'stitchTiles'],
126
- ['surfacescale', 'surfaceScale'],
127
- ['systemlanguage', 'systemLanguage'],
128
- ['tablevalues', 'tableValues'],
129
- ['targetx', 'targetX'],
130
- ['targety', 'targetY'],
131
- ['textlength', 'textLength'],
132
- ['viewbox', 'viewBox'],
133
- ['viewtarget', 'viewTarget'],
134
- ['xchannelselector', 'xChannelSelector'],
135
- ['ychannelselector', 'yChannelSelector'],
136
- ['zoomandpan', 'zoomAndPan'],
137
- ]);
138
- const unencodedElements = new Set([
139
- 'style',
140
- 'script',
141
- 'xmp',
142
- 'iframe',
143
- 'noembed',
144
- 'noframes',
145
- 'plaintext',
146
- 'noscript',
147
- ]);
148
- /**
149
- * Format attributes
150
- */
151
- function formatAttributes(attributes, opts) {
152
- if (!attributes)
153
- return;
154
- return Object.keys(attributes)
155
- .map(key => {
156
- const value = attributes[key] ?? '';
157
- if (opts.xmlMode === 'foreign') {
158
- /* Fix up mixed-case attribute names */
159
- key = exports.attributeNames.get(key) ?? key;
160
- }
161
- if (!opts.emptyAttrs && !opts.xmlMode && value === '') {
162
- return key;
163
- }
164
- return `${key}="${opts.decodeEntities !== false
165
- ? (0, mod_js_1.encodeXML)(value)
166
- : value.replace(/"/g, '"')}"`;
167
- })
168
- .join(' ');
169
- }
170
- /**
171
- * Self-enclosing tags
172
- */
173
- const singleTag = new Set([
174
- 'area',
175
- 'base',
176
- 'basefont',
177
- 'br',
178
- 'col',
179
- 'command',
180
- 'embed',
181
- 'frame',
182
- 'hr',
183
- 'img',
184
- 'input',
185
- 'isindex',
186
- 'keygen',
187
- 'link',
188
- 'meta',
189
- 'param',
190
- 'source',
191
- 'track',
192
- 'wbr',
193
- ]);
194
- /**
195
- * Renders a DOM node or an array of DOM nodes to a string.
196
- *
197
- * Can be thought of as the equivalent of the `outerHTML` of the passed node(s).
198
- *
199
- * @param node Node to be rendered.
200
- * @param options Changes serialization behavior
201
- */
202
- function render(node, options = {}) {
203
- const nodes = 'length' in node ? node : [node];
204
- let output = '';
205
- for (let i = 0; i < nodes.length; i++) {
206
- output += renderNode(nodes[i], options);
207
- }
208
- return output;
209
- }
210
- exports.default = render;
211
- function renderNode(node, options) {
212
- switch (node.type) {
213
- case ElementType.Root:
214
- return render(node.children, options);
215
- case ElementType.Directive:
216
- case ElementType.Doctype:
217
- return renderDirective(node);
218
- case ElementType.Comment:
219
- return renderComment(node);
220
- case ElementType.CDATA:
221
- return renderCdata(node);
222
- case ElementType.Script:
223
- case ElementType.Style:
224
- case ElementType.Tag:
225
- return renderTag(node, options);
226
- case ElementType.Text:
227
- return renderText(node, options);
228
- }
229
- }
230
- const foreignModeIntegrationPoints = new Set([
231
- 'mi',
232
- 'mo',
233
- 'mn',
234
- 'ms',
235
- 'mtext',
236
- 'annotation-xml',
237
- 'foreignObject',
238
- 'desc',
239
- 'title',
240
- ]);
241
- const foreignElements = new Set(['svg', 'math']);
242
- function renderTag(elem, opts) {
243
- // Handle SVG / MathML in HTML
244
- if (opts.xmlMode === 'foreign') {
245
- /* Fix up mixed-case element names */
246
- elem.name = exports.elementNames.get(elem.name) ?? elem.name;
247
- /* Exit foreign mode at integration points */
248
- if (elem.parent &&
249
- foreignModeIntegrationPoints.has(elem.parent.name)) {
250
- opts = { ...opts, xmlMode: false };
251
- }
252
- }
253
- if (!opts.xmlMode && foreignElements.has(elem.name)) {
254
- opts = { ...opts, xmlMode: 'foreign' };
255
- }
256
- let tag = `<${elem.name}`;
257
- const attribs = formatAttributes(elem.attribs, opts);
258
- if (attribs) {
259
- tag += ` ${attribs}`;
260
- }
261
- if (elem.children.length === 0 &&
262
- (opts.xmlMode
263
- ? // In XML mode or foreign mode, and user hasn't explicitly turned off self-closing tags
264
- opts.selfClosingTags !== false
265
- : // User explicitly asked for self-closing tags, even in HTML mode
266
- opts.selfClosingTags && singleTag.has(elem.name))) {
267
- if (!opts.xmlMode)
268
- tag += ' ';
269
- tag += '/>';
270
- }
271
- else {
272
- tag += '>';
273
- if (elem.children.length > 0) {
274
- tag += render(elem.children, opts);
275
- }
276
- if (opts.xmlMode || !singleTag.has(elem.name)) {
277
- tag += `</${elem.name}>`;
278
- }
279
- }
280
- return tag;
281
- }
282
- function renderDirective(elem) {
283
- return `<${elem.data}>`;
284
- }
285
- function renderText(elem, opts) {
286
- let data = elem.data || '';
287
- // If entities weren't decoded, no need to encode them back
288
- if (opts.decodeEntities !== false &&
289
- !(!opts.xmlMode &&
290
- elem.parent &&
291
- unencodedElements.has(elem.parent.name))) {
292
- data = (0, mod_js_1.encodeXML)(data);
293
- }
294
- return data;
295
- }
296
- function renderCdata(elem) {
297
- return `<![CDATA[${elem.children[0].data}]]>`;
298
- }
299
- function renderComment(elem) {
300
- return `<!--${elem.data}-->`;
301
- }
@@ -1,47 +0,0 @@
1
- /** Types of elements found in htmlparser2's DOM */
2
- export declare enum ElementType {
3
- /** Type for the root element of a document */
4
- Root = "root",
5
- /** Type for Text */
6
- Text = "text",
7
- /** Type for <? ... ?> */
8
- Directive = "directive",
9
- /** Type for <!-- ... --> */
10
- Comment = "comment",
11
- /** Type for <script> tags */
12
- Script = "script",
13
- /** Type for <style> tags */
14
- Style = "style",
15
- /** Type for Any tag */
16
- Tag = "tag",
17
- /** Type for <![CDATA[ ... ]]> */
18
- CDATA = "cdata",
19
- /** Type for <!doctype ...> */
20
- Doctype = "doctype"
21
- }
22
- /**
23
- * Tests whether an element is a tag or not.
24
- *
25
- * @param elem Element to test
26
- */
27
- export declare function isTag(elem: {
28
- type: ElementType;
29
- }): boolean;
30
- /** Type for the root element of a document */
31
- export declare const Root = ElementType.Root;
32
- /** Type for Text */
33
- export declare const Text = ElementType.Text;
34
- /** Type for <? ... ?> */
35
- export declare const Directive = ElementType.Directive;
36
- /** Type for <!-- ... --> */
37
- export declare const Comment = ElementType.Comment;
38
- /** Type for <script> tags */
39
- export declare const Script = ElementType.Script;
40
- /** Type for <style> tags */
41
- export declare const Style = ElementType.Style;
42
- /** Type for Any tag */
43
- export declare const Tag = ElementType.Tag;
44
- /** Type for <![CDATA[ ... ]]> */
45
- export declare const CDATA = ElementType.CDATA;
46
- /** Type for <!doctype ...> */
47
- export declare const Doctype = ElementType.Doctype;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Doctype = exports.CDATA = exports.Tag = exports.Style = exports.Script = exports.Comment = exports.Directive = exports.Text = exports.Root = exports.isTag = exports.ElementType = void 0;
4
- /** Types of elements found in htmlparser2's DOM */
5
- var ElementType;
6
- (function (ElementType) {
7
- /** Type for the root element of a document */
8
- ElementType["Root"] = "root";
9
- /** Type for Text */
10
- ElementType["Text"] = "text";
11
- /** Type for <? ... ?> */
12
- ElementType["Directive"] = "directive";
13
- /** Type for <!-- ... --> */
14
- ElementType["Comment"] = "comment";
15
- /** Type for <script> tags */
16
- ElementType["Script"] = "script";
17
- /** Type for <style> tags */
18
- ElementType["Style"] = "style";
19
- /** Type for Any tag */
20
- ElementType["Tag"] = "tag";
21
- /** Type for <![CDATA[ ... ]]> */
22
- ElementType["CDATA"] = "cdata";
23
- /** Type for <!doctype ...> */
24
- ElementType["Doctype"] = "doctype";
25
- })(ElementType || (exports.ElementType = ElementType = {}));
26
- /**
27
- * Tests whether an element is a tag or not.
28
- *
29
- * @param elem Element to test
30
- */
31
- function isTag(elem) {
32
- return (elem.type === ElementType.Tag ||
33
- elem.type === ElementType.Script ||
34
- elem.type === ElementType.Style);
35
- }
36
- exports.isTag = isTag;
37
- // Exports for backwards compatibility
38
- /** Type for the root element of a document */
39
- exports.Root = ElementType.Root;
40
- /** Type for Text */
41
- exports.Text = ElementType.Text;
42
- /** Type for <? ... ?> */
43
- exports.Directive = ElementType.Directive;
44
- /** Type for <!-- ... --> */
45
- exports.Comment = ElementType.Comment;
46
- /** Type for <script> tags */
47
- exports.Script = ElementType.Script;
48
- /** Type for <style> tags */
49
- exports.Style = ElementType.Style;
50
- /** Type for Any tag */
51
- exports.Tag = ElementType.Tag;
52
- /** Type for <![CDATA[ ... ]]> */
53
- exports.CDATA = ElementType.CDATA;
54
- /** Type for <!doctype ...> */
55
- exports.Doctype = ElementType.Doctype;
@@ -1,66 +0,0 @@
1
- import DomHandler, { DomHandlerOptions } from './DomHandler.js';
2
- import { ParserOptions } from './Parser.js';
3
- declare enum FeedItemMediaMedium {
4
- image = 0,
5
- audio = 1,
6
- video = 2,
7
- document = 3,
8
- executable = 4
9
- }
10
- declare enum FeedItemMediaExpression {
11
- sample = 0,
12
- full = 1,
13
- nonstop = 2
14
- }
15
- interface FeedItemMedia {
16
- url?: string;
17
- fileSize?: number;
18
- type?: string;
19
- medium: FeedItemMediaMedium | undefined;
20
- isDefault: boolean;
21
- expression?: FeedItemMediaExpression;
22
- bitrate?: number;
23
- framerate?: number;
24
- samplingrate?: number;
25
- channels?: number;
26
- duration?: number;
27
- height?: number;
28
- width?: number;
29
- lang?: string;
30
- }
31
- interface FeedItem {
32
- id?: string;
33
- title?: string;
34
- link?: string;
35
- description?: string;
36
- pubDate?: Date;
37
- media?: FeedItemMedia[];
38
- }
39
- interface Feed {
40
- type?: string;
41
- id?: string;
42
- title?: string;
43
- link?: string;
44
- description?: string;
45
- updated?: Date;
46
- author?: string;
47
- items?: FeedItem[];
48
- }
49
- export declare class FeedHandler extends DomHandler {
50
- feed?: Feed;
51
- /**
52
- *
53
- * @param callback
54
- * @param options
55
- */
56
- constructor(callback?: ((error: Error | null) => void) | DomHandlerOptions, options?: DomHandlerOptions);
57
- onend(): void;
58
- }
59
- /**
60
- * Parse a feed.
61
- *
62
- * @param feed The feed that should be parsed, as a string.
63
- * @param options Optionally, options for parsing. When using this option, you should set `xmlMode` to `true`.
64
- */
65
- export declare function parseFeed(feed: string, options?: ParserOptions & DomHandlerOptions): Feed | undefined;
66
- export {};
@@ -1,222 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.parseFeed = exports.FeedHandler = void 0;
30
- const DomHandler_js_1 = __importDefault(require("./DomHandler.js"));
31
- const DomUtils = __importStar(require("./utils/mod.js"));
32
- const Parser_js_1 = require("./Parser.js");
33
- var FeedItemMediaMedium;
34
- (function (FeedItemMediaMedium) {
35
- FeedItemMediaMedium[FeedItemMediaMedium["image"] = 0] = "image";
36
- FeedItemMediaMedium[FeedItemMediaMedium["audio"] = 1] = "audio";
37
- FeedItemMediaMedium[FeedItemMediaMedium["video"] = 2] = "video";
38
- FeedItemMediaMedium[FeedItemMediaMedium["document"] = 3] = "document";
39
- FeedItemMediaMedium[FeedItemMediaMedium["executable"] = 4] = "executable";
40
- })(FeedItemMediaMedium || (FeedItemMediaMedium = {}));
41
- var FeedItemMediaExpression;
42
- (function (FeedItemMediaExpression) {
43
- FeedItemMediaExpression[FeedItemMediaExpression["sample"] = 0] = "sample";
44
- FeedItemMediaExpression[FeedItemMediaExpression["full"] = 1] = "full";
45
- FeedItemMediaExpression[FeedItemMediaExpression["nonstop"] = 2] = "nonstop";
46
- })(FeedItemMediaExpression || (FeedItemMediaExpression = {}));
47
- // TODO: Consume data as it is coming in
48
- class FeedHandler extends DomHandler_js_1.default {
49
- /**
50
- *
51
- * @param callback
52
- * @param options
53
- */
54
- constructor(callback, options) {
55
- if (typeof callback === 'object') {
56
- callback = undefined;
57
- options = callback;
58
- }
59
- super(callback, options);
60
- Object.defineProperty(this, "feed", {
61
- enumerable: true,
62
- configurable: true,
63
- writable: true,
64
- value: void 0
65
- });
66
- }
67
- onend() {
68
- const feedRoot = getOneElement(isValidFeed, this.dom);
69
- if (!feedRoot) {
70
- this.handleCallback(new Error("couldn't find root of feed"));
71
- return;
72
- }
73
- const feed = {};
74
- if (feedRoot.name === 'feed') {
75
- const childs = feedRoot.children;
76
- feed.type = 'atom';
77
- addConditionally(feed, 'id', 'id', childs);
78
- addConditionally(feed, 'title', 'title', childs);
79
- const href = getAttribute('href', getOneElement('link', childs));
80
- if (href) {
81
- feed.link = href;
82
- }
83
- addConditionally(feed, 'description', 'subtitle', childs);
84
- const updated = fetch('updated', childs);
85
- if (updated) {
86
- feed.updated = new Date(updated);
87
- }
88
- addConditionally(feed, 'author', 'email', childs, true);
89
- feed.items = getElements('entry', childs).map(item => {
90
- const entry = {};
91
- const { children } = item;
92
- addConditionally(entry, 'id', 'id', children);
93
- addConditionally(entry, 'title', 'title', children);
94
- const href = getAttribute('href', getOneElement('link', children));
95
- if (href) {
96
- entry.link = href;
97
- }
98
- const description = fetch('summary', children) || fetch('content', children);
99
- if (description) {
100
- entry.description = description;
101
- }
102
- const pubDate = fetch('updated', children);
103
- if (pubDate) {
104
- entry.pubDate = new Date(pubDate);
105
- }
106
- entry.media = getMediaElements(children);
107
- return entry;
108
- });
109
- }
110
- else {
111
- const childs = getOneElement('channel', feedRoot.children)?.children ?? [];
112
- feed.type = feedRoot.name.substr(0, 3);
113
- feed.id = '';
114
- addConditionally(feed, 'title', 'title', childs);
115
- addConditionally(feed, 'link', 'link', childs);
116
- addConditionally(feed, 'description', 'description', childs);
117
- const updated = fetch('lastBuildDate', childs);
118
- if (updated) {
119
- feed.updated = new Date(updated);
120
- }
121
- addConditionally(feed, 'author', 'managingEditor', childs, true);
122
- feed.items = getElements('item', feedRoot.children).map((item) => {
123
- const entry = {};
124
- const { children } = item;
125
- addConditionally(entry, 'id', 'guid', children);
126
- addConditionally(entry, 'title', 'title', children);
127
- addConditionally(entry, 'link', 'link', children);
128
- addConditionally(entry, 'description', 'description', children);
129
- const pubDate = fetch('pubDate', children);
130
- if (pubDate)
131
- entry.pubDate = new Date(pubDate);
132
- entry.media = getMediaElements(children);
133
- return entry;
134
- });
135
- }
136
- this.feed = feed;
137
- this.handleCallback(null);
138
- }
139
- }
140
- exports.FeedHandler = FeedHandler;
141
- function getMediaElements(where) {
142
- return getElements('media:content', where).map(elem => {
143
- const media = {
144
- medium: elem.attribs.medium,
145
- isDefault: !!elem.attribs.isDefault,
146
- };
147
- if (elem.attribs.url) {
148
- media.url = elem.attribs.url;
149
- }
150
- if (elem.attribs.fileSize) {
151
- media.fileSize = parseInt(elem.attribs.fileSize, 10);
152
- }
153
- if (elem.attribs.type) {
154
- media.type = elem.attribs.type;
155
- }
156
- if (elem.attribs.expression) {
157
- media.expression = elem.attribs
158
- .expression;
159
- }
160
- if (elem.attribs.bitrate) {
161
- media.bitrate = parseInt(elem.attribs.bitrate, 10);
162
- }
163
- if (elem.attribs.framerate) {
164
- media.framerate = parseInt(elem.attribs.framerate, 10);
165
- }
166
- if (elem.attribs.samplingrate) {
167
- media.samplingrate = parseInt(elem.attribs.samplingrate, 10);
168
- }
169
- if (elem.attribs.channels) {
170
- media.channels = parseInt(elem.attribs.channels, 10);
171
- }
172
- if (elem.attribs.duration) {
173
- media.duration = parseInt(elem.attribs.duration, 10);
174
- }
175
- if (elem.attribs.height) {
176
- media.height = parseInt(elem.attribs.height, 10);
177
- }
178
- if (elem.attribs.width) {
179
- media.width = parseInt(elem.attribs.width, 10);
180
- }
181
- if (elem.attribs.lang) {
182
- media.lang = elem.attribs.lang;
183
- }
184
- return media;
185
- });
186
- }
187
- function getElements(tagName, where) {
188
- return DomUtils.getElementsByTagName(tagName, where, true);
189
- }
190
- function getOneElement(tagName, node) {
191
- return DomUtils.getElementsByTagName(tagName, node, true, 1)[0];
192
- }
193
- function fetch(tagName, where, recurse = false) {
194
- return DomUtils.getText(DomUtils.getElementsByTagName(tagName, where, recurse, 1)).trim();
195
- }
196
- function getAttribute(name, elem) {
197
- if (!elem) {
198
- return null;
199
- }
200
- const { attribs } = elem;
201
- return attribs[name];
202
- }
203
- function addConditionally(obj, prop, what, where, recurse = false) {
204
- const tmp = fetch(what, where, recurse);
205
- if (tmp)
206
- obj[prop] = tmp;
207
- }
208
- function isValidFeed(value) {
209
- return value === 'rss' || value === 'feed' || value === 'rdf:RDF';
210
- }
211
- /**
212
- * Parse a feed.
213
- *
214
- * @param feed The feed that should be parsed, as a string.
215
- * @param options Optionally, options for parsing. When using this option, you should set `xmlMode` to `true`.
216
- */
217
- function parseFeed(feed, options = { xmlMode: true }) {
218
- const handler = new FeedHandler(options);
219
- new Parser_js_1.Parser(handler, options).end(feed);
220
- return handler.feed;
221
- }
222
- exports.parseFeed = parseFeed;