@mtkruto/browser 0.134.0 → 0.135.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/esm/3_types.d.ts +1 -0
  2. package/esm/3_types.d.ts.map +1 -1
  3. package/esm/3_types.js +1 -0
  4. package/esm/client/0_params.d.ts +24 -2
  5. package/esm/client/0_params.d.ts.map +1 -1
  6. package/esm/client/0_utilities.d.ts +1 -1
  7. package/esm/client/0_utilities.d.ts.map +1 -1
  8. package/esm/client/1_client_generic.d.ts +11 -3
  9. package/esm/client/1_client_generic.d.ts.map +1 -1
  10. package/esm/client/3_message_manager.d.ts.map +1 -1
  11. package/esm/client/3_message_manager.js +13 -9
  12. package/esm/client/4_gift_manager.d.ts +3 -2
  13. package/esm/client/4_gift_manager.d.ts.map +1 -1
  14. package/esm/client/4_gift_manager.js +9 -0
  15. package/esm/client/4_poll_manager.js +1 -1
  16. package/esm/client/6_client.d.ts +11 -3
  17. package/esm/client/6_client.d.ts.map +1 -1
  18. package/esm/client/6_client.js +11 -1
  19. package/esm/client/6_client_dispatcher.d.ts +11 -3
  20. package/esm/client/6_client_dispatcher.d.ts.map +1 -1
  21. package/esm/client/6_client_dispatcher.js +11 -1
  22. package/esm/tl/1_telegram_api.d.ts +1616 -10
  23. package/esm/tl/1_telegram_api.d.ts.map +1 -1
  24. package/esm/tl/1_telegram_api.js +333 -48
  25. package/esm/types/0_premium_subscription_duration.d.ts +21 -0
  26. package/esm/types/0_premium_subscription_duration.d.ts.map +1 -0
  27. package/esm/types/0_premium_subscription_duration.js +20 -0
  28. package/esm/types/3_poll_option.d.ts +1 -1
  29. package/esm/types/3_poll_option.d.ts.map +1 -1
  30. package/esm/types/3_poll_option.js +2 -1
  31. package/esm/types/4_poll.d.ts +3 -3
  32. package/esm/types/4_poll.d.ts.map +1 -1
  33. package/esm/types/4_poll.js +5 -3
  34. package/package.json +1 -1
  35. package/script/3_types.d.ts +1 -0
  36. package/script/3_types.d.ts.map +1 -1
  37. package/script/3_types.js +1 -0
  38. package/script/client/0_params.d.ts +24 -2
  39. package/script/client/0_params.d.ts.map +1 -1
  40. package/script/client/0_utilities.d.ts +1 -1
  41. package/script/client/0_utilities.d.ts.map +1 -1
  42. package/script/client/1_client_generic.d.ts +11 -3
  43. package/script/client/1_client_generic.d.ts.map +1 -1
  44. package/script/client/3_message_manager.d.ts.map +1 -1
  45. package/script/client/3_message_manager.js +13 -9
  46. package/script/client/4_gift_manager.d.ts +3 -2
  47. package/script/client/4_gift_manager.d.ts.map +1 -1
  48. package/script/client/4_gift_manager.js +9 -0
  49. package/script/client/4_poll_manager.js +1 -1
  50. package/script/client/6_client.d.ts +11 -3
  51. package/script/client/6_client.d.ts.map +1 -1
  52. package/script/client/6_client.js +11 -1
  53. package/script/client/6_client_dispatcher.d.ts +11 -3
  54. package/script/client/6_client_dispatcher.d.ts.map +1 -1
  55. package/script/client/6_client_dispatcher.js +11 -1
  56. package/script/tl/1_telegram_api.d.ts +1616 -10
  57. package/script/tl/1_telegram_api.d.ts.map +1 -1
  58. package/script/tl/1_telegram_api.js +333 -48
  59. package/script/types/0_premium_subscription_duration.d.ts +21 -0
  60. package/script/types/0_premium_subscription_duration.d.ts.map +1 -0
  61. package/script/types/0_premium_subscription_duration.js +21 -0
  62. package/script/types/3_poll_option.d.ts +1 -1
  63. package/script/types/3_poll_option.d.ts.map +1 -1
  64. package/script/types/3_poll_option.js +2 -1
  65. package/script/types/4_poll.d.ts +3 -3
  66. package/script/types/4_poll.d.ts.map +1 -1
  67. package/script/types/4_poll.js +5 -3
@@ -0,0 +1,21 @@
1
+ /**
2
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
+ * Copyright (C) 2023-2026 Roj <https://roj.im/>
4
+ *
5
+ * This file is part of MTKruto.
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU Lesser General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public License
18
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
+ */
20
+ export type PremiumSubscriptionDuration = 3 | 6 | 12;
21
+ //# sourceMappingURL=0_premium_subscription_duration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"0_premium_subscription_duration.d.ts","sourceRoot":"","sources":["../../src/types/0_premium_subscription_duration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,MAAM,2BAA2B,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /**
3
+ * MTKruto - Cross-runtime JavaScript library for building Telegram clients
4
+ * Copyright (C) 2023-2026 Roj <https://roj.im/>
5
+ *
6
+ * This file is part of MTKruto.
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU Lesser General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU Lesser General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU Lesser General Public License
19
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
+ */
21
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -17,7 +17,7 @@
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
- import type { Api } from "../2_tl.js";
20
+ import { Api } from "../2_tl.js";
21
21
  import { type MessageEntity } from "./2_message_entity.js";
22
22
  /** A poll option. */
23
23
  export interface PollOption {
@@ -1 +1 @@
1
- {"version":3,"file":"3_poll_option.d.ts","sourceRoot":"","sources":["../../src/types/3_poll_option.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAA0B,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEnF,qBAAqB;AACrB,MAAM,WAAW,UAAU;IACzB,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,UAAU,CAQ5G"}
1
+ {"version":3,"file":"3_poll_option.d.ts","sourceRoot":"","sources":["../../src/types/3_poll_option.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAA0B,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEnF,qBAAqB;AACrB,MAAM,WAAW,UAAU;IACzB,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,UAAU,CAQ5G"}
@@ -20,9 +20,10 @@
20
20
  */
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.constructPollOption = constructPollOption;
23
+ const _2_tl_js_1 = require("../2_tl.js");
23
24
  const _2_message_entity_js_1 = require("./2_message_entity.js");
24
25
  function constructPollOption(option, results) {
25
- const result = results.find((v) => v.option.every((v, i) => option.option[i] === v));
26
+ const result = results.find((v) => v.option.every((v, i) => _2_tl_js_1.Api.as("pollAnswer", option).option[i] === v));
26
27
  return {
27
28
  text: option.text.text,
28
29
  entities: option.text.entities?.map(_2_message_entity_js_1.constructMessageEntity).filter((v) => v !== null),
@@ -17,7 +17,7 @@
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
- import type { Api } from "../2_tl.js";
20
+ import { Api } from "../2_tl.js";
21
21
  import { type MessageEntity } from "./2_message_entity.js";
22
22
  import { type PollOption } from "./3_poll_option.js";
23
23
  /** A poll. */
@@ -40,8 +40,8 @@ export interface Poll {
40
40
  type: "regular" | "quiz";
41
41
  /** Whether the poll allows multiple answers. */
42
42
  allowMultipleAnswers?: boolean;
43
- /** Index of the correct option. */
44
- correctOptionIndex?: number;
43
+ /** The indexes of correct options. */
44
+ correctOptionIndexes?: number[];
45
45
  /** A text that is shown to the user when the poll is answered. */
46
46
  explanation?: string;
47
47
  /** The explanation's entities. */
@@ -1 +1 @@
1
- {"version":3,"file":"4_poll.d.ts","sourceRoot":"","sources":["../../src/types/4_poll.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAA0B,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAuB,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE1E,cAAc;AACd,MAAM,WAAW,IAAI;IACnB,kCAAkC;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C;IAClC,0BAA0B;IAC1B,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,6DAA6D;IAC7D,eAAe,EAAE,MAAM,CAAC;IACxB,kCAAkC;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,qCAAqC;IACrC,WAAW,EAAE,OAAO,CAAC;IACrB,4BAA4B;IAC5B,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC;IACzB,gDAAgD;IAChD,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,sCAAsC;IACtC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,kEAAkE;IAClE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kCAAkC;IAClC,mBAAmB,CAAC,EAAE,aAAa,EAAE,CAAC;IACtC,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,gBAAgB,GAAG,IAAI,CAoBhE"}
@@ -20,13 +20,15 @@
20
20
  */
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.constructPoll = constructPoll;
23
+ const _0_deps_js_1 = require("../0_deps.js");
23
24
  const _1_utilities_js_1 = require("../1_utilities.js");
25
+ const _2_tl_js_1 = require("../2_tl.js");
24
26
  const _2_message_entity_js_1 = require("./2_message_entity.js");
25
27
  const _3_poll_option_js_1 = require("./3_poll_option.js");
26
28
  function constructPoll(media_) {
27
29
  const poll = media_.poll;
28
- const correctOption = media_.results.results?.find((v) => v.correct)?.option;
29
- const correctOptionIndex = correctOption !== undefined ? poll.answers.findIndex((v) => v.option.every((v, i) => correctOption[i] === v)) : undefined;
30
+ const correctOptions = media_.results.results?.filter((v) => v.correct).map((v) => v.option);
31
+ const correctOptionIndexes = correctOptions !== undefined ? poll.answers.filter((v) => correctOptions.some((v_) => (0, _0_deps_js_1.equals)(v_, _2_tl_js_1.Api.as("pollAnswer", v).option))).map((_, i) => i) : undefined;
30
32
  return (0, _1_utilities_js_1.cleanObject)({
31
33
  id: String(poll.id),
32
34
  question: poll.question.text,
@@ -37,7 +39,7 @@ function constructPoll(media_) {
37
39
  isAnonymous: !poll.public_voters,
38
40
  type: poll.quiz ? "quiz" : "regular",
39
41
  allowMultipleAnswers: poll.quiz ? undefined : poll.multiple_choice || false,
40
- correctOptionIndex,
42
+ correctOptionIndexes,
41
43
  explanation: media_.results.solution,
42
44
  explanationEntities: media_.results.solution_entities?.map(_2_message_entity_js_1.constructMessageEntity).filter((v) => v !== null),
43
45
  openPeriod: poll.close_period,