@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,168 +0,0 @@
|
|
|
1
|
-
import { ElementType } from './ElementType.js';
|
|
2
|
-
/**
|
|
3
|
-
* This object will be used as the prototype for Nodes when creating a
|
|
4
|
-
* DOM-Level-1-compliant structure.
|
|
5
|
-
*/
|
|
6
|
-
export declare class Node {
|
|
7
|
-
type: ElementType;
|
|
8
|
-
/** Parent of the node */
|
|
9
|
-
parent: NodeWithChildren | null;
|
|
10
|
-
/** Previous sibling */
|
|
11
|
-
prev: Node | null;
|
|
12
|
-
/** Next sibling */
|
|
13
|
-
next: Node | null;
|
|
14
|
-
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
|
|
15
|
-
startIndex: number | null;
|
|
16
|
-
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
|
|
17
|
-
endIndex: number | null;
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* @param type The type of the node.
|
|
21
|
-
*/
|
|
22
|
-
constructor(type: ElementType);
|
|
23
|
-
get nodeType(): number;
|
|
24
|
-
get parentNode(): NodeWithChildren | null;
|
|
25
|
-
set parentNode(parent: NodeWithChildren | null);
|
|
26
|
-
get previousSibling(): Node | null;
|
|
27
|
-
set previousSibling(prev: Node | null);
|
|
28
|
-
get nextSibling(): Node | null;
|
|
29
|
-
set nextSibling(next: Node | null);
|
|
30
|
-
/**
|
|
31
|
-
* Clone this node, and optionally its children.
|
|
32
|
-
*
|
|
33
|
-
* @param recursive Clone child nodes as well.
|
|
34
|
-
* @returns A clone of the node.
|
|
35
|
-
*/
|
|
36
|
-
cloneNode<T extends Node>(this: T, recursive?: boolean): T;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* A node that contains some data.
|
|
40
|
-
*/
|
|
41
|
-
export declare class DataNode extends Node {
|
|
42
|
-
data: string;
|
|
43
|
-
/**
|
|
44
|
-
* @param type The type of the node
|
|
45
|
-
* @param data The content of the data node
|
|
46
|
-
*/
|
|
47
|
-
constructor(type: ElementType.Comment | ElementType.Text | ElementType.Directive, data: string);
|
|
48
|
-
get nodeValue(): string;
|
|
49
|
-
set nodeValue(data: string);
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Text within the document.
|
|
53
|
-
*/
|
|
54
|
-
export declare class Text extends DataNode {
|
|
55
|
-
constructor(data: string);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Comments within the document.
|
|
59
|
-
*/
|
|
60
|
-
export declare class Comment extends DataNode {
|
|
61
|
-
constructor(data: string);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Processing instructions, including doc types.
|
|
65
|
-
*/
|
|
66
|
-
export declare class ProcessingInstruction extends DataNode {
|
|
67
|
-
name: string;
|
|
68
|
-
constructor(name: string, data: string);
|
|
69
|
-
'x-name'?: string;
|
|
70
|
-
'x-publicId'?: string;
|
|
71
|
-
'x-systemId'?: string;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* A `Node` that can have children.
|
|
75
|
-
*/
|
|
76
|
-
export declare class NodeWithChildren extends Node {
|
|
77
|
-
children: Node[];
|
|
78
|
-
/**
|
|
79
|
-
* @param type Type of the node.
|
|
80
|
-
* @param children Children of the node. Only certain node types can have children.
|
|
81
|
-
*/
|
|
82
|
-
constructor(type: ElementType.Root | ElementType.CDATA | ElementType.Script | ElementType.Style | ElementType.Tag, children: Node[]);
|
|
83
|
-
get firstChild(): Node | null;
|
|
84
|
-
get lastChild(): Node | null;
|
|
85
|
-
get childNodes(): Node[];
|
|
86
|
-
set childNodes(children: Node[]);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* The root node of the document.
|
|
90
|
-
*/
|
|
91
|
-
export declare class Document extends NodeWithChildren {
|
|
92
|
-
constructor(children: Node[]);
|
|
93
|
-
'x-mode'?: 'no-quirks' | 'quirks' | 'limited-quirks';
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* The description of an individual attribute.
|
|
97
|
-
*/
|
|
98
|
-
interface Attribute {
|
|
99
|
-
name: string;
|
|
100
|
-
value: string;
|
|
101
|
-
namespace?: string;
|
|
102
|
-
prefix?: string;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* An element within the DOM.
|
|
106
|
-
*/
|
|
107
|
-
export declare class Element extends NodeWithChildren {
|
|
108
|
-
name: string;
|
|
109
|
-
attribs: {
|
|
110
|
-
[name: string]: string;
|
|
111
|
-
};
|
|
112
|
-
/**
|
|
113
|
-
* @param name Name of the tag, eg. `div`, `span`.
|
|
114
|
-
* @param attribs Object mapping attribute names to attribute values.
|
|
115
|
-
* @param children Children of the node.
|
|
116
|
-
*/
|
|
117
|
-
constructor(name: string, attribs: {
|
|
118
|
-
[name: string]: string;
|
|
119
|
-
}, children?: Node[], type?: ElementType.Tag | ElementType.Script | ElementType.Style);
|
|
120
|
-
get tagName(): string;
|
|
121
|
-
set tagName(name: string);
|
|
122
|
-
get attributes(): Attribute[];
|
|
123
|
-
'x-attribsNamespace'?: Record<string, string>;
|
|
124
|
-
'x-attribsPrefix'?: Record<string, string>;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* @param node Node to check.
|
|
128
|
-
* @returns `true` if the node is a `Element`, `false` otherwise.
|
|
129
|
-
*/
|
|
130
|
-
export declare function isTag(node: Node): node is Element;
|
|
131
|
-
/**
|
|
132
|
-
* @param node Node to check.
|
|
133
|
-
* @returns `true` if the node has the type `CDATA`, `false` otherwise.
|
|
134
|
-
*/
|
|
135
|
-
export declare function isCDATA(node: Node): node is NodeWithChildren;
|
|
136
|
-
/**
|
|
137
|
-
* @param node Node to check.
|
|
138
|
-
* @returns `true` if the node has the type `Text`, `false` otherwise.
|
|
139
|
-
*/
|
|
140
|
-
export declare function isText(node: Node): node is Text;
|
|
141
|
-
/**
|
|
142
|
-
* @param node Node to check.
|
|
143
|
-
* @returns `true` if the node has the type `Comment`, `false` otherwise.
|
|
144
|
-
*/
|
|
145
|
-
export declare function isComment(node: Node): node is DataNode;
|
|
146
|
-
/**
|
|
147
|
-
* @param node Node to check.
|
|
148
|
-
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
|
149
|
-
*/
|
|
150
|
-
export declare function isDirective(node: Node): node is ProcessingInstruction;
|
|
151
|
-
/**
|
|
152
|
-
* @param node Node to check.
|
|
153
|
-
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
|
154
|
-
*/
|
|
155
|
-
export declare function isDocument(node: Node): node is Document;
|
|
156
|
-
/**
|
|
157
|
-
* @param node Node to check.
|
|
158
|
-
* @returns `true` if the node is a `NodeWithChildren` (has children), `false` otherwise.
|
|
159
|
-
*/
|
|
160
|
-
export declare function hasChildren(node: Node): node is NodeWithChildren;
|
|
161
|
-
/**
|
|
162
|
-
* Clone a node, and optionally its children.
|
|
163
|
-
*
|
|
164
|
-
* @param recursive Clone child nodes as well.
|
|
165
|
-
* @returns A clone of the node.
|
|
166
|
-
*/
|
|
167
|
-
export declare function cloneNode<T extends Node>(node: T, recursive?: boolean): T;
|
|
168
|
-
export {};
|
|
@@ -1,385 +0,0 @@
|
|
|
1
|
-
import { ElementType, isTag as isTagRaw } from './ElementType.js';
|
|
2
|
-
const nodeTypes = new Map([
|
|
3
|
-
[ElementType.Tag, 1],
|
|
4
|
-
[ElementType.Script, 1],
|
|
5
|
-
[ElementType.Style, 1],
|
|
6
|
-
[ElementType.Directive, 1],
|
|
7
|
-
[ElementType.Text, 3],
|
|
8
|
-
[ElementType.CDATA, 4],
|
|
9
|
-
[ElementType.Comment, 8],
|
|
10
|
-
[ElementType.Root, 9],
|
|
11
|
-
]);
|
|
12
|
-
/**
|
|
13
|
-
* This object will be used as the prototype for Nodes when creating a
|
|
14
|
-
* DOM-Level-1-compliant structure.
|
|
15
|
-
*/
|
|
16
|
-
export class Node {
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
* @param type The type of the node.
|
|
20
|
-
*/
|
|
21
|
-
constructor(type) {
|
|
22
|
-
Object.defineProperty(this, "type", {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
configurable: true,
|
|
25
|
-
writable: true,
|
|
26
|
-
value: type
|
|
27
|
-
});
|
|
28
|
-
/** Parent of the node */
|
|
29
|
-
Object.defineProperty(this, "parent", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
configurable: true,
|
|
32
|
-
writable: true,
|
|
33
|
-
value: null
|
|
34
|
-
});
|
|
35
|
-
/** Previous sibling */
|
|
36
|
-
Object.defineProperty(this, "prev", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
configurable: true,
|
|
39
|
-
writable: true,
|
|
40
|
-
value: null
|
|
41
|
-
});
|
|
42
|
-
/** Next sibling */
|
|
43
|
-
Object.defineProperty(this, "next", {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
configurable: true,
|
|
46
|
-
writable: true,
|
|
47
|
-
value: null
|
|
48
|
-
});
|
|
49
|
-
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
|
|
50
|
-
Object.defineProperty(this, "startIndex", {
|
|
51
|
-
enumerable: true,
|
|
52
|
-
configurable: true,
|
|
53
|
-
writable: true,
|
|
54
|
-
value: null
|
|
55
|
-
});
|
|
56
|
-
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
|
|
57
|
-
Object.defineProperty(this, "endIndex", {
|
|
58
|
-
enumerable: true,
|
|
59
|
-
configurable: true,
|
|
60
|
-
writable: true,
|
|
61
|
-
value: null
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
// Read-only aliases
|
|
65
|
-
get nodeType() {
|
|
66
|
-
return nodeTypes.get(this.type) ?? 1;
|
|
67
|
-
}
|
|
68
|
-
// Read-write aliases for properties
|
|
69
|
-
get parentNode() {
|
|
70
|
-
return this.parent;
|
|
71
|
-
}
|
|
72
|
-
set parentNode(parent) {
|
|
73
|
-
this.parent = parent;
|
|
74
|
-
}
|
|
75
|
-
get previousSibling() {
|
|
76
|
-
return this.prev;
|
|
77
|
-
}
|
|
78
|
-
set previousSibling(prev) {
|
|
79
|
-
this.prev = prev;
|
|
80
|
-
}
|
|
81
|
-
get nextSibling() {
|
|
82
|
-
return this.next;
|
|
83
|
-
}
|
|
84
|
-
set nextSibling(next) {
|
|
85
|
-
this.next = next;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Clone this node, and optionally its children.
|
|
89
|
-
*
|
|
90
|
-
* @param recursive Clone child nodes as well.
|
|
91
|
-
* @returns A clone of the node.
|
|
92
|
-
*/
|
|
93
|
-
cloneNode(recursive = false) {
|
|
94
|
-
return cloneNode(this, recursive);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* A node that contains some data.
|
|
99
|
-
*/
|
|
100
|
-
export class DataNode extends Node {
|
|
101
|
-
/**
|
|
102
|
-
* @param type The type of the node
|
|
103
|
-
* @param data The content of the data node
|
|
104
|
-
*/
|
|
105
|
-
constructor(type, data) {
|
|
106
|
-
super(type);
|
|
107
|
-
Object.defineProperty(this, "data", {
|
|
108
|
-
enumerable: true,
|
|
109
|
-
configurable: true,
|
|
110
|
-
writable: true,
|
|
111
|
-
value: data
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
get nodeValue() {
|
|
115
|
-
return this.data;
|
|
116
|
-
}
|
|
117
|
-
set nodeValue(data) {
|
|
118
|
-
this.data = data;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Text within the document.
|
|
123
|
-
*/
|
|
124
|
-
export class Text extends DataNode {
|
|
125
|
-
constructor(data) {
|
|
126
|
-
super(ElementType.Text, data);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Comments within the document.
|
|
131
|
-
*/
|
|
132
|
-
export class Comment extends DataNode {
|
|
133
|
-
constructor(data) {
|
|
134
|
-
super(ElementType.Comment, data);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Processing instructions, including doc types.
|
|
139
|
-
*/
|
|
140
|
-
export class ProcessingInstruction extends DataNode {
|
|
141
|
-
constructor(name, data) {
|
|
142
|
-
super(ElementType.Directive, data);
|
|
143
|
-
Object.defineProperty(this, "name", {
|
|
144
|
-
enumerable: true,
|
|
145
|
-
configurable: true,
|
|
146
|
-
writable: true,
|
|
147
|
-
value: name
|
|
148
|
-
});
|
|
149
|
-
Object.defineProperty(this, 'x-name', {
|
|
150
|
-
enumerable: true,
|
|
151
|
-
configurable: true,
|
|
152
|
-
writable: true,
|
|
153
|
-
value: void 0
|
|
154
|
-
});
|
|
155
|
-
Object.defineProperty(this, 'x-publicId', {
|
|
156
|
-
enumerable: true,
|
|
157
|
-
configurable: true,
|
|
158
|
-
writable: true,
|
|
159
|
-
value: void 0
|
|
160
|
-
});
|
|
161
|
-
Object.defineProperty(this, 'x-systemId', {
|
|
162
|
-
enumerable: true,
|
|
163
|
-
configurable: true,
|
|
164
|
-
writable: true,
|
|
165
|
-
value: void 0
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* A `Node` that can have children.
|
|
171
|
-
*/
|
|
172
|
-
export class NodeWithChildren extends Node {
|
|
173
|
-
/**
|
|
174
|
-
* @param type Type of the node.
|
|
175
|
-
* @param children Children of the node. Only certain node types can have children.
|
|
176
|
-
*/
|
|
177
|
-
constructor(type, children) {
|
|
178
|
-
super(type);
|
|
179
|
-
Object.defineProperty(this, "children", {
|
|
180
|
-
enumerable: true,
|
|
181
|
-
configurable: true,
|
|
182
|
-
writable: true,
|
|
183
|
-
value: children
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
// Aliases
|
|
187
|
-
get firstChild() {
|
|
188
|
-
return this.children[0] ?? null;
|
|
189
|
-
}
|
|
190
|
-
get lastChild() {
|
|
191
|
-
return this.children.length > 0
|
|
192
|
-
? this.children[this.children.length - 1]
|
|
193
|
-
: null;
|
|
194
|
-
}
|
|
195
|
-
get childNodes() {
|
|
196
|
-
return this.children;
|
|
197
|
-
}
|
|
198
|
-
set childNodes(children) {
|
|
199
|
-
this.children = children;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* The root node of the document.
|
|
204
|
-
*/
|
|
205
|
-
export class Document extends NodeWithChildren {
|
|
206
|
-
constructor(children) {
|
|
207
|
-
super(ElementType.Root, children);
|
|
208
|
-
Object.defineProperty(this, 'x-mode', {
|
|
209
|
-
enumerable: true,
|
|
210
|
-
configurable: true,
|
|
211
|
-
writable: true,
|
|
212
|
-
value: void 0
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* An element within the DOM.
|
|
218
|
-
*/
|
|
219
|
-
export class Element extends NodeWithChildren {
|
|
220
|
-
/**
|
|
221
|
-
* @param name Name of the tag, eg. `div`, `span`.
|
|
222
|
-
* @param attribs Object mapping attribute names to attribute values.
|
|
223
|
-
* @param children Children of the node.
|
|
224
|
-
*/
|
|
225
|
-
constructor(name, attribs, children = [], type = name === 'script'
|
|
226
|
-
? ElementType.Script
|
|
227
|
-
: name === 'style'
|
|
228
|
-
? ElementType.Style
|
|
229
|
-
: ElementType.Tag) {
|
|
230
|
-
super(type, children);
|
|
231
|
-
Object.defineProperty(this, "name", {
|
|
232
|
-
enumerable: true,
|
|
233
|
-
configurable: true,
|
|
234
|
-
writable: true,
|
|
235
|
-
value: name
|
|
236
|
-
});
|
|
237
|
-
Object.defineProperty(this, "attribs", {
|
|
238
|
-
enumerable: true,
|
|
239
|
-
configurable: true,
|
|
240
|
-
writable: true,
|
|
241
|
-
value: attribs
|
|
242
|
-
});
|
|
243
|
-
Object.defineProperty(this, 'x-attribsNamespace', {
|
|
244
|
-
enumerable: true,
|
|
245
|
-
configurable: true,
|
|
246
|
-
writable: true,
|
|
247
|
-
value: void 0
|
|
248
|
-
});
|
|
249
|
-
Object.defineProperty(this, 'x-attribsPrefix', {
|
|
250
|
-
enumerable: true,
|
|
251
|
-
configurable: true,
|
|
252
|
-
writable: true,
|
|
253
|
-
value: void 0
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
// DOM Level 1 aliases
|
|
257
|
-
get tagName() {
|
|
258
|
-
return this.name;
|
|
259
|
-
}
|
|
260
|
-
set tagName(name) {
|
|
261
|
-
this.name = name;
|
|
262
|
-
}
|
|
263
|
-
get attributes() {
|
|
264
|
-
return Object.keys(this.attribs).map(name => ({
|
|
265
|
-
name,
|
|
266
|
-
value: this.attribs[name],
|
|
267
|
-
namespace: this['x-attribsNamespace']?.[name],
|
|
268
|
-
prefix: this['x-attribsPrefix']?.[name],
|
|
269
|
-
}));
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* @param node Node to check.
|
|
274
|
-
* @returns `true` if the node is a `Element`, `false` otherwise.
|
|
275
|
-
*/
|
|
276
|
-
export function isTag(node) {
|
|
277
|
-
return isTagRaw(node);
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* @param node Node to check.
|
|
281
|
-
* @returns `true` if the node has the type `CDATA`, `false` otherwise.
|
|
282
|
-
*/
|
|
283
|
-
export function isCDATA(node) {
|
|
284
|
-
return node.type === ElementType.CDATA;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* @param node Node to check.
|
|
288
|
-
* @returns `true` if the node has the type `Text`, `false` otherwise.
|
|
289
|
-
*/
|
|
290
|
-
export function isText(node) {
|
|
291
|
-
return node.type === ElementType.Text;
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* @param node Node to check.
|
|
295
|
-
* @returns `true` if the node has the type `Comment`, `false` otherwise.
|
|
296
|
-
*/
|
|
297
|
-
export function isComment(node) {
|
|
298
|
-
return node.type === ElementType.Comment;
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* @param node Node to check.
|
|
302
|
-
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
|
303
|
-
*/
|
|
304
|
-
export function isDirective(node) {
|
|
305
|
-
return node.type === ElementType.Directive;
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* @param node Node to check.
|
|
309
|
-
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
|
310
|
-
*/
|
|
311
|
-
export function isDocument(node) {
|
|
312
|
-
return node.type === ElementType.Root;
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* @param node Node to check.
|
|
316
|
-
* @returns `true` if the node is a `NodeWithChildren` (has children), `false` otherwise.
|
|
317
|
-
*/
|
|
318
|
-
export function hasChildren(node) {
|
|
319
|
-
return Object.prototype.hasOwnProperty.call(node, 'children');
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* Clone a node, and optionally its children.
|
|
323
|
-
*
|
|
324
|
-
* @param recursive Clone child nodes as well.
|
|
325
|
-
* @returns A clone of the node.
|
|
326
|
-
*/
|
|
327
|
-
export function cloneNode(node, recursive = false) {
|
|
328
|
-
let result;
|
|
329
|
-
if (isText(node)) {
|
|
330
|
-
result = new Text(node.data);
|
|
331
|
-
}
|
|
332
|
-
else if (isComment(node)) {
|
|
333
|
-
result = new Comment(node.data);
|
|
334
|
-
}
|
|
335
|
-
else if (isTag(node)) {
|
|
336
|
-
const children = recursive ? cloneChildren(node.children) : [];
|
|
337
|
-
const clone = new Element(node.name, { ...node.attribs }, children);
|
|
338
|
-
children.forEach(child => (child.parent = clone));
|
|
339
|
-
if (node['x-attribsNamespace']) {
|
|
340
|
-
clone['x-attribsNamespace'] = { ...node['x-attribsNamespace'] };
|
|
341
|
-
}
|
|
342
|
-
if (node['x-attribsPrefix']) {
|
|
343
|
-
clone['x-attribsPrefix'] = { ...node['x-attribsPrefix'] };
|
|
344
|
-
}
|
|
345
|
-
result = clone;
|
|
346
|
-
}
|
|
347
|
-
else if (isCDATA(node)) {
|
|
348
|
-
const children = recursive ? cloneChildren(node.children) : [];
|
|
349
|
-
const clone = new NodeWithChildren(ElementType.CDATA, children);
|
|
350
|
-
children.forEach(child => (child.parent = clone));
|
|
351
|
-
result = clone;
|
|
352
|
-
}
|
|
353
|
-
else if (isDocument(node)) {
|
|
354
|
-
const children = recursive ? cloneChildren(node.children) : [];
|
|
355
|
-
const clone = new Document(children);
|
|
356
|
-
children.forEach(child => (child.parent = clone));
|
|
357
|
-
if (node['x-mode']) {
|
|
358
|
-
clone['x-mode'] = node['x-mode'];
|
|
359
|
-
}
|
|
360
|
-
result = clone;
|
|
361
|
-
}
|
|
362
|
-
else if (isDirective(node)) {
|
|
363
|
-
const instruction = new ProcessingInstruction(node.name, node.data);
|
|
364
|
-
if (node['x-name'] != null) {
|
|
365
|
-
instruction['x-name'] = node['x-name'];
|
|
366
|
-
instruction['x-publicId'] = node['x-publicId'];
|
|
367
|
-
instruction['x-systemId'] = node['x-systemId'];
|
|
368
|
-
}
|
|
369
|
-
result = instruction;
|
|
370
|
-
}
|
|
371
|
-
else {
|
|
372
|
-
throw new Error(`Not implemented yet: ${node.type}`);
|
|
373
|
-
}
|
|
374
|
-
result.startIndex = node.startIndex;
|
|
375
|
-
result.endIndex = node.endIndex;
|
|
376
|
-
return result;
|
|
377
|
-
}
|
|
378
|
-
function cloneChildren(childs) {
|
|
379
|
-
const children = childs.map(child => cloneNode(child, true));
|
|
380
|
-
for (let i = 1; i < children.length; i++) {
|
|
381
|
-
children[i].prev = children[i - 1];
|
|
382
|
-
children[i - 1].next = children[i];
|
|
383
|
-
}
|
|
384
|
-
return children;
|
|
385
|
-
}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import Tokenizer from './Tokenizer.js';
|
|
2
|
-
export interface ParserOptions {
|
|
3
|
-
/**
|
|
4
|
-
* Indicates whether special tags (`<script>`, `<style>`, and `<title>`) should get special treatment
|
|
5
|
-
* and if "empty" tags (eg. `<br>`) can have children. If `false`, the content of special tags
|
|
6
|
-
* will be text only. For feeds and other XML content (documents that don't consist of HTML),
|
|
7
|
-
* set this to `true`.
|
|
8
|
-
*
|
|
9
|
-
* @default false
|
|
10
|
-
*/
|
|
11
|
-
xmlMode?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Decode entities within the document.
|
|
14
|
-
*
|
|
15
|
-
* @default true
|
|
16
|
-
*/
|
|
17
|
-
decodeEntities?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* If set to true, all tags will be lowercased.
|
|
20
|
-
*
|
|
21
|
-
* @default !xmlMode
|
|
22
|
-
*/
|
|
23
|
-
lowerCaseTags?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* If set to `true`, all attribute names will be lowercased. This has noticeable impact on speed.
|
|
26
|
-
*
|
|
27
|
-
* @default !xmlMode
|
|
28
|
-
*/
|
|
29
|
-
lowerCaseAttributeNames?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* If set to true, CDATA sections will be recognized as text even if the xmlMode option is not enabled.
|
|
32
|
-
* NOTE: If xmlMode is set to `true` then CDATA sections will always be recognized as text.
|
|
33
|
-
*
|
|
34
|
-
* @default xmlMode
|
|
35
|
-
*/
|
|
36
|
-
recognizeCDATA?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* If set to `true`, self-closing tags will trigger the onclosetag event even if xmlMode is not set to `true`.
|
|
39
|
-
* NOTE: If xmlMode is set to `true` then self-closing tags will always be recognized.
|
|
40
|
-
*
|
|
41
|
-
* @default xmlMode
|
|
42
|
-
*/
|
|
43
|
-
recognizeSelfClosing?: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Allows the default tokenizer to be overwritten.
|
|
46
|
-
*/
|
|
47
|
-
Tokenizer?: typeof Tokenizer;
|
|
48
|
-
}
|
|
49
|
-
export interface Handler {
|
|
50
|
-
onparserinit(parser: Parser): void;
|
|
51
|
-
/**
|
|
52
|
-
* Resets the handler back to starting state
|
|
53
|
-
*/
|
|
54
|
-
onreset(): void;
|
|
55
|
-
/**
|
|
56
|
-
* Signals the handler that parsing is done
|
|
57
|
-
*/
|
|
58
|
-
onend(): void;
|
|
59
|
-
onerror(error: Error): void;
|
|
60
|
-
onclosetag(name: string): void;
|
|
61
|
-
onopentagname(name: string): void;
|
|
62
|
-
/**
|
|
63
|
-
*
|
|
64
|
-
* @param name Name of the attribute
|
|
65
|
-
* @param value Value of the attribute.
|
|
66
|
-
* @param quote Quotes used around the attribute. `null` if the attribute has no quotes around the value, `undefined` if the attribute has no value.
|
|
67
|
-
*/
|
|
68
|
-
onattribute(name: string, value: string, quote?: string | undefined | null): void;
|
|
69
|
-
onopentag(name: string, attribs: {
|
|
70
|
-
[s: string]: string;
|
|
71
|
-
}): void;
|
|
72
|
-
ontext(data: string): void;
|
|
73
|
-
oncomment(data: string): void;
|
|
74
|
-
oncdatastart(): void;
|
|
75
|
-
oncdataend(): void;
|
|
76
|
-
oncommentend(): void;
|
|
77
|
-
onprocessinginstruction(name: string, data: string): void;
|
|
78
|
-
}
|
|
79
|
-
export declare class Parser {
|
|
80
|
-
/** The start index of the last event. */
|
|
81
|
-
startIndex: number;
|
|
82
|
-
/** The end index of the last event. */
|
|
83
|
-
endIndex: number | null;
|
|
84
|
-
private tagname;
|
|
85
|
-
private attribname;
|
|
86
|
-
private attribvalue;
|
|
87
|
-
private attribs;
|
|
88
|
-
private stack;
|
|
89
|
-
private readonly foreignContext;
|
|
90
|
-
private readonly cbs;
|
|
91
|
-
private readonly options;
|
|
92
|
-
private readonly lowerCaseTagNames;
|
|
93
|
-
private readonly lowerCaseAttributeNames;
|
|
94
|
-
private readonly tokenizer;
|
|
95
|
-
constructor(cbs: Partial<Handler> | null, options?: ParserOptions);
|
|
96
|
-
private updatePosition;
|
|
97
|
-
ontext(data: string): void;
|
|
98
|
-
isVoidElement(name: string): boolean;
|
|
99
|
-
onopentagname(name: string): void;
|
|
100
|
-
onopentagend(): void;
|
|
101
|
-
onclosetag(name: string): void;
|
|
102
|
-
onselfclosingtag(): void;
|
|
103
|
-
private closeCurrentTag;
|
|
104
|
-
onattribname(name: string): void;
|
|
105
|
-
onattribdata(value: string): void;
|
|
106
|
-
onattribend(quote: string | undefined | null): void;
|
|
107
|
-
private getInstructionName;
|
|
108
|
-
ondeclaration(value: string): void;
|
|
109
|
-
onprocessinginstruction(value: string): void;
|
|
110
|
-
oncomment(value: string): void;
|
|
111
|
-
oncdata(value: string): void;
|
|
112
|
-
onerror(err: Error): void;
|
|
113
|
-
onend(): void;
|
|
114
|
-
/**
|
|
115
|
-
* Resets the parser to a blank state, ready to parse a new HTML document
|
|
116
|
-
*/
|
|
117
|
-
reset(): void;
|
|
118
|
-
/**
|
|
119
|
-
* Resets the parser, then parses a complete document and
|
|
120
|
-
* pushes it to the handler.
|
|
121
|
-
*
|
|
122
|
-
* @param data Document to parse.
|
|
123
|
-
*/
|
|
124
|
-
parseComplete(data: string): void;
|
|
125
|
-
/**
|
|
126
|
-
* Parses a chunk of data and calls the corresponding callbacks.
|
|
127
|
-
*
|
|
128
|
-
* @param chunk Chunk to parse.
|
|
129
|
-
*/
|
|
130
|
-
write(chunk: string): void;
|
|
131
|
-
/**
|
|
132
|
-
* Parses the end of the buffer and clears the stack, calls onend.
|
|
133
|
-
*
|
|
134
|
-
* @param chunk Optional final chunk to parse.
|
|
135
|
-
*/
|
|
136
|
-
end(chunk?: string): void;
|
|
137
|
-
/**
|
|
138
|
-
* Pauses parsing. The parser won't emit events until `resume` is called.
|
|
139
|
-
*/
|
|
140
|
-
pause(): void;
|
|
141
|
-
/**
|
|
142
|
-
* Resumes parsing after `pause` was called.
|
|
143
|
-
*/
|
|
144
|
-
resume(): void;
|
|
145
|
-
/**
|
|
146
|
-
* Alias of `write`, for backwards compatibility.
|
|
147
|
-
*
|
|
148
|
-
* @param chunk Chunk to parse.
|
|
149
|
-
* @deprecated
|
|
150
|
-
*/
|
|
151
|
-
parseChunk(chunk: string): void;
|
|
152
|
-
/**
|
|
153
|
-
* Alias of `end`, for backwards compatibility.
|
|
154
|
-
*
|
|
155
|
-
* @param chunk Optional final chunk to parse.
|
|
156
|
-
* @deprecated
|
|
157
|
-
*/
|
|
158
|
-
done(chunk?: string): void;
|
|
159
|
-
}
|