@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
package/script/types/5_chat.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.constructChat4 = exports.constructChat3 = exports.constructChat2 = exports.constructChat = exports.getChatOrder = void 0;
|
|
4
|
+
const _0_deps_js_1 = require("../0_deps.js");
|
|
4
5
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
5
6
|
const _2_tl_js_1 = require("../2_tl.js");
|
|
6
7
|
const _0_chat_photo_js_1 = require("./0_chat_photo.js");
|
|
@@ -21,7 +22,7 @@ function getChatPAlsoPhoto(entity) {
|
|
|
21
22
|
also = "usernames" in entity ? entity.usernames?.map((v) => v.username).filter((v) => v != ("username" in chatP ? chatP.username : "")) : undefined;
|
|
22
23
|
}
|
|
23
24
|
else {
|
|
24
|
-
(0,
|
|
25
|
+
(0, _0_deps_js_1.unreachable)();
|
|
25
26
|
}
|
|
26
27
|
let photo = undefined;
|
|
27
28
|
if (entity.photo instanceof _2_tl_js_1.types.UserProfilePhoto) {
|
|
@@ -43,7 +44,7 @@ exports.getChatOrder = getChatOrder;
|
|
|
43
44
|
async function constructChat(dialog, dialogs, pinnedChats, getEntity, getMessage, getStickerSetName) {
|
|
44
45
|
const topMessage_ = dialogs.messages.find((v) => "id" in v && v.id == dialog.top_message);
|
|
45
46
|
if (!topMessage_) {
|
|
46
|
-
(0,
|
|
47
|
+
(0, _0_deps_js_1.unreachable)();
|
|
47
48
|
}
|
|
48
49
|
const pinned = pinnedChats.indexOf((0, _2_tl_js_1.peerToChatId)(dialog.peer));
|
|
49
50
|
const lastMessage = await (0, _4_message_js_1.constructMessage)(topMessage_, getEntity, getMessage, getStickerSetName, false);
|
|
@@ -51,9 +52,9 @@ async function constructChat(dialog, dialogs, pinnedChats, getEntity, getMessage
|
|
|
51
52
|
const userId = "user_id" in dialog.peer ? dialog.peer.user_id : null;
|
|
52
53
|
const chatId = "chat_id" in dialog.peer ? dialog.peer.chat_id : null;
|
|
53
54
|
const channelId = "channel_id" in dialog.peer ? dialog.peer.channel_id : null;
|
|
54
|
-
const chat__ = chatId != null ? dialogs.chats.find((v) => v instanceof _2_tl_js_1.types.Chat && v.id == chatId) : channelId != null ? dialogs.chats.find((v) => v instanceof _2_tl_js_1.types.Channel && v.id == channelId) : userId != null ? dialogs.users.find((v) => v instanceof _2_tl_js_1.types.User && v.id == userId) : (0,
|
|
55
|
+
const chat__ = chatId != null ? dialogs.chats.find((v) => v instanceof _2_tl_js_1.types.Chat && v.id == chatId) : channelId != null ? dialogs.chats.find((v) => v instanceof _2_tl_js_1.types.Channel && v.id == channelId) : userId != null ? dialogs.users.find((v) => v instanceof _2_tl_js_1.types.User && v.id == userId) : (0, _0_deps_js_1.unreachable)();
|
|
55
56
|
if (!chat__) {
|
|
56
|
-
(0,
|
|
57
|
+
(0, _0_deps_js_1.unreachable)();
|
|
57
58
|
}
|
|
58
59
|
const chat_ = chat__;
|
|
59
60
|
const { chatP, also, photo } = getChatPAlsoPhoto(chat_);
|
|
@@ -70,7 +71,7 @@ async function constructChat(dialog, dialogs, pinnedChats, getEntity, getMessage
|
|
|
70
71
|
return (0, _1_utilities_js_1.cleanObject)({ ...chatP, order, lastMessage, also, photo: photo, pinned });
|
|
71
72
|
}
|
|
72
73
|
else {
|
|
73
|
-
(0,
|
|
74
|
+
(0, _0_deps_js_1.unreachable)();
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
exports.constructChat = constructChat;
|
|
@@ -91,7 +92,7 @@ function constructChat2(entity, pinned, lastMessage) {
|
|
|
91
92
|
return (0, _1_utilities_js_1.cleanObject)({ ...chatP, order, lastMessage, also, photo: photo, pinned });
|
|
92
93
|
}
|
|
93
94
|
else {
|
|
94
|
-
(0,
|
|
95
|
+
(0, _0_deps_js_1.unreachable)();
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
exports.constructChat2 = constructChat2;
|
package/script/types/_file_id.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toUniqueFileId = exports.serializeFileId = exports.deserializeFileId = exports.PhotoSourceType = exports.FileType = void 0;
|
|
4
|
+
const _0_deps_js_1 = require("../0_deps.js");
|
|
4
5
|
const _0_errors_js_1 = require("../0_errors.js");
|
|
5
6
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
6
7
|
const _2_tl_js_1 = require("../2_tl.js");
|
|
@@ -125,7 +126,7 @@ function serializePhotoSource(photoSource, writer) {
|
|
|
125
126
|
writer.writeInt32(photoSource.version);
|
|
126
127
|
break;
|
|
127
128
|
default:
|
|
128
|
-
(0,
|
|
129
|
+
(0, _0_deps_js_1.unreachable)();
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
function getPhotoSourceCompareType(source) {
|
|
@@ -135,7 +136,7 @@ function getPhotoSourceCompareType(source) {
|
|
|
135
136
|
case PhotoSourceType.Thumbnail: {
|
|
136
137
|
const type = source.thumbnailType;
|
|
137
138
|
if (!(0 <= type && type <= 127)) {
|
|
138
|
-
(0,
|
|
139
|
+
(0, _0_deps_js_1.unreachable)();
|
|
139
140
|
}
|
|
140
141
|
if (type == "a".charCodeAt(0)) {
|
|
141
142
|
return 0;
|
|
@@ -161,7 +162,7 @@ function getPhotoSourceCompareType(source) {
|
|
|
161
162
|
default:
|
|
162
163
|
break;
|
|
163
164
|
}
|
|
164
|
-
(0,
|
|
165
|
+
(0, _0_deps_js_1.unreachable)();
|
|
165
166
|
}
|
|
166
167
|
function writePhotoSourceUniqueId(photoSource, writer) {
|
|
167
168
|
const compareType = getPhotoSourceCompareType(photoSource);
|
|
@@ -172,8 +173,8 @@ function writePhotoSourceUniqueId(photoSource, writer) {
|
|
|
172
173
|
if (compareType == 2) {
|
|
173
174
|
writer.write(new Uint8Array([0x02]));
|
|
174
175
|
}
|
|
175
|
-
writer.writeInt64("volumeId" in photoSource ? photoSource.volumeId : "stickerSetId" in photoSource ? photoSource.stickerSetId : (0,
|
|
176
|
-
writer.writeInt32("localId" in photoSource ? photoSource.localId : "version" in photoSource ? photoSource.version : (0,
|
|
176
|
+
writer.writeInt64("volumeId" in photoSource ? photoSource.volumeId : "stickerSetId" in photoSource ? photoSource.stickerSetId : (0, _0_deps_js_1.unreachable)());
|
|
177
|
+
writer.writeInt32("localId" in photoSource ? photoSource.localId : "version" in photoSource ? photoSource.version : (0, _0_deps_js_1.unreachable)());
|
|
177
178
|
}
|
|
178
179
|
function getFileTypeClass(fileType) {
|
|
179
180
|
switch (fileType) {
|
|
@@ -207,7 +208,7 @@ function getFileTypeClass(fileType) {
|
|
|
207
208
|
case FileType.None:
|
|
208
209
|
case FileType.Size:
|
|
209
210
|
default:
|
|
210
|
-
(0,
|
|
211
|
+
(0, _0_deps_js_1.unreachable)();
|
|
211
212
|
}
|
|
212
213
|
}
|
|
213
214
|
function isWeb(fileType) {
|
|
@@ -284,7 +285,7 @@ function toUniqueFileId(fileId) {
|
|
|
284
285
|
switch (fileId.location.source.type) {
|
|
285
286
|
case PhotoSourceType.Legacy:
|
|
286
287
|
case PhotoSourceType.StickerSetThumbnail:
|
|
287
|
-
(0,
|
|
288
|
+
(0, _0_deps_js_1.unreachable)();
|
|
288
289
|
/* falls through */
|
|
289
290
|
case PhotoSourceType.FullLegacy:
|
|
290
291
|
case PhotoSourceType.ChatPhotoSmallLegacy:
|
|
@@ -5,3 +5,4 @@ export declare function bigIntFromBuffer(buffer: Uint8Array, little?: boolean, s
|
|
|
5
5
|
export declare function getRandomBigInt(byteLength: number, little?: boolean, signed?: boolean): bigint;
|
|
6
6
|
/** Get a random ID. Useful when calling API functions directly. */
|
|
7
7
|
export declare function getRandomId(): bigint;
|
|
8
|
+
export declare function gcd(a: bigint, b: bigint): bigint;
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getRandomId = exports.getRandomBigInt = exports.bigIntFromBuffer = exports.mod = exports.modExp = void 0;
|
|
26
|
+
exports.gcd = exports.getRandomId = exports.getRandomBigInt = exports.bigIntFromBuffer = exports.mod = exports.modExp = void 0;
|
|
27
27
|
const dntShim = __importStar(require("../_dnt.shims.js"));
|
|
28
28
|
function modExp(a, b, n) {
|
|
29
29
|
a %= n;
|
|
@@ -72,3 +72,29 @@ function getRandomId() {
|
|
|
72
72
|
return getRandomBigInt(8, true, true);
|
|
73
73
|
}
|
|
74
74
|
exports.getRandomId = getRandomId;
|
|
75
|
+
function gcd(a, b) {
|
|
76
|
+
if (a == 0n) {
|
|
77
|
+
return b;
|
|
78
|
+
}
|
|
79
|
+
while ((a & 1n) == 0n) {
|
|
80
|
+
a >>= 1n;
|
|
81
|
+
}
|
|
82
|
+
while (true) {
|
|
83
|
+
if (a > b) {
|
|
84
|
+
a = (a - b) >> 1n;
|
|
85
|
+
while ((a & 1n) == 0n) {
|
|
86
|
+
a >>= 1n;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else if (b > a) {
|
|
90
|
+
b = (b - a) >> 1n;
|
|
91
|
+
while ((b & 1n) == 0n) {
|
|
92
|
+
b >>= 1n;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
return a;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.gcd = gcd;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
export declare function setLogVerbosity(verbosity_: number): void;
|
|
2
|
+
export interface LoggingProvider {
|
|
3
|
+
error(...args: any[]): void;
|
|
4
|
+
warn(...args: any[]): void;
|
|
5
|
+
info(...args: any[]): void;
|
|
6
|
+
debug(...args: any[]): void;
|
|
7
|
+
log(...args: any[]): void;
|
|
8
|
+
}
|
|
9
|
+
export declare function setLoggingProvider(provider_: LoggingProvider): void;
|
|
2
10
|
export declare const ERROR = 1;
|
|
3
11
|
export declare const WARNING = 2;
|
|
4
12
|
export declare const INFO = 3;
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getLogger = exports.OUT_BIN = exports.IN_BIN = exports.OUT = exports.IN = exports.TRACE = exports.DEBUG = exports.INFO = exports.WARNING = exports.ERROR = exports.setLogVerbosity = void 0;
|
|
26
|
+
exports.getLogger = exports.OUT_BIN = exports.IN_BIN = exports.OUT = exports.IN = exports.TRACE = exports.DEBUG = exports.INFO = exports.WARNING = exports.ERROR = exports.setLoggingProvider = exports.setLogVerbosity = void 0;
|
|
27
27
|
// deno-lint-ignore-file no-explicit-any
|
|
28
28
|
const dntShim = __importStar(require("../_dnt.shims.js"));
|
|
29
29
|
let verbosity = Number("LOG_VERBOSITY" in dntShim.dntGlobalThis ? dntShim.dntGlobalThis.LOG_VERBOSITY : "Deno" in dntShim.dntGlobalThis ? dntShim.dntGlobalThis.Deno.env.get("LOG_VERBOSITY") : "process" in dntShim.dntGlobalThis ? dntShim.dntGlobalThis.process.env.LOG : "") || 0;
|
|
@@ -31,6 +31,11 @@ function setLogVerbosity(verbosity_) {
|
|
|
31
31
|
verbosity = verbosity_;
|
|
32
32
|
}
|
|
33
33
|
exports.setLogVerbosity = setLogVerbosity;
|
|
34
|
+
let provider = console;
|
|
35
|
+
function setLoggingProvider(provider_) {
|
|
36
|
+
provider = provider_;
|
|
37
|
+
}
|
|
38
|
+
exports.setLoggingProvider = setLoggingProvider;
|
|
34
39
|
exports.ERROR = 1;
|
|
35
40
|
exports.WARNING = 2;
|
|
36
41
|
exports.INFO = 3;
|
|
@@ -97,19 +102,19 @@ function getLogger(scope) {
|
|
|
97
102
|
let fn;
|
|
98
103
|
switch (verbosity_) {
|
|
99
104
|
case exports.ERROR:
|
|
100
|
-
fn =
|
|
105
|
+
fn = provider.error;
|
|
101
106
|
break;
|
|
102
107
|
case exports.WARNING:
|
|
103
|
-
fn =
|
|
108
|
+
fn = provider.warn;
|
|
104
109
|
break;
|
|
105
110
|
case exports.INFO:
|
|
106
|
-
fn =
|
|
111
|
+
fn = provider.info;
|
|
107
112
|
break;
|
|
108
113
|
case exports.DEBUG:
|
|
109
|
-
fn =
|
|
114
|
+
fn = provider.debug;
|
|
110
115
|
break;
|
|
111
116
|
default:
|
|
112
|
-
fn =
|
|
117
|
+
fn = provider.log;
|
|
113
118
|
}
|
|
114
119
|
fn(`[${verbosity_} ${scope}]`, ...args);
|
|
115
120
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function factorize(pq: bigint): [bigint, bigint];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.factorize = void 0;
|
|
4
|
+
const _0_deps_js_1 = require("../0_deps.js");
|
|
5
|
+
const _0_bigint_js_1 = require("./0_bigint.js");
|
|
6
|
+
function getRandomNumberInRange(min, max) {
|
|
7
|
+
return Math.floor(Math.random() * (max - min) + min);
|
|
8
|
+
}
|
|
9
|
+
function factorize(pq) {
|
|
10
|
+
let a;
|
|
11
|
+
let b;
|
|
12
|
+
let p = 0n;
|
|
13
|
+
let q;
|
|
14
|
+
const one = 1n;
|
|
15
|
+
let found = false;
|
|
16
|
+
for (let i = 0, iter = 0; !found && (i < 3 || iter < 1000); i++) {
|
|
17
|
+
const t = BigInt(getRandomNumberInRange(17, 32)) % (pq - 1n);
|
|
18
|
+
a = (0, _0_bigint_js_1.getRandomId)();
|
|
19
|
+
b = a;
|
|
20
|
+
const lim = 1 << (i + 23);
|
|
21
|
+
for (let j = 1; j < lim; j++) {
|
|
22
|
+
iter++;
|
|
23
|
+
a = (0, _0_bigint_js_1.mod)(a * a, pq);
|
|
24
|
+
a += t;
|
|
25
|
+
if (a >= pq) {
|
|
26
|
+
a = a - pq;
|
|
27
|
+
}
|
|
28
|
+
if (a > b) {
|
|
29
|
+
q = a - b;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
q = b - a;
|
|
33
|
+
}
|
|
34
|
+
p = (0, _0_bigint_js_1.gcd)(q, pq);
|
|
35
|
+
if (p != one) {
|
|
36
|
+
found = true;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
if ((j & (j - 1)) == 0) {
|
|
40
|
+
b = a;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (found) {
|
|
45
|
+
q = pq / p;
|
|
46
|
+
if (p > q) {
|
|
47
|
+
return [q, p];
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return [p, q];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
(0, _0_deps_js_1.unreachable)();
|
|
54
|
+
}
|
|
55
|
+
exports.factorize = factorize;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fromUnixTimestamp = exports.toUnixTimestamp = exports.VECTOR_CONSTRUCTOR = exports.ZERO_CHANNEL_ID = exports.mustPromptOneOf = exports.mustPromptNumber = exports.mustPrompt = exports.drop = void 0;
|
|
4
|
-
const
|
|
4
|
+
const _0_deps_js_1 = require("../0_deps.js");
|
|
5
5
|
function drop(promise) {
|
|
6
6
|
promise.catch(() => { });
|
|
7
7
|
}
|
|
@@ -9,7 +9,7 @@ exports.drop = drop;
|
|
|
9
9
|
function mustPrompt(message) {
|
|
10
10
|
const result = prompt(message);
|
|
11
11
|
if (result == null) {
|
|
12
|
-
throw (0,
|
|
12
|
+
throw (0, _0_deps_js_1.unreachable)();
|
|
13
13
|
}
|
|
14
14
|
else {
|
|
15
15
|
return result;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { Node, Element, Document, NodeWithChildren, DataNode } from './Node.js';
|
|
2
|
-
export interface DomHandlerOptions {
|
|
3
|
-
/**
|
|
4
|
-
* Add a `startIndex` property to nodes.
|
|
5
|
-
* When the parser is used in a non-streaming fashion, `startIndex` is an integer
|
|
6
|
-
* indicating the position of the start of the node in the document.
|
|
7
|
-
*
|
|
8
|
-
* @default false
|
|
9
|
-
*/
|
|
10
|
-
withStartIndices?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Add an `endIndex` property to nodes.
|
|
13
|
-
* When the parser is used in a non-streaming fashion, `endIndex` is an integer
|
|
14
|
-
* indicating the position of the end of the node in the document.
|
|
15
|
-
*
|
|
16
|
-
* @default false
|
|
17
|
-
*/
|
|
18
|
-
withEndIndices?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Replace all whitespace with single spaces.
|
|
21
|
-
*
|
|
22
|
-
* **Note:** Enabling this might break your markup.
|
|
23
|
-
*
|
|
24
|
-
* @default false
|
|
25
|
-
* @deprecated
|
|
26
|
-
*/
|
|
27
|
-
normalizeWhitespace?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Treat the markup as XML.
|
|
30
|
-
*
|
|
31
|
-
* @default false
|
|
32
|
-
*/
|
|
33
|
-
xmlMode?: boolean;
|
|
34
|
-
}
|
|
35
|
-
interface ParserInterface {
|
|
36
|
-
startIndex: number | null;
|
|
37
|
-
endIndex: number | null;
|
|
38
|
-
}
|
|
39
|
-
type Callback = (error: Error | null, dom: Node[]) => void;
|
|
40
|
-
type ElementCallback = (element: Element) => void;
|
|
41
|
-
export declare class DomHandler {
|
|
42
|
-
/** The elements of the DOM */
|
|
43
|
-
dom: Node[];
|
|
44
|
-
/** The root element for the DOM */
|
|
45
|
-
root: Document;
|
|
46
|
-
/** Called once parsing has completed. */
|
|
47
|
-
private readonly callback;
|
|
48
|
-
/** Settings for the handler. */
|
|
49
|
-
private readonly options;
|
|
50
|
-
/** Callback whenever a tag is closed. */
|
|
51
|
-
private readonly elementCB;
|
|
52
|
-
/** Indicated whether parsing has been completed. */
|
|
53
|
-
private done;
|
|
54
|
-
/** Stack of open tags. */
|
|
55
|
-
protected tagStack: NodeWithChildren[];
|
|
56
|
-
/** A data node that is still being written to. */
|
|
57
|
-
protected lastNode: DataNode | null;
|
|
58
|
-
/** Reference to the parser instance. Used for location information. */
|
|
59
|
-
private parser;
|
|
60
|
-
/**
|
|
61
|
-
* @param callback Called once parsing has completed.
|
|
62
|
-
* @param options Settings for the handler.
|
|
63
|
-
* @param elementCB Callback whenever a tag is closed.
|
|
64
|
-
*/
|
|
65
|
-
constructor(callback?: Callback | null, options?: DomHandlerOptions | null, elementCB?: ElementCallback);
|
|
66
|
-
onparserinit(parser: ParserInterface): void;
|
|
67
|
-
onreset(): void;
|
|
68
|
-
onend(): void;
|
|
69
|
-
onerror(error: Error): void;
|
|
70
|
-
onclosetag(): void;
|
|
71
|
-
onopentag(name: string, attribs: {
|
|
72
|
-
[key: string]: string;
|
|
73
|
-
}): void;
|
|
74
|
-
ontext(data: string): void;
|
|
75
|
-
oncomment(data: string): void;
|
|
76
|
-
oncommentend(): void;
|
|
77
|
-
oncdatastart(): void;
|
|
78
|
-
oncdataend(): void;
|
|
79
|
-
onprocessinginstruction(name: string, data: string): void;
|
|
80
|
-
protected handleCallback(error: Error | null): void;
|
|
81
|
-
protected addNode(node: Node): void;
|
|
82
|
-
}
|
|
83
|
-
export default DomHandler;
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { Element, Document, NodeWithChildren, Comment, Text, ProcessingInstruction, } from './Node.js';
|
|
2
|
-
import { ElementType } from './ElementType.js';
|
|
3
|
-
const reWhitespace = /\s+/g;
|
|
4
|
-
// Default options
|
|
5
|
-
const defaultOpts = {
|
|
6
|
-
normalizeWhitespace: false,
|
|
7
|
-
withStartIndices: false,
|
|
8
|
-
withEndIndices: false,
|
|
9
|
-
};
|
|
10
|
-
export class DomHandler {
|
|
11
|
-
/**
|
|
12
|
-
* @param callback Called once parsing has completed.
|
|
13
|
-
* @param options Settings for the handler.
|
|
14
|
-
* @param elementCB Callback whenever a tag is closed.
|
|
15
|
-
*/
|
|
16
|
-
constructor(callback, options, elementCB) {
|
|
17
|
-
/** The elements of the DOM */
|
|
18
|
-
Object.defineProperty(this, "dom", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
configurable: true,
|
|
21
|
-
writable: true,
|
|
22
|
-
value: []
|
|
23
|
-
});
|
|
24
|
-
/** The root element for the DOM */
|
|
25
|
-
Object.defineProperty(this, "root", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
configurable: true,
|
|
28
|
-
writable: true,
|
|
29
|
-
value: new Document(this.dom)
|
|
30
|
-
});
|
|
31
|
-
/** Called once parsing has completed. */
|
|
32
|
-
Object.defineProperty(this, "callback", {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
configurable: true,
|
|
35
|
-
writable: true,
|
|
36
|
-
value: void 0
|
|
37
|
-
});
|
|
38
|
-
/** Settings for the handler. */
|
|
39
|
-
Object.defineProperty(this, "options", {
|
|
40
|
-
enumerable: true,
|
|
41
|
-
configurable: true,
|
|
42
|
-
writable: true,
|
|
43
|
-
value: void 0
|
|
44
|
-
});
|
|
45
|
-
/** Callback whenever a tag is closed. */
|
|
46
|
-
Object.defineProperty(this, "elementCB", {
|
|
47
|
-
enumerable: true,
|
|
48
|
-
configurable: true,
|
|
49
|
-
writable: true,
|
|
50
|
-
value: void 0
|
|
51
|
-
});
|
|
52
|
-
/** Indicated whether parsing has been completed. */
|
|
53
|
-
Object.defineProperty(this, "done", {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
configurable: true,
|
|
56
|
-
writable: true,
|
|
57
|
-
value: false
|
|
58
|
-
});
|
|
59
|
-
/** Stack of open tags. */
|
|
60
|
-
Object.defineProperty(this, "tagStack", {
|
|
61
|
-
enumerable: true,
|
|
62
|
-
configurable: true,
|
|
63
|
-
writable: true,
|
|
64
|
-
value: [this.root]
|
|
65
|
-
});
|
|
66
|
-
/** A data node that is still being written to. */
|
|
67
|
-
Object.defineProperty(this, "lastNode", {
|
|
68
|
-
enumerable: true,
|
|
69
|
-
configurable: true,
|
|
70
|
-
writable: true,
|
|
71
|
-
value: null
|
|
72
|
-
});
|
|
73
|
-
/** Reference to the parser instance. Used for location information. */
|
|
74
|
-
Object.defineProperty(this, "parser", {
|
|
75
|
-
enumerable: true,
|
|
76
|
-
configurable: true,
|
|
77
|
-
writable: true,
|
|
78
|
-
value: null
|
|
79
|
-
});
|
|
80
|
-
// Make it possible to skip arguments, for backwards-compatibility
|
|
81
|
-
if (typeof options === 'function') {
|
|
82
|
-
elementCB = options;
|
|
83
|
-
options = defaultOpts;
|
|
84
|
-
}
|
|
85
|
-
if (typeof callback === 'object') {
|
|
86
|
-
options = callback;
|
|
87
|
-
callback = undefined;
|
|
88
|
-
}
|
|
89
|
-
this.callback = callback ?? null;
|
|
90
|
-
this.options = options ?? defaultOpts;
|
|
91
|
-
this.elementCB = elementCB ?? null;
|
|
92
|
-
}
|
|
93
|
-
onparserinit(parser) {
|
|
94
|
-
this.parser = parser;
|
|
95
|
-
}
|
|
96
|
-
// Resets the handler back to starting state
|
|
97
|
-
onreset() {
|
|
98
|
-
this.dom = [];
|
|
99
|
-
this.root = new Document(this.dom);
|
|
100
|
-
this.done = false;
|
|
101
|
-
this.tagStack = [this.root];
|
|
102
|
-
this.lastNode = null;
|
|
103
|
-
this.parser = this.parser ?? null;
|
|
104
|
-
}
|
|
105
|
-
// Signals the handler that parsing is done
|
|
106
|
-
onend() {
|
|
107
|
-
if (this.done)
|
|
108
|
-
return;
|
|
109
|
-
this.done = true;
|
|
110
|
-
this.parser = null;
|
|
111
|
-
this.handleCallback(null);
|
|
112
|
-
}
|
|
113
|
-
onerror(error) {
|
|
114
|
-
this.handleCallback(error);
|
|
115
|
-
}
|
|
116
|
-
onclosetag() {
|
|
117
|
-
this.lastNode = null;
|
|
118
|
-
const elem = this.tagStack.pop();
|
|
119
|
-
if (this.options.withEndIndices) {
|
|
120
|
-
elem.endIndex = this.parser.endIndex;
|
|
121
|
-
}
|
|
122
|
-
if (this.elementCB)
|
|
123
|
-
this.elementCB(elem);
|
|
124
|
-
}
|
|
125
|
-
onopentag(name, attribs) {
|
|
126
|
-
const type = this.options.xmlMode ? ElementType.Tag : undefined;
|
|
127
|
-
const element = new Element(name, attribs, undefined, type);
|
|
128
|
-
this.addNode(element);
|
|
129
|
-
this.tagStack.push(element);
|
|
130
|
-
}
|
|
131
|
-
ontext(data) {
|
|
132
|
-
const { normalizeWhitespace } = this.options;
|
|
133
|
-
const { lastNode } = this;
|
|
134
|
-
if (lastNode && lastNode.type === ElementType.Text) {
|
|
135
|
-
if (normalizeWhitespace) {
|
|
136
|
-
lastNode.data = (lastNode.data + data).replace(reWhitespace, ' ');
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
lastNode.data += data;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
if (normalizeWhitespace) {
|
|
144
|
-
data = data.replace(reWhitespace, ' ');
|
|
145
|
-
}
|
|
146
|
-
const node = new Text(data);
|
|
147
|
-
this.addNode(node);
|
|
148
|
-
this.lastNode = node;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
oncomment(data) {
|
|
152
|
-
if (this.lastNode && this.lastNode.type === ElementType.Comment) {
|
|
153
|
-
this.lastNode.data += data;
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
const node = new Comment(data);
|
|
157
|
-
this.addNode(node);
|
|
158
|
-
this.lastNode = node;
|
|
159
|
-
}
|
|
160
|
-
oncommentend() {
|
|
161
|
-
this.lastNode = null;
|
|
162
|
-
}
|
|
163
|
-
oncdatastart() {
|
|
164
|
-
const text = new Text('');
|
|
165
|
-
const node = new NodeWithChildren(ElementType.CDATA, [text]);
|
|
166
|
-
this.addNode(node);
|
|
167
|
-
text.parent = node;
|
|
168
|
-
this.lastNode = text;
|
|
169
|
-
}
|
|
170
|
-
oncdataend() {
|
|
171
|
-
this.lastNode = null;
|
|
172
|
-
}
|
|
173
|
-
onprocessinginstruction(name, data) {
|
|
174
|
-
const node = new ProcessingInstruction(name, data);
|
|
175
|
-
this.addNode(node);
|
|
176
|
-
}
|
|
177
|
-
handleCallback(error) {
|
|
178
|
-
if (typeof this.callback === 'function') {
|
|
179
|
-
this.callback(error, this.dom);
|
|
180
|
-
}
|
|
181
|
-
else if (error) {
|
|
182
|
-
throw error;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
addNode(node) {
|
|
186
|
-
const parent = this.tagStack[this.tagStack.length - 1];
|
|
187
|
-
const previousSibling = parent.children[parent.children.length - 1];
|
|
188
|
-
if (this.options.withStartIndices) {
|
|
189
|
-
node.startIndex = this.parser.startIndex;
|
|
190
|
-
}
|
|
191
|
-
if (this.options.withEndIndices) {
|
|
192
|
-
node.endIndex = this.parser.endIndex;
|
|
193
|
-
}
|
|
194
|
-
parent.children.push(node);
|
|
195
|
-
if (previousSibling) {
|
|
196
|
-
node.prev = previousSibling;
|
|
197
|
-
previousSibling.next = node;
|
|
198
|
-
}
|
|
199
|
-
node.parent = parent;
|
|
200
|
-
this.lastNode = null;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
export default DomHandler;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { Node } from './Node.js';
|
|
2
|
-
/**
|
|
3
|
-
* Mixed-case SVG and MathML tags & attributes
|
|
4
|
-
* recognized by the HTML parser.
|
|
5
|
-
*
|
|
6
|
-
* @see https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inforeign
|
|
7
|
-
*/
|
|
8
|
-
export declare const elementNames: Map<string, string>;
|
|
9
|
-
export declare const attributeNames: Map<string, string>;
|
|
10
|
-
export interface DomSerializerOptions {
|
|
11
|
-
/**
|
|
12
|
-
* Print an empty attribute's value.
|
|
13
|
-
*
|
|
14
|
-
* @default xmlMode
|
|
15
|
-
* @example With <code>emptyAttrs: false</code>: <code><input checked></code>
|
|
16
|
-
* @example With <code>emptyAttrs: true</code>: <code><input checked=""></code>
|
|
17
|
-
*/
|
|
18
|
-
emptyAttrs?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Print self-closing tags for tags without contents.
|
|
21
|
-
*
|
|
22
|
-
* @default xmlMode
|
|
23
|
-
* @example With <code>selfClosingTags: false</code>: <code><foo></foo></code>
|
|
24
|
-
* @example With <code>selfClosingTags: true</code>: <code><foo /></code>
|
|
25
|
-
*/
|
|
26
|
-
selfClosingTags?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Treat the input as an XML document; enables the `emptyAttrs` and `selfClosingTags` options.
|
|
29
|
-
*
|
|
30
|
-
* If the value is `"foreign"`, it will try to correct mixed-case attribute names.
|
|
31
|
-
*
|
|
32
|
-
* @default false
|
|
33
|
-
*/
|
|
34
|
-
xmlMode?: boolean | 'foreign';
|
|
35
|
-
/**
|
|
36
|
-
* Encode characters that are either reserved in HTML or XML, or are outside of the ASCII range.
|
|
37
|
-
*
|
|
38
|
-
* @default true
|
|
39
|
-
*/
|
|
40
|
-
decodeEntities?: boolean;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Renders a DOM node or an array of DOM nodes to a string.
|
|
44
|
-
*
|
|
45
|
-
* Can be thought of as the equivalent of the `outerHTML` of the passed node(s).
|
|
46
|
-
*
|
|
47
|
-
* @param node Node to be rendered.
|
|
48
|
-
* @param options Changes serialization behavior
|
|
49
|
-
*/
|
|
50
|
-
export default function render(node: Node | ArrayLike<Node>, options?: DomSerializerOptions): string;
|