@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
@@ -18,18 +18,6 @@
18
18
  * You should have received a copy of the GNU Lesser General Public License
19
19
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
20
  */
21
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
22
- if (kind === "m") throw new TypeError("Private method is not writable");
23
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
24
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
25
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
26
- };
27
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
28
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
29
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
30
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
31
- };
32
- var _BotInfoManager_instances, _BotInfoManager_c, _BotInfoManager_setMyInfo, _BotInfoManager_getMyInfo;
33
21
  Object.defineProperty(exports, "__esModule", { value: true });
34
22
  exports.BotInfoManager = void 0;
35
23
  const _2_tl_js_1 = require("../2_tl.js");
@@ -39,54 +27,59 @@ const botInfoManagerUpdates = [
39
27
  "updateBotCommands",
40
28
  ];
41
29
  class BotInfoManager {
30
+ #c;
42
31
  constructor(c) {
43
- _BotInfoManager_instances.add(this);
44
- _BotInfoManager_c.set(this, void 0);
45
- __classPrivateFieldSet(this, _BotInfoManager_c, c, "f");
32
+ this.#c = c;
46
33
  }
47
34
  canHandleUpdate(update) {
48
35
  return _2_tl_js_1.Api.isOneOf(botInfoManagerUpdates, update);
49
36
  }
37
+ async #setMyInfo(info) {
38
+ await this.#c.invoke({ _: "bots.setBotInfo", ...info });
39
+ }
50
40
  async setMyDescription(params) {
51
- __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("setMyDescription");
52
- await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_setMyInfo).call(this, { description: params?.description, lang_code: params?.languageCode ?? "" });
41
+ this.#c.storage.assertBot("setMyDescription");
42
+ await this.#setMyInfo({ description: params?.description, lang_code: params?.languageCode ?? "" });
53
43
  }
54
44
  async setMyName(params) {
55
- __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("setMyName");
56
- await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_setMyInfo).call(this, { name: params?.name, lang_code: params?.languageCode ?? "" });
45
+ this.#c.storage.assertBot("setMyName");
46
+ await this.#setMyInfo({ name: params?.name, lang_code: params?.languageCode ?? "" });
57
47
  }
58
48
  async setMyShortDescription(params) {
59
- __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("setMyShortDescription");
60
- await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_setMyInfo).call(this, { about: params?.shortDescription, lang_code: params?.languageCode ?? "" });
49
+ this.#c.storage.assertBot("setMyShortDescription");
50
+ await this.#setMyInfo({ about: params?.shortDescription, lang_code: params?.languageCode ?? "" });
51
+ }
52
+ #getMyInfo(languageCode) {
53
+ return this.#c.invoke({ _: "bots.getBotInfo", lang_code: languageCode ?? "" });
61
54
  }
62
55
  async getMyDescription(params) {
63
- __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("getMyDescription");
64
- return (await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_getMyInfo).call(this, params?.languageCode)).description;
56
+ this.#c.storage.assertBot("getMyDescription");
57
+ return (await this.#getMyInfo(params?.languageCode)).description;
65
58
  }
66
59
  async getMyName(params) {
67
- __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("getMyName");
68
- return (await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_getMyInfo).call(this, params?.languageCode)).description;
60
+ this.#c.storage.assertBot("getMyName");
61
+ return (await this.#getMyInfo(params?.languageCode)).description;
69
62
  }
70
63
  async getMyShortDescription(params) {
71
- __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("getMyShortDescription");
72
- return (await __classPrivateFieldGet(this, _BotInfoManager_instances, "m", _BotInfoManager_getMyInfo).call(this, params?.languageCode)).about;
64
+ this.#c.storage.assertBot("getMyShortDescription");
65
+ return (await this.#getMyInfo(params?.languageCode)).about;
73
66
  }
74
67
  async getMyCommands(params) {
75
- __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("getMyCommands");
76
- const commands_ = await __classPrivateFieldGet(this, _BotInfoManager_c, "f").invoke({
68
+ this.#c.storage.assertBot("getMyCommands");
69
+ const commands_ = await this.#c.invoke({
77
70
  _: "bots.getBotCommands",
78
71
  lang_code: params?.languageCode ?? "",
79
- scope: await (0, _3_types_js_1.botCommandScopeToTlObject)(params?.scope ?? { type: "default" }, __classPrivateFieldGet(this, _BotInfoManager_c, "f").getInputPeer),
72
+ scope: await (0, _3_types_js_1.botCommandScopeToTlObject)(params?.scope ?? { type: "default" }, this.#c.getInputPeer),
80
73
  });
81
74
  return commands_.map((v) => ({ command: v.command, description: v.description }));
82
75
  }
83
76
  async setMyCommands(commands, params) {
84
- __classPrivateFieldGet(this, _BotInfoManager_c, "f").storage.assertBot("setMyCommands");
85
- await __classPrivateFieldGet(this, _BotInfoManager_c, "f").invoke({
77
+ this.#c.storage.assertBot("setMyCommands");
78
+ await this.#c.invoke({
86
79
  _: "bots.setBotCommands",
87
80
  commands: commands.map((v) => ({ ...v, _: "botCommand" })),
88
81
  lang_code: params?.languageCode ?? "",
89
- scope: await (0, _3_types_js_1.botCommandScopeToTlObject)(params?.scope ?? { type: "default" }, __classPrivateFieldGet(this, _BotInfoManager_c, "f").getInputPeer),
82
+ scope: await (0, _3_types_js_1.botCommandScopeToTlObject)(params?.scope ?? { type: "default" }, this.#c.getInputPeer),
90
83
  });
91
84
  }
92
85
  handleUpdate(update) {
@@ -97,8 +90,3 @@ class BotInfoManager {
97
90
  }
98
91
  }
99
92
  exports.BotInfoManager = BotInfoManager;
100
- _BotInfoManager_c = new WeakMap(), _BotInfoManager_instances = new WeakSet(), _BotInfoManager_setMyInfo = async function _BotInfoManager_setMyInfo(info) {
101
- await __classPrivateFieldGet(this, _BotInfoManager_c, "f").invoke({ _: "bots.setBotInfo", ...info });
102
- }, _BotInfoManager_getMyInfo = function _BotInfoManager_getMyInfo(languageCode) {
103
- return __classPrivateFieldGet(this, _BotInfoManager_c, "f").invoke({ _: "bots.getBotInfo", lang_code: languageCode ?? "" });
104
- };
@@ -18,18 +18,6 @@
18
18
  * You should have received a copy of the GNU Lesser General Public License
19
19
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
20
  */
21
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
22
- if (kind === "m") throw new TypeError("Private method is not writable");
23
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
24
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
25
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
26
- };
27
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
28
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
29
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
30
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
31
- };
32
- var _BusinessConnectionManager_c;
33
21
  Object.defineProperty(exports, "__esModule", { value: true });
34
22
  exports.BusinessConnectionManager = void 0;
35
23
  const _2_tl_js_1 = require("../2_tl.js");
@@ -38,21 +26,21 @@ const businessConnectionManagerUpdates = [
38
26
  "updateBotBusinessConnect",
39
27
  ];
40
28
  class BusinessConnectionManager {
29
+ #c;
41
30
  constructor(c) {
42
- _BusinessConnectionManager_c.set(this, void 0);
43
- __classPrivateFieldSet(this, _BusinessConnectionManager_c, c, "f");
31
+ this.#c = c;
44
32
  }
45
33
  async getBusinessConnection(id) {
46
- const connection_ = await __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").messageStorage.getBusinessConnection(id);
34
+ const connection_ = await this.#c.messageStorage.getBusinessConnection(id);
47
35
  if (!connection_) {
48
- const connection_ = await __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").invoke({ _: "account.getBotBusinessConnection", connection_id: id })
36
+ const connection_ = await this.#c.invoke({ _: "account.getBotBusinessConnection", connection_id: id })
49
37
  .then((v) => _2_tl_js_1.Api.as("updates", v))
50
38
  .then((v) => _2_tl_js_1.Api.as("updateBotBusinessConnect", v.updates[0]).connection);
51
- await __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").messageStorage.setBusinessConnection(id, connection_);
52
- return (0, _3_types_js_1.constructBusinessConnection)(connection_, __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").getPeer);
39
+ await this.#c.messageStorage.setBusinessConnection(id, connection_);
40
+ return (0, _3_types_js_1.constructBusinessConnection)(connection_, this.#c.getPeer);
53
41
  }
54
42
  else {
55
- return (0, _3_types_js_1.constructBusinessConnection)(connection_, __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").getPeer);
43
+ return (0, _3_types_js_1.constructBusinessConnection)(connection_, this.#c.getPeer);
56
44
  }
57
45
  }
58
46
  canHandleUpdate(update) {
@@ -60,14 +48,13 @@ class BusinessConnectionManager {
60
48
  }
61
49
  async handleUpdate(update) {
62
50
  if (update.connection.disabled) {
63
- await __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").messageStorage.setBusinessConnection(update.connection.connection_id, null);
51
+ await this.#c.messageStorage.setBusinessConnection(update.connection.connection_id, null);
64
52
  }
65
53
  else {
66
- await __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").messageStorage.setBusinessConnection(update.connection.connection_id, update.connection);
54
+ await this.#c.messageStorage.setBusinessConnection(update.connection.connection_id, update.connection);
67
55
  }
68
- const businessConnection = (0, _3_types_js_1.constructBusinessConnection)(update.connection, __classPrivateFieldGet(this, _BusinessConnectionManager_c, "f").getPeer);
56
+ const businessConnection = (0, _3_types_js_1.constructBusinessConnection)(update.connection, this.#c.getPeer);
69
57
  return { businessConnection };
70
58
  }
71
59
  }
72
60
  exports.BusinessConnectionManager = BusinessConnectionManager;
73
- _BusinessConnectionManager_c = new WeakMap();