@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/script/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>;
|
|
@@ -29,7 +29,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
29
29
|
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");
|
|
30
30
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
31
31
|
};
|
|
32
|
-
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
|
+
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;
|
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
34
|
exports.FileManager = void 0;
|
|
35
35
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
@@ -86,6 +86,51 @@ class FileManager {
|
|
|
86
86
|
return new _2_tl_js_1.types.InputFileBig({ id: fileId, parts: result.parts, name });
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
+
async *downloadInner(location, dcId, params) {
|
|
90
|
+
const id = "id" in location ? location.id : "photo_id" in location ? location.photo_id : null;
|
|
91
|
+
if (id != null && __classPrivateFieldGet(this, _FileManager_c, "f").storage.supportsFiles) {
|
|
92
|
+
const file = await __classPrivateFieldGet(this, _FileManager_c, "f").storage.getFile(id);
|
|
93
|
+
const partOffset = file == null ? 0 : params?.offset ? Math.ceil(10 / file[1]) - 1 : 0;
|
|
94
|
+
if (file != null && file[0] > 0) {
|
|
95
|
+
yield* __classPrivateFieldGet(this, _FileManager_c, "f").storage.iterFileParts(id, file[0], partOffset);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const chunkSize = params?.chunkSize ?? __classPrivateFieldGet(_a, _a, "f", _FileManager_DOWNLOAD_MAX_CHUNK_SIZE);
|
|
100
|
+
_a.validateChunkSize(chunkSize, __classPrivateFieldGet(_a, _a, "f", _FileManager_DOWNLOAD_MAX_CHUNK_SIZE));
|
|
101
|
+
const connection = __classPrivateFieldGet(this, _FileManager_c, "f").getCdnConnection(dcId);
|
|
102
|
+
await connection.connect();
|
|
103
|
+
const limit = chunkSize;
|
|
104
|
+
let offset = params?.offset ? BigInt(params.offset) : 0n;
|
|
105
|
+
let part = 0;
|
|
106
|
+
try {
|
|
107
|
+
while (true) {
|
|
108
|
+
const file = await connection.api.upload.getFile({ location, offset, limit });
|
|
109
|
+
if (file instanceof _2_tl_js_1.types.upload.File) {
|
|
110
|
+
yield file.bytes;
|
|
111
|
+
if (id != null) {
|
|
112
|
+
await __classPrivateFieldGet(this, _FileManager_c, "f").storage.saveFilePart(id, part, file.bytes);
|
|
113
|
+
}
|
|
114
|
+
++part;
|
|
115
|
+
if (file.bytes.length < limit) {
|
|
116
|
+
if (id != null) {
|
|
117
|
+
await __classPrivateFieldGet(this, _FileManager_c, "f").storage.setFilePartCount(id, part + 1, chunkSize);
|
|
118
|
+
}
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
offset += BigInt(file.bytes.length);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
(0, _0_deps_js_1.unreachable)();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
(0, _1_utilities_js_1.drop)(connection.disconnect());
|
|
132
|
+
}
|
|
133
|
+
}
|
|
89
134
|
static validateChunkSize(chunkSize, max) {
|
|
90
135
|
if (chunkSize <= 0) {
|
|
91
136
|
throw new _0_errors_js_1.InputError("chunkSize must be bigger than zero.");
|
|
@@ -111,7 +156,7 @@ class FileManager {
|
|
|
111
156
|
const big = fileId_.location.source.type == _3_types_js_1.PhotoSourceType.ChatPhotoBig;
|
|
112
157
|
const peer = await __classPrivateFieldGet(this, _FileManager_c, "f").getInputPeer(Number(fileId_.location.source.chatId)); // TODO: use access hash from source?
|
|
113
158
|
const location = new _2_tl_js_1.types.InputPeerPhotoFileLocation({ big: big ? true : undefined, peer, photo_id: fileId_.location.id });
|
|
114
|
-
yield*
|
|
159
|
+
yield* this.downloadInner(location, fileId_.dcId, params);
|
|
115
160
|
break;
|
|
116
161
|
}
|
|
117
162
|
case _3_types_js_1.FileType.Photo: {
|
|
@@ -121,7 +166,7 @@ class FileManager {
|
|
|
121
166
|
file_reference: fileId_.fileReference ?? new Uint8Array(),
|
|
122
167
|
thumb_size: "thumbnailType" in fileId_.location.source ? String.fromCharCode(fileId_.location.source.thumbnailType) : "",
|
|
123
168
|
});
|
|
124
|
-
yield*
|
|
169
|
+
yield* this.downloadInner(location, fileId_.dcId, params);
|
|
125
170
|
break;
|
|
126
171
|
}
|
|
127
172
|
case _3_types_js_1.FileType.Thumbnail: {
|
|
@@ -131,7 +176,7 @@ class FileManager {
|
|
|
131
176
|
file_reference: fileId_.fileReference ?? new Uint8Array(),
|
|
132
177
|
thumb_size: "thumbnailType" in fileId_.location.source ? String.fromCharCode(fileId_.location.source.thumbnailType) : (0, _0_deps_js_1.unreachable)(),
|
|
133
178
|
});
|
|
134
|
-
yield*
|
|
179
|
+
yield* this.downloadInner(location, fileId_.dcId, params);
|
|
135
180
|
break;
|
|
136
181
|
}
|
|
137
182
|
}
|
|
@@ -143,7 +188,7 @@ class FileManager {
|
|
|
143
188
|
file_reference: fileId_.fileReference ?? new Uint8Array(),
|
|
144
189
|
thumb_size: "",
|
|
145
190
|
});
|
|
146
|
-
yield*
|
|
191
|
+
yield* this.downloadInner(location, fileId_.dcId, params);
|
|
147
192
|
}
|
|
148
193
|
else {
|
|
149
194
|
(0, _0_deps_js_1.unreachable)();
|
|
@@ -249,14 +294,16 @@ _a = FileManager, _FileManager_c = new WeakMap(), _FileManager_Lupload = new Wea
|
|
|
249
294
|
const isBig = buffer.byteLength > __classPrivateFieldGet(_a, _a, "f", _FileManager_BIG_FILE_THRESHOLD);
|
|
250
295
|
const partCount = Math.ceil(buffer.byteLength / chunkSize);
|
|
251
296
|
let promises = new Array();
|
|
252
|
-
for (let part = 0; part < partCount;) {
|
|
297
|
+
main: for (let part = 0; part < partCount;) {
|
|
253
298
|
for (let i = 0; i < pool.size; ++i) {
|
|
254
299
|
const api = pool.api();
|
|
255
300
|
for (let i = 0; i < __classPrivateFieldGet(_a, _a, "f", _FileManager_UPLOAD_REQUEST_PER_CONNECTION); ++i) {
|
|
256
301
|
const start = part * chunkSize;
|
|
257
302
|
const end = start + chunkSize;
|
|
258
303
|
const bytes = buffer.subarray(start, end);
|
|
259
|
-
|
|
304
|
+
if (!bytes.length) {
|
|
305
|
+
break main;
|
|
306
|
+
}
|
|
260
307
|
const thisPart = part++; // `thisPart` must be used instead of `part` in the promise body
|
|
261
308
|
promises.push(Promise.resolve().then(async () => {
|
|
262
309
|
while (true) {
|
|
@@ -376,50 +423,6 @@ _a = FileManager, _FileManager_c = new WeakMap(), _FileManager_Lupload = new Wea
|
|
|
376
423
|
}
|
|
377
424
|
}
|
|
378
425
|
return { size: params?.fileSize ? params.fileSize : size, name, contents };
|
|
379
|
-
}, _FileManager_downloadInner = async function* _FileManager_downloadInner(location, dcId, params) {
|
|
380
|
-
const id = "id" in location ? location.id : "photo_id" in location ? location.photo_id : null;
|
|
381
|
-
if (id != null && __classPrivateFieldGet(this, _FileManager_c, "f").storage.supportsFiles) {
|
|
382
|
-
const file = await __classPrivateFieldGet(this, _FileManager_c, "f").storage.getFile(id);
|
|
383
|
-
const partOffset = file == null ? 0 : params?.offset ? Math.ceil(10 / file[1]) - 1 : 0;
|
|
384
|
-
if (file != null && file[0] > 0) {
|
|
385
|
-
yield* __classPrivateFieldGet(this, _FileManager_c, "f").storage.iterFileParts(id, file[0], partOffset);
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
const chunkSize = params?.chunkSize ?? __classPrivateFieldGet(_a, _a, "f", _FileManager_DOWNLOAD_MAX_CHUNK_SIZE);
|
|
390
|
-
_a.validateChunkSize(chunkSize, __classPrivateFieldGet(_a, _a, "f", _FileManager_DOWNLOAD_MAX_CHUNK_SIZE));
|
|
391
|
-
const connection = __classPrivateFieldGet(this, _FileManager_c, "f").getCdnConnection(dcId);
|
|
392
|
-
await connection.connect();
|
|
393
|
-
const limit = chunkSize;
|
|
394
|
-
let offset = params?.offset ? BigInt(params.offset) : 0n;
|
|
395
|
-
let part = 0;
|
|
396
|
-
try {
|
|
397
|
-
while (true) {
|
|
398
|
-
const file = await connection.api.upload.getFile({ location, offset, limit });
|
|
399
|
-
if (file instanceof _2_tl_js_1.types.upload.File) {
|
|
400
|
-
yield file.bytes;
|
|
401
|
-
if (id != null) {
|
|
402
|
-
await __classPrivateFieldGet(this, _FileManager_c, "f").storage.saveFilePart(id, part, file.bytes);
|
|
403
|
-
}
|
|
404
|
-
++part;
|
|
405
|
-
if (file.bytes.length < limit) {
|
|
406
|
-
if (id != null) {
|
|
407
|
-
await __classPrivateFieldGet(this, _FileManager_c, "f").storage.setFilePartCount(id, part + 1, chunkSize);
|
|
408
|
-
}
|
|
409
|
-
break;
|
|
410
|
-
}
|
|
411
|
-
else {
|
|
412
|
-
offset += BigInt(file.bytes.length);
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
else {
|
|
416
|
-
(0, _0_deps_js_1.unreachable)();
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
finally {
|
|
421
|
-
(0, _1_utilities_js_1.drop)(connection.disconnect());
|
|
422
|
-
}
|
|
423
426
|
};
|
|
424
427
|
_FileManager_UPLOAD_MAX_CHUNK_SIZE = { value: 512 * _1_utilities_js_1.kilobyte };
|
|
425
428
|
_FileManager_DOWNLOAD_MAX_CHUNK_SIZE = { value: 1 * _1_utilities_js_1.megabyte };
|
package/script/client/{1_network_statistics_manager.d.ts → 2_network_statistics_manager.d.ts}
RENAMED
|
@@ -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,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
4
|
+
* Copyright (C) 2023-2024 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
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
22
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
23
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
24
|
+
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");
|
|
25
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
26
|
+
};
|
|
27
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
28
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
29
|
+
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");
|
|
30
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
31
|
+
};
|
|
32
|
+
var _VideoChatManager_instances, _VideoChatManager_c, _VideoChatManager_createGroupCall, _VideoChatManager_getInputGroupCall, _VideoChatManager_getCall;
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.VideoChatManager = void 0;
|
|
35
|
+
const _0_deps_js_1 = require("../0_deps.js");
|
|
36
|
+
const _0_errors_js_1 = require("../0_errors.js");
|
|
37
|
+
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
38
|
+
const _2_tl_js_1 = require("../2_tl.js");
|
|
39
|
+
const _3_types_js_1 = require("../3_types.js");
|
|
40
|
+
class VideoChatManager {
|
|
41
|
+
constructor(c) {
|
|
42
|
+
_VideoChatManager_instances.add(this);
|
|
43
|
+
_VideoChatManager_c.set(this, void 0);
|
|
44
|
+
__classPrivateFieldSet(this, _VideoChatManager_c, c, "f");
|
|
45
|
+
}
|
|
46
|
+
async startVideoChat(chatId, params) {
|
|
47
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("startVideoChat");
|
|
48
|
+
return await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_createGroupCall).call(this, chatId, params?.title, params?.liveStream || undefined);
|
|
49
|
+
}
|
|
50
|
+
async scheduleVideoChat(chatId, startAt, params) {
|
|
51
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("scheduleVideoChat");
|
|
52
|
+
return await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_createGroupCall).call(this, chatId, params?.title, params?.liveStream || undefined, startAt);
|
|
53
|
+
}
|
|
54
|
+
async joinVideoChat(id, params, params_) {
|
|
55
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("joinVideoChat");
|
|
56
|
+
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getInputGroupCall).call(this, id);
|
|
57
|
+
const { updates } = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").api.phone.joinGroupCall({
|
|
58
|
+
call,
|
|
59
|
+
join_as: params_?.joinAs ? await __classPrivateFieldGet(this, _VideoChatManager_c, "f").getInputPeer(params_.joinAs) : new _2_tl_js_1.types.InputPeerSelf(),
|
|
60
|
+
params: new _2_tl_js_1.types.DataJSON({ data: params }),
|
|
61
|
+
invite_hash: params_?.inviteHash,
|
|
62
|
+
muted: params_?.audio ? undefined : true,
|
|
63
|
+
video_stopped: params_?.video ? undefined : true,
|
|
64
|
+
}).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.Updates));
|
|
65
|
+
const updateGroupCall = updates
|
|
66
|
+
.find((v) => v instanceof _2_tl_js_1.types.UpdateGroupCallConnection);
|
|
67
|
+
if (!updateGroupCall)
|
|
68
|
+
(0, _0_deps_js_1.unreachable)();
|
|
69
|
+
return updateGroupCall.params.data;
|
|
70
|
+
}
|
|
71
|
+
async leaveVideoChat(id) {
|
|
72
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("leaveVideoChat");
|
|
73
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").api.phone.leaveGroupCall({ call: await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getInputGroupCall).call(this, id), source: 0 });
|
|
74
|
+
}
|
|
75
|
+
async joinLiveStream(id) {
|
|
76
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("joinLiveStream");
|
|
77
|
+
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getInputGroupCall).call(this, id);
|
|
78
|
+
const { updates } = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").api.phone.joinGroupCall({
|
|
79
|
+
call,
|
|
80
|
+
join_as: new _2_tl_js_1.types.InputPeerSelf(),
|
|
81
|
+
params: new _2_tl_js_1.types.DataJSON({
|
|
82
|
+
data: JSON.stringify({
|
|
83
|
+
fingerprints: [],
|
|
84
|
+
pwd: "",
|
|
85
|
+
ssrc: (0, _1_utilities_js_1.getRandomId)(true),
|
|
86
|
+
"ssrc-groups": [],
|
|
87
|
+
ufrag: "",
|
|
88
|
+
}),
|
|
89
|
+
}),
|
|
90
|
+
}).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.Updates));
|
|
91
|
+
const updateGroupCall = updates
|
|
92
|
+
.find((v) => v instanceof _2_tl_js_1.types.UpdateGroupCallConnection);
|
|
93
|
+
if (!updateGroupCall)
|
|
94
|
+
(0, _0_deps_js_1.unreachable)();
|
|
95
|
+
}
|
|
96
|
+
async getVideoChat(id) {
|
|
97
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("getVideoChat");
|
|
98
|
+
return (0, _3_types_js_1.constructVideoChat)(await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getCall).call(this, id));
|
|
99
|
+
}
|
|
100
|
+
static canHandleUpdate(update) {
|
|
101
|
+
return update instanceof _2_tl_js_1.types.UpdateGroupCall;
|
|
102
|
+
}
|
|
103
|
+
async handleUpdate(update) {
|
|
104
|
+
let chatId = Number(-update.chat_id);
|
|
105
|
+
const fullChat = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.getFullChat(chatId).then((v) => v == null ? __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.getFullChat(chatId = _1_utilities_js_1.ZERO_CHANNEL_ID - Number(update.chat_id)) : v);
|
|
106
|
+
let updateFullChat = false;
|
|
107
|
+
if (update.call instanceof _2_tl_js_1.types.GroupCallDiscarded) {
|
|
108
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.setGroupCall(update.call.id, null);
|
|
109
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.setGroupCallAccessHash(update.call.id, null);
|
|
110
|
+
if (fullChat != null) {
|
|
111
|
+
fullChat.call = undefined;
|
|
112
|
+
updateFullChat = true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.setGroupCall(update.call.id, update.call);
|
|
117
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.setGroupCallAccessHash(update.call.id, update.call.access_hash);
|
|
118
|
+
if (fullChat != null) {
|
|
119
|
+
if (!("call" in fullChat) || !fullChat.call || fullChat.call.id != update.call.id) {
|
|
120
|
+
fullChat.call = new _2_tl_js_1.types.InputGroupCall(update.call);
|
|
121
|
+
updateFullChat = true;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (updateFullChat) {
|
|
126
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.setFullChat(chatId, fullChat);
|
|
127
|
+
}
|
|
128
|
+
return { videoChat: (0, _3_types_js_1.constructVideoChat)(update.call) };
|
|
129
|
+
}
|
|
130
|
+
async getLiveStreamChannels(id) {
|
|
131
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("getLiveStreamChannels");
|
|
132
|
+
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getCall).call(this, id);
|
|
133
|
+
if (!(call instanceof _2_tl_js_1.types.GroupCall) || !call.rtmp_stream) {
|
|
134
|
+
throw new _0_errors_js_1.InputError("Not a live stream.");
|
|
135
|
+
}
|
|
136
|
+
const client = __classPrivateFieldGet(this, _VideoChatManager_c, "f").getCdnConnection(call.stream_dc_id);
|
|
137
|
+
await client.connect();
|
|
138
|
+
try {
|
|
139
|
+
const streams = await client.api.phone.getGroupCallStreamChannels({ call: await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getInputGroupCall).call(this, id) });
|
|
140
|
+
return streams.channels.map(_3_types_js_1.constructLiveStreamChannel);
|
|
141
|
+
}
|
|
142
|
+
finally {
|
|
143
|
+
await client.disconnect();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
async *downloadLiveStreamChunk(id, channel, scale, timestamp, params) {
|
|
147
|
+
await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.assertUser("downloadLiveStreamChunk");
|
|
148
|
+
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getCall).call(this, id);
|
|
149
|
+
if (!(call instanceof _2_tl_js_1.types.GroupCall) || !call.rtmp_stream) {
|
|
150
|
+
throw new _0_errors_js_1.InputError("Not a live stream.");
|
|
151
|
+
}
|
|
152
|
+
const quality = params?.quality ?? "low";
|
|
153
|
+
const location = new _2_tl_js_1.types.InputGroupCallStream({
|
|
154
|
+
call: new _2_tl_js_1.types.InputGroupCall(call),
|
|
155
|
+
scale,
|
|
156
|
+
time_ms: BigInt(timestamp),
|
|
157
|
+
video_channel: channel,
|
|
158
|
+
video_quality: quality == "low" ? 0 : quality == "medium" ? 1 : quality == "high" ? 2 : (() => {
|
|
159
|
+
throw new _0_errors_js_1.InputError("Got invalid quality.");
|
|
160
|
+
})(),
|
|
161
|
+
});
|
|
162
|
+
yield* __classPrivateFieldGet(this, _VideoChatManager_c, "f").fileManager.downloadInner(location, call.stream_dc_id ?? (0, _0_deps_js_1.unreachable)());
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.VideoChatManager = VideoChatManager;
|
|
166
|
+
_VideoChatManager_c = new WeakMap(), _VideoChatManager_instances = new WeakSet(), _VideoChatManager_createGroupCall = async function _VideoChatManager_createGroupCall(chatId, title, liveStream, scheduleDate) {
|
|
167
|
+
const peer = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").getInputPeer(chatId);
|
|
168
|
+
if (peer instanceof _2_tl_js_1.types.InputPeerUser) {
|
|
169
|
+
throw new _0_errors_js_1.InputError("Video chats are only available for groups and channels.");
|
|
170
|
+
}
|
|
171
|
+
const { updates } = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").api.phone.createGroupCall({
|
|
172
|
+
peer,
|
|
173
|
+
random_id: (0, _1_utilities_js_1.getRandomId)(true),
|
|
174
|
+
title,
|
|
175
|
+
rtmp_stream: liveStream,
|
|
176
|
+
schedule_date: scheduleDate ? (0, _1_utilities_js_1.toUnixTimestamp)(scheduleDate) : undefined,
|
|
177
|
+
}).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.Updates));
|
|
178
|
+
const updateGroupCall = updates
|
|
179
|
+
.find((v) => v instanceof _2_tl_js_1.types.UpdateGroupCall);
|
|
180
|
+
if (!updateGroupCall) {
|
|
181
|
+
(0, _0_deps_js_1.unreachable)();
|
|
182
|
+
}
|
|
183
|
+
return (0, _3_types_js_1.constructVideoChat)(updateGroupCall.call);
|
|
184
|
+
}, _VideoChatManager_getInputGroupCall = async function _VideoChatManager_getInputGroupCall(id_) {
|
|
185
|
+
const id = BigInt(id_);
|
|
186
|
+
const accessHash = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.getGroupCallAccessHash(id);
|
|
187
|
+
if (accessHash == null) {
|
|
188
|
+
throw new _0_errors_js_1.InputError("Video chat not found.");
|
|
189
|
+
}
|
|
190
|
+
return new _2_tl_js_1.types.InputGroupCall({ id, access_hash: accessHash });
|
|
191
|
+
}, _VideoChatManager_getCall = async function _VideoChatManager_getCall(id) {
|
|
192
|
+
let groupCall = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").storage.getGroupCall(BigInt(id));
|
|
193
|
+
if (groupCall == null) {
|
|
194
|
+
const call = await __classPrivateFieldGet(this, _VideoChatManager_instances, "m", _VideoChatManager_getInputGroupCall).call(this, id);
|
|
195
|
+
groupCall = await __classPrivateFieldGet(this, _VideoChatManager_c, "f").api.phone.getGroupCall({ call, limit: 1 }).then((v) => v.call);
|
|
196
|
+
}
|
|
197
|
+
return groupCall;
|
|
198
|
+
};
|
package/{esm/client/3_callback_query_manager.d.ts → script/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
|
};
|
|
@@ -53,6 +53,7 @@ class CallbackQueryManager {
|
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
async sendCallbackQuery(chatId, messageId, question) {
|
|
56
|
+
await __classPrivateFieldGet(this, _CallbackQueryManager_c, "f").storage.assertUser("sendCallbackQuery");
|
|
56
57
|
(0, _0_utilities_js_1.checkMessageId)(messageId);
|
|
57
58
|
(0, _3_types_js_1.validateCallbackQueryQuestion)(question);
|
|
58
59
|
const peer = await __classPrivateFieldGet(this, _CallbackQueryManager_c, "f").getInputPeer(chatId), peerId = (0, _2_tl_js_1.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 {};
|