@mtkruto/node 0.1.600 → 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/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 +5 -1
- 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} +1 -1
- package/esm/client/{1_file_manager.js → 2_file_manager.js} +5 -3
- 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/{script/client/2_message_manager.d.ts → esm/client/3_message_manager.d.ts} +2 -2
- package/esm/client/{2_video_chat_manager.d.ts → 3_video_chat_manager.d.ts} +2 -2
- package/{script/client/3_callback_query_manager.d.ts → esm/client/4_callback_query_manager.d.ts} +2 -2
- package/{script/client/3_chat_list_manager.d.ts → esm/client/4_chat_list_manager.d.ts} +3 -3
- package/{script/client/3_inline_query_manager.d.ts → esm/client/4_inline_query_manager.d.ts} +2 -2
- 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} +39 -29
- package/esm/client/{4_client.js → 5_client.js} +83 -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 -159
- package/esm/storage/0_storage.js +1 -563
- 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/types/0_id.d.ts +1 -1
- package/package.json +1 -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 +5 -1
- 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} +1 -1
- package/script/client/{1_file_manager.js → 2_file_manager.js} +4 -2
- 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/{esm/client/2_message_manager.d.ts → script/client/3_message_manager.d.ts} +2 -2
- package/script/client/{2_video_chat_manager.d.ts → 3_video_chat_manager.d.ts} +2 -2
- package/{esm/client/3_callback_query_manager.d.ts → script/client/4_callback_query_manager.d.ts} +2 -2
- package/{esm/client/3_chat_list_manager.d.ts → script/client/4_chat_list_manager.d.ts} +3 -3
- package/{esm/client/3_inline_query_manager.d.ts → script/client/4_inline_query_manager.d.ts} +2 -2
- 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} +39 -29
- package/script/client/{4_client.js → 5_client.js} +105 -95
- 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 -159
- package/script/storage/0_storage.js +0 -565
- 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/types/0_id.d.ts +1 -1
- /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/{2_video_chat_manager.js → 3_video_chat_manager.js} +0 -0
- /package/esm/client/{3_callback_query_manager.js → 4_callback_query_manager.js} +0 -0
- /package/esm/client/{3_chat_list_manager.js → 4_chat_list_manager.js} +0 -0
- /package/esm/client/{3_inline_query_manager.js → 4_inline_query_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/{2_video_chat_manager.js → 3_video_chat_manager.js} +0 -0
- /package/script/client/{3_callback_query_manager.js → 4_callback_query_manager.js} +0 -0
- /package/script/client/{3_chat_list_manager.js → 4_chat_list_manager.js} +0 -0
- /package/script/client/{3_inline_query_manager.js → 4_inline_query_manager.js} +0 -0
- /package/script/client/{3_story_manager.js → 4_story_manager.js} +0 -0
|
@@ -29,35 +29,37 @@ 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 _Client_instances, _a, _Client_client, _Client_guaranteeUpdateDelivery, _Client_updateManager, _Client_networkStatisticsManager, _Client_botInfoManager, _Client_fileManager, _Client_reactionManager, _Client_videoChatManager, _Client_businessConnectionManager, _Client_messageManager, _Client_storyManager, _Client_callbackQueryManager, _Client_inlineQueryManager, _Client_chatListManager, _Client_accountManager, _Client_parseMode, _Client_publicKeys, _Client_ignoreOutgoing,
|
|
32
|
+
var _Client_instances, _a, _Client_client, _Client_guaranteeUpdateDelivery, _Client_updateManager, _Client_networkStatisticsManager, _Client_botInfoManager, _Client_fileManager, _Client_reactionManager, _Client_videoChatManager, _Client_businessConnectionManager, _Client_messageManager, _Client_storyManager, _Client_callbackQueryManager, _Client_inlineQueryManager, _Client_chatListManager, _Client_accountManager, _Client_storage_, _Client_messageStorage_, _Client_parseMode, _Client_apiId, _Client_apiHash, _Client_publicKeys, _Client_ignoreOutgoing, _Client_persistCache, _Client_LsignIn, _Client_LpingLoop, _Client_LhandleMigrationError, _Client_L$initConncetion, _Client_namespaceProxies, _Client_getApiId, _Client_getCdnConnectionPool, _Client_getCdnConnection, _Client_constructContext, _Client_propagateConnectionState, _Client_lastPropagatedConnectionState, _Client_stateChangeHandler, _Client_storageInited, _Client_initStorage, _Client_connectionInited, _Client_lastPropagatedAuthorizationState, _Client_propagateAuthorizationState, _Client_getSelfId, _Client_pingLoopStarted, _Client_pingLoopAbortController, _Client_pingInterval, _Client_lastUpdates, _Client_startPingLoop, _Client_pingLoop, _Client_invoke, _Client_handleInvokeError, _Client_getUserAccessHash, _Client_getChannelAccessHash, _Client_getInputPeerInner, _Client_handleCtxUpdate, _Client_queueHandleCtxUpdate, _Client_handleUpdate, _Client_lastGetMe, _Client_getMe;
|
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
34
|
exports.Client = exports.handleMigrationError = exports.restartAuth = exports.Composer = void 0;
|
|
35
35
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
36
36
|
const _0_errors_js_1 = require("../0_errors.js");
|
|
37
37
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
38
38
|
const _2_tl_js_1 = require("../2_tl.js");
|
|
39
|
-
const
|
|
39
|
+
const _2_storage_js_1 = require("../2_storage.js");
|
|
40
40
|
const _3_types_js_1 = require("../3_types.js");
|
|
41
41
|
const _4_constants_js_1 = require("../4_constants.js");
|
|
42
42
|
const _4_errors_js_1 = require("../4_errors.js");
|
|
43
43
|
const _0_password_js_1 = require("./0_password.js");
|
|
44
44
|
const _0_utilities_js_1 = require("./0_utilities.js");
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
45
|
+
const _2_account_manager_js_1 = require("./2_account_manager.js");
|
|
46
|
+
const _2_bot_info_manager_js_1 = require("./2_bot_info_manager.js");
|
|
47
|
+
const _2_business_connection_manager_js_1 = require("./2_business_connection_manager.js");
|
|
48
48
|
const _1_client_encrypted_js_1 = require("./1_client_encrypted.js");
|
|
49
49
|
const _1_client_plain_js_1 = require("./1_client_plain.js");
|
|
50
50
|
const _1_composer_js_1 = require("./1_composer.js");
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
const
|
|
51
|
+
const _2_file_manager_js_1 = require("./2_file_manager.js");
|
|
52
|
+
const _2_network_statistics_manager_js_1 = require("./2_network_statistics_manager.js");
|
|
53
|
+
const _2_reaction_manager_js_1 = require("./2_reaction_manager.js");
|
|
54
|
+
const _2_update_manager_js_1 = require("./2_update_manager.js");
|
|
55
|
+
const _3_message_manager_js_1 = require("./3_message_manager.js");
|
|
56
|
+
const _4_callback_query_manager_js_1 = require("./4_callback_query_manager.js");
|
|
57
|
+
const _4_chat_list_manager_js_1 = require("./4_chat_list_manager.js");
|
|
58
|
+
const _4_inline_query_manager_js_1 = require("./4_inline_query_manager.js");
|
|
59
|
+
const _4_story_manager_js_1 = require("./4_story_manager.js");
|
|
60
|
+
const _3_video_chat_manager_js_1 = require("./3_video_chat_manager.js");
|
|
61
|
+
const _0_storage_operations_js_1 = require("./0_storage_operations.js");
|
|
62
|
+
const _4_errors_js_2 = require("../4_errors.js");
|
|
61
63
|
class Composer extends _1_composer_js_1.Composer {
|
|
62
64
|
}
|
|
63
65
|
exports.Composer = Composer;
|
|
@@ -81,21 +83,9 @@ class Client extends Composer {
|
|
|
81
83
|
* @param apiId App's API ID from [my.telegram.org](https://my.telegram.org/apps). Defaults to 0 (unset).
|
|
82
84
|
* @param apiHash App's API hash from [my.telegram.org/apps](https://my.telegram.org/apps). Defaults to empty string (unset).
|
|
83
85
|
*/
|
|
84
|
-
constructor(
|
|
86
|
+
constructor(params) {
|
|
85
87
|
super();
|
|
86
88
|
_Client_instances.add(this);
|
|
87
|
-
Object.defineProperty(this, "apiId", {
|
|
88
|
-
enumerable: true,
|
|
89
|
-
configurable: true,
|
|
90
|
-
writable: true,
|
|
91
|
-
value: apiId
|
|
92
|
-
});
|
|
93
|
-
Object.defineProperty(this, "apiHash", {
|
|
94
|
-
enumerable: true,
|
|
95
|
-
configurable: true,
|
|
96
|
-
writable: true,
|
|
97
|
-
value: apiHash
|
|
98
|
-
});
|
|
99
89
|
_Client_client.set(this, void 0);
|
|
100
90
|
_Client_guaranteeUpdateDelivery.set(this, void 0);
|
|
101
91
|
_Client_updateManager.set(this, void 0);
|
|
@@ -111,6 +101,8 @@ class Client extends Composer {
|
|
|
111
101
|
_Client_inlineQueryManager.set(this, void 0);
|
|
112
102
|
_Client_chatListManager.set(this, void 0);
|
|
113
103
|
_Client_accountManager.set(this, void 0);
|
|
104
|
+
_Client_storage_.set(this, void 0);
|
|
105
|
+
_Client_messageStorage_.set(this, void 0);
|
|
114
106
|
Object.defineProperty(this, "storage", {
|
|
115
107
|
enumerable: true,
|
|
116
108
|
configurable: true,
|
|
@@ -124,6 +116,8 @@ class Client extends Composer {
|
|
|
124
116
|
value: void 0
|
|
125
117
|
});
|
|
126
118
|
_Client_parseMode.set(this, void 0);
|
|
119
|
+
_Client_apiId.set(this, void 0);
|
|
120
|
+
_Client_apiHash.set(this, void 0);
|
|
127
121
|
Object.defineProperty(this, "appVersion", {
|
|
128
122
|
enumerable: true,
|
|
129
123
|
configurable: true,
|
|
@@ -162,8 +156,8 @@ class Client extends Composer {
|
|
|
162
156
|
});
|
|
163
157
|
_Client_publicKeys.set(this, void 0);
|
|
164
158
|
_Client_ignoreOutgoing.set(this, void 0);
|
|
165
|
-
|
|
166
|
-
|
|
159
|
+
_Client_persistCache.set(this, void 0);
|
|
160
|
+
_Client_LsignIn.set(this, void 0);
|
|
167
161
|
_Client_LpingLoop.set(this, void 0);
|
|
168
162
|
_Client_LhandleMigrationError.set(this, void 0);
|
|
169
163
|
_Client_L$initConncetion.set(this, void 0);
|
|
@@ -264,9 +258,9 @@ class Client extends Composer {
|
|
|
264
258
|
}
|
|
265
259
|
(0, _0_deps_js_1.unreachable)();
|
|
266
260
|
};
|
|
267
|
-
const chat_ = "messageReactions" in update ? update.messageReactions.chat : "messageReactionCount" in update ? update.messageReactionCount.chat : undefined;
|
|
261
|
+
const chat_ = "messageReactions" in update ? update.messageReactions.chat : "messageReactionCount" in update ? update.messageReactionCount.chat : "chatMember" in update ? update.chatMember.chat : undefined;
|
|
268
262
|
const chat = chat_ ?? msg?.chat;
|
|
269
|
-
const from = "callbackQuery" in update ? update.callbackQuery.from : "inlineQuery" in update ? update.inlineQuery.from : "message" in update ? update.message.from : "editedMessage" in update ? update.editedMessage?.from : undefined;
|
|
263
|
+
const from = "callbackQuery" in update ? update.callbackQuery.from : "inlineQuery" in update ? update.inlineQuery.from : "message" in update ? update.message.from : "editedMessage" in update ? update.editedMessage?.from : "chatMember" in update ? update.chatMember.from : "messageReactions" in update ? update.messageReactions.user : undefined;
|
|
270
264
|
const senderChat = msg?.senderChat;
|
|
271
265
|
const getReplyToMessageId = (quote, chatId, messageId) => {
|
|
272
266
|
const isPrivate = chatId > 0;
|
|
@@ -642,14 +636,18 @@ class Client extends Composer {
|
|
|
642
636
|
}
|
|
643
637
|
},
|
|
644
638
|
};
|
|
645
|
-
this
|
|
646
|
-
__classPrivateFieldSet(this,
|
|
647
|
-
|
|
648
|
-
|
|
639
|
+
__classPrivateFieldSet(this, _Client_apiId, params?.apiId ?? 0, "f");
|
|
640
|
+
__classPrivateFieldSet(this, _Client_apiHash, params?.apiHash ?? "", "f");
|
|
641
|
+
__classPrivateFieldSet(this, _Client_storage_, params?.storage || new _2_storage_js_1.StorageMemory(), "f");
|
|
642
|
+
__classPrivateFieldSet(this, _Client_persistCache, params?.persistCache ?? false, "f");
|
|
643
|
+
if (!__classPrivateFieldGet(this, _Client_persistCache, "f")) {
|
|
644
|
+
__classPrivateFieldSet(this, _Client_messageStorage_, new _2_storage_js_1.StorageMemory(), "f");
|
|
649
645
|
}
|
|
650
646
|
else {
|
|
651
|
-
this
|
|
647
|
+
__classPrivateFieldSet(this, _Client_messageStorage_, __classPrivateFieldGet(this, _Client_storage_, "f"), "f");
|
|
652
648
|
}
|
|
649
|
+
this.storage = new _0_storage_operations_js_1.StorageOperations(__classPrivateFieldGet(this, _Client_storage_, "f"));
|
|
650
|
+
this.messageStorage = new _0_storage_operations_js_1.StorageOperations(__classPrivateFieldGet(this, _Client_messageStorage_, "f"));
|
|
653
651
|
__classPrivateFieldSet(this, _Client_parseMode, params?.parseMode ?? null, "f");
|
|
654
652
|
this.appVersion = params?.appVersion ?? _4_constants_js_1.APP_VERSION;
|
|
655
653
|
this.deviceModel = params?.deviceModel ?? _4_constants_js_1.DEVICE_MODEL;
|
|
@@ -664,7 +662,7 @@ class Client extends Composer {
|
|
|
664
662
|
}
|
|
665
663
|
__classPrivateFieldSet(this, _Client_guaranteeUpdateDelivery, params?.guaranteeUpdateDelivery ?? false, "f");
|
|
666
664
|
const L = (0, _1_utilities_js_1.getLogger)("Client").client(id++);
|
|
667
|
-
__classPrivateFieldSet(this,
|
|
665
|
+
__classPrivateFieldSet(this, _Client_LsignIn, L.branch("signIn"), "f");
|
|
668
666
|
__classPrivateFieldSet(this, _Client_LpingLoop, L.branch("pingLoop"), "f");
|
|
669
667
|
__classPrivateFieldSet(this, _Client_LhandleMigrationError, L.branch("[handleMigrationError]"), "f");
|
|
670
668
|
__classPrivateFieldSet(this, _Client_L$initConncetion, L.branch("#initConnection"), "f");
|
|
@@ -697,19 +695,19 @@ class Client extends Composer {
|
|
|
697
695
|
ignoreOutgoing: __classPrivateFieldGet(this, _Client_ignoreOutgoing, "f"),
|
|
698
696
|
dropPendingUpdates: params?.dropPendingUpdates,
|
|
699
697
|
};
|
|
700
|
-
__classPrivateFieldSet(this, _Client_updateManager, new
|
|
701
|
-
__classPrivateFieldSet(this, _Client_networkStatisticsManager, new
|
|
702
|
-
__classPrivateFieldSet(this, _Client_botInfoManager, new
|
|
703
|
-
__classPrivateFieldSet(this, _Client_fileManager, new
|
|
704
|
-
__classPrivateFieldSet(this, _Client_reactionManager, new
|
|
705
|
-
__classPrivateFieldSet(this, _Client_businessConnectionManager, new
|
|
706
|
-
__classPrivateFieldSet(this, _Client_videoChatManager, new
|
|
707
|
-
__classPrivateFieldSet(this, _Client_messageManager, new
|
|
708
|
-
__classPrivateFieldSet(this, _Client_callbackQueryManager, new
|
|
709
|
-
__classPrivateFieldSet(this, _Client_storyManager, new
|
|
710
|
-
__classPrivateFieldSet(this, _Client_inlineQueryManager, new
|
|
711
|
-
__classPrivateFieldSet(this, _Client_chatListManager, new
|
|
712
|
-
__classPrivateFieldSet(this, _Client_accountManager, new
|
|
698
|
+
__classPrivateFieldSet(this, _Client_updateManager, new _2_update_manager_js_1.UpdateManager(c), "f");
|
|
699
|
+
__classPrivateFieldSet(this, _Client_networkStatisticsManager, new _2_network_statistics_manager_js_1.NetworkStatisticsManager(c), "f");
|
|
700
|
+
__classPrivateFieldSet(this, _Client_botInfoManager, new _2_bot_info_manager_js_1.BotInfoManager(c), "f");
|
|
701
|
+
__classPrivateFieldSet(this, _Client_fileManager, new _2_file_manager_js_1.FileManager(c), "f");
|
|
702
|
+
__classPrivateFieldSet(this, _Client_reactionManager, new _2_reaction_manager_js_1.ReactionManager(c), "f");
|
|
703
|
+
__classPrivateFieldSet(this, _Client_businessConnectionManager, new _2_business_connection_manager_js_1.BusinessConnectionManager(c), "f");
|
|
704
|
+
__classPrivateFieldSet(this, _Client_videoChatManager, new _3_video_chat_manager_js_1.VideoChatManager({ ...c, fileManager: __classPrivateFieldGet(this, _Client_fileManager, "f") }), "f");
|
|
705
|
+
__classPrivateFieldSet(this, _Client_messageManager, new _3_message_manager_js_1.MessageManager({ ...c, fileManager: __classPrivateFieldGet(this, _Client_fileManager, "f") }), "f");
|
|
706
|
+
__classPrivateFieldSet(this, _Client_callbackQueryManager, new _4_callback_query_manager_js_1.CallbackQueryManager({ ...c, messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
|
|
707
|
+
__classPrivateFieldSet(this, _Client_storyManager, new _4_story_manager_js_1.StoryManager({ ...c, fileManager: __classPrivateFieldGet(this, _Client_fileManager, "f"), messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
|
|
708
|
+
__classPrivateFieldSet(this, _Client_inlineQueryManager, new _4_inline_query_manager_js_1.InlineQueryManager({ ...c, messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
|
|
709
|
+
__classPrivateFieldSet(this, _Client_chatListManager, new _4_chat_list_manager_js_1.ChatListManager({ ...c, fileManager: __classPrivateFieldGet(this, _Client_fileManager, "f"), messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
|
|
710
|
+
__classPrivateFieldSet(this, _Client_accountManager, new _2_account_manager_js_1.AccountManager(c), "f");
|
|
713
711
|
__classPrivateFieldGet(this, _Client_updateManager, "f").setUpdateHandler(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleUpdate).bind(this));
|
|
714
712
|
const transportProvider = __classPrivateFieldGet(this, _Client_client, "f").transportProvider;
|
|
715
713
|
__classPrivateFieldGet(this, _Client_client, "f").transportProvider = (params) => {
|
|
@@ -818,10 +816,10 @@ class Client extends Composer {
|
|
|
818
816
|
}
|
|
819
817
|
await this.connect();
|
|
820
818
|
}
|
|
821
|
-
async [(_Client_client = new WeakMap(), _Client_guaranteeUpdateDelivery = new WeakMap(), _Client_updateManager = new WeakMap(), _Client_networkStatisticsManager = new WeakMap(), _Client_botInfoManager = new WeakMap(), _Client_fileManager = new WeakMap(), _Client_reactionManager = new WeakMap(), _Client_videoChatManager = new WeakMap(), _Client_businessConnectionManager = new WeakMap(), _Client_messageManager = new WeakMap(), _Client_storyManager = new WeakMap(), _Client_callbackQueryManager = new WeakMap(), _Client_inlineQueryManager = new WeakMap(), _Client_chatListManager = new WeakMap(), _Client_accountManager = new WeakMap(), _Client_parseMode = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(),
|
|
822
|
-
const apiId = this
|
|
819
|
+
async [(_Client_client = new WeakMap(), _Client_guaranteeUpdateDelivery = new WeakMap(), _Client_updateManager = new WeakMap(), _Client_networkStatisticsManager = new WeakMap(), _Client_botInfoManager = new WeakMap(), _Client_fileManager = new WeakMap(), _Client_reactionManager = new WeakMap(), _Client_videoChatManager = new WeakMap(), _Client_businessConnectionManager = new WeakMap(), _Client_messageManager = new WeakMap(), _Client_storyManager = new WeakMap(), _Client_callbackQueryManager = new WeakMap(), _Client_inlineQueryManager = new WeakMap(), _Client_chatListManager = new WeakMap(), _Client_accountManager = new WeakMap(), _Client_storage_ = new WeakMap(), _Client_messageStorage_ = new WeakMap(), _Client_parseMode = new WeakMap(), _Client_apiId = new WeakMap(), _Client_apiHash = new WeakMap(), _Client_publicKeys = new WeakMap(), _Client_ignoreOutgoing = new WeakMap(), _Client_persistCache = new WeakMap(), _Client_LsignIn = new WeakMap(), _Client_LpingLoop = new WeakMap(), _Client_LhandleMigrationError = new WeakMap(), _Client_L$initConncetion = new WeakMap(), _Client_namespaceProxies = new WeakMap(), _Client_constructContext = new WeakMap(), _Client_lastPropagatedConnectionState = new WeakMap(), _Client_stateChangeHandler = new WeakMap(), _Client_storageInited = new WeakMap(), _Client_connectionInited = new WeakMap(), _Client_lastPropagatedAuthorizationState = new WeakMap(), _Client_pingLoopStarted = new WeakMap(), _Client_pingLoopAbortController = new WeakMap(), _Client_pingInterval = new WeakMap(), _Client_lastUpdates = new WeakMap(), _Client_handleInvokeError = new WeakMap(), _Client_lastGetMe = new WeakMap(), _Client_instances = new WeakSet(), _Client_getApiId = async function _Client_getApiId() {
|
|
820
|
+
const apiId = __classPrivateFieldGet(this, _Client_apiId, "f") || await this.storage.getApiId();
|
|
823
821
|
if (!apiId) {
|
|
824
|
-
throw new
|
|
822
|
+
throw new _0_errors_js_1.InputError("apiId not set");
|
|
825
823
|
}
|
|
826
824
|
return apiId;
|
|
827
825
|
}, _Client_getCdnConnectionPool = function _Client_getCdnConnectionPool(connectionCount, dcId) {
|
|
@@ -850,7 +848,11 @@ class Client extends Composer {
|
|
|
850
848
|
},
|
|
851
849
|
};
|
|
852
850
|
}, _Client_getCdnConnection = function _Client_getCdnConnection(dcId) {
|
|
853
|
-
const
|
|
851
|
+
const provider = this.storage.provider;
|
|
852
|
+
const client = new _a({
|
|
853
|
+
storage: (!dcId || dcId == __classPrivateFieldGet(this, _Client_client, "f").dcId) ? provider : provider.branch(`download_client_${dcId}`),
|
|
854
|
+
apiId: __classPrivateFieldGet(this, _Client_apiId, "f"),
|
|
855
|
+
apiHash: __classPrivateFieldGet(this, _Client_apiHash, "f"),
|
|
854
856
|
transportProvider: __classPrivateFieldGet(this, _Client_client, "f").transportProvider,
|
|
855
857
|
appVersion: this.appVersion,
|
|
856
858
|
deviceModel: this.deviceModel,
|
|
@@ -915,25 +917,19 @@ class Client extends Composer {
|
|
|
915
917
|
__classPrivateFieldGet(this, _Client_pingLoopAbortController, "f")?.abort();
|
|
916
918
|
}
|
|
917
919
|
/**
|
|
918
|
-
*
|
|
919
|
-
*
|
|
920
|
-
* - Bot token (`string`)
|
|
921
|
-
* - User authorization handlers (`AuthorizeUserParams`)
|
|
922
|
-
*
|
|
923
|
-
* if the current auth key doesn't throw AUTH_KEY_UNREGISTERED when calling [updates.getState](1).
|
|
920
|
+
* Signs in using the provided parameters if not already signed in.
|
|
921
|
+
* If no parameters are provided, the credentials will be prompted in runtime.
|
|
924
922
|
*
|
|
925
923
|
* Notes:
|
|
926
924
|
* 1. Requires the `apiId` and `apiHash` paramters to be passed when constructing the client.
|
|
927
|
-
*
|
|
928
|
-
*
|
|
929
|
-
* [1]: https://core.telegram.org/method/updates.getState
|
|
925
|
+
* 3. Reconnects the client to the appropriate DC in case of MIGRATE_X errors.
|
|
930
926
|
*/
|
|
931
|
-
async
|
|
927
|
+
async signIn(params) {
|
|
932
928
|
try {
|
|
933
|
-
await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("
|
|
929
|
+
await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("signIn");
|
|
934
930
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, true);
|
|
935
|
-
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("
|
|
936
|
-
__classPrivateFieldGet(this,
|
|
931
|
+
(0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("signIn"));
|
|
932
|
+
__classPrivateFieldGet(this, _Client_LsignIn, "f").debug("already signed in");
|
|
937
933
|
return;
|
|
938
934
|
}
|
|
939
935
|
catch (err) {
|
|
@@ -942,23 +938,23 @@ class Client extends Composer {
|
|
|
942
938
|
}
|
|
943
939
|
}
|
|
944
940
|
const apiId = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getApiId).call(this);
|
|
945
|
-
if (!this
|
|
946
|
-
throw new
|
|
941
|
+
if (!__classPrivateFieldGet(this, _Client_apiHash, "f")) {
|
|
942
|
+
throw new _0_errors_js_1.InputError("apiHash not set");
|
|
947
943
|
}
|
|
948
944
|
if (typeof params === "undefined") {
|
|
949
945
|
const loginType = (0, _1_utilities_js_1.mustPromptOneOf)("Do you want to login as bot [b] or user [u]?", ["b", "u"]);
|
|
950
946
|
if (loginType == "b") {
|
|
951
|
-
params = (0, _1_utilities_js_1.mustPrompt)("Bot token:");
|
|
947
|
+
params = { botToken: (0, _1_utilities_js_1.mustPrompt)("Bot token:") };
|
|
952
948
|
}
|
|
953
949
|
else {
|
|
954
950
|
params = { phone: () => (0, _1_utilities_js_1.mustPrompt)("Phone number:"), code: () => (0, _1_utilities_js_1.mustPrompt)("Verification code:"), password: () => (0, _1_utilities_js_1.mustPrompt)("Password:") };
|
|
955
951
|
}
|
|
956
952
|
}
|
|
957
|
-
__classPrivateFieldGet(this,
|
|
958
|
-
if (
|
|
953
|
+
__classPrivateFieldGet(this, _Client_LsignIn, "f").debug("authorizing with", typeof params === "string" ? "bot token" : params instanceof _2_tl_js_1.types.auth.ExportedAuthorization ? "exported authorization" : "AuthorizeUserParams");
|
|
954
|
+
if (params && "botToken" in params) {
|
|
959
955
|
while (true) {
|
|
960
956
|
try {
|
|
961
|
-
const auth = await this.api.auth.importBotAuthorization({ api_id: apiId, api_hash: this
|
|
957
|
+
const auth = await this.api.auth.importBotAuthorization({ api_id: apiId, api_hash: __classPrivateFieldGet(this, _Client_apiHash, "f"), bot_auth_token: params.botToken, flags: 0 });
|
|
962
958
|
await this.storage.setAccountId(Number(auth[_2_tl_js_1.as](_2_tl_js_1.types.auth.Authorization).user.id));
|
|
963
959
|
await this.storage.setAccountType("bot");
|
|
964
960
|
break;
|
|
@@ -973,7 +969,7 @@ class Client extends Composer {
|
|
|
973
969
|
}
|
|
974
970
|
}
|
|
975
971
|
}
|
|
976
|
-
__classPrivateFieldGet(this,
|
|
972
|
+
__classPrivateFieldGet(this, _Client_LsignIn, "f").debug("authorized as bot");
|
|
977
973
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, true);
|
|
978
974
|
await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("authorize");
|
|
979
975
|
return;
|
|
@@ -987,8 +983,8 @@ class Client extends Composer {
|
|
|
987
983
|
phone = typeof params.phone === "string" ? params.phone : await params.phone();
|
|
988
984
|
const sendCode = () => this.api.auth.sendCode({
|
|
989
985
|
phone_number: phone,
|
|
990
|
-
api_id: this
|
|
991
|
-
api_hash: this
|
|
986
|
+
api_id: __classPrivateFieldGet(this, _Client_apiId, "f"),
|
|
987
|
+
api_hash: __classPrivateFieldGet(this, _Client_apiHash, "f"),
|
|
992
988
|
settings: new _2_tl_js_1.types.CodeSettings(),
|
|
993
989
|
}).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.auth.SentCode));
|
|
994
990
|
try {
|
|
@@ -1014,7 +1010,7 @@ class Client extends Composer {
|
|
|
1014
1010
|
}
|
|
1015
1011
|
}
|
|
1016
1012
|
}
|
|
1017
|
-
__classPrivateFieldGet(this,
|
|
1013
|
+
__classPrivateFieldGet(this, _Client_LsignIn, "f").debug("verification code sent");
|
|
1018
1014
|
let err;
|
|
1019
1015
|
code: while (true) {
|
|
1020
1016
|
const code = typeof params.code === "string" ? params.code : await params.code();
|
|
@@ -1026,13 +1022,13 @@ class Client extends Composer {
|
|
|
1026
1022
|
});
|
|
1027
1023
|
await this.storage.setAccountId(Number(auth[_2_tl_js_1.as](_2_tl_js_1.types.auth.Authorization).user.id));
|
|
1028
1024
|
await this.storage.setAccountType("user");
|
|
1029
|
-
__classPrivateFieldGet(this,
|
|
1025
|
+
__classPrivateFieldGet(this, _Client_LsignIn, "f").debug("signed in as user");
|
|
1030
1026
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, true);
|
|
1031
|
-
await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("
|
|
1027
|
+
await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("signIn");
|
|
1032
1028
|
return;
|
|
1033
1029
|
}
|
|
1034
1030
|
catch (err_) {
|
|
1035
|
-
if (err_ instanceof
|
|
1031
|
+
if (err_ instanceof _4_errors_js_2.PhoneCodeInvalid) {
|
|
1036
1032
|
continue code;
|
|
1037
1033
|
}
|
|
1038
1034
|
else {
|
|
@@ -1055,9 +1051,9 @@ class Client extends Composer {
|
|
|
1055
1051
|
const auth = await this.api.auth.checkPassword({ password: input });
|
|
1056
1052
|
await this.storage.setAccountId(Number(auth[_2_tl_js_1.as](_2_tl_js_1.types.auth.Authorization).user.id));
|
|
1057
1053
|
await this.storage.setAccountType("user");
|
|
1058
|
-
__classPrivateFieldGet(this,
|
|
1054
|
+
__classPrivateFieldGet(this, _Client_LsignIn, "f").debug("signed in as user");
|
|
1059
1055
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, true);
|
|
1060
|
-
await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("
|
|
1056
|
+
await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("signIn");
|
|
1061
1057
|
return;
|
|
1062
1058
|
}
|
|
1063
1059
|
catch (err) {
|
|
@@ -1080,12 +1076,26 @@ class Client extends Composer {
|
|
|
1080
1076
|
}
|
|
1081
1077
|
}
|
|
1082
1078
|
}
|
|
1079
|
+
async signOut() {
|
|
1080
|
+
try {
|
|
1081
|
+
await Promise.all([
|
|
1082
|
+
this.storage.reset(),
|
|
1083
|
+
this.api.auth.logOut().then(() => {
|
|
1084
|
+
__classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, false);
|
|
1085
|
+
}),
|
|
1086
|
+
]);
|
|
1087
|
+
}
|
|
1088
|
+
finally {
|
|
1089
|
+
__classPrivateFieldSet(this, _Client_lastGetMe, null, "f");
|
|
1090
|
+
await this.reconnect();
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1083
1093
|
/**
|
|
1084
|
-
* Same as calling `.connect()` followed by `.
|
|
1094
|
+
* Same as calling `.connect()` followed by `.signIn(params)`.
|
|
1085
1095
|
*/
|
|
1086
1096
|
async start(params) {
|
|
1087
1097
|
await this.connect();
|
|
1088
|
-
await this.
|
|
1098
|
+
await this.signIn(params);
|
|
1089
1099
|
}
|
|
1090
1100
|
/**
|
|
1091
1101
|
* Alias for `invoke` with its second parameter being `true`.
|
|
@@ -1094,7 +1104,7 @@ class Client extends Composer {
|
|
|
1094
1104
|
return this.invoke(function_, true);
|
|
1095
1105
|
}
|
|
1096
1106
|
exportAuthString() {
|
|
1097
|
-
return this.storage.exportAuthString(this
|
|
1107
|
+
return this.storage.exportAuthString(__classPrivateFieldGet(this, _Client_apiId, "f"));
|
|
1098
1108
|
}
|
|
1099
1109
|
async importAuthString(authString) {
|
|
1100
1110
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_initStorage).call(this);
|
|
@@ -2385,7 +2395,7 @@ exports.Client = Client;
|
|
|
2385
2395
|
_a = Client, _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(update) {
|
|
2386
2396
|
await this.middleware()(await __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, update), _0_utilities_js_1.resolve);
|
|
2387
2397
|
}, _Client_queueHandleCtxUpdate = function _Client_queueHandleCtxUpdate(update) {
|
|
2388
|
-
__classPrivateFieldGet(this, _Client_updateManager, "f").getHandleUpdateQueue(
|
|
2398
|
+
__classPrivateFieldGet(this, _Client_updateManager, "f").getHandleUpdateQueue(_2_update_manager_js_1.UpdateManager.MAIN_BOX_ID).add(async () => {
|
|
2389
2399
|
await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, update);
|
|
2390
2400
|
});
|
|
2391
2401
|
}, _Client_handleUpdate = async function _Client_handleUpdate(update) {
|
|
@@ -2401,7 +2411,7 @@ _a = Client, _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(up
|
|
|
2401
2411
|
await this.messageStorage.setEntity(entity);
|
|
2402
2412
|
}
|
|
2403
2413
|
}
|
|
2404
|
-
if (
|
|
2414
|
+
if (_3_message_manager_js_1.MessageManager.canHandleUpdate(update)) {
|
|
2405
2415
|
const update_ = await __classPrivateFieldGet(this, _Client_messageManager, "f").handleUpdate(update);
|
|
2406
2416
|
if (update_) {
|
|
2407
2417
|
promises.push((async () => {
|
|
@@ -2419,31 +2429,31 @@ _a = Client, _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(up
|
|
|
2419
2429
|
})());
|
|
2420
2430
|
}
|
|
2421
2431
|
}
|
|
2422
|
-
if (
|
|
2432
|
+
if (_3_video_chat_manager_js_1.VideoChatManager.canHandleUpdate(update)) {
|
|
2423
2433
|
promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, await __classPrivateFieldGet(this, _Client_videoChatManager, "f").handleUpdate(update)));
|
|
2424
2434
|
}
|
|
2425
|
-
if (
|
|
2435
|
+
if (_4_callback_query_manager_js_1.CallbackQueryManager.canHandleUpdate(update)) {
|
|
2426
2436
|
promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, await __classPrivateFieldGet(this, _Client_callbackQueryManager, "f").handleUpdate(update)));
|
|
2427
2437
|
}
|
|
2428
|
-
if (
|
|
2438
|
+
if (_4_inline_query_manager_js_1.InlineQueryManager.canHandleUpdate(update)) {
|
|
2429
2439
|
promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, await __classPrivateFieldGet(this, _Client_inlineQueryManager, "f").handleUpdate(update)));
|
|
2430
2440
|
}
|
|
2431
|
-
if (
|
|
2441
|
+
if (_2_reaction_manager_js_1.ReactionManager.canHandleUpdate(update)) {
|
|
2432
2442
|
const upd = await __classPrivateFieldGet(this, _Client_reactionManager, "f").handleUpdate(update);
|
|
2433
2443
|
if (upd) {
|
|
2434
2444
|
promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, upd));
|
|
2435
2445
|
}
|
|
2436
2446
|
}
|
|
2437
|
-
if (
|
|
2447
|
+
if (_4_chat_list_manager_js_1.ChatListManager.canHandleUpdate(update)) {
|
|
2438
2448
|
await __classPrivateFieldGet(this, _Client_chatListManager, "f").handleUpdate(update);
|
|
2439
2449
|
}
|
|
2440
|
-
if (
|
|
2450
|
+
if (_4_story_manager_js_1.StoryManager.canHandleUpdate(update)) {
|
|
2441
2451
|
const upd = await __classPrivateFieldGet(this, _Client_storyManager, "f").handleUpdate(update);
|
|
2442
2452
|
if (upd) {
|
|
2443
2453
|
promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, upd));
|
|
2444
2454
|
}
|
|
2445
2455
|
}
|
|
2446
|
-
if (
|
|
2456
|
+
if (_2_business_connection_manager_js_1.BusinessConnectionManager.canHandleUpdate(update)) {
|
|
2447
2457
|
promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, await __classPrivateFieldGet(this, _Client_businessConnectionManager, "f").handleUpdate(update)));
|
|
2448
2458
|
}
|
|
2449
2459
|
return () => Promise.all(promises);
|
|
@@ -18,24 +18,15 @@
|
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
20
|
import { MaybePromise } from "../1_utilities.js";
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
export interface Connection {
|
|
22
|
+
get connected(): boolean;
|
|
23
23
|
stateChangeHandler?: (connected: boolean) => void;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
open(): MaybePromise<void>;
|
|
25
|
+
write(p: Uint8Array): MaybePromise<void>;
|
|
26
|
+
close(): MaybePromise<void>;
|
|
27
27
|
callback?: {
|
|
28
28
|
read(count: number): void;
|
|
29
29
|
write(count: number): void;
|
|
30
30
|
};
|
|
31
|
+
read(p: Uint8Array): MaybePromise<void>;
|
|
31
32
|
}
|
|
32
|
-
export declare abstract class ConnectionUnframed extends Foundation {
|
|
33
|
-
readonly type: "framed";
|
|
34
|
-
abstract read(p: Uint8Array): MaybePromise<void>;
|
|
35
|
-
}
|
|
36
|
-
export declare abstract class ConnectionFramed extends Foundation {
|
|
37
|
-
readonly type: "framed";
|
|
38
|
-
abstract read(): MaybePromise<Uint8Array>;
|
|
39
|
-
}
|
|
40
|
-
export type Connection = ConnectionUnframed | ConnectionFramed;
|
|
41
|
-
export {};
|
|
@@ -19,44 +19,3 @@
|
|
|
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.ConnectionFramed = exports.ConnectionUnframed = void 0;
|
|
23
|
-
class Foundation {
|
|
24
|
-
constructor() {
|
|
25
|
-
Object.defineProperty(this, "stateChangeHandler", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
configurable: true,
|
|
28
|
-
writable: true,
|
|
29
|
-
value: void 0
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(this, "callback", {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
configurable: true,
|
|
34
|
-
writable: true,
|
|
35
|
-
value: void 0
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
class ConnectionUnframed extends Foundation {
|
|
40
|
-
constructor() {
|
|
41
|
-
super(...arguments);
|
|
42
|
-
Object.defineProperty(this, "type", {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
configurable: true,
|
|
45
|
-
writable: true,
|
|
46
|
-
value: "framed"
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.ConnectionUnframed = ConnectionUnframed;
|
|
51
|
-
class ConnectionFramed extends Foundation {
|
|
52
|
-
constructor() {
|
|
53
|
-
super(...arguments);
|
|
54
|
-
Object.defineProperty(this, "type", {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
configurable: true,
|
|
57
|
-
writable: true,
|
|
58
|
-
value: "framed"
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
exports.ConnectionFramed = ConnectionFramed;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class ConnectionWebSocket
|
|
1
|
+
import { Connection } from "./0_connection.js";
|
|
2
|
+
export declare class ConnectionWebSocket implements Connection {
|
|
3
3
|
#private;
|
|
4
4
|
private readonly url;
|
|
5
|
+
stateChangeHandler?: Connection["stateChangeHandler"];
|
|
5
6
|
constructor(url: string | URL);
|
|
6
7
|
get connected(): boolean;
|
|
7
8
|
open(): Promise<void>;
|
|
@@ -58,12 +58,10 @@ exports.ConnectionWebSocket = void 0;
|
|
|
58
58
|
const dntShim = __importStar(require("../_dnt.shims.js"));
|
|
59
59
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
60
60
|
const _1_utilities_js_1 = require("../1_utilities.js");
|
|
61
|
-
const _0_connection_js_1 = require("./0_connection.js");
|
|
62
61
|
const L = (0, _1_utilities_js_1.getLogger)("ConnectionWebSocket");
|
|
63
62
|
const errConnectionNotOpen = new Error("Connection not open");
|
|
64
|
-
class ConnectionWebSocket
|
|
63
|
+
class ConnectionWebSocket {
|
|
65
64
|
constructor(url) {
|
|
66
|
-
super();
|
|
67
65
|
_ConnectionWebSocket_instances.add(this);
|
|
68
66
|
Object.defineProperty(this, "url", {
|
|
69
67
|
enumerable: true,
|
|
@@ -76,6 +74,12 @@ class ConnectionWebSocket extends _0_connection_js_1.ConnectionUnframed {
|
|
|
76
74
|
_ConnectionWebSocket_wMutex.set(this, new _1_utilities_js_1.Mutex());
|
|
77
75
|
_ConnectionWebSocket_buffer.set(this, new Uint8Array());
|
|
78
76
|
_ConnectionWebSocket_nextResolve.set(this, null);
|
|
77
|
+
Object.defineProperty(this, "stateChangeHandler", {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
configurable: true,
|
|
80
|
+
writable: true,
|
|
81
|
+
value: void 0
|
|
82
|
+
});
|
|
79
83
|
_ConnectionWebSocket_wasConnected.set(this, false);
|
|
80
84
|
_ConnectionWebSocket_isConnecting.set(this, false);
|
|
81
85
|
_ConnectionWebSocket_connectionError.set(this, null);
|
package/script/mod.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export * from "./0_errors.js";
|
|
|
21
21
|
export { getColorFromPeerId, getColorName, getRandomId, type LoggingProvider, setLoggingProvider, setLogVerbosity } from "./1_utilities.js";
|
|
22
22
|
export { checkPassword } from "./client/0_password.js";
|
|
23
23
|
export * from "./2_connection.js";
|
|
24
|
-
export * from "./
|
|
24
|
+
export * from "./2_storage.js";
|
|
25
25
|
export * from "./3_transport.js";
|
|
26
26
|
export * from "./2_tl.js";
|
|
27
27
|
export * from "./3_types.js";
|
package/script/mod.js
CHANGED
|
@@ -56,7 +56,7 @@ Object.defineProperty(exports, "setLogVerbosity", { enumerable: true, get: funct
|
|
|
56
56
|
var _0_password_js_1 = require("./client/0_password.js");
|
|
57
57
|
Object.defineProperty(exports, "checkPassword", { enumerable: true, get: function () { return _0_password_js_1.checkPassword; } });
|
|
58
58
|
__exportStar(require("./2_connection.js"), exports);
|
|
59
|
-
__exportStar(require("./
|
|
59
|
+
__exportStar(require("./2_storage.js"), exports);
|
|
60
60
|
__exportStar(require("./3_transport.js"), exports);
|
|
61
61
|
__exportStar(require("./2_tl.js"), exports);
|
|
62
62
|
__exportStar(require("./3_types.js"), exports);
|