@mtkruto/browser 0.119.0 → 0.120.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 (128) hide show
  1. package/README.md +1 -1
  2. package/esm/0_errors.d.ts.map +1 -1
  3. package/esm/0_errors.js +9 -31
  4. package/esm/3_errors.js +2 -12
  5. package/esm/4_errors.js +2 -12
  6. package/esm/_dnt.polyfills.d.ts +0 -99
  7. package/esm/_dnt.polyfills.d.ts.map +1 -1
  8. package/esm/_dnt.polyfills.js +1 -127
  9. package/esm/client/0_abortable_loop.js +26 -39
  10. package/esm/client/0_storage_operations.js +179 -218
  11. package/esm/client/1_client_plain.js +4 -22
  12. package/esm/client/2_account_manager.js +140 -149
  13. package/esm/client/2_bot_info_manager.js +26 -38
  14. package/esm/client/2_business_connection_manager.js +10 -23
  15. package/esm/client/2_client_encrypted.js +198 -215
  16. package/esm/client/2_file_manager.js +255 -262
  17. package/esm/client/2_network_statistics_manager.js +31 -44
  18. package/esm/client/2_payment_manager.js +7 -20
  19. package/esm/client/2_reaction_manager.js +7 -20
  20. package/esm/client/2_translations_manager.js +101 -111
  21. package/esm/client/2_update_manager.js +750 -745
  22. package/esm/client/3_client_encrypted_pool.js +10 -26
  23. package/esm/client/3_message_manager.js +503 -508
  24. package/esm/client/3_video_chat_manager.js +57 -68
  25. package/esm/client/4_callback_query_manager.js +18 -30
  26. package/esm/client/4_chat_list_manager.js +140 -146
  27. package/esm/client/4_chat_manager.js +161 -169
  28. package/esm/client/4_checklist_manager.js +26 -39
  29. package/esm/client/4_context.js +244 -259
  30. package/esm/client/4_forum_manager.js +67 -73
  31. package/esm/client/4_gift_manager.js +22 -35
  32. package/esm/client/4_inline_query_manager.js +16 -28
  33. package/esm/client/4_link_preview_manager.js +6 -19
  34. package/esm/client/4_poll_manager.js +44 -57
  35. package/esm/client/4_story_manager.js +41 -53
  36. package/esm/client/5_composer.js +13 -26
  37. package/esm/client/6_client.js +866 -896
  38. package/esm/client/6_client_dispatcher.js +308 -325
  39. package/esm/client/7_client_worker.js +16 -29
  40. package/esm/connection/1_connection_tcp.js +55 -82
  41. package/esm/connection/1_connection_web_socket.js +75 -91
  42. package/esm/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
  43. package/esm/deps/jsr.io/@std/async/1.2.0/mux_async_iterator.js +31 -47
  44. package/esm/deps/jsr.io/@std/async/1.2.0/tee.js +11 -34
  45. package/esm/deps/jsr.io/@std/cache/0.2.2/lru_cache.js +30 -47
  46. package/esm/deps/jsr.io/@std/datetime/0.225.7/_date_time_formatter.js +4 -17
  47. package/esm/session/0_session_state.js +12 -38
  48. package/esm/session/1_session.js +49 -72
  49. package/esm/session/2_session_encrypted.js +422 -420
  50. package/esm/storage/2_storage_indexed_db.js +26 -44
  51. package/esm/storage/2_storage_local_storage.js +3 -16
  52. package/esm/storage/2_storage_memory.js +24 -41
  53. package/esm/storage/2_storage_session_storage.js +3 -16
  54. package/esm/tl/1_tl_reader.d.ts +1 -1
  55. package/esm/tl/1_tl_reader.d.ts.map +1 -1
  56. package/esm/tl/1_tl_reader.js +95 -103
  57. package/esm/tl/1_tl_writer.js +169 -178
  58. package/esm/transport/0_transport.js +1 -8
  59. package/esm/transport/1_transport_abridged.js +11 -24
  60. package/esm/transport/1_transport_intermediate.js +10 -23
  61. package/esm/utilities/0_mutex.js +4 -19
  62. package/esm/utilities/0_part_stream.js +11 -25
  63. package/esm/utilities/1_crypto.js +42 -53
  64. package/esm/utilities/2_queue.js +29 -47
  65. package/package.json +1 -1
  66. package/script/0_errors.d.ts.map +1 -1
  67. package/script/0_errors.js +9 -31
  68. package/script/3_errors.js +2 -12
  69. package/script/4_errors.js +2 -12
  70. package/script/_dnt.polyfills.d.ts +0 -99
  71. package/script/_dnt.polyfills.d.ts.map +1 -1
  72. package/script/_dnt.polyfills.js +0 -128
  73. package/script/client/0_abortable_loop.js +27 -40
  74. package/script/client/0_storage_operations.js +179 -218
  75. package/script/client/1_client_plain.js +4 -22
  76. package/script/client/2_account_manager.js +140 -149
  77. package/script/client/2_bot_info_manager.js +26 -38
  78. package/script/client/2_business_connection_manager.js +10 -23
  79. package/script/client/2_client_encrypted.js +199 -216
  80. package/script/client/2_file_manager.js +255 -262
  81. package/script/client/2_network_statistics_manager.js +32 -45
  82. package/script/client/2_payment_manager.js +7 -20
  83. package/script/client/2_reaction_manager.js +7 -20
  84. package/script/client/2_translations_manager.js +102 -112
  85. package/script/client/2_update_manager.js +750 -745
  86. package/script/client/3_client_encrypted_pool.js +10 -26
  87. package/script/client/3_message_manager.js +503 -508
  88. package/script/client/3_video_chat_manager.js +57 -68
  89. package/script/client/4_callback_query_manager.js +18 -30
  90. package/script/client/4_chat_list_manager.js +140 -146
  91. package/script/client/4_chat_manager.js +161 -169
  92. package/script/client/4_checklist_manager.js +26 -39
  93. package/script/client/4_context.js +244 -259
  94. package/script/client/4_forum_manager.js +67 -73
  95. package/script/client/4_gift_manager.js +22 -35
  96. package/script/client/4_inline_query_manager.js +16 -28
  97. package/script/client/4_link_preview_manager.js +6 -19
  98. package/script/client/4_poll_manager.js +44 -57
  99. package/script/client/4_story_manager.js +41 -53
  100. package/script/client/5_composer.js +13 -26
  101. package/script/client/6_client.js +866 -896
  102. package/script/client/6_client_dispatcher.js +308 -325
  103. package/script/client/7_client_worker.js +16 -29
  104. package/script/connection/1_connection_tcp.js +55 -82
  105. package/script/connection/1_connection_web_socket.js +75 -91
  106. package/script/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
  107. package/script/deps/jsr.io/@std/async/1.2.0/mux_async_iterator.js +31 -47
  108. package/script/deps/jsr.io/@std/async/1.2.0/tee.js +11 -34
  109. package/script/deps/jsr.io/@std/cache/0.2.2/lru_cache.js +30 -47
  110. package/script/deps/jsr.io/@std/datetime/0.225.7/_date_time_formatter.js +4 -17
  111. package/script/session/0_session_state.js +12 -38
  112. package/script/session/1_session.js +49 -72
  113. package/script/session/2_session_encrypted.js +423 -421
  114. package/script/storage/2_storage_indexed_db.js +26 -44
  115. package/script/storage/2_storage_local_storage.js +3 -16
  116. package/script/storage/2_storage_memory.js +24 -41
  117. package/script/storage/2_storage_session_storage.js +3 -16
  118. package/script/tl/1_tl_reader.d.ts +1 -1
  119. package/script/tl/1_tl_reader.d.ts.map +1 -1
  120. package/script/tl/1_tl_reader.js +96 -104
  121. package/script/tl/1_tl_writer.js +170 -179
  122. package/script/transport/0_transport.js +1 -8
  123. package/script/transport/1_transport_abridged.js +11 -24
  124. package/script/transport/1_transport_intermediate.js +10 -23
  125. package/script/utilities/0_mutex.js +4 -19
  126. package/script/utilities/0_part_stream.js +11 -25
  127. package/script/utilities/1_crypto.js +43 -54
  128. package/script/utilities/2_queue.js +30 -48
@@ -17,18 +17,6 @@
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 _StorageOperations_instances, _StorageOperations_storage, _StorageOperations_supportsFiles, _StorageOperations_mustSerialize, _StorageOperations_L, _StorageOperations_maps, _StorageOperations_values, _StorageOperations_addMap, _StorageOperations_addValue, _StorageOperations_lastCommit, _StorageOperations_accountId, _StorageOperations_getUpdateId, _StorageMap_storage, _StorageMap_path, _StorageMap_pendingUpdates, _StorageMap_cache, _StorageValue_storage, _StorageValue_key, _StorageValue_updatePending, _StorageValue_value, _StorageAuth_instances, _StorageAuth_authKeyId, _StorageAuth_resetAuthKeyId;
32
20
  import { MINUTE } from "../0_deps.js";
33
21
  import { LruCache, unreachable } from "../0_deps.js";
34
22
  import { InputError } from "../0_errors.js";
@@ -93,74 +81,54 @@ export const K = {
93
81
  },
94
82
  };
95
83
  export class StorageOperations {
84
+ #storage;
85
+ #supportsFiles;
86
+ #mustSerialize;
87
+ #L;
88
+ #maps = new Array();
89
+ #values = new Array();
90
+ auth;
91
+ channelPts;
92
+ peers;
93
+ usernames;
94
+ translations;
96
95
  constructor(storage) {
97
- _StorageOperations_instances.add(this);
98
- _StorageOperations_storage.set(this, void 0);
99
- _StorageOperations_supportsFiles.set(this, void 0);
100
- _StorageOperations_mustSerialize.set(this, void 0);
101
- _StorageOperations_L.set(this, void 0);
102
- _StorageOperations_maps.set(this, new Array());
103
- _StorageOperations_values.set(this, new Array());
104
- Object.defineProperty(this, "auth", {
105
- enumerable: true,
106
- configurable: true,
107
- writable: true,
108
- value: void 0
109
- });
110
- Object.defineProperty(this, "channelPts", {
111
- enumerable: true,
112
- configurable: true,
113
- writable: true,
114
- value: void 0
115
- });
116
- Object.defineProperty(this, "peers", {
117
- enumerable: true,
118
- configurable: true,
119
- writable: true,
120
- value: void 0
121
- });
122
- Object.defineProperty(this, "usernames", {
123
- enumerable: true,
124
- configurable: true,
125
- writable: true,
126
- value: void 0
127
- });
128
- Object.defineProperty(this, "translations", {
129
- enumerable: true,
130
- configurable: true,
131
- writable: true,
132
- value: void 0
133
- });
134
- _StorageOperations_lastCommit.set(this, null);
135
- _StorageOperations_accountId.set(this, null);
136
- __classPrivateFieldSet(this, _StorageOperations_storage, storage, "f");
137
- __classPrivateFieldSet(this, _StorageOperations_supportsFiles, storage.supportsFiles, "f");
138
- __classPrivateFieldSet(this, _StorageOperations_mustSerialize, storage.mustSerialize, "f");
139
- __classPrivateFieldSet(this, _StorageOperations_L, getLogger("StorageOperations"), "f");
140
- this.auth = __classPrivateFieldGet(this, _StorageOperations_instances, "m", _StorageOperations_addValue).call(this, new StorageAuth(storage));
141
- this.channelPts = __classPrivateFieldGet(this, _StorageOperations_instances, "m", _StorageOperations_addMap).call(this, new StorageMap(storage, "channelPts"));
142
- this.peers = __classPrivateFieldGet(this, _StorageOperations_instances, "m", _StorageOperations_addMap).call(this, new StorageMap(storage, "peers"));
143
- this.usernames = __classPrivateFieldGet(this, _StorageOperations_instances, "m", _StorageOperations_addMap).call(this, new StorageMap(storage, "usernames"));
144
- this.translations = __classPrivateFieldGet(this, _StorageOperations_instances, "m", _StorageOperations_addMap).call(this, new StorageMap(storage, "translations"));
96
+ this.#storage = storage;
97
+ this.#supportsFiles = storage.supportsFiles;
98
+ this.#mustSerialize = storage.mustSerialize;
99
+ this.#L = getLogger("StorageOperations");
100
+ this.auth = this.#addValue(new StorageAuth(storage));
101
+ this.channelPts = this.#addMap(new StorageMap(storage, "channelPts"));
102
+ this.peers = this.#addMap(new StorageMap(storage, "peers"));
103
+ this.usernames = this.#addMap(new StorageMap(storage, "usernames"));
104
+ this.translations = this.#addMap(new StorageMap(storage, "translations"));
105
+ }
106
+ #addMap(map) {
107
+ this.#maps.push(map);
108
+ return map;
109
+ }
110
+ #addValue(value) {
111
+ this.#values.push(value);
112
+ return value;
145
113
  }
146
114
  get provider() {
147
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f");
115
+ return this.#storage;
148
116
  }
149
117
  get supportsFiles() {
150
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").supportsFiles;
118
+ return this.#storage.supportsFiles;
151
119
  }
152
120
  async initialize() {
153
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").initialize();
121
+ await this.#storage.initialize();
154
122
  await this.auth.get();
155
123
  }
156
124
  set(...args) {
157
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(...args);
125
+ return this.#storage.set(...args);
158
126
  }
159
127
  incr(...args) {
160
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").incr(...args);
128
+ return this.#storage.incr(...args);
161
129
  }
162
130
  get(...args) {
163
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(...args);
131
+ return this.#storage.get(...args);
164
132
  }
165
133
  async exportAuthString(apiId_) {
166
134
  if (typeof apiId_ === "number") {
@@ -195,56 +163,57 @@ export class StorageOperations {
195
163
  userId,
196
164
  });
197
165
  }
166
+ #lastCommit = null;
198
167
  async commit(force = false) {
199
- if (__classPrivateFieldGet(this, _StorageOperations_storage, "f").isMemory) {
168
+ if (this.#storage.isMemory) {
200
169
  return;
201
170
  }
202
- const pending = __classPrivateFieldGet(this, _StorageOperations_values, "f").filter((v) => v.isUpdatePending).length + __classPrivateFieldGet(this, _StorageOperations_maps, "f").filter((v) => v.pendingUpdateCount > 0).length;
171
+ const pending = this.#values.filter((v) => v.isUpdatePending).length + this.#maps.filter((v) => v.pendingUpdateCount > 0).length;
203
172
  if (pending <= 0) {
204
- __classPrivateFieldGet(this, _StorageOperations_L, "f").debug("nothing to commit");
173
+ this.#L.debug("nothing to commit");
205
174
  return;
206
175
  }
207
176
  let commit = false;
208
177
  if (force) {
209
- __classPrivateFieldGet(this, _StorageOperations_L, "f").debug("committing because force = true");
178
+ this.#L.debug("committing because force = true");
210
179
  commit = true;
211
180
  }
212
181
  else {
213
182
  if (!commit && pending >= 1_000) {
214
- __classPrivateFieldGet(this, _StorageOperations_L, "f").debug("committing because pending writes >= threshold");
183
+ this.#L.debug("committing because pending writes >= threshold");
215
184
  commit = true;
216
185
  }
217
- else if (__classPrivateFieldGet(this, _StorageOperations_lastCommit, "f") === null) {
218
- __classPrivateFieldGet(this, _StorageOperations_L, "f").debug("committing because there is no last commit");
186
+ else if (this.#lastCommit === null) {
187
+ this.#L.debug("committing because there is no last commit");
219
188
  commit = true;
220
189
  }
221
- else if (Date.now() - __classPrivateFieldGet(this, _StorageOperations_lastCommit, "f").getTime() >= 5 * MINUTE) {
222
- __classPrivateFieldGet(this, _StorageOperations_L, "f").debug("committing because last commit is older than threshold");
190
+ else if (Date.now() - this.#lastCommit.getTime() >= 5 * MINUTE) {
191
+ this.#L.debug("committing because last commit is older than threshold");
223
192
  commit = true;
224
193
  }
225
194
  else {
226
- __classPrivateFieldGet(this, _StorageOperations_L, "f").debug("not committing");
195
+ this.#L.debug("not committing");
227
196
  }
228
197
  }
229
198
  if (commit) {
230
- const values = __classPrivateFieldGet(this, _StorageOperations_values, "f").filter((v) => v.isUpdatePending).map((v) => v.commit());
231
- const maps = __classPrivateFieldGet(this, _StorageOperations_maps, "f").filter((v) => v.pendingUpdateCount > 0).map((v) => v.commit());
199
+ const values = this.#values.filter((v) => v.isUpdatePending).map((v) => v.commit());
200
+ const maps = this.#maps.filter((v) => v.pendingUpdateCount > 0).map((v) => v.commit());
232
201
  await Promise.all(values.concat(maps));
233
- __classPrivateFieldGet(this, _StorageOperations_L, "f").debug("committed", values.length, "value(s) and", maps.length, "map(s)");
234
- __classPrivateFieldSet(this, _StorageOperations_lastCommit, new Date(), "f");
202
+ this.#L.debug("committed", values.length, "value(s) and", maps.length, "map(s)");
203
+ this.#lastCommit = new Date();
235
204
  }
236
205
  }
237
206
  async setTlObject(key, value) {
238
207
  if (value === null) {
239
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
208
+ await this.#storage.set(key, null);
240
209
  }
241
210
  else {
242
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, __classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? [value._, rleEncode(Api.serializeObject(value))] : value);
211
+ await this.#storage.set(key, this.#mustSerialize ? [value._, rleEncode(Api.serializeObject(value))] : value);
243
212
  }
244
213
  }
245
214
  async getTlObject(keyOrBuffer) {
246
215
  // @ts-ignore: TBD
247
- const buffer = (keyOrBuffer instanceof Uint8Array || Api.isValidObject(keyOrBuffer)) ? keyOrBuffer : await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(keyOrBuffer);
216
+ const buffer = (keyOrBuffer instanceof Uint8Array || Api.isValidObject(keyOrBuffer)) ? keyOrBuffer : await this.#storage.get(keyOrBuffer);
248
217
  if (buffer !== null) {
249
218
  if (buffer instanceof Uint8Array) {
250
219
  return await Api.deserializeType(X, rleDecode(buffer));
@@ -268,19 +237,19 @@ export class StorageOperations {
268
237
  }
269
238
  async setMessage(chatId, messageId, message) {
270
239
  if (chatId > ZERO_CHANNEL_ID) {
271
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.messages.messageRef(messageId), message === null ? null : chatId);
240
+ await this.#storage.set(K.messages.messageRef(messageId), message === null ? null : chatId);
272
241
  }
273
242
  await this.setTlObject(K.messages.message(chatId, messageId), message);
274
243
  }
275
244
  async deleteMessages() {
276
245
  const maybePromises = new Array();
277
- for await (const [k, o] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: K.messages.allMessageRefs() })) {
278
- maybePromises.push(Promise.all([__classPrivateFieldGet(this, _StorageOperations_storage, "f").set(k, null), o === null ? Promise.resolve() : __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.messages.message(o, k[1]), null)]));
246
+ for await (const [k, o] of await this.#storage.getMany({ prefix: K.messages.allMessageRefs() })) {
247
+ maybePromises.push(Promise.all([this.#storage.set(k, null), o === null ? Promise.resolve() : this.#storage.set(K.messages.message(o, k[1]), null)]));
279
248
  }
280
249
  await Promise.all(maybePromises.filter((v) => v instanceof Promise));
281
250
  }
282
251
  getMessageChat(messageId) {
283
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(K.messages.messageRef(messageId));
252
+ return this.#storage.get(K.messages.messageRef(messageId));
284
253
  }
285
254
  async getMessage(chatId, messageId) {
286
255
  return await this.getTlObject(K.messages.message(chatId, messageId));
@@ -292,31 +261,32 @@ export class StorageOperations {
292
261
  setPeer2(chatP, accessHash) {
293
262
  this.peers.set([chatP.id], [chatP, accessHash]);
294
263
  }
264
+ #accountId = null;
295
265
  async getAccountId() {
296
- if (__classPrivateFieldGet(this, _StorageOperations_accountId, "f") !== null) {
297
- return __classPrivateFieldGet(this, _StorageOperations_accountId, "f");
266
+ if (this.#accountId !== null) {
267
+ return this.#accountId;
298
268
  }
299
269
  else {
300
- return __classPrivateFieldSet(this, _StorageOperations_accountId, (await this.auth.get())?.userId ?? null, "f");
270
+ return this.#accountId = (await this.auth.get())?.userId ?? null;
301
271
  }
302
272
  }
303
273
  async setIsPremium(isPremium) {
304
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.auth.isPremium(), isPremium);
274
+ await this.#storage.set(K.auth.isPremium(), isPremium);
305
275
  }
306
276
  async getIsPremium() {
307
- return await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(K.auth.isPremium());
277
+ return await this.#storage.get(K.auth.isPremium());
308
278
  }
309
279
  async updateStickerSetName(id, accessHash, name) {
310
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.cache.stickerSetName(id, accessHash), [name, new Date()]);
280
+ await this.#storage.set(K.cache.stickerSetName(id, accessHash), [name, new Date()]);
311
281
  }
312
282
  getStickerSetName(id, accessHash) {
313
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(K.cache.stickerSetName(id, accessHash));
283
+ return this.#storage.get(K.cache.stickerSetName(id, accessHash));
314
284
  }
315
285
  async setServerSalt(serverSalt) {
316
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.session.serverSalt(), serverSalt);
286
+ await this.#storage.set(K.session.serverSalt(), serverSalt);
317
287
  }
318
288
  getServerSalt() {
319
- return __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(K.session.serverSalt());
289
+ return this.#storage.get(K.session.serverSalt());
320
290
  }
321
291
  async getHistory(chatId, offsetId, limit) {
322
292
  if (offsetId === 0) {
@@ -324,7 +294,7 @@ export class StorageOperations {
324
294
  }
325
295
  ++limit;
326
296
  const messages = new Array();
327
- for await (const [_, buffer] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ start: K.messages.message(chatId, 0), end: K.messages.message(chatId, offsetId) }, { limit, reverse: true })) {
297
+ for await (const [_, buffer] of await this.#storage.getMany({ start: K.messages.message(chatId, 0), end: K.messages.message(chatId, offsetId) }, { limit, reverse: true })) {
328
298
  const message = await this.getTlObject(buffer);
329
299
  if ("id" in message && message.id === offsetId) {
330
300
  continue;
@@ -334,18 +304,18 @@ export class StorageOperations {
334
304
  return messages;
335
305
  }
336
306
  async getFile(id) {
337
- if (!__classPrivateFieldGet(this, _StorageOperations_supportsFiles, "f")) {
307
+ if (!this.#supportsFiles) {
338
308
  return null;
339
309
  }
340
- return await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(K.cache.file(id));
310
+ return await this.#storage.get(K.cache.file(id));
341
311
  }
342
312
  async *iterFileParts(id, partCount, offset, signal) {
343
- if (!__classPrivateFieldGet(this, _StorageOperations_supportsFiles, "f")) {
313
+ if (!this.#supportsFiles) {
344
314
  return;
345
315
  }
346
316
  for (let i = offset; i < partCount; i++) {
347
317
  signal?.throwIfAborted();
348
- const part = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(K.cache.filePart(id, i));
318
+ const part = await this.#storage.get(K.cache.filePart(id, i));
349
319
  if (part === null) {
350
320
  continue;
351
321
  }
@@ -353,22 +323,22 @@ export class StorageOperations {
353
323
  }
354
324
  }
355
325
  async saveFilePart(id, index, bytes) {
356
- if (!__classPrivateFieldGet(this, _StorageOperations_supportsFiles, "f")) {
326
+ if (!this.#supportsFiles) {
357
327
  return;
358
328
  }
359
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.cache.filePart(id, index), bytes);
329
+ await this.#storage.set(K.cache.filePart(id, index), bytes);
360
330
  }
361
331
  async setFilePartCount(id, partCount, chunkSize) {
362
- if (!__classPrivateFieldGet(this, _StorageOperations_supportsFiles, "f")) {
332
+ if (!this.#supportsFiles) {
363
333
  return;
364
334
  }
365
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.cache.file(id), [partCount, chunkSize]);
335
+ await this.#storage.set(K.cache.file(id), [partCount, chunkSize]);
366
336
  }
367
337
  async setCustomEmojiDocument(id, document) {
368
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.cache.customEmojiDocument(id), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? rleEncode(Api.serializeObject(document)) : document, new Date()]);
338
+ await this.#storage.set(K.cache.customEmojiDocument(id), [this.#mustSerialize ? rleEncode(Api.serializeObject(document)) : document, new Date()]);
369
339
  }
370
340
  async getCustomEmojiDocument(id) {
371
- const v = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(K.cache.customEmojiDocument(id));
341
+ const v = await this.#storage.get(K.cache.customEmojiDocument(id));
372
342
  if (v !== null) {
373
343
  return [await this.getTlObject(v[0]), v[1]];
374
344
  }
@@ -377,10 +347,10 @@ export class StorageOperations {
377
347
  }
378
348
  }
379
349
  async setBusinessConnection(id, connection) {
380
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.cache.businessConnection(id), connection === null ? null : __classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? rleEncode(Api.serializeObject(connection)) : connection);
350
+ await this.#storage.set(K.cache.businessConnection(id), connection === null ? null : this.#mustSerialize ? rleEncode(Api.serializeObject(connection)) : connection);
381
351
  }
382
352
  async getBusinessConnection(id) {
383
- const v = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(K.cache.businessConnection(id));
353
+ const v = await this.#storage.get(K.cache.businessConnection(id));
384
354
  if (v !== null) {
385
355
  return await this.getTlObject(v);
386
356
  }
@@ -389,10 +359,10 @@ export class StorageOperations {
389
359
  }
390
360
  }
391
361
  async setInlineQueryAnswer(userId, chatId, query, offset, results, date) {
392
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.cache.inlineQueryAnswer(userId, chatId, query, offset), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? rleEncode(Api.serializeObject(results)) : results, date]);
362
+ await this.#storage.set(K.cache.inlineQueryAnswer(userId, chatId, query, offset), [this.#mustSerialize ? rleEncode(Api.serializeObject(results)) : results, date]);
393
363
  }
394
364
  async getInlineQueryAnswer(userId, chatId, query, offset) {
395
- const peer_ = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(K.cache.inlineQueryAnswer(userId, chatId, query, offset));
365
+ const peer_ = await this.#storage.get(K.cache.inlineQueryAnswer(userId, chatId, query, offset));
396
366
  if (peer_ !== null) {
397
367
  const [obj_, date] = peer_;
398
368
  return [Api.as("messages.botResults", await this.getTlObject(obj_)), date];
@@ -402,10 +372,10 @@ export class StorageOperations {
402
372
  }
403
373
  }
404
374
  async setCallbackQueryAnswer(chatId, messageId, question, answer) {
405
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.cache.callbackQueryAnswer(chatId, messageId, question), [__classPrivateFieldGet(this, _StorageOperations_mustSerialize, "f") ? rleEncode(Api.serializeObject(answer)) : answer, new Date()]);
375
+ await this.#storage.set(K.cache.callbackQueryAnswer(chatId, messageId, question), [this.#mustSerialize ? rleEncode(Api.serializeObject(answer)) : answer, new Date()]);
406
376
  }
407
377
  async getCallbackQueryAnswer(chatId, messageId, question) {
408
- const peer_ = await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(K.cache.callbackQueryAnswer(chatId, messageId, question));
378
+ const peer_ = await this.#storage.get(K.cache.callbackQueryAnswer(chatId, messageId, question));
409
379
  if (peer_ !== null) {
410
380
  const [obj_, date] = peer_;
411
381
  return [Api.as("messages.botCallbackAnswer", await this.getTlObject(obj_)), date];
@@ -427,23 +397,33 @@ export class StorageOperations {
427
397
  return await this.getTlObject(K.cache.groupCall(id));
428
398
  }
429
399
  async setGroupCallAccessHash(id, accessHash) {
430
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.cache.groupCallAccessHash(id), accessHash);
400
+ await this.#storage.set(K.cache.groupCallAccessHash(id), accessHash);
431
401
  }
432
402
  async getGroupCallAccessHash(id) {
433
- return await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(K.cache.groupCallAccessHash(id));
403
+ return await this.#storage.get(K.cache.groupCallAccessHash(id));
404
+ }
405
+ #getUpdateId(update) {
406
+ let id = BigInt(Date.now()) << 32n;
407
+ if ("pts" in update && update.pts) {
408
+ id |= BigInt(update.pts);
409
+ }
410
+ else {
411
+ id |= BigInt(0xffffffffn);
412
+ }
413
+ return id;
434
414
  }
435
415
  async setUpdate(boxId, update) {
436
- await this.setTlObject(K.updates.update(boxId, __classPrivateFieldGet(this, _StorageOperations_instances, "m", _StorageOperations_getUpdateId).call(this, update)), update);
416
+ await this.setTlObject(K.updates.update(boxId, this.#getUpdateId(update)), update);
437
417
  }
438
418
  async deleteUpdates() {
439
419
  const maybePromises = new Array();
440
- for await (const [k] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: K.updates.all() })) {
441
- maybePromises.push(__classPrivateFieldGet(this, _StorageOperations_storage, "f").set(k, null));
420
+ for await (const [k] of await this.#storage.getMany({ prefix: K.updates.all() })) {
421
+ maybePromises.push(this.#storage.set(k, null));
442
422
  }
443
423
  await Promise.all(maybePromises.filter((v) => v instanceof Promise));
444
424
  }
445
425
  async getFirstUpdate(boxId) {
446
- for await (const [key, update] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: K.updates.updates(boxId) }, { limit: 1 })) {
426
+ for await (const [key, update] of await this.#storage.getMany({ prefix: K.updates.updates(boxId) }, { limit: 1 })) {
447
427
  return [key, (await this.getTlObject(update))];
448
428
  }
449
429
  return null;
@@ -482,49 +462,49 @@ export class StorageOperations {
482
462
  }
483
463
  }
484
464
  async deleteFiles() {
485
- if (!__classPrivateFieldGet(this, _StorageOperations_supportsFiles, "f")) {
465
+ if (!this.#supportsFiles) {
486
466
  return;
487
467
  }
488
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: K.cache.fileParts() })) {
489
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
468
+ for await (const [key] of await this.#storage.getMany({ prefix: K.cache.fileParts() })) {
469
+ await this.#storage.set(key, null);
490
470
  }
491
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: K.cache.files() })) {
492
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
471
+ for await (const [key] of await this.#storage.getMany({ prefix: K.cache.files() })) {
472
+ await this.#storage.set(key, null);
493
473
  }
494
474
  }
495
475
  async deleteCustomEmojiDocuments() {
496
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: K.cache.customEmojiDocuments() })) {
497
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
476
+ for await (const [key] of await this.#storage.getMany({ prefix: K.cache.customEmojiDocuments() })) {
477
+ await this.#storage.set(key, null);
498
478
  }
499
479
  }
500
480
  async deleteBusinessConnections() {
501
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: K.cache.businessConnections() })) {
502
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
481
+ for await (const [key] of await this.#storage.getMany({ prefix: K.cache.businessConnections() })) {
482
+ await this.#storage.set(key, null);
503
483
  }
504
484
  }
505
485
  async deleteInlineQueryAnswers() {
506
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: K.cache.inlineQueryAnswers() })) {
507
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
486
+ for await (const [key] of await this.#storage.getMany({ prefix: K.cache.inlineQueryAnswers() })) {
487
+ await this.#storage.set(key, null);
508
488
  }
509
489
  }
510
490
  async deleteCallbackQueryAnswers() {
511
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: K.cache.callbackQueryAnswers() })) {
512
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
491
+ for await (const [key] of await this.#storage.getMany({ prefix: K.cache.callbackQueryAnswers() })) {
492
+ await this.#storage.set(key, null);
513
493
  }
514
494
  }
515
495
  async deleteFullChats() {
516
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: K.cache.fullChats() })) {
517
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
496
+ for await (const [key] of await this.#storage.getMany({ prefix: K.cache.fullChats() })) {
497
+ await this.#storage.set(key, null);
518
498
  }
519
499
  }
520
500
  async deleteGroupCalls() {
521
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: K.cache.groupCalls() })) {
522
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
501
+ for await (const [key] of await this.#storage.getMany({ prefix: K.cache.groupCalls() })) {
502
+ await this.#storage.set(key, null);
523
503
  }
524
504
  }
525
505
  async deleteStickerSetNames() {
526
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: K.cache.stickerSetNames() })) {
527
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
506
+ for await (const [key] of await this.#storage.getMany({ prefix: K.cache.stickerSetNames() })) {
507
+ await this.#storage.set(key, null);
528
508
  }
529
509
  }
530
510
  async clear() {
@@ -549,8 +529,8 @@ export class StorageOperations {
549
529
  ]);
550
530
  }
551
531
  async reset() {
552
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: [] })) {
553
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null);
532
+ for await (const [key] of await this.#storage.getMany({ prefix: [] })) {
533
+ await this.#storage.set(key, null);
554
534
  }
555
535
  }
556
536
  async setPollResults(pollId, pollResults) {
@@ -561,8 +541,8 @@ export class StorageOperations {
561
541
  }
562
542
  async deletePollResults() {
563
543
  const maybePromises = new Array();
564
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: K.cache.pollResults() })) {
565
- maybePromises.push(__classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null));
544
+ for await (const [key] of await this.#storage.getMany({ prefix: K.cache.pollResults() })) {
545
+ maybePromises.push(this.#storage.set(key, null));
566
546
  }
567
547
  await Promise.all(maybePromises);
568
548
  }
@@ -574,75 +554,59 @@ export class StorageOperations {
574
554
  }
575
555
  async deletePolls() {
576
556
  const maybePromises = new Array();
577
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: K.cache.polls() })) {
578
- maybePromises.push(__classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null));
557
+ for await (const [key] of await this.#storage.getMany({ prefix: K.cache.polls() })) {
558
+ maybePromises.push(this.#storage.set(key, null));
579
559
  }
580
560
  await Promise.all(maybePromises);
581
561
  }
582
562
  async setVoiceTranscription(voiceTranscription) {
583
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.cache.voiceTranscription(BigInt(voiceTranscription.id)), voiceTranscription);
563
+ await this.#storage.set(K.cache.voiceTranscription(BigInt(voiceTranscription.id)), voiceTranscription);
584
564
  }
585
565
  async getVoiceTranscription(transcriptionId) {
586
- return await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(K.cache.voiceTranscription(transcriptionId));
566
+ return await this.#storage.get(K.cache.voiceTranscription(transcriptionId));
587
567
  }
588
568
  async deleteVoiceTranscriptions() {
589
569
  const maybePromises = new Array();
590
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: K.cache.voiceTranscriptions() })) {
591
- maybePromises.push(__classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null));
570
+ for await (const [key] of await this.#storage.getMany({ prefix: K.cache.voiceTranscriptions() })) {
571
+ maybePromises.push(this.#storage.set(key, null));
592
572
  }
593
573
  await Promise.all(maybePromises);
594
574
  }
595
575
  async setVoiceTranscriptionReference(chatId, messageId, messageEditDate, transcriptionId) {
596
- await __classPrivateFieldGet(this, _StorageOperations_storage, "f").set(K.cache.voiceTranscriptionReference(chatId, messageId, messageEditDate.getTime()), transcriptionId);
576
+ await this.#storage.set(K.cache.voiceTranscriptionReference(chatId, messageId, messageEditDate.getTime()), transcriptionId);
597
577
  }
598
578
  async getVoiceTranscriptionReference(chatId, messageId, messageEditDate) {
599
- return await __classPrivateFieldGet(this, _StorageOperations_storage, "f").get(K.cache.voiceTranscriptionReference(chatId, messageId, messageEditDate.getTime()));
579
+ return await this.#storage.get(K.cache.voiceTranscriptionReference(chatId, messageId, messageEditDate.getTime()));
600
580
  }
601
581
  async deleteVoiceTranscriptionReferences() {
602
582
  const maybePromises = new Array();
603
- for await (const [key] of await __classPrivateFieldGet(this, _StorageOperations_storage, "f").getMany({ prefix: K.cache.voiceTranscriptions() })) {
604
- maybePromises.push(__classPrivateFieldGet(this, _StorageOperations_storage, "f").set(key, null));
583
+ for await (const [key] of await this.#storage.getMany({ prefix: K.cache.voiceTranscriptions() })) {
584
+ maybePromises.push(this.#storage.set(key, null));
605
585
  }
606
586
  await Promise.all(maybePromises);
607
587
  }
608
588
  }
609
- _StorageOperations_storage = new WeakMap(), _StorageOperations_supportsFiles = new WeakMap(), _StorageOperations_mustSerialize = new WeakMap(), _StorageOperations_L = new WeakMap(), _StorageOperations_maps = new WeakMap(), _StorageOperations_values = new WeakMap(), _StorageOperations_lastCommit = new WeakMap(), _StorageOperations_accountId = new WeakMap(), _StorageOperations_instances = new WeakSet(), _StorageOperations_addMap = function _StorageOperations_addMap(map) {
610
- __classPrivateFieldGet(this, _StorageOperations_maps, "f").push(map);
611
- return map;
612
- }, _StorageOperations_addValue = function _StorageOperations_addValue(value) {
613
- __classPrivateFieldGet(this, _StorageOperations_values, "f").push(value);
614
- return value;
615
- }, _StorageOperations_getUpdateId = function _StorageOperations_getUpdateId(update) {
616
- let id = BigInt(Date.now()) << 32n;
617
- if ("pts" in update && update.pts) {
618
- id |= BigInt(update.pts);
619
- }
620
- else {
621
- id |= BigInt(0xffffffffn);
622
- }
623
- return id;
624
- };
625
589
  class StorageMap {
590
+ #storage;
591
+ #path;
626
592
  constructor(storage, path) {
627
- _StorageMap_storage.set(this, void 0);
628
- _StorageMap_path.set(this, void 0);
629
- _StorageMap_pendingUpdates.set(this, new Map());
630
- _StorageMap_cache.set(this, new LruCache(20_000));
631
- __classPrivateFieldSet(this, _StorageMap_storage, storage, "f");
632
- __classPrivateFieldSet(this, _StorageMap_path, path, "f");
593
+ this.#storage = storage;
594
+ this.#path = path;
633
595
  }
596
+ #pendingUpdates = new Map();
597
+ #cache = new LruCache(20_000);
634
598
  set(key, value) {
635
599
  const key_ = toString(key);
636
- __classPrivateFieldGet(this, _StorageMap_cache, "f").set(key_, value);
637
- if (!__classPrivateFieldGet(this, _StorageMap_storage, "f").isMemory) {
638
- __classPrivateFieldGet(this, _StorageMap_pendingUpdates, "f").set(key_, value);
600
+ this.#cache.set(key_, value);
601
+ if (!this.#storage.isMemory) {
602
+ this.#pendingUpdates.set(key_, value);
639
603
  }
640
604
  }
641
605
  get pendingUpdateCount() {
642
- return __classPrivateFieldGet(this, _StorageMap_pendingUpdates, "f").size;
606
+ return this.#pendingUpdates.size;
643
607
  }
644
608
  mustGet(key) {
645
- const value = __classPrivateFieldGet(this, _StorageMap_cache, "f").get(toString(key));
609
+ const value = this.#cache.get(toString(key));
646
610
  if (value === undefined) {
647
611
  unreachable();
648
612
  }
@@ -651,71 +615,67 @@ class StorageMap {
651
615
  }
652
616
  }
653
617
  async clear() {
654
- await awaitablePooledMap(10, await __classPrivateFieldGet(this, _StorageMap_storage, "f").getMany({ prefix: [__classPrivateFieldGet(this, _StorageMap_path, "f")] }), async ([key]) => await __classPrivateFieldGet(this, _StorageMap_storage, "f").set(key, null));
618
+ await awaitablePooledMap(10, await this.#storage.getMany({ prefix: [this.#path] }), async ([key]) => await this.#storage.set(key, null));
655
619
  }
656
620
  async get(key) {
657
621
  const key_ = toString(key);
658
- let value = __classPrivateFieldGet(this, _StorageMap_cache, "f").get(key_);
622
+ let value = this.#cache.get(key_);
659
623
  if (value === undefined) {
660
- value = await __classPrivateFieldGet(this, _StorageMap_storage, "f").get([__classPrivateFieldGet(this, _StorageMap_path, "f"), ...key]);
661
- __classPrivateFieldGet(this, _StorageMap_cache, "f").set(key_, value);
624
+ value = await this.#storage.get([this.#path, ...key]);
625
+ this.#cache.set(key_, value);
662
626
  }
663
627
  return value;
664
628
  }
665
629
  async commit() {
666
- if (__classPrivateFieldGet(this, _StorageMap_storage, "f").isMemory) {
630
+ if (this.#storage.isMemory) {
667
631
  return;
668
632
  }
669
- await awaitablePooledMap(2, __classPrivateFieldGet(this, _StorageMap_pendingUpdates, "f"), async ([key, value]) => await __classPrivateFieldGet(this, _StorageMap_storage, "f").set([__classPrivateFieldGet(this, _StorageMap_path, "f"), ...fromString(key)], value));
670
- __classPrivateFieldGet(this, _StorageMap_pendingUpdates, "f").clear();
633
+ await awaitablePooledMap(2, this.#pendingUpdates, async ([key, value]) => await this.#storage.set([this.#path, ...fromString(key)], value));
634
+ this.#pendingUpdates.clear();
671
635
  }
672
636
  }
673
- _StorageMap_storage = new WeakMap(), _StorageMap_path = new WeakMap(), _StorageMap_pendingUpdates = new WeakMap(), _StorageMap_cache = new WeakMap();
674
637
  class StorageValue {
638
+ #storage;
639
+ #key;
675
640
  constructor(storage, path) {
676
- _StorageValue_storage.set(this, void 0);
677
- _StorageValue_key.set(this, void 0);
678
- _StorageValue_updatePending.set(this, false);
679
- _StorageValue_value.set(this, void 0);
680
- __classPrivateFieldSet(this, _StorageValue_storage, storage, "f");
681
- __classPrivateFieldSet(this, _StorageValue_key, [path], "f");
641
+ this.#storage = storage;
642
+ this.#key = [path];
682
643
  }
644
+ #updatePending = false;
645
+ #value;
683
646
  set(value) {
684
- __classPrivateFieldSet(this, _StorageValue_value, value, "f");
685
- if (!__classPrivateFieldGet(this, _StorageValue_storage, "f").isMemory) {
686
- __classPrivateFieldSet(this, _StorageValue_updatePending, true, "f");
647
+ this.#value = value;
648
+ if (!this.#storage.isMemory) {
649
+ this.#updatePending = true;
687
650
  }
688
651
  }
689
652
  get isUpdatePending() {
690
- return __classPrivateFieldGet(this, _StorageValue_updatePending, "f");
653
+ return this.#updatePending;
691
654
  }
692
655
  mustGet() {
693
- return __classPrivateFieldGet(this, _StorageValue_value, "f") === undefined ? unreachable() : __classPrivateFieldGet(this, _StorageValue_value, "f");
656
+ return this.#value === undefined ? unreachable() : this.#value;
694
657
  }
695
658
  async get() {
696
- if (__classPrivateFieldGet(this, _StorageValue_value, "f") === undefined) {
697
- __classPrivateFieldSet(this, _StorageValue_value, await __classPrivateFieldGet(this, _StorageValue_storage, "f").get(__classPrivateFieldGet(this, _StorageValue_key, "f")), "f");
659
+ if (this.#value === undefined) {
660
+ this.#value = await this.#storage.get(this.#key);
698
661
  }
699
- return __classPrivateFieldGet(this, _StorageValue_value, "f");
662
+ return this.#value;
700
663
  }
701
664
  async commit() {
702
- if (__classPrivateFieldGet(this, _StorageValue_storage, "f").isMemory || __classPrivateFieldGet(this, _StorageValue_value, "f") === undefined) {
665
+ if (this.#storage.isMemory || this.#value === undefined) {
703
666
  return;
704
667
  }
705
- await __classPrivateFieldGet(this, _StorageValue_storage, "f").set(__classPrivateFieldGet(this, _StorageValue_key, "f"), __classPrivateFieldGet(this, _StorageValue_value, "f"));
706
- __classPrivateFieldSet(this, _StorageValue_updatePending, false, "f");
668
+ await this.#storage.set(this.#key, this.#value);
669
+ this.#updatePending = false;
707
670
  }
708
671
  }
709
- _StorageValue_storage = new WeakMap(), _StorageValue_key = new WeakMap(), _StorageValue_updatePending = new WeakMap(), _StorageValue_value = new WeakMap();
710
672
  class StorageAuth extends StorageValue {
711
673
  constructor(storage) {
712
674
  super(storage, "auth");
713
- _StorageAuth_instances.add(this);
714
- _StorageAuth_authKeyId.set(this, null);
715
675
  }
716
676
  async get() {
717
677
  const value = await super.get();
718
- await __classPrivateFieldGet(this, _StorageAuth_instances, "m", _StorageAuth_resetAuthKeyId).call(this, value);
678
+ await this.#resetAuthKeyId(value);
719
679
  return value;
720
680
  }
721
681
  mustGet() {
@@ -729,22 +689,23 @@ class StorageAuth extends StorageValue {
729
689
  }
730
690
  async set(auth) {
731
691
  super.set(auth);
732
- await __classPrivateFieldGet(this, _StorageAuth_instances, "m", _StorageAuth_resetAuthKeyId).call(this, auth);
692
+ await this.#resetAuthKeyId(auth);
733
693
  }
734
694
  async update(fn) {
735
695
  const auth = this.mustGet();
736
696
  fn(auth);
737
697
  await this.set(auth);
738
698
  }
699
+ #authKeyId = null;
700
+ async #resetAuthKeyId(auth) {
701
+ if (auth?.authKey) {
702
+ this.#authKeyId = intFromBytes((await sha1(auth.authKey)).subarray(-8));
703
+ }
704
+ else {
705
+ this.#authKeyId = null;
706
+ }
707
+ }
739
708
  get authKeyId() {
740
- return __classPrivateFieldGet(this, _StorageAuth_authKeyId, "f");
709
+ return this.#authKeyId;
741
710
  }
742
711
  }
743
- _StorageAuth_authKeyId = new WeakMap(), _StorageAuth_instances = new WeakSet(), _StorageAuth_resetAuthKeyId = async function _StorageAuth_resetAuthKeyId(auth) {
744
- if (auth?.authKey) {
745
- __classPrivateFieldSet(this, _StorageAuth_authKeyId, intFromBytes((await sha1(auth.authKey)).subarray(-8)), "f");
746
- }
747
- else {
748
- __classPrivateFieldSet(this, _StorageAuth_authKeyId, null, "f");
749
- }
750
- };