@mtkruto/node 0.1.100 → 0.1.102

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 (197) hide show
  1. package/esm/0_deps.d.ts +3 -3
  2. package/esm/0_deps.js +3 -3
  3. package/esm/4_constants.d.ts +1 -1
  4. package/esm/4_constants.js +1 -1
  5. package/esm/client/0_message.js +3 -9
  6. package/esm/client/3_types.d.ts +2 -0
  7. package/esm/client/4_client.d.ts +55 -4
  8. package/esm/client/4_client.js +260 -72
  9. package/esm/connection/1_connection_web_socket.js +5 -2
  10. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_diff.js +10 -3
  11. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_false.js +1 -0
  12. package/esm/deps/deno.land/std@0.204.0/encoding/_util.d.ts +1 -0
  13. package/esm/deps/deno.land/std@0.204.0/encoding/_util.js +26 -0
  14. package/esm/deps/deno.land/std@0.204.0/encoding/base64.d.ts +23 -0
  15. package/{script/deps/deno.land/std@0.201.0 → esm/deps/deno.land/std@0.204.0}/encoding/base64.js +23 -18
  16. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/fmt/colors.js +1 -1
  17. package/esm/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/mod.js +10 -4
  18. package/esm/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +324 -0
  19. package/esm/tl/6_message.d.ts +1 -0
  20. package/esm/tl/6_message.js +1 -2
  21. package/esm/tl/6_message_test.d.ts +1 -0
  22. package/esm/transport/0_obfuscation.js +3 -3
  23. package/esm/transport/0_transport.d.ts +2 -2
  24. package/esm/transport/0_transport.js +2 -8
  25. package/esm/transport/1_transport_abridged.js +9 -7
  26. package/esm/transport/1_transport_intermediate.js +7 -3
  27. package/esm/types/3_message.d.ts +4 -0
  28. package/esm/types/3_message.js +4 -1
  29. package/esm/utilities/0_bigint.d.ts +1 -0
  30. package/esm/utilities/0_bigint.js +2 -0
  31. package/esm/utilities/0_crypto.d.ts +1 -1
  32. package/esm/utilities/0_crypto.js +1 -3
  33. package/esm/utilities/0_queue.js +1 -1
  34. package/package.json +1 -1
  35. package/script/0_deps.d.ts +3 -3
  36. package/script/0_deps.js +3 -3
  37. package/script/4_constants.d.ts +1 -1
  38. package/script/4_constants.js +1 -1
  39. package/script/client/0_message.js +2 -8
  40. package/script/client/3_types.d.ts +2 -0
  41. package/script/client/4_client.d.ts +55 -4
  42. package/script/client/4_client.js +260 -71
  43. package/script/connection/1_connection_web_socket.js +5 -2
  44. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_diff.js +10 -3
  45. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_false.js +1 -0
  46. package/script/deps/deno.land/std@0.204.0/encoding/_util.d.ts +1 -0
  47. package/script/deps/deno.land/std@0.204.0/encoding/_util.js +30 -0
  48. package/script/deps/deno.land/std@0.204.0/encoding/base64.d.ts +23 -0
  49. package/{esm/deps/deno.land/std@0.201.0 → script/deps/deno.land/std@0.204.0}/encoding/base64.js +28 -13
  50. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/fmt/colors.js +1 -1
  51. package/script/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/mod.js +10 -4
  52. package/script/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +326 -0
  53. package/script/tl/6_message.d.ts +1 -0
  54. package/script/tl/6_message.js +2 -2
  55. package/script/tl/6_message_test.d.ts +1 -0
  56. package/script/transport/0_obfuscation.js +3 -3
  57. package/script/transport/0_transport.d.ts +2 -2
  58. package/script/transport/0_transport.js +2 -8
  59. package/script/transport/1_transport_abridged.js +9 -7
  60. package/script/transport/1_transport_intermediate.js +7 -3
  61. package/script/types/3_message.d.ts +4 -0
  62. package/script/types/3_message.js +4 -1
  63. package/script/utilities/0_bigint.d.ts +1 -0
  64. package/script/utilities/0_bigint.js +2 -0
  65. package/script/utilities/0_crypto.d.ts +1 -1
  66. package/script/utilities/0_crypto.js +1 -3
  67. package/script/utilities/0_queue.js +1 -1
  68. package/esm/deps/deno.land/std@0.201.0/encoding/base64.d.ts +0 -11
  69. package/esm/deps/deno.land/x/tgcrypto@0.3.2/tgcrypto.js +0 -308
  70. package/script/deps/deno.land/std@0.201.0/encoding/base64.d.ts +0 -11
  71. package/script/deps/deno.land/x/tgcrypto@0.3.2/tgcrypto.js +0 -310
  72. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_constants.d.ts +0 -0
  73. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_constants.js +0 -0
  74. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_diff.d.ts +0 -0
  75. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_format.d.ts +0 -0
  76. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_format.js +0 -0
  77. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert.d.ts +0 -0
  78. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert.js +0 -0
  79. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_almost_equals.d.ts +0 -0
  80. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_almost_equals.js +0 -0
  81. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_array_includes.d.ts +0 -0
  82. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_array_includes.js +0 -0
  83. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_equals.d.ts +0 -0
  84. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_equals.js +0 -0
  85. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_exists.d.ts +0 -0
  86. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_exists.js +0 -0
  87. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_false.d.ts +1 -1
  88. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater.d.ts +0 -0
  89. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater.js +0 -0
  90. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater_or_equal.d.ts +0 -0
  91. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater_or_equal.js +0 -0
  92. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_instance_of.d.ts +0 -0
  93. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_instance_of.js +0 -0
  94. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_is_error.d.ts +0 -0
  95. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_is_error.js +0 -0
  96. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less.d.ts +0 -0
  97. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less.js +0 -0
  98. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less_or_equal.d.ts +0 -0
  99. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less_or_equal.js +0 -0
  100. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_match.d.ts +0 -0
  101. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_match.js +0 -0
  102. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_equals.d.ts +0 -0
  103. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_equals.js +0 -0
  104. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_instance_of.d.ts +0 -0
  105. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_instance_of.js +0 -0
  106. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_match.d.ts +0 -0
  107. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_match.js +0 -0
  108. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_strict_equals.d.ts +0 -0
  109. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_strict_equals.js +0 -0
  110. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_object_match.d.ts +0 -0
  111. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_object_match.js +0 -0
  112. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_rejects.d.ts +0 -0
  113. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_rejects.js +0 -0
  114. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_strict_equals.d.ts +0 -0
  115. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_strict_equals.js +0 -0
  116. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_string_includes.d.ts +0 -0
  117. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_string_includes.js +0 -0
  118. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_throws.d.ts +0 -0
  119. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_throws.js +0 -0
  120. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assertion_error.d.ts +0 -0
  121. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assertion_error.js +0 -0
  122. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/equal.d.ts +0 -0
  123. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/equal.js +0 -0
  124. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/fail.d.ts +0 -0
  125. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/fail.js +0 -0
  126. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/mod.d.ts +0 -0
  127. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/mod.js +0 -0
  128. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unimplemented.d.ts +0 -0
  129. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unimplemented.js +0 -0
  130. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unreachable.d.ts +0 -0
  131. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unreachable.js +0 -0
  132. package/esm/deps/deno.land/{std@0.201.0 → std@0.204.0}/fmt/colors.d.ts +0 -0
  133. package/esm/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/mod.d.ts +0 -0
  134. package/esm/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/tgcrypto.d.ts +0 -0
  135. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_constants.d.ts +0 -0
  136. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_constants.js +0 -0
  137. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_diff.d.ts +0 -0
  138. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_format.d.ts +0 -0
  139. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/_format.js +0 -0
  140. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert.d.ts +0 -0
  141. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert.js +0 -0
  142. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_almost_equals.d.ts +0 -0
  143. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_almost_equals.js +0 -0
  144. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_array_includes.d.ts +0 -0
  145. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_array_includes.js +0 -0
  146. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_equals.d.ts +0 -0
  147. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_equals.js +0 -0
  148. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_exists.d.ts +0 -0
  149. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_exists.js +0 -0
  150. package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_false.d.ts +1 -1
  151. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater.d.ts +0 -0
  152. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater.js +0 -0
  153. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater_or_equal.d.ts +0 -0
  154. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_greater_or_equal.js +0 -0
  155. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_instance_of.d.ts +0 -0
  156. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_instance_of.js +0 -0
  157. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_is_error.d.ts +0 -0
  158. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_is_error.js +0 -0
  159. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less.d.ts +0 -0
  160. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less.js +0 -0
  161. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less_or_equal.d.ts +0 -0
  162. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_less_or_equal.js +0 -0
  163. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_match.d.ts +0 -0
  164. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_match.js +0 -0
  165. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_equals.d.ts +0 -0
  166. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_equals.js +0 -0
  167. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_instance_of.d.ts +0 -0
  168. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_instance_of.js +0 -0
  169. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_match.d.ts +0 -0
  170. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_match.js +0 -0
  171. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_strict_equals.d.ts +0 -0
  172. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_not_strict_equals.js +0 -0
  173. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_object_match.d.ts +0 -0
  174. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_object_match.js +0 -0
  175. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_rejects.d.ts +0 -0
  176. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_rejects.js +0 -0
  177. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_strict_equals.d.ts +0 -0
  178. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_strict_equals.js +0 -0
  179. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_string_includes.d.ts +0 -0
  180. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_string_includes.js +0 -0
  181. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_throws.d.ts +0 -0
  182. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assert_throws.js +0 -0
  183. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assertion_error.d.ts +0 -0
  184. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/assertion_error.js +0 -0
  185. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/equal.d.ts +0 -0
  186. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/equal.js +0 -0
  187. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/fail.d.ts +0 -0
  188. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/fail.js +0 -0
  189. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/mod.d.ts +0 -0
  190. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/mod.js +0 -0
  191. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unimplemented.d.ts +0 -0
  192. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unimplemented.js +0 -0
  193. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unreachable.d.ts +0 -0
  194. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/assert/unreachable.js +0 -0
  195. /package/script/deps/deno.land/{std@0.201.0 → std@0.204.0}/fmt/colors.d.ts +0 -0
  196. /package/script/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/mod.d.ts +0 -0
  197. /package/script/deps/deno.land/x/{tgcrypto@0.3.2 → tgcrypto@0.3.3}/tgcrypto.d.ts +0 -0
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Client = exports.restartAuth = exports.getMessageWithReply = exports.handleMigrationError = exports.getStickerSetName = exports.getEntity = void 0;
3
+ exports.Client = exports.ConnectionError = exports.restartAuth = exports.getMessageWithReply = exports.handleMigrationError = exports.getStickerSetName = exports.getEntity = void 0;
4
4
  const _0_deps_js_1 = require("../0_deps.js");
5
5
  const _1_utilities_js_1 = require("../1_utilities.js");
6
6
  const _2_tl_js_1 = require("../2_tl.js");
@@ -20,11 +20,15 @@ const dGap = (0, _0_deps_js_1.debug)("Client/recoverUpdateGap");
20
20
  const dGapC = (0, _0_deps_js_1.debug)("Client/recoverChannelUpdateGap");
21
21
  const dAuth = (0, _0_deps_js_1.debug)("Client/authorize");
22
22
  const dRecv = (0, _0_deps_js_1.debug)("Client/receiveLoop");
23
+ const dUpload = (0, _0_deps_js_1.debug)("Client/upload");
23
24
  exports.getEntity = Symbol();
24
25
  exports.getStickerSetName = Symbol();
25
26
  exports.handleMigrationError = Symbol();
26
27
  exports.getMessageWithReply = Symbol();
27
28
  exports.restartAuth = Symbol();
29
+ class ConnectionError extends Error {
30
+ }
31
+ exports.ConnectionError = ConnectionError;
28
32
  class Client extends _1_client_abstract_js_1.ClientAbstract {
29
33
  /**
30
34
  * Constructs the client.
@@ -33,14 +37,8 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
33
37
  * @param apiId App's API ID from [my.telegram.org](https://my.telegram.org/apps). Defaults to 0 (unset).
34
38
  * @param apiHash App's API hash from [my.telegram.org/apps](https://my.telegram.org/apps). Defaults to empty string (unset).
35
39
  */
36
- constructor(storage = new _3_storage_js_1.StorageMemory(), apiId = 0, apiHash = "", params) {
40
+ constructor(storage, apiId = 0, apiHash = "", params) {
37
41
  super(params);
38
- Object.defineProperty(this, "storage", {
39
- enumerable: true,
40
- configurable: true,
41
- writable: true,
42
- value: storage
43
- });
44
42
  Object.defineProperty(this, "apiId", {
45
43
  enumerable: true,
46
44
  configurable: true,
@@ -89,6 +87,18 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
89
87
  writable: true,
90
88
  value: void 0
91
89
  });
90
+ Object.defineProperty(this, "errorHandler", {
91
+ enumerable: true,
92
+ configurable: true,
93
+ writable: true,
94
+ value: void 0
95
+ });
96
+ Object.defineProperty(this, "storage", {
97
+ enumerable: true,
98
+ configurable: true,
99
+ writable: true,
100
+ value: void 0
101
+ });
92
102
  Object.defineProperty(this, "parseMode", {
93
103
  enumerable: true,
94
104
  configurable: true,
@@ -192,6 +202,12 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
192
202
  writable: true,
193
203
  value: null
194
204
  });
205
+ Object.defineProperty(this, "pingLoopStarted", {
206
+ enumerable: true,
207
+ configurable: true,
208
+ writable: true,
209
+ value: false
210
+ });
195
211
  Object.defineProperty(this, "autoStarted", {
196
212
  enumerable: true,
197
213
  configurable: true,
@@ -231,6 +247,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
231
247
  writable: true,
232
248
  value: _3_types_js_2.skip
233
249
  });
250
+ this.storage = storage ?? new _3_storage_js_1.StorageMemory();
234
251
  this.parseMode = params?.parseMode ?? null;
235
252
  this.appVersion = params?.appVersion ?? _4_constants_js_1.APP_VERSION;
236
253
  this.deviceModel = params?.deviceModel ?? _4_constants_js_1.DEVICE_MODEL;
@@ -240,6 +257,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
240
257
  this.systemVersion = params?.systemVersion ?? _4_constants_js_1.SYSTEM_VERSION;
241
258
  this.publicKeys = params?.publicKeys;
242
259
  this.autoStart = params?.autoStart ?? true;
260
+ this.errorHandler = params?.errorHandler;
243
261
  }
244
262
  propagateConnectionState(connectionState) {
245
263
  return this.handle({ connectionState }, _0_utilities_js_1.resolve);
@@ -309,7 +327,6 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
309
327
  }
310
328
  d("encrypted client connected");
311
329
  (0, _1_utilities_js_1.drop)(this.receiveLoop());
312
- (0, _1_utilities_js_1.drop)(this.pingLoop());
313
330
  }
314
331
  finally {
315
332
  release();
@@ -551,7 +568,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
551
568
  }
552
569
  async receiveLoop() {
553
570
  if (!this.auth || !this.transport) {
554
- throw new Error("Not connected");
571
+ throw new ConnectionError("Not connected");
555
572
  }
556
573
  while (this.connected) {
557
574
  try {
@@ -579,6 +596,9 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
579
596
  if (body instanceof _2_tl_js_1.types._TypeUpdates || body instanceof _2_tl_js_1.types._TypeUpdate) {
580
597
  this.processUpdatesQueue.add(() => this.processUpdates(body));
581
598
  }
599
+ else if (body instanceof _2_tl_js_1.types.NewSessionCreated) {
600
+ this.state.salt = body.serverSalt;
601
+ }
582
602
  else if (message.body instanceof _2_tl_js_1.RPCResult) {
583
603
  let result = message.body.result;
584
604
  if (result instanceof _2_tl_js_1.types.GZIPPacked) {
@@ -642,10 +662,18 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
642
662
  (0, _1_utilities_js_1.drop)(this.recoverUpdateGap("deserialize"));
643
663
  }
644
664
  else {
645
- throw err;
665
+ dRecv("uncaught error: %o", err);
646
666
  }
647
667
  }
648
668
  }
669
+ if (!this.connected) {
670
+ for (const { reject } of this.promises.values()) {
671
+ reject(new ConnectionError("Connection was closed"));
672
+ }
673
+ }
674
+ else {
675
+ (0, _1_utilities_js_1.UNREACHABLE)();
676
+ }
649
677
  }
650
678
  async pingLoop() {
651
679
  while (this.connected) {
@@ -664,41 +692,61 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
664
692
  await this.start();
665
693
  }
666
694
  else {
667
- throw new Error("Not connected");
695
+ throw new ConnectionError("Not connected");
668
696
  }
669
697
  }
670
698
  if (!this.auth || !this.transport) {
671
699
  (0, _1_utilities_js_1.UNREACHABLE)();
672
700
  }
673
- let seqNo = this.state.seqNo * 2;
674
- if (!(function_ instanceof _2_tl_js_1.functions.Ping) && !(function_ instanceof _2_tl_js_1.types.MsgsAck)) {
675
- seqNo++;
676
- this.state.seqNo++;
677
- }
678
- const messageId = this.lastMsgId = (0, _0_message_js_1.getMessageId)(this.lastMsgId);
679
- const message = new _2_tl_js_1.Message_(messageId, seqNo, function_);
680
- await this.transport.transport.send(await (0, _0_message_js_1.encryptMessage)(message, this.auth.key, this.auth.id, this.state.salt, this.sessionId));
681
- d("invoked %s", function_.constructor.name);
682
- if (noWait) {
683
- return;
684
- }
685
- let result;
686
- try {
687
- result = await new Promise((resolve, reject) => {
688
- this.promises.set(message.id, { resolve, reject });
689
- });
690
- }
691
- catch (err) {
692
- if (err instanceof _4_errors_js_1.AuthKeyUnregistered) {
693
- await this.propagateAuthorizationState(false);
701
+ let n = 1;
702
+ while (true) {
703
+ try {
704
+ let seqNo = this.state.seqNo * 2;
705
+ if (!(function_ instanceof _2_tl_js_1.functions.Ping) && !(function_ instanceof _2_tl_js_1.types.MsgsAck)) {
706
+ seqNo++;
707
+ this.state.seqNo++;
708
+ }
709
+ const messageId = this.lastMsgId = (0, _0_message_js_1.getMessageId)(this.lastMsgId);
710
+ const message = new _2_tl_js_1.Message_(messageId, seqNo, function_);
711
+ await this.transport.transport.send(await (0, _0_message_js_1.encryptMessage)(message, this.auth.key, this.auth.id, this.state.salt, this.sessionId));
712
+ d("invoked %s", function_.constructor.name);
713
+ if (noWait) {
714
+ return;
715
+ }
716
+ let result;
717
+ try {
718
+ result = await new Promise((resolve, reject) => {
719
+ this.promises.set(message.id, { resolve, reject });
720
+ });
721
+ }
722
+ catch (err) {
723
+ if (err instanceof _4_errors_js_1.AuthKeyUnregistered) {
724
+ await this.propagateAuthorizationState(false);
725
+ }
726
+ throw err;
727
+ }
728
+ if (result instanceof _2_tl_js_1.types.BadServerSalt) {
729
+ return await this.invoke(function_);
730
+ }
731
+ else {
732
+ if (!this.pingLoopStarted) {
733
+ (0, _1_utilities_js_1.drop)(this.pingLoop());
734
+ this.pingLoopStarted = true;
735
+ }
736
+ return result;
737
+ }
738
+ }
739
+ catch (err) {
740
+ if (this.errorHandler === undefined) {
741
+ throw err;
742
+ }
743
+ if (this.errorHandler !== undefined && await this.errorHandler(err, function_, n++)) {
744
+ continue;
745
+ }
746
+ else {
747
+ throw err;
748
+ }
694
749
  }
695
- throw err;
696
- }
697
- if (result instanceof _2_tl_js_1.types.BadServerSalt) {
698
- return await this.invoke(function_);
699
- }
700
- else {
701
- return result;
702
750
  }
703
751
  }
704
752
  /**
@@ -1155,10 +1203,10 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1155
1203
  const messages = new Array();
1156
1204
  if (updates instanceof _2_tl_js_1.types.Updates) {
1157
1205
  for (const update of updates.updates) {
1158
- if (update instanceof _2_tl_js_1.types.UpdateNewMessage) {
1206
+ if (update instanceof _2_tl_js_1.types.UpdateNewMessage || update instanceof _2_tl_js_1.types.UpdateEditMessage) {
1159
1207
  messages.push(await (0, _3_types_js_1.constructMessage)(update.message, this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this)));
1160
1208
  }
1161
- else if (update instanceof _2_tl_js_1.types.UpdateNewChannelMessage) {
1209
+ else if (update instanceof _2_tl_js_1.types.UpdateNewChannelMessage || update instanceof _2_tl_js_1.types.UpdateEditChannelMessage) {
1162
1210
  messages.push(await (0, _3_types_js_1.constructMessage)(update.message, this[exports.getEntity].bind(this), this.getMessage.bind(this), this[exports.getStickerSetName].bind(this)));
1163
1211
  }
1164
1212
  }
@@ -1239,7 +1287,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1239
1287
  */
1240
1288
  async editMessageText(chatId, messageId, text, params) {
1241
1289
  const [message, entities] = this.parseText(text, params);
1242
- await this.invoke(new _2_tl_js_1.functions.MessagesEditMessage({
1290
+ const result = await this.invoke(new _2_tl_js_1.functions.MessagesEditMessage({
1243
1291
  id: messageId,
1244
1292
  peer: await this.getInputPeer(chatId),
1245
1293
  entities,
@@ -1247,6 +1295,8 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1247
1295
  noWebpage: params?.disableWebPagePreview ? true : undefined,
1248
1296
  replyMarkup: await this.constructReplyMarkup(params),
1249
1297
  }));
1298
+ const message_ = await this.updatesToMessages(chatId, result).then((v) => v[0]);
1299
+ return Client.assertMsgHas(message_, "text");
1250
1300
  }
1251
1301
  async getMessagesInner(chatId_, messageIds) {
1252
1302
  const peer = await this.getInputPeer(chatId_);
@@ -1308,29 +1358,30 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1308
1358
  const messages = await this.getMessages(chatId, [messageId]);
1309
1359
  return messages[0] ?? null;
1310
1360
  }
1311
- async *downloadInner(location, dcId) {
1312
- let client = null;
1313
- if (dcId != undefined && dcId != this.dcId) {
1314
- const exportedAuth = await this.invoke(new _2_tl_js_1.functions.AuthExportAuthorization({ dcId }));
1315
- client = new Client(new _3_storage_js_1.StorageMemory(), this.apiId, this.apiHash, {
1316
- transportProvider: this.transportProvider,
1317
- appVersion: this.appVersion,
1318
- deviceModel: this.deviceModel,
1319
- langCode: this.langCode,
1320
- langPack: this.langPack,
1321
- systemLangCode: this.systemLangCode,
1322
- systemVersion: this.systemVersion,
1323
- cdn: true,
1324
- });
1325
- let dc = String(dcId);
1326
- if (this.dcId < 0) {
1327
- dc += "-test";
1328
- }
1329
- await client.setDc(dc);
1330
- await client.connect();
1331
- await client.authorize(exportedAuth);
1332
- }
1333
- const limit = 1024 * 1024;
1361
+ async *downloadInner(location, dcId, params) {
1362
+ const chunkSize = params?.chunkSize ?? 1024 * 1024;
1363
+ if ((0, _1_utilities_js_1.mod)(chunkSize, 1024) != 0) {
1364
+ throw new Error("chunkSize must be divisible by 1024");
1365
+ }
1366
+ const exportedAuth = await this.invoke(new _2_tl_js_1.functions.AuthExportAuthorization({ dcId }));
1367
+ const client = new Client(new _3_storage_js_1.StorageMemory(), this.apiId, this.apiHash, {
1368
+ transportProvider: this.transportProvider,
1369
+ appVersion: this.appVersion,
1370
+ deviceModel: this.deviceModel,
1371
+ langCode: this.langCode,
1372
+ langPack: this.langPack,
1373
+ systemLangCode: this.systemLangCode,
1374
+ systemVersion: this.systemVersion,
1375
+ cdn: true,
1376
+ });
1377
+ let dc = String(dcId);
1378
+ if (this.dcId < 0) {
1379
+ dc += "-test";
1380
+ }
1381
+ await client.setDc(dc);
1382
+ await client.connect();
1383
+ await client.authorize(exportedAuth);
1384
+ const limit = chunkSize;
1334
1385
  let offset = 0n;
1335
1386
  while (true) {
1336
1387
  const file = await (client ?? this).invoke(new _2_tl_js_1.functions.UploadGetFile({ location, offset, limit }));
@@ -1353,14 +1404,14 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1353
1404
  *
1354
1405
  * @param fileId The identifier of the file to download.
1355
1406
  */
1356
- async download(fileId) {
1407
+ async download(fileId, params) {
1357
1408
  const fileId_ = _3_types_js_1.FileID.decode(fileId);
1358
1409
  switch (fileId_.fileType) {
1359
1410
  case _3_types_js_1.FileType.ChatPhoto: {
1360
1411
  const big = fileId_.params.thumbnailSource == _3_types_js_1.ThumbnailSource.ChatPhotoBig;
1361
1412
  const peer = await this.getInputPeer(fileId_.params.chatId);
1362
1413
  const location = new _2_tl_js_1.types.InputPeerPhotoFileLocation({ big: big ? true : undefined, peer, photoId: fileId_.params.mediaId });
1363
- return this.downloadInner(location);
1414
+ return this.downloadInner(location, fileId_.dcId, params);
1364
1415
  }
1365
1416
  case _3_types_js_1.FileType.Photo: {
1366
1417
  if (fileId_.params.mediaId == undefined || fileId_.params.accessHash == undefined || fileId_.params.fileReference == undefined || fileId_.params.thumbnailSize == undefined) {
@@ -1372,7 +1423,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1372
1423
  fileReference: fileId_.params.fileReference,
1373
1424
  thumbSize: fileId_.params.thumbnailSize,
1374
1425
  });
1375
- return this.downloadInner(location);
1426
+ return this.downloadInner(location, fileId_.dcId, params);
1376
1427
  }
1377
1428
  default:
1378
1429
  (0, _1_utilities_js_1.UNREACHABLE)();
@@ -1610,17 +1661,107 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1610
1661
  }
1611
1662
  await this.invoke(new _2_tl_js_1.functions.MessagesSetTyping({ peer: await this.getInputPeer(chatId), action, topMsgId: messageThreadId }));
1612
1663
  }
1664
+ /**
1665
+ * Upload a file.
1666
+ *
1667
+ * @param contents The contents of the file.
1668
+ */
1669
+ async upload(contents, params) {
1670
+ const isBig = contents.length > 1048576; // 10 MB
1671
+ const chunkSize = params?.chunkSize ?? 512 * 1024;
1672
+ if ((0, _1_utilities_js_1.mod)(chunkSize, 1024) != 0) {
1673
+ throw new Error("chunkSize must be divisible by 1024");
1674
+ }
1675
+ const signal = params?.signal;
1676
+ dUpload("uploading " + (isBig ? "big " : "") + "file of size " + contents.length + " with chunk size of " + chunkSize);
1677
+ const fileId = (0, _1_utilities_js_1.getRandomId)();
1678
+ const name = params?.fileName ?? fileId.toString();
1679
+ const client = new Client(this.storage, this.apiId, this.apiHash, {
1680
+ transportProvider: this.transportProvider,
1681
+ appVersion: this.appVersion,
1682
+ deviceModel: this.deviceModel,
1683
+ langCode: this.langCode,
1684
+ langPack: this.langPack,
1685
+ systemLangCode: this.systemLangCode,
1686
+ systemVersion: this.systemVersion,
1687
+ cdn: true,
1688
+ initialDc: this.initialDc,
1689
+ autoStart: false,
1690
+ });
1691
+ signal?.addEventListener("abort", () => (0, _1_utilities_js_1.drop)(client.disconnect()));
1692
+ client.state.salt = this.state.salt;
1693
+ await client.connect();
1694
+ let part = 0;
1695
+ const partCount = Math.ceil(contents.length / chunkSize);
1696
+ try {
1697
+ main: for (; part < partCount; part++) {
1698
+ chunk: while (true) {
1699
+ try {
1700
+ const start = part * chunkSize;
1701
+ const end = start + chunkSize;
1702
+ const bytes = contents.slice(start, end);
1703
+ if (bytes.length == 0) {
1704
+ continue main;
1705
+ }
1706
+ if (isBig) {
1707
+ await client.invoke(new _2_tl_js_1.functions.UploadSaveBigFilePart({ fileId, filePart: part, bytes, fileTotalParts: partCount }));
1708
+ }
1709
+ else {
1710
+ await client.invoke(new _2_tl_js_1.functions.UploadSaveFilePart({ fileId, bytes, filePart: part }));
1711
+ }
1712
+ dUpload((part + 1) + " out of " + partCount + " chunks have been uploaded so far");
1713
+ break chunk;
1714
+ }
1715
+ catch (err) {
1716
+ if (signal?.aborted) {
1717
+ break main;
1718
+ }
1719
+ if (err instanceof _4_errors_js_1.FloodWait) {
1720
+ dUpload("got a flood wait of " + err.seconds + " seconds");
1721
+ await new Promise((r) => setTimeout(r, err.seconds * 1000));
1722
+ }
1723
+ else if (err instanceof ConnectionError) {
1724
+ while (true) {
1725
+ try {
1726
+ await new Promise((r) => setTimeout(r, 3000));
1727
+ await client.connect();
1728
+ }
1729
+ catch {
1730
+ if (signal?.aborted) {
1731
+ break main;
1732
+ }
1733
+ }
1734
+ }
1735
+ }
1736
+ else {
1737
+ throw err;
1738
+ }
1739
+ }
1740
+ }
1741
+ }
1742
+ }
1743
+ finally {
1744
+ (0, _1_utilities_js_1.drop)(client.disconnect());
1745
+ }
1746
+ dUpload("uploaded all " + partCount + " chunk(s)");
1747
+ if (isBig) {
1748
+ return new _2_tl_js_1.types.InputFileBig({ id: fileId, parts: contents.length / chunkSize, name });
1749
+ }
1750
+ else {
1751
+ return new _2_tl_js_1.types.InputFile({ id: fileId, name, parts: part, md5Checksum: "" });
1752
+ }
1753
+ }
1613
1754
  async setMyCommands(commands, params) {
1614
1755
  await this.invoke(new _2_tl_js_1.functions.BotsSetBotCommands({
1615
1756
  commands: commands.map((v) => new _2_tl_js_1.types.BotCommand(v)),
1616
1757
  langCode: params?.languageCode ?? "",
1617
- scope: await (0, _3_types_js_1.botCommandScopeToTlObject)(params?.scope ?? { type: "default" }, this.getInputPeer.bind(this)), // TODO: use params.scope
1758
+ scope: await (0, _3_types_js_1.botCommandScopeToTlObject)(params?.scope ?? { type: "default" }, this.getInputPeer.bind(this)),
1618
1759
  }));
1619
1760
  }
1620
1761
  async getMyCommands(params) {
1621
1762
  const commands_ = await this.invoke(new _2_tl_js_1.functions.BotsGetBotCommands({
1622
1763
  langCode: params?.languageCode ?? "",
1623
- scope: await (0, _3_types_js_1.botCommandScopeToTlObject)(params?.scope ?? { type: "default" }, this.getInputPeer.bind(this)), // TODO: use params.scope
1764
+ scope: await (0, _3_types_js_1.botCommandScopeToTlObject)(params?.scope ?? { type: "default" }, this.getInputPeer.bind(this)),
1624
1765
  }));
1625
1766
  return commands_.map((v) => ({ command: v.command, description: v.description }));
1626
1767
  }
@@ -1682,5 +1823,53 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
1682
1823
  }
1683
1824
  }, handler);
1684
1825
  }
1826
+ async setMyInfo(info) {
1827
+ await this.invoke(new _2_tl_js_1.functions.BotsSetBotInfo({ bot: new _2_tl_js_1.types.InputUserSelf(), ...info }));
1828
+ }
1829
+ /**
1830
+ * Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty.
1831
+ */
1832
+ async setMyDescription({ description, languageCode }) {
1833
+ await this.assertBot("setMyDescription");
1834
+ await this.setMyInfo({ description, langCode: languageCode ?? "" });
1835
+ }
1836
+ /**
1837
+ * Use this method to change the bot's name.
1838
+ */
1839
+ async setMyName({ name, languageCode }) {
1840
+ await this.assertBot("setMyName");
1841
+ await this.setMyInfo({ name, langCode: languageCode ?? "" });
1842
+ }
1843
+ /**
1844
+ * Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot.
1845
+ */
1846
+ async setMyShortDescription({ shortDescription: about, languageCode }) {
1847
+ await this.assertBot("setMyShortDescription");
1848
+ await this.setMyInfo({ about, langCode: languageCode ?? "" });
1849
+ }
1850
+ getMyInfo(languageCode) {
1851
+ return this.invoke(new _2_tl_js_1.functions.BotsGetBotInfo({ bot: new _2_tl_js_1.types.InputUserSelf(), langCode: languageCode ?? "" }));
1852
+ }
1853
+ /**
1854
+ * Use this method to get the current bot description for the given user language.
1855
+ */
1856
+ async getMyDescription(languageCode) {
1857
+ await this.assertBot("getMyDescription");
1858
+ return await this.getMyInfo(languageCode).then((v) => v.description);
1859
+ }
1860
+ /**
1861
+ * Use this method to get the current bot name for the given user language.
1862
+ */
1863
+ async getMyName(languageCode) {
1864
+ await this.assertBot("getMyName");
1865
+ return await this.getMyInfo(languageCode).then((v) => v.description);
1866
+ }
1867
+ /**
1868
+ * Use this method to get the current bot short description for the given user language.
1869
+ */
1870
+ async getMyShortDescription(languageCode) {
1871
+ await this.assertBot("getMyShortDescription");
1872
+ return await this.getMyInfo(languageCode).then((v) => v.about);
1873
+ }
1685
1874
  }
1686
1875
  exports.Client = Client;
@@ -107,7 +107,7 @@ class ConnectionWebSocket extends _0_connection_js_1.ConnectionUnframed {
107
107
  this.buffer.push(byte);
108
108
  }
109
109
  if (this.nextResolve != null && this.buffer.length >= this.nextResolve[0]) {
110
- this.nextResolve[1]();
110
+ this.nextResolve[1].resolve();
111
111
  this.nextResolve = null;
112
112
  }
113
113
  release();
@@ -162,7 +162,7 @@ class ConnectionWebSocket extends _0_connection_js_1.ConnectionUnframed {
162
162
  const release = await this.rMutex.acquire();
163
163
  try {
164
164
  if (this.buffer.length < p.length) {
165
- await new Promise((r) => this.nextResolve = [p.length, r]);
165
+ await new Promise((resolve, reject) => this.nextResolve = [p.length, { resolve, reject }]);
166
166
  }
167
167
  p.set(this.buffer.splice(0, p.length));
168
168
  }
@@ -187,6 +187,9 @@ class ConnectionWebSocket extends _0_connection_js_1.ConnectionUnframed {
187
187
  throw new Error("Connection not open");
188
188
  }
189
189
  this.webSocket.close(1000, "method");
190
+ if (this.nextResolve != null) {
191
+ this.nextResolve[1].reject(new Error("Connection not open"));
192
+ }
190
193
  }
191
194
  }
192
195
  exports.ConnectionWebSocket = ConnectionWebSocket;
@@ -243,14 +243,21 @@ function diffstr(A, B) {
243
243
  }
244
244
  }
245
245
  // Compute word-diff
246
- const aLines = added.length < removed.length ? added : removed;
247
- const bLines = aLines === removed ? added : removed;
246
+ const hasMoreRemovedLines = added.length < removed.length;
247
+ const aLines = hasMoreRemovedLines ? added : removed;
248
+ const bLines = hasMoreRemovedLines ? removed : added;
248
249
  for (const a of aLines) {
249
250
  let tokens = [], b;
250
251
  // Search another diff line with at least one common token
251
252
  while (bLines.length) {
252
253
  b = bLines.shift();
253
- tokens = diff(tokenize(a.value, { wordDiff: true }), tokenize(b?.value ?? "", { wordDiff: true }));
254
+ const tokenized = [
255
+ tokenize(a.value, { wordDiff: true }),
256
+ tokenize(b?.value ?? "", { wordDiff: true }),
257
+ ];
258
+ if (hasMoreRemovedLines)
259
+ tokenized.reverse();
260
+ tokens = diff(tokenized[0], tokenized[1]);
254
261
  if (tokens.some(({ type, value }) => type === DiffType.common && value.trim().length)) {
255
262
  break;
256
263
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.assertFalse = void 0;
4
4
  // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
5
5
  const assertion_error_js_1 = require("./assertion_error.js");
6
+ /** Make an assertion, error will be thrown if `expr` have truthy value. */
6
7
  function assertFalse(expr, msg = "") {
7
8
  if (expr) {
8
9
  throw new assertion_error_js_1.AssertionError(msg);
@@ -0,0 +1 @@
1
+ export declare function validateBinaryLike(source: unknown): Uint8Array;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.validateBinaryLike = void 0;
5
+ const encoder = new TextEncoder();
6
+ function getTypeName(value) {
7
+ const type = typeof value;
8
+ if (type !== "object") {
9
+ return type;
10
+ }
11
+ else if (value === null) {
12
+ return "null";
13
+ }
14
+ else {
15
+ return value?.constructor?.name ?? "object";
16
+ }
17
+ }
18
+ function validateBinaryLike(source) {
19
+ if (typeof source === "string") {
20
+ return encoder.encode(source);
21
+ }
22
+ else if (source instanceof Uint8Array) {
23
+ return source;
24
+ }
25
+ else if (source instanceof ArrayBuffer) {
26
+ return new Uint8Array(source);
27
+ }
28
+ throw new TypeError(`The input must be a Uint8Array, a string, or an ArrayBuffer. Received a value of the type ${getTypeName(source)}.`);
29
+ }
30
+ exports.validateBinaryLike = validateBinaryLike;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @deprecated (will be removed in 0.210.0) Use a `encodeBase64` instead.
3
+ *
4
+ * CREDIT: https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727
5
+ * Encodes a given Uint8Array, ArrayBuffer or string into RFC4648 base64 representation
6
+ * @param data
7
+ */
8
+ export declare const encode: typeof encodeBase64;
9
+ /**
10
+ * @deprecated (will be removed in 0.210.0) Use a `decodeBase64` instead.
11
+ *
12
+ * Decodes a given RFC4648 base64 encoded string
13
+ * @param b64
14
+ */
15
+ export declare const decode: typeof decodeBase64;
16
+ /**
17
+ * Encodes a given Uint8Array, ArrayBuffer or string into RFC4648 base64 representation
18
+ */
19
+ export declare function encodeBase64(data: ArrayBuffer | Uint8Array | string): string;
20
+ /**
21
+ * Decodes a given RFC4648 base64 encoded string
22
+ */
23
+ export declare function decodeBase64(b64: string): Uint8Array;