@mtkruto/node 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.
Files changed (179) hide show
  1. package/esm/3_types.d.ts +6 -1
  2. package/esm/3_types.js +6 -1
  3. package/esm/4_errors.js +2 -4
  4. package/esm/5_client.d.ts +1 -1
  5. package/esm/5_client.js +1 -1
  6. package/esm/client/0_params.d.ts +33 -7
  7. package/esm/client/0_storage_operations.d.ts +182 -0
  8. package/esm/client/0_storage_operations.js +611 -0
  9. package/esm/client/1_composer.d.ts +2 -0
  10. package/esm/client/1_composer.js +28 -0
  11. package/{script/client/0_types.d.ts → esm/client/1_types.d.ts} +3 -3
  12. package/{script/client/1_account_manager.d.ts → esm/client/2_account_manager.d.ts} +1 -1
  13. package/{script/client/1_bot_info_manager.d.ts → esm/client/2_bot_info_manager.d.ts} +1 -1
  14. package/esm/client/{1_business_connection_manager.d.ts → 2_business_connection_manager.d.ts} +1 -1
  15. package/{script/client/1_file_manager.d.ts → esm/client/2_file_manager.d.ts} +6 -2
  16. package/esm/client/{1_file_manager.js → 2_file_manager.js} +55 -52
  17. package/esm/client/{1_network_statistics_manager.d.ts → 2_network_statistics_manager.d.ts} +1 -1
  18. package/{script/client/1_reaction_manager.d.ts → esm/client/2_reaction_manager.d.ts} +1 -1
  19. package/{script/client/1_update_manager.d.ts → esm/client/2_update_manager.d.ts} +1 -1
  20. package/esm/client/{2_message_manager.d.ts → 3_message_manager.d.ts} +2 -2
  21. package/esm/client/3_video_chat_manager.d.ts +43 -0
  22. package/esm/client/3_video_chat_manager.js +194 -0
  23. package/esm/client/{3_callback_query_manager.d.ts → 4_callback_query_manager.d.ts} +2 -2
  24. package/esm/client/{3_callback_query_manager.js → 4_callback_query_manager.js} +1 -0
  25. package/{script/client/3_chat_list_manager.d.ts → esm/client/4_chat_list_manager.d.ts} +6 -6
  26. package/esm/client/{3_chat_list_manager.js → 4_chat_list_manager.js} +75 -98
  27. package/esm/client/{3_inline_query_manager.d.ts → 4_inline_query_manager.d.ts} +2 -2
  28. package/esm/client/{3_inline_query_manager.js → 4_inline_query_manager.js} +1 -0
  29. package/esm/client/{3_story_manager.d.ts → 4_story_manager.d.ts} +3 -3
  30. package/{script/client/4_client.d.ts → esm/client/5_client.d.ts} +105 -31
  31. package/esm/client/{4_client.js → 5_client.js} +172 -73
  32. package/esm/connection/0_connection.d.ts +6 -15
  33. package/esm/connection/0_connection.js +1 -38
  34. package/esm/connection/1_connection_web_socket.d.ts +3 -2
  35. package/esm/connection/1_connection_web_socket.js +7 -3
  36. package/esm/mod.d.ts +1 -1
  37. package/esm/mod.js +1 -1
  38. package/esm/storage/0_storage.d.ts +9 -145
  39. package/esm/storage/0_storage.js +1 -526
  40. package/esm/storage/2_storage_indexed_db.d.ts +3 -2
  41. package/esm/storage/2_storage_indexed_db.js +9 -8
  42. package/esm/storage/2_storage_local_storage.d.ts +3 -2
  43. package/esm/storage/2_storage_local_storage.js +5 -4
  44. package/esm/storage/2_storage_memory.d.ts +4 -4
  45. package/esm/storage/2_storage_memory.js +12 -19
  46. package/esm/storage/2_storage_session_storage.d.ts +2 -1
  47. package/esm/storage/2_storage_session_storage.js +5 -4
  48. package/esm/tl/3_utilities.d.ts +1 -1
  49. package/esm/tl/3_utilities.js +3 -3
  50. package/esm/types/0_birthday.d.ts +27 -0
  51. package/esm/types/0_birthday.js +26 -0
  52. package/esm/types/0_giveaway_parameters.d.ts +1 -1
  53. package/esm/types/0_id.d.ts +1 -1
  54. package/esm/types/0_live_stream_channel.d.ts +30 -0
  55. package/esm/types/0_live_stream_channel.js +26 -0
  56. package/esm/types/0_opening_hours.d.ts +25 -0
  57. package/esm/types/0_opening_hours.js +25 -0
  58. package/esm/types/0_video_chat.d.ts +60 -0
  59. package/esm/types/0_video_chat.js +53 -0
  60. package/esm/types/1_chat_p.d.ts +4 -0
  61. package/esm/types/1_chat_p.js +1 -0
  62. package/esm/types/2_business_connection.d.ts +6 -0
  63. package/esm/types/2_chat.d.ts +62 -0
  64. package/esm/types/2_chat.js +66 -0
  65. package/esm/types/2_inactive_chat.d.ts +1 -1
  66. package/esm/types/2_invite_link.d.ts +1 -1
  67. package/esm/types/2_message_reaction_count.d.ts +1 -1
  68. package/esm/types/2_message_reactions.d.ts +1 -1
  69. package/esm/types/3_chat_member_updated.d.ts +1 -1
  70. package/esm/types/4_message.d.ts +3 -3
  71. package/esm/types/5_chat_list_item.d.ts +35 -0
  72. package/esm/types/5_chat_list_item.js +86 -0
  73. package/esm/types/6_update.d.ts +14 -5
  74. package/esm/types/_file_id.d.ts +1 -0
  75. package/esm/utilities/0_bigint.d.ts +1 -0
  76. package/esm/utilities/0_bigint.js +7 -3
  77. package/package.json +1 -1
  78. package/script/3_types.d.ts +6 -1
  79. package/script/3_types.js +6 -1
  80. package/script/4_errors.js +2 -4
  81. package/script/5_client.d.ts +1 -1
  82. package/script/5_client.js +1 -1
  83. package/script/client/0_params.d.ts +33 -7
  84. package/script/client/0_storage_operations.d.ts +182 -0
  85. package/script/client/0_storage_operations.js +615 -0
  86. package/script/client/1_composer.d.ts +2 -0
  87. package/script/client/1_composer.js +28 -0
  88. package/{esm/client/0_types.d.ts → script/client/1_types.d.ts} +3 -3
  89. package/{esm/client/1_account_manager.d.ts → script/client/2_account_manager.d.ts} +1 -1
  90. package/{esm/client/1_bot_info_manager.d.ts → script/client/2_bot_info_manager.d.ts} +1 -1
  91. package/script/client/{1_business_connection_manager.d.ts → 2_business_connection_manager.d.ts} +1 -1
  92. package/{esm/client/1_file_manager.d.ts → script/client/2_file_manager.d.ts} +6 -2
  93. package/script/client/{1_file_manager.js → 2_file_manager.js} +54 -51
  94. package/script/client/{1_network_statistics_manager.d.ts → 2_network_statistics_manager.d.ts} +1 -1
  95. package/{esm/client/1_reaction_manager.d.ts → script/client/2_reaction_manager.d.ts} +1 -1
  96. package/{esm/client/1_update_manager.d.ts → script/client/2_update_manager.d.ts} +1 -1
  97. package/script/client/{2_message_manager.d.ts → 3_message_manager.d.ts} +2 -2
  98. package/script/client/3_video_chat_manager.d.ts +43 -0
  99. package/script/client/3_video_chat_manager.js +198 -0
  100. package/script/client/{3_callback_query_manager.d.ts → 4_callback_query_manager.d.ts} +2 -2
  101. package/script/client/{3_callback_query_manager.js → 4_callback_query_manager.js} +1 -0
  102. package/{esm/client/3_chat_list_manager.d.ts → script/client/4_chat_list_manager.d.ts} +6 -6
  103. package/script/client/{3_chat_list_manager.js → 4_chat_list_manager.js} +72 -95
  104. package/script/client/{3_inline_query_manager.d.ts → 4_inline_query_manager.d.ts} +2 -2
  105. package/script/client/{3_inline_query_manager.js → 4_inline_query_manager.js} +1 -0
  106. package/script/client/{3_story_manager.d.ts → 4_story_manager.d.ts} +3 -3
  107. package/{esm/client/4_client.d.ts → script/client/5_client.d.ts} +105 -31
  108. package/script/client/{4_client.js → 5_client.js} +192 -93
  109. package/script/connection/0_connection.d.ts +6 -15
  110. package/script/connection/0_connection.js +0 -41
  111. package/script/connection/1_connection_web_socket.d.ts +3 -2
  112. package/script/connection/1_connection_web_socket.js +7 -3
  113. package/script/mod.d.ts +1 -1
  114. package/script/mod.js +1 -1
  115. package/script/storage/0_storage.d.ts +9 -145
  116. package/script/storage/0_storage.js +0 -528
  117. package/script/storage/2_storage_indexed_db.d.ts +3 -2
  118. package/script/storage/2_storage_indexed_db.js +9 -8
  119. package/script/storage/2_storage_local_storage.d.ts +3 -2
  120. package/script/storage/2_storage_local_storage.js +5 -4
  121. package/script/storage/2_storage_memory.d.ts +4 -4
  122. package/script/storage/2_storage_memory.js +12 -19
  123. package/script/storage/2_storage_session_storage.d.ts +2 -1
  124. package/script/storage/2_storage_session_storage.js +5 -4
  125. package/script/tl/3_utilities.d.ts +1 -1
  126. package/script/tl/3_utilities.js +3 -3
  127. package/script/types/0_birthday.d.ts +27 -0
  128. package/script/types/0_birthday.js +30 -0
  129. package/script/types/0_giveaway_parameters.d.ts +1 -1
  130. package/script/types/0_id.d.ts +1 -1
  131. package/script/types/0_live_stream_channel.d.ts +30 -0
  132. package/script/types/0_live_stream_channel.js +30 -0
  133. package/script/types/0_opening_hours.d.ts +25 -0
  134. package/script/types/0_opening_hours.js +29 -0
  135. package/script/types/0_video_chat.d.ts +60 -0
  136. package/script/types/0_video_chat.js +57 -0
  137. package/script/types/1_chat_p.d.ts +4 -0
  138. package/script/types/1_chat_p.js +1 -0
  139. package/script/types/2_business_connection.d.ts +6 -0
  140. package/script/types/2_chat.d.ts +62 -0
  141. package/script/types/2_chat.js +70 -0
  142. package/script/types/2_inactive_chat.d.ts +1 -1
  143. package/script/types/2_invite_link.d.ts +1 -1
  144. package/script/types/2_message_reaction_count.d.ts +1 -1
  145. package/script/types/2_message_reactions.d.ts +1 -1
  146. package/script/types/3_chat_member_updated.d.ts +1 -1
  147. package/script/types/4_message.d.ts +3 -3
  148. package/script/types/5_chat_list_item.d.ts +35 -0
  149. package/script/types/5_chat_list_item.js +94 -0
  150. package/script/types/6_update.d.ts +14 -5
  151. package/script/types/_file_id.d.ts +1 -0
  152. package/script/utilities/0_bigint.d.ts +1 -0
  153. package/script/utilities/0_bigint.js +7 -3
  154. package/esm/types/5_chat.d.ts +0 -59
  155. package/esm/types/5_chat.js +0 -126
  156. package/script/types/5_chat.d.ts +0 -59
  157. package/script/types/5_chat.js +0 -134
  158. /package/esm/{3_storage.d.ts → 2_storage.d.ts} +0 -0
  159. /package/esm/{3_storage.js → 2_storage.js} +0 -0
  160. /package/esm/client/{0_types.js → 1_types.js} +0 -0
  161. /package/esm/client/{1_account_manager.js → 2_account_manager.js} +0 -0
  162. /package/esm/client/{1_bot_info_manager.js → 2_bot_info_manager.js} +0 -0
  163. /package/esm/client/{1_business_connection_manager.js → 2_business_connection_manager.js} +0 -0
  164. /package/esm/client/{1_network_statistics_manager.js → 2_network_statistics_manager.js} +0 -0
  165. /package/esm/client/{1_reaction_manager.js → 2_reaction_manager.js} +0 -0
  166. /package/esm/client/{1_update_manager.js → 2_update_manager.js} +0 -0
  167. /package/esm/client/{2_message_manager.js → 3_message_manager.js} +0 -0
  168. /package/esm/client/{3_story_manager.js → 4_story_manager.js} +0 -0
  169. /package/script/{3_storage.d.ts → 2_storage.d.ts} +0 -0
  170. /package/script/{3_storage.js → 2_storage.js} +0 -0
  171. /package/script/client/{0_types.js → 1_types.js} +0 -0
  172. /package/script/client/{1_account_manager.js → 2_account_manager.js} +0 -0
  173. /package/script/client/{1_bot_info_manager.js → 2_bot_info_manager.js} +0 -0
  174. /package/script/client/{1_business_connection_manager.js → 2_business_connection_manager.js} +0 -0
  175. /package/script/client/{1_network_statistics_manager.js → 2_network_statistics_manager.js} +0 -0
  176. /package/script/client/{1_reaction_manager.js → 2_reaction_manager.js} +0 -0
  177. /package/script/client/{1_update_manager.js → 2_update_manager.js} +0 -0
  178. /package/script/client/{2_message_manager.js → 3_message_manager.js} +0 -0
  179. /package/script/client/{3_story_manager.js → 4_story_manager.js} +0 -0
@@ -29,34 +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_businessConnectionManager, _Client_messageManager, _Client_storyManager, _Client_callbackQueryManager, _Client_inlineQueryManager, _Client_chatListManager, _Client_accountManager, _Client_parseMode, _Client_publicKeys, _Client_ignoreOutgoing, _Client_storeMessages, _Client_Lauthorize, _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;
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 _3_storage_js_1 = require("../3_storage.js");
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 _1_account_manager_js_1 = require("./1_account_manager.js");
46
- const _1_bot_info_manager_js_1 = require("./1_bot_info_manager.js");
47
- const _1_business_connection_manager_js_1 = require("./1_business_connection_manager.js");
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 _1_file_manager_js_1 = require("./1_file_manager.js");
52
- const _1_network_statistics_manager_js_1 = require("./1_network_statistics_manager.js");
53
- const _1_reaction_manager_js_1 = require("./1_reaction_manager.js");
54
- const _1_update_manager_js_1 = require("./1_update_manager.js");
55
- const _2_message_manager_js_1 = require("./2_message_manager.js");
56
- const _3_callback_query_manager_js_1 = require("./3_callback_query_manager.js");
57
- const _3_chat_list_manager_js_1 = require("./3_chat_list_manager.js");
58
- const _3_inline_query_manager_js_1 = require("./3_inline_query_manager.js");
59
- const _3_story_manager_js_1 = require("./3_story_manager.js");
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");
60
63
  class Composer extends _1_composer_js_1.Composer {
61
64
  }
62
65
  exports.Composer = Composer;
@@ -80,21 +83,9 @@ class Client extends Composer {
80
83
  * @param apiId App's API ID from [my.telegram.org](https://my.telegram.org/apps). Defaults to 0 (unset).
81
84
  * @param apiHash App's API hash from [my.telegram.org/apps](https://my.telegram.org/apps). Defaults to empty string (unset).
82
85
  */
83
- constructor(storage, apiId = 0, apiHash = "", params) {
86
+ constructor(params) {
84
87
  super();
85
88
  _Client_instances.add(this);
86
- Object.defineProperty(this, "apiId", {
87
- enumerable: true,
88
- configurable: true,
89
- writable: true,
90
- value: apiId
91
- });
92
- Object.defineProperty(this, "apiHash", {
93
- enumerable: true,
94
- configurable: true,
95
- writable: true,
96
- value: apiHash
97
- });
98
89
  _Client_client.set(this, void 0);
99
90
  _Client_guaranteeUpdateDelivery.set(this, void 0);
100
91
  _Client_updateManager.set(this, void 0);
@@ -102,6 +93,7 @@ class Client extends Composer {
102
93
  _Client_botInfoManager.set(this, void 0);
103
94
  _Client_fileManager.set(this, void 0);
104
95
  _Client_reactionManager.set(this, void 0);
96
+ _Client_videoChatManager.set(this, void 0);
105
97
  _Client_businessConnectionManager.set(this, void 0);
106
98
  _Client_messageManager.set(this, void 0);
107
99
  _Client_storyManager.set(this, void 0);
@@ -109,6 +101,8 @@ class Client extends Composer {
109
101
  _Client_inlineQueryManager.set(this, void 0);
110
102
  _Client_chatListManager.set(this, void 0);
111
103
  _Client_accountManager.set(this, void 0);
104
+ _Client_storage_.set(this, void 0);
105
+ _Client_messageStorage_.set(this, void 0);
112
106
  Object.defineProperty(this, "storage", {
113
107
  enumerable: true,
114
108
  configurable: true,
@@ -122,6 +116,8 @@ class Client extends Composer {
122
116
  value: void 0
123
117
  });
124
118
  _Client_parseMode.set(this, void 0);
119
+ _Client_apiId.set(this, void 0);
120
+ _Client_apiHash.set(this, void 0);
125
121
  Object.defineProperty(this, "appVersion", {
126
122
  enumerable: true,
127
123
  configurable: true,
@@ -160,8 +156,8 @@ class Client extends Composer {
160
156
  });
161
157
  _Client_publicKeys.set(this, void 0);
162
158
  _Client_ignoreOutgoing.set(this, void 0);
163
- _Client_storeMessages.set(this, void 0);
164
- _Client_Lauthorize.set(this, void 0);
159
+ _Client_persistCache.set(this, void 0);
160
+ _Client_LsignIn.set(this, void 0);
165
161
  _Client_LpingLoop.set(this, void 0);
166
162
  _Client_LhandleMigrationError.set(this, void 0);
167
163
  _Client_L$initConncetion.set(this, void 0);
@@ -262,9 +258,9 @@ class Client extends Composer {
262
258
  }
263
259
  (0, _0_deps_js_1.unreachable)();
264
260
  };
265
- 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;
266
262
  const chat = chat_ ?? msg?.chat;
267
- 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;
268
264
  const senderChat = msg?.senderChat;
269
265
  const getReplyToMessageId = (quote, chatId, messageId) => {
270
266
  const isPrivate = chatId > 0;
@@ -640,14 +636,18 @@ class Client extends Composer {
640
636
  }
641
637
  },
642
638
  };
643
- this.storage = typeof storage === "string" ? new _3_storage_js_1.StorageMemory(storage) : storage ?? new _3_storage_js_1.StorageMemory();
644
- __classPrivateFieldSet(this, _Client_storeMessages, params?.storeMessages ?? false, "f");
645
- if (!__classPrivateFieldGet(this, _Client_storeMessages, "f")) {
646
- this.messageStorage = new _3_storage_js_1.StorageMemory();
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");
647
645
  }
648
646
  else {
649
- this.messageStorage = this.storage;
647
+ __classPrivateFieldSet(this, _Client_messageStorage_, __classPrivateFieldGet(this, _Client_storage_, "f"), "f");
650
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"));
651
651
  __classPrivateFieldSet(this, _Client_parseMode, params?.parseMode ?? null, "f");
652
652
  this.appVersion = params?.appVersion ?? _4_constants_js_1.APP_VERSION;
653
653
  this.deviceModel = params?.deviceModel ?? _4_constants_js_1.DEVICE_MODEL;
@@ -662,7 +662,7 @@ class Client extends Composer {
662
662
  }
663
663
  __classPrivateFieldSet(this, _Client_guaranteeUpdateDelivery, params?.guaranteeUpdateDelivery ?? false, "f");
664
664
  const L = (0, _1_utilities_js_1.getLogger)("Client").client(id++);
665
- __classPrivateFieldSet(this, _Client_Lauthorize, L.branch("authorize"), "f");
665
+ __classPrivateFieldSet(this, _Client_LsignIn, L.branch("signIn"), "f");
666
666
  __classPrivateFieldSet(this, _Client_LpingLoop, L.branch("pingLoop"), "f");
667
667
  __classPrivateFieldSet(this, _Client_LhandleMigrationError, L.branch("[handleMigrationError]"), "f");
668
668
  __classPrivateFieldSet(this, _Client_L$initConncetion, L.branch("#initConnection"), "f");
@@ -695,18 +695,19 @@ class Client extends Composer {
695
695
  ignoreOutgoing: __classPrivateFieldGet(this, _Client_ignoreOutgoing, "f"),
696
696
  dropPendingUpdates: params?.dropPendingUpdates,
697
697
  };
698
- __classPrivateFieldSet(this, _Client_updateManager, new _1_update_manager_js_1.UpdateManager(c), "f");
699
- __classPrivateFieldSet(this, _Client_networkStatisticsManager, new _1_network_statistics_manager_js_1.NetworkStatisticsManager(c), "f");
700
- __classPrivateFieldSet(this, _Client_botInfoManager, new _1_bot_info_manager_js_1.BotInfoManager(c), "f");
701
- __classPrivateFieldSet(this, _Client_fileManager, new _1_file_manager_js_1.FileManager(c), "f");
702
- __classPrivateFieldSet(this, _Client_reactionManager, new _1_reaction_manager_js_1.ReactionManager(c), "f");
703
- __classPrivateFieldSet(this, _Client_businessConnectionManager, new _1_business_connection_manager_js_1.BusinessConnectionManager(c), "f");
704
- __classPrivateFieldSet(this, _Client_messageManager, new _2_message_manager_js_1.MessageManager({ ...c, fileManager: __classPrivateFieldGet(this, _Client_fileManager, "f") }), "f");
705
- __classPrivateFieldSet(this, _Client_callbackQueryManager, new _3_callback_query_manager_js_1.CallbackQueryManager({ ...c, messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
706
- __classPrivateFieldSet(this, _Client_storyManager, new _3_story_manager_js_1.StoryManager({ ...c, fileManager: __classPrivateFieldGet(this, _Client_fileManager, "f"), messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
707
- __classPrivateFieldSet(this, _Client_inlineQueryManager, new _3_inline_query_manager_js_1.InlineQueryManager({ ...c, messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
708
- __classPrivateFieldSet(this, _Client_chatListManager, new _3_chat_list_manager_js_1.ChatListManager({ ...c, fileManager: __classPrivateFieldGet(this, _Client_fileManager, "f"), messageManager: __classPrivateFieldGet(this, _Client_messageManager, "f") }), "f");
709
- __classPrivateFieldSet(this, _Client_accountManager, new _1_account_manager_js_1.AccountManager(c), "f");
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");
710
711
  __classPrivateFieldGet(this, _Client_updateManager, "f").setUpdateHandler(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleUpdate).bind(this));
711
712
  const transportProvider = __classPrivateFieldGet(this, _Client_client, "f").transportProvider;
712
713
  __classPrivateFieldGet(this, _Client_client, "f").transportProvider = (params) => {
@@ -815,10 +816,10 @@ class Client extends Composer {
815
816
  }
816
817
  await this.connect();
817
818
  }
818
- 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_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(), _Client_storeMessages = new WeakMap(), _Client_Lauthorize = 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() {
819
- const apiId = this.apiId || await this.storage.getApiId();
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();
820
821
  if (!apiId) {
821
- throw new Error("apiId not set");
822
+ throw new _0_errors_js_1.InputError("apiId not set");
822
823
  }
823
824
  return apiId;
824
825
  }, _Client_getCdnConnectionPool = function _Client_getCdnConnectionPool(connectionCount, dcId) {
@@ -847,7 +848,11 @@ class Client extends Composer {
847
848
  },
848
849
  };
849
850
  }, _Client_getCdnConnection = function _Client_getCdnConnection(dcId) {
850
- const client = new _a((!dcId || dcId == __classPrivateFieldGet(this, _Client_client, "f").dcId) ? this.storage : this.storage.branch(`download_client_${dcId}`), this.apiId, this.apiHash, {
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"),
851
856
  transportProvider: __classPrivateFieldGet(this, _Client_client, "f").transportProvider,
852
857
  appVersion: this.appVersion,
853
858
  deviceModel: this.deviceModel,
@@ -912,25 +917,19 @@ class Client extends Composer {
912
917
  __classPrivateFieldGet(this, _Client_pingLoopAbortController, "f")?.abort();
913
918
  }
914
919
  /**
915
- * Authorizes the client with one of the following:
916
- *
917
- * - Bot token (`string`)
918
- * - User authorization handlers (`AuthorizeUserParams`)
919
- *
920
- * 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.
921
922
  *
922
923
  * Notes:
923
924
  * 1. Requires the `apiId` and `apiHash` paramters to be passed when constructing the client.
924
- * 2. Reconnects the client to the appropriate DC in case of MIGRATE_X errors.
925
- *
926
- * [1]: https://core.telegram.org/method/updates.getState
925
+ * 3. Reconnects the client to the appropriate DC in case of MIGRATE_X errors.
927
926
  */
928
- async authorize(params) {
927
+ async signIn(params) {
929
928
  try {
930
- await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("authorize");
929
+ await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("signIn");
931
930
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, true);
932
- (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("authorize"));
933
- __classPrivateFieldGet(this, _Client_Lauthorize, "f").debug("already authorized");
931
+ (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Client_updateManager, "f").recoverUpdateGap("signIn"));
932
+ __classPrivateFieldGet(this, _Client_LsignIn, "f").debug("already signed in");
934
933
  return;
935
934
  }
936
935
  catch (err) {
@@ -939,23 +938,23 @@ class Client extends Composer {
939
938
  }
940
939
  }
941
940
  const apiId = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getApiId).call(this);
942
- if (!this.apiHash) {
943
- throw new Error("apiHash not set");
941
+ if (!__classPrivateFieldGet(this, _Client_apiHash, "f")) {
942
+ throw new _0_errors_js_1.InputError("apiHash not set");
944
943
  }
945
944
  if (typeof params === "undefined") {
946
945
  const loginType = (0, _1_utilities_js_1.mustPromptOneOf)("Do you want to login as bot [b] or user [u]?", ["b", "u"]);
947
946
  if (loginType == "b") {
948
- params = (0, _1_utilities_js_1.mustPrompt)("Bot token:");
947
+ params = { botToken: (0, _1_utilities_js_1.mustPrompt)("Bot token:") };
949
948
  }
950
949
  else {
951
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:") };
952
951
  }
953
952
  }
954
- __classPrivateFieldGet(this, _Client_Lauthorize, "f").debug("authorizing with", typeof params === "string" ? "bot token" : params instanceof _2_tl_js_1.types.auth.ExportedAuthorization ? "exported authorization" : "AuthorizeUserParams");
955
- if (typeof params === "string") {
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) {
956
955
  while (true) {
957
956
  try {
958
- const auth = await this.api.auth.importBotAuthorization({ api_id: apiId, api_hash: this.apiHash, bot_auth_token: params, flags: 0 });
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 });
959
958
  await this.storage.setAccountId(Number(auth[_2_tl_js_1.as](_2_tl_js_1.types.auth.Authorization).user.id));
960
959
  await this.storage.setAccountType("bot");
961
960
  break;
@@ -970,7 +969,7 @@ class Client extends Composer {
970
969
  }
971
970
  }
972
971
  }
973
- __classPrivateFieldGet(this, _Client_Lauthorize, "f").debug("authorized as bot");
972
+ __classPrivateFieldGet(this, _Client_LsignIn, "f").debug("authorized as bot");
974
973
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, true);
975
974
  await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("authorize");
976
975
  return;
@@ -984,8 +983,8 @@ class Client extends Composer {
984
983
  phone = typeof params.phone === "string" ? params.phone : await params.phone();
985
984
  const sendCode = () => this.api.auth.sendCode({
986
985
  phone_number: phone,
987
- api_id: this.apiId,
988
- api_hash: this.apiHash,
986
+ api_id: __classPrivateFieldGet(this, _Client_apiId, "f"),
987
+ api_hash: __classPrivateFieldGet(this, _Client_apiHash, "f"),
989
988
  settings: new _2_tl_js_1.types.CodeSettings(),
990
989
  }).then((v) => v[_2_tl_js_1.as](_2_tl_js_1.types.auth.SentCode));
991
990
  try {
@@ -1011,7 +1010,7 @@ class Client extends Composer {
1011
1010
  }
1012
1011
  }
1013
1012
  }
1014
- __classPrivateFieldGet(this, _Client_Lauthorize, "f").debug("verification code sent");
1013
+ __classPrivateFieldGet(this, _Client_LsignIn, "f").debug("verification code sent");
1015
1014
  let err;
1016
1015
  code: while (true) {
1017
1016
  const code = typeof params.code === "string" ? params.code : await params.code();
@@ -1023,13 +1022,13 @@ class Client extends Composer {
1023
1022
  });
1024
1023
  await this.storage.setAccountId(Number(auth[_2_tl_js_1.as](_2_tl_js_1.types.auth.Authorization).user.id));
1025
1024
  await this.storage.setAccountType("user");
1026
- __classPrivateFieldGet(this, _Client_Lauthorize, "f").debug("authorized as user");
1025
+ __classPrivateFieldGet(this, _Client_LsignIn, "f").debug("signed in as user");
1027
1026
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, true);
1028
- await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("authorize");
1027
+ await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("signIn");
1029
1028
  return;
1030
1029
  }
1031
1030
  catch (err_) {
1032
- if (err_ instanceof _2_tl_js_1.types.Rpc_error && err_.error_message == "PHONE_CODE_INVALID") {
1031
+ if (err_ instanceof _4_errors_js_2.PhoneCodeInvalid) {
1033
1032
  continue code;
1034
1033
  }
1035
1034
  else {
@@ -1052,9 +1051,9 @@ class Client extends Composer {
1052
1051
  const auth = await this.api.auth.checkPassword({ password: input });
1053
1052
  await this.storage.setAccountId(Number(auth[_2_tl_js_1.as](_2_tl_js_1.types.auth.Authorization).user.id));
1054
1053
  await this.storage.setAccountType("user");
1055
- __classPrivateFieldGet(this, _Client_Lauthorize, "f").debug("authorized as user");
1054
+ __classPrivateFieldGet(this, _Client_LsignIn, "f").debug("signed in as user");
1056
1055
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_propagateAuthorizationState).call(this, true);
1057
- await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("authorize");
1056
+ await __classPrivateFieldGet(this, _Client_updateManager, "f").fetchState("signIn");
1058
1057
  return;
1059
1058
  }
1060
1059
  catch (err) {
@@ -1077,12 +1076,26 @@ class Client extends Composer {
1077
1076
  }
1078
1077
  }
1079
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
+ }
1080
1093
  /**
1081
- * Same as calling `.connect()` followed by `.authorize(params)`.
1094
+ * Same as calling `.connect()` followed by `.signIn(params)`.
1082
1095
  */
1083
1096
  async start(params) {
1084
1097
  await this.connect();
1085
- await this.authorize(params);
1098
+ await this.signIn(params);
1086
1099
  }
1087
1100
  /**
1088
1101
  * Alias for `invoke` with its second parameter being `true`.
@@ -1091,7 +1104,7 @@ class Client extends Composer {
1091
1104
  return this.invoke(function_, true);
1092
1105
  }
1093
1106
  exportAuthString() {
1094
- return this.storage.exportAuthString(this.apiId);
1107
+ return this.storage.exportAuthString(__classPrivateFieldGet(this, _Client_apiId, "f"));
1095
1108
  }
1096
1109
  async importAuthString(authString) {
1097
1110
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_initStorage).call(this);
@@ -1107,7 +1120,7 @@ class Client extends Composer {
1107
1120
  return new _2_tl_js_1.types.InputPeerSelf();
1108
1121
  }
1109
1122
  const inputPeer = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getInputPeerInner).call(this, id);
1110
- if ((inputPeer instanceof _2_tl_js_1.types.InputPeerUser || inputPeer instanceof _2_tl_js_1.types.InputPeerChannel && inputPeer.access_hash == 0n) && await this.storage.getAccountType() == "bot") {
1123
+ if (((inputPeer instanceof _2_tl_js_1.types.InputPeerUser || inputPeer instanceof _2_tl_js_1.types.InputPeerChannel) && inputPeer.access_hash == 0n) && await this.storage.getAccountType() == "bot") {
1111
1124
  if ("channel_id" in inputPeer) {
1112
1125
  inputPeer.access_hash = await __classPrivateFieldGet(this, _Client_instances, "m", _Client_getChannelAccessHash).call(this, inputPeer.channel_id);
1113
1126
  }
@@ -2294,12 +2307,95 @@ class Client extends Composer {
2294
2307
  async unblockUser(userId) {
2295
2308
  await __classPrivateFieldGet(this, _Client_messageManager, "f").unblockUser(userId);
2296
2309
  }
2310
+ //
2311
+ // ========================= VIDEO CHATS ========================= //
2312
+ //
2313
+ /**
2314
+ * Start a video chat. User-only.
2315
+ *
2316
+ * @method vc
2317
+ * @param chatId The chat to start the video chat in.
2318
+ * @returns The started video chat.
2319
+ */
2320
+ async startVideoChat(chatId, params) {
2321
+ return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").startVideoChat(chatId, params);
2322
+ }
2323
+ /**
2324
+ * Schedule a video chat. User-only.
2325
+ *
2326
+ * @method vc
2327
+ * @param chatId The chat to schedule the video chat in.
2328
+ * @param startAt A point in time within the future in which the video chat will be started.
2329
+ * @returns The scheduled video chat.
2330
+ */
2331
+ async scheduleVideoChat(chatId, startAt, params) {
2332
+ return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").scheduleVideoChat(chatId, startAt, params);
2333
+ }
2334
+ /**
2335
+ * Join a video chat. User-only.
2336
+ *
2337
+ * @method vc
2338
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
2339
+ * @param params_ WebRTC connection parameters.
2340
+ * @returns Parameters to be passed to the used WebRTC library.
2341
+ */
2342
+ async joinVideoChat(id, params_, params) {
2343
+ return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").joinVideoChat(id, params_, params);
2344
+ }
2345
+ /**
2346
+ * Leave a video chat. User-only.
2347
+ *
2348
+ * @method vc
2349
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
2350
+ */
2351
+ async leaveVideoChat(id) {
2352
+ return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").leaveVideoChat(id);
2353
+ }
2354
+ /**
2355
+ * Join a live stream. User-only.
2356
+ *
2357
+ * @method vc
2358
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
2359
+ */
2360
+ async joinLiveStream(id) {
2361
+ return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").joinLiveStream(id);
2362
+ }
2363
+ /**
2364
+ * Get a video chat. User-only.
2365
+ *
2366
+ * @method vc
2367
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
2368
+ */
2369
+ async getVideoChat(id) {
2370
+ return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").getVideoChat(id);
2371
+ }
2372
+ /**
2373
+ * Get live stream channels. User-only.
2374
+ *
2375
+ * @method vc
2376
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
2377
+ */
2378
+ async getLiveStreamChannels(id) {
2379
+ return await __classPrivateFieldGet(this, _Client_videoChatManager, "f").getLiveStreamChannels(id);
2380
+ }
2381
+ /**
2382
+ * Download a live stream chunk. User-only.
2383
+ *
2384
+ * @method vc
2385
+ * @param id The identifier of a video chat retrieved from getChat, startVideoChat, or scheduleVideoChat.
2386
+ * @param channelId Stream channel ID.
2387
+ * @param scale Stream channel scale.
2388
+ * @param timestamp Millisecond timestamp of the chunk to download.
2389
+ */
2390
+ async *downloadLiveStreamChunk(id, channelId, scale, timestamp, params) {
2391
+ yield* __classPrivateFieldGet(this, _Client_videoChatManager, "f").downloadLiveStreamChunk(id, channelId, scale, timestamp, params);
2392
+ }
2297
2393
  }
2298
2394
  exports.Client = Client;
2299
2395
  _a = Client, _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(update) {
2300
2396
  await this.middleware()(await __classPrivateFieldGet(this, _Client_constructContext, "f").call(this, update), _0_utilities_js_1.resolve);
2301
2397
  }, _Client_queueHandleCtxUpdate = function _Client_queueHandleCtxUpdate(update) {
2302
- __classPrivateFieldGet(this, _Client_updateManager, "f").getHandleUpdateQueue(_1_update_manager_js_1.UpdateManager.MAIN_BOX_ID).add(async () => {
2398
+ __classPrivateFieldGet(this, _Client_updateManager, "f").getHandleUpdateQueue(_2_update_manager_js_1.UpdateManager.MAIN_BOX_ID).add(async () => {
2303
2399
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, update);
2304
2400
  });
2305
2401
  }, _Client_handleUpdate = async function _Client_handleUpdate(update) {
@@ -2315,7 +2411,7 @@ _a = Client, _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(up
2315
2411
  await this.messageStorage.setEntity(entity);
2316
2412
  }
2317
2413
  }
2318
- if (_2_message_manager_js_1.MessageManager.canHandleUpdate(update)) {
2414
+ if (_3_message_manager_js_1.MessageManager.canHandleUpdate(update)) {
2319
2415
  const update_ = await __classPrivateFieldGet(this, _Client_messageManager, "f").handleUpdate(update);
2320
2416
  if (update_) {
2321
2417
  promises.push((async () => {
@@ -2333,28 +2429,31 @@ _a = Client, _Client_handleCtxUpdate = async function _Client_handleCtxUpdate(up
2333
2429
  })());
2334
2430
  }
2335
2431
  }
2336
- if (_3_callback_query_manager_js_1.CallbackQueryManager.canHandleUpdate(update)) {
2432
+ if (_3_video_chat_manager_js_1.VideoChatManager.canHandleUpdate(update)) {
2433
+ promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, await __classPrivateFieldGet(this, _Client_videoChatManager, "f").handleUpdate(update)));
2434
+ }
2435
+ if (_4_callback_query_manager_js_1.CallbackQueryManager.canHandleUpdate(update)) {
2337
2436
  promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, await __classPrivateFieldGet(this, _Client_callbackQueryManager, "f").handleUpdate(update)));
2338
2437
  }
2339
- if (_3_inline_query_manager_js_1.InlineQueryManager.canHandleUpdate(update)) {
2438
+ if (_4_inline_query_manager_js_1.InlineQueryManager.canHandleUpdate(update)) {
2340
2439
  promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, await __classPrivateFieldGet(this, _Client_inlineQueryManager, "f").handleUpdate(update)));
2341
2440
  }
2342
- if (_1_reaction_manager_js_1.ReactionManager.canHandleUpdate(update)) {
2441
+ if (_2_reaction_manager_js_1.ReactionManager.canHandleUpdate(update)) {
2343
2442
  const upd = await __classPrivateFieldGet(this, _Client_reactionManager, "f").handleUpdate(update);
2344
2443
  if (upd) {
2345
2444
  promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, upd));
2346
2445
  }
2347
2446
  }
2348
- if (_3_chat_list_manager_js_1.ChatListManager.canHandleUpdate(update)) {
2447
+ if (_4_chat_list_manager_js_1.ChatListManager.canHandleUpdate(update)) {
2349
2448
  await __classPrivateFieldGet(this, _Client_chatListManager, "f").handleUpdate(update);
2350
2449
  }
2351
- if (_3_story_manager_js_1.StoryManager.canHandleUpdate(update)) {
2450
+ if (_4_story_manager_js_1.StoryManager.canHandleUpdate(update)) {
2352
2451
  const upd = await __classPrivateFieldGet(this, _Client_storyManager, "f").handleUpdate(update);
2353
2452
  if (upd) {
2354
2453
  promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, upd));
2355
2454
  }
2356
2455
  }
2357
- if (_1_business_connection_manager_js_1.BusinessConnectionManager.canHandleUpdate(update)) {
2456
+ if (_2_business_connection_manager_js_1.BusinessConnectionManager.canHandleUpdate(update)) {
2358
2457
  promises.push(__classPrivateFieldGet(this, _Client_instances, "m", _Client_handleCtxUpdate).call(this, await __classPrivateFieldGet(this, _Client_businessConnectionManager, "f").handleUpdate(update)));
2359
2458
  }
2360
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
- declare abstract class Foundation {
22
- abstract get connected(): boolean;
21
+ export interface Connection {
22
+ get connected(): boolean;
23
23
  stateChangeHandler?: (connected: boolean) => void;
24
- abstract open(): MaybePromise<void>;
25
- abstract write(p: Uint8Array): MaybePromise<void>;
26
- abstract close(): MaybePromise<void>;
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 { ConnectionUnframed } from "./0_connection.js";
2
- export declare class ConnectionWebSocket extends ConnectionUnframed implements ConnectionUnframed {
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>;