@mtkruto/browser 0.1.500 → 0.1.700
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_types.d.ts +6 -1
- package/esm/3_types.js +6 -1
- package/esm/4_errors.js +2 -4
- package/esm/5_client.d.ts +1 -1
- package/esm/5_client.js +1 -1
- package/esm/client/0_params.d.ts +33 -7
- package/esm/client/0_storage_operations.d.ts +182 -0
- package/esm/client/0_storage_operations.js +611 -0
- package/esm/client/1_composer.d.ts +2 -0
- package/esm/client/1_composer.js +28 -0
- package/{script/client/0_types.d.ts → esm/client/1_types.d.ts} +3 -3
- package/{script/client/1_account_manager.d.ts → esm/client/2_account_manager.d.ts} +1 -1
- package/{script/client/1_bot_info_manager.d.ts → esm/client/2_bot_info_manager.d.ts} +1 -1
- package/esm/client/{1_business_connection_manager.d.ts → 2_business_connection_manager.d.ts} +1 -1
- package/{script/client/1_file_manager.d.ts → esm/client/2_file_manager.d.ts} +6 -2
- package/esm/client/{1_file_manager.js → 2_file_manager.js} +55 -52
- package/esm/client/{1_network_statistics_manager.d.ts → 2_network_statistics_manager.d.ts} +1 -1
- package/{script/client/1_reaction_manager.d.ts → esm/client/2_reaction_manager.d.ts} +1 -1
- package/{script/client/1_update_manager.d.ts → esm/client/2_update_manager.d.ts} +1 -1
- package/esm/client/{2_message_manager.d.ts → 3_message_manager.d.ts} +2 -2
- package/esm/client/3_video_chat_manager.d.ts +43 -0
- package/esm/client/3_video_chat_manager.js +194 -0
- package/{script/client/3_callback_query_manager.d.ts → esm/client/4_callback_query_manager.d.ts} +2 -2
- package/esm/client/{3_callback_query_manager.js → 4_callback_query_manager.js} +1 -0
- package/{script/client/3_chat_list_manager.d.ts → esm/client/4_chat_list_manager.d.ts} +6 -6
- package/esm/client/{3_chat_list_manager.js → 4_chat_list_manager.js} +75 -98
- package/esm/client/{3_inline_query_manager.d.ts → 4_inline_query_manager.d.ts} +2 -2
- package/esm/client/{3_inline_query_manager.js → 4_inline_query_manager.js} +1 -0
- package/esm/client/{3_story_manager.d.ts → 4_story_manager.d.ts} +3 -3
- package/{script/client/4_client.d.ts → esm/client/5_client.d.ts} +105 -31
- package/esm/client/{4_client.js → 5_client.js} +172 -73
- package/esm/connection/0_connection.d.ts +6 -15
- package/esm/connection/0_connection.js +1 -38
- package/esm/connection/1_connection_web_socket.d.ts +3 -2
- package/esm/connection/1_connection_web_socket.js +7 -3
- package/esm/mod.d.ts +1 -1
- package/esm/mod.js +1 -1
- package/esm/storage/0_storage.d.ts +9 -145
- package/esm/storage/0_storage.js +1 -526
- package/esm/storage/2_storage_indexed_db.d.ts +3 -2
- package/esm/storage/2_storage_indexed_db.js +9 -8
- package/esm/storage/2_storage_local_storage.d.ts +3 -2
- package/esm/storage/2_storage_local_storage.js +5 -4
- package/esm/storage/2_storage_memory.d.ts +4 -4
- package/esm/storage/2_storage_memory.js +12 -19
- package/esm/storage/2_storage_session_storage.d.ts +2 -1
- package/esm/storage/2_storage_session_storage.js +5 -4
- package/esm/tl/3_utilities.d.ts +1 -1
- package/esm/tl/3_utilities.js +3 -3
- package/esm/types/0_birthday.d.ts +27 -0
- package/esm/types/0_birthday.js +26 -0
- package/esm/types/0_giveaway_parameters.d.ts +1 -1
- package/esm/types/0_id.d.ts +1 -1
- package/esm/types/0_live_stream_channel.d.ts +30 -0
- package/esm/types/0_live_stream_channel.js +26 -0
- package/esm/types/0_opening_hours.d.ts +25 -0
- package/esm/types/0_opening_hours.js +25 -0
- package/esm/types/0_video_chat.d.ts +60 -0
- package/esm/types/0_video_chat.js +53 -0
- package/esm/types/1_chat_p.d.ts +4 -0
- package/esm/types/1_chat_p.js +1 -0
- package/esm/types/2_business_connection.d.ts +6 -0
- package/esm/types/2_chat.d.ts +62 -0
- package/esm/types/2_chat.js +66 -0
- package/esm/types/2_inactive_chat.d.ts +1 -1
- package/esm/types/2_invite_link.d.ts +1 -1
- package/esm/types/2_message_reaction_count.d.ts +1 -1
- package/esm/types/2_message_reactions.d.ts +1 -1
- package/esm/types/3_chat_member_updated.d.ts +1 -1
- package/esm/types/4_message.d.ts +3 -3
- package/esm/types/5_chat_list_item.d.ts +35 -0
- package/esm/types/5_chat_list_item.js +86 -0
- package/esm/types/6_update.d.ts +14 -5
- package/esm/types/_file_id.d.ts +1 -0
- package/esm/utilities/0_bigint.d.ts +1 -0
- package/esm/utilities/0_bigint.js +7 -3
- package/package.json +1 -1
- package/script/3_types.d.ts +6 -1
- package/script/3_types.js +6 -1
- package/script/4_errors.js +2 -4
- package/script/5_client.d.ts +1 -1
- package/script/5_client.js +1 -1
- package/script/client/0_params.d.ts +33 -7
- package/script/client/0_storage_operations.d.ts +182 -0
- package/script/client/0_storage_operations.js +615 -0
- package/script/client/1_composer.d.ts +2 -0
- package/script/client/1_composer.js +28 -0
- package/{esm/client/0_types.d.ts → script/client/1_types.d.ts} +3 -3
- package/{esm/client/1_account_manager.d.ts → script/client/2_account_manager.d.ts} +1 -1
- package/{esm/client/1_bot_info_manager.d.ts → script/client/2_bot_info_manager.d.ts} +1 -1
- package/script/client/{1_business_connection_manager.d.ts → 2_business_connection_manager.d.ts} +1 -1
- package/{esm/client/1_file_manager.d.ts → script/client/2_file_manager.d.ts} +6 -2
- package/script/client/{1_file_manager.js → 2_file_manager.js} +54 -51
- package/script/client/{1_network_statistics_manager.d.ts → 2_network_statistics_manager.d.ts} +1 -1
- package/{esm/client/1_reaction_manager.d.ts → script/client/2_reaction_manager.d.ts} +1 -1
- package/{esm/client/1_update_manager.d.ts → script/client/2_update_manager.d.ts} +1 -1
- package/script/client/{2_message_manager.d.ts → 3_message_manager.d.ts} +2 -2
- package/script/client/3_video_chat_manager.d.ts +43 -0
- package/script/client/3_video_chat_manager.js +198 -0
- package/{esm/client/3_callback_query_manager.d.ts → script/client/4_callback_query_manager.d.ts} +2 -2
- package/script/client/{3_callback_query_manager.js → 4_callback_query_manager.js} +1 -0
- package/{esm/client/3_chat_list_manager.d.ts → script/client/4_chat_list_manager.d.ts} +6 -6
- package/script/client/{3_chat_list_manager.js → 4_chat_list_manager.js} +72 -95
- package/script/client/{3_inline_query_manager.d.ts → 4_inline_query_manager.d.ts} +2 -2
- package/script/client/{3_inline_query_manager.js → 4_inline_query_manager.js} +1 -0
- package/script/client/{3_story_manager.d.ts → 4_story_manager.d.ts} +3 -3
- package/{esm/client/4_client.d.ts → script/client/5_client.d.ts} +105 -31
- package/script/client/{4_client.js → 5_client.js} +192 -93
- package/script/connection/0_connection.d.ts +6 -15
- package/script/connection/0_connection.js +0 -41
- package/script/connection/1_connection_web_socket.d.ts +3 -2
- package/script/connection/1_connection_web_socket.js +7 -3
- package/script/mod.d.ts +1 -1
- package/script/mod.js +1 -1
- package/script/storage/0_storage.d.ts +9 -145
- package/script/storage/0_storage.js +0 -528
- package/script/storage/2_storage_indexed_db.d.ts +3 -2
- package/script/storage/2_storage_indexed_db.js +9 -8
- package/script/storage/2_storage_local_storage.d.ts +3 -2
- package/script/storage/2_storage_local_storage.js +5 -4
- package/script/storage/2_storage_memory.d.ts +4 -4
- package/script/storage/2_storage_memory.js +12 -19
- package/script/storage/2_storage_session_storage.d.ts +2 -1
- package/script/storage/2_storage_session_storage.js +5 -4
- package/script/tl/3_utilities.d.ts +1 -1
- package/script/tl/3_utilities.js +3 -3
- package/script/types/0_birthday.d.ts +27 -0
- package/script/types/0_birthday.js +30 -0
- package/script/types/0_giveaway_parameters.d.ts +1 -1
- package/script/types/0_id.d.ts +1 -1
- package/script/types/0_live_stream_channel.d.ts +30 -0
- package/script/types/0_live_stream_channel.js +30 -0
- package/script/types/0_opening_hours.d.ts +25 -0
- package/script/types/0_opening_hours.js +29 -0
- package/script/types/0_video_chat.d.ts +60 -0
- package/script/types/0_video_chat.js +57 -0
- package/script/types/1_chat_p.d.ts +4 -0
- package/script/types/1_chat_p.js +1 -0
- package/script/types/2_business_connection.d.ts +6 -0
- package/script/types/2_chat.d.ts +62 -0
- package/script/types/2_chat.js +70 -0
- package/script/types/2_inactive_chat.d.ts +1 -1
- package/script/types/2_invite_link.d.ts +1 -1
- package/script/types/2_message_reaction_count.d.ts +1 -1
- package/script/types/2_message_reactions.d.ts +1 -1
- package/script/types/3_chat_member_updated.d.ts +1 -1
- package/script/types/4_message.d.ts +3 -3
- package/script/types/5_chat_list_item.d.ts +35 -0
- package/script/types/5_chat_list_item.js +94 -0
- package/script/types/6_update.d.ts +14 -5
- package/script/types/_file_id.d.ts +1 -0
- package/script/utilities/0_bigint.d.ts +1 -0
- package/script/utilities/0_bigint.js +7 -3
- package/esm/types/5_chat.d.ts +0 -59
- package/esm/types/5_chat.js +0 -126
- package/script/types/5_chat.d.ts +0 -59
- package/script/types/5_chat.js +0 -134
- /package/esm/{3_storage.d.ts → 2_storage.d.ts} +0 -0
- /package/esm/{3_storage.js → 2_storage.js} +0 -0
- /package/esm/client/{0_types.js → 1_types.js} +0 -0
- /package/esm/client/{1_account_manager.js → 2_account_manager.js} +0 -0
- /package/esm/client/{1_bot_info_manager.js → 2_bot_info_manager.js} +0 -0
- /package/esm/client/{1_business_connection_manager.js → 2_business_connection_manager.js} +0 -0
- /package/esm/client/{1_network_statistics_manager.js → 2_network_statistics_manager.js} +0 -0
- /package/esm/client/{1_reaction_manager.js → 2_reaction_manager.js} +0 -0
- /package/esm/client/{1_update_manager.js → 2_update_manager.js} +0 -0
- /package/esm/client/{2_message_manager.js → 3_message_manager.js} +0 -0
- /package/esm/client/{3_story_manager.js → 4_story_manager.js} +0 -0
- /package/script/{3_storage.d.ts → 2_storage.d.ts} +0 -0
- /package/script/{3_storage.js → 2_storage.js} +0 -0
- /package/script/client/{0_types.js → 1_types.js} +0 -0
- /package/script/client/{1_account_manager.js → 2_account_manager.js} +0 -0
- /package/script/client/{1_bot_info_manager.js → 2_bot_info_manager.js} +0 -0
- /package/script/client/{1_business_connection_manager.js → 2_business_connection_manager.js} +0 -0
- /package/script/client/{1_network_statistics_manager.js → 2_network_statistics_manager.js} +0 -0
- /package/script/client/{1_reaction_manager.js → 2_reaction_manager.js} +0 -0
- /package/script/client/{1_update_manager.js → 2_update_manager.js} +0 -0
- /package/script/client/{2_message_manager.js → 3_message_manager.js} +0 -0
- /package/script/client/{3_story_manager.js → 4_story_manager.js} +0 -0
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
20
|
import { ID } from "../3_types.js";
|
|
21
|
-
import { C } from "./
|
|
21
|
+
import { C } from "./1_types.js";
|
|
22
22
|
export declare class AccountManager {
|
|
23
23
|
#private;
|
|
24
24
|
constructor(c: C);
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { BotCommand } from "../3_types.js";
|
|
21
21
|
import { GetMyCommandsParams, SetMyCommandsParams } from "./0_params.js";
|
|
22
|
-
import { C } from "./
|
|
22
|
+
import { C } from "./1_types.js";
|
|
23
23
|
export declare class BotInfoManager {
|
|
24
24
|
#private;
|
|
25
25
|
constructor(c: C);
|
package/esm/client/{1_business_connection_manager.d.ts → 2_business_connection_manager.d.ts}
RENAMED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { enums, types } from "../2_tl.js";
|
|
21
21
|
import { Update } from "../3_types.js";
|
|
22
|
-
import { C } from "./
|
|
22
|
+
import { C } from "./1_types.js";
|
|
23
23
|
export type BusinessConnectionManagerUpdate = types.UpdateBotBusinessConnect;
|
|
24
24
|
export declare class BusinessConnectionManager {
|
|
25
25
|
#private;
|
|
@@ -17,14 +17,18 @@
|
|
|
17
17
|
* You should have received a copy of the GNU Lesser General Public License
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
|
-
import { types } from "../2_tl.js";
|
|
20
|
+
import { enums, types } from "../2_tl.js";
|
|
21
21
|
import { FileSource, Sticker } from "../3_types.js";
|
|
22
22
|
import { DownloadParams, UploadParams } from "./0_params.js";
|
|
23
|
-
import { C } from "./
|
|
23
|
+
import { C } from "./1_types.js";
|
|
24
24
|
export declare class FileManager {
|
|
25
25
|
#private;
|
|
26
26
|
constructor(c: C);
|
|
27
27
|
upload(file: FileSource, params?: UploadParams, checkName?: null | ((name: string) => string), allowStream?: boolean): Promise<import("../tl/2_types.js").InputFile_ | import("../tl/2_types.js").InputFileBig_>;
|
|
28
|
+
downloadInner(location: enums.InputFileLocation, dcId: number, params?: {
|
|
29
|
+
chunkSize?: number;
|
|
30
|
+
offset?: number;
|
|
31
|
+
}): AsyncGenerator<Uint8Array, void, unknown>;
|
|
28
32
|
static validateChunkSize(chunkSize: number, max: number): void;
|
|
29
33
|
download(fileId: string, params?: DownloadParams): AsyncGenerator<Uint8Array, void, unknown>;
|
|
30
34
|
getStickerSetName(inputStickerSet: types.InputStickerSetID, hash?: number): Promise<string>;
|
|
@@ -28,8 +28,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
28
28
|
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");
|
|
29
29
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
30
30
|
};
|
|
31
|
-
var _FileManager_instances, _a, _FileManager_c, _FileManager_Lupload, _FileManager_UPLOAD_MAX_CHUNK_SIZE, _FileManager_DOWNLOAD_MAX_CHUNK_SIZE, _FileManager_BIG_FILE_THRESHOLD, _FileManager_UPLOAD_REQUEST_PER_CONNECTION, _FileManager_uploadStream, _FileManager_uploadBuffer, _FileManager_handleUploadError, _FileManager_getFileContents,
|
|
32
|
-
import {
|
|
31
|
+
var _FileManager_instances, _a, _FileManager_c, _FileManager_Lupload, _FileManager_UPLOAD_MAX_CHUNK_SIZE, _FileManager_DOWNLOAD_MAX_CHUNK_SIZE, _FileManager_BIG_FILE_THRESHOLD, _FileManager_UPLOAD_REQUEST_PER_CONNECTION, _FileManager_uploadStream, _FileManager_uploadBuffer, _FileManager_handleUploadError, _FileManager_getFileContents, _FileManager_CUSTOM_EMOJI_TTL;
|
|
32
|
+
import { extension, path, unreachable } from "../0_deps.js";
|
|
33
33
|
import { InputError } from "../0_errors.js";
|
|
34
34
|
import { drop, getLogger, getRandomId, iterateReadableStream, kilobyte, megabyte, minute, mod, PartStream } from "../1_utilities.js";
|
|
35
35
|
import { as, types } from "../2_tl.js";
|
|
@@ -83,6 +83,51 @@ export class FileManager {
|
|
|
83
83
|
return new types.InputFileBig({ id: fileId, parts: result.parts, name });
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
+
async *downloadInner(location, dcId, params) {
|
|
87
|
+
const id = "id" in location ? location.id : "photo_id" in location ? location.photo_id : null;
|
|
88
|
+
if (id != null && __classPrivateFieldGet(this, _FileManager_c, "f").storage.supportsFiles) {
|
|
89
|
+
const file = await __classPrivateFieldGet(this, _FileManager_c, "f").storage.getFile(id);
|
|
90
|
+
const partOffset = file == null ? 0 : params?.offset ? Math.ceil(10 / file[1]) - 1 : 0;
|
|
91
|
+
if (file != null && file[0] > 0) {
|
|
92
|
+
yield* __classPrivateFieldGet(this, _FileManager_c, "f").storage.iterFileParts(id, file[0], partOffset);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const chunkSize = params?.chunkSize ?? __classPrivateFieldGet(_a, _a, "f", _FileManager_DOWNLOAD_MAX_CHUNK_SIZE);
|
|
97
|
+
_a.validateChunkSize(chunkSize, __classPrivateFieldGet(_a, _a, "f", _FileManager_DOWNLOAD_MAX_CHUNK_SIZE));
|
|
98
|
+
const connection = __classPrivateFieldGet(this, _FileManager_c, "f").getCdnConnection(dcId);
|
|
99
|
+
await connection.connect();
|
|
100
|
+
const limit = chunkSize;
|
|
101
|
+
let offset = params?.offset ? BigInt(params.offset) : 0n;
|
|
102
|
+
let part = 0;
|
|
103
|
+
try {
|
|
104
|
+
while (true) {
|
|
105
|
+
const file = await connection.api.upload.getFile({ location, offset, limit });
|
|
106
|
+
if (file instanceof types.upload.File) {
|
|
107
|
+
yield file.bytes;
|
|
108
|
+
if (id != null) {
|
|
109
|
+
await __classPrivateFieldGet(this, _FileManager_c, "f").storage.saveFilePart(id, part, file.bytes);
|
|
110
|
+
}
|
|
111
|
+
++part;
|
|
112
|
+
if (file.bytes.length < limit) {
|
|
113
|
+
if (id != null) {
|
|
114
|
+
await __classPrivateFieldGet(this, _FileManager_c, "f").storage.setFilePartCount(id, part + 1, chunkSize);
|
|
115
|
+
}
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
offset += BigInt(file.bytes.length);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
unreachable();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
drop(connection.disconnect());
|
|
129
|
+
}
|
|
130
|
+
}
|
|
86
131
|
static validateChunkSize(chunkSize, max) {
|
|
87
132
|
if (chunkSize <= 0) {
|
|
88
133
|
throw new InputError("chunkSize must be bigger than zero.");
|
|
@@ -108,7 +153,7 @@ export class FileManager {
|
|
|
108
153
|
const big = fileId_.location.source.type == PhotoSourceType.ChatPhotoBig;
|
|
109
154
|
const peer = await __classPrivateFieldGet(this, _FileManager_c, "f").getInputPeer(Number(fileId_.location.source.chatId)); // TODO: use access hash from source?
|
|
110
155
|
const location = new types.InputPeerPhotoFileLocation({ big: big ? true : undefined, peer, photo_id: fileId_.location.id });
|
|
111
|
-
yield*
|
|
156
|
+
yield* this.downloadInner(location, fileId_.dcId, params);
|
|
112
157
|
break;
|
|
113
158
|
}
|
|
114
159
|
case FileType.Photo: {
|
|
@@ -118,7 +163,7 @@ export class FileManager {
|
|
|
118
163
|
file_reference: fileId_.fileReference ?? new Uint8Array(),
|
|
119
164
|
thumb_size: "thumbnailType" in fileId_.location.source ? String.fromCharCode(fileId_.location.source.thumbnailType) : "",
|
|
120
165
|
});
|
|
121
|
-
yield*
|
|
166
|
+
yield* this.downloadInner(location, fileId_.dcId, params);
|
|
122
167
|
break;
|
|
123
168
|
}
|
|
124
169
|
case FileType.Thumbnail: {
|
|
@@ -128,7 +173,7 @@ export class FileManager {
|
|
|
128
173
|
file_reference: fileId_.fileReference ?? new Uint8Array(),
|
|
129
174
|
thumb_size: "thumbnailType" in fileId_.location.source ? String.fromCharCode(fileId_.location.source.thumbnailType) : unreachable(),
|
|
130
175
|
});
|
|
131
|
-
yield*
|
|
176
|
+
yield* this.downloadInner(location, fileId_.dcId, params);
|
|
132
177
|
break;
|
|
133
178
|
}
|
|
134
179
|
}
|
|
@@ -140,7 +185,7 @@ export class FileManager {
|
|
|
140
185
|
file_reference: fileId_.fileReference ?? new Uint8Array(),
|
|
141
186
|
thumb_size: "",
|
|
142
187
|
});
|
|
143
|
-
yield*
|
|
188
|
+
yield* this.downloadInner(location, fileId_.dcId, params);
|
|
144
189
|
}
|
|
145
190
|
else {
|
|
146
191
|
unreachable();
|
|
@@ -245,14 +290,16 @@ _a = FileManager, _FileManager_c = new WeakMap(), _FileManager_Lupload = new Wea
|
|
|
245
290
|
const isBig = buffer.byteLength > __classPrivateFieldGet(_a, _a, "f", _FileManager_BIG_FILE_THRESHOLD);
|
|
246
291
|
const partCount = Math.ceil(buffer.byteLength / chunkSize);
|
|
247
292
|
let promises = new Array();
|
|
248
|
-
for (let part = 0; part < partCount;) {
|
|
293
|
+
main: for (let part = 0; part < partCount;) {
|
|
249
294
|
for (let i = 0; i < pool.size; ++i) {
|
|
250
295
|
const api = pool.api();
|
|
251
296
|
for (let i = 0; i < __classPrivateFieldGet(_a, _a, "f", _FileManager_UPLOAD_REQUEST_PER_CONNECTION); ++i) {
|
|
252
297
|
const start = part * chunkSize;
|
|
253
298
|
const end = start + chunkSize;
|
|
254
299
|
const bytes = buffer.subarray(start, end);
|
|
255
|
-
|
|
300
|
+
if (!bytes.length) {
|
|
301
|
+
break main;
|
|
302
|
+
}
|
|
256
303
|
const thisPart = part++; // `thisPart` must be used instead of `part` in the promise body
|
|
257
304
|
promises.push(Promise.resolve().then(async () => {
|
|
258
305
|
while (true) {
|
|
@@ -372,50 +419,6 @@ _a = FileManager, _FileManager_c = new WeakMap(), _FileManager_Lupload = new Wea
|
|
|
372
419
|
}
|
|
373
420
|
}
|
|
374
421
|
return { size: params?.fileSize ? params.fileSize : size, name, contents };
|
|
375
|
-
}, _FileManager_downloadInner = async function* _FileManager_downloadInner(location, dcId, params) {
|
|
376
|
-
const id = "id" in location ? location.id : "photo_id" in location ? location.photo_id : null;
|
|
377
|
-
if (id != null && __classPrivateFieldGet(this, _FileManager_c, "f").storage.supportsFiles) {
|
|
378
|
-
const file = await __classPrivateFieldGet(this, _FileManager_c, "f").storage.getFile(id);
|
|
379
|
-
const partOffset = file == null ? 0 : params?.offset ? Math.ceil(10 / file[1]) - 1 : 0;
|
|
380
|
-
if (file != null && file[0] > 0) {
|
|
381
|
-
yield* __classPrivateFieldGet(this, _FileManager_c, "f").storage.iterFileParts(id, file[0], partOffset);
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
const chunkSize = params?.chunkSize ?? __classPrivateFieldGet(_a, _a, "f", _FileManager_DOWNLOAD_MAX_CHUNK_SIZE);
|
|
386
|
-
_a.validateChunkSize(chunkSize, __classPrivateFieldGet(_a, _a, "f", _FileManager_DOWNLOAD_MAX_CHUNK_SIZE));
|
|
387
|
-
const connection = __classPrivateFieldGet(this, _FileManager_c, "f").getCdnConnection(dcId);
|
|
388
|
-
await connection.connect();
|
|
389
|
-
const limit = chunkSize;
|
|
390
|
-
let offset = params?.offset ? BigInt(params.offset) : 0n;
|
|
391
|
-
let part = 0;
|
|
392
|
-
try {
|
|
393
|
-
while (true) {
|
|
394
|
-
const file = await connection.api.upload.getFile({ location, offset, limit });
|
|
395
|
-
if (file instanceof types.upload.File) {
|
|
396
|
-
yield file.bytes;
|
|
397
|
-
if (id != null) {
|
|
398
|
-
await __classPrivateFieldGet(this, _FileManager_c, "f").storage.saveFilePart(id, part, file.bytes);
|
|
399
|
-
}
|
|
400
|
-
++part;
|
|
401
|
-
if (file.bytes.length < limit) {
|
|
402
|
-
if (id != null) {
|
|
403
|
-
await __classPrivateFieldGet(this, _FileManager_c, "f").storage.setFilePartCount(id, part + 1, chunkSize);
|
|
404
|
-
}
|
|
405
|
-
break;
|
|
406
|
-
}
|
|
407
|
-
else {
|
|
408
|
-
offset += BigInt(file.bytes.length);
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
else {
|
|
412
|
-
unreachable();
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
finally {
|
|
417
|
-
drop(connection.disconnect());
|
|
418
|
-
}
|
|
419
422
|
};
|
|
420
423
|
_FileManager_UPLOAD_MAX_CHUNK_SIZE = { value: 512 * kilobyte };
|
|
421
424
|
_FileManager_DOWNLOAD_MAX_CHUNK_SIZE = { value: 1 * megabyte };
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* You should have received a copy of the GNU Lesser General Public License
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
|
-
import { C } from "./
|
|
20
|
+
import { C } from "./1_types.js";
|
|
21
21
|
export declare class NetworkStatisticsManager {
|
|
22
22
|
#private;
|
|
23
23
|
constructor(c: C);
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { enums, types } from "../2_tl.js";
|
|
21
21
|
import { Update } from "../3_types.js";
|
|
22
|
-
import { C } from "./
|
|
22
|
+
import { C } from "./1_types.js";
|
|
23
23
|
type ReactionManagerUpdate = types.UpdateBotMessageReactions | types.UpdateBotMessageReaction | types.UpdateMessageReactions | types.UpdateChannelMessageViews | types.UpdateChannelMessageForwards;
|
|
24
24
|
export declare class ReactionManager {
|
|
25
25
|
#private;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { Queue } from "../1_utilities.js";
|
|
21
21
|
import { enums, ReadObject, TLObject, types } from "../2_tl.js";
|
|
22
|
-
import { C } from "./
|
|
22
|
+
import { C } from "./1_types.js";
|
|
23
23
|
type UpdateHandler = (update: enums.Update) => Promise<(() => Promise<unknown>)>;
|
|
24
24
|
export type PtsUpdate = types.UpdateNewMessage | types.UpdateDeleteMessages | types.UpdateReadHistoryInbox | types.UpdateReadHistoryOutbox | types.UpdatePinnedChannelMessages | types.UpdatePinnedMessages | types.UpdateFolderPeers | types.UpdateChannelWebPage | types.UpdateEditMessage | types.UpdateReadMessagesContents | types.UpdateWebPage;
|
|
25
25
|
export type ChannelPtsUpdate = types.UpdateNewChannelMessage | types.UpdateEditChannelMessage | types.UpdateDeleteChannelMessages | types.UpdateChannelTooLong;
|
|
@@ -21,8 +21,8 @@ import { enums, types } from "../2_tl.js";
|
|
|
21
21
|
import { InputMedia } from "../3_types.js";
|
|
22
22
|
import { ChatAction, ChatMember, FileSource, FileType, ID, Message, MessageEntity, ParseMode, Reaction, Update, UsernameResolver } from "../3_types.js";
|
|
23
23
|
import { AddReactionParams, BanChatMemberParams, CreateInviteLinkParams, DeleteMessagesParams, EditMessageLiveLocationParams, EditMessageMediaParams, EditMessageParams, EditMessageReplyMarkupParams, ForwardMessagesParams, GetCreatedInviteLinksParams, GetHistoryParams, PinMessageParams, SearchMessagesParams, SendAnimationParams, SendAudioParams, SendChatActionParams, SendContactParams, SendDiceParams, SendDocumentParams, SendLocationParams, SendMessageParams, SendPhotoParams, SendPollParams, SendStickerParams, SendVenueParams, SendVideoNoteParams, SendVideoParams, SendVoiceParams, SetChatMemberRightsParams, SetChatPhotoParams, SetReactionsParams, StopPollParams } from "./0_params.js";
|
|
24
|
-
import { C as C_ } from "./
|
|
25
|
-
import { FileManager } from "./
|
|
24
|
+
import { C as C_ } from "./1_types.js";
|
|
25
|
+
import { FileManager } from "./2_file_manager.js";
|
|
26
26
|
interface C extends C_ {
|
|
27
27
|
fileManager: FileManager;
|
|
28
28
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2024 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 { enums, types } from "../2_tl.js";
|
|
21
|
+
import { ID, Update, VideoChatActive, VideoChatScheduled } from "../3_types.js";
|
|
22
|
+
import { DownloadLiveStreamChunkParams, JoinVideoChatParams, StartVideoChatParams } from "./0_params.js";
|
|
23
|
+
import { C as C_ } from "./1_types.js";
|
|
24
|
+
import { FileManager } from "./2_file_manager.js";
|
|
25
|
+
interface C extends C_ {
|
|
26
|
+
fileManager: FileManager;
|
|
27
|
+
}
|
|
28
|
+
type VideoChatManagerUpdate = types.UpdateGroupCall;
|
|
29
|
+
export declare class VideoChatManager {
|
|
30
|
+
#private;
|
|
31
|
+
constructor(c: C);
|
|
32
|
+
startVideoChat(chatId: ID, params?: StartVideoChatParams): Promise<VideoChatActive>;
|
|
33
|
+
scheduleVideoChat(chatId: ID, startAt: Date, params?: StartVideoChatParams): Promise<VideoChatScheduled>;
|
|
34
|
+
joinVideoChat(id: string, params: string, params_?: JoinVideoChatParams): Promise<string>;
|
|
35
|
+
leaveVideoChat(id: string): Promise<void>;
|
|
36
|
+
joinLiveStream(id: string): Promise<void>;
|
|
37
|
+
getVideoChat(id: string): Promise<import("../3_types.js").VideoChat>;
|
|
38
|
+
static canHandleUpdate(update: enums.Update): update is VideoChatManagerUpdate;
|
|
39
|
+
handleUpdate(update: VideoChatManagerUpdate): Promise<Update>;
|
|
40
|
+
getLiveStreamChannels(id: string): Promise<import("../3_types.js").LiveStreamChannel[]>;
|
|
41
|
+
downloadLiveStreamChunk(id: string, channel: number, scale: number, timestamp: number, params?: DownloadLiveStreamChunkParams): AsyncGenerator<Uint8Array, void, unknown>;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2024 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
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
21
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
22
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
23
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
24
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
25
|
+
};
|
|
26
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
27
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
28
|
+
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");
|
|
29
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
30
|
+
};
|
|
31
|
+
var _VideoChatManager_instances, _VideoChatManager_c, _VideoChatManager_createGroupCall, _VideoChatManager_getInputGroupCall, _VideoChatManager_getCall;
|
|
32
|
+
import { unreachable } from "../0_deps.js";
|
|
33
|
+
import { InputError } from "../0_errors.js";
|
|
34
|
+
import { getRandomId, toUnixTimestamp, ZERO_CHANNEL_ID } from "../1_utilities.js";
|
|
35
|
+
import { as, types } from "../2_tl.js";
|
|
36
|
+
import { constructLiveStreamChannel, constructVideoChat } from "../3_types.js";
|
|
37
|
+
export class VideoChatManager {
|
|
38
|
+
constructor(c) {
|
|
39
|
+
_VideoChatManager_instances.add(this);
|
|
40
|
+
_VideoChatManager_c.set(this, void 0);
|
|
41
|
+
__classPrivateFieldSet(this, _VideoChatManager_c, c, "f");
|
|
42
|
+
}
|
|
43
|
+
async startVideoChat(chatId, params) {
|
|
44
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("startVideoChat");
|
|
45
|
+
return await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_createGroupCall).call(this, chatId, params?.title, params?.liveStream || undefined);
|
|
46
|
+
}
|
|
47
|
+
async scheduleVideoChat(chatId, startAt, params) {
|
|
48
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("scheduleVideoChat");
|
|
49
|
+
return await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_createGroupCall).call(this, chatId, params?.title, params?.liveStream || undefined, startAt);
|
|
50
|
+
}
|
|
51
|
+
async joinVideoChat(id, params, params_) {
|
|
52
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("joinVideoChat");
|
|
53
|
+
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getInputGroupCall).call(this, id);
|
|
54
|
+
const { updates } = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").api.phone.joinGroupCall({
|
|
55
|
+
call,
|
|
56
|
+
join_as: params_?.joinAs ? await __classPrivateFieldGet(this, _VideoChatManager_c, "f").getInputPeer(params_.joinAs) : new types.InputPeerSelf(),
|
|
57
|
+
params: new types.DataJSON({ data: params }),
|
|
58
|
+
invite_hash: params_?.inviteHash,
|
|
59
|
+
muted: params_?.audio ? undefined : true,
|
|
60
|
+
video_stopped: params_?.video ? undefined : true,
|
|
61
|
+
}).then((v) => v[as](types.Updates));
|
|
62
|
+
const updateGroupCall = updates
|
|
63
|
+
.find((v) => v instanceof types.UpdateGroupCallConnection);
|
|
64
|
+
if (!updateGroupCall)
|
|
65
|
+
unreachable();
|
|
66
|
+
return updateGroupCall.params.data;
|
|
67
|
+
}
|
|
68
|
+
async leaveVideoChat(id) {
|
|
69
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("leaveVideoChat");
|
|
70
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").api.phone.leaveGroupCall({ call: await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getInputGroupCall).call(this, id), source: 0 });
|
|
71
|
+
}
|
|
72
|
+
async joinLiveStream(id) {
|
|
73
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("joinLiveStream");
|
|
74
|
+
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getInputGroupCall).call(this, id);
|
|
75
|
+
const { updates } = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").api.phone.joinGroupCall({
|
|
76
|
+
call,
|
|
77
|
+
join_as: new types.InputPeerSelf(),
|
|
78
|
+
params: new types.DataJSON({
|
|
79
|
+
data: JSON.stringify({
|
|
80
|
+
fingerprints: [],
|
|
81
|
+
pwd: "",
|
|
82
|
+
ssrc: getRandomId(true),
|
|
83
|
+
"ssrc-groups": [],
|
|
84
|
+
ufrag: "",
|
|
85
|
+
}),
|
|
86
|
+
}),
|
|
87
|
+
}).then((v) => v[as](types.Updates));
|
|
88
|
+
const updateGroupCall = updates
|
|
89
|
+
.find((v) => v instanceof types.UpdateGroupCallConnection);
|
|
90
|
+
if (!updateGroupCall)
|
|
91
|
+
unreachable();
|
|
92
|
+
}
|
|
93
|
+
async getVideoChat(id) {
|
|
94
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("getVideoChat");
|
|
95
|
+
return constructVideoChat(await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getCall).call(this, id));
|
|
96
|
+
}
|
|
97
|
+
static canHandleUpdate(update) {
|
|
98
|
+
return update instanceof types.UpdateGroupCall;
|
|
99
|
+
}
|
|
100
|
+
async handleUpdate(update) {
|
|
101
|
+
let chatId = Number(-update.chat_id);
|
|
102
|
+
const fullChat = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.getFullChat(chatId).then((v) => v == null ? __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.getFullChat(chatId = ZERO_CHANNEL_ID - Number(update.chat_id)) : v);
|
|
103
|
+
let updateFullChat = false;
|
|
104
|
+
if (update.call instanceof types.GroupCallDiscarded) {
|
|
105
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.setGroupCall(update.call.id, null);
|
|
106
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.setGroupCallAccessHash(update.call.id, null);
|
|
107
|
+
if (fullChat != null) {
|
|
108
|
+
fullChat.call = undefined;
|
|
109
|
+
updateFullChat = true;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.setGroupCall(update.call.id, update.call);
|
|
114
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.setGroupCallAccessHash(update.call.id, update.call.access_hash);
|
|
115
|
+
if (fullChat != null) {
|
|
116
|
+
if (!("call" in fullChat) || !fullChat.call || fullChat.call.id != update.call.id) {
|
|
117
|
+
fullChat.call = new types.InputGroupCall(update.call);
|
|
118
|
+
updateFullChat = true;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (updateFullChat) {
|
|
123
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.setFullChat(chatId, fullChat);
|
|
124
|
+
}
|
|
125
|
+
return { videoChat: constructVideoChat(update.call) };
|
|
126
|
+
}
|
|
127
|
+
async getLiveStreamChannels(id) {
|
|
128
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("getLiveStreamChannels");
|
|
129
|
+
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getCall).call(this, id);
|
|
130
|
+
if (!(call instanceof types.GroupCall) || !call.rtmp_stream) {
|
|
131
|
+
throw new InputError("Not a live stream.");
|
|
132
|
+
}
|
|
133
|
+
const client = __classPrivateFieldGet(this, _VideoChatManager_c, "f").getCdnConnection(call.stream_dc_id);
|
|
134
|
+
await client.connect();
|
|
135
|
+
try {
|
|
136
|
+
const streams = await client.api.phone.getGroupCallStreamChannels({ call: await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getInputGroupCall).call(this, id) });
|
|
137
|
+
return streams.channels.map(constructLiveStreamChannel);
|
|
138
|
+
}
|
|
139
|
+
finally {
|
|
140
|
+
await client.disconnect();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async *downloadLiveStreamChunk(id, channel, scale, timestamp, params) {
|
|
144
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("downloadLiveStreamChunk");
|
|
145
|
+
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getCall).call(this, id);
|
|
146
|
+
if (!(call instanceof types.GroupCall) || !call.rtmp_stream) {
|
|
147
|
+
throw new InputError("Not a live stream.");
|
|
148
|
+
}
|
|
149
|
+
const quality = params?.quality ?? "low";
|
|
150
|
+
const location = new types.InputGroupCallStream({
|
|
151
|
+
call: new types.InputGroupCall(call),
|
|
152
|
+
scale,
|
|
153
|
+
time_ms: BigInt(timestamp),
|
|
154
|
+
video_channel: channel,
|
|
155
|
+
video_quality: quality == "low" ? 0 : quality == "medium" ? 1 : quality == "high" ? 2 : (() => {
|
|
156
|
+
throw new InputError("Got invalid quality.");
|
|
157
|
+
})(),
|
|
158
|
+
});
|
|
159
|
+
yield* __classPrivateFieldGet(this, _VideoChatManager_c, "f").fileManager.downloadInner(location, call.stream_dc_id ?? unreachable());
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
_VideoChatManager_c = new WeakMap(), _VideoChatManager_instances = new WeakSet(), _VideoChatManager_createGroupCall = async function _VideoChatManager_createGroupCall(chatId, title, liveStream, scheduleDate) {
|
|
163
|
+
const peer = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").getInputPeer(chatId);
|
|
164
|
+
if (peer instanceof types.InputPeerUser) {
|
|
165
|
+
throw new InputError("Video chats are only available for groups and channels.");
|
|
166
|
+
}
|
|
167
|
+
const { updates } = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").api.phone.createGroupCall({
|
|
168
|
+
peer,
|
|
169
|
+
random_id: getRandomId(true),
|
|
170
|
+
title,
|
|
171
|
+
rtmp_stream: liveStream,
|
|
172
|
+
schedule_date: scheduleDate ? toUnixTimestamp(scheduleDate) : undefined,
|
|
173
|
+
}).then((v) => v[as](types.Updates));
|
|
174
|
+
const updateGroupCall = updates
|
|
175
|
+
.find((v) => v instanceof types.UpdateGroupCall);
|
|
176
|
+
if (!updateGroupCall) {
|
|
177
|
+
unreachable();
|
|
178
|
+
}
|
|
179
|
+
return constructVideoChat(updateGroupCall.call);
|
|
180
|
+
}, _VideoChatManager_getInputGroupCall = async function _VideoChatManager_getInputGroupCall(id_) {
|
|
181
|
+
const id = BigInt(id_);
|
|
182
|
+
const accessHash = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.getGroupCallAccessHash(id);
|
|
183
|
+
if (accessHash == null) {
|
|
184
|
+
throw new InputError("Video chat not found.");
|
|
185
|
+
}
|
|
186
|
+
return new types.InputGroupCall({ id, access_hash: accessHash });
|
|
187
|
+
}, _VideoChatManager_getCall = async function _VideoChatManager_getCall(id) {
|
|
188
|
+
let groupCall = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.getGroupCall(BigInt(id));
|
|
189
|
+
if (groupCall == null) {
|
|
190
|
+
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getInputGroupCall).call(this, id);
|
|
191
|
+
groupCall = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").api.phone.getGroupCall({ call, limit: 1 }).then((v) => v.call);
|
|
192
|
+
}
|
|
193
|
+
return groupCall;
|
|
194
|
+
};
|
package/{script/client/3_callback_query_manager.d.ts → esm/client/4_callback_query_manager.d.ts}
RENAMED
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
import { enums, types } from "../2_tl.js";
|
|
21
21
|
import { CallbackQueryQuestion, ID, Update } from "../3_types.js";
|
|
22
22
|
import { AnswerCallbackQueryParams } from "./0_params.js";
|
|
23
|
-
import { C as C_ } from "./
|
|
24
|
-
import { MessageManager } from "./
|
|
23
|
+
import { C as C_ } from "./1_types.js";
|
|
24
|
+
import { MessageManager } from "./3_message_manager.js";
|
|
25
25
|
type C = C_ & {
|
|
26
26
|
messageManager: MessageManager;
|
|
27
27
|
};
|
|
@@ -50,6 +50,7 @@ export class CallbackQueryManager {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
async sendCallbackQuery(chatId, messageId, question) {
|
|
53
|
+
await __classPrivateFieldGet(this, _CallbackQueryManager_c, "f").storage.assertUser("sendCallbackQuery");
|
|
53
54
|
checkMessageId(messageId);
|
|
54
55
|
validateCallbackQueryQuestion(question);
|
|
55
56
|
const peer = await __classPrivateFieldGet(this, _CallbackQueryManager_c, "f").getInputPeer(chatId), peerId = peerToChatId(peer), questionKey = JSON.stringify(question);
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
20
|
import { enums, types } from "../2_tl.js";
|
|
21
|
-
import {
|
|
22
|
-
import { C as C_ } from "./
|
|
23
|
-
import { FileManager } from "./
|
|
24
|
-
import { MessageManager } from "./
|
|
21
|
+
import { ChatListItem, ID } from "../3_types.js";
|
|
22
|
+
import { C as C_ } from "./1_types.js";
|
|
23
|
+
import { FileManager } from "./2_file_manager.js";
|
|
24
|
+
import { MessageManager } from "./3_message_manager.js";
|
|
25
25
|
type C = C_ & {
|
|
26
26
|
fileManager: FileManager;
|
|
27
27
|
messageManager: MessageManager;
|
|
@@ -31,9 +31,9 @@ export declare class ChatListManager {
|
|
|
31
31
|
#private;
|
|
32
32
|
constructor(c: C);
|
|
33
33
|
reassignChatLastMessage(chatId: number, add?: boolean, sendUpdate?: boolean): Promise<() => Promise<void>>;
|
|
34
|
-
getChats(from?: "archived" | "main", after?:
|
|
34
|
+
getChats(from?: "archived" | "main", after?: ChatListItem, limit?: number): Promise<ChatListItem[]>;
|
|
35
35
|
static canHandleUpdate(update: enums.Update): update is ChatListManagerUpdate;
|
|
36
36
|
handleUpdate(update: ChatListManagerUpdate): Promise<void>;
|
|
37
|
-
getChat(chatId: ID): Promise<Chat>;
|
|
37
|
+
getChat(chatId: ID): Promise<import("../3_types.js").Chat>;
|
|
38
38
|
}
|
|
39
39
|
export {};
|