@mtkruto/browser 0.119.0 → 0.119.1

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 (127) hide show
  1. package/esm/0_errors.d.ts.map +1 -1
  2. package/esm/0_errors.js +9 -31
  3. package/esm/3_errors.js +2 -12
  4. package/esm/4_errors.js +2 -12
  5. package/esm/_dnt.polyfills.d.ts +0 -99
  6. package/esm/_dnt.polyfills.d.ts.map +1 -1
  7. package/esm/_dnt.polyfills.js +1 -127
  8. package/esm/client/0_abortable_loop.js +26 -39
  9. package/esm/client/0_storage_operations.js +179 -218
  10. package/esm/client/1_client_plain.js +4 -22
  11. package/esm/client/2_account_manager.js +140 -149
  12. package/esm/client/2_bot_info_manager.js +26 -38
  13. package/esm/client/2_business_connection_manager.js +10 -23
  14. package/esm/client/2_client_encrypted.js +198 -215
  15. package/esm/client/2_file_manager.js +255 -262
  16. package/esm/client/2_network_statistics_manager.js +31 -44
  17. package/esm/client/2_payment_manager.js +7 -20
  18. package/esm/client/2_reaction_manager.js +7 -20
  19. package/esm/client/2_translations_manager.js +101 -111
  20. package/esm/client/2_update_manager.js +750 -745
  21. package/esm/client/3_client_encrypted_pool.js +10 -26
  22. package/esm/client/3_message_manager.js +503 -508
  23. package/esm/client/3_video_chat_manager.js +57 -68
  24. package/esm/client/4_callback_query_manager.js +18 -30
  25. package/esm/client/4_chat_list_manager.js +140 -146
  26. package/esm/client/4_chat_manager.js +161 -169
  27. package/esm/client/4_checklist_manager.js +26 -39
  28. package/esm/client/4_context.js +244 -259
  29. package/esm/client/4_forum_manager.js +67 -73
  30. package/esm/client/4_gift_manager.js +22 -35
  31. package/esm/client/4_inline_query_manager.js +16 -28
  32. package/esm/client/4_link_preview_manager.js +6 -19
  33. package/esm/client/4_poll_manager.js +44 -57
  34. package/esm/client/4_story_manager.js +41 -53
  35. package/esm/client/5_composer.js +13 -26
  36. package/esm/client/6_client.js +866 -896
  37. package/esm/client/6_client_dispatcher.js +308 -325
  38. package/esm/client/7_client_worker.js +16 -29
  39. package/esm/connection/1_connection_tcp.js +55 -82
  40. package/esm/connection/1_connection_web_socket.js +75 -91
  41. package/esm/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
  42. package/esm/deps/jsr.io/@std/async/1.2.0/mux_async_iterator.js +31 -47
  43. package/esm/deps/jsr.io/@std/async/1.2.0/tee.js +11 -34
  44. package/esm/deps/jsr.io/@std/cache/0.2.2/lru_cache.js +30 -47
  45. package/esm/deps/jsr.io/@std/datetime/0.225.7/_date_time_formatter.js +4 -17
  46. package/esm/session/0_session_state.js +12 -38
  47. package/esm/session/1_session.js +49 -72
  48. package/esm/session/2_session_encrypted.js +422 -420
  49. package/esm/storage/2_storage_indexed_db.js +26 -44
  50. package/esm/storage/2_storage_local_storage.js +3 -16
  51. package/esm/storage/2_storage_memory.js +24 -41
  52. package/esm/storage/2_storage_session_storage.js +3 -16
  53. package/esm/tl/1_tl_reader.d.ts +1 -1
  54. package/esm/tl/1_tl_reader.d.ts.map +1 -1
  55. package/esm/tl/1_tl_reader.js +95 -103
  56. package/esm/tl/1_tl_writer.js +169 -178
  57. package/esm/transport/0_transport.js +1 -8
  58. package/esm/transport/1_transport_abridged.js +11 -24
  59. package/esm/transport/1_transport_intermediate.js +10 -23
  60. package/esm/utilities/0_mutex.js +4 -19
  61. package/esm/utilities/0_part_stream.js +11 -25
  62. package/esm/utilities/1_crypto.js +42 -53
  63. package/esm/utilities/2_queue.js +29 -47
  64. package/package.json +1 -1
  65. package/script/0_errors.d.ts.map +1 -1
  66. package/script/0_errors.js +9 -31
  67. package/script/3_errors.js +2 -12
  68. package/script/4_errors.js +2 -12
  69. package/script/_dnt.polyfills.d.ts +0 -99
  70. package/script/_dnt.polyfills.d.ts.map +1 -1
  71. package/script/_dnt.polyfills.js +0 -128
  72. package/script/client/0_abortable_loop.js +27 -40
  73. package/script/client/0_storage_operations.js +179 -218
  74. package/script/client/1_client_plain.js +4 -22
  75. package/script/client/2_account_manager.js +140 -149
  76. package/script/client/2_bot_info_manager.js +26 -38
  77. package/script/client/2_business_connection_manager.js +10 -23
  78. package/script/client/2_client_encrypted.js +199 -216
  79. package/script/client/2_file_manager.js +255 -262
  80. package/script/client/2_network_statistics_manager.js +32 -45
  81. package/script/client/2_payment_manager.js +7 -20
  82. package/script/client/2_reaction_manager.js +7 -20
  83. package/script/client/2_translations_manager.js +102 -112
  84. package/script/client/2_update_manager.js +750 -745
  85. package/script/client/3_client_encrypted_pool.js +10 -26
  86. package/script/client/3_message_manager.js +503 -508
  87. package/script/client/3_video_chat_manager.js +57 -68
  88. package/script/client/4_callback_query_manager.js +18 -30
  89. package/script/client/4_chat_list_manager.js +140 -146
  90. package/script/client/4_chat_manager.js +161 -169
  91. package/script/client/4_checklist_manager.js +26 -39
  92. package/script/client/4_context.js +244 -259
  93. package/script/client/4_forum_manager.js +67 -73
  94. package/script/client/4_gift_manager.js +22 -35
  95. package/script/client/4_inline_query_manager.js +16 -28
  96. package/script/client/4_link_preview_manager.js +6 -19
  97. package/script/client/4_poll_manager.js +44 -57
  98. package/script/client/4_story_manager.js +41 -53
  99. package/script/client/5_composer.js +13 -26
  100. package/script/client/6_client.js +866 -896
  101. package/script/client/6_client_dispatcher.js +308 -325
  102. package/script/client/7_client_worker.js +16 -29
  103. package/script/connection/1_connection_tcp.js +55 -82
  104. package/script/connection/1_connection_web_socket.js +75 -91
  105. package/script/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
  106. package/script/deps/jsr.io/@std/async/1.2.0/mux_async_iterator.js +31 -47
  107. package/script/deps/jsr.io/@std/async/1.2.0/tee.js +11 -34
  108. package/script/deps/jsr.io/@std/cache/0.2.2/lru_cache.js +30 -47
  109. package/script/deps/jsr.io/@std/datetime/0.225.7/_date_time_formatter.js +4 -17
  110. package/script/session/0_session_state.js +12 -38
  111. package/script/session/1_session.js +49 -72
  112. package/script/session/2_session_encrypted.js +423 -421
  113. package/script/storage/2_storage_indexed_db.js +26 -44
  114. package/script/storage/2_storage_local_storage.js +3 -16
  115. package/script/storage/2_storage_memory.js +24 -41
  116. package/script/storage/2_storage_session_storage.js +3 -16
  117. package/script/tl/1_tl_reader.d.ts +1 -1
  118. package/script/tl/1_tl_reader.d.ts.map +1 -1
  119. package/script/tl/1_tl_reader.js +96 -104
  120. package/script/tl/1_tl_writer.js +170 -179
  121. package/script/transport/0_transport.js +1 -8
  122. package/script/transport/1_transport_abridged.js +11 -24
  123. package/script/transport/1_transport_intermediate.js +10 -23
  124. package/script/utilities/0_mutex.js +4 -19
  125. package/script/utilities/0_part_stream.js +11 -25
  126. package/script/utilities/1_crypto.js +43 -54
  127. package/script/utilities/2_queue.js +30 -48
@@ -17,49 +17,35 @@
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 _PartStream_buffer, _PartStream_totalRead, _PartStream_part;
32
20
  import { concat } from "../0_deps.js";
33
21
  export class PartStream extends TransformStream {
22
+ #buffer = new Uint8Array();
23
+ #totalRead = 0;
24
+ #part = 0;
34
25
  constructor(chunkSize) {
35
26
  super({
36
27
  transform: (chunk, controller) => {
37
- var _a, _b;
38
- __classPrivateFieldSet(this, _PartStream_totalRead, __classPrivateFieldGet(this, _PartStream_totalRead, "f") + chunk.byteLength, "f");
39
- chunk = concat([__classPrivateFieldGet(this, _PartStream_buffer, "f"), chunk]);
28
+ this.#totalRead += chunk.byteLength;
29
+ chunk = concat([this.#buffer, chunk]);
40
30
  while (chunk.byteLength > chunkSize) {
41
31
  controller.enqueue({
42
32
  isSmall: false,
43
- part: (__classPrivateFieldSet(this, _PartStream_part, (_b = __classPrivateFieldGet(this, _PartStream_part, "f"), _a = _b++, _b), "f"), _a),
33
+ part: this.#part++,
44
34
  totalParts: -1,
45
35
  bytes: chunk.slice(0, chunkSize),
46
36
  });
47
37
  chunk = chunk.slice(chunkSize);
48
38
  }
49
- __classPrivateFieldSet(this, _PartStream_buffer, chunk, "f");
39
+ this.#buffer = chunk;
50
40
  },
51
41
  flush: (controller) => {
52
42
  controller.enqueue({
53
- isSmall: __classPrivateFieldGet(this, _PartStream_totalRead, "f") <= chunkSize,
54
- part: __classPrivateFieldGet(this, _PartStream_part, "f"),
55
- totalParts: Math.ceil(__classPrivateFieldGet(this, _PartStream_totalRead, "f") / chunkSize),
56
- bytes: __classPrivateFieldGet(this, _PartStream_buffer, "f"),
43
+ isSmall: this.#totalRead <= chunkSize,
44
+ part: this.#part,
45
+ totalParts: Math.ceil(this.#totalRead / chunkSize),
46
+ bytes: this.#buffer,
57
47
  });
58
48
  },
59
49
  });
60
- _PartStream_buffer.set(this, new Uint8Array());
61
- _PartStream_totalRead.set(this, 0);
62
- _PartStream_part.set(this, 0);
63
50
  }
64
51
  }
65
- _PartStream_buffer = new WeakMap(), _PartStream_totalRead = new WeakMap(), _PartStream_part = new WeakMap();
@@ -17,74 +17,63 @@
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 _CTR_instances, _CTR_key, _CTR_iv, _CTR_bytesUntilNextBlock, _CTR_promise, _CTR_call, _CTR_encrypt, _CTR_increaseIv;
32
20
  import { concat } from "../0_deps.js";
33
21
  import { intFromBytes, intToBytes } from "./0_int.js";
34
22
  export class CTR {
23
+ #key;
24
+ #iv;
25
+ #bytesUntilNextBlock = 0;
26
+ #promise;
35
27
  get _state() {
36
- return { iv: new Uint8Array(__classPrivateFieldGet(this, _CTR_iv, "f")), state: __classPrivateFieldGet(this, _CTR_bytesUntilNextBlock, "f") };
28
+ return { iv: new Uint8Array(this.#iv), state: this.#bytesUntilNextBlock };
37
29
  }
38
30
  constructor(key, iv) {
39
- _CTR_instances.add(this);
40
- _CTR_key.set(this, void 0);
41
- _CTR_iv.set(this, void 0);
42
- _CTR_bytesUntilNextBlock.set(this, 0);
43
- _CTR_promise.set(this, void 0);
44
- __classPrivateFieldSet(this, _CTR_key, key, "f");
45
- __classPrivateFieldSet(this, _CTR_iv, iv, "f");
31
+ this.#key = key;
32
+ this.#iv = iv;
46
33
  }
47
34
  static async importKey(key) {
48
35
  return await crypto.subtle.importKey("raw", key, "AES-CTR", false, ["encrypt"]);
49
36
  }
50
37
  async call(data) {
51
- if (__classPrivateFieldGet(this, _CTR_promise, "f")) {
52
- await Promise.allSettled([__classPrivateFieldGet(this, _CTR_promise, "f")]);
38
+ if (this.#promise) {
39
+ await Promise.allSettled([this.#promise]);
53
40
  }
54
- return await (__classPrivateFieldSet(this, _CTR_promise, __classPrivateFieldGet(this, _CTR_instances, "m", _CTR_call).call(this, data), "f"));
41
+ return await (this.#promise = this.#call(data));
55
42
  }
56
- }
57
- _CTR_key = new WeakMap(), _CTR_iv = new WeakMap(), _CTR_bytesUntilNextBlock = new WeakMap(), _CTR_promise = new WeakMap(), _CTR_instances = new WeakSet(), _CTR_call = async function _CTR_call(data) {
58
- let header;
59
- if (__classPrivateFieldGet(this, _CTR_bytesUntilNextBlock, "f")) {
60
- const headerLength = Math.min(data.length, __classPrivateFieldGet(this, _CTR_iv, "f").length - __classPrivateFieldGet(this, _CTR_bytesUntilNextBlock, "f"));
61
- const encrypted = await __classPrivateFieldGet(this, _CTR_instances, "m", _CTR_encrypt).call(this, concat([new Uint8Array(__classPrivateFieldGet(this, _CTR_bytesUntilNextBlock, "f")), data.subarray(0, headerLength)]));
62
- header = encrypted.subarray(__classPrivateFieldGet(this, _CTR_bytesUntilNextBlock, "f"));
63
- data = data.subarray(headerLength);
64
- if (encrypted.length === __classPrivateFieldGet(this, _CTR_iv, "f").length) {
65
- __classPrivateFieldGet(this, _CTR_instances, "m", _CTR_increaseIv).call(this, 1);
66
- __classPrivateFieldSet(this, _CTR_bytesUntilNextBlock, 0, "f");
43
+ async #call(data) {
44
+ let header;
45
+ if (this.#bytesUntilNextBlock) {
46
+ const headerLength = Math.min(data.length, this.#iv.length - this.#bytesUntilNextBlock);
47
+ const encrypted = await this.#encrypt(concat([new Uint8Array(this.#bytesUntilNextBlock), data.subarray(0, headerLength)]));
48
+ header = encrypted.subarray(this.#bytesUntilNextBlock);
49
+ data = data.subarray(headerLength);
50
+ if (encrypted.length === this.#iv.length) {
51
+ this.#increaseIv(1);
52
+ this.#bytesUntilNextBlock = 0;
53
+ }
54
+ else {
55
+ this.#bytesUntilNextBlock += headerLength;
56
+ }
67
57
  }
68
- else {
69
- __classPrivateFieldSet(this, _CTR_bytesUntilNextBlock, __classPrivateFieldGet(this, _CTR_bytesUntilNextBlock, "f") + headerLength, "f");
58
+ if (!data.length && header) {
59
+ return header;
70
60
  }
61
+ const encrypted = await this.#encrypt(data);
62
+ this.#bytesUntilNextBlock = encrypted.length % this.#iv.length;
63
+ this.#increaseIv((encrypted.length - this.#bytesUntilNextBlock) / this.#iv.length);
64
+ return header ? concat([header, encrypted]) : encrypted;
71
65
  }
72
- if (!data.length && header) {
73
- return header;
66
+ async #encrypt(data) {
67
+ return new Uint8Array(await crypto.subtle.encrypt({
68
+ name: "AES-CTR",
69
+ counter: new Uint8Array(this.#iv),
70
+ length: this.#iv.length * 8,
71
+ }, this.#key, data));
74
72
  }
75
- const encrypted = await __classPrivateFieldGet(this, _CTR_instances, "m", _CTR_encrypt).call(this, data);
76
- __classPrivateFieldSet(this, _CTR_bytesUntilNextBlock, encrypted.length % __classPrivateFieldGet(this, _CTR_iv, "f").length, "f");
77
- __classPrivateFieldGet(this, _CTR_instances, "m", _CTR_increaseIv).call(this, (encrypted.length - __classPrivateFieldGet(this, _CTR_bytesUntilNextBlock, "f")) / __classPrivateFieldGet(this, _CTR_iv, "f").length);
78
- return header ? concat([header, encrypted]) : encrypted;
79
- }, _CTR_encrypt = async function _CTR_encrypt(data) {
80
- return new Uint8Array(await crypto.subtle.encrypt({
81
- name: "AES-CTR",
82
- counter: new Uint8Array(__classPrivateFieldGet(this, _CTR_iv, "f")),
83
- length: __classPrivateFieldGet(this, _CTR_iv, "f").length * 8,
84
- }, __classPrivateFieldGet(this, _CTR_key, "f"), data));
85
- }, _CTR_increaseIv = function _CTR_increaseIv(amount) {
86
- if (amount < 1) {
87
- return;
73
+ #increaseIv(amount) {
74
+ if (amount < 1) {
75
+ return;
76
+ }
77
+ this.#iv = intToBytes(intFromBytes(this.#iv, { byteOrder: "big", isSigned: false }) + BigInt(amount), this.#iv.length, { byteOrder: "big", isSigned: false });
88
78
  }
89
- __classPrivateFieldSet(this, _CTR_iv, intToBytes(intFromBytes(__classPrivateFieldGet(this, _CTR_iv, "f"), { byteOrder: "big", isSigned: false }) + BigInt(amount), __classPrivateFieldGet(this, _CTR_iv, "f").length, { byteOrder: "big", isSigned: false }), "f");
90
- };
79
+ }
@@ -17,60 +17,42 @@
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 _Queue_instances, _Queue_logger, _Queue_throw, _Queue_busy, _Queue_check;
32
20
  import { getLogger } from "./1_logger.js";
33
21
  export class Queue {
22
+ #logger;
23
+ functions = new Array();
24
+ #throw;
34
25
  constructor(name, throw_ = false) {
35
- _Queue_instances.add(this);
36
- _Queue_logger.set(this, void 0);
37
- Object.defineProperty(this, "functions", {
38
- enumerable: true,
39
- configurable: true,
40
- writable: true,
41
- value: new Array()
42
- });
43
- _Queue_throw.set(this, void 0);
44
- _Queue_busy.set(this, false);
45
- __classPrivateFieldSet(this, _Queue_logger, getLogger(`q/${name}`), "f");
46
- __classPrivateFieldSet(this, _Queue_throw, throw_, "f");
26
+ this.#logger = getLogger(`q/${name}`);
27
+ this.#throw = throw_;
47
28
  }
48
29
  add(fn) {
49
30
  this.functions.push(fn);
50
- __classPrivateFieldGet(this, _Queue_instances, "m", _Queue_check).call(this);
31
+ this.#check();
51
32
  }
52
- }
53
- _Queue_logger = new WeakMap(), _Queue_throw = new WeakMap(), _Queue_busy = new WeakMap(), _Queue_instances = new WeakSet(), _Queue_check = function _Queue_check() {
54
- if (__classPrivateFieldGet(this, _Queue_busy, "f")) {
55
- return;
56
- }
57
- else {
58
- __classPrivateFieldSet(this, _Queue_busy, true, "f");
59
- }
60
- const fn = this.functions.shift();
61
- if (fn !== undefined) {
62
- const promise = fn()
63
- .finally(() => {
64
- __classPrivateFieldSet(this, _Queue_busy, false, "f");
65
- __classPrivateFieldGet(this, _Queue_instances, "m", _Queue_check).call(this);
66
- });
67
- if (!__classPrivateFieldGet(this, _Queue_throw, "f")) {
68
- promise.catch((err) => {
69
- __classPrivateFieldGet(this, _Queue_logger, "f").error((typeof err === "object" && err !== null && "stack" in err) ? err.stack : err);
33
+ #busy = false;
34
+ #check() {
35
+ if (this.#busy) {
36
+ return;
37
+ }
38
+ else {
39
+ this.#busy = true;
40
+ }
41
+ const fn = this.functions.shift();
42
+ if (fn !== undefined) {
43
+ const promise = fn()
44
+ .finally(() => {
45
+ this.#busy = false;
46
+ this.#check();
70
47
  });
48
+ if (!this.#throw) {
49
+ promise.catch((err) => {
50
+ this.#logger.error((typeof err === "object" && err !== null && "stack" in err) ? err.stack : err);
51
+ });
52
+ }
53
+ }
54
+ else {
55
+ this.#busy = false;
71
56
  }
72
57
  }
73
- else {
74
- __classPrivateFieldSet(this, _Queue_busy, false, "f");
75
- }
76
- };
58
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mtkruto/browser",
3
- "version": "0.119.0",
3
+ "version": "0.119.1",
4
4
  "description": "MTKruto for browsers",
5
5
  "author": "Roj <rojvv@icloud.com>",
6
6
  "repository": {
@@ -1 +1 @@
1
- {"version":3,"file":"0_errors.d.ts","sourceRoot":"","sources":["../src/0_errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,8BAAsB,YAAa,SAAQ,KAAK;CAC/C;AAED,qBAAa,eAAgB,SAAQ,YAAY;gBACnC,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,KAAK,CAAC;CAIzD;AAED,qBAAa,WAAY,SAAQ,YAAY;gBAC/B,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,KAAK,CAAC;CAIzD;AAED,qBAAa,UAAW,SAAQ,YAAY;gBAC9B,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,KAAK,CAAC;CAIzD;AAED,qBAAa,cAAe,SAAQ,YAAY;aAClB,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM;CAIzC;AAED,qBAAa,OAAQ,SAAQ,YAAY;;IAC9B,IAAI,SAAa;gBAId,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;IAM3C,IAAI,eAAe,IAAI,MAAM,CAE5B;IAED,IAAI,IAAI,IAAI,MAAM,EAAE,CAEnB;CACF"}
1
+ {"version":3,"file":"0_errors.d.ts","sourceRoot":"","sources":["../src/0_errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,8BAAsB,YAAa,SAAQ,KAAK;CAC/C;AAED,qBAAa,eAAgB,SAAQ,YAAY;gBACnC,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,KAAK,CAAC;CAIzD;AAED,qBAAa,WAAY,SAAQ,YAAY;gBAC/B,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,KAAK,CAAC;CAIzD;AAED,qBAAa,UAAW,SAAQ,YAAY;gBAC9B,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,KAAK,CAAC;CAIzD;AAED,qBAAa,cAAe,SAAQ,YAAY;IAC9C,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEjB,IAAI,EAAE,MAAM;CAKzB;AAED,qBAAa,OAAQ,SAAQ,YAAY;;IAC9B,IAAI,SAAa;gBAId,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;IAM3C,IAAI,eAAe,IAAI,MAAM,CAE5B;IAED,IAAI,IAAI,IAAI,MAAM,EAAE,CAEnB;CACF"}
@@ -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 _TLError_originalMessage, _TLError_path;
33
21
  Object.defineProperty(exports, "__esModule", { value: true });
34
22
  exports.TLError = exports.TransportError = exports.InputError = exports.AccessError = exports.ConnectionError = exports.MtkrutoError = void 0;
35
23
  class MtkrutoError extends Error {
@@ -57,38 +45,28 @@ class InputError extends MtkrutoError {
57
45
  }
58
46
  exports.InputError = InputError;
59
47
  class TransportError extends MtkrutoError {
48
+ code;
60
49
  constructor(code) {
61
50
  super(`Transport error: ${code}`);
62
- Object.defineProperty(this, "code", {
63
- enumerable: true,
64
- configurable: true,
65
- writable: true,
66
- value: code
67
- });
68
51
  this.name = "TransportError";
52
+ this.code = code;
69
53
  }
70
54
  }
71
55
  exports.TransportError = TransportError;
72
56
  class TLError extends MtkrutoError {
57
+ name = "TLError";
58
+ #originalMessage;
59
+ #path;
73
60
  constructor(message, path) {
74
61
  super(`${message}${path.length ? ` at ${path.join(" ")}` : ""}`);
75
- Object.defineProperty(this, "name", {
76
- enumerable: true,
77
- configurable: true,
78
- writable: true,
79
- value: "TLError"
80
- });
81
- _TLError_originalMessage.set(this, void 0);
82
- _TLError_path.set(this, void 0);
83
- __classPrivateFieldSet(this, _TLError_originalMessage, message, "f");
84
- __classPrivateFieldSet(this, _TLError_path, path, "f");
62
+ this.#originalMessage = message;
63
+ this.#path = path;
85
64
  }
86
65
  get originalMessage() {
87
- return __classPrivateFieldGet(this, _TLError_originalMessage, "f");
66
+ return this.#originalMessage;
88
67
  }
89
68
  get path() {
90
- return __classPrivateFieldGet(this, _TLError_path, "f");
69
+ return this.#path;
91
70
  }
92
71
  }
93
72
  exports.TLError = TLError;
94
- _TLError_originalMessage = new WeakMap(), _TLError_path = new WeakMap();
@@ -48,20 +48,10 @@ const _0_errors_js_1 = require("./0_errors.js");
48
48
  const _2_tl_js_1 = require("./2_tl.js");
49
49
  __exportStar(require("./0_errors.js"), exports);
50
50
  class TelegramError extends _0_errors_js_1.MtkrutoError {
51
+ errorCode;
52
+ errorMessage;
51
53
  constructor(params) {
52
54
  super(`${params.error_code}: ${params.error_message} (${(0, _2_tl_js_1.repr)(params.call)})`);
53
- Object.defineProperty(this, "errorCode", {
54
- enumerable: true,
55
- configurable: true,
56
- writable: true,
57
- value: void 0
58
- });
59
- Object.defineProperty(this, "errorMessage", {
60
- enumerable: true,
61
- configurable: true,
62
- writable: true,
63
- value: void 0
64
- });
65
55
  this.name = "TelegramError";
66
56
  this.errorCode = params.error_code;
67
57
  this.errorMessage = params.error_message;
@@ -39,14 +39,9 @@ const _0_deps_js_1 = require("./0_deps.js");
39
39
  const _3_errors_js_1 = require("./3_errors.js");
40
40
  __exportStar(require("./3_errors.js"), exports);
41
41
  class FloodWait extends _3_errors_js_1.TelegramError {
42
+ seconds;
42
43
  constructor(params) {
43
44
  super(params);
44
- Object.defineProperty(this, "seconds", {
45
- enumerable: true,
46
- configurable: true,
47
- writable: true,
48
- value: void 0
49
- });
50
45
  const p = params.error_message.split("_");
51
46
  this.seconds = Number(p[p.length - 1]);
52
47
  if (isNaN(this.seconds)) {
@@ -56,14 +51,9 @@ class FloodWait extends _3_errors_js_1.TelegramError {
56
51
  }
57
52
  exports.FloodWait = FloodWait;
58
53
  class Migrate extends _3_errors_js_1.TelegramError {
54
+ dc;
59
55
  constructor(params) {
60
56
  super(params);
61
- Object.defineProperty(this, "dc", {
62
- enumerable: true,
63
- configurable: true,
64
- writable: true,
65
- value: void 0
66
- });
67
57
  const p = params.error_message.split("_");
68
58
  this.dc = Number(p[p.length - 1]);
69
59
  if (isNaN(this.dc)) {
@@ -24,103 +24,4 @@ declare global {
24
24
  }
25
25
  }
26
26
  export {};
27
- /**
28
- * Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
29
- * but instead of using npm to install additional dependencies,
30
- * this approach manually consolidates cjs/mjs/d.ts into a single file.
31
- *
32
- * Note that this code might be imported multiple times
33
- * (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
34
- * or Node.js might dynamically clear the cache and then force a require).
35
- * Therefore, it's important to avoid redundant writes to global objects.
36
- * Additionally, consider that commonjs is used alongside esm,
37
- * so the two ponyfill functions are stored independently in two separate global objects.
38
- */
39
- import { createRequire } from "node:module";
40
- import { type URL } from "node:url";
41
- declare global {
42
- interface ImportMeta {
43
- /** A string representation of the fully qualified module URL. When the
44
- * module is loaded locally, the value will be a file URL (e.g.
45
- * `file:///path/module.ts`).
46
- *
47
- * You can also parse the string as a URL to determine more information about
48
- * how the current module was loaded. For example to determine if a module was
49
- * local or not:
50
- *
51
- * ```ts
52
- * const url = new URL(import.meta.url);
53
- * if (url.protocol === "file:") {
54
- * console.log("this module was loaded locally");
55
- * }
56
- * ```
57
- */
58
- url: string;
59
- /**
60
- * A function that returns resolved specifier as if it would be imported
61
- * using `import(specifier)`.
62
- *
63
- * ```ts
64
- * console.log(import.meta.resolve("./foo.js"));
65
- * // file:///dev/foo.js
66
- * ```
67
- *
68
- * @param specifier The module specifier to resolve relative to `parent`.
69
- * @param parent The absolute parent module URL to resolve from.
70
- * @returns The absolute (`file:`) URL string for the resolved module.
71
- */
72
- resolve(specifier: string, parent?: string | URL | undefined): string;
73
- /** A flag that indicates if the current module is the main module that was
74
- * called when starting the program under Deno.
75
- *
76
- * ```ts
77
- * if (import.meta.main) {
78
- * // this was loaded as the main module, maybe do some bootstrapping
79
- * }
80
- * ```
81
- */
82
- main: boolean;
83
- /** The absolute path of the current module.
84
- *
85
- * This property is only provided for local modules (ie. using `file://` URLs).
86
- *
87
- * Example:
88
- * ```
89
- * // Unix
90
- * console.log(import.meta.filename); // /home/alice/my_module.ts
91
- *
92
- * // Windows
93
- * console.log(import.meta.filename); // C:\alice\my_module.ts
94
- * ```
95
- */
96
- filename: string;
97
- /** The absolute path of the directory containing the current module.
98
- *
99
- * This property is only provided for local modules (ie. using `file://` URLs).
100
- *
101
- * * Example:
102
- * ```
103
- * // Unix
104
- * console.log(import.meta.dirname); // /home/alice
105
- *
106
- * // Windows
107
- * console.log(import.meta.dirname); // C:\alice
108
- * ```
109
- */
110
- dirname: string;
111
- }
112
- }
113
- type NodeRequest = ReturnType<typeof createRequire>;
114
- type NodeModule = NonNullable<NodeRequest["main"]>;
115
- interface ImportMetaPonyfillCommonjs {
116
- (require: NodeRequest, module: NodeModule): ImportMeta;
117
- }
118
- interface ImportMetaPonyfillEsmodule {
119
- (importMeta: ImportMeta): ImportMeta;
120
- }
121
- interface ImportMetaPonyfill extends ImportMetaPonyfillCommonjs, ImportMetaPonyfillEsmodule {
122
- }
123
- export declare let import_meta_ponyfill_commonjs: ImportMetaPonyfillCommonjs;
124
- export declare let import_meta_ponyfill_esmodule: ImportMetaPonyfillEsmodule;
125
- export declare let import_meta_ponyfill: ImportMetaPonyfill;
126
27
  //# sourceMappingURL=_dnt.polyfills.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,kBAAkB;QAC1B;;;WAGG;QACH,aAAa,CAAC,CAAC,KAAK;YAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;YAAC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;YAAC,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAA;SAAE,CAAC;KAC3H;CACF;AAcD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,gBAAgB;QACxB,SAAS,CAAC,CAAC,EACP,mBAAmB,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAC7F,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;QAEhB,SAAS,CAAC,CAAC,EAAE,CAAC,EACV,mBAAmB,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,EAClE,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,EAC/B,OAAO,CAAC,EAAE,GAAG,GACd,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;KAC1B;CACF;AAoID,OAAO,EAAE,CAAC;AAAA,OAAO,CAAC,MAAM,CAAC;IACvB,UAAU,K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