@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
@@ -1,15 +1,4 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- 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");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- 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");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _FileManager_instances, _a, _FileManager_c, _FileManager_Lupload, _FileManager_UPLOAD_MAX_CHUNK_SIZE, _FileManager_DOWNLOAD_MAX_CHUNK_SIZE, _FileManager_BIG_FILE_THRESHOLD, _FileManager_uploadStream, _FileManager_uploadBuffer, _FileManager_uploadPart, _FileManager_handleError, _FileManager_getFileContents, _FileManager_CUSTOM_EMOJI_TTL;
1
+ var _a;
13
2
  /**
14
3
  * MTKruto - Cross-runtime JavaScript library for building Telegram clients
15
4
  * Copyright (C) 2023-2025 Roj <https://roj.im/>
@@ -37,39 +26,58 @@ import { Api } from "../2_tl.js";
37
26
  import { getDc } from "../3_transport.js";
38
27
  import { constructSticker, deserializeFileId, FileType, PhotoSourceType, serializeFileId, toUniqueFileId } from "../3_types.js";
39
28
  import { STICKER_SET_NAME_TTL } from "../4_constants.js";
29
+ import { StickersetInvalid } from "../4_errors.js";
40
30
  import { UPLOAD_REQUEST_PER_CONNECTION } from "./0_utilities.js";
41
31
  export class FileManager {
32
+ #c;
33
+ #Lupload;
34
+ static #UPLOAD_MAX_CHUNK_SIZE = 512 * kilobyte;
35
+ static #DOWNLOAD_MAX_CHUNK_SIZE = 1 * megabyte;
36
+ static #BIG_FILE_THRESHOLD = 10 * megabyte;
42
37
  constructor(c) {
43
- _FileManager_instances.add(this);
44
- _FileManager_c.set(this, void 0);
45
- _FileManager_Lupload.set(this, void 0);
46
- __classPrivateFieldSet(this, _FileManager_c, c, "f");
38
+ this.#c = c;
47
39
  const L = getLogger("FileManager").client(c.id);
48
- __classPrivateFieldSet(this, _FileManager_Lupload, L.branch("upload"), "f");
40
+ this.#Lupload = L.branch("upload");
41
+ }
42
+ #progressIds = new Set();
43
+ getProgressId() {
44
+ let id;
45
+ do {
46
+ id = getRandomId();
47
+ } while (id === 0n || this.#progressIds.has(id));
48
+ this.#progressIds.add(id);
49
+ return Promise.resolve(String(id));
49
50
  }
50
51
  async upload(file, params, checkName, allowStream = true) {
51
- let { size, name, contents } = await __classPrivateFieldGet(_a, _a, "m", _FileManager_getFileContents).call(_a, file, params, allowStream);
52
+ if (params?.progressId !== undefined && !this.#progressIds.has(BigInt(params.progressId))) {
53
+ throw new InputError("Invalid progressId.");
54
+ }
55
+ if (params?.progressId !== undefined) {
56
+ this.#progressIds.delete(BigInt(params.progressId));
57
+ }
58
+ let { size, name, contents } = await _a.#getFileContents(file, params, allowStream);
52
59
  if (checkName) {
53
60
  name = checkName(name);
54
61
  }
55
62
  if (size == 0 || size < -1) {
56
63
  throw new InputError("Invalid file size.");
57
64
  }
58
- const poolSize = await __classPrivateFieldGet(this, _FileManager_c, "f").getUploadPoolSize();
59
- const chunkSize = params?.chunkSize ?? __classPrivateFieldGet(_a, _a, "f", _FileManager_UPLOAD_MAX_CHUNK_SIZE);
60
- _a.validateChunkSize(chunkSize, __classPrivateFieldGet(_a, _a, "f", _FileManager_UPLOAD_MAX_CHUNK_SIZE));
61
- const fileId = getRandomId();
62
- const isBig = contents instanceof Uint8Array ? contents.length > __classPrivateFieldGet(_a, _a, "f", _FileManager_BIG_FILE_THRESHOLD) : true;
65
+ const poolSize = await this.#c.getUploadPoolSize();
66
+ const chunkSize = params?.chunkSize ?? _a.#UPLOAD_MAX_CHUNK_SIZE;
67
+ _a.validateChunkSize(chunkSize, _a.#UPLOAD_MAX_CHUNK_SIZE);
68
+ const mustTrackProgress = params?.progressId !== undefined;
69
+ const fileId = params?.progressId !== undefined ? BigInt(params.progressId) : getRandomId();
70
+ const isBig = contents instanceof Uint8Array ? contents.length > _a.#BIG_FILE_THRESHOLD : true;
63
71
  const whatIsUploaded = contents instanceof Uint8Array ? (isBig ? "big file" : "file") + " of size " + size : "stream";
64
- __classPrivateFieldGet(this, _FileManager_Lupload, "f").debug("uploading " + whatIsUploaded + " with chunk size of " + chunkSize + " and pool size of " + poolSize + " and file ID of " + fileId);
72
+ this.#Lupload.debug("uploading " + whatIsUploaded + " with chunk size of " + chunkSize + " and pool size of " + poolSize + " and file ID of " + fileId);
65
73
  let result;
66
74
  if (contents instanceof Uint8Array) {
67
- result = await __classPrivateFieldGet(this, _FileManager_instances, "m", _FileManager_uploadBuffer).call(this, contents, fileId, chunkSize, poolSize, params?.signal);
75
+ result = await this.#uploadBuffer(contents, fileId, mustTrackProgress, chunkSize, poolSize, params?.signal);
68
76
  }
69
77
  else {
70
- result = await __classPrivateFieldGet(this, _FileManager_instances, "m", _FileManager_uploadStream).call(this, contents, fileId, chunkSize, poolSize, params?.signal);
78
+ result = await this.#uploadStream(contents, fileId, mustTrackProgress, chunkSize, poolSize, params?.signal);
71
79
  }
72
- __classPrivateFieldGet(this, _FileManager_Lupload, "f").debug(`[${fileId}] uploaded ` + result.parts + " part(s)");
80
+ this.#Lupload.debug(`[${fileId}] uploaded ` + result.parts + " part(s)");
73
81
  if (result.small) {
74
82
  return { _: "inputFile", id: fileId, name, parts: result.parts, md5_checksum: "" };
75
83
  }
@@ -77,20 +85,222 @@ export class FileManager {
77
85
  return { _: "inputFileBig", id: fileId, name, parts: result.parts };
78
86
  }
79
87
  }
88
+ async #uploadStream(stream, fileId, mustTrackProgress, chunkSize, poolSize, signal) {
89
+ let part;
90
+ let promises = new Array();
91
+ let ms = 0.05;
92
+ let uploaded = 0;
93
+ for await (part of iterateReadableStream(stream.pipeThrough(new PartStream(chunkSize)))) {
94
+ if (!part.small && part.part > 0) {
95
+ await delay(ms);
96
+ ms = Math.max(ms * .8, 0.003);
97
+ }
98
+ promises.push(this.#uploadPart(fileId, part.totalParts, !part.small, part.part, part.bytes, signal).then(() => {
99
+ if (mustTrackProgress) {
100
+ uploaded += part.bytes.length;
101
+ this.#c.handleUpdate({
102
+ uploadProgress: {
103
+ id: String(fileId),
104
+ uploaded,
105
+ total: 0,
106
+ },
107
+ });
108
+ }
109
+ }));
110
+ if (promises.length == poolSize * UPLOAD_REQUEST_PER_CONNECTION) {
111
+ await Promise.all(promises);
112
+ promises = [];
113
+ }
114
+ }
115
+ await Promise.all(promises);
116
+ return { small: part.small, parts: part.totalParts };
117
+ }
118
+ async #uploadBuffer(buffer, fileId, mustTrackProgress, chunkSize, poolSize, signal) {
119
+ const isBig = buffer.byteLength > _a.#BIG_FILE_THRESHOLD;
120
+ const partCount = Math.ceil(buffer.byteLength / chunkSize);
121
+ let promises = new Array();
122
+ let started = false;
123
+ let ms = 0.05;
124
+ let uploaded = 0;
125
+ main: for (let part = 0; part < partCount;) {
126
+ for (let i = 0; i < poolSize; ++i) {
127
+ for (let i = 0; i < UPLOAD_REQUEST_PER_CONNECTION; ++i) {
128
+ const start = part * chunkSize;
129
+ const end = start + chunkSize;
130
+ const bytes = buffer.subarray(start, end);
131
+ if (!bytes.length) {
132
+ break main;
133
+ }
134
+ if (!started) {
135
+ started = true;
136
+ }
137
+ else if (isBig && part > 0) {
138
+ await delay(ms);
139
+ ms = Math.max(ms * .8, 0.003);
140
+ }
141
+ promises.push(this.#uploadPart(fileId, partCount, isBig, part++, bytes, signal).then(() => {
142
+ if (mustTrackProgress) {
143
+ uploaded += bytes.length;
144
+ this.#c.handleUpdate({
145
+ uploadProgress: {
146
+ id: String(fileId),
147
+ uploaded,
148
+ total: buffer.length,
149
+ },
150
+ });
151
+ }
152
+ }));
153
+ if (promises.length == poolSize * UPLOAD_REQUEST_PER_CONNECTION) {
154
+ await Promise.all(promises);
155
+ promises = [];
156
+ }
157
+ }
158
+ }
159
+ await Promise.all(promises);
160
+ promises = [];
161
+ }
162
+ await Promise.all(promises);
163
+ return { small: !isBig, parts: partCount };
164
+ }
165
+ async #uploadPart(fileId, partCount, isBig, index, bytes, signal) {
166
+ let retryIn = 1;
167
+ let errorCount = 0;
168
+ while (true) {
169
+ try {
170
+ signal?.throwIfAborted();
171
+ this.#Lupload.debug(`[${fileId}] uploading part ` + (index + 1));
172
+ if (isBig) {
173
+ await this.#c.invoke({ _: "upload.saveBigFilePart", file_id: fileId, file_part: index, bytes: bytes, file_total_parts: partCount }, { type: "upload" });
174
+ }
175
+ else {
176
+ await this.#c.invoke({ _: "upload.saveFilePart", file_id: fileId, bytes: bytes, file_part: index }, { type: "upload" });
177
+ }
178
+ this.#Lupload.debug(`[${fileId}] uploaded part ` + (index + 1));
179
+ break;
180
+ }
181
+ catch (err) {
182
+ signal?.throwIfAborted();
183
+ this.#Lupload.debug(`[${fileId}] failed to upload part ` + (index + 1));
184
+ ++errorCount;
185
+ if (errorCount > 20) {
186
+ retryIn = 0;
187
+ errorCount = 20;
188
+ }
189
+ await this.#handleError(err, retryIn, `[${fileId}-${index + 1}]`);
190
+ retryIn += 2;
191
+ if (retryIn > 11) {
192
+ retryIn = 11;
193
+ }
194
+ }
195
+ }
196
+ }
197
+ async #handleError(err, retryIn, logPrefix) {
198
+ if (retryIn > 0) {
199
+ this.#Lupload.warning(`${logPrefix} retrying in ${retryIn} seconds`);
200
+ await delay(retryIn * SECOND);
201
+ }
202
+ else {
203
+ throw err;
204
+ }
205
+ }
206
+ static async #getFileContents(source, params, allowStream) {
207
+ let name = params?.fileName?.trim() || "file";
208
+ let contents;
209
+ let size = -1;
210
+ if (source instanceof Uint8Array) {
211
+ contents = source;
212
+ size = source.byteLength;
213
+ }
214
+ else if (source instanceof ReadableStream) {
215
+ if (!allowStream) {
216
+ throw new InputError("Streamed upload not allowed.");
217
+ }
218
+ contents = source;
219
+ }
220
+ else if (typeof source === "object" && source != null && (Symbol.iterator in source || Symbol.asyncIterator in source)) {
221
+ if (!allowStream) {
222
+ throw new InputError("Streamed upload not allowed.");
223
+ }
224
+ contents = new ReadableStream({
225
+ pull: Symbol.asyncIterator in source
226
+ ? async (controller) => {
227
+ const { value, done } = await source.next();
228
+ done ? controller.close() : controller.enqueue(value);
229
+ }
230
+ : (controller) => {
231
+ const { value, done } = source.next();
232
+ done ? controller.close() : controller.enqueue(value);
233
+ },
234
+ });
235
+ }
236
+ else {
237
+ let url;
238
+ try {
239
+ url = new URL(source).toString();
240
+ }
241
+ catch {
242
+ let path_;
243
+ if (typeof source === "string") {
244
+ if (isAbsolute(source)) {
245
+ path_ = source;
246
+ }
247
+ else {
248
+ // @ts-ignore: lib
249
+ path_ = join(dntShim.Deno.cwd(), source);
250
+ }
251
+ url = toFileUrl(path_).toString();
252
+ name = basename(path_);
253
+ }
254
+ else {
255
+ unreachable();
256
+ }
257
+ }
258
+ const response = await fetch(url);
259
+ if (response.body == null) {
260
+ throw new InputError("Invalid response");
261
+ }
262
+ if (name == "file") {
263
+ const contentType = response.headers.get("content-type")?.split(";")[0].trim();
264
+ if (contentType) {
265
+ name += extension(contentType);
266
+ }
267
+ else {
268
+ const maybeFileName = new URL(response.url).pathname.split("/")
269
+ .filter((v) => v)
270
+ .slice(-1)[0]
271
+ .trim();
272
+ if (maybeFileName) {
273
+ name += extension(extname(maybeFileName));
274
+ }
275
+ }
276
+ }
277
+ const contentLength = Number(response.headers.get("content-length"));
278
+ if (!isNaN(contentLength)) {
279
+ size = contentLength;
280
+ }
281
+ if (allowStream) {
282
+ contents = response.body;
283
+ }
284
+ else {
285
+ contents = new Uint8Array(await response.arrayBuffer());
286
+ }
287
+ }
288
+ return { size: params?.fileSize ? params.fileSize : size, name, contents };
289
+ }
80
290
  async *downloadInner(location, dcId, params) {
81
291
  const signal = params?.signal;
82
292
  signal?.throwIfAborted();
83
293
  const id = "id" in location ? location.id : "photo_id" in location ? location.photo_id : null;
84
- if (id != null && __classPrivateFieldGet(this, _FileManager_c, "f").storage.supportsFiles) {
85
- const file = await __classPrivateFieldGet(this, _FileManager_c, "f").storage.getFile(id);
294
+ if (id != null && this.#c.storage.supportsFiles) {
295
+ const file = await this.#c.storage.getFile(id);
86
296
  const partOffset = file == null ? 0 : params?.offset ? Math.ceil(10 / file[1]) - 1 : 0;
87
297
  if (file != null && file[0] > 0) {
88
- yield* __classPrivateFieldGet(this, _FileManager_c, "f").storage.iterFileParts(id, file[0], partOffset, signal);
298
+ yield* this.#c.storage.iterFileParts(id, file[0], partOffset, signal);
89
299
  return;
90
300
  }
91
301
  }
92
- const chunkSize = params?.chunkSize ?? __classPrivateFieldGet(_a, _a, "f", _FileManager_DOWNLOAD_MAX_CHUNK_SIZE);
93
- _a.validateChunkSize(chunkSize, __classPrivateFieldGet(_a, _a, "f", _FileManager_DOWNLOAD_MAX_CHUNK_SIZE));
302
+ const chunkSize = params?.chunkSize ?? _a.#DOWNLOAD_MAX_CHUNK_SIZE;
303
+ _a.validateChunkSize(chunkSize, _a.#DOWNLOAD_MAX_CHUNK_SIZE);
94
304
  if (params?.offset !== undefined) {
95
305
  _a.validateOffset(params.offset);
96
306
  }
@@ -105,18 +315,18 @@ export class FileManager {
105
315
  let retryIn = 1;
106
316
  let errorCount = 0;
107
317
  try {
108
- const file = await __classPrivateFieldGet(this, _FileManager_c, "f").invoke({ _: "upload.getFile", location, offset, limit }, { dc, type: "download" });
318
+ const file = await this.#c.invoke({ _: "upload.getFile", location, offset, limit }, { dc, type: "download" });
109
319
  signal?.throwIfAborted();
110
320
  if (Api.is("upload.file", file)) {
111
321
  yield file.bytes;
112
322
  if (id != null) {
113
- await __classPrivateFieldGet(this, _FileManager_c, "f").storage.saveFilePart(id, part, file.bytes);
323
+ await this.#c.storage.saveFilePart(id, part, file.bytes);
114
324
  signal?.throwIfAborted();
115
325
  }
116
326
  ++part;
117
327
  if (file.bytes.length < limit) {
118
328
  if (id != null) {
119
- await __classPrivateFieldGet(this, _FileManager_c, "f").storage.setFilePartCount(id, part + 1, chunkSize);
329
+ await this.#c.storage.setFilePartCount(id, part + 1, chunkSize);
120
330
  signal?.throwIfAborted();
121
331
  }
122
332
  break;
@@ -140,7 +350,7 @@ export class FileManager {
140
350
  retryIn = 0;
141
351
  errorCount = 0;
142
352
  }
143
- await __classPrivateFieldGet(this, _FileManager_instances, "m", _FileManager_handleError).call(this, err, retryIn, `[${id}-${part + 1}]`);
353
+ await this.#handleError(err, retryIn, `[${id}-${part + 1}]`);
144
354
  signal?.throwIfAborted();
145
355
  retryIn += 2;
146
356
  if (retryIn > 11) {
@@ -183,7 +393,7 @@ export class FileManager {
183
393
  unreachable();
184
394
  }
185
395
  const big = fileId_.location.source.type == PhotoSourceType.ChatPhotoBig;
186
- const peer = await __classPrivateFieldGet(this, _FileManager_c, "f").getInputPeer(Number(fileId_.location.source.chatId));
396
+ const peer = await this.#c.getInputPeer(Number(fileId_.location.source.chatId));
187
397
  const location = { _: "inputPeerPhotoFileLocation", big: big ? true : undefined, peer, photo_id: fileId_.location.id };
188
398
  yield* this.downloadInner(location, fileId_.dcId, params);
189
399
  break;
@@ -227,17 +437,28 @@ export class FileManager {
227
437
  }
228
438
  }
229
439
  async getStickerSetName(inputStickerSet, hash = 0) {
230
- const maybeStickerSetName = await __classPrivateFieldGet(this, _FileManager_c, "f").messageStorage.getStickerSetName(inputStickerSet.id, inputStickerSet.access_hash);
440
+ const maybeStickerSetName = await this.#c.messageStorage.getStickerSetName(inputStickerSet.id, inputStickerSet.access_hash);
231
441
  if (maybeStickerSetName != null && Date.now() - maybeStickerSetName[1].getTime() < STICKER_SET_NAME_TTL) {
232
442
  return maybeStickerSetName[0];
233
443
  }
234
444
  else {
235
- const stickerSet = await __classPrivateFieldGet(this, _FileManager_c, "f").invoke({ _: "messages.getStickerSet", stickerset: inputStickerSet, hash });
236
- const name = Api.as("messages.stickerSet", stickerSet).set.short_name;
237
- await __classPrivateFieldGet(this, _FileManager_c, "f").messageStorage.updateStickerSetName(inputStickerSet.id, inputStickerSet.access_hash, name);
238
- return name;
445
+ try {
446
+ const stickerSet = await this.#c.invoke({ _: "messages.getStickerSet", stickerset: inputStickerSet, hash });
447
+ const name = Api.as("messages.stickerSet", stickerSet).set.short_name;
448
+ await this.#c.messageStorage.updateStickerSetName(inputStickerSet.id, inputStickerSet.access_hash, name);
449
+ return name;
450
+ }
451
+ catch (err) {
452
+ if (err instanceof StickersetInvalid) {
453
+ return undefined;
454
+ }
455
+ else {
456
+ throw err;
457
+ }
458
+ }
239
459
  }
240
460
  }
461
+ static #CUSTOM_EMOJI_TTL = 30 * MINUTE;
241
462
  async getCustomEmojiStickers(id) {
242
463
  id = Array.isArray(id) ? id : [id];
243
464
  if (!id.length) {
@@ -246,8 +467,8 @@ export class FileManager {
246
467
  const stickers = new Array();
247
468
  let shouldFetch = false;
248
469
  for (const id_ of id) {
249
- const maybeDocument = await __classPrivateFieldGet(this, _FileManager_c, "f").messageStorage.getCustomEmojiDocument(BigInt(id_));
250
- if (maybeDocument != null && Date.now() - maybeDocument[1].getTime() <= __classPrivateFieldGet(_a, _a, "f", _FileManager_CUSTOM_EMOJI_TTL)) {
470
+ const maybeDocument = await this.#c.messageStorage.getCustomEmojiDocument(BigInt(id_));
471
+ if (maybeDocument != null && Date.now() - maybeDocument[1].getTime() <= _a.#CUSTOM_EMOJI_TTL) {
251
472
  const document_ = maybeDocument[0];
252
473
  const fileId_ = {
253
474
  type: FileType.Document,
@@ -268,9 +489,9 @@ export class FileManager {
268
489
  if (!shouldFetch) {
269
490
  return stickers;
270
491
  }
271
- const documents_ = (await __classPrivateFieldGet(this, _FileManager_c, "f").invoke({ _: "messages.getCustomEmojiDocuments", document_id: id.map(BigInt) })).map((v) => Api.as("document", v));
492
+ const documents_ = (await this.#c.invoke({ _: "messages.getCustomEmojiDocuments", document_id: id.map(BigInt) })).map((v) => Api.as("document", v));
272
493
  for (const [i, document_] of documents_.entries()) {
273
- await __classPrivateFieldGet(this, _FileManager_c, "f").messageStorage.setCustomEmojiDocument(document_.id, document_);
494
+ await this.#c.messageStorage.setCustomEmojiDocument(document_.id, document_);
274
495
  const fileId_ = {
275
496
  type: FileType.Document,
276
497
  dcId: document_.dc_id,
@@ -285,181 +506,4 @@ export class FileManager {
285
506
  return stickers;
286
507
  }
287
508
  }
288
- _a = FileManager, _FileManager_c = new WeakMap(), _FileManager_Lupload = new WeakMap(), _FileManager_instances = new WeakSet(), _FileManager_uploadStream = async function _FileManager_uploadStream(stream, fileId, chunkSize, poolSize, signal) {
289
- let part;
290
- let promises = new Array();
291
- let ms = 0.05;
292
- for await (part of iterateReadableStream(stream.pipeThrough(new PartStream(chunkSize)))) {
293
- if (!part.small && part.part > 0) {
294
- await delay(ms);
295
- ms = Math.max(ms * .8, 0.003);
296
- }
297
- promises.push(__classPrivateFieldGet(this, _FileManager_instances, "m", _FileManager_uploadPart).call(this, fileId, part.totalParts, !part.small, part.part, part.bytes, signal));
298
- if (promises.length == poolSize * UPLOAD_REQUEST_PER_CONNECTION) {
299
- await Promise.all(promises);
300
- promises = [];
301
- }
302
- }
303
- await Promise.all(promises);
304
- return { small: part.small, parts: part.totalParts };
305
- }, _FileManager_uploadBuffer = async function _FileManager_uploadBuffer(buffer, fileId, chunkSize, poolSize, signal) {
306
- const isBig = buffer.byteLength > __classPrivateFieldGet(_a, _a, "f", _FileManager_BIG_FILE_THRESHOLD);
307
- const partCount = Math.ceil(buffer.byteLength / chunkSize);
308
- let promises = new Array();
309
- let started = false;
310
- let ms = 0.05;
311
- main: for (let part = 0; part < partCount;) {
312
- for (let i = 0; i < poolSize; ++i) {
313
- for (let i = 0; i < UPLOAD_REQUEST_PER_CONNECTION; ++i) {
314
- const start = part * chunkSize;
315
- const end = start + chunkSize;
316
- const bytes = buffer.subarray(start, end);
317
- if (!bytes.length) {
318
- break main;
319
- }
320
- if (!started) {
321
- started = true;
322
- }
323
- else if (isBig && part > 0) {
324
- await delay(ms);
325
- ms = Math.max(ms * .8, 0.003);
326
- }
327
- promises.push(__classPrivateFieldGet(this, _FileManager_instances, "m", _FileManager_uploadPart).call(this, fileId, partCount, isBig, part++, bytes, signal));
328
- if (promises.length == poolSize * UPLOAD_REQUEST_PER_CONNECTION) {
329
- await Promise.all(promises);
330
- promises = [];
331
- }
332
- }
333
- }
334
- await Promise.all(promises);
335
- promises = [];
336
- }
337
- await Promise.all(promises);
338
- return { small: !isBig, parts: partCount };
339
- }, _FileManager_uploadPart = async function _FileManager_uploadPart(fileId, partCount, isBig, index, bytes, signal) {
340
- let retryIn = 1;
341
- let errorCount = 0;
342
- while (true) {
343
- try {
344
- signal?.throwIfAborted();
345
- __classPrivateFieldGet(this, _FileManager_Lupload, "f").debug(`[${fileId}] uploading part ` + (index + 1));
346
- if (isBig) {
347
- await __classPrivateFieldGet(this, _FileManager_c, "f").invoke({ _: "upload.saveBigFilePart", file_id: fileId, file_part: index, bytes: bytes, file_total_parts: partCount }, { type: "upload" });
348
- }
349
- else {
350
- await __classPrivateFieldGet(this, _FileManager_c, "f").invoke({ _: "upload.saveFilePart", file_id: fileId, bytes: bytes, file_part: index }, { type: "upload" });
351
- }
352
- __classPrivateFieldGet(this, _FileManager_Lupload, "f").debug(`[${fileId}] uploaded part ` + (index + 1));
353
- break;
354
- }
355
- catch (err) {
356
- signal?.throwIfAborted();
357
- __classPrivateFieldGet(this, _FileManager_Lupload, "f").debug(`[${fileId}] failed to upload part ` + (index + 1));
358
- ++errorCount;
359
- if (errorCount > 20) {
360
- retryIn = 0;
361
- errorCount = 20;
362
- }
363
- await __classPrivateFieldGet(this, _FileManager_instances, "m", _FileManager_handleError).call(this, err, retryIn, `[${fileId}-${index + 1}]`);
364
- retryIn += 2;
365
- if (retryIn > 11) {
366
- retryIn = 11;
367
- }
368
- }
369
- }
370
- }, _FileManager_handleError = async function _FileManager_handleError(err, retryIn, logPrefix) {
371
- if (retryIn > 0) {
372
- __classPrivateFieldGet(this, _FileManager_Lupload, "f").warning(`${logPrefix} retrying in ${retryIn} seconds`);
373
- await delay(retryIn * SECOND);
374
- }
375
- else {
376
- throw err;
377
- }
378
- }, _FileManager_getFileContents = async function _FileManager_getFileContents(source, params, allowStream) {
379
- let name = params?.fileName?.trim() || "file";
380
- let contents;
381
- let size = -1;
382
- if (source instanceof Uint8Array) {
383
- contents = source;
384
- size = source.byteLength;
385
- }
386
- else if (source instanceof ReadableStream) {
387
- if (!allowStream) {
388
- throw new InputError("Streamed upload not allowed.");
389
- }
390
- contents = source;
391
- }
392
- else if (typeof source === "object" && source != null && (Symbol.iterator in source || Symbol.asyncIterator in source)) {
393
- if (!allowStream) {
394
- throw new InputError("Streamed upload not allowed.");
395
- }
396
- contents = new ReadableStream({
397
- pull: Symbol.asyncIterator in source
398
- ? async (controller) => {
399
- const { value, done } = await source.next();
400
- done ? controller.close() : controller.enqueue(value);
401
- }
402
- : (controller) => {
403
- const { value, done } = source.next();
404
- done ? controller.close() : controller.enqueue(value);
405
- },
406
- });
407
- }
408
- else {
409
- let url;
410
- try {
411
- url = new URL(source).toString();
412
- }
413
- catch {
414
- let path_;
415
- if (typeof source === "string") {
416
- if (isAbsolute(source)) {
417
- path_ = source;
418
- }
419
- else {
420
- // @ts-ignore: lib
421
- path_ = join(dntShim.Deno.cwd(), source);
422
- }
423
- url = toFileUrl(path_).toString();
424
- name = basename(path_);
425
- }
426
- else {
427
- unreachable();
428
- }
429
- }
430
- const response = await fetch(url);
431
- if (response.body == null) {
432
- throw new InputError("Invalid response");
433
- }
434
- if (name == "file") {
435
- const contentType = response.headers.get("content-type")?.split(";")[0].trim();
436
- if (contentType) {
437
- name += extension(contentType);
438
- }
439
- else {
440
- const maybeFileName = new URL(response.url).pathname.split("/")
441
- .filter((v) => v)
442
- .slice(-1)[0]
443
- .trim();
444
- if (maybeFileName) {
445
- name += extension(extname(maybeFileName));
446
- }
447
- }
448
- }
449
- const contentLength = Number(response.headers.get("content-length"));
450
- if (!isNaN(contentLength)) {
451
- size = contentLength;
452
- }
453
- if (allowStream) {
454
- contents = response.body;
455
- }
456
- else {
457
- contents = new Uint8Array(await response.arrayBuffer());
458
- }
459
- }
460
- return { size: params?.fileSize ? params.fileSize : size, name, contents };
461
- };
462
- _FileManager_UPLOAD_MAX_CHUNK_SIZE = { value: 512 * kilobyte };
463
- _FileManager_DOWNLOAD_MAX_CHUNK_SIZE = { value: 1 * megabyte };
464
- _FileManager_BIG_FILE_THRESHOLD = { value: 10 * megabyte };
465
- _FileManager_CUSTOM_EMOJI_TTL = { value: 30 * MINUTE };
509
+ _a = FileManager;
@@ -1 +1 @@
1
- {"version":3,"file":"2_file_manager_test.d.ts","sourceRoot":"","sources":["../../src/client/2_file_manager_test.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"2_file_manager_test.d.ts","sourceRoot":"","sources":["../../src/client/2_file_manager_test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,2BAA2B,CAAC"}
@@ -17,29 +17,17 @@
17
17
  * You should have received a copy of the GNU Lesser General Public License
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
21
- if (kind === "m") throw new TypeError("Private method is not writable");
22
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
23
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
24
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
25
- };
26
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
27
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
28
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
29
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
30
- };
31
- var _NetworkStatisticsManager_c;
32
20
  export class NetworkStatisticsManager {
21
+ #c;
33
22
  constructor(c) {
34
- _NetworkStatisticsManager_c.set(this, void 0);
35
- __classPrivateFieldSet(this, _NetworkStatisticsManager_c, c, "f");
23
+ this.#c = c;
36
24
  }
37
25
  async getNetworkStatistics() {
38
26
  const [messagesRead, messagesWrite, cdnRead, cdnWrite] = await Promise.all([
39
- __classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").storage.get(["netstat_messages_read"]),
40
- __classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").storage.get(["netstat_messages_write"]),
41
- __classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").storage.get(["netstat_cdn_read"]),
42
- __classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").storage.get(["netstat_cdn_write"]),
27
+ this.#c.storage.get(["netstat_messages_read"]),
28
+ this.#c.storage.get(["netstat_messages_write"]),
29
+ this.#c.storage.get(["netstat_cdn_read"]),
30
+ this.#c.storage.get(["netstat_cdn_write"]),
43
31
  ]);
44
32
  const messages = {
45
33
  sent: Number(messagesWrite || 0),
@@ -55,13 +43,12 @@ export class NetworkStatisticsManager {
55
43
  return {
56
44
  read: async (count) => {
57
45
  const key = cdn ? "netstat_cdn_read" : "netstat_messages_read";
58
- await __classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").storage.incr([key], count);
46
+ await this.#c.storage.incr([key], count);
59
47
  },
60
48
  write: async (count) => {
61
49
  const key = cdn ? "netstat_cdn_write" : "netstat_messages_write";
62
- await __classPrivateFieldGet(this, _NetworkStatisticsManager_c, "f").storage.incr([key], count);
50
+ await this.#c.storage.incr([key], count);
63
51
  },
64
52
  };
65
53
  }
66
54
  }
67
- _NetworkStatisticsManager_c = new WeakMap();