@mtkruto/node 0.1.200 → 0.1.300

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 (231) hide show
  1. package/esm/0_deps.d.ts +1 -1
  2. package/esm/0_deps.js +2 -1
  3. package/esm/1_utilities.d.ts +1 -1
  4. package/esm/1_utilities.js +1 -1
  5. package/esm/4_errors.js +3 -3
  6. package/esm/client/0_markdown.js +5 -5
  7. package/esm/client/0_utilities.d.ts +6 -0
  8. package/esm/client/0_utilities.js +35 -4
  9. package/esm/client/1_account_manager.js +4 -4
  10. package/esm/client/1_client_encrypted.js +4 -4
  11. package/esm/client/1_client_plain.js +3 -3
  12. package/esm/client/1_file_manager.js +6 -5
  13. package/esm/client/1_reaction_manager.js +2 -2
  14. package/esm/client/1_update_manager.js +9 -8
  15. package/esm/client/2_message_manager.js +47 -24
  16. package/esm/client/3_callback_query_manager.js +2 -0
  17. package/esm/client/3_chat_list_manager.js +13 -12
  18. package/esm/client/3_inline_query_manager.js +4 -2
  19. package/esm/client/3_story_manager.js +7 -5
  20. package/esm/client/4_client.d.ts +5 -8
  21. package/esm/client/4_client.js +19 -27
  22. package/esm/connection/1_connection_web_socket.js +3 -2
  23. package/{script/deps/deno.land/x/tgcrypto@0.3.3 → esm/deps/deno.land/x/tgcrypto@0.4.0}/mod.d.ts +0 -1
  24. package/esm/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/mod.js +0 -11
  25. package/esm/deps/deno.land/x/tgcrypto@0.4.0/tgcrypto.js +308 -0
  26. package/esm/mod.d.ts +1 -1
  27. package/esm/mod.js +1 -1
  28. package/esm/storage/0_storage.js +6 -5
  29. package/esm/storage/1_utilities.d.ts +0 -1
  30. package/esm/storage/1_utilities.js +2 -3
  31. package/esm/storage/2_storage_local_storage.js +1 -4
  32. package/esm/storage/2_storage_session_storage.js +1 -4
  33. package/esm/tl/3_utilities.js +5 -4
  34. package/esm/transport/2_transport_provider.js +4 -4
  35. package/esm/types/0_message_entity.js +3 -3
  36. package/esm/types/0_message_search_filter.js +2 -2
  37. package/esm/types/0_reaction.js +2 -2
  38. package/esm/types/1_bot_command_scope.js +3 -3
  39. package/esm/types/1_chat_p.js +3 -2
  40. package/esm/types/1_keyboard_button.js +3 -3
  41. package/esm/types/1_message_reaction.js +2 -2
  42. package/esm/types/1_story_privacy.js +3 -3
  43. package/esm/types/2_chat_member.js +6 -5
  44. package/esm/types/2_chosen_inline_result.js +3 -2
  45. package/esm/types/2_inactive_chat.js +3 -2
  46. package/esm/types/2_inline_keyboard_button.js +3 -3
  47. package/esm/types/2_inline_query.js +3 -3
  48. package/esm/types/2_invite_link.js +3 -2
  49. package/esm/types/2_story_content.js +5 -5
  50. package/esm/types/2_story_interactive_area.js +5 -5
  51. package/esm/types/3_chat_member_updated.js +4 -3
  52. package/esm/types/3_reply_markup.js +4 -3
  53. package/esm/types/3_story.js +3 -2
  54. package/esm/types/4_inline_query_result.js +5 -5
  55. package/esm/types/4_message.js +17 -16
  56. package/esm/types/5_callback_query.js +4 -3
  57. package/esm/types/5_chat.js +8 -7
  58. package/esm/types/_file_id.js +9 -8
  59. package/esm/utilities/0_bigint.d.ts +1 -0
  60. package/esm/utilities/0_bigint.js +25 -0
  61. package/esm/utilities/0_logger.d.ts +8 -0
  62. package/esm/utilities/0_logger.js +9 -5
  63. package/esm/utilities/1_math.d.ts +1 -0
  64. package/esm/utilities/1_math.js +51 -0
  65. package/esm/utilities/1_misc.js +2 -2
  66. package/package.json +1 -1
  67. package/script/0_deps.d.ts +1 -1
  68. package/script/0_deps.js +3 -3
  69. package/script/1_utilities.d.ts +1 -1
  70. package/script/1_utilities.js +1 -1
  71. package/script/4_errors.js +3 -3
  72. package/script/client/0_markdown.js +5 -5
  73. package/script/client/0_utilities.d.ts +6 -0
  74. package/script/client/0_utilities.js +41 -4
  75. package/script/client/1_account_manager.js +4 -4
  76. package/script/client/1_client_encrypted.js +2 -2
  77. package/script/client/1_client_plain.js +2 -2
  78. package/script/client/1_file_manager.js +5 -4
  79. package/script/client/1_reaction_manager.js +2 -2
  80. package/script/client/1_update_manager.js +8 -7
  81. package/script/client/2_message_manager.js +51 -28
  82. package/script/client/3_callback_query_manager.js +2 -0
  83. package/script/client/3_chat_list_manager.js +12 -11
  84. package/script/client/3_inline_query_manager.js +4 -2
  85. package/script/client/3_story_manager.js +4 -2
  86. package/script/client/4_client.d.ts +5 -8
  87. package/script/client/4_client.js +18 -26
  88. package/script/connection/1_connection_web_socket.js +2 -1
  89. package/{esm/deps/deno.land/x/tgcrypto@0.3.3 → script/deps/deno.land/x/tgcrypto@0.4.0}/mod.d.ts +0 -1
  90. package/script/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/mod.js +1 -13
  91. package/script/deps/deno.land/x/tgcrypto@0.4.0/tgcrypto.js +310 -0
  92. package/script/mod.d.ts +1 -1
  93. package/script/mod.js +2 -1
  94. package/script/storage/0_storage.js +5 -4
  95. package/script/storage/1_utilities.d.ts +0 -1
  96. package/script/storage/1_utilities.js +3 -4
  97. package/script/storage/2_storage_local_storage.js +0 -3
  98. package/script/storage/2_storage_session_storage.js +0 -3
  99. package/script/tl/3_utilities.js +4 -3
  100. package/script/transport/2_transport_provider.js +4 -4
  101. package/script/types/0_message_entity.js +3 -3
  102. package/script/types/0_message_search_filter.js +2 -2
  103. package/script/types/0_reaction.js +2 -2
  104. package/script/types/1_bot_command_scope.js +3 -3
  105. package/script/types/1_chat_p.js +2 -1
  106. package/script/types/1_keyboard_button.js +3 -3
  107. package/script/types/1_message_reaction.js +2 -2
  108. package/script/types/1_story_privacy.js +3 -3
  109. package/script/types/2_chat_member.js +5 -4
  110. package/script/types/2_chosen_inline_result.js +2 -1
  111. package/script/types/2_inactive_chat.js +2 -1
  112. package/script/types/2_inline_keyboard_button.js +3 -3
  113. package/script/types/2_inline_query.js +3 -3
  114. package/script/types/2_invite_link.js +2 -1
  115. package/script/types/2_story_content.js +5 -5
  116. package/script/types/2_story_interactive_area.js +5 -5
  117. package/script/types/3_chat_member_updated.js +3 -2
  118. package/script/types/3_reply_markup.js +3 -2
  119. package/script/types/3_story.js +2 -1
  120. package/script/types/4_inline_query_result.js +5 -5
  121. package/script/types/4_message.js +16 -15
  122. package/script/types/5_callback_query.js +3 -2
  123. package/script/types/5_chat.js +7 -6
  124. package/script/types/_file_id.js +8 -7
  125. package/script/utilities/0_bigint.d.ts +1 -0
  126. package/script/utilities/0_bigint.js +27 -1
  127. package/script/utilities/0_logger.d.ts +8 -0
  128. package/script/utilities/0_logger.js +11 -6
  129. package/script/utilities/1_math.d.ts +1 -0
  130. package/script/utilities/1_math.js +55 -0
  131. package/script/utilities/1_misc.js +2 -2
  132. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.d.ts +0 -83
  133. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.js +0 -203
  134. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.d.ts +0 -50
  135. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.js +0 -274
  136. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.d.ts +0 -47
  137. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.js +0 -51
  138. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.d.ts +0 -66
  139. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.js +0 -191
  140. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Node.d.ts +0 -168
  141. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Node.js +0 -385
  142. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Parser.d.ts +0 -159
  143. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Parser.js +0 -431
  144. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.d.ts +0 -181
  145. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.js +0 -1046
  146. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/mod.d.ts +0 -42
  147. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/mod.js +0 -52
  148. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.d.ts +0 -11
  149. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.js +0 -122
  150. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.d.ts +0 -1
  151. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.js +0 -24
  152. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.d.ts +0 -46
  153. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.js +0 -121
  154. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.d.ts +0 -31
  155. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.js +0 -30
  156. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.d.ts +0 -2128
  157. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.js +0 -2127
  158. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.d.ts +0 -109
  159. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.js +0 -108
  160. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.d.ts +0 -8
  161. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.js +0 -1
  162. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.d.ts +0 -90
  163. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.js +0 -95
  164. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.d.ts +0 -50
  165. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.js +0 -128
  166. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.d.ts +0 -46
  167. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.js +0 -110
  168. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.d.ts +0 -42
  169. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.js +0 -120
  170. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.d.ts +0 -6
  171. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.js +0 -6
  172. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.d.ts +0 -54
  173. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.js +0 -110
  174. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.d.ts +0 -40
  175. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.js +0 -75
  176. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.d.ts +0 -58
  177. package/esm/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.js +0 -101
  178. package/esm/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +0 -324
  179. package/esm/utilities/0_control.d.ts +0 -1
  180. package/esm/utilities/0_control.js +0 -3
  181. package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.d.ts +0 -83
  182. package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomHandler.js +0 -207
  183. package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.d.ts +0 -50
  184. package/script/deps/deno.land/x/html_parser@v0.1.3/src/DomSerializer.js +0 -301
  185. package/script/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.d.ts +0 -47
  186. package/script/deps/deno.land/x/html_parser@v0.1.3/src/ElementType.js +0 -55
  187. package/script/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.d.ts +0 -66
  188. package/script/deps/deno.land/x/html_parser@v0.1.3/src/FeedHandler.js +0 -222
  189. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Node.d.ts +0 -168
  190. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Node.js +0 -404
  191. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Parser.d.ts +0 -159
  192. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Parser.js +0 -438
  193. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.d.ts +0 -181
  194. package/script/deps/deno.land/x/html_parser@v0.1.3/src/Tokenizer.js +0 -1052
  195. package/script/deps/deno.land/x/html_parser@v0.1.3/src/mod.d.ts +0 -42
  196. package/script/deps/deno.land/x/html_parser@v0.1.3/src/mod.js +0 -88
  197. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.d.ts +0 -11
  198. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode.js +0 -128
  199. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.d.ts +0 -1
  200. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/decode_codepoint.js +0 -30
  201. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.d.ts +0 -46
  202. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/encode.js +0 -129
  203. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.d.ts +0 -31
  204. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/decode.js +0 -32
  205. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.d.ts +0 -2128
  206. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/entities.js +0 -2129
  207. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.d.ts +0 -109
  208. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/legacy.js +0 -110
  209. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.d.ts +0 -8
  210. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/maps/xml.js +0 -3
  211. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.d.ts +0 -90
  212. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/entities/mod.js +0 -114
  213. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.d.ts +0 -50
  214. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/helpers.js +0 -134
  215. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.d.ts +0 -46
  216. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/legacy.js +0 -118
  217. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.d.ts +0 -42
  218. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/manipulation.js +0 -129
  219. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.d.ts +0 -6
  220. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/mod.js +0 -22
  221. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.d.ts +0 -54
  222. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/querying.js +0 -119
  223. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.d.ts +0 -40
  224. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/stringify.js +0 -86
  225. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.d.ts +0 -58
  226. package/script/deps/deno.land/x/html_parser@v0.1.3/src/utils/traversal.js +0 -112
  227. package/script/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +0 -326
  228. package/script/utilities/0_control.d.ts +0 -1
  229. package/script/utilities/0_control.js +0 -7
  230. /package/esm/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/tgcrypto.d.ts +0 -0
  231. /package/script/deps/deno.land/x/{tgcrypto@0.3.3 → tgcrypto@0.4.0}/tgcrypto.d.ts +0 -0
package/esm/0_deps.d.ts CHANGED
@@ -4,6 +4,6 @@ export { decodeBase64, encodeBase64 } from "./deps/deno.land/std@0.221.0/encodin
4
4
  import { contentType as contentType_ } from "./deps/deno.land/std@0.221.0/media_types/content_type.js";
5
5
  export declare const contentType: typeof contentType_;
6
6
  export declare function extension(mimeType: string): string;
7
- export { ctr256, factorize, ige256Decrypt, ige256Encrypt, init as initTgCrypto } from "./deps/deno.land/x/tgcrypto@0.3.3/mod.js";
7
+ export { ctr256, ige256Decrypt, ige256Encrypt, init as initTgCrypto } from "./deps/deno.land/x/tgcrypto@0.4.0/mod.js";
8
8
  export { gunzip, gzip } from "./deps/raw.githubusercontent.com/MTKruto/compress/main/mod.js";
9
9
  export { Parser } from "./deps/deno.land/x/html_parser@v0.1.3/src/mod.js";
package/esm/0_deps.js CHANGED
@@ -1,3 +1,4 @@
1
+ // connection/1_connection_tcp.ts must be updated too when updating std.
1
2
  export * from "./deps/deno.land/std@0.221.0/assert/mod.js";
2
3
  export * as path from "./deps/deno.land/std@0.221.0/path/mod.js";
3
4
  export { decodeBase64, encodeBase64 } from "./deps/deno.land/std@0.221.0/encoding/base64.js";
@@ -19,6 +20,6 @@ export function extension(mimeType) {
19
20
  return extension_(mimeType) || "unknown";
20
21
  }
21
22
  }
22
- export { ctr256, factorize, ige256Decrypt, ige256Encrypt, init as initTgCrypto } from "./deps/deno.land/x/tgcrypto@0.3.3/mod.js";
23
+ export { ctr256, ige256Decrypt, ige256Encrypt, init as initTgCrypto } from "./deps/deno.land/x/tgcrypto@0.4.0/mod.js";
23
24
  export { gunzip, gzip } from "./deps/raw.githubusercontent.com/MTKruto/compress/main/mod.js";
24
25
  export { Parser } from "./deps/deno.land/x/html_parser@v0.1.3/src/mod.js";
@@ -2,7 +2,6 @@ export * from "./utilities/0_bigint.js";
2
2
  export * from "./utilities/0_buffer.js";
3
3
  export * from "./utilities/0_cache_map.js";
4
4
  export * from "./utilities/0_color.js";
5
- export * from "./utilities/0_control.js";
6
5
  export * from "./utilities/0_crypto.js";
7
6
  export * from "./utilities/0_hash.js";
8
7
  export * from "./utilities/0_logger.js";
@@ -12,5 +11,6 @@ export * from "./utilities/0_rle.js";
12
11
  export * from "./utilities/0_types.js";
13
12
  export * from "./utilities/1_auth.js";
14
13
  export * from "./utilities/1_base64.js";
14
+ export * from "./utilities/1_math.js";
15
15
  export * from "./utilities/1_misc.js";
16
16
  export * from "./utilities/1_queue.js";
@@ -2,7 +2,6 @@ export * from "./utilities/0_bigint.js";
2
2
  export * from "./utilities/0_buffer.js";
3
3
  export * from "./utilities/0_cache_map.js";
4
4
  export * from "./utilities/0_color.js";
5
- export * from "./utilities/0_control.js";
6
5
  export * from "./utilities/0_crypto.js";
7
6
  export * from "./utilities/0_hash.js";
8
7
  export * from "./utilities/0_logger.js";
@@ -12,5 +11,6 @@ export * from "./utilities/0_rle.js";
12
11
  export * from "./utilities/0_types.js";
13
12
  export * from "./utilities/1_auth.js";
14
13
  export * from "./utilities/1_base64.js";
14
+ export * from "./utilities/1_math.js";
15
15
  export * from "./utilities/1_misc.js";
16
16
  export * from "./utilities/1_queue.js";
package/esm/4_errors.js CHANGED
@@ -1,4 +1,4 @@
1
- import { UNREACHABLE } from "./1_utilities.js";
1
+ import { unreachable } from "./0_deps.js";
2
2
  import { ErrorWithCall, map } from "./3_errors.js";
3
3
  export * from "./3_errors.js";
4
4
  export class FloodWait extends ErrorWithCall {
@@ -13,7 +13,7 @@ export class FloodWait extends ErrorWithCall {
13
13
  const p = params.error_message.split("_");
14
14
  this.seconds = Number(p[p.length - 1]);
15
15
  if (isNaN(this.seconds)) {
16
- UNREACHABLE();
16
+ unreachable();
17
17
  }
18
18
  }
19
19
  }
@@ -29,7 +29,7 @@ export class Migrate extends ErrorWithCall {
29
29
  const p = params.error_message.split("_");
30
30
  this.dc = Number(p[p.length - 1]);
31
31
  if (isNaN(this.dc)) {
32
- UNREACHABLE();
32
+ unreachable();
33
33
  }
34
34
  }
35
35
  }
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Copyright (c) 2023 Dunkan
3
- * Copyright (c) 2024 Roj
2
+ * Copyright (C) 2023 Dunkan
3
+ * Copyright (C) 2024 Roj
4
4
  */
5
- import { UNREACHABLE } from "../1_utilities.js";
5
+ import { unreachable } from "../0_deps.js";
6
6
  import { sortMessageEntities } from "../3_types.js";
7
7
  import { InputError } from "../0_errors.js";
8
8
  const enc = new TextEncoder();
@@ -136,7 +136,7 @@ export function parseMarkdown(text_) {
136
136
  case "customEmoji":
137
137
  return c === CODEPOINTS["]"];
138
138
  default:
139
- UNREACHABLE();
139
+ unreachable();
140
140
  }
141
141
  })();
142
142
  }
@@ -289,7 +289,7 @@ export function parseMarkdown(text_) {
289
289
  break;
290
290
  }
291
291
  default:
292
- UNREACHABLE();
292
+ unreachable();
293
293
  }
294
294
  if (!skipEntity) {
295
295
  const entityOffset = nestedEntities.at(-1).entityOffset;
@@ -4,3 +4,9 @@ export declare function getFileContents(source: FileSource, fileName?: string):
4
4
  export declare function isHttpUrl(string: string): boolean;
5
5
  export declare function getUsername(string: string): string;
6
6
  export declare function getChatListId(chatList: string): 0 | 1;
7
+ export declare function checkMessageId(messageId: number): number;
8
+ export declare function checkStoryId(storyId: number): number;
9
+ export declare function checkPollOption(option: string): void;
10
+ export declare function checkArray<T>(array: T[], check: (value: T) => void): void;
11
+ export declare function checkCallbackQueryId(id: string): void;
12
+ export declare function checkInlineQueryId(id: string): void;
@@ -1,7 +1,6 @@
1
1
  import * as dntShim from "../_dnt.shims.js";
2
- import { path } from "../0_deps.js";
2
+ import { path, unreachable } from "../0_deps.js";
3
3
  import { InputError } from "../0_errors.js";
4
- import { UNREACHABLE } from "../1_utilities.js";
5
4
  export const resolve = () => Promise.resolve();
6
5
  export async function getFileContents(source, fileName = "") {
7
6
  fileName = fileName.trim() || "file";
@@ -28,7 +27,7 @@ export async function getFileContents(source, fileName = "") {
28
27
  fileName = path.basename(path_);
29
28
  }
30
29
  else {
31
- UNREACHABLE();
30
+ unreachable();
32
31
  }
33
32
  }
34
33
  const res = await fetch(url);
@@ -123,6 +122,38 @@ export function getChatListId(chatList) {
123
122
  case "archived":
124
123
  return 1;
125
124
  default:
126
- UNREACHABLE();
125
+ unreachable();
126
+ }
127
+ }
128
+ export function checkMessageId(messageId) {
129
+ if (typeof messageId !== "number" || isNaN(messageId) || !messageId) {
130
+ throw new InputError("Invalid message ID");
131
+ }
132
+ return messageId;
133
+ }
134
+ export function checkStoryId(storyId) {
135
+ if (typeof storyId !== "number" || isNaN(storyId) || !storyId) {
136
+ throw new InputError("Invalid story ID");
137
+ }
138
+ return storyId;
139
+ }
140
+ export function checkPollOption(option) {
141
+ if (!option.trim()) {
142
+ throw new InputError("Poll option must not be empty.");
143
+ }
144
+ }
145
+ export function checkArray(array, check) {
146
+ for (const item of array) {
147
+ check(item);
148
+ }
149
+ }
150
+ export function checkCallbackQueryId(id) {
151
+ if (typeof id !== "string" || !id.trim()) {
152
+ throw new InputError("Invalid callback query ID.");
153
+ }
154
+ }
155
+ export function checkInlineQueryId(id) {
156
+ if (typeof id !== "string" || !id.trim()) {
157
+ throw new InputError("Invalid inline query ID.");
127
158
  }
128
159
  }
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
12
  var _AccountManager_instances, _AccountManager_c, _AccountManager_toggleUsername;
13
- import { UNREACHABLE } from "../1_utilities.js";
13
+ import { unreachable } from "../0_deps.js";
14
14
  import { types } from "../2_tl.js";
15
15
  import { constructInactiveChat } from "../3_types.js";
16
16
  export class AccountManager {
@@ -40,7 +40,7 @@ export class AccountManager {
40
40
  return await __classPrivateFieldGet(this, _AccountManager_c, "f").api.channels.reorderUsernames({ channel: new types.InputChannel(peer), order });
41
41
  }
42
42
  else {
43
- UNREACHABLE();
43
+ unreachable();
44
44
  }
45
45
  }
46
46
  async hideUsernames(id) {
@@ -50,7 +50,7 @@ export class AccountManager {
50
50
  return await __classPrivateFieldGet(this, _AccountManager_c, "f").api.channels.deactivateAllUsernames({ channel: new types.InputChannel(peer) });
51
51
  }
52
52
  else {
53
- UNREACHABLE();
53
+ unreachable();
54
54
  }
55
55
  }
56
56
  async getInactiveChats() {
@@ -71,6 +71,6 @@ _AccountManager_c = new WeakMap(), _AccountManager_instances = new WeakSet(), _A
71
71
  await __classPrivateFieldGet(this, _AccountManager_c, "f").api.channels.toggleUsername({ channel: new types.InputChannel(peer), username, active });
72
72
  }
73
73
  else {
74
- UNREACHABLE();
74
+ unreachable();
75
75
  }
76
76
  };
@@ -10,9 +10,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
12
  var _ClientEncrypted_instances, _ClientEncrypted_authKey, _ClientEncrypted_authKeyId, _ClientEncrypted_sessionId, _ClientEncrypted_state, _ClientEncrypted_toAcknowledge, _ClientEncrypted_recentAcks, _ClientEncrypted_promises, _ClientEncrypted_L, _ClientEncrypted_LreceiveLoop, _ClientEncrypted_Linvoke, _ClientEncrypted_nextMessageId, _ClientEncrypted_nextSeqNo, _ClientEncrypted_sendMessage, _ClientEncrypted_receiveLoop;
13
- import { gunzip } from "../0_deps.js";
13
+ import { gunzip, unreachable } from "../0_deps.js";
14
14
  import { ConnectionError } from "../0_errors.js";
15
- import { bigIntFromBuffer, CacheMap, drop, getLogger, getRandomBigInt, sha1, UNREACHABLE } from "../1_utilities.js";
15
+ import { bigIntFromBuffer, CacheMap, drop, getLogger, getRandomBigInt, sha1 } from "../1_utilities.js";
16
16
  import { Message_, MessageContainer, name, RPCResult, TLError, TLReader, types } from "../2_tl.js";
17
17
  import { upgradeInstance } from "../4_errors.js";
18
18
  import { ClientAbstract } from "./0_client_abstract.js";
@@ -118,7 +118,7 @@ _ClientEncrypted_authKey = new WeakMap(), _ClientEncrypted_authKeyId = new WeakM
118
118
  __classPrivateFieldGet(this, _ClientEncrypted_L, "f").outBin(payload);
119
119
  }, _ClientEncrypted_receiveLoop = async function _ClientEncrypted_receiveLoop() {
120
120
  if (!this.transport) {
121
- UNREACHABLE();
121
+ unreachable();
122
122
  }
123
123
  while (this.connected) {
124
124
  try {
@@ -234,6 +234,6 @@ _ClientEncrypted_authKey = new WeakMap(), _ClientEncrypted_authKeyId = new WeakM
234
234
  }
235
235
  }
236
236
  else {
237
- UNREACHABLE();
237
+ unreachable();
238
238
  }
239
239
  };
@@ -10,9 +10,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
12
  var _ClientPlain_publicKeys, _ClientPlain_lastMsgId;
13
- import { assertEquals, assertInstanceOf, factorize, ige256Decrypt, ige256Encrypt } from "../0_deps.js";
13
+ import { assertEquals, assertInstanceOf, ige256Decrypt, ige256Encrypt, unreachable } from "../0_deps.js";
14
14
  import { ConnectionError, TransportError } from "../0_errors.js";
15
- import { bigIntFromBuffer, bufferFromBigInt, concat, getLogger, getRandomBigInt, modExp, rsaPad, sha1, UNREACHABLE } from "../1_utilities.js";
15
+ import { bigIntFromBuffer, bufferFromBigInt, concat, factorize, getLogger, getRandomBigInt, modExp, rsaPad, sha1 } from "../1_utilities.js";
16
16
  import { functions, serialize, TLReader, types } from "../2_tl.js";
17
17
  import { PUBLIC_KEYS } from "../4_constants.js";
18
18
  import { ClientAbstract } from "./0_client_abstract.js";
@@ -68,7 +68,7 @@ export class ClientPlain extends ClientAbstract {
68
68
  }
69
69
  }
70
70
  if (!resPq) {
71
- UNREACHABLE();
71
+ unreachable();
72
72
  }
73
73
  const pq_ = bigIntFromBuffer(resPq.pq, false, false);
74
74
  LcreateAuthKey.debug(`pq=${pq_}`);
@@ -10,8 +10,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
12
  var _FileManager_instances, _FileManager_c, _FileManager_Lupload, _FileManager_downloadInner;
13
+ import { unreachable } from "../0_deps.js";
13
14
  import { ConnectionError, InputError } from "../0_errors.js";
14
- import { drop, getLogger, getRandomId, mod, UNREACHABLE } from "../1_utilities.js";
15
+ import { drop, getLogger, getRandomId, mod } from "../1_utilities.js";
15
16
  import { as, types } from "../2_tl.js";
16
17
  import { constructSticker, deserializeFileId, FileType, PhotoSourceType, serializeFileId, toUniqueFileId } from "../3_types.js";
17
18
  import { STICKER_SET_NAME_TTL } from "../4_constants.js";
@@ -104,7 +105,7 @@ export class FileManager {
104
105
  switch (fileId_.type) {
105
106
  case FileType.ProfilePhoto: {
106
107
  if (fileId_.location.source.type != PhotoSourceType.ChatPhotoBig && fileId_.location.source.type != PhotoSourceType.ChatPhotoSmall) {
107
- UNREACHABLE();
108
+ unreachable();
108
109
  }
109
110
  const big = fileId_.location.source.type == PhotoSourceType.ChatPhotoBig;
110
111
  const peer = await __classPrivateFieldGet(this, _FileManager_c, "f").getInputPeer(Number(fileId_.location.source.chatId)); // TODO: use access hash from source?
@@ -131,7 +132,7 @@ export class FileManager {
131
132
  id: fileId_.location.id,
132
133
  access_hash: fileId_.location.accessHash,
133
134
  file_reference: fileId_.fileReference ?? new Uint8Array(),
134
- thumb_size: "thumbnailType" in fileId_.location.source ? String.fromCharCode(fileId_.location.source.thumbnailType) : UNREACHABLE(),
135
+ thumb_size: "thumbnailType" in fileId_.location.source ? String.fromCharCode(fileId_.location.source.thumbnailType) : unreachable(),
135
136
  });
136
137
  for await (const chunk of __classPrivateFieldGet(this, _FileManager_instances, "m", _FileManager_downloadInner).call(this, location, fileId_.dcId, params)) {
137
138
  yield chunk;
@@ -152,7 +153,7 @@ export class FileManager {
152
153
  }
153
154
  }
154
155
  else {
155
- UNREACHABLE();
156
+ unreachable();
156
157
  }
157
158
  }
158
159
  async getStickerSetName(inputStickerSet, hash = 0) {
@@ -255,7 +256,7 @@ _FileManager_c = new WeakMap(), _FileManager_Lupload = new WeakMap(), _FileManag
255
256
  }
256
257
  }
257
258
  else {
258
- UNREACHABLE();
259
+ unreachable();
259
260
  }
260
261
  }
261
262
  }
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
12
  var _ReactionManager_c;
13
- import { UNREACHABLE } from "../1_utilities.js";
13
+ import { unreachable } from "../0_deps.js";
14
14
  import { peerToChatId, types } from "../2_tl.js";
15
15
  import { constructMessageReaction, constructMessageReactionCount, constructMessageReactions } from "../3_types.js";
16
16
  export class ReactionManager {
@@ -77,7 +77,7 @@ export class ReactionManager {
77
77
  }
78
78
  }
79
79
  else {
80
- UNREACHABLE();
80
+ unreachable();
81
81
  }
82
82
  }
83
83
  }
@@ -10,7 +10,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
12
  var _UpdateManager_instances, _a, _UpdateManager_c, _UpdateManager_updateState, _UpdateManager_updateHandler, _UpdateManager_LrecoverUpdateGap, _UpdateManager_LrecoverChannelUpdateGap, _UpdateManager_L$handleUpdate, _UpdateManager_L$processUpdates, _UpdateManager_LfetchState, _UpdateManager_defaultDropPendingUpdates, _UpdateManager_mustDropPendingUpdates, _UpdateManager_state, _UpdateManager_getState, _UpdateManager_setState, _UpdateManager_handleUpdateQueues, _UpdateManager_nonFirst, _UpdateManager_getChannelPtsWithDropPendingUpdatesCheck, _UpdateManager_checkGap, _UpdateManager_checkGapQts, _UpdateManager_checkChannelGap, _UpdateManager_channelUpdateQueues, _UpdateManager_processChannelPtsUpdateInner, _UpdateManager_queueUpdate, _UpdateManager_processChannelPtsUpdate, _UpdateManager_processPtsUpdateInner, _UpdateManager_ptsUpdateQueue, _UpdateManager_processPtsUpdate, _UpdateManager_processQtsUpdateInner, _UpdateManager_qtsUpdateQueue, _UpdateManager_processQtsUpdate, _UpdateManager_processUpdatesQueue, _UpdateManager_processUpdates, _UpdateManager_setUpdateStateDate, _UpdateManager_setUpdatePts, _UpdateManager_setUpdateQts, _UpdateManager_getLocalState, _UpdateManager_recoverChannelUpdateGap, _UpdateManager_handleUpdatesSet, _UpdateManager_handleStoredUpdates, _UpdateManager_handleUpdate;
13
- import { getLogger, Queue, UNREACHABLE, ZERO_CHANNEL_ID } from "../1_utilities.js";
13
+ import { unreachable } from "../0_deps.js";
14
+ import { getLogger, Queue, ZERO_CHANNEL_ID } from "../1_utilities.js";
14
15
  import { as, functions, inputPeerToPeer, peerToChatId, types } from "../2_tl.js";
15
16
  import { CHANNEL_DIFFERENCE_LIMIT_BOT, CHANNEL_DIFFERENCE_LIMIT_USER } from "../4_constants.js";
16
17
  export class UpdateManager {
@@ -250,7 +251,7 @@ export class UpdateManager {
250
251
  state = difference.intermediate_state;
251
252
  }
252
253
  else {
253
- UNREACHABLE();
254
+ unreachable();
254
255
  }
255
256
  }
256
257
  else if (difference instanceof types.updates.DifferenceTooLong) {
@@ -266,7 +267,7 @@ export class UpdateManager {
266
267
  break;
267
268
  }
268
269
  else {
269
- UNREACHABLE();
270
+ unreachable();
270
271
  }
271
272
  }
272
273
  }
@@ -511,7 +512,7 @@ _a = UpdateManager, _UpdateManager_c = new WeakMap(), _UpdateManager_updateState
511
512
  }
512
513
  else if (updates_ instanceof types.UpdateShortSentMessage) {
513
514
  if (!(call instanceof functions.messages.sendMessage)) {
514
- UNREACHABLE();
515
+ unreachable();
515
516
  }
516
517
  updates = [
517
518
  new types.UpdateNewMessage({
@@ -541,7 +542,7 @@ _a = UpdateManager, _UpdateManager_c = new WeakMap(), _UpdateManager_updateState
541
542
  updates = [updates_];
542
543
  }
543
544
  else {
544
- UNREACHABLE();
545
+ unreachable();
545
546
  }
546
547
  /// We process the updates when we are sure there is no gap.
547
548
  if (updates_ instanceof types.Updates || updates_ instanceof types.UpdatesCombined) {
@@ -562,7 +563,7 @@ _a = UpdateManager, _UpdateManager_c = new WeakMap(), _UpdateManager_updateState
562
563
  await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_setState).call(this, __classPrivateFieldGet(this, _UpdateManager_updateState, "f"));
563
564
  }
564
565
  else {
565
- UNREACHABLE();
566
+ unreachable();
566
567
  }
567
568
  }
568
569
  else if (_a.isPtsUpdate(update)) {
@@ -604,7 +605,7 @@ _a = UpdateManager, _UpdateManager_c = new WeakMap(), _UpdateManager_updateState
604
605
  await __classPrivateFieldGet(this, _UpdateManager_instances, "m", _UpdateManager_setState).call(this, localState);
605
606
  }
606
607
  else {
607
- UNREACHABLE();
608
+ unreachable();
608
609
  }
609
610
  }
610
611
  }
@@ -647,7 +648,7 @@ _a = UpdateManager, _UpdateManager_c = new WeakMap(), _UpdateManager_updateState
647
648
  pts = pts_;
648
649
  }
649
650
  else {
650
- UNREACHABLE();
651
+ unreachable();
651
652
  }
652
653
  __classPrivateFieldGet(this, _UpdateManager_LrecoverChannelUpdateGap, "f").debug("processed channelDifferenceTooLong");
653
654
  }