@mtkruto/node 0.1.132 → 0.1.134
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/3_errors.d.ts +519 -510
- package/esm/3_errors.js +521 -509
- package/esm/3_types.d.ts +19 -7
- package/esm/3_types.js +19 -7
- package/esm/4_constants.d.ts +2 -2
- package/esm/4_constants.js +2 -2
- package/esm/4_errors.d.ts +7 -12
- package/esm/4_errors.js +6 -7
- package/esm/5_client.d.ts +3 -3
- package/esm/5_client.js +3 -3
- package/esm/client/0_utilities.d.ts +30 -2
- package/esm/client/0_utilities.js +13 -5
- package/esm/client/1_composer.d.ts +30 -0
- package/esm/client/{4_composer.js → 1_composer.js} +15 -2
- package/esm/client/2_client_plain.d.ts +1 -1
- package/esm/client/2_client_plain.js +1 -1
- package/esm/client/{3_types.d.ts → 3_params.d.ts} +68 -172
- package/esm/client/3_params.js +1 -0
- package/esm/client/{5_client.d.ts → 4_client.d.ts} +89 -57
- package/esm/client/{5_client.js → 4_client.js} +499 -308
- package/esm/client/5_composer.d.ts +4 -0
- package/esm/client/5_composer.js +3 -0
- package/esm/storage/0_storage.d.ts +4 -1
- package/esm/storage/0_storage.js +36 -7
- package/esm/storage/1_storage_indexed_db.d.ts +6 -2
- package/esm/storage/1_storage_indexed_db.js +7 -5
- package/esm/storage/1_storage_local_storage.d.ts +1 -1
- package/esm/storage/1_storage_local_storage.js +1 -1
- package/esm/storage/1_storage_memory.d.ts +1 -1
- package/esm/storage/1_storage_memory.js +1 -1
- package/esm/storage/1_storage_session_storage.d.ts +1 -1
- package/esm/storage/1_storage_session_storage.js +1 -1
- package/esm/tl/2_types.d.ts +313 -24
- package/esm/tl/2_types.js +982 -46
- package/esm/tl/3_functions.d.ts +95 -32
- package/esm/tl/3_functions.js +227 -66
- package/esm/tl/3_utilities.d.ts +1 -0
- package/esm/tl/3_utilities.js +14 -0
- package/esm/tl/6_message.js +1 -1
- package/esm/types/0_authorization_state.d.ts +5 -0
- package/esm/types/0_authorization_state.js +1 -0
- package/esm/types/0_chat_photo.d.ts +22 -21
- package/esm/types/0_connection_state.d.ts +17 -0
- package/esm/types/0_connection_state.js +1 -0
- package/esm/types/0_giveaway_parameters.d.ts +9 -0
- package/esm/types/0_giveaway_parameters.js +9 -0
- package/esm/types/0_login_url.d.ts +0 -4
- package/esm/types/0_mask_position.d.ts +0 -4
- package/esm/types/0_message_entity.d.ts +91 -74
- package/esm/types/0_message_identifier.d.ts +4 -0
- package/esm/types/0_message_identifier.js +1 -0
- package/esm/types/0_network_statistics_entry.d.ts +4 -0
- package/esm/types/0_network_statistics_entry.js +1 -0
- package/esm/types/0_reaction.d.ts +14 -10
- package/esm/types/0_reaction.js +29 -1
- package/esm/types/1__getters.d.ts +3 -0
- package/esm/types/1_bot_command_scope.d.ts +32 -27
- package/esm/types/1_chat_p.d.ts +77 -68
- package/esm/types/1_giveaway.d.ts +8 -0
- package/esm/types/1_giveaway.js +7 -0
- package/esm/types/1_keyboard_button.d.ts +41 -57
- package/esm/types/1_keyboard_button.js +3 -0
- package/esm/types/1_message_reaction.d.ts +14 -0
- package/esm/types/1_message_reaction.js +22 -0
- package/esm/types/1_network_statistics.d.ts +5 -0
- package/esm/types/1_network_statistics.js +1 -0
- package/esm/types/1_poll.d.ts +0 -13
- package/esm/types/1_reaction_count.d.ts +7 -0
- package/esm/types/1_reaction_count.js +6 -0
- package/esm/types/1_user.d.ts +2 -2
- package/esm/types/2_game.d.ts +0 -7
- package/esm/types/2_inline_keyboard_button.d.ts +36 -37
- package/esm/types/2_inline_query.d.ts +0 -6
- package/esm/types/2_message_interactions.d.ts +8 -0
- package/esm/types/2_message_interactions.js +1 -0
- package/esm/types/2_message_reaction_count.d.ts +8 -0
- package/esm/types/2_message_reaction_count.js +1 -0
- package/esm/types/2_reply_keyboard_markup.d.ts +0 -7
- package/esm/types/3_inline_keyboard_markup.d.ts +0 -2
- package/esm/types/4_message.d.ts +457 -0
- package/esm/types/{3_message.js → 4_message.js} +216 -129
- package/{script/types/4_callback_query.d.ts → esm/types/5_callback_query.d.ts} +1 -1
- package/esm/types/5_chat.d.ts +37 -0
- package/esm/types/{4_chat.js → 5_chat.js} +2 -2
- package/esm/types/6_update.d.ts +134 -0
- package/esm/types/6_update.js +1 -0
- package/package.json +1 -1
- package/script/3_errors.d.ts +519 -510
- package/script/3_errors.js +533 -520
- package/script/3_types.d.ts +19 -7
- package/script/3_types.js +19 -7
- package/script/4_constants.d.ts +2 -2
- package/script/4_constants.js +2 -2
- package/script/4_errors.d.ts +7 -12
- package/script/4_errors.js +5 -6
- package/script/5_client.d.ts +3 -3
- package/script/5_client.js +3 -3
- package/script/client/0_utilities.d.ts +30 -2
- package/script/client/0_utilities.js +15 -6
- package/script/client/1_composer.d.ts +30 -0
- package/script/client/{4_composer.js → 1_composer.js} +17 -4
- package/script/client/2_client_plain.d.ts +1 -1
- package/script/client/2_client_plain.js +2 -2
- package/script/client/{3_types.d.ts → 3_params.d.ts} +68 -172
- package/script/client/3_params.js +2 -0
- package/script/client/{5_client.d.ts → 4_client.d.ts} +89 -57
- package/script/client/{5_client.js → 4_client.js} +505 -314
- package/script/client/5_composer.d.ts +4 -0
- package/script/client/{6_composer.js → 5_composer.js} +2 -2
- package/script/storage/0_storage.d.ts +4 -1
- package/script/storage/0_storage.js +36 -7
- package/script/storage/1_storage_indexed_db.d.ts +6 -2
- package/script/storage/1_storage_indexed_db.js +7 -5
- package/script/storage/1_storage_local_storage.d.ts +1 -1
- package/script/storage/1_storage_local_storage.js +1 -1
- package/script/storage/1_storage_memory.d.ts +1 -1
- package/script/storage/1_storage_memory.js +1 -1
- package/script/storage/1_storage_session_storage.d.ts +1 -1
- package/script/storage/1_storage_session_storage.js +1 -1
- package/script/tl/2_types.d.ts +313 -24
- package/script/tl/2_types.js +1169 -217
- package/script/tl/3_functions.d.ts +95 -32
- package/script/tl/3_functions.js +241 -77
- package/script/tl/3_utilities.d.ts +1 -0
- package/script/tl/3_utilities.js +16 -1
- package/script/tl/6_message.js +1 -1
- package/script/types/0_authorization_state.d.ts +5 -0
- package/script/types/0_authorization_state.js +2 -0
- package/script/types/0_chat_photo.d.ts +22 -21
- package/script/types/0_connection_state.d.ts +17 -0
- package/script/types/0_connection_state.js +2 -0
- package/script/types/0_giveaway_parameters.d.ts +9 -0
- package/script/types/0_giveaway_parameters.js +13 -0
- package/script/types/0_login_url.d.ts +0 -4
- package/script/types/0_mask_position.d.ts +0 -4
- package/script/types/0_message_entity.d.ts +91 -74
- package/script/types/0_message_identifier.d.ts +4 -0
- package/script/types/0_message_identifier.js +2 -0
- package/script/types/0_network_statistics_entry.d.ts +4 -0
- package/script/types/0_network_statistics_entry.js +2 -0
- package/script/types/0_reaction.d.ts +14 -10
- package/script/types/0_reaction.js +33 -0
- package/script/types/1__getters.d.ts +3 -0
- package/script/types/1_bot_command_scope.d.ts +32 -27
- package/script/types/1_chat_p.d.ts +77 -68
- package/script/types/1_giveaway.d.ts +8 -0
- package/script/types/1_giveaway.js +11 -0
- package/script/types/1_keyboard_button.d.ts +41 -57
- package/script/types/1_keyboard_button.js +3 -0
- package/script/types/1_message_reaction.d.ts +14 -0
- package/script/types/1_message_reaction.js +26 -0
- package/script/types/1_network_statistics.d.ts +5 -0
- package/script/types/1_network_statistics.js +2 -0
- package/script/types/1_poll.d.ts +0 -13
- package/script/types/1_reaction_count.d.ts +7 -0
- package/script/types/1_reaction_count.js +10 -0
- package/script/types/1_user.d.ts +2 -2
- package/script/types/2_game.d.ts +0 -7
- package/script/types/2_inline_keyboard_button.d.ts +36 -37
- package/script/types/2_inline_query.d.ts +0 -6
- package/script/types/2_message_interactions.d.ts +8 -0
- package/script/types/2_message_interactions.js +2 -0
- package/script/types/2_message_reaction_count.d.ts +8 -0
- package/script/types/2_message_reaction_count.js +2 -0
- package/script/types/2_reply_keyboard_markup.d.ts +0 -7
- package/script/types/3_inline_keyboard_markup.d.ts +0 -2
- package/script/types/4_message.d.ts +457 -0
- package/script/types/{3_message.js → 4_message.js} +218 -130
- package/{esm/types/4_callback_query.d.ts → script/types/5_callback_query.d.ts} +1 -1
- package/script/types/5_chat.d.ts +37 -0
- package/script/types/{4_chat.js → 5_chat.js} +3 -3
- package/script/types/6_update.d.ts +134 -0
- package/script/types/6_update.js +2 -0
- package/esm/client/3_types.js +0 -11
- package/esm/client/4_composer.d.ts +0 -31
- package/esm/client/6_composer.d.ts +0 -4
- package/esm/client/6_composer.js +0 -3
- package/esm/types/3_message.d.ts +0 -182
- package/esm/types/4_chat.d.ts +0 -34
- package/script/client/3_types.js +0 -15
- package/script/client/4_composer.d.ts +0 -31
- package/script/client/6_composer.d.ts +0 -4
- package/script/types/3_message.d.ts +0 -182
- package/script/types/4_chat.d.ts +0 -34
- /package/esm/client/{1_client_abstract.d.ts → 0_client_abstract.d.ts} +0 -0
- /package/esm/client/{1_client_abstract.js → 0_client_abstract.js} +0 -0
- /package/esm/types/{0_audio.d.ts → 1_audio.d.ts} +0 -0
- /package/esm/types/{0_audio.js → 1_audio.js} +0 -0
- /package/esm/types/{4_callback_query.js → 5_callback_query.js} +0 -0
- /package/script/client/{1_client_abstract.d.ts → 0_client_abstract.d.ts} +0 -0
- /package/script/client/{1_client_abstract.js → 0_client_abstract.js} +0 -0
- /package/script/types/{0_audio.d.ts → 1_audio.d.ts} +0 -0
- /package/script/types/{0_audio.js → 1_audio.js} +0 -0
- /package/script/types/{4_callback_query.js → 5_callback_query.js} +0 -0
|
@@ -10,7 +10,7 @@ export type GetManyFilter = {
|
|
|
10
10
|
};
|
|
11
11
|
export declare abstract class Storage {
|
|
12
12
|
#private;
|
|
13
|
-
abstract
|
|
13
|
+
abstract initialize(): MaybePromise<void>;
|
|
14
14
|
abstract set(key: readonly StorageKeyPart[], value: unknown): MaybePromise<void>;
|
|
15
15
|
abstract incr(key: readonly StorageKeyPart[], by: number): MaybePromise<void>;
|
|
16
16
|
abstract get<T>(key: readonly StorageKeyPart[]): MaybePromise<T | null>;
|
|
@@ -73,4 +73,7 @@ export declare abstract class Storage {
|
|
|
73
73
|
setFilePartCount(id: bigint, partCount: number): Promise<void>;
|
|
74
74
|
setCustomEmojiDocument(id: bigint, document: types.Document): Promise<void>;
|
|
75
75
|
getCustomEmojiDocument(id: bigint): Promise<[import("../tl/2_types.js").Document_, Date] | null>;
|
|
76
|
+
setUpdate(boxId: bigint, update: enums.Update): Promise<void>;
|
|
77
|
+
deleteUpdates(): Promise<void>;
|
|
78
|
+
getFirstUpdate(boxId: bigint): Promise<readonly [readonly StorageKeyPart[], import("../tl/2_types.js").UpdateNewMessage_ | import("../tl/2_types.js").UpdateMessageID_ | import("../tl/2_types.js").UpdateDeleteMessages_ | import("../tl/2_types.js").UpdateUserTyping_ | import("../tl/2_types.js").UpdateChatUserTyping_ | import("../tl/2_types.js").UpdateChatParticipants_ | import("../tl/2_types.js").UpdateUserStatus_ | import("../tl/2_types.js").UpdateUserName_ | import("../tl/2_types.js").UpdateNewAuthorization_ | import("../tl/2_types.js").UpdateNewEncryptedMessage_ | import("../tl/2_types.js").UpdateEncryptedChatTyping_ | import("../tl/2_types.js").UpdateEncryption_ | import("../tl/2_types.js").UpdateEncryptedMessagesRead_ | import("../tl/2_types.js").UpdateChatParticipantAdd_ | import("../tl/2_types.js").UpdateChatParticipantDelete_ | import("../tl/2_types.js").UpdateDcOptions_ | import("../tl/2_types.js").UpdateNotifySettings_ | import("../tl/2_types.js").UpdateServiceNotification_ | import("../tl/2_types.js").UpdatePrivacy_ | import("../tl/2_types.js").UpdateUserPhone_ | import("../tl/2_types.js").UpdateReadHistoryInbox_ | import("../tl/2_types.js").UpdateReadHistoryOutbox_ | import("../tl/2_types.js").UpdateWebPage_ | import("../tl/2_types.js").UpdateReadMessagesContents_ | import("../tl/2_types.js").UpdateChannelTooLong_ | import("../tl/2_types.js").UpdateChannel_ | import("../tl/2_types.js").UpdateNewChannelMessage_ | import("../tl/2_types.js").UpdateReadChannelInbox_ | import("../tl/2_types.js").UpdateDeleteChannelMessages_ | import("../tl/2_types.js").UpdateChannelMessageViews_ | import("../tl/2_types.js").UpdateChatParticipantAdmin_ | import("../tl/2_types.js").UpdateNewStickerSet_ | import("../tl/2_types.js").UpdateStickerSetsOrder_ | import("../tl/2_types.js").UpdateStickerSets_ | import("../tl/2_types.js").UpdateSavedGifs_ | import("../tl/2_types.js").UpdateBotInlineQuery_ | import("../tl/2_types.js").UpdateBotInlineSend_ | import("../tl/2_types.js").UpdateEditChannelMessage_ | import("../tl/2_types.js").UpdateBotCallbackQuery_ | import("../tl/2_types.js").UpdateEditMessage_ | import("../tl/2_types.js").UpdateInlineBotCallbackQuery_ | import("../tl/2_types.js").UpdateReadChannelOutbox_ | import("../tl/2_types.js").UpdateDraftMessage_ | import("../tl/2_types.js").UpdateReadFeaturedStickers_ | import("../tl/2_types.js").UpdateRecentStickers_ | import("../tl/2_types.js").UpdateConfig_ | import("../tl/2_types.js").UpdatePtsChanged_ | import("../tl/2_types.js").UpdateChannelWebPage_ | import("../tl/2_types.js").UpdateDialogPinned_ | import("../tl/2_types.js").UpdatePinnedDialogs_ | import("../tl/2_types.js").UpdateBotWebhookJSON_ | import("../tl/2_types.js").UpdateBotWebhookJSONQuery_ | import("../tl/2_types.js").UpdateBotShippingQuery_ | import("../tl/2_types.js").UpdateBotPrecheckoutQuery_ | import("../tl/2_types.js").UpdatePhoneCall_ | import("../tl/2_types.js").UpdateLangPackTooLong_ | import("../tl/2_types.js").UpdateLangPack_ | import("../tl/2_types.js").UpdateFavedStickers_ | import("../tl/2_types.js").UpdateChannelReadMessagesContents_ | import("../tl/2_types.js").UpdateContactsReset_ | import("../tl/2_types.js").UpdateChannelAvailableMessages_ | import("../tl/2_types.js").UpdateDialogUnreadMark_ | import("../tl/2_types.js").UpdateMessagePoll_ | import("../tl/2_types.js").UpdateChatDefaultBannedRights_ | import("../tl/2_types.js").UpdateFolderPeers_ | import("../tl/2_types.js").UpdatePeerSettings_ | import("../tl/2_types.js").UpdatePeerLocated_ | import("../tl/2_types.js").UpdateNewScheduledMessage_ | import("../tl/2_types.js").UpdateDeleteScheduledMessages_ | import("../tl/2_types.js").UpdateTheme_ | import("../tl/2_types.js").UpdateGeoLiveViewed_ | import("../tl/2_types.js").UpdateLoginToken_ | import("../tl/2_types.js").UpdateMessagePollVote_ | import("../tl/2_types.js").UpdateDialogFilter_ | import("../tl/2_types.js").UpdateDialogFilterOrder_ | import("../tl/2_types.js").UpdateDialogFilters_ | import("../tl/2_types.js").UpdatePhoneCallSignalingData_ | import("../tl/2_types.js").UpdateChannelMessageForwards_ | import("../tl/2_types.js").UpdateReadChannelDiscussionInbox_ | import("../tl/2_types.js").UpdateReadChannelDiscussionOutbox_ | import("../tl/2_types.js").UpdatePeerBlocked_ | import("../tl/2_types.js").UpdateChannelUserTyping_ | import("../tl/2_types.js").UpdatePinnedMessages_ | import("../tl/2_types.js").UpdatePinnedChannelMessages_ | import("../tl/2_types.js").UpdateChat_ | import("../tl/2_types.js").UpdateGroupCallParticipants_ | import("../tl/2_types.js").UpdateGroupCall_ | import("../tl/2_types.js").UpdatePeerHistoryTTL_ | import("../tl/2_types.js").UpdateChatParticipant_ | import("../tl/2_types.js").UpdateChannelParticipant_ | import("../tl/2_types.js").UpdateBotStopped_ | import("../tl/2_types.js").UpdateGroupCallConnection_ | import("../tl/2_types.js").UpdateBotCommands_ | import("../tl/2_types.js").UpdatePendingJoinRequests_ | import("../tl/2_types.js").UpdateBotChatInviteRequester_ | import("../tl/2_types.js").UpdateMessageReactions_ | import("../tl/2_types.js").UpdateAttachMenuBots_ | import("../tl/2_types.js").UpdateWebViewResultSent_ | import("../tl/2_types.js").UpdateBotMenuButton_ | import("../tl/2_types.js").UpdateSavedRingtones_ | import("../tl/2_types.js").UpdateTranscribedAudio_ | import("../tl/2_types.js").UpdateReadFeaturedEmojiStickers_ | import("../tl/2_types.js").UpdateUserEmojiStatus_ | import("../tl/2_types.js").UpdateRecentEmojiStatuses_ | import("../tl/2_types.js").UpdateRecentReactions_ | import("../tl/2_types.js").UpdateMoveStickerSetToTop_ | import("../tl/2_types.js").UpdateMessageExtendedMedia_ | import("../tl/2_types.js").UpdateChannelPinnedTopic_ | import("../tl/2_types.js").UpdateChannelPinnedTopics_ | import("../tl/2_types.js").UpdateUser_ | import("../tl/2_types.js").UpdateAutoSaveSettings_ | import("../tl/2_types.js").UpdateGroupInvitePrivacyForbidden_ | import("../tl/2_types.js").UpdateStory_ | import("../tl/2_types.js").UpdateReadStories_ | import("../tl/2_types.js").UpdateStoryID_ | import("../tl/2_types.js").UpdateStoriesStealthMode_ | import("../tl/2_types.js").UpdateSentStoryReaction_ | import("../tl/2_types.js").UpdateBotChatBoost_ | import("../tl/2_types.js").UpdateChannelViewForumAsMessages_ | import("../tl/2_types.js").UpdatePeerWallpaper_ | import("../tl/2_types.js").UpdateBotMessageReaction_ | import("../tl/2_types.js").UpdateBotMessageReactions_] | null>;
|
|
76
79
|
}
|
package/esm/storage/0_storage.js
CHANGED
|
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _Storage_instances,
|
|
12
|
+
var _Storage_instances, _Storage_authKeyId, _Storage_resetAuthKeyId, _Storage_getEntityType, _Storage_getUpdateId;
|
|
13
13
|
import { bigIntFromBuffer, rleDecode, rleEncode, sha1, UNREACHABLE, ZERO_CHANNEL_ID } from "../1_utilities.js";
|
|
14
14
|
import { serialize, TLReader, types } from "../2_tl.js";
|
|
15
15
|
const KPARTS__DC = ["dc"];
|
|
@@ -24,6 +24,7 @@ const KPARTS__ACCOUNT_TYPE = ["accountType"];
|
|
|
24
24
|
const KPARTS__STICKER_SET_NAME = (id, accessHash) => ["stickerSetName", id, accessHash];
|
|
25
25
|
const KPARTS_MESSAGE = (chatId, messageId) => ["messages", chatId, messageId];
|
|
26
26
|
const KPARTS_MESSAGES = (chatId) => ["messages", chatId];
|
|
27
|
+
const KPARTS_ALL_MESSAGE_REFS = ["messageRefs"];
|
|
27
28
|
const KPARTS_MESSAGE_REF = (messageId) => ["messageRefs", messageId];
|
|
28
29
|
const KPARTS_HAS_ALL_CHATS = (listId) => ["hasAllChats", listId];
|
|
29
30
|
const KPARTS_CHATS = (listId) => ["chats", listId];
|
|
@@ -33,10 +34,13 @@ const KPARTS_SERVER_SALT = ["serverSalt"];
|
|
|
33
34
|
const KPARTS_FILE = (fileId) => ["files", fileId];
|
|
34
35
|
const KPARTS_FILE_PART = (fileId, n) => ["fileParts", fileId, n];
|
|
35
36
|
const KPARTS_CEMOJI = (id) => ["customEmojiDocuments", id];
|
|
37
|
+
const KPARTS_ALL_UPDATES = ["updates"];
|
|
38
|
+
const KPARTS_UPDATES = (boxId) => ["updates", boxId];
|
|
39
|
+
const KPARTS_UPDATE = (boxId, id) => ["updates", boxId, id];
|
|
36
40
|
export class Storage {
|
|
37
41
|
constructor() {
|
|
38
42
|
_Storage_instances.add(this);
|
|
39
|
-
|
|
43
|
+
_Storage_authKeyId.set(this, null);
|
|
40
44
|
}
|
|
41
45
|
setDc(dc) {
|
|
42
46
|
return this.set(KPARTS__DC, dc);
|
|
@@ -54,7 +58,7 @@ export class Storage {
|
|
|
54
58
|
await __classPrivateFieldGet(this, _Storage_instances, "m", _Storage_resetAuthKeyId).call(this, authKey);
|
|
55
59
|
}
|
|
56
60
|
get authKeyId() {
|
|
57
|
-
return __classPrivateFieldGet(this,
|
|
61
|
+
return __classPrivateFieldGet(this, _Storage_authKeyId, "f");
|
|
58
62
|
}
|
|
59
63
|
setChannelAccessHash(id, accessHash) {
|
|
60
64
|
return this.set(KPARTS__CHANNEL_ACCESS_HASH(id), accessHash);
|
|
@@ -109,7 +113,7 @@ export class Storage {
|
|
|
109
113
|
}
|
|
110
114
|
async deleteMessages() {
|
|
111
115
|
const maybePromises = new Array();
|
|
112
|
-
for await (const [k, o] of await this.getMany({ prefix:
|
|
116
|
+
for await (const [k, o] of await this.getMany({ prefix: KPARTS_ALL_MESSAGE_REFS })) {
|
|
113
117
|
maybePromises.push(Promise.all([this.set(k, null), o == null ? Promise.resolve() : this.set(KPARTS_MESSAGE(o, k[1]), null)]).then(() => { }));
|
|
114
118
|
}
|
|
115
119
|
await Promise.all(maybePromises.filter((v) => v instanceof Promise));
|
|
@@ -268,13 +272,29 @@ export class Storage {
|
|
|
268
272
|
return null;
|
|
269
273
|
}
|
|
270
274
|
}
|
|
275
|
+
async setUpdate(boxId, update) {
|
|
276
|
+
await this.setTlObject(KPARTS_UPDATE(boxId, __classPrivateFieldGet(this, _Storage_instances, "m", _Storage_getUpdateId).call(this, update)), update);
|
|
277
|
+
}
|
|
278
|
+
async deleteUpdates() {
|
|
279
|
+
const maybePromises = new Array();
|
|
280
|
+
for await (const [k] of await this.getMany({ prefix: KPARTS_ALL_UPDATES })) {
|
|
281
|
+
maybePromises.push(this.set(k, null));
|
|
282
|
+
}
|
|
283
|
+
await Promise.all(maybePromises.filter((v) => v instanceof Promise));
|
|
284
|
+
}
|
|
285
|
+
async getFirstUpdate(boxId) {
|
|
286
|
+
for await (const [key, update] of await this.getMany({ prefix: KPARTS_UPDATES(boxId) }, { limit: 1 })) {
|
|
287
|
+
return [key, await this.getTlObject(update).then((v) => v)];
|
|
288
|
+
}
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
271
291
|
}
|
|
272
|
-
|
|
292
|
+
_Storage_authKeyId = new WeakMap(), _Storage_instances = new WeakSet(), _Storage_resetAuthKeyId = async function _Storage_resetAuthKeyId(authKey) {
|
|
273
293
|
if (authKey != null) {
|
|
274
|
-
__classPrivateFieldSet(this,
|
|
294
|
+
__classPrivateFieldSet(this, _Storage_authKeyId, await sha1(authKey).then((hash) => bigIntFromBuffer(hash.slice(-8), true, false)), "f");
|
|
275
295
|
}
|
|
276
296
|
else {
|
|
277
|
-
__classPrivateFieldSet(this,
|
|
297
|
+
__classPrivateFieldSet(this, _Storage_authKeyId, null, "f");
|
|
278
298
|
}
|
|
279
299
|
}, _Storage_getEntityType = function _Storage_getEntityType(entity) {
|
|
280
300
|
if (entity instanceof types.Channel || entity instanceof types.ChannelForbidden) {
|
|
@@ -289,4 +309,13 @@ _Storage__authKeyId = new WeakMap(), _Storage_instances = new WeakSet(), _Storag
|
|
|
289
309
|
else {
|
|
290
310
|
UNREACHABLE();
|
|
291
311
|
}
|
|
312
|
+
}, _Storage_getUpdateId = function _Storage_getUpdateId(update) {
|
|
313
|
+
let id = BigInt(Date.now()) << 32n;
|
|
314
|
+
if ("pts" in update && update.pts) {
|
|
315
|
+
id |= BigInt(update.pts);
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
id |= BigInt(0xffffffffn);
|
|
319
|
+
}
|
|
320
|
+
return id;
|
|
292
321
|
};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { GetManyFilter, Storage, StorageKeyPart } from "./0_storage.js";
|
|
2
|
+
export interface StorageIndexedDBParams {
|
|
3
|
+
/** Whether to store files. Defaults to true. */
|
|
4
|
+
fileStorage?: boolean;
|
|
5
|
+
}
|
|
2
6
|
export declare class StorageIndexedDB extends Storage {
|
|
3
7
|
#private;
|
|
4
8
|
database: IDBDatabase | null;
|
|
5
|
-
constructor(name: string);
|
|
9
|
+
constructor(name: string, params?: StorageIndexedDBParams);
|
|
6
10
|
get name(): string;
|
|
7
11
|
branch(id: string): StorageIndexedDB;
|
|
8
|
-
|
|
12
|
+
initialize(): Promise<void>;
|
|
9
13
|
get supportsFiles(): boolean;
|
|
10
14
|
set(k: readonly StorageKeyPart[], v: unknown, tx_?: IDBTransaction): Promise<void>;
|
|
11
15
|
get<T>(k: readonly StorageKeyPart[], tx_?: IDBTransaction | null, fix?: boolean): Promise<T | null>;
|
|
@@ -9,13 +9,13 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _StorageIndexedDB_instances, _StorageIndexedDB_name, _StorageIndexedDB_id, _StorageIndexedDB_fixKey;
|
|
12
|
+
var _StorageIndexedDB_instances, _StorageIndexedDB_name, _StorageIndexedDB_id, _StorageIndexedDB_supportsFiles, _StorageIndexedDB_fixKey;
|
|
13
13
|
import { Storage } from "./0_storage.js";
|
|
14
14
|
import { fixKey, getPrefixKeyRange, restoreKey } from "./0_utilities.js";
|
|
15
15
|
const VERSION = 1;
|
|
16
16
|
const KV_OBJECT_STORE = "kv";
|
|
17
17
|
export class StorageIndexedDB extends Storage {
|
|
18
|
-
constructor(name) {
|
|
18
|
+
constructor(name, params) {
|
|
19
19
|
if (typeof indexedDB == "undefined") {
|
|
20
20
|
throw new Error("Unavailable in current environment");
|
|
21
21
|
}
|
|
@@ -29,7 +29,9 @@ export class StorageIndexedDB extends Storage {
|
|
|
29
29
|
});
|
|
30
30
|
_StorageIndexedDB_name.set(this, void 0);
|
|
31
31
|
_StorageIndexedDB_id.set(this, null);
|
|
32
|
+
_StorageIndexedDB_supportsFiles.set(this, void 0);
|
|
32
33
|
__classPrivateFieldSet(this, _StorageIndexedDB_name, name, "f");
|
|
34
|
+
__classPrivateFieldSet(this, _StorageIndexedDB_supportsFiles, params?.fileStorage ?? true, "f");
|
|
33
35
|
}
|
|
34
36
|
get name() {
|
|
35
37
|
return __classPrivateFieldGet(this, _StorageIndexedDB_name, "f");
|
|
@@ -39,7 +41,7 @@ export class StorageIndexedDB extends Storage {
|
|
|
39
41
|
__classPrivateFieldSet(storage, _StorageIndexedDB_id, id, "f");
|
|
40
42
|
return storage;
|
|
41
43
|
}
|
|
42
|
-
|
|
44
|
+
initialize() {
|
|
43
45
|
const db = indexedDB.open(this.name, VERSION);
|
|
44
46
|
return new Promise((res, rej) => {
|
|
45
47
|
db.onblocked = rej;
|
|
@@ -54,7 +56,7 @@ export class StorageIndexedDB extends Storage {
|
|
|
54
56
|
});
|
|
55
57
|
}
|
|
56
58
|
get supportsFiles() {
|
|
57
|
-
return
|
|
59
|
+
return __classPrivateFieldGet(this, _StorageIndexedDB_supportsFiles, "f");
|
|
58
60
|
}
|
|
59
61
|
set(k, v, tx_) {
|
|
60
62
|
k = __classPrivateFieldGet(this, _StorageIndexedDB_instances, "m", _StorageIndexedDB_fixKey).call(this, k);
|
|
@@ -155,7 +157,7 @@ export class StorageIndexedDB extends Storage {
|
|
|
155
157
|
await this.set(key, (currentValue || 0) + by, tx);
|
|
156
158
|
}
|
|
157
159
|
}
|
|
158
|
-
_StorageIndexedDB_name = new WeakMap(), _StorageIndexedDB_id = new WeakMap(), _StorageIndexedDB_instances = new WeakSet(), _StorageIndexedDB_fixKey = function _StorageIndexedDB_fixKey(key) {
|
|
160
|
+
_StorageIndexedDB_name = new WeakMap(), _StorageIndexedDB_id = new WeakMap(), _StorageIndexedDB_supportsFiles = new WeakMap(), _StorageIndexedDB_instances = new WeakSet(), _StorageIndexedDB_fixKey = function _StorageIndexedDB_fixKey(key) {
|
|
159
161
|
if (__classPrivateFieldGet(this, _StorageIndexedDB_id, "f") !== null) {
|
|
160
162
|
return ["__S" + __classPrivateFieldGet(this, _StorageIndexedDB_id, "f"), ...key];
|
|
161
163
|
}
|
|
@@ -4,7 +4,7 @@ export declare class StorageLocalStorage extends Storage implements Storage {
|
|
|
4
4
|
constructor(prefix: string);
|
|
5
5
|
get prefix(): string;
|
|
6
6
|
branch(id: string): StorageLocalStorage;
|
|
7
|
-
|
|
7
|
+
initialize(): void;
|
|
8
8
|
get supportsFiles(): boolean;
|
|
9
9
|
get<T>(key_: readonly StorageKeyPart[]): T | null;
|
|
10
10
|
getMany<T>(filter: GetManyFilter, params?: {
|
|
@@ -3,7 +3,7 @@ import { GetManyFilter, Storage, StorageKeyPart } from "./0_storage.js";
|
|
|
3
3
|
export declare class StorageMemory extends Storage implements Storage {
|
|
4
4
|
#private;
|
|
5
5
|
protected map: Map<string, unknown>;
|
|
6
|
-
|
|
6
|
+
initialize(): void;
|
|
7
7
|
branch(id: string): Storage;
|
|
8
8
|
get supportsFiles(): boolean;
|
|
9
9
|
get<T>(key: readonly StorageKeyPart[]): NonNullable<T> | null;
|
|
@@ -5,7 +5,7 @@ export declare class StorageSessionStorage extends Storage implements Storage {
|
|
|
5
5
|
constructor(prefix: string);
|
|
6
6
|
get prefix(): string;
|
|
7
7
|
branch(id: string): StorageSessionStorage;
|
|
8
|
-
|
|
8
|
+
initialize(): void;
|
|
9
9
|
get supportsFiles(): boolean;
|
|
10
10
|
get<T>(key_: readonly StorageKeyPart[]): T | null;
|
|
11
11
|
getMany<T>(filter: GetManyFilter, params?: {
|