@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,60 +1,37 @@
1
1
  "use strict";
2
2
  // Copyright 2018-2025 the Deno authors. MIT license.
3
3
  // This module is browser compatible.
4
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
5
- if (kind === "m") throw new TypeError("Private method is not writable");
6
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
7
- 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");
8
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
9
- };
10
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
11
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
12
- 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");
13
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
14
- };
15
- var _Queue_source, _Queue_queue;
16
4
  Object.defineProperty(exports, "__esModule", { value: true });
17
5
  exports.tee = tee;
18
6
  class Queue {
7
+ #source;
8
+ #queue;
9
+ head;
10
+ done;
19
11
  constructor(iterable) {
20
- _Queue_source.set(this, void 0);
21
- _Queue_queue.set(this, void 0);
22
- Object.defineProperty(this, "head", {
23
- enumerable: true,
24
- configurable: true,
25
- writable: true,
26
- value: void 0
27
- });
28
- Object.defineProperty(this, "done", {
29
- enumerable: true,
30
- configurable: true,
31
- writable: true,
32
- value: void 0
33
- });
34
- __classPrivateFieldSet(this, _Queue_source, iterable[Symbol.asyncIterator](), "f");
35
- __classPrivateFieldSet(this, _Queue_queue, {
12
+ this.#source = iterable[Symbol.asyncIterator]();
13
+ this.#queue = {
36
14
  value: undefined,
37
15
  next: undefined,
38
- }, "f");
39
- this.head = __classPrivateFieldGet(this, _Queue_queue, "f");
16
+ };
17
+ this.head = this.#queue;
40
18
  this.done = false;
41
19
  }
42
20
  async next() {
43
- const result = await __classPrivateFieldGet(this, _Queue_source, "f").next();
21
+ const result = await this.#source.next();
44
22
  if (!result.done) {
45
23
  const nextNode = {
46
24
  value: result.value,
47
25
  next: undefined,
48
26
  };
49
- __classPrivateFieldGet(this, _Queue_queue, "f").next = nextNode;
50
- __classPrivateFieldSet(this, _Queue_queue, nextNode, "f");
27
+ this.#queue.next = nextNode;
28
+ this.#queue = nextNode;
51
29
  }
52
30
  else {
53
31
  this.done = true;
54
32
  }
55
33
  }
56
34
  }
57
- _Queue_source = new WeakMap(), _Queue_queue = new WeakMap();
58
35
  /**
59
36
  * Branches the given async iterable into the `n` branches.
60
37
  *
@@ -1,18 +1,6 @@
1
1
  "use strict";
2
2
  // Copyright 2018-2025 the Deno authors. MIT license.
3
3
  // This module is browser compatible.
4
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
5
- if (kind === "m") throw new TypeError("Private method is not writable");
6
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
7
- 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");
8
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
9
- };
10
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
11
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
12
- 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");
13
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
14
- };
15
- var _DateTimeFormatter_formatParts;
16
4
  Object.defineProperty(exports, "__esModule", { value: true });
17
5
  exports.DateTimeFormatter = void 0;
18
6
  function digits(value, count = 2) {
@@ -137,14 +125,14 @@ function sortDateTimeFormatParts(parts) {
137
125
  return result;
138
126
  }
139
127
  class DateTimeFormatter {
128
+ #formatParts;
140
129
  constructor(formatString) {
141
- _DateTimeFormatter_formatParts.set(this, void 0);
142
- __classPrivateFieldSet(this, _DateTimeFormatter_formatParts, formatToFormatParts(formatString), "f");
130
+ this.#formatParts = formatToFormatParts(formatString);
143
131
  }
144
132
  format(date, options = {}) {
145
133
  let string = "";
146
134
  const utc = options.timeZone === "UTC";
147
- for (const part of __classPrivateFieldGet(this, _DateTimeFormatter_formatParts, "f")) {
135
+ for (const part of this.#formatParts) {
148
136
  const type = part.type;
149
137
  switch (type) {
150
138
  case "year": {
@@ -277,7 +265,7 @@ class DateTimeFormatter {
277
265
  }
278
266
  formatToParts(string) {
279
267
  const parts = [];
280
- for (const part of __classPrivateFieldGet(this, _DateTimeFormatter_formatParts, "f")) {
268
+ for (const part of this.#formatParts) {
281
269
  const type = part.type;
282
270
  let length = 0;
283
271
  let value = "";
@@ -551,4 +539,3 @@ class DateTimeFormatter {
551
539
  }
552
540
  }
553
541
  exports.DateTimeFormatter = DateTimeFormatter;
554
- _DateTimeFormatter_formatParts = new WeakMap();
@@ -17,13 +17,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
17
17
  }) : function(o, v) {
18
18
  o["default"] = v;
19
19
  });
20
- var __importStar = (this && this.__importStar) || function (mod) {
21
- if (mod && mod.__esModule) return mod;
22
- var result = {};
23
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
- __setModuleDefault(result, mod);
25
- return result;
26
- };
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
+ };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
27
37
  Object.defineProperty(exports, "__esModule", { value: true });
28
38
  exports.format = format;
29
39
  /** An inspect function conforming to the shape of `Deno.inspect` and `node:util`'s `inspect` */
@@ -19,13 +19,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
19
19
  }) : function(o, v) {
20
20
  o["default"] = v;
21
21
  });
22
- var __importStar = (this && this.__importStar) || function (mod) {
23
- if (mod && mod.__esModule) return mod;
24
- var result = {};
25
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
26
- __setModuleDefault(result, mod);
27
- return result;
28
- };
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
29
39
  Object.defineProperty(exports, "__esModule", { value: true });
30
40
  exports.bold = bold;
31
41
  exports.red = red;
@@ -18,13 +18,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
18
18
  }) : function(o, v) {
19
19
  o["default"] = v;
20
20
  });
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
39
  exports.isWindows = void 0;
30
40
  // Check Deno, then the remaining runtimes (e.g. Node, Bun and the browser)
package/script/mod.js CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
37
  };
@@ -78,19 +88,9 @@ if (!("CompressionStream" in dntShim.dntGlobalThis)) {
78
88
  // original idea: MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource>
79
89
  // @see https://github.com/oven-sh/bun/issues/1723#issuecomment-1774174194
80
90
  class Stream {
91
+ readable;
92
+ writable;
81
93
  constructor(compress, format) {
82
- Object.defineProperty(this, "readable", {
83
- enumerable: true,
84
- configurable: true,
85
- writable: true,
86
- value: void 0
87
- });
88
- Object.defineProperty(this, "writable", {
89
- enumerable: true,
90
- configurable: true,
91
- writable: true,
92
- value: void 0
93
- });
94
94
  let handler;
95
95
  if (format === "gzip") {
96
96
  handler = compress ? (0, node_zlib_1.createGzip)() : (0, node_zlib_1.createGunzip)();
@@ -18,64 +18,38 @@
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 _SessionState_seqNo, _SessionState_messageId;
33
21
  Object.defineProperty(exports, "__esModule", { value: true });
34
22
  exports.SessionState = void 0;
35
23
  const _1_utilities_js_1 = require("../1_utilities.js");
36
24
  class SessionState {
37
- constructor() {
38
- Object.defineProperty(this, "timeDifference", {
39
- enumerable: true,
40
- configurable: true,
41
- writable: true,
42
- value: 0
43
- });
44
- Object.defineProperty(this, "serverSalt", {
45
- enumerable: true,
46
- configurable: true,
47
- writable: true,
48
- value: 0n
49
- });
50
- _SessionState_seqNo.set(this, 0);
51
- _SessionState_messageId.set(this, 0n);
52
- }
25
+ timeDifference = 0;
26
+ serverSalt = 0n;
27
+ #seqNo = 0;
28
+ #messageId = 0n;
53
29
  nextMessageId() {
54
30
  const now = (0, _1_utilities_js_1.toUnixTimestamp)(new Date()) + this.timeDifference;
55
31
  const nanoseconds = Math.floor((now - Math.floor(now)) * 1e9);
56
32
  const newMessageId = (BigInt(Math.floor(now)) << 32n) || (BigInt(nanoseconds) << 2n);
57
- if (__classPrivateFieldGet(this, _SessionState_messageId, "f") >= newMessageId) {
58
- __classPrivateFieldSet(this, _SessionState_messageId, __classPrivateFieldGet(this, _SessionState_messageId, "f") + 4n, "f");
33
+ if (this.#messageId >= newMessageId) {
34
+ this.#messageId += 4n;
59
35
  }
60
36
  else {
61
- __classPrivateFieldSet(this, _SessionState_messageId, newMessageId, "f");
37
+ this.#messageId = newMessageId;
62
38
  }
63
- return __classPrivateFieldGet(this, _SessionState_messageId, "f");
39
+ return this.#messageId;
64
40
  }
65
41
  nextSeqNo(contentRelated) {
66
- var _a;
67
- let seqNo = __classPrivateFieldGet(this, _SessionState_seqNo, "f") * 2;
42
+ let seqNo = this.#seqNo * 2;
68
43
  if (contentRelated) {
69
44
  seqNo++;
70
- __classPrivateFieldSet(this, _SessionState_seqNo, (_a = __classPrivateFieldGet(this, _SessionState_seqNo, "f"), _a++, _a), "f");
45
+ this.#seqNo++;
71
46
  }
72
47
  return seqNo;
73
48
  }
74
49
  reset() {
75
50
  this.serverSalt = 0n;
76
- __classPrivateFieldSet(this, _SessionState_seqNo, 0, "f");
77
- __classPrivateFieldSet(this, _SessionState_messageId, 0n, "f");
51
+ this.#seqNo = 0;
52
+ this.#messageId = 0n;
78
53
  }
79
54
  }
80
55
  exports.SessionState = SessionState;
81
- _SessionState_seqNo = new WeakMap(), _SessionState_messageId = new WeakMap();
@@ -15,25 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
26
- if (kind === "m") throw new TypeError("Private method is not writable");
27
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
28
- 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");
29
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
30
- };
31
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
32
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
33
- 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");
34
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
35
- };
36
- var _Session_instances, _Session_dc, _Session_cdn, _Session_lastConnect, _Session_disconnected, _Session_L, _Session_onConnectionStateChange, _Session_lastState, _Session_stateChangeHandler, _Session_connectMutex;
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
37
35
  Object.defineProperty(exports, "__esModule", { value: true });
38
36
  exports.Session = void 0;
39
37
  /**
@@ -65,108 +63,97 @@ let id = 0;
65
63
  // @ts-ignore: lib
66
64
  const defaultTransportProvider = typeof dntShim.Deno === "undefined" ? _3_transport_js_1.transportProviderWebSocket : _3_transport_js_1.transportProviderTcp;
67
65
  class Session {
66
+ #dc;
67
+ #cdn;
68
+ state = new _0_session_state_js_1.SessionState();
69
+ transport;
70
+ #lastConnect;
71
+ #disconnected = true;
72
+ #L;
73
+ #onConnectionStateChange;
68
74
  constructor(dc, params) {
69
- _Session_instances.add(this);
70
- _Session_dc.set(this, void 0);
71
- _Session_cdn.set(this, void 0);
72
- Object.defineProperty(this, "state", {
73
- enumerable: true,
74
- configurable: true,
75
- writable: true,
76
- value: new _0_session_state_js_1.SessionState()
77
- });
78
- Object.defineProperty(this, "transport", {
79
- enumerable: true,
80
- configurable: true,
81
- writable: true,
82
- value: void 0
83
- });
84
- _Session_lastConnect.set(this, void 0);
85
- _Session_disconnected.set(this, true);
86
- _Session_L.set(this, void 0);
87
- _Session_onConnectionStateChange.set(this, void 0);
88
- _Session_lastState.set(this, void 0);
89
- _Session_connectMutex.set(this, new _1_utilities_js_1.Mutex());
90
- __classPrivateFieldSet(this, _Session_dc, dc, "f");
91
- __classPrivateFieldSet(this, _Session_cdn, params?.cdn ?? false, "f");
75
+ this.#dc = dc;
76
+ this.#cdn = params?.cdn ?? false;
92
77
  const transportProvider = params?.transportProvider ?? defaultTransportProvider();
93
- this.transport = transportProvider({ dc: __classPrivateFieldGet(this, _Session_dc, "f"), cdn: __classPrivateFieldGet(this, _Session_cdn, "f") });
78
+ this.transport = transportProvider({ dc: this.#dc, cdn: this.#cdn });
94
79
  this.transport.connection.stateChangeHandler = (connected) => {
95
80
  setTimeout(() => {
96
- (0, _1_utilities_js_1.drop)(__classPrivateFieldGet(this, _Session_instances, "m", _Session_stateChangeHandler).call(this, connected));
81
+ (0, _1_utilities_js_1.drop)(this.#stateChangeHandler(connected));
97
82
  });
98
83
  };
99
- __classPrivateFieldSet(this, _Session_L, (0, _1_utilities_js_1.getLogger)("Session").client(id++), "f");
84
+ this.#L = (0, _1_utilities_js_1.getLogger)("Session").client(id++);
100
85
  }
101
86
  set onConnectionStateChange(onConnectionStateChange) {
102
- __classPrivateFieldSet(this, _Session_onConnectionStateChange, onConnectionStateChange, "f");
87
+ this.#onConnectionStateChange = onConnectionStateChange;
103
88
  }
104
89
  set connectionCallback(connectionCallback) {
105
90
  this.transport.connection.callback = connectionCallback;
106
91
  }
107
92
  get dc() {
108
- return __classPrivateFieldGet(this, _Session_dc, "f");
93
+ return this.#dc;
109
94
  }
110
95
  get cdn() {
111
- return __classPrivateFieldGet(this, _Session_cdn, "f");
96
+ return this.#cdn;
112
97
  }
113
98
  set serverSalt(serverSalt) {
114
99
  this.state.serverSalt = serverSalt;
115
100
  }
101
+ #lastState;
102
+ async #stateChangeHandler(connected) {
103
+ if (this.#lastState !== connected) {
104
+ setTimeout(() => {
105
+ this.#onConnectionStateChange?.(connected);
106
+ });
107
+ }
108
+ if (this.#lastState === connected) {
109
+ return;
110
+ }
111
+ this.#lastState = connected;
112
+ if (connected || this.#disconnected) {
113
+ if (this.#disconnected) {
114
+ this.#L.debug("not reconnecting because explicitly disconnected");
115
+ }
116
+ return;
117
+ }
118
+ if (this.#lastConnect && Date.now() - this.#lastConnect.getTime() <= 10 * _0_deps_js_1.SECOND) {
119
+ this.#L.debug("reconnecting after a delay");
120
+ await (0, _0_deps_js_1.delay)(3 * _0_deps_js_1.SECOND);
121
+ }
122
+ else {
123
+ this.#L.debug("reconnecting");
124
+ }
125
+ await this.connect();
126
+ }
116
127
  get connected() {
117
128
  return this.transport.connection.connected;
118
129
  }
130
+ #connectMutex = new _1_utilities_js_1.Mutex();
119
131
  async connect() {
120
- const unlock = await __classPrivateFieldGet(this, _Session_connectMutex, "f").lock();
132
+ const unlock = await this.#connectMutex.lock();
121
133
  try {
122
134
  if (this.connected) {
123
135
  return;
124
136
  }
125
137
  await this.transport.connection.open();
126
138
  await this.transport.transport.initialize();
127
- __classPrivateFieldSet(this, _Session_lastConnect, new Date(), "f");
128
- __classPrivateFieldSet(this, _Session_disconnected, false, "f");
139
+ this.#lastConnect = new Date();
140
+ this.#disconnected = false;
129
141
  }
130
142
  finally {
131
143
  unlock();
132
144
  }
133
145
  }
134
146
  async waitUntilConnected() {
135
- (await __classPrivateFieldGet(this, _Session_connectMutex, "f").lock())();
147
+ (await this.#connectMutex.lock())();
136
148
  }
137
149
  get disconnected() {
138
- return __classPrivateFieldGet(this, _Session_disconnected, "f");
150
+ return this.#disconnected;
139
151
  }
140
152
  disconnect() {
141
- __classPrivateFieldSet(this, _Session_disconnected, true, "f");
153
+ this.#disconnected = true;
142
154
  if (this.transport.connection.connected) {
143
155
  this.transport.connection.close();
144
156
  }
145
157
  }
146
158
  }
147
159
  exports.Session = Session;
148
- _Session_dc = new WeakMap(), _Session_cdn = new WeakMap(), _Session_lastConnect = new WeakMap(), _Session_disconnected = new WeakMap(), _Session_L = new WeakMap(), _Session_onConnectionStateChange = new WeakMap(), _Session_lastState = new WeakMap(), _Session_connectMutex = new WeakMap(), _Session_instances = new WeakSet(), _Session_stateChangeHandler = async function _Session_stateChangeHandler(connected) {
149
- if (__classPrivateFieldGet(this, _Session_lastState, "f") !== connected) {
150
- setTimeout(() => {
151
- __classPrivateFieldGet(this, _Session_onConnectionStateChange, "f")?.call(this, connected);
152
- });
153
- }
154
- if (__classPrivateFieldGet(this, _Session_lastState, "f") === connected) {
155
- return;
156
- }
157
- __classPrivateFieldSet(this, _Session_lastState, connected, "f");
158
- if (connected || __classPrivateFieldGet(this, _Session_disconnected, "f")) {
159
- if (__classPrivateFieldGet(this, _Session_disconnected, "f")) {
160
- __classPrivateFieldGet(this, _Session_L, "f").debug("not reconnecting because explicitly disconnected");
161
- }
162
- return;
163
- }
164
- if (__classPrivateFieldGet(this, _Session_lastConnect, "f") && Date.now() - __classPrivateFieldGet(this, _Session_lastConnect, "f").getTime() <= 10 * _0_deps_js_1.SECOND) {
165
- __classPrivateFieldGet(this, _Session_L, "f").debug("reconnecting after a delay");
166
- await (0, _0_deps_js_1.delay)(3 * _0_deps_js_1.SECOND);
167
- }
168
- else {
169
- __classPrivateFieldGet(this, _Session_L, "f").debug("reconnecting");
170
- }
171
- await this.connect();
172
- };