@mtkruto/node 0.1.200 → 0.1.300
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/0_deps.d.ts +1 -1
- package/esm/0_deps.js +2 -1
- package/esm/1_utilities.d.ts +1 -1
- package/esm/1_utilities.js +1 -1
- package/esm/4_errors.js +3 -3
- package/esm/client/0_markdown.js +5 -5
- package/esm/client/0_utilities.d.ts +6 -0
- package/esm/client/0_utilities.js +35 -4
- package/esm/client/1_account_manager.js +4 -4
- package/esm/client/1_client_encrypted.js +4 -4
- package/esm/client/1_client_plain.js +3 -3
- package/esm/client/1_file_manager.js +6 -5
- package/esm/client/1_reaction_manager.js +2 -2
- package/esm/client/1_update_manager.js +9 -8
- package/esm/client/2_message_manager.js +47 -24
- package/esm/client/3_callback_query_manager.js +2 -0
- package/esm/client/3_chat_list_manager.js +13 -12
- package/esm/client/3_inline_query_manager.js +4 -2
- package/esm/client/3_story_manager.js +7 -5
- package/esm/client/4_client.d.ts +5 -8
- package/esm/client/4_client.js +19 -27
- package/esm/connection/1_connection_web_socket.js +3 -2
- package/{script/deps/deno.land/x/tgcrypto@0.3.3 → esm/deps/deno.land/x/tgcrypto@0.4.0}/mod.d.ts +0 -1
- package/esm/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/mod.js +0 -11
- package/esm/deps/deno.land/x/tgcrypto@0.4.0/tgcrypto.js +308 -0
- package/esm/mod.d.ts +1 -1
- package/esm/mod.js +1 -1
- package/esm/storage/0_storage.js +6 -5
- package/esm/storage/1_utilities.d.ts +0 -1
- package/esm/storage/1_utilities.js +2 -3
- package/esm/storage/2_storage_local_storage.js +1 -4
- package/esm/storage/2_storage_session_storage.js +1 -4
- package/esm/tl/3_utilities.js +5 -4
- package/esm/transport/2_transport_provider.js +4 -4
- package/esm/types/0_message_entity.js +3 -3
- package/esm/types/0_message_search_filter.js +2 -2
- package/esm/types/0_reaction.js +2 -2
- package/esm/types/1_bot_command_scope.js +3 -3
- package/esm/types/1_chat_p.js +3 -2
- package/esm/types/1_keyboard_button.js +3 -3
- package/esm/types/1_message_reaction.js +2 -2
- package/esm/types/1_story_privacy.js +3 -3
- package/esm/types/2_chat_member.js +6 -5
- package/esm/types/2_chosen_inline_result.js +3 -2
- package/esm/types/2_inactive_chat.js +3 -2
- package/esm/types/2_inline_keyboard_button.js +3 -3
- package/esm/types/2_inline_query.js +3 -3
- package/esm/types/2_invite_link.js +3 -2
- package/esm/types/2_story_content.js +5 -5
- package/esm/types/2_story_interactive_area.js +5 -5
- package/esm/types/3_chat_member_updated.js +4 -3
- package/esm/types/3_reply_markup.js +4 -3
- package/esm/types/3_story.js +3 -2
- package/esm/types/4_inline_query_result.js +5 -5
- package/esm/types/4_message.js +17 -16
- package/esm/types/5_callback_query.js +4 -3
- package/esm/types/5_chat.js +8 -7
- package/esm/types/_file_id.js +9 -8
- package/esm/utilities/0_bigint.d.ts +1 -0
- package/esm/utilities/0_bigint.js +25 -0
- package/esm/utilities/0_logger.d.ts +8 -0
- package/esm/utilities/0_logger.js +9 -5
- package/esm/utilities/1_math.d.ts +1 -0
- package/esm/utilities/1_math.js +51 -0
- package/esm/utilities/1_misc.js +2 -2
- package/package.json +1 -1
- package/script/0_deps.d.ts +1 -1
- package/script/0_deps.js +3 -3
- package/script/1_utilities.d.ts +1 -1
- package/script/1_utilities.js +1 -1
- package/script/4_errors.js +3 -3
- package/script/client/0_markdown.js +5 -5
- package/script/client/0_utilities.d.ts +6 -0
- package/script/client/0_utilities.js +41 -4
- package/script/client/1_account_manager.js +4 -4
- package/script/client/1_client_encrypted.js +2 -2
- package/script/client/1_client_plain.js +2 -2
- package/script/client/1_file_manager.js +5 -4
- package/script/client/1_reaction_manager.js +2 -2
- package/script/client/1_update_manager.js +8 -7
- package/script/client/2_message_manager.js +51 -28
- package/script/client/3_callback_query_manager.js +2 -0
- package/script/client/3_chat_list_manager.js +12 -11
- package/script/client/3_inline_query_manager.js +4 -2
- package/script/client/3_story_manager.js +4 -2
- package/script/client/4_client.d.ts +5 -8
- package/script/client/4_client.js +18 -26
- package/script/connection/1_connection_web_socket.js +2 -1
- package/{esm/deps/deno.land/x/tgcrypto@0.3.3 → script/deps/deno.land/x/tgcrypto@0.4.0}/mod.d.ts +0 -1
- package/script/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/mod.js +1 -13
- package/script/deps/deno.land/x/tgcrypto@0.4.0/tgcrypto.js +310 -0
- package/script/mod.d.ts +1 -1
- package/script/mod.js +2 -1
- package/script/storage/0_storage.js +5 -4
- package/script/storage/1_utilities.d.ts +0 -1
- package/script/storage/1_utilities.js +3 -4
- package/script/storage/2_storage_local_storage.js +0 -3
- package/script/storage/2_storage_session_storage.js +0 -3
- package/script/tl/3_utilities.js +4 -3
- package/script/transport/2_transport_provider.js +4 -4
- package/script/types/0_message_entity.js +3 -3
- package/script/types/0_message_search_filter.js +2 -2
- package/script/types/0_reaction.js +2 -2
- package/script/types/1_bot_command_scope.js +3 -3
- package/script/types/1_chat_p.js +2 -1
- package/script/types/1_keyboard_button.js +3 -3
- package/script/types/1_message_reaction.js +2 -2
- package/script/types/1_story_privacy.js +3 -3
- package/script/types/2_chat_member.js +5 -4
- package/script/types/2_chosen_inline_result.js +2 -1
- package/script/types/2_inactive_chat.js +2 -1
- package/script/types/2_inline_keyboard_button.js +3 -3
- package/script/types/2_inline_query.js +3 -3
- package/script/types/2_invite_link.js +2 -1
- package/script/types/2_story_content.js +5 -5
- package/script/types/2_story_interactive_area.js +5 -5
- package/script/types/3_chat_member_updated.js +3 -2
- package/script/types/3_reply_markup.js +3 -2
- package/script/types/3_story.js +2 -1
- package/script/types/4_inline_query_result.js +5 -5
- package/script/types/4_message.js +16 -15
- package/script/types/5_callback_query.js +3 -2
- package/script/types/5_chat.js +7 -6
- package/script/types/_file_id.js +8 -7
- package/script/utilities/0_bigint.d.ts +1 -0
- package/script/utilities/0_bigint.js +27 -1
- package/script/utilities/0_logger.d.ts +8 -0
- package/script/utilities/0_logger.js +11 -6
- package/script/utilities/1_math.d.ts +1 -0
- package/script/utilities/1_math.js +55 -0
- package/script/utilities/1_misc.js +2 -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/esm/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +0 -324
- package/esm/utilities/0_control.d.ts +0 -1
- package/esm/utilities/0_control.js +0 -3
- 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/script/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +0 -326
- package/script/utilities/0_control.d.ts +0 -1
- package/script/utilities/0_control.js +0 -7
- /package/esm/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/tgcrypto.d.ts +0 -0
- /package/script/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/tgcrypto.d.ts +0 -0
|
@@ -1,404 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cloneNode = exports.hasChildren = exports.isDocument = exports.isDirective = exports.isComment = exports.isText = exports.isCDATA = exports.isTag = exports.Element = exports.Document = exports.NodeWithChildren = exports.ProcessingInstruction = exports.Comment = exports.Text = exports.DataNode = exports.Node = void 0;
|
|
4
|
-
const ElementType_js_1 = require("./ElementType.js");
|
|
5
|
-
const nodeTypes = new Map([
|
|
6
|
-
[ElementType_js_1.ElementType.Tag, 1],
|
|
7
|
-
[ElementType_js_1.ElementType.Script, 1],
|
|
8
|
-
[ElementType_js_1.ElementType.Style, 1],
|
|
9
|
-
[ElementType_js_1.ElementType.Directive, 1],
|
|
10
|
-
[ElementType_js_1.ElementType.Text, 3],
|
|
11
|
-
[ElementType_js_1.ElementType.CDATA, 4],
|
|
12
|
-
[ElementType_js_1.ElementType.Comment, 8],
|
|
13
|
-
[ElementType_js_1.ElementType.Root, 9],
|
|
14
|
-
]);
|
|
15
|
-
/**
|
|
16
|
-
* This object will be used as the prototype for Nodes when creating a
|
|
17
|
-
* DOM-Level-1-compliant structure.
|
|
18
|
-
*/
|
|
19
|
-
class Node {
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* @param type The type of the node.
|
|
23
|
-
*/
|
|
24
|
-
constructor(type) {
|
|
25
|
-
Object.defineProperty(this, "type", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
configurable: true,
|
|
28
|
-
writable: true,
|
|
29
|
-
value: type
|
|
30
|
-
});
|
|
31
|
-
/** Parent of the node */
|
|
32
|
-
Object.defineProperty(this, "parent", {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
configurable: true,
|
|
35
|
-
writable: true,
|
|
36
|
-
value: null
|
|
37
|
-
});
|
|
38
|
-
/** Previous sibling */
|
|
39
|
-
Object.defineProperty(this, "prev", {
|
|
40
|
-
enumerable: true,
|
|
41
|
-
configurable: true,
|
|
42
|
-
writable: true,
|
|
43
|
-
value: null
|
|
44
|
-
});
|
|
45
|
-
/** Next sibling */
|
|
46
|
-
Object.defineProperty(this, "next", {
|
|
47
|
-
enumerable: true,
|
|
48
|
-
configurable: true,
|
|
49
|
-
writable: true,
|
|
50
|
-
value: null
|
|
51
|
-
});
|
|
52
|
-
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
|
|
53
|
-
Object.defineProperty(this, "startIndex", {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
configurable: true,
|
|
56
|
-
writable: true,
|
|
57
|
-
value: null
|
|
58
|
-
});
|
|
59
|
-
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
|
|
60
|
-
Object.defineProperty(this, "endIndex", {
|
|
61
|
-
enumerable: true,
|
|
62
|
-
configurable: true,
|
|
63
|
-
writable: true,
|
|
64
|
-
value: null
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
// Read-only aliases
|
|
68
|
-
get nodeType() {
|
|
69
|
-
return nodeTypes.get(this.type) ?? 1;
|
|
70
|
-
}
|
|
71
|
-
// Read-write aliases for properties
|
|
72
|
-
get parentNode() {
|
|
73
|
-
return this.parent;
|
|
74
|
-
}
|
|
75
|
-
set parentNode(parent) {
|
|
76
|
-
this.parent = parent;
|
|
77
|
-
}
|
|
78
|
-
get previousSibling() {
|
|
79
|
-
return this.prev;
|
|
80
|
-
}
|
|
81
|
-
set previousSibling(prev) {
|
|
82
|
-
this.prev = prev;
|
|
83
|
-
}
|
|
84
|
-
get nextSibling() {
|
|
85
|
-
return this.next;
|
|
86
|
-
}
|
|
87
|
-
set nextSibling(next) {
|
|
88
|
-
this.next = next;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Clone this node, and optionally its children.
|
|
92
|
-
*
|
|
93
|
-
* @param recursive Clone child nodes as well.
|
|
94
|
-
* @returns A clone of the node.
|
|
95
|
-
*/
|
|
96
|
-
cloneNode(recursive = false) {
|
|
97
|
-
return cloneNode(this, recursive);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
exports.Node = Node;
|
|
101
|
-
/**
|
|
102
|
-
* A node that contains some data.
|
|
103
|
-
*/
|
|
104
|
-
class DataNode extends Node {
|
|
105
|
-
/**
|
|
106
|
-
* @param type The type of the node
|
|
107
|
-
* @param data The content of the data node
|
|
108
|
-
*/
|
|
109
|
-
constructor(type, data) {
|
|
110
|
-
super(type);
|
|
111
|
-
Object.defineProperty(this, "data", {
|
|
112
|
-
enumerable: true,
|
|
113
|
-
configurable: true,
|
|
114
|
-
writable: true,
|
|
115
|
-
value: data
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
get nodeValue() {
|
|
119
|
-
return this.data;
|
|
120
|
-
}
|
|
121
|
-
set nodeValue(data) {
|
|
122
|
-
this.data = data;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
exports.DataNode = DataNode;
|
|
126
|
-
/**
|
|
127
|
-
* Text within the document.
|
|
128
|
-
*/
|
|
129
|
-
class Text extends DataNode {
|
|
130
|
-
constructor(data) {
|
|
131
|
-
super(ElementType_js_1.ElementType.Text, data);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
exports.Text = Text;
|
|
135
|
-
/**
|
|
136
|
-
* Comments within the document.
|
|
137
|
-
*/
|
|
138
|
-
class Comment extends DataNode {
|
|
139
|
-
constructor(data) {
|
|
140
|
-
super(ElementType_js_1.ElementType.Comment, data);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
exports.Comment = Comment;
|
|
144
|
-
/**
|
|
145
|
-
* Processing instructions, including doc types.
|
|
146
|
-
*/
|
|
147
|
-
class ProcessingInstruction extends DataNode {
|
|
148
|
-
constructor(name, data) {
|
|
149
|
-
super(ElementType_js_1.ElementType.Directive, data);
|
|
150
|
-
Object.defineProperty(this, "name", {
|
|
151
|
-
enumerable: true,
|
|
152
|
-
configurable: true,
|
|
153
|
-
writable: true,
|
|
154
|
-
value: name
|
|
155
|
-
});
|
|
156
|
-
Object.defineProperty(this, 'x-name', {
|
|
157
|
-
enumerable: true,
|
|
158
|
-
configurable: true,
|
|
159
|
-
writable: true,
|
|
160
|
-
value: void 0
|
|
161
|
-
});
|
|
162
|
-
Object.defineProperty(this, 'x-publicId', {
|
|
163
|
-
enumerable: true,
|
|
164
|
-
configurable: true,
|
|
165
|
-
writable: true,
|
|
166
|
-
value: void 0
|
|
167
|
-
});
|
|
168
|
-
Object.defineProperty(this, 'x-systemId', {
|
|
169
|
-
enumerable: true,
|
|
170
|
-
configurable: true,
|
|
171
|
-
writable: true,
|
|
172
|
-
value: void 0
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
exports.ProcessingInstruction = ProcessingInstruction;
|
|
177
|
-
/**
|
|
178
|
-
* A `Node` that can have children.
|
|
179
|
-
*/
|
|
180
|
-
class NodeWithChildren extends Node {
|
|
181
|
-
/**
|
|
182
|
-
* @param type Type of the node.
|
|
183
|
-
* @param children Children of the node. Only certain node types can have children.
|
|
184
|
-
*/
|
|
185
|
-
constructor(type, children) {
|
|
186
|
-
super(type);
|
|
187
|
-
Object.defineProperty(this, "children", {
|
|
188
|
-
enumerable: true,
|
|
189
|
-
configurable: true,
|
|
190
|
-
writable: true,
|
|
191
|
-
value: children
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
// Aliases
|
|
195
|
-
get firstChild() {
|
|
196
|
-
return this.children[0] ?? null;
|
|
197
|
-
}
|
|
198
|
-
get lastChild() {
|
|
199
|
-
return this.children.length > 0
|
|
200
|
-
? this.children[this.children.length - 1]
|
|
201
|
-
: null;
|
|
202
|
-
}
|
|
203
|
-
get childNodes() {
|
|
204
|
-
return this.children;
|
|
205
|
-
}
|
|
206
|
-
set childNodes(children) {
|
|
207
|
-
this.children = children;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
exports.NodeWithChildren = NodeWithChildren;
|
|
211
|
-
/**
|
|
212
|
-
* The root node of the document.
|
|
213
|
-
*/
|
|
214
|
-
class Document extends NodeWithChildren {
|
|
215
|
-
constructor(children) {
|
|
216
|
-
super(ElementType_js_1.ElementType.Root, children);
|
|
217
|
-
Object.defineProperty(this, 'x-mode', {
|
|
218
|
-
enumerable: true,
|
|
219
|
-
configurable: true,
|
|
220
|
-
writable: true,
|
|
221
|
-
value: void 0
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
exports.Document = Document;
|
|
226
|
-
/**
|
|
227
|
-
* An element within the DOM.
|
|
228
|
-
*/
|
|
229
|
-
class Element extends NodeWithChildren {
|
|
230
|
-
/**
|
|
231
|
-
* @param name Name of the tag, eg. `div`, `span`.
|
|
232
|
-
* @param attribs Object mapping attribute names to attribute values.
|
|
233
|
-
* @param children Children of the node.
|
|
234
|
-
*/
|
|
235
|
-
constructor(name, attribs, children = [], type = name === 'script'
|
|
236
|
-
? ElementType_js_1.ElementType.Script
|
|
237
|
-
: name === 'style'
|
|
238
|
-
? ElementType_js_1.ElementType.Style
|
|
239
|
-
: ElementType_js_1.ElementType.Tag) {
|
|
240
|
-
super(type, children);
|
|
241
|
-
Object.defineProperty(this, "name", {
|
|
242
|
-
enumerable: true,
|
|
243
|
-
configurable: true,
|
|
244
|
-
writable: true,
|
|
245
|
-
value: name
|
|
246
|
-
});
|
|
247
|
-
Object.defineProperty(this, "attribs", {
|
|
248
|
-
enumerable: true,
|
|
249
|
-
configurable: true,
|
|
250
|
-
writable: true,
|
|
251
|
-
value: attribs
|
|
252
|
-
});
|
|
253
|
-
Object.defineProperty(this, 'x-attribsNamespace', {
|
|
254
|
-
enumerable: true,
|
|
255
|
-
configurable: true,
|
|
256
|
-
writable: true,
|
|
257
|
-
value: void 0
|
|
258
|
-
});
|
|
259
|
-
Object.defineProperty(this, 'x-attribsPrefix', {
|
|
260
|
-
enumerable: true,
|
|
261
|
-
configurable: true,
|
|
262
|
-
writable: true,
|
|
263
|
-
value: void 0
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
// DOM Level 1 aliases
|
|
267
|
-
get tagName() {
|
|
268
|
-
return this.name;
|
|
269
|
-
}
|
|
270
|
-
set tagName(name) {
|
|
271
|
-
this.name = name;
|
|
272
|
-
}
|
|
273
|
-
get attributes() {
|
|
274
|
-
return Object.keys(this.attribs).map(name => ({
|
|
275
|
-
name,
|
|
276
|
-
value: this.attribs[name],
|
|
277
|
-
namespace: this['x-attribsNamespace']?.[name],
|
|
278
|
-
prefix: this['x-attribsPrefix']?.[name],
|
|
279
|
-
}));
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
exports.Element = Element;
|
|
283
|
-
/**
|
|
284
|
-
* @param node Node to check.
|
|
285
|
-
* @returns `true` if the node is a `Element`, `false` otherwise.
|
|
286
|
-
*/
|
|
287
|
-
function isTag(node) {
|
|
288
|
-
return (0, ElementType_js_1.isTag)(node);
|
|
289
|
-
}
|
|
290
|
-
exports.isTag = isTag;
|
|
291
|
-
/**
|
|
292
|
-
* @param node Node to check.
|
|
293
|
-
* @returns `true` if the node has the type `CDATA`, `false` otherwise.
|
|
294
|
-
*/
|
|
295
|
-
function isCDATA(node) {
|
|
296
|
-
return node.type === ElementType_js_1.ElementType.CDATA;
|
|
297
|
-
}
|
|
298
|
-
exports.isCDATA = isCDATA;
|
|
299
|
-
/**
|
|
300
|
-
* @param node Node to check.
|
|
301
|
-
* @returns `true` if the node has the type `Text`, `false` otherwise.
|
|
302
|
-
*/
|
|
303
|
-
function isText(node) {
|
|
304
|
-
return node.type === ElementType_js_1.ElementType.Text;
|
|
305
|
-
}
|
|
306
|
-
exports.isText = isText;
|
|
307
|
-
/**
|
|
308
|
-
* @param node Node to check.
|
|
309
|
-
* @returns `true` if the node has the type `Comment`, `false` otherwise.
|
|
310
|
-
*/
|
|
311
|
-
function isComment(node) {
|
|
312
|
-
return node.type === ElementType_js_1.ElementType.Comment;
|
|
313
|
-
}
|
|
314
|
-
exports.isComment = isComment;
|
|
315
|
-
/**
|
|
316
|
-
* @param node Node to check.
|
|
317
|
-
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
|
318
|
-
*/
|
|
319
|
-
function isDirective(node) {
|
|
320
|
-
return node.type === ElementType_js_1.ElementType.Directive;
|
|
321
|
-
}
|
|
322
|
-
exports.isDirective = isDirective;
|
|
323
|
-
/**
|
|
324
|
-
* @param node Node to check.
|
|
325
|
-
* @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
|
|
326
|
-
*/
|
|
327
|
-
function isDocument(node) {
|
|
328
|
-
return node.type === ElementType_js_1.ElementType.Root;
|
|
329
|
-
}
|
|
330
|
-
exports.isDocument = isDocument;
|
|
331
|
-
/**
|
|
332
|
-
* @param node Node to check.
|
|
333
|
-
* @returns `true` if the node is a `NodeWithChildren` (has children), `false` otherwise.
|
|
334
|
-
*/
|
|
335
|
-
function hasChildren(node) {
|
|
336
|
-
return Object.prototype.hasOwnProperty.call(node, 'children');
|
|
337
|
-
}
|
|
338
|
-
exports.hasChildren = hasChildren;
|
|
339
|
-
/**
|
|
340
|
-
* Clone a node, and optionally its children.
|
|
341
|
-
*
|
|
342
|
-
* @param recursive Clone child nodes as well.
|
|
343
|
-
* @returns A clone of the node.
|
|
344
|
-
*/
|
|
345
|
-
function cloneNode(node, recursive = false) {
|
|
346
|
-
let result;
|
|
347
|
-
if (isText(node)) {
|
|
348
|
-
result = new Text(node.data);
|
|
349
|
-
}
|
|
350
|
-
else if (isComment(node)) {
|
|
351
|
-
result = new Comment(node.data);
|
|
352
|
-
}
|
|
353
|
-
else if (isTag(node)) {
|
|
354
|
-
const children = recursive ? cloneChildren(node.children) : [];
|
|
355
|
-
const clone = new Element(node.name, { ...node.attribs }, children);
|
|
356
|
-
children.forEach(child => (child.parent = clone));
|
|
357
|
-
if (node['x-attribsNamespace']) {
|
|
358
|
-
clone['x-attribsNamespace'] = { ...node['x-attribsNamespace'] };
|
|
359
|
-
}
|
|
360
|
-
if (node['x-attribsPrefix']) {
|
|
361
|
-
clone['x-attribsPrefix'] = { ...node['x-attribsPrefix'] };
|
|
362
|
-
}
|
|
363
|
-
result = clone;
|
|
364
|
-
}
|
|
365
|
-
else if (isCDATA(node)) {
|
|
366
|
-
const children = recursive ? cloneChildren(node.children) : [];
|
|
367
|
-
const clone = new NodeWithChildren(ElementType_js_1.ElementType.CDATA, children);
|
|
368
|
-
children.forEach(child => (child.parent = clone));
|
|
369
|
-
result = clone;
|
|
370
|
-
}
|
|
371
|
-
else if (isDocument(node)) {
|
|
372
|
-
const children = recursive ? cloneChildren(node.children) : [];
|
|
373
|
-
const clone = new Document(children);
|
|
374
|
-
children.forEach(child => (child.parent = clone));
|
|
375
|
-
if (node['x-mode']) {
|
|
376
|
-
clone['x-mode'] = node['x-mode'];
|
|
377
|
-
}
|
|
378
|
-
result = clone;
|
|
379
|
-
}
|
|
380
|
-
else if (isDirective(node)) {
|
|
381
|
-
const instruction = new ProcessingInstruction(node.name, node.data);
|
|
382
|
-
if (node['x-name'] != null) {
|
|
383
|
-
instruction['x-name'] = node['x-name'];
|
|
384
|
-
instruction['x-publicId'] = node['x-publicId'];
|
|
385
|
-
instruction['x-systemId'] = node['x-systemId'];
|
|
386
|
-
}
|
|
387
|
-
result = instruction;
|
|
388
|
-
}
|
|
389
|
-
else {
|
|
390
|
-
throw new Error(`Not implemented yet: ${node.type}`);
|
|
391
|
-
}
|
|
392
|
-
result.startIndex = node.startIndex;
|
|
393
|
-
result.endIndex = node.endIndex;
|
|
394
|
-
return result;
|
|
395
|
-
}
|
|
396
|
-
exports.cloneNode = cloneNode;
|
|
397
|
-
function cloneChildren(childs) {
|
|
398
|
-
const children = childs.map(child => cloneNode(child, true));
|
|
399
|
-
for (let i = 1; i < children.length; i++) {
|
|
400
|
-
children[i].prev = children[i - 1];
|
|
401
|
-
children[i - 1].next = children[i];
|
|
402
|
-
}
|
|
403
|
-
return children;
|
|
404
|
-
}
|
|
@@ -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
|
-
}
|