@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 +1 @@
1
- {"version":3,"file":"1_utilities_test.d.ts","sourceRoot":"","sources":["../../src/storage/1_utilities_test.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"1_utilities_test.d.ts","sourceRoot":"","sources":["../../src/storage/1_utilities_test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,2BAA2B,CAAC"}
@@ -18,47 +18,29 @@
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 _StorageIndexedDB_instances, _StorageIndexedDB_name, _StorageIndexedDB_id, _StorageIndexedDB_supportsFiles, _StorageIndexedDB_fixKey;
33
21
  Object.defineProperty(exports, "__esModule", { value: true });
34
22
  exports.StorageIndexedDB = void 0;
35
23
  const _1_utilities_js_1 = require("./1_utilities.js");
36
24
  const VERSION = 1;
37
25
  const KV_OBJECT_STORE = "kv";
38
26
  class StorageIndexedDB {
27
+ database = null;
28
+ #name;
29
+ #id = null;
30
+ #supportsFiles;
39
31
  constructor(name, params) {
40
- _StorageIndexedDB_instances.add(this);
41
- Object.defineProperty(this, "database", {
42
- enumerable: true,
43
- configurable: true,
44
- writable: true,
45
- value: null
46
- });
47
- _StorageIndexedDB_name.set(this, void 0);
48
- _StorageIndexedDB_id.set(this, null);
49
- _StorageIndexedDB_supportsFiles.set(this, void 0);
50
32
  if (typeof indexedDB == "undefined") {
51
33
  throw new Error("Unavailable in current environment");
52
34
  }
53
- __classPrivateFieldSet(this, _StorageIndexedDB_name, name, "f");
54
- __classPrivateFieldSet(this, _StorageIndexedDB_supportsFiles, params?.storeFiles ?? true, "f");
35
+ this.#name = name;
36
+ this.#supportsFiles = params?.storeFiles ?? true;
55
37
  }
56
38
  get name() {
57
- return __classPrivateFieldGet(this, _StorageIndexedDB_name, "f");
39
+ return this.#name;
58
40
  }
59
41
  branch(id) {
60
- const storage = new StorageIndexedDB(this.name, { storeFiles: __classPrivateFieldGet(this, _StorageIndexedDB_supportsFiles, "f") });
61
- __classPrivateFieldSet(storage, _StorageIndexedDB_id, id, "f");
42
+ const storage = new StorageIndexedDB(this.name, { storeFiles: this.#supportsFiles });
43
+ storage.#id = id;
62
44
  return storage;
63
45
  }
64
46
  initialize() {
@@ -76,13 +58,21 @@ class StorageIndexedDB {
76
58
  });
77
59
  }
78
60
  get supportsFiles() {
79
- return __classPrivateFieldGet(this, _StorageIndexedDB_supportsFiles, "f");
61
+ return this.#supportsFiles;
80
62
  }
81
63
  get mustSerialize() {
82
64
  return true;
83
65
  }
66
+ #fixKey(key) {
67
+ if (this.#id !== null) {
68
+ return ["__S" + this.#id, ...key];
69
+ }
70
+ else {
71
+ return key;
72
+ }
73
+ }
84
74
  set(k, v, tx_) {
85
- k = __classPrivateFieldGet(this, _StorageIndexedDB_instances, "m", _StorageIndexedDB_fixKey).call(this, k);
75
+ k = this.#fixKey(k);
86
76
  if (!this.database) {
87
77
  throw new Error("Not initialized");
88
78
  }
@@ -106,7 +96,7 @@ class StorageIndexedDB {
106
96
  }
107
97
  get(k, tx_, fix = true) {
108
98
  if (fix) {
109
- k = __classPrivateFieldGet(this, _StorageIndexedDB_instances, "m", _StorageIndexedDB_fixKey).call(this, k);
99
+ k = this.#fixKey(k);
110
100
  }
111
101
  if (!this.database) {
112
102
  throw new Error("Not initialized");
@@ -123,14 +113,14 @@ class StorageIndexedDB {
123
113
  });
124
114
  }
125
115
  async *getMany(filter, params, tx_) {
126
- if ("prefix" in filter && __classPrivateFieldGet(this, _StorageIndexedDB_id, "f") !== null) {
127
- filter.prefix = __classPrivateFieldGet(this, _StorageIndexedDB_instances, "m", _StorageIndexedDB_fixKey).call(this, filter.prefix);
116
+ if ("prefix" in filter && this.#id !== null) {
117
+ filter.prefix = this.#fixKey(filter.prefix);
128
118
  }
129
- if ("start" in filter && __classPrivateFieldGet(this, _StorageIndexedDB_id, "f") !== null) {
130
- filter.start = __classPrivateFieldGet(this, _StorageIndexedDB_instances, "m", _StorageIndexedDB_fixKey).call(this, filter.start);
119
+ if ("start" in filter && this.#id !== null) {
120
+ filter.start = this.#fixKey(filter.start);
131
121
  }
132
- if ("end" in filter && __classPrivateFieldGet(this, _StorageIndexedDB_id, "f") !== null) {
133
- filter.end = __classPrivateFieldGet(this, _StorageIndexedDB_instances, "m", _StorageIndexedDB_fixKey).call(this, filter.end);
122
+ if ("end" in filter && this.#id !== null) {
123
+ filter.end = this.#fixKey(filter.end);
134
124
  }
135
125
  if (!this.database) {
136
126
  throw new Error("Not initialized");
@@ -181,11 +171,3 @@ class StorageIndexedDB {
181
171
  }
182
172
  }
183
173
  exports.StorageIndexedDB = StorageIndexedDB;
184
- _StorageIndexedDB_name = new WeakMap(), _StorageIndexedDB_id = new WeakMap(), _StorageIndexedDB_supportsFiles = new WeakMap(), _StorageIndexedDB_instances = new WeakSet(), _StorageIndexedDB_fixKey = function _StorageIndexedDB_fixKey(key) {
185
- if (__classPrivateFieldGet(this, _StorageIndexedDB_id, "f") !== null) {
186
- return ["__S" + __classPrivateFieldGet(this, _StorageIndexedDB_id, "f"), ...key];
187
- }
188
- else {
189
- return key;
190
- }
191
- };
@@ -18,36 +18,24 @@
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 _StorageLocalStorage_prefix, _StorageLocalStorage_path, _StorageLocalStorage_storage;
33
21
  Object.defineProperty(exports, "__esModule", { value: true });
34
22
  exports.StorageLocalStorage = void 0;
35
23
  const node_localstorage_1 = require("node-localstorage");
36
24
  const _1_utilities_js_1 = require("./1_utilities.js");
37
25
  class StorageLocalStorage {
26
+ #prefix;
27
+ #path;
28
+ #storage;
38
29
  constructor(path) {
39
- _StorageLocalStorage_prefix.set(this, void 0);
40
- _StorageLocalStorage_path.set(this, void 0);
41
- _StorageLocalStorage_storage.set(this, void 0);
42
- __classPrivateFieldSet(this, _StorageLocalStorage_prefix, "main", "f");
43
- __classPrivateFieldSet(this, _StorageLocalStorage_storage, new node_localstorage_1.LocalStorage(__classPrivateFieldSet(this, _StorageLocalStorage_path, path, "f")), "f");
30
+ this.#prefix = "main";
31
+ this.#storage = new node_localstorage_1.LocalStorage(this.#path = path);
44
32
  }
45
33
  get prefix() {
46
- return __classPrivateFieldGet(this, _StorageLocalStorage_prefix, "f");
34
+ return this.#prefix;
47
35
  }
48
36
  branch(id) {
49
- const storage = new StorageLocalStorage(__classPrivateFieldGet(this, _StorageLocalStorage_path, "f"));
50
- __classPrivateFieldSet(storage, _StorageLocalStorage_prefix, this.prefix + "S__" + id, "f");
37
+ const storage = new StorageLocalStorage(this.#path);
38
+ storage.#prefix = this.prefix + "S__" + id;
51
39
  return storage;
52
40
  }
53
41
  initialize() {
@@ -60,7 +48,7 @@ class StorageLocalStorage {
60
48
  }
61
49
  get(key_) {
62
50
  const key = this.prefix + (0, _1_utilities_js_1.toString)(key_);
63
- const value = __classPrivateFieldGet(this, _StorageLocalStorage_storage, "f").getItem(key);
51
+ const value = this.#storage.getItem(key);
64
52
  if (value != null) {
65
53
  return (0, _1_utilities_js_1.fromString)(value);
66
54
  }
@@ -69,7 +57,7 @@ class StorageLocalStorage {
69
57
  }
70
58
  }
71
59
  *getMany(filter, params) {
72
- let entries = Object.entries(__classPrivateFieldGet(this, _StorageLocalStorage_storage, "f")).sort(([a], [b]) => a.localeCompare(b));
60
+ let entries = Object.entries(this.#storage).sort(([a], [b]) => a.localeCompare(b));
73
61
  if (params?.reverse) {
74
62
  entries.reverse();
75
63
  }
@@ -101,10 +89,10 @@ class StorageLocalStorage {
101
89
  set(key_, value) {
102
90
  const key = this.prefix + (0, _1_utilities_js_1.toString)(key_);
103
91
  if (value != null) {
104
- __classPrivateFieldGet(this, _StorageLocalStorage_storage, "f").setItem(key, (0, _1_utilities_js_1.toString)(value));
92
+ this.#storage.setItem(key, (0, _1_utilities_js_1.toString)(value));
105
93
  }
106
94
  else {
107
- __classPrivateFieldGet(this, _StorageLocalStorage_storage, "f").removeItem(key);
95
+ this.#storage.removeItem(key);
108
96
  }
109
97
  }
110
98
  incr(key, by) {
@@ -112,4 +100,3 @@ class StorageLocalStorage {
112
100
  }
113
101
  }
114
102
  exports.StorageLocalStorage = StorageLocalStorage;
115
- _StorageLocalStorage_prefix = new WeakMap(), _StorageLocalStorage_path = new WeakMap(), _StorageLocalStorage_storage = new WeakMap();
@@ -18,51 +18,51 @@
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 _StorageMemory_instances, _StorageMemory_id, _StorageMemory_fixKey, _StorageMemory_getEntries;
33
21
  Object.defineProperty(exports, "__esModule", { value: true });
34
22
  exports.StorageMemory = void 0;
35
23
  const _1_utilities_js_1 = require("./1_utilities.js");
36
24
  class StorageMemory {
25
+ map = new Map();
26
+ #id = null;
37
27
  constructor() {
38
- _StorageMemory_instances.add(this);
39
- Object.defineProperty(this, "map", {
40
- enumerable: true,
41
- configurable: true,
42
- writable: true,
43
- value: new Map()
44
- });
45
- _StorageMemory_id.set(this, null);
46
28
  }
47
29
  get mustSerialize() {
48
30
  return false;
49
31
  }
50
32
  initialize() {
51
33
  }
34
+ #fixKey(key) {
35
+ if (this.#id !== null) {
36
+ return ["__S" + this.#id, ...key];
37
+ }
38
+ else {
39
+ return key;
40
+ }
41
+ }
52
42
  branch(id) {
53
43
  const storage = new StorageMemory();
54
- __classPrivateFieldSet(storage, _StorageMemory_id, id, "f");
44
+ storage.#id = id;
55
45
  return storage;
56
46
  }
57
47
  get supportsFiles() {
58
48
  return false;
59
49
  }
60
50
  get(key) {
61
- key = __classPrivateFieldGet(this, _StorageMemory_instances, "m", _StorageMemory_fixKey).call(this, key);
51
+ key = this.#fixKey(key);
62
52
  return this.map.get((0, _1_utilities_js_1.toString)(key)) ?? null;
63
53
  }
54
+ #getEntries() {
55
+ const entries = new Array();
56
+ for (const entry of this.map.entries()) {
57
+ if (this.#id !== null && !entry[0].startsWith("__S" + this.#id)) {
58
+ continue;
59
+ }
60
+ entries.push(entry);
61
+ }
62
+ return entries;
63
+ }
64
64
  *getMany(filter, params) {
65
- let entries = __classPrivateFieldGet(this, _StorageMemory_instances, "m", _StorageMemory_getEntries).call(this);
65
+ let entries = this.#getEntries();
66
66
  if (params?.reverse) {
67
67
  entries.reverse();
68
68
  }
@@ -89,7 +89,7 @@ class StorageMemory {
89
89
  }
90
90
  }
91
91
  set(key_, value) {
92
- key_ = __classPrivateFieldGet(this, _StorageMemory_instances, "m", _StorageMemory_fixKey).call(this, key_);
92
+ key_ = this.#fixKey(key_);
93
93
  const key = (0, _1_utilities_js_1.toString)(key_);
94
94
  if (value != null) {
95
95
  this.map.set(key, value);
@@ -103,20 +103,3 @@ class StorageMemory {
103
103
  }
104
104
  }
105
105
  exports.StorageMemory = StorageMemory;
106
- _StorageMemory_id = new WeakMap(), _StorageMemory_instances = new WeakSet(), _StorageMemory_fixKey = function _StorageMemory_fixKey(key) {
107
- if (__classPrivateFieldGet(this, _StorageMemory_id, "f") !== null) {
108
- return ["__S" + __classPrivateFieldGet(this, _StorageMemory_id, "f"), ...key];
109
- }
110
- else {
111
- return key;
112
- }
113
- }, _StorageMemory_getEntries = function _StorageMemory_getEntries() {
114
- const entries = new Array();
115
- for (const entry of this.map.entries()) {
116
- if (__classPrivateFieldGet(this, _StorageMemory_id, "f") !== null && !entry[0].startsWith("__S" + __classPrivateFieldGet(this, _StorageMemory_id, "f"))) {
117
- continue;
118
- }
119
- entries.push(entry);
120
- }
121
- return entries;
122
- };
@@ -18,37 +18,25 @@
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 _StorageSessionStorage_prefix;
33
21
  Object.defineProperty(exports, "__esModule", { value: true });
34
22
  exports.StorageSessionStorage = void 0;
35
23
  const _1_utilities_js_1 = require("./1_utilities.js");
36
24
  class StorageSessionStorage {
25
+ #prefix;
37
26
  constructor(prefix) {
38
- _StorageSessionStorage_prefix.set(this, void 0);
39
27
  if (typeof sessionStorage === "undefined") {
40
28
  throw new Error("Unavailable in current environment");
41
29
  }
42
30
  if (prefix.length <= 0) {
43
31
  throw new Error("Empty prefix");
44
32
  }
45
- __classPrivateFieldSet(this, _StorageSessionStorage_prefix, prefix, "f");
33
+ this.#prefix = prefix;
46
34
  }
47
35
  get mustSerialize() {
48
36
  return true;
49
37
  }
50
38
  get prefix() {
51
- return __classPrivateFieldGet(this, _StorageSessionStorage_prefix, "f");
39
+ return this.#prefix;
52
40
  }
53
41
  branch(id) {
54
42
  return new StorageSessionStorage(this.prefix + "S__" + id);
@@ -112,4 +100,3 @@ class StorageSessionStorage {
112
100
  }
113
101
  }
114
102
  exports.StorageSessionStorage = StorageSessionStorage;
115
- _StorageSessionStorage_prefix = new WeakMap();
@@ -1 +1 @@
1
- {"version":3,"file":"0_utilities_test.d.ts","sourceRoot":"","sources":["../../src/tl/0_utilities_test.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"0_utilities_test.d.ts","sourceRoot":"","sources":["../../src/tl/0_utilities_test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,2BAA2B,CAAC"}
@@ -19,12 +19,6 @@
19
19
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
20
  */
21
21
  // deno-lint-ignore-file no-explicit-any
22
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
23
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
24
- 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");
25
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
26
- };
27
- var _TLReader_instances, _TLReader_deserializeEnum, _TLReader_deserializeType, _TLReader_deserializeVector, _TLReader_deserializePrimitive;
28
22
  Object.defineProperty(exports, "__esModule", { value: true });
29
23
  exports.TLReader = exports.TLError = void 0;
30
24
  const _1_utilities_js_1 = require("../1_utilities.js");
@@ -33,14 +27,9 @@ class TLError extends Error {
33
27
  }
34
28
  exports.TLError = TLError;
35
29
  class TLReader {
30
+ _buffer;
36
31
  constructor(_buffer) {
37
- _TLReader_instances.add(this);
38
- Object.defineProperty(this, "_buffer", {
39
- enumerable: true,
40
- configurable: true,
41
- writable: true,
42
- value: _buffer
43
- });
32
+ this._buffer = _buffer;
44
33
  }
45
34
  get buffer() {
46
35
  return this._buffer;
@@ -111,7 +100,7 @@ class TLReader {
111
100
  if ((0, _0_utilities_js_1.isOptionalParam)(name)) {
112
101
  name = (0, _0_utilities_js_1.getOptionalParamInnerType)(name);
113
102
  }
114
- const primitive = __classPrivateFieldGet(this, _TLReader_instances, "m", _TLReader_deserializePrimitive).call(this, name);
103
+ const primitive = this.#deserializePrimitive(name);
115
104
  if (primitive !== undefined) {
116
105
  return primitive;
117
106
  }
@@ -125,94 +114,97 @@ class TLReader {
125
114
  return await this.readType(typeName, schema);
126
115
  }
127
116
  if (id == _0_utilities_js_1.VECTOR) {
128
- return await __classPrivateFieldGet(this, _TLReader_instances, "m", _TLReader_deserializeVector).call(this, name, schema);
117
+ return await this.#deserializeVector(name, schema);
129
118
  }
130
119
  const definition = schema.definitions[name];
131
120
  if (definition) {
132
- return await __classPrivateFieldGet(this, _TLReader_instances, "m", _TLReader_deserializeType).call(this, name, definition, id, schema);
121
+ return await this.#deserializeType(name, definition, id, schema);
133
122
  }
134
- const deserializedEnum = await __classPrivateFieldGet(this, _TLReader_instances, "m", _TLReader_deserializeEnum).call(this, name, id, schema);
123
+ const deserializedEnum = await this.#deserializeEnum(name, id, schema);
135
124
  if (deserializedEnum !== undefined) {
136
125
  return deserializedEnum;
137
126
  }
138
127
  throw new TLError(`Unknown type: ${name} ID ${id}`);
139
128
  }
140
- }
141
- exports.TLReader = TLReader;
142
- _TLReader_instances = new WeakSet(), _TLReader_deserializeEnum = async function _TLReader_deserializeEnum(type, id, schema) {
143
- const name = schema.identifierToName[id];
144
- if (!name) {
145
- return;
146
- }
147
- const definition = schema.definitions[name];
148
- if (definition[2] != type) {
149
- return;
150
- }
151
- return await __classPrivateFieldGet(this, _TLReader_instances, "m", _TLReader_deserializeType).call(this, name, definition, id, schema);
152
- }, _TLReader_deserializeType = async function _TLReader_deserializeType(type, desc, id, schema) {
153
- if (desc[0] != id) {
154
- throw new TLError(`Expected constructor ${desc[0].toString(16)} but got ${id}`);
155
- }
156
- const type_ = { _: type };
157
- const flagFields = {};
158
- for (const [name, type] of desc[1]) {
159
- if ((0, _0_utilities_js_1.isOptionalParam)(type)) {
160
- const { flagField, bitIndex } = (0, _0_utilities_js_1.analyzeOptionalParam)(type);
161
- const bits = flagFields[flagField];
162
- if ((bits & (1 << bitIndex)) == 0) {
129
+ async #deserializeEnum(type, id, schema) {
130
+ const name = schema.identifierToName[id];
131
+ if (!name) {
132
+ return;
133
+ }
134
+ const definition = schema.definitions[name];
135
+ if (definition[2] != type) {
136
+ return;
137
+ }
138
+ return await this.#deserializeType(name, definition, id, schema);
139
+ }
140
+ async #deserializeType(type, desc, id, schema) {
141
+ if (desc[0] != id) {
142
+ throw new TLError(`Expected constructor ${desc[0].toString(16)} but got ${id}`);
143
+ }
144
+ const type_ = { _: type };
145
+ const flagFields = {};
146
+ for (const [name, type] of desc[1]) {
147
+ if ((0, _0_utilities_js_1.isOptionalParam)(type)) {
148
+ const { flagField, bitIndex } = (0, _0_utilities_js_1.analyzeOptionalParam)(type);
149
+ const bits = flagFields[flagField];
150
+ if ((bits & (1 << bitIndex)) == 0) {
151
+ continue;
152
+ }
153
+ }
154
+ if (type == "#") {
155
+ flagFields[name] = this.readInt32();
163
156
  continue;
164
157
  }
158
+ const value = await this.readType(type, schema);
159
+ if (typeof value !== "boolean" || value) {
160
+ type_[name] = value;
161
+ }
162
+ }
163
+ return type_;
164
+ }
165
+ async #deserializeVector(type, schema) {
166
+ const itemType = (0, _0_utilities_js_1.getVectorItemType)(type);
167
+ if (!itemType) {
168
+ throw new TLError(`Expected Vector but received ${type}`);
169
+ }
170
+ const size = this.readInt32();
171
+ const array = new Array();
172
+ for (let i = 0; i < size; ++i) {
173
+ array.push(await this.readType(itemType, schema));
165
174
  }
166
- if (type == "#") {
167
- flagFields[name] = this.readInt32();
168
- continue;
169
- }
170
- const value = await this.readType(type, schema);
171
- if (typeof value !== "boolean" || value) {
172
- type_[name] = value;
173
- }
174
- }
175
- return type_;
176
- }, _TLReader_deserializeVector = async function _TLReader_deserializeVector(type, schema) {
177
- const itemType = (0, _0_utilities_js_1.getVectorItemType)(type);
178
- if (!itemType) {
179
- throw new TLError(`Expected Vector but received ${type}`);
180
- }
181
- const size = this.readInt32();
182
- const array = new Array();
183
- for (let i = 0; i < size; ++i) {
184
- array.push(await this.readType(itemType, schema));
185
- }
186
- return array;
187
- }, _TLReader_deserializePrimitive = function _TLReader_deserializePrimitive(type) {
188
- switch (type) {
189
- case "bytes":
190
- return this.readBytes();
191
- case "int128":
192
- return this.readInt128();
193
- case "int256":
194
- return this.readInt256();
195
- case "double":
196
- return this.readDouble();
197
- case "long":
198
- return this.readInt64();
199
- case "true":
200
- return true;
201
- case "int":
202
- return this.readInt32();
203
- case "Bool": {
204
- const id = this.readInt32(false);
205
- if (id == _0_utilities_js_1.BOOL_TRUE) {
175
+ return array;
176
+ }
177
+ #deserializePrimitive(type) {
178
+ switch (type) {
179
+ case "bytes":
180
+ return this.readBytes();
181
+ case "int128":
182
+ return this.readInt128();
183
+ case "int256":
184
+ return this.readInt256();
185
+ case "double":
186
+ return this.readDouble();
187
+ case "long":
188
+ return this.readInt64();
189
+ case "true":
206
190
  return true;
191
+ case "int":
192
+ return this.readInt32();
193
+ case "Bool": {
194
+ const id = this.readInt32(false);
195
+ if (id == _0_utilities_js_1.BOOL_TRUE) {
196
+ return true;
197
+ }
198
+ else if (id == _0_utilities_js_1.BOOL_FALSE) {
199
+ return false;
200
+ }
201
+ else {
202
+ throw new TLError(`Expected boolTrue or boolFalse but got ${id}`);
203
+ }
207
204
  }
208
- else if (id == _0_utilities_js_1.BOOL_FALSE) {
209
- return false;
210
- }
211
- else {
212
- throw new TLError(`Expected boolTrue or boolFalse but got ${id}`);
213
- }
205
+ case "string":
206
+ return this.readString();
214
207
  }
215
- case "string":
216
- return this.readString();
217
208
  }
218
- };
209
+ }
210
+ exports.TLReader = TLReader;
@@ -1 +1 @@
1
- {"version":3,"file":"1_tl_reader_test.d.ts","sourceRoot":"","sources":["../../src/tl/1_tl_reader_test.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"1_tl_reader_test.d.ts","sourceRoot":"","sources":["../../src/tl/1_tl_reader_test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,2BAA2B,CAAC"}