@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
@@ -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 _ConnectionTCP_instances, _ConnectionTCP_hostname, _ConnectionTCP_port, _ConnectionTCP_socket, _ConnectionTCP_rMutex, _ConnectionTCP_wMutex, _ConnectionTCP_buffer, _ConnectionTCP_nextResolve, _ConnectionTCP_rejectRead, _ConnectionTCP_assertConnected;
33
21
  Object.defineProperty(exports, "__esModule", { value: true });
34
22
  exports.ConnectionTCP = void 0;
35
23
  const node_net_1 = require("node:net");
@@ -38,79 +26,84 @@ const _1_utilities_js_1 = require("../1_utilities.js");
38
26
  const L = (0, _1_utilities_js_1.getLogger)("ConnectionTCP");
39
27
  const errConnectionNotOpen = new _0_errors_js_1.ConnectionError("Connection not open");
40
28
  class ConnectionTCP {
29
+ #hostname;
30
+ #port;
31
+ #socket;
32
+ #rMutex = new _1_utilities_js_1.Mutex();
33
+ #wMutex = new _1_utilities_js_1.Mutex();
34
+ #buffer = new Array();
35
+ #nextResolve = null;
36
+ stateChangeHandler;
41
37
  constructor(hostname, port) {
42
- _ConnectionTCP_instances.add(this);
43
- _ConnectionTCP_hostname.set(this, void 0);
44
- _ConnectionTCP_port.set(this, void 0);
45
- _ConnectionTCP_socket.set(this, void 0);
46
- _ConnectionTCP_rMutex.set(this, new _1_utilities_js_1.Mutex());
47
- _ConnectionTCP_wMutex.set(this, new _1_utilities_js_1.Mutex());
48
- _ConnectionTCP_buffer.set(this, new Array());
49
- _ConnectionTCP_nextResolve.set(this, null);
50
- Object.defineProperty(this, "stateChangeHandler", {
51
- enumerable: true,
52
- configurable: true,
53
- writable: true,
54
- value: void 0
55
- });
56
- __classPrivateFieldSet(this, _ConnectionTCP_hostname, hostname, "f");
57
- __classPrivateFieldSet(this, _ConnectionTCP_port, port, "f");
38
+ this.#hostname = hostname;
39
+ this.#port = port;
40
+ }
41
+ #rejectRead() {
42
+ if (this.#nextResolve != null) {
43
+ this.#nextResolve[1].reject(errConnectionNotOpen);
44
+ this.#nextResolve = null;
45
+ }
58
46
  }
59
47
  open() {
60
- __classPrivateFieldSet(this, _ConnectionTCP_socket, new node_net_1.Socket(), "f");
61
- __classPrivateFieldGet(this, _ConnectionTCP_socket, "f").on("close", () => {
62
- __classPrivateFieldGet(this, _ConnectionTCP_instances, "m", _ConnectionTCP_rejectRead).call(this);
48
+ this.#socket = new node_net_1.Socket();
49
+ this.#socket.on("close", () => {
50
+ this.#rejectRead();
63
51
  this.stateChangeHandler?.(false);
64
52
  });
65
53
  const mutex = new _1_utilities_js_1.Mutex();
66
- __classPrivateFieldGet(this, _ConnectionTCP_socket, "f").on("data", async (data) => {
54
+ this.#socket.on("data", async (data) => {
67
55
  const unlock = await mutex.lock();
68
56
  for (const byte of data) {
69
- __classPrivateFieldGet(this, _ConnectionTCP_buffer, "f").push(byte);
57
+ this.#buffer.push(byte);
70
58
  }
71
- if (__classPrivateFieldGet(this, _ConnectionTCP_nextResolve, "f") != null && __classPrivateFieldGet(this, _ConnectionTCP_buffer, "f").length >= __classPrivateFieldGet(this, _ConnectionTCP_nextResolve, "f")[0]) {
72
- const resolve = __classPrivateFieldGet(this, _ConnectionTCP_nextResolve, "f")[1].resolve;
73
- __classPrivateFieldSet(this, _ConnectionTCP_nextResolve, null, "f");
59
+ if (this.#nextResolve != null && this.#buffer.length >= this.#nextResolve[0]) {
60
+ const resolve = this.#nextResolve[1].resolve;
61
+ this.#nextResolve = null;
74
62
  resolve();
75
63
  }
76
64
  unlock();
77
65
  });
78
66
  return new Promise((resolve, reject) => {
79
- __classPrivateFieldGet(this, _ConnectionTCP_socket, "f").connect(__classPrivateFieldGet(this, _ConnectionTCP_port, "f"), __classPrivateFieldGet(this, _ConnectionTCP_hostname, "f"));
80
- __classPrivateFieldGet(this, _ConnectionTCP_socket, "f").once("error", reject);
81
- __classPrivateFieldGet(this, _ConnectionTCP_socket, "f").once("connect", () => {
82
- __classPrivateFieldGet(this, _ConnectionTCP_socket, "f").off("error", reject);
67
+ this.#socket.connect(this.#port, this.#hostname);
68
+ this.#socket.once("error", reject);
69
+ this.#socket.once("connect", () => {
70
+ this.#socket.off("error", reject);
83
71
  resolve();
84
72
  this.stateChangeHandler?.(true);
85
- L.debug("connected to", __classPrivateFieldGet(this, _ConnectionTCP_hostname, "f"), "port", __classPrivateFieldGet(this, _ConnectionTCP_port, "f"));
73
+ L.debug("connected to", this.#hostname, "port", this.#port);
86
74
  });
87
75
  });
88
76
  }
89
77
  get connected() {
90
- return __classPrivateFieldGet(this, _ConnectionTCP_socket, "f")?.readyState == "open";
78
+ return this.#socket?.readyState == "open";
79
+ }
80
+ #assertConnected() {
81
+ if (!this.connected) {
82
+ throw errConnectionNotOpen;
83
+ }
91
84
  }
92
85
  async read(p) {
93
- __classPrivateFieldGet(this, _ConnectionTCP_instances, "m", _ConnectionTCP_assertConnected).call(this);
94
- const unlock = await __classPrivateFieldGet(this, _ConnectionTCP_rMutex, "f").lock();
86
+ this.#assertConnected();
87
+ const unlock = await this.#rMutex.lock();
95
88
  try {
96
- __classPrivateFieldGet(this, _ConnectionTCP_instances, "m", _ConnectionTCP_assertConnected).call(this);
97
- if (__classPrivateFieldGet(this, _ConnectionTCP_buffer, "f").length < p.length) {
98
- await new Promise((resolve, reject) => __classPrivateFieldSet(this, _ConnectionTCP_nextResolve, [p.length, { resolve, reject }], "f"));
89
+ this.#assertConnected();
90
+ if (this.#buffer.length < p.length) {
91
+ await new Promise((resolve, reject) => this.#nextResolve = [p.length, { resolve, reject }]);
99
92
  }
100
- p.set(__classPrivateFieldGet(this, _ConnectionTCP_buffer, "f").splice(0, p.length));
93
+ p.set(this.#buffer.splice(0, p.length));
101
94
  }
102
95
  finally {
103
96
  unlock();
104
97
  }
105
98
  }
106
99
  async write(p) {
107
- __classPrivateFieldGet(this, _ConnectionTCP_instances, "m", _ConnectionTCP_assertConnected).call(this);
108
- const unlock = await __classPrivateFieldGet(this, _ConnectionTCP_wMutex, "f").lock();
100
+ this.#assertConnected();
101
+ const unlock = await this.#wMutex.lock();
109
102
  try {
110
- __classPrivateFieldGet(this, _ConnectionTCP_instances, "m", _ConnectionTCP_assertConnected).call(this);
103
+ this.#assertConnected();
111
104
  try {
112
105
  await new Promise((resolve, reject) => {
113
- __classPrivateFieldGet(this, _ConnectionTCP_socket, "f").write(p, (err) => {
106
+ this.#socket.write(p, (err) => {
114
107
  (err === undefined || err == null) ? resolve() : reject(err);
115
108
  });
116
109
  });
@@ -129,19 +122,9 @@ class ConnectionTCP {
129
122
  }
130
123
  }
131
124
  close() {
132
- __classPrivateFieldGet(this, _ConnectionTCP_instances, "m", _ConnectionTCP_assertConnected).call(this);
133
- __classPrivateFieldGet(this, _ConnectionTCP_socket, "f").destroy();
134
- __classPrivateFieldSet(this, _ConnectionTCP_socket, undefined, "f");
125
+ this.#assertConnected();
126
+ this.#socket.destroy();
127
+ this.#socket = undefined;
135
128
  }
136
129
  }
137
130
  exports.ConnectionTCP = ConnectionTCP;
138
- _ConnectionTCP_hostname = new WeakMap(), _ConnectionTCP_port = new WeakMap(), _ConnectionTCP_socket = new WeakMap(), _ConnectionTCP_rMutex = new WeakMap(), _ConnectionTCP_wMutex = new WeakMap(), _ConnectionTCP_buffer = new WeakMap(), _ConnectionTCP_nextResolve = new WeakMap(), _ConnectionTCP_instances = new WeakSet(), _ConnectionTCP_rejectRead = function _ConnectionTCP_rejectRead() {
139
- if (__classPrivateFieldGet(this, _ConnectionTCP_nextResolve, "f") != null) {
140
- __classPrivateFieldGet(this, _ConnectionTCP_nextResolve, "f")[1].reject(errConnectionNotOpen);
141
- __classPrivateFieldSet(this, _ConnectionTCP_nextResolve, null, "f");
142
- }
143
- }, _ConnectionTCP_assertConnected = function _ConnectionTCP_assertConnected() {
144
- if (!this.connected) {
145
- throw errConnectionNotOpen;
146
- }
147
- };
@@ -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 _ConnectionWebSocket_instances, _ConnectionWebSocket_url, _ConnectionWebSocket_webSocket, _ConnectionWebSocket_rMutex, _ConnectionWebSocket_wMutex, _ConnectionWebSocket_buffer, _ConnectionWebSocket_nextResolve, _ConnectionWebSocket_initWs, _ConnectionWebSocket_isConnecting, _ConnectionWebSocket_assertConnected, _ConnectionWebSocket_rejectRead;
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.ConnectionWebSocket = void 0;
39
37
  /**
@@ -62,118 +60,114 @@ const _1_utilities_js_1 = require("../1_utilities.js");
62
60
  const L = (0, _1_utilities_js_1.getLogger)("ConnectionWebSocket");
63
61
  const errConnectionNotOpen = new _0_errors_js_1.ConnectionError("Connection not open");
64
62
  class ConnectionWebSocket {
63
+ #url;
64
+ #webSocket;
65
+ #rMutex = new _1_utilities_js_1.Mutex();
66
+ #wMutex = new _1_utilities_js_1.Mutex();
67
+ #buffer = new Uint8Array();
68
+ #nextResolve = null;
69
+ stateChangeHandler;
65
70
  constructor(url) {
66
- _ConnectionWebSocket_instances.add(this);
67
- _ConnectionWebSocket_url.set(this, void 0);
68
- _ConnectionWebSocket_webSocket.set(this, void 0);
69
- _ConnectionWebSocket_rMutex.set(this, new _1_utilities_js_1.Mutex());
70
- _ConnectionWebSocket_wMutex.set(this, new _1_utilities_js_1.Mutex());
71
- _ConnectionWebSocket_buffer.set(this, new Uint8Array());
72
- _ConnectionWebSocket_nextResolve.set(this, null);
73
- Object.defineProperty(this, "stateChangeHandler", {
74
- enumerable: true,
75
- configurable: true,
76
- writable: true,
77
- value: void 0
71
+ this.#url = url;
72
+ }
73
+ #initWs() {
74
+ return new Promise((resolve, reject) => {
75
+ const webSocket = new dntShim.WebSocket(this.#url, "binary");
76
+ const mutex = new _1_utilities_js_1.Mutex();
77
+ webSocket.addEventListener("close", () => {
78
+ this.#rejectRead();
79
+ this.stateChangeHandler?.(false);
80
+ });
81
+ webSocket.addEventListener("open", () => {
82
+ this.stateChangeHandler?.(true);
83
+ resolve(webSocket);
84
+ L.debug("connected to", this.#url);
85
+ });
86
+ webSocket.addEventListener("message", async (e) => {
87
+ if (typeof e.data === "string") {
88
+ return;
89
+ }
90
+ const unlock = await mutex.lock();
91
+ const data = new Uint8Array(await new Blob([e.data].map((v) => v instanceof Blob || v instanceof Uint8Array ? v : v instanceof ArrayBuffer ? v : (0, _0_deps_js_1.unreachable)())).arrayBuffer());
92
+ this.#buffer = (0, _0_deps_js_1.concat)([this.#buffer, data]);
93
+ if (this.#nextResolve != null && this.#buffer.length >= this.#nextResolve[0]) {
94
+ this.#nextResolve[1].resolve();
95
+ this.#nextResolve = null;
96
+ }
97
+ unlock();
98
+ });
99
+ webSocket.addEventListener("error", (err) => {
100
+ if (this.#isConnecting) {
101
+ reject("message" in err ? new _0_errors_js_1.ConnectionError(err.message) : new _0_errors_js_1.ConnectionError("Connection failed"));
102
+ }
103
+ if (this.connected) {
104
+ L.error(err);
105
+ }
106
+ });
78
107
  });
79
- _ConnectionWebSocket_isConnecting.set(this, false);
80
- __classPrivateFieldSet(this, _ConnectionWebSocket_url, url, "f");
81
108
  }
82
109
  get connected() {
83
- return !!__classPrivateFieldGet(this, _ConnectionWebSocket_webSocket, "f") && __classPrivateFieldGet(this, _ConnectionWebSocket_webSocket, "f").readyState == dntShim.WebSocket.OPEN;
110
+ return !!this.#webSocket && this.#webSocket.readyState == dntShim.WebSocket.OPEN;
84
111
  }
112
+ #isConnecting = false;
85
113
  async open() {
86
- if (__classPrivateFieldGet(this, _ConnectionWebSocket_isConnecting, "f")) {
114
+ if (this.#isConnecting) {
87
115
  throw new _0_errors_js_1.ConnectionError("Already connecting");
88
116
  }
89
- __classPrivateFieldSet(this, _ConnectionWebSocket_isConnecting, true, "f");
117
+ this.#isConnecting = true;
90
118
  if (this.connected) {
91
119
  throw new _0_errors_js_1.ConnectionError("Already connected");
92
120
  }
93
121
  try {
94
- __classPrivateFieldSet(this, _ConnectionWebSocket_webSocket, await __classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_initWs).call(this), "f");
122
+ this.#webSocket = await this.#initWs();
95
123
  }
96
124
  finally {
97
- __classPrivateFieldSet(this, _ConnectionWebSocket_isConnecting, false, "f");
125
+ this.#isConnecting = false;
126
+ }
127
+ }
128
+ #assertConnected() {
129
+ if (!this.connected) {
130
+ throw errConnectionNotOpen;
98
131
  }
99
132
  }
100
133
  async read(p) {
101
- __classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
102
- const unlock = await __classPrivateFieldGet(this, _ConnectionWebSocket_rMutex, "f").lock();
134
+ this.#assertConnected();
135
+ const unlock = await this.#rMutex.lock();
103
136
  try {
104
- __classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
105
- if (__classPrivateFieldGet(this, _ConnectionWebSocket_buffer, "f").length < p.length) {
106
- await new Promise((resolve, reject) => __classPrivateFieldSet(this, _ConnectionWebSocket_nextResolve, [p.length, { resolve, reject }], "f"));
137
+ this.#assertConnected();
138
+ if (this.#buffer.length < p.length) {
139
+ await new Promise((resolve, reject) => this.#nextResolve = [p.length, { resolve, reject }]);
107
140
  }
108
- const slice = __classPrivateFieldGet(this, _ConnectionWebSocket_buffer, "f").slice(0, p.length);
141
+ const slice = this.#buffer.slice(0, p.length);
109
142
  p.set(slice);
110
- __classPrivateFieldSet(this, _ConnectionWebSocket_buffer, __classPrivateFieldGet(this, _ConnectionWebSocket_buffer, "f").slice(slice.length), "f");
143
+ this.#buffer = this.#buffer.slice(slice.length);
111
144
  }
112
145
  finally {
113
146
  unlock();
114
147
  }
115
148
  }
116
149
  async write(p) {
117
- __classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
118
- const unlock = await __classPrivateFieldGet(this, _ConnectionWebSocket_wMutex, "f").lock();
150
+ this.#assertConnected();
151
+ const unlock = await this.#wMutex.lock();
119
152
  try {
120
- __classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
121
- __classPrivateFieldGet(this, _ConnectionWebSocket_webSocket, "f").send(p);
153
+ this.#assertConnected();
154
+ this.#webSocket.send(p);
122
155
  }
123
156
  finally {
124
157
  unlock();
125
158
  }
126
159
  }
160
+ #rejectRead() {
161
+ if (this.#nextResolve != null) {
162
+ this.#nextResolve[1].reject(errConnectionNotOpen);
163
+ this.#nextResolve = null;
164
+ }
165
+ }
127
166
  close() {
128
- __classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_assertConnected).call(this);
129
- __classPrivateFieldGet(this, _ConnectionWebSocket_webSocket, "f").close(1000, "method");
130
- __classPrivateFieldSet(this, _ConnectionWebSocket_webSocket, undefined, "f");
131
- __classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_rejectRead).call(this);
167
+ this.#assertConnected();
168
+ this.#webSocket.close(1000, "method");
169
+ this.#webSocket = undefined;
170
+ this.#rejectRead();
132
171
  }
133
172
  }
134
173
  exports.ConnectionWebSocket = ConnectionWebSocket;
135
- _ConnectionWebSocket_url = new WeakMap(), _ConnectionWebSocket_webSocket = new WeakMap(), _ConnectionWebSocket_rMutex = new WeakMap(), _ConnectionWebSocket_wMutex = new WeakMap(), _ConnectionWebSocket_buffer = new WeakMap(), _ConnectionWebSocket_nextResolve = new WeakMap(), _ConnectionWebSocket_isConnecting = new WeakMap(), _ConnectionWebSocket_instances = new WeakSet(), _ConnectionWebSocket_initWs = function _ConnectionWebSocket_initWs() {
136
- return new Promise((resolve, reject) => {
137
- const webSocket = new dntShim.WebSocket(__classPrivateFieldGet(this, _ConnectionWebSocket_url, "f"), "binary");
138
- const mutex = new _1_utilities_js_1.Mutex();
139
- webSocket.addEventListener("close", () => {
140
- __classPrivateFieldGet(this, _ConnectionWebSocket_instances, "m", _ConnectionWebSocket_rejectRead).call(this);
141
- this.stateChangeHandler?.(false);
142
- });
143
- webSocket.addEventListener("open", () => {
144
- this.stateChangeHandler?.(true);
145
- resolve(webSocket);
146
- L.debug("connected to", __classPrivateFieldGet(this, _ConnectionWebSocket_url, "f"));
147
- });
148
- webSocket.addEventListener("message", async (e) => {
149
- if (typeof e.data === "string") {
150
- return;
151
- }
152
- const unlock = await mutex.lock();
153
- const data = new Uint8Array(await new Blob([e.data].map((v) => v instanceof Blob || v instanceof Uint8Array ? v : v instanceof ArrayBuffer ? v : (0, _0_deps_js_1.unreachable)())).arrayBuffer());
154
- __classPrivateFieldSet(this, _ConnectionWebSocket_buffer, (0, _0_deps_js_1.concat)([__classPrivateFieldGet(this, _ConnectionWebSocket_buffer, "f"), data]), "f");
155
- if (__classPrivateFieldGet(this, _ConnectionWebSocket_nextResolve, "f") != null && __classPrivateFieldGet(this, _ConnectionWebSocket_buffer, "f").length >= __classPrivateFieldGet(this, _ConnectionWebSocket_nextResolve, "f")[0]) {
156
- __classPrivateFieldGet(this, _ConnectionWebSocket_nextResolve, "f")[1].resolve();
157
- __classPrivateFieldSet(this, _ConnectionWebSocket_nextResolve, null, "f");
158
- }
159
- unlock();
160
- });
161
- webSocket.addEventListener("error", (err) => {
162
- if (__classPrivateFieldGet(this, _ConnectionWebSocket_isConnecting, "f")) {
163
- reject("message" in err ? new _0_errors_js_1.ConnectionError(err.message) : new _0_errors_js_1.ConnectionError("Connection failed"));
164
- }
165
- if (this.connected) {
166
- L.error(err);
167
- }
168
- });
169
- });
170
- }, _ConnectionWebSocket_assertConnected = function _ConnectionWebSocket_assertConnected() {
171
- if (!this.connected) {
172
- throw errConnectionNotOpen;
173
- }
174
- }, _ConnectionWebSocket_rejectRead = function _ConnectionWebSocket_rejectRead() {
175
- if (__classPrivateFieldGet(this, _ConnectionWebSocket_nextResolve, "f") != null) {
176
- __classPrivateFieldGet(this, _ConnectionWebSocket_nextResolve, "f")[1].reject(errConnectionNotOpen);
177
- __classPrivateFieldSet(this, _ConnectionWebSocket_nextResolve, null, "f");
178
- }
179
- };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var Module = (() => {
4
- var _scriptName = require("url").pathToFileURL(__filename).href;
4
+ var _scriptName = globalThis[Symbol.for("import-meta-ponyfill-commonjs")](require, module).url;
5
5
  return (function (moduleArg = {}) {
6
6
  var moduleRtn;
7
7
  var Module = moduleArg;
@@ -119,16 +119,8 @@ var Module = (() => {
119
119
  }
120
120
  } wasmBinaryFile ??= findWasmBinary(); instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult).catch(readyPromiseReject); return {}; }
121
121
  class ExitStatus {
122
- constructor(status) {
123
- Object.defineProperty(this, "name", {
124
- enumerable: true,
125
- configurable: true,
126
- writable: true,
127
- value: "ExitStatus"
128
- });
129
- this.message = `Program terminated with exit(${status})`;
130
- this.status = status;
131
- }
122
+ name = "ExitStatus";
123
+ constructor(status) { this.message = `Program terminated with exit(${status})`; this.status = status; }
132
124
  }
133
125
  var callRuntimeCallbacks = callbacks => { while (callbacks.length > 0) {
134
126
  callbacks.shift()(Module);
@@ -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
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.equal = equal;
27
37
  // Copyright 2018-2025 the Deno authors. MIT license.
@@ -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.delay = delay;
29
39
  /** Options for {@linkcode delay}. */
@@ -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 __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
5
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
6
- 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");
7
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
8
- };
9
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
10
- if (kind === "m") throw new TypeError("Private method is not writable");
11
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
12
- 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");
13
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
14
- };
15
- var _MuxAsyncIterator_instances, _MuxAsyncIterator_iteratorCount, _MuxAsyncIterator_yields, _MuxAsyncIterator_throws, _MuxAsyncIterator_signal, _MuxAsyncIterator_callIteratorNext;
16
4
  Object.defineProperty(exports, "__esModule", { value: true });
17
5
  exports.MuxAsyncIterator = void 0;
18
6
  /**
@@ -50,14 +38,11 @@ exports.MuxAsyncIterator = void 0;
50
38
  * @typeParam T The type of the provided async iterables and generated async iterable.
51
39
  */
52
40
  class MuxAsyncIterator {
53
- constructor() {
54
- _MuxAsyncIterator_instances.add(this);
55
- _MuxAsyncIterator_iteratorCount.set(this, 0);
56
- _MuxAsyncIterator_yields.set(this, []);
57
- // deno-lint-ignore no-explicit-any
58
- _MuxAsyncIterator_throws.set(this, []);
59
- _MuxAsyncIterator_signal.set(this, Promise.withResolvers());
60
- }
41
+ #iteratorCount = 0;
42
+ #yields = [];
43
+ // deno-lint-ignore no-explicit-any
44
+ #throws = [];
45
+ #signal = Promise.withResolvers();
61
46
  /**
62
47
  * Add an async iterable to the stream.
63
48
  *
@@ -83,9 +68,23 @@ class MuxAsyncIterator {
83
68
  * ```
84
69
  */
85
70
  add(iterable) {
86
- var _a;
87
- __classPrivateFieldSet(this, _MuxAsyncIterator_iteratorCount, (_a = __classPrivateFieldGet(this, _MuxAsyncIterator_iteratorCount, "f"), ++_a), "f");
88
- __classPrivateFieldGet(this, _MuxAsyncIterator_instances, "m", _MuxAsyncIterator_callIteratorNext).call(this, iterable[Symbol.asyncIterator]());
71
+ ++this.#iteratorCount;
72
+ this.#callIteratorNext(iterable[Symbol.asyncIterator]());
73
+ }
74
+ async #callIteratorNext(iterator) {
75
+ try {
76
+ const { value, done } = await iterator.next();
77
+ if (done) {
78
+ --this.#iteratorCount;
79
+ }
80
+ else {
81
+ this.#yields.push({ iterator, value });
82
+ }
83
+ }
84
+ catch (e) {
85
+ this.#throws.push(e);
86
+ }
87
+ this.#signal.resolve();
89
88
  }
90
89
  /**
91
90
  * Returns an async iterator of the stream.
@@ -111,22 +110,22 @@ class MuxAsyncIterator {
111
110
  * ```
112
111
  */
113
112
  async *iterate() {
114
- while (__classPrivateFieldGet(this, _MuxAsyncIterator_iteratorCount, "f") > 0) {
113
+ while (this.#iteratorCount > 0) {
115
114
  // Sleep until any of the wrapped iterators yields.
116
- await __classPrivateFieldGet(this, _MuxAsyncIterator_signal, "f").promise;
115
+ await this.#signal.promise;
117
116
  // Note that while we're looping over `yields`, new items may be added.
118
- for (const { iterator, value } of __classPrivateFieldGet(this, _MuxAsyncIterator_yields, "f")) {
117
+ for (const { iterator, value } of this.#yields) {
119
118
  yield value;
120
- __classPrivateFieldGet(this, _MuxAsyncIterator_instances, "m", _MuxAsyncIterator_callIteratorNext).call(this, iterator);
119
+ this.#callIteratorNext(iterator);
121
120
  }
122
- if (__classPrivateFieldGet(this, _MuxAsyncIterator_throws, "f").length) {
123
- for (const e of __classPrivateFieldGet(this, _MuxAsyncIterator_throws, "f")) {
121
+ if (this.#throws.length) {
122
+ for (const e of this.#throws) {
124
123
  throw e;
125
124
  }
126
125
  }
127
126
  // Clear the `yields` list and reset the `signal` promise.
128
- __classPrivateFieldGet(this, _MuxAsyncIterator_yields, "f").length = 0;
129
- __classPrivateFieldSet(this, _MuxAsyncIterator_signal, Promise.withResolvers(), "f");
127
+ this.#yields.length = 0;
128
+ this.#signal = Promise.withResolvers();
130
129
  }
131
130
  }
132
131
  /**
@@ -152,22 +151,7 @@ class MuxAsyncIterator {
152
151
  * assertEquals(result, [1, 2, 3]);
153
152
  * ```
154
153
  */
155
- [(_MuxAsyncIterator_iteratorCount = new WeakMap(), _MuxAsyncIterator_yields = new WeakMap(), _MuxAsyncIterator_throws = new WeakMap(), _MuxAsyncIterator_signal = new WeakMap(), _MuxAsyncIterator_instances = new WeakSet(), _MuxAsyncIterator_callIteratorNext = async function _MuxAsyncIterator_callIteratorNext(iterator) {
156
- var _a;
157
- try {
158
- const { value, done } = await iterator.next();
159
- if (done) {
160
- __classPrivateFieldSet(this, _MuxAsyncIterator_iteratorCount, (_a = __classPrivateFieldGet(this, _MuxAsyncIterator_iteratorCount, "f"), --_a), "f");
161
- }
162
- else {
163
- __classPrivateFieldGet(this, _MuxAsyncIterator_yields, "f").push({ iterator, value });
164
- }
165
- }
166
- catch (e) {
167
- __classPrivateFieldGet(this, _MuxAsyncIterator_throws, "f").push(e);
168
- }
169
- __classPrivateFieldGet(this, _MuxAsyncIterator_signal, "f").resolve();
170
- }, Symbol.asyncIterator)]() {
154
+ [Symbol.asyncIterator]() {
171
155
  return this.iterate();
172
156
  }
173
157
  }