@mtkruto/node 0.67.2 → 0.68.0

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 (244) hide show
  1. package/esm/0_errors.js +2 -6
  2. package/esm/3_errors.js +2 -12
  3. package/esm/3_types.d.ts +1 -0
  4. package/esm/3_types.d.ts.map +1 -1
  5. package/esm/3_types.js +1 -0
  6. package/esm/4_errors.js +2 -12
  7. package/esm/_dnt.polyfills.d.ts +99 -0
  8. package/esm/_dnt.polyfills.d.ts.map +1 -1
  9. package/esm/_dnt.polyfills.js +127 -1
  10. package/esm/_dnt.test_polyfills.d.ts.map +1 -0
  11. package/esm/client/0_filters_test.d.ts.map +1 -1
  12. package/esm/client/0_markdown_test.d.ts.map +1 -1
  13. package/esm/client/0_params.d.ts +2 -0
  14. package/esm/client/0_params.d.ts.map +1 -1
  15. package/esm/client/0_password.d.ts +5 -5
  16. package/esm/client/0_password.d.ts.map +1 -1
  17. package/esm/client/0_password_test.d.ts.map +1 -1
  18. package/esm/client/0_storage_operations.js +143 -155
  19. package/esm/client/0_storage_operations_test.d.ts.map +1 -1
  20. package/esm/client/0_utilities.d.ts +1 -1
  21. package/esm/client/0_utilities_test.d.ts.map +1 -1
  22. package/esm/client/1_client_plain.js +4 -22
  23. package/esm/client/1_composer.js +8 -21
  24. package/esm/client/2_account_manager.js +85 -97
  25. package/esm/client/2_bot_info_manager.js +26 -38
  26. package/esm/client/2_business_connection_manager.js +10 -23
  27. package/esm/client/2_client_encrypted.js +194 -211
  28. package/esm/client/2_file_manager.d.ts +4 -3
  29. package/esm/client/2_file_manager.d.ts.map +1 -1
  30. package/esm/client/2_file_manager.js +268 -224
  31. package/esm/client/2_file_manager_test.d.ts.map +1 -1
  32. package/esm/client/2_network_statistics_manager.js +8 -21
  33. package/esm/client/2_payment_manager.js +7 -20
  34. package/esm/client/2_reaction_manager.js +7 -20
  35. package/esm/client/2_translations_manager.js +97 -107
  36. package/esm/client/2_update_manager.js +764 -759
  37. package/esm/client/3_client_encrypted_pool.js +10 -26
  38. package/esm/client/3_client_encrypted_pool_test.d.ts.map +1 -1
  39. package/esm/client/3_message_manager.d.ts +1 -1
  40. package/esm/client/3_message_manager.js +441 -448
  41. package/esm/client/3_message_manager_test.d.ts.map +1 -1
  42. package/esm/client/3_video_chat_manager.d.ts +1 -1
  43. package/esm/client/3_video_chat_manager.js +57 -68
  44. package/esm/client/4_callback_query_manager.js +18 -30
  45. package/esm/client/4_chat_list_manager.js +322 -318
  46. package/esm/client/4_chat_manager.js +118 -131
  47. package/esm/client/4_forum_manager.js +67 -73
  48. package/esm/client/4_gift_manager.js +16 -29
  49. package/esm/client/4_inline_query_manager.js +16 -28
  50. package/esm/client/4_link_preview_manager.js +6 -19
  51. package/esm/client/4_poll_manager.js +44 -57
  52. package/esm/client/4_story_manager.js +41 -53
  53. package/esm/client/5_client.d.ts +7 -0
  54. package/esm/client/5_client.d.ts.map +1 -1
  55. package/esm/client/5_client.js +1269 -1288
  56. package/esm/connection/1_connection_tcp.node.js +48 -65
  57. package/esm/connection/1_connection_web_socket.js +75 -91
  58. package/esm/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
  59. package/esm/deps/jsr.io/@std/async/1.0.13/mux_async_iterator.js +31 -47
  60. package/esm/deps/jsr.io/@std/async/1.0.13/tee.js +11 -34
  61. package/esm/deps/jsr.io/@std/datetime/0.225.5/_date_time_formatter.js +4 -17
  62. package/esm/mod.js +2 -12
  63. package/esm/session/0_session_state.js +12 -38
  64. package/esm/session/1_session.js +49 -72
  65. package/esm/session/2_session_encrypted.js +324 -320
  66. package/esm/storage/1_utilities_test.d.ts.map +1 -1
  67. package/esm/storage/2_storage_indexed_db.js +26 -44
  68. package/esm/storage/2_storage_local_storage.node.js +12 -25
  69. package/esm/storage/2_storage_memory.js +24 -41
  70. package/esm/storage/2_storage_session_storage.js +3 -16
  71. package/esm/tl/0_utilities_test.d.ts.map +1 -1
  72. package/esm/tl/1_tl_reader.js +80 -88
  73. package/esm/tl/1_tl_reader_test.d.ts.map +1 -1
  74. package/esm/tl/1_tl_writer.js +155 -164
  75. package/esm/tl/1_tl_writer_test.d.ts.map +1 -1
  76. package/esm/transport/0_transport.js +1 -8
  77. package/esm/transport/1_transport_abridged.js +11 -24
  78. package/esm/transport/1_transport_intermediate.js +10 -23
  79. package/esm/transport/2_transport_provider_web_socket.d.ts.map +1 -1
  80. package/esm/types/0_upload_progress.d.ts +29 -0
  81. package/esm/types/0_upload_progress.d.ts.map +1 -0
  82. package/esm/types/0_upload_progress.js +20 -0
  83. package/esm/types/1_sticker.d.ts +1 -1
  84. package/esm/types/1_sticker.d.ts.map +1 -1
  85. package/esm/types/2_poll_answer.d.ts +19 -0
  86. package/esm/types/2_poll_answer.d.ts.map +1 -1
  87. package/esm/types/2_poll_answer.js +19 -0
  88. package/esm/types/7_update.d.ts +21 -2
  89. package/esm/types/7_update.d.ts.map +1 -1
  90. package/esm/utilities/0_bigint_test.d.ts.map +1 -1
  91. package/esm/utilities/0_buffer.d.ts +1 -1
  92. package/esm/utilities/0_buffer.d.ts.map +1 -1
  93. package/esm/utilities/0_buffer_test.d.ts.map +1 -1
  94. package/esm/utilities/0_hash.d.ts +2 -2
  95. package/esm/utilities/0_hash.d.ts.map +1 -1
  96. package/esm/utilities/0_mutex.js +4 -19
  97. package/esm/utilities/0_part_stream.js +11 -25
  98. package/esm/utilities/0_part_stream_test.d.ts.map +1 -1
  99. package/esm/utilities/0_rle.d.ts +2 -2
  100. package/esm/utilities/0_rle.d.ts.map +1 -1
  101. package/esm/utilities/0_rle_test.d.ts.map +1 -1
  102. package/esm/utilities/0_text.d.ts +20 -1
  103. package/esm/utilities/0_text.d.ts.map +1 -1
  104. package/esm/utilities/0_text.js +19 -0
  105. package/esm/utilities/1_auth.d.ts +1 -1
  106. package/esm/utilities/1_auth.d.ts.map +1 -1
  107. package/esm/utilities/1_base64.d.ts +1 -1
  108. package/esm/utilities/1_base64.d.ts.map +1 -1
  109. package/esm/utilities/1_base64_test.d.ts.map +1 -1
  110. package/esm/utilities/1_crypto.js +42 -53
  111. package/esm/utilities/1_crypto_test.d.ts.map +1 -1
  112. package/esm/utilities/1_logger.d.ts +2 -2
  113. package/esm/utilities/1_math_test.d.ts.map +1 -1
  114. package/esm/utilities/2_queue.js +29 -47
  115. package/package.json +1 -1
  116. package/script/0_errors.js +2 -6
  117. package/script/2_tl.js +17 -7
  118. package/script/3_errors.js +2 -12
  119. package/script/3_types.d.ts +1 -0
  120. package/script/3_types.d.ts.map +1 -1
  121. package/script/3_types.js +1 -0
  122. package/script/4_constants.js +17 -7
  123. package/script/4_errors.js +2 -12
  124. package/script/_dnt.polyfills.d.ts +99 -0
  125. package/script/_dnt.polyfills.d.ts.map +1 -1
  126. package/script/_dnt.polyfills.js +128 -0
  127. package/script/_dnt.test_polyfills.d.ts.map +1 -0
  128. package/script/client/0_filters_test.d.ts.map +1 -1
  129. package/script/client/0_markdown_test.d.ts.map +1 -1
  130. package/script/client/0_params.d.ts +2 -0
  131. package/script/client/0_params.d.ts.map +1 -1
  132. package/script/client/0_password.d.ts +5 -5
  133. package/script/client/0_password.d.ts.map +1 -1
  134. package/script/client/0_password.js +17 -7
  135. package/script/client/0_password_test.d.ts.map +1 -1
  136. package/script/client/0_storage_operations.js +143 -155
  137. package/script/client/0_storage_operations_test.d.ts.map +1 -1
  138. package/script/client/0_utilities.d.ts +1 -1
  139. package/script/client/0_utilities_test.d.ts.map +1 -1
  140. package/script/client/1_client_plain.js +4 -22
  141. package/script/client/1_composer.js +8 -21
  142. package/script/client/2_account_manager.js +85 -97
  143. package/script/client/2_bot_info_manager.js +26 -38
  144. package/script/client/2_business_connection_manager.js +10 -23
  145. package/script/client/2_client_encrypted.js +195 -212
  146. package/script/client/2_file_manager.d.ts +4 -3
  147. package/script/client/2_file_manager.d.ts.map +1 -1
  148. package/script/client/2_file_manager.js +285 -231
  149. package/script/client/2_file_manager_test.d.ts.map +1 -1
  150. package/script/client/2_network_statistics_manager.js +8 -21
  151. package/script/client/2_payment_manager.js +7 -20
  152. package/script/client/2_reaction_manager.js +7 -20
  153. package/script/client/2_translations_manager.js +98 -108
  154. package/script/client/2_update_manager.js +764 -759
  155. package/script/client/3_client_encrypted_pool.js +10 -26
  156. package/script/client/3_client_encrypted_pool_test.d.ts.map +1 -1
  157. package/script/client/3_message_manager.d.ts +1 -1
  158. package/script/client/3_message_manager.js +441 -448
  159. package/script/client/3_message_manager_test.d.ts.map +1 -1
  160. package/script/client/3_video_chat_manager.d.ts +1 -1
  161. package/script/client/3_video_chat_manager.js +57 -68
  162. package/script/client/4_callback_query_manager.js +18 -30
  163. package/script/client/4_chat_list_manager.js +322 -318
  164. package/script/client/4_chat_manager.js +118 -131
  165. package/script/client/4_forum_manager.js +67 -73
  166. package/script/client/4_gift_manager.js +16 -29
  167. package/script/client/4_inline_query_manager.js +16 -28
  168. package/script/client/4_link_preview_manager.js +6 -19
  169. package/script/client/4_poll_manager.js +44 -57
  170. package/script/client/4_story_manager.js +41 -53
  171. package/script/client/5_client.d.ts +7 -0
  172. package/script/client/5_client.d.ts.map +1 -1
  173. package/script/client/5_client.js +1269 -1288
  174. package/script/connection/1_connection_tcp.node.js +48 -65
  175. package/script/connection/1_connection_web_socket.js +92 -98
  176. package/script/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
  177. package/script/deps/jsr.io/@std/assert/1.0.13/equal.js +17 -7
  178. package/script/deps/jsr.io/@std/async/1.0.13/delay.js +17 -7
  179. package/script/deps/jsr.io/@std/async/1.0.13/mux_async_iterator.js +31 -47
  180. package/script/deps/jsr.io/@std/async/1.0.13/tee.js +11 -34
  181. package/script/deps/jsr.io/@std/datetime/0.225.5/_date_time_formatter.js +4 -17
  182. package/script/deps/jsr.io/@std/internal/1.0.10/format.js +17 -7
  183. package/script/deps/jsr.io/@std/internal/1.0.10/styles.js +17 -7
  184. package/script/deps/jsr.io/@std/path/1.1.0/_os.js +17 -7
  185. package/script/mod.js +19 -19
  186. package/script/session/0_session_state.js +12 -38
  187. package/script/session/1_session.js +66 -79
  188. package/script/session/2_session_encrypted.js +325 -321
  189. package/script/storage/1_utilities_test.d.ts.map +1 -1
  190. package/script/storage/2_storage_indexed_db.js +26 -44
  191. package/script/storage/2_storage_local_storage.node.js +12 -25
  192. package/script/storage/2_storage_memory.js +24 -41
  193. package/script/storage/2_storage_session_storage.js +3 -16
  194. package/script/tl/0_utilities_test.d.ts.map +1 -1
  195. package/script/tl/1_tl_reader.js +81 -89
  196. package/script/tl/1_tl_reader_test.d.ts.map +1 -1
  197. package/script/tl/1_tl_writer.js +156 -165
  198. package/script/tl/1_tl_writer_test.d.ts.map +1 -1
  199. package/script/tl/2_telegram.js +17 -7
  200. package/script/transport/0_obfuscation.js +17 -7
  201. package/script/transport/0_transport.js +1 -8
  202. package/script/transport/1_transport_abridged.js +11 -24
  203. package/script/transport/1_transport_intermediate.js +10 -23
  204. package/script/transport/2_transport_provider_web_socket.d.ts.map +1 -1
  205. package/script/types/0_upload_progress.d.ts +29 -0
  206. package/script/types/0_upload_progress.d.ts.map +1 -0
  207. package/script/types/0_upload_progress.js +21 -0
  208. package/script/types/1_sticker.d.ts +1 -1
  209. package/script/types/1_sticker.d.ts.map +1 -1
  210. package/script/types/2_poll_answer.d.ts +19 -0
  211. package/script/types/2_poll_answer.d.ts.map +1 -1
  212. package/script/types/2_poll_answer.js +19 -0
  213. package/script/types/7_update.d.ts +21 -2
  214. package/script/types/7_update.d.ts.map +1 -1
  215. package/script/utilities/0_bigint.js +17 -7
  216. package/script/utilities/0_bigint_test.d.ts.map +1 -1
  217. package/script/utilities/0_buffer.d.ts +1 -1
  218. package/script/utilities/0_buffer.d.ts.map +1 -1
  219. package/script/utilities/0_buffer_test.d.ts.map +1 -1
  220. package/script/utilities/0_env.js +17 -7
  221. package/script/utilities/0_hash.d.ts +2 -2
  222. package/script/utilities/0_hash.d.ts.map +1 -1
  223. package/script/utilities/0_hash.js +17 -7
  224. package/script/utilities/0_misc.js +17 -7
  225. package/script/utilities/0_mutex.js +4 -19
  226. package/script/utilities/0_part_stream.js +11 -25
  227. package/script/utilities/0_part_stream_test.d.ts.map +1 -1
  228. package/script/utilities/0_rle.d.ts +2 -2
  229. package/script/utilities/0_rle.d.ts.map +1 -1
  230. package/script/utilities/0_rle_test.d.ts.map +1 -1
  231. package/script/utilities/0_text.d.ts +20 -1
  232. package/script/utilities/0_text.d.ts.map +1 -1
  233. package/script/utilities/0_text.js +19 -0
  234. package/script/utilities/1_auth.d.ts +1 -1
  235. package/script/utilities/1_auth.d.ts.map +1 -1
  236. package/script/utilities/1_auth.js +17 -7
  237. package/script/utilities/1_base64.d.ts +1 -1
  238. package/script/utilities/1_base64.d.ts.map +1 -1
  239. package/script/utilities/1_base64_test.d.ts.map +1 -1
  240. package/script/utilities/1_crypto.js +60 -61
  241. package/script/utilities/1_crypto_test.d.ts.map +1 -1
  242. package/script/utilities/1_logger.d.ts +2 -2
  243. package/script/utilities/1_math_test.d.ts.map +1 -1
  244. package/script/utilities/2_queue.js +30 -48
@@ -21,7 +21,7 @@ import { Api } from "../2_tl.js";
21
21
  export declare const resolve: () => Promise<void>;
22
22
  export declare function isHttpUrl(string: string): boolean;
23
23
  export declare function getUsername(string: string): string;
24
- export declare function getChatListId(chatList: string): 0 | 1;
24
+ export declare function getChatListId(chatList: string): 1 | 0;
25
25
  export declare function checkMessageId(messageId: number): number;
26
26
  export declare function checkStoryId(storyId: number): number;
27
27
  export declare function checkPollOption(option: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"0_utilities_test.d.ts","sourceRoot":"","sources":["../../src/client/0_utilities_test.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"0_utilities_test.d.ts","sourceRoot":"","sources":["../../src/client/0_utilities_test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,2BAA2B,CAAC"}
@@ -18,18 +18,6 @@
18
18
  * You should have received a copy of the GNU Lesser General Public License
19
19
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
20
  */
21
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
22
- if (kind === "m") throw new TypeError("Private method is not writable");
23
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
24
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
25
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
26
- };
27
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
28
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
29
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
30
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
31
- };
32
- var _ClientPlain_publicKeys;
33
21
  Object.defineProperty(exports, "__esModule", { value: true });
34
22
  exports.ClientPlain = void 0;
35
23
  const _0_deps_js_1 = require("../0_deps.js");
@@ -45,16 +33,11 @@ const LcreateAuthKey = L.branch("createAuthKey");
45
33
  * An MTProto client for making plain connections. Most users won't need to interact with this. Used internally for creating authorization keys.
46
34
  */
47
35
  class ClientPlain extends _0_client_abstract_js_1.ClientAbstract {
36
+ #publicKeys;
37
+ session;
48
38
  constructor(dc, params) {
49
39
  super();
50
- _ClientPlain_publicKeys.set(this, void 0);
51
- Object.defineProperty(this, "session", {
52
- enumerable: true,
53
- configurable: true,
54
- writable: true,
55
- value: void 0
56
- });
57
- __classPrivateFieldSet(this, _ClientPlain_publicKeys, params?.publicKeys ?? _4_constants_js_1.PUBLIC_KEYS, "f");
40
+ this.#publicKeys = params?.publicKeys ?? _4_constants_js_1.PUBLIC_KEYS;
58
41
  this.session = new _4_session_js_1.SessionPlain(dc, params);
59
42
  }
60
43
  async invoke(function_) {
@@ -92,7 +75,7 @@ class ClientPlain extends _0_client_abstract_js_1.ClientAbstract {
92
75
  let publicKeyFingerprint;
93
76
  let publicKey;
94
77
  for (const fingerprint of resPq.server_public_key_fingerprints) {
95
- const maybePublicKey = __classPrivateFieldGet(this, _ClientPlain_publicKeys, "f").find(([k]) => (k == fingerprint));
78
+ const maybePublicKey = this.#publicKeys.find(([k]) => (k == fingerprint));
96
79
  if (maybePublicKey) {
97
80
  publicKeyFingerprint = fingerprint;
98
81
  publicKey = maybePublicKey[1];
@@ -167,4 +150,3 @@ class ClientPlain extends _0_client_abstract_js_1.ClientAbstract {
167
150
  }
168
151
  }
169
152
  exports.ClientPlain = ClientPlain;
170
- _ClientPlain_publicKeys = new WeakMap();
@@ -18,18 +18,6 @@
18
18
  * You should have received a copy of the GNU Lesser General Public License
19
19
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
20
  */
21
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
22
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
23
- 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");
24
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
25
- };
26
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
27
- if (kind === "m") throw new TypeError("Private method is not writable");
28
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
29
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
30
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
31
- };
32
- var _Composer_handle, _Composer_prefixes;
33
21
  Object.defineProperty(exports, "__esModule", { value: true });
34
22
  exports.Composer = void 0;
35
23
  exports.flatten = flatten;
@@ -58,23 +46,23 @@ function skip(_ctx, next) {
58
46
  return next();
59
47
  }
60
48
  class Composer {
49
+ #handle;
50
+ #prefixes;
61
51
  set prefixes(value) {
62
- if (__classPrivateFieldGet(this, _Composer_prefixes, "f") !== undefined) {
52
+ if (this.#prefixes !== undefined) {
63
53
  throw new _0_errors_js_1.InputError("Prefixes already set");
64
54
  }
65
- __classPrivateFieldSet(this, _Composer_prefixes, value, "f");
55
+ this.#prefixes = value;
66
56
  }
67
57
  constructor(...middleware) {
68
- _Composer_handle.set(this, void 0);
69
- _Composer_prefixes.set(this, void 0);
70
- __classPrivateFieldSet(this, _Composer_handle, middleware.length == 0 ? skip : middleware.map(flatten).reduce(concat), "f");
58
+ this.#handle = middleware.length == 0 ? skip : middleware.map(flatten).reduce(concat);
71
59
  }
72
60
  middleware() {
73
- return __classPrivateFieldGet(this, _Composer_handle, "f");
61
+ return this.#handle;
74
62
  }
75
63
  use(...middleware) {
76
64
  const composer = new Composer(...middleware);
77
- __classPrivateFieldSet(this, _Composer_handle, concat(__classPrivateFieldGet(this, _Composer_handle, "f"), flatten(composer)), "f");
65
+ this.#handle = concat(this.#handle, flatten(composer));
78
66
  return composer;
79
67
  }
80
68
  branch(predicate, trueHandler_, falseHandler_) {
@@ -102,7 +90,7 @@ class Composer {
102
90
  command(commands, ...middleware) {
103
91
  const commands__ = typeof commands === "object" && "names" in commands ? commands.names : commands;
104
92
  const commands_ = Array.isArray(commands__) ? commands__ : [commands__];
105
- const prefixes_ = typeof commands === "object" && "prefixes" in commands ? commands.prefixes : (__classPrivateFieldGet(this, _Composer_prefixes, "f") ?? []);
93
+ const prefixes_ = typeof commands === "object" && "prefixes" in commands ? commands.prefixes : (this.#prefixes ?? []);
106
94
  const prefixes = Array.isArray(prefixes_) ? prefixes_ : [prefixes_];
107
95
  for (const left of prefixes) {
108
96
  for (const right of prefixes) {
@@ -172,4 +160,3 @@ class Composer {
172
160
  }
173
161
  }
174
162
  exports.Composer = Composer;
175
- _Composer_handle = new WeakMap(), _Composer_prefixes = new WeakMap();
@@ -18,18 +18,6 @@
18
18
  * You should have received a copy of the GNU Lesser General Public License
19
19
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
20
  */
21
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
22
- if (kind === "m") throw new TypeError("Private method is not writable");
23
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
24
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
25
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
26
- };
27
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
28
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
29
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
30
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
31
- };
32
- var _AccountManager_instances, _AccountManager_c, _AccountManager_toggleUsername, _AccountManager_getUserFull;
33
21
  Object.defineProperty(exports, "__esModule", { value: true });
34
22
  exports.AccountManager = void 0;
35
23
  const _0_deps_js_1 = require("../0_deps.js");
@@ -38,99 +26,113 @@ const _2_tl_js_1 = require("../2_tl.js");
38
26
  const _3_types_js_1 = require("../3_types.js");
39
27
  const _0_utilities_js_1 = require("./0_utilities.js");
40
28
  class AccountManager {
29
+ #c;
41
30
  constructor(c) {
42
- _AccountManager_instances.add(this);
43
- _AccountManager_c.set(this, void 0);
44
- __classPrivateFieldSet(this, _AccountManager_c, c, "f");
31
+ this.#c = c;
32
+ }
33
+ async #toggleUsername(id, username, active) {
34
+ const peer = await this.#c.getInputPeer(id);
35
+ if (_2_tl_js_1.Api.is("inputPeerSelf", peer)) {
36
+ await this.#c.invoke({ _: "account.toggleUsername", username, active });
37
+ }
38
+ else if ((0, _0_utilities_js_1.canBeInputUser)(peer)) {
39
+ await this.#c.invoke({ _: "bots.toggleUsername", bot: (0, _0_utilities_js_1.toInputUser)(peer), username, active });
40
+ }
41
+ else if ((0, _0_utilities_js_1.canBeInputChannel)(peer)) {
42
+ await this.#c.invoke({ _: "channels.toggleUsername", channel: (0, _0_utilities_js_1.toInputChannel)(peer), username, active });
43
+ }
44
+ else {
45
+ (0, _0_deps_js_1.unreachable)();
46
+ }
45
47
  }
46
48
  async showUsername(id, username) {
47
- __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("showUsername");
48
- await __classPrivateFieldGet(this, _AccountManager_instances, "m", _AccountManager_toggleUsername).call(this, id, username, true);
49
+ this.#c.storage.assertUser("showUsername");
50
+ await this.#toggleUsername(id, username, true);
49
51
  }
50
52
  async hideUsername(id, username) {
51
- __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("hideUsername");
52
- await __classPrivateFieldGet(this, _AccountManager_instances, "m", _AccountManager_toggleUsername).call(this, id, username, false);
53
+ this.#c.storage.assertUser("hideUsername");
54
+ await this.#toggleUsername(id, username, false);
53
55
  }
54
56
  async reorderUsernames(id, order) {
55
- __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("reorderUsernames");
56
- const peer = await __classPrivateFieldGet(this, _AccountManager_c, "f").getInputPeer(id);
57
+ this.#c.storage.assertUser("reorderUsernames");
58
+ const peer = await this.#c.getInputPeer(id);
57
59
  if (_2_tl_js_1.Api.is("inputPeerSelf", peer)) {
58
- return await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "account.reorderUsernames", order });
60
+ return await this.#c.invoke({ _: "account.reorderUsernames", order });
59
61
  }
60
62
  else if ((0, _0_utilities_js_1.canBeInputUser)(peer)) {
61
- return await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "bots.reorderUsernames", bot: (0, _0_utilities_js_1.toInputUser)(peer), order });
63
+ return await this.#c.invoke({ _: "bots.reorderUsernames", bot: (0, _0_utilities_js_1.toInputUser)(peer), order });
62
64
  }
63
65
  else if ((0, _0_utilities_js_1.canBeInputChannel)(peer)) {
64
- return await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "channels.reorderUsernames", channel: (0, _0_utilities_js_1.toInputChannel)(peer), order });
66
+ return await this.#c.invoke({ _: "channels.reorderUsernames", channel: (0, _0_utilities_js_1.toInputChannel)(peer), order });
65
67
  }
66
68
  else {
67
69
  (0, _0_deps_js_1.unreachable)();
68
70
  }
69
71
  }
70
72
  async hideUsernames(id) {
71
- __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("hideUsernames");
72
- const peer = await __classPrivateFieldGet(this, _AccountManager_c, "f").getInputPeer(id);
73
+ this.#c.storage.assertUser("hideUsernames");
74
+ const peer = await this.#c.getInputPeer(id);
73
75
  if ((0, _0_utilities_js_1.canBeInputChannel)(peer)) {
74
- return await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "channels.deactivateAllUsernames", channel: (0, _0_utilities_js_1.toInputChannel)(peer) });
76
+ return await this.#c.invoke({ _: "channels.deactivateAllUsernames", channel: (0, _0_utilities_js_1.toInputChannel)(peer) });
75
77
  }
76
78
  else {
77
79
  (0, _0_deps_js_1.unreachable)();
78
80
  }
79
81
  }
80
82
  async getInactiveChats() {
81
- __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("getInactiveChats");
82
- const { chats, dates } = await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "channels.getInactiveChannels" });
83
+ this.#c.storage.assertUser("getInactiveChats");
84
+ const { chats, dates } = await this.#c.invoke({ _: "channels.getInactiveChannels" });
83
85
  return chats.map((v, i) => (0, _3_types_js_1.constructInactiveChat)(v, dates[i]));
84
86
  }
85
87
  async setOnline(online) {
86
- __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("setOnline");
87
- await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "account.updateStatus", offline: !online });
88
+ this.#c.storage.assertUser("setOnline");
89
+ await this.#c.invoke({ _: "account.updateStatus", offline: !online });
88
90
  }
89
91
  async setEmojiStatus(id, params) {
90
- __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("setEmojiStatus");
92
+ this.#c.storage.assertUser("setEmojiStatus");
91
93
  const document_id = BigInt(id);
92
94
  const until = params?.until;
93
95
  const emoji_status = { _: "emojiStatus", document_id, until };
94
- await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "account.updateEmojiStatus", emoji_status });
96
+ await this.#c.invoke({ _: "account.updateEmojiStatus", emoji_status });
95
97
  }
96
98
  async setUserEmojiStatus(userId, id, params) {
97
- __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertBot("setUserEmojiStatus");
98
- const user_id = await __classPrivateFieldGet(this, _AccountManager_c, "f").getInputUser(userId);
99
+ this.#c.storage.assertBot("setUserEmojiStatus");
100
+ const user_id = await this.#c.getInputUser(userId);
99
101
  const document_id = BigInt(id);
100
102
  const until = params?.until;
101
103
  const emoji_status = { _: "emojiStatus", document_id, until };
102
- await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "bots.updateUserEmojiStatus", user_id, emoji_status });
104
+ await this.#c.invoke({ _: "bots.updateUserEmojiStatus", user_id, emoji_status });
103
105
  }
104
106
  async setBotCanSetEmojiStatus(botId, canSetEmojiStatus) {
105
- __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("setBotCanSetEmojiStatus");
106
- const bot = await __classPrivateFieldGet(this, _AccountManager_c, "f").getInputUser(botId);
107
+ this.#c.storage.assertUser("setBotCanSetEmojiStatus");
108
+ const bot = await this.#c.getInputUser(botId);
107
109
  const enabled = canSetEmojiStatus;
108
- await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "bots.toggleUserEmojiStatusPermission", bot, enabled });
110
+ await this.#c.invoke({ _: "bots.toggleUserEmojiStatusPermission", bot, enabled });
109
111
  }
110
112
  async getContacts() {
111
- __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("getContacts");
112
- const result = await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "contacts.getContacts", hash: 0n });
113
+ this.#c.storage.assertUser("getContacts");
114
+ const result = await this.#c.invoke({ _: "contacts.getContacts", hash: 0n });
113
115
  if (!_2_tl_js_1.Api.is("contacts.contacts", result)) {
114
116
  (0, _0_deps_js_1.unreachable)();
115
117
  }
116
118
  return result.users.map((v) => _2_tl_js_1.Api.is("user", v) ? (0, _3_types_js_1.constructUser)(v) : null).filter((v) => v != null);
117
119
  }
118
120
  async deleteContacts(userIds) {
119
- __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("deleteContacts");
120
- const id = await Promise.all(userIds.map((v) => __classPrivateFieldGet(this, _AccountManager_c, "f").getInputUser(v)));
121
- await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "contacts.deleteContacts", id });
121
+ this.#c.storage.assertUser("deleteContacts");
122
+ const id = await Promise.all(userIds.map((v) => this.#c.getInputUser(v)));
123
+ await this.#c.invoke({ _: "contacts.deleteContacts", id });
122
124
  }
123
125
  async deleteContact(userId) {
124
- __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("deleteContact");
126
+ this.#c.storage.assertUser("deleteContact");
125
127
  await this.deleteContacts([userId]);
126
128
  }
127
129
  async addContact(userId, params) {
128
- __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("addContact");
129
- const id = await __classPrivateFieldGet(this, _AccountManager_c, "f").getInputUser(userId);
130
+ this.#c.storage.assertUser("addContact");
131
+ const id = await this.#c.getInputUser(userId);
130
132
  if (!_2_tl_js_1.Api.is("inputPeerUser", id)) {
131
133
  (0, _0_deps_js_1.unreachable)();
132
134
  }
133
- const user = await __classPrivateFieldGet(this, _AccountManager_c, "f").getEntity(_2_tl_js_1.Api.inputPeerToPeer(id));
135
+ const user = await this.#c.getEntity(_2_tl_js_1.Api.inputPeerToPeer(id));
134
136
  if (!user || !("first_name" in user)) {
135
137
  (0, _0_deps_js_1.unreachable)();
136
138
  }
@@ -138,13 +140,31 @@ class AccountManager {
138
140
  const last_name = params?.lastName ?? user.last_name ?? "";
139
141
  const phone = "";
140
142
  const add_phone_privacy_exception = params?.sharePhoneNumber ? true : undefined;
141
- await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "contacts.addContact", add_phone_privacy_exception, id, first_name, last_name, phone });
143
+ await this.#c.invoke({ _: "contacts.addContact", add_phone_privacy_exception, id, first_name, last_name, phone });
144
+ }
145
+ async #getUserFull(chatId) {
146
+ const inputPeer = await this.#c.getInputPeer(chatId);
147
+ const chatId_ = await this.#c.getInputPeerChatId(inputPeer);
148
+ let fullChat = await this.#c.storage.getFullChat(chatId_);
149
+ if (fullChat != null) {
150
+ if (!_2_tl_js_1.Api.is("userFull", fullChat)) {
151
+ (0, _0_deps_js_1.unreachable)();
152
+ }
153
+ return fullChat;
154
+ }
155
+ if ((0, _0_utilities_js_1.canBeInputUser)(inputPeer)) {
156
+ fullChat = (await this.#c.invoke({ _: "users.getFullUser", id: (0, _0_utilities_js_1.toInputUser)(inputPeer) })).full_user;
157
+ }
158
+ else {
159
+ (0, _0_deps_js_1.unreachable)();
160
+ }
161
+ return fullChat;
142
162
  }
143
163
  async updateProfile(params) {
144
- __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("updateProfile");
145
- const selfId = await __classPrivateFieldGet(this, _AccountManager_c, "f").getSelfId();
146
- const userFull = await __classPrivateFieldGet(this, _AccountManager_instances, "m", _AccountManager_getUserFull).call(this, selfId);
147
- const entity = await __classPrivateFieldGet(this, _AccountManager_c, "f").getEntity(_2_tl_js_1.Api.chatIdToPeer(selfId));
164
+ this.#c.storage.assertUser("updateProfile");
165
+ const selfId = await this.#c.getSelfId();
166
+ const userFull = await this.#getUserFull(selfId);
167
+ const entity = await this.#c.getEntity(_2_tl_js_1.Api.chatIdToPeer(selfId));
148
168
  if (!_2_tl_js_1.Api.is("user", entity)) {
149
169
  (0, _0_deps_js_1.unreachable)();
150
170
  }
@@ -170,33 +190,33 @@ class AccountManager {
170
190
  if (!params?.firstName && !params?.lastName && !params?.bio) {
171
191
  throw new _0_errors_js_1.InputError("At least one parameter must be specified.");
172
192
  }
173
- await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "account.updateProfile", first_name: params.firstName, last_name: params.lastName, about: params.bio });
193
+ await this.#c.invoke({ _: "account.updateProfile", first_name: params.firstName, last_name: params.lastName, about: params.bio });
174
194
  }
175
195
  async setBirthday(params) {
176
- __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("setBirthday");
196
+ this.#c.storage.assertUser("setBirthday");
177
197
  const birthday = params?.birthday ? (0, _3_types_js_1.birthdayToTlObject)(params.birthday) : undefined;
178
- await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "account.updateBirthday", birthday });
198
+ await this.#c.invoke({ _: "account.updateBirthday", birthday });
179
199
  }
180
200
  async setPersonalChannel(params) {
181
- __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("setPersonalChannel");
201
+ this.#c.storage.assertUser("setPersonalChannel");
182
202
  let channel = { _: "inputChannelEmpty" };
183
203
  if (params?.chatId) {
184
- channel = await __classPrivateFieldGet(this, _AccountManager_c, "f").getInputChannel(params.chatId);
204
+ channel = await this.#c.getInputChannel(params.chatId);
185
205
  }
186
- await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "account.updatePersonalChannel", channel });
206
+ await this.#c.invoke({ _: "account.updatePersonalChannel", channel });
187
207
  }
188
208
  async setNameColor(color, params) {
189
- __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("setNameColor");
209
+ this.#c.storage.assertUser("setNameColor");
190
210
  const background_emoji_id = params?.customEmojiId ? BigInt(params.customEmojiId) : undefined;
191
- await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "account.updateColor", color, background_emoji_id });
211
+ await this.#c.invoke({ _: "account.updateColor", color, background_emoji_id });
192
212
  }
193
213
  async setProfileColor(color, params) {
194
- __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("setProfileColor");
214
+ this.#c.storage.assertUser("setProfileColor");
195
215
  const background_emoji_id = params?.customEmojiId ? BigInt(params.customEmojiId) : undefined;
196
- await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "account.updateColor", for_profile: true, color, background_emoji_id });
216
+ await this.#c.invoke({ _: "account.updateColor", for_profile: true, color, background_emoji_id });
197
217
  }
198
218
  async setLocation(params) {
199
- __classPrivateFieldGet(this, _AccountManager_c, "f").storage.assertUser("setLocation");
219
+ this.#c.storage.assertUser("setLocation");
200
220
  let address = params?.address;
201
221
  if (typeof address === "string") {
202
222
  address = address.trim();
@@ -211,39 +231,7 @@ class AccountManager {
211
231
  if (params?.latitude && params.longitude) {
212
232
  geo_point = { _: "inputGeoPoint", lat: params.latitude, long: params.longitude };
213
233
  }
214
- await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "account.updateBusinessLocation", address, geo_point });
234
+ await this.#c.invoke({ _: "account.updateBusinessLocation", address, geo_point });
215
235
  }
216
236
  }
217
237
  exports.AccountManager = AccountManager;
218
- _AccountManager_c = new WeakMap(), _AccountManager_instances = new WeakSet(), _AccountManager_toggleUsername = async function _AccountManager_toggleUsername(id, username, active) {
219
- const peer = await __classPrivateFieldGet(this, _AccountManager_c, "f").getInputPeer(id);
220
- if (_2_tl_js_1.Api.is("inputPeerSelf", peer)) {
221
- await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "account.toggleUsername", username, active });
222
- }
223
- else if ((0, _0_utilities_js_1.canBeInputUser)(peer)) {
224
- await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "bots.toggleUsername", bot: (0, _0_utilities_js_1.toInputUser)(peer), username, active });
225
- }
226
- else if ((0, _0_utilities_js_1.canBeInputChannel)(peer)) {
227
- await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "channels.toggleUsername", channel: (0, _0_utilities_js_1.toInputChannel)(peer), username, active });
228
- }
229
- else {
230
- (0, _0_deps_js_1.unreachable)();
231
- }
232
- }, _AccountManager_getUserFull = async function _AccountManager_getUserFull(chatId) {
233
- const inputPeer = await __classPrivateFieldGet(this, _AccountManager_c, "f").getInputPeer(chatId);
234
- const chatId_ = await __classPrivateFieldGet(this, _AccountManager_c, "f").getInputPeerChatId(inputPeer);
235
- let fullChat = await __classPrivateFieldGet(this, _AccountManager_c, "f").storage.getFullChat(chatId_);
236
- if (fullChat != null) {
237
- if (!_2_tl_js_1.Api.is("userFull", fullChat)) {
238
- (0, _0_deps_js_1.unreachable)();
239
- }
240
- return fullChat;
241
- }
242
- if ((0, _0_utilities_js_1.canBeInputUser)(inputPeer)) {
243
- fullChat = (await __classPrivateFieldGet(this, _AccountManager_c, "f").invoke({ _: "users.getFullUser", id: (0, _0_utilities_js_1.toInputUser)(inputPeer) })).full_user;
244
- }
245
- else {
246
- (0, _0_deps_js_1.unreachable)();
247
- }
248
- return fullChat;
249
- };
@@ -18,73 +18,61 @@
18
18
  * You should have received a copy of the GNU Lesser General Public License
19
19
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
20
  */
21
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
22
- if (kind === "m") throw new TypeError("Private method is not writable");
23
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
24
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
25
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
26
- };
27
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
28
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
29
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
30
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
31
- };
32
- var _BotInfoManager_instances, _BotInfoManager_c, _BotInfoManager_setMyInfo, _BotInfoManager_getMyInfo;
33
21
  Object.defineProperty(exports, "__esModule", { value: true });
34
22
  exports.BotInfoManager = void 0;
35
23
  const _3_types_js_1 = require("../3_types.js");
36
24
  class BotInfoManager {
25
+ #c;
37
26
  constructor(c) {
38
- _BotInfoManager_instances.add(this);
39
- _BotInfoManager_c.set(this, void 0);
40
- __classPrivateFieldSet(this, _BotInfoManager_c, c, "f");
27
+ this.#c = c;
28
+ }
29
+ async #setMyInfo(info) {
30
+ await this.#c.invoke({ _: "bots.setBotInfo", ...info });
41
31
  }
42
32
  async setMyDescription(params) {
43
- __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("setMyDescription");
44
- await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_setMyInfo).call(this, { description: params?.description, lang_code: params?.languageCode ?? "" });
33
+ this.#c.storage.assertBot("setMyDescription");
34
+ await this.#setMyInfo({ description: params?.description, lang_code: params?.languageCode ?? "" });
45
35
  }
46
36
  async setMyName(params) {
47
- __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("setMyName");
48
- await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_setMyInfo).call(this, { name: params?.name, lang_code: params?.languageCode ?? "" });
37
+ this.#c.storage.assertBot("setMyName");
38
+ await this.#setMyInfo({ name: params?.name, lang_code: params?.languageCode ?? "" });
49
39
  }
50
40
  async setMyShortDescription(params) {
51
- __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("setMyShortDescription");
52
- await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_setMyInfo).call(this, { about: params?.shortDescription, lang_code: params?.languageCode ?? "" });
41
+ this.#c.storage.assertBot("setMyShortDescription");
42
+ await this.#setMyInfo({ about: params?.shortDescription, lang_code: params?.languageCode ?? "" });
43
+ }
44
+ #getMyInfo(languageCode) {
45
+ return this.#c.invoke({ _: "bots.getBotInfo", lang_code: languageCode ?? "" });
53
46
  }
54
47
  async getMyDescription(params) {
55
- __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("getMyDescription");
56
- return (await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_getMyInfo).call(this, params?.languageCode)).description;
48
+ this.#c.storage.assertBot("getMyDescription");
49
+ return (await this.#getMyInfo(params?.languageCode)).description;
57
50
  }
58
51
  async getMyName(params) {
59
- __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("getMyName");
60
- return (await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_getMyInfo).call(this, params?.languageCode)).description;
52
+ this.#c.storage.assertBot("getMyName");
53
+ return (await this.#getMyInfo(params?.languageCode)).description;
61
54
  }
62
55
  async getMyShortDescription(params) {
63
- __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("getMyShortDescription");
64
- return (await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_getMyInfo).call(this, params?.languageCode)).about;
56
+ this.#c.storage.assertBot("getMyShortDescription");
57
+ return (await this.#getMyInfo(params?.languageCode)).about;
65
58
  }
66
59
  async getMyCommands(params) {
67
- __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("getMyCommands");
68
- const commands_ = await __classPrivateFieldGet(this, _BotInfoManager_c, "f").invoke({
60
+ this.#c.storage.assertBot("getMyCommands");
61
+ const commands_ = await this.#c.invoke({
69
62
  _: "bots.getBotCommands",
70
63
  lang_code: params?.languageCode ?? "",
71
- scope: await (0, _3_types_js_1.botCommandScopeToTlObject)(params?.scope ?? { type: "default" }, __classPrivateFieldGet(this, _BotInfoManager_c, "f").getInputPeer),
64
+ scope: await (0, _3_types_js_1.botCommandScopeToTlObject)(params?.scope ?? { type: "default" }, this.#c.getInputPeer),
72
65
  });
73
66
  return commands_.map((v) => ({ command: v.command, description: v.description }));
74
67
  }
75
68
  async setMyCommands(commands, params) {
76
- __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("setMyCommands");
77
- await __classPrivateFieldGet(this, _BotInfoManager_c, "f").invoke({
69
+ this.#c.storage.assertBot("setMyCommands");
70
+ await this.#c.invoke({
78
71
  _: "bots.setBotCommands",
79
72
  commands: commands.map((v) => ({ ...v, _: "botCommand" })),
80
73
  lang_code: params?.languageCode ?? "",
81
- scope: await (0, _3_types_js_1.botCommandScopeToTlObject)(params?.scope ?? { type: "default" }, __classPrivateFieldGet(this, _BotInfoManager_c, "f").getInputPeer),
74
+ scope: await (0, _3_types_js_1.botCommandScopeToTlObject)(params?.scope ?? { type: "default" }, this.#c.getInputPeer),
82
75
  });
83
76
  }
84
77
  }
85
78
  exports.BotInfoManager = BotInfoManager;
86
- _BotInfoManager_c = new WeakMap(), _BotInfoManager_instances = new WeakSet(), _BotInfoManager_setMyInfo = async function _BotInfoManager_setMyInfo(info) {
87
- await __classPrivateFieldGet(this, _BotInfoManager_c, "f").invoke({ _: "bots.setBotInfo", ...info });
88
- }, _BotInfoManager_getMyInfo = function _BotInfoManager_getMyInfo(languageCode) {
89
- return __classPrivateFieldGet(this, _BotInfoManager_c, "f").invoke({ _: "bots.getBotInfo", lang_code: languageCode ?? "" });
90
- };
@@ -18,18 +18,6 @@
18
18
  * You should have received a copy of the GNU Lesser General Public License
19
19
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
20
  */
21
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
22
- if (kind === "m") throw new TypeError("Private method is not writable");
23
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
24
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
25
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
26
- };
27
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
28
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
29
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
30
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
31
- };
32
- var _BusinessConnectionManager_c;
33
21
  Object.defineProperty(exports, "__esModule", { value: true });
34
22
  exports.BusinessConnectionManager = void 0;
35
23
  const _2_tl_js_1 = require("../2_tl.js");
@@ -38,21 +26,21 @@ const businessConnectionManagerUpdates = [
38
26
  "updateBotBusinessConnect",
39
27
  ];
40
28
  class BusinessConnectionManager {
29
+ #c;
41
30
  constructor(c) {
42
- _BusinessConnectionManager_c.set(this, void 0);
43
- __classPrivateFieldSet(this, _BusinessConnectionManager_c, c, "f");
31
+ this.#c = c;
44
32
  }
45
33
  async getBusinessConnection(id) {
46
- const connection_ = await __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").messageStorage.getBusinessConnection(id);
34
+ const connection_ = await this.#c.messageStorage.getBusinessConnection(id);
47
35
  if (!connection_) {
48
- const connection_ = await __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").invoke({ _: "account.getBotBusinessConnection", connection_id: id })
36
+ const connection_ = await this.#c.invoke({ _: "account.getBotBusinessConnection", connection_id: id })
49
37
  .then((v) => _2_tl_js_1.Api.as("updates", v))
50
38
  .then((v) => _2_tl_js_1.Api.as("updateBotBusinessConnect", v.updates[0]).connection);
51
- await __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").messageStorage.setBusinessConnection(id, connection_);
52
- return await (0, _3_types_js_1.constructBusinessConnection)(connection_, __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").getEntity);
39
+ await this.#c.messageStorage.setBusinessConnection(id, connection_);
40
+ return await (0, _3_types_js_1.constructBusinessConnection)(connection_, this.#c.getEntity);
53
41
  }
54
42
  else {
55
- return await (0, _3_types_js_1.constructBusinessConnection)(connection_, __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").getEntity);
43
+ return await (0, _3_types_js_1.constructBusinessConnection)(connection_, this.#c.getEntity);
56
44
  }
57
45
  }
58
46
  canHandleUpdate(update) {
@@ -60,14 +48,13 @@ class BusinessConnectionManager {
60
48
  }
61
49
  async handleUpdate(update) {
62
50
  if (update.connection.disabled) {
63
- await __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").messageStorage.setBusinessConnection(update.connection.connection_id, null);
51
+ await this.#c.messageStorage.setBusinessConnection(update.connection.connection_id, null);
64
52
  }
65
53
  else {
66
- await __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").messageStorage.setBusinessConnection(update.connection.connection_id, update.connection);
54
+ await this.#c.messageStorage.setBusinessConnection(update.connection.connection_id, update.connection);
67
55
  }
68
- const businessConnection = await (0, _3_types_js_1.constructBusinessConnection)(update.connection, __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").getEntity);
56
+ const businessConnection = await (0, _3_types_js_1.constructBusinessConnection)(update.connection, this.#c.getEntity);
69
57
  return { businessConnection };
70
58
  }
71
59
  }
72
60
  exports.BusinessConnectionManager = BusinessConnectionManager;
73
- _BusinessConnectionManager_c = new WeakMap();