@mtkruto/node 0.100.0 → 0.100.2

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.
Files changed (41) hide show
  1. package/esm/3_types.d.ts +1 -0
  2. package/esm/3_types.d.ts.map +1 -1
  3. package/esm/3_types.js +1 -0
  4. package/esm/client/1_client_generic.d.ts +7 -0
  5. package/esm/client/1_client_generic.d.ts.map +1 -1
  6. package/esm/client/4_chat_list_manager.d.ts +1 -0
  7. package/esm/client/4_chat_list_manager.d.ts.map +1 -1
  8. package/esm/client/4_chat_list_manager.js +13 -2
  9. package/esm/client/5_client.d.ts +7 -0
  10. package/esm/client/5_client.d.ts.map +1 -1
  11. package/esm/client/5_client.js +9 -0
  12. package/esm/client/5_client_dispatcher.d.ts +7 -0
  13. package/esm/client/5_client_dispatcher.d.ts.map +1 -1
  14. package/esm/client/5_client_dispatcher.js +9 -0
  15. package/esm/types/0_chat_folder.d.ts +26 -0
  16. package/esm/types/0_chat_folder.d.ts.map +1 -0
  17. package/esm/types/0_chat_folder.js +25 -0
  18. package/esm/types/7_chat_list_item.d.ts +7 -7
  19. package/esm/types/7_chat_list_item.d.ts.map +1 -1
  20. package/esm/types/7_chat_list_item.js +20 -50
  21. package/package.json +1 -1
  22. package/script/3_types.d.ts +1 -0
  23. package/script/3_types.d.ts.map +1 -1
  24. package/script/3_types.js +1 -0
  25. package/script/client/1_client_generic.d.ts +7 -0
  26. package/script/client/1_client_generic.d.ts.map +1 -1
  27. package/script/client/4_chat_list_manager.d.ts +1 -0
  28. package/script/client/4_chat_list_manager.d.ts.map +1 -1
  29. package/script/client/4_chat_list_manager.js +12 -1
  30. package/script/client/5_client.d.ts +7 -0
  31. package/script/client/5_client.d.ts.map +1 -1
  32. package/script/client/5_client.js +9 -0
  33. package/script/client/5_client_dispatcher.d.ts +7 -0
  34. package/script/client/5_client_dispatcher.d.ts.map +1 -1
  35. package/script/client/5_client_dispatcher.js +9 -0
  36. package/script/types/0_chat_folder.d.ts +26 -0
  37. package/script/types/0_chat_folder.d.ts.map +1 -0
  38. package/script/types/0_chat_folder.js +28 -0
  39. package/script/types/7_chat_list_item.d.ts +7 -7
  40. package/script/types/7_chat_list_item.d.ts.map +1 -1
  41. package/script/types/7_chat_list_item.js +20 -54
@@ -0,0 +1,26 @@
1
+ /**
2
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
+ * Copyright (C) 2023-2026 Roj <https://roj.im/>
4
+ *
5
+ * This file is part of MTKruto.
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
+ */
20
+ import type { Api } from "../2_tl.js";
21
+ export interface ChatFolder {
22
+ id: number;
23
+ title: string;
24
+ }
25
+ export declare function constructChatFolder(folder: Api.Folder): ChatFolder;
26
+ //# sourceMappingURL=0_chat_folder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"0_chat_folder.d.ts","sourceRoot":"","sources":["../../src/types/0_chat_folder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,UAAU,CAKlE"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /**
3
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
4
+ * Copyright (C) 2023-2026 Roj <https://roj.im/>
5
+ *
6
+ * This file is part of MTKruto.
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU Lesser General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU Lesser General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU Lesser General Public License
19
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+ */
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.constructChatFolder = constructChatFolder;
23
+ function constructChatFolder(folder) {
24
+ return {
25
+ id: folder.id,
26
+ title: folder.title,
27
+ };
28
+ }
@@ -18,18 +18,18 @@
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
20
  import { Api } from "../2_tl.js";
21
+ import { type ChatFolder } from "./0_chat_folder.js";
21
22
  import { type ChatP, type PeerGetter } from "./1_chat_p.js";
22
23
  import type { StickerSetNameGetter } from "./1_sticker.js";
23
24
  import { type Message, type MessageGetter } from "./6_message.js";
24
25
  export interface ChatListItem {
26
+ folder?: ChatFolder;
25
27
  chat: ChatP;
26
- order: string;
27
- pinned: number;
28
28
  lastMessage?: Omit<Message, "replyToMessage">;
29
+ unreadChatCount?: number;
30
+ unreadMessageCount?: number;
31
+ unreadMutedChatCount?: number;
32
+ unreadMutedMessageCount?: number;
29
33
  }
30
- export declare function getChatListItemOrder(lastMessage: Omit<Message, "replyToMessage"> | undefined, pinned: number): string;
31
- export declare function constructChatListItem(chatId: number, pinned: number, lastMessageId: number, getPeer: PeerGetter, getMessage: MessageGetter): Promise<ChatListItem | null>;
32
- export declare function constructChatListItem2(entity: Api.user | Api.chat | Api.chatForbidden | Api.channel | Api.channelForbidden, pinned: number, lastMessage: Omit<Message, "replyToMessage"> | undefined): ChatListItem;
33
- export declare function constructChatListItem3(chatId: number, pinned: number, lastMessage: Omit<Message, "replyToMessage"> | undefined, getPeer: PeerGetter): ChatListItem | null;
34
- export declare function constructChatListItem4(dialog: Api.Dialog, dialogs: Api.messages_dialogs | Api.messages_dialogsSlice, pinnedChats: number[], getPeer: PeerGetter, getMessage: MessageGetter, getStickerSetName: StickerSetNameGetter): Promise<ChatListItem>;
34
+ export declare function constructChatListItem(dialog: Api.Dialog, dialogs: Api.messages_dialogs | Api.messages_dialogsSlice | Api.messages_peerDialogs, getPeer: PeerGetter, getMessage: MessageGetter, getStickerSetName: StickerSetNameGetter): Promise<ChatListItem>;
35
35
  //# sourceMappingURL=7_chat_list_item.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"7_chat_list_item.d.ts","sourceRoot":"","sources":["../../src/types/7_chat_list_item.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,KAAK,KAAK,EAAkB,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAoB,KAAK,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpF,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;CAC/C;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,EAAE,gBAAgB,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMrH;AAED,wBAAsB,qBAAqB,CAAC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EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAoB,KAAK,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpF,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,IAAI,EAAE,KAAK,CAAC;IACZ,WAAW,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IAC9C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,gBAAgB,GAAG,GAAG,CAAC,qBAAqB,GAAG,GAAG,CAAC,oBAAoB,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,iBAAiB,EAAE,oBAAoB,GAAG,OAAO,CAAC,YAAY,CAAC,CAgCpQ"}
@@ -19,65 +19,16 @@
19
19
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
20
  */
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.getChatListItemOrder = getChatListItemOrder;
23
22
  exports.constructChatListItem = constructChatListItem;
24
- exports.constructChatListItem2 = constructChatListItem2;
25
- exports.constructChatListItem3 = constructChatListItem3;
26
- exports.constructChatListItem4 = constructChatListItem4;
27
23
  const _0_deps_js_1 = require("../0_deps.js");
28
24
  const _1_utilities_js_1 = require("../1_utilities.js");
29
25
  const _2_tl_js_1 = require("../2_tl.js");
26
+ const _0_chat_folder_js_1 = require("./0_chat_folder.js");
30
27
  const _1_chat_p_js_1 = require("./1_chat_p.js");
31
28
  const _6_message_js_1 = require("./6_message.js");
32
- function getChatListItemOrder(lastMessage, pinned) {
33
- const p = pinned === -1 ? "" : `P${100 - pinned}`;
34
- if (!lastMessage) {
35
- return p + "0";
36
- }
37
- return p + String((BigInt(Math.floor(lastMessage.date)) << 32n) + BigInt(lastMessage.id));
38
- }
39
- async function constructChatListItem(chatId, pinned, lastMessageId, getPeer, getMessage) {
40
- const peer = getPeer(_2_tl_js_1.Api.chatIdToPeer(chatId));
41
- if (peer === null) {
42
- return null;
43
- }
44
- const lastMessage_ = lastMessageId > 0 ? await getMessage(chatId, lastMessageId) : null;
45
- const lastMessage = lastMessage_ === null ? undefined : lastMessage_;
46
- return (0, _1_utilities_js_1.cleanObject)({
47
- chat: peer[0],
48
- order: getChatListItemOrder(lastMessage, pinned),
49
- pinned,
50
- lastMessage,
51
- });
52
- }
53
- function constructChatListItem2(entity, pinned, lastMessage) {
54
- return (0, _1_utilities_js_1.cleanObject)({
55
- chat: (0, _1_chat_p_js_1.constructChatP)(entity),
56
- order: getChatListItemOrder(lastMessage, pinned),
57
- pinned,
58
- lastMessage,
59
- });
60
- }
61
- function constructChatListItem3(chatId, pinned, lastMessage, getPeer) {
62
- const chat = getPeer(_2_tl_js_1.Api.chatIdToPeer(chatId));
63
- if (chat === null) {
64
- return null;
65
- }
66
- return (0, _1_utilities_js_1.cleanObject)({
67
- chat: chat[0],
68
- order: getChatListItemOrder(lastMessage, pinned),
69
- pinned,
70
- lastMessage,
71
- });
72
- }
73
- async function constructChatListItem4(dialog, dialogs, pinnedChats, getPeer, getMessage, getStickerSetName) {
29
+ async function constructChatListItem(dialog, dialogs, getPeer, getMessage, getStickerSetName) {
74
30
  const topMessage_ = dialogs.messages.find((v) => "id" in v && v.id === dialog.top_message);
75
- if (!topMessage_) {
76
- (0, _0_deps_js_1.unreachable)();
77
- }
78
- const pinned = pinnedChats.indexOf(_2_tl_js_1.Api.peerToChatId(dialog.peer));
79
- const lastMessage = await (0, _6_message_js_1.constructMessage)(topMessage_, getPeer, getMessage, getStickerSetName, false);
80
- const order = getChatListItemOrder(lastMessage, pinned);
31
+ const lastMessage = topMessage_ ? await (0, _6_message_js_1.constructMessage)(topMessage_, getPeer, getMessage, getStickerSetName, false) : undefined;
81
32
  const userId = "user_id" in dialog.peer ? dialog.peer.user_id : null;
82
33
  const chatId = "chat_id" in dialog.peer ? dialog.peer.chat_id : null;
83
34
  const channelId = "channel_id" in dialog.peer ? dialog.peer.channel_id : null;
@@ -85,10 +36,25 @@ async function constructChatListItem4(dialog, dialogs, pinnedChats, getPeer, get
85
36
  if (!chat__) {
86
37
  (0, _0_deps_js_1.unreachable)();
87
38
  }
39
+ let folder;
40
+ let unreadChatCount;
41
+ let unreadMessageCount;
42
+ let unreadMutedChatCount;
43
+ let unreadMutedMessageCount;
44
+ if (_2_tl_js_1.Api.is("dialogFolder", dialog)) {
45
+ folder = (0, _0_chat_folder_js_1.constructChatFolder)(dialog.folder);
46
+ unreadChatCount = dialog.unread_unmuted_peers_count;
47
+ unreadMessageCount = dialog.unread_unmuted_messages_count;
48
+ unreadMutedChatCount = dialog.unread_muted_peers_count;
49
+ unreadMutedMessageCount = dialog.unread_muted_messages_count;
50
+ }
88
51
  return (0, _1_utilities_js_1.cleanObject)({
52
+ folder,
89
53
  chat: (0, _1_chat_p_js_1.constructChatP)(chat__),
90
- order,
91
54
  lastMessage,
92
- pinned,
55
+ unreadChatCount,
56
+ unreadMessageCount,
57
+ unreadMutedChatCount,
58
+ unreadMutedMessageCount,
93
59
  });
94
60
  }