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