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