@mtkruto/browser 0.2.6 → 0.2.10

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 (71) hide show
  1. package/esm/3_types.d.ts +4 -3
  2. package/esm/3_types.d.ts.map +1 -1
  3. package/esm/3_types.js +4 -3
  4. package/esm/4_constants.d.ts +1 -1
  5. package/esm/4_constants.js +1 -1
  6. package/esm/client/0_params.d.ts +24 -0
  7. package/esm/client/0_params.d.ts.map +1 -1
  8. package/esm/client/2_update_manager.d.ts.map +1 -1
  9. package/esm/client/2_update_manager.js +15 -3
  10. package/esm/client/3_message_manager.d.ts +4 -3
  11. package/esm/client/3_message_manager.d.ts.map +1 -1
  12. package/esm/client/3_message_manager.js +61 -3
  13. package/esm/client/5_client.d.ts +15 -2
  14. package/esm/client/5_client.d.ts.map +1 -1
  15. package/esm/client/5_client.js +21 -6
  16. package/esm/connection/1_connection_tcp.d.ts.map +1 -1
  17. package/esm/connection/1_connection_tcp.js +7 -3
  18. package/esm/connection/1_connection_web_socket.js +1 -1
  19. package/esm/tl/0_api.d.ts +386 -33
  20. package/esm/tl/0_api.d.ts.map +1 -1
  21. package/esm/tl/0_api.js +621 -66
  22. package/esm/types/0_invoice.d.ts +10 -0
  23. package/esm/types/0_invoice.d.ts.map +1 -0
  24. package/esm/types/0_invoice.js +9 -0
  25. package/esm/types/{0_poll_option.d.ts → 1_poll_option.d.ts} +4 -1
  26. package/esm/types/1_poll_option.d.ts.map +1 -0
  27. package/esm/types/{0_poll_option.js → 1_poll_option.js} +3 -1
  28. package/{script/types/1_poll.d.ts → esm/types/2_poll.d.ts} +4 -2
  29. package/esm/types/2_poll.d.ts.map +1 -0
  30. package/esm/types/{1_poll.js → 2_poll.js} +3 -2
  31. package/esm/types/4_message.d.ts +15 -2
  32. package/esm/types/4_message.d.ts.map +1 -1
  33. package/esm/types/4_message.js +7 -1
  34. package/package.json +1 -1
  35. package/script/3_types.d.ts +4 -3
  36. package/script/3_types.d.ts.map +1 -1
  37. package/script/3_types.js +4 -3
  38. package/script/4_constants.d.ts +1 -1
  39. package/script/4_constants.js +1 -1
  40. package/script/client/0_params.d.ts +24 -0
  41. package/script/client/0_params.d.ts.map +1 -1
  42. package/script/client/2_update_manager.d.ts.map +1 -1
  43. package/script/client/2_update_manager.js +14 -2
  44. package/script/client/3_message_manager.d.ts +4 -3
  45. package/script/client/3_message_manager.d.ts.map +1 -1
  46. package/script/client/3_message_manager.js +61 -3
  47. package/script/client/5_client.d.ts +15 -2
  48. package/script/client/5_client.d.ts.map +1 -1
  49. package/script/client/5_client.js +21 -6
  50. package/script/connection/1_connection_tcp.d.ts.map +1 -1
  51. package/script/connection/1_connection_tcp.js +7 -3
  52. package/script/connection/1_connection_web_socket.js +1 -1
  53. package/script/tl/0_api.d.ts +386 -33
  54. package/script/tl/0_api.d.ts.map +1 -1
  55. package/script/tl/0_api.js +621 -66
  56. package/script/types/0_invoice.d.ts +10 -0
  57. package/script/types/0_invoice.d.ts.map +1 -0
  58. package/script/types/0_invoice.js +13 -0
  59. package/script/types/{0_poll_option.d.ts → 1_poll_option.d.ts} +4 -1
  60. package/script/types/1_poll_option.d.ts.map +1 -0
  61. package/script/types/{0_poll_option.js → 1_poll_option.js} +3 -1
  62. package/{esm/types/1_poll.d.ts → script/types/2_poll.d.ts} +4 -2
  63. package/script/types/2_poll.d.ts.map +1 -0
  64. package/script/types/{1_poll.js → 2_poll.js} +4 -3
  65. package/script/types/4_message.d.ts +15 -2
  66. package/script/types/4_message.d.ts.map +1 -1
  67. package/script/types/4_message.js +8 -2
  68. package/esm/types/0_poll_option.d.ts.map +0 -1
  69. package/esm/types/1_poll.d.ts.map +0 -1
  70. package/script/types/0_poll_option.d.ts.map +0 -1
  71. package/script/types/1_poll.d.ts.map +0 -1
@@ -747,13 +747,13 @@ export class Client extends Composer {
747
747
  */
748
748
  async connect() {
749
749
  const unlock = await __classPrivateFieldGet(this, _Client_connectMutex, "f").lock();
750
- if (this.connected) {
751
- return;
752
- }
753
- if (__classPrivateFieldGet(this, _Client_lastConnect, "f") != null && Date.now() - __classPrivateFieldGet(this, _Client_lastConnect, "f").getTime() <= 10 * second) {
754
- await new Promise((r) => setTimeout(r, 3 * second));
755
- }
756
750
  try {
751
+ if (this.connected) {
752
+ return;
753
+ }
754
+ if (__classPrivateFieldGet(this, _Client_lastConnect, "f") != null && Date.now() - __classPrivateFieldGet(this, _Client_lastConnect, "f").getTime() <= 10 * second) {
755
+ await new Promise((r) => setTimeout(r, 3 * second));
756
+ }
757
757
  await __classPrivateFieldGet(this, _Client_instances, "m", _Client_initStorage).call(this);
758
758
  const [authKey, dc] = await Promise.all([this.storage.getAuthKey(), this.storage.getDc()]);
759
759
  if (authKey != null && dc != null) {
@@ -1532,6 +1532,21 @@ export class Client extends Composer {
1532
1532
  async sendPoll(chatId, question, options, params) {
1533
1533
  return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendPoll(chatId, question, options, params);
1534
1534
  }
1535
+ /**
1536
+ * Send an invoice.
1537
+ *
1538
+ * @method ms
1539
+ * @param chatId The chat to send the invoice to.
1540
+ * @param title The invoice's title.
1541
+ * @param description The invoice's description.
1542
+ * @param payload The invoice's payload.
1543
+ * @param currency The invoice's currency.
1544
+ * @param prices The invoice's price tags.
1545
+ * @returns The sent invoice.
1546
+ */
1547
+ async sendInvoice(chatId, title, description, payload, currency, prices, params) {
1548
+ return await __classPrivateFieldGet(this, _Client_messageManager, "f").sendInvoice(chatId, title, description, payload, currency, prices, params);
1549
+ }
1535
1550
  /**
1536
1551
  * Edit a message's text.
1537
1552
  *
@@ -1 +1 @@
1
- {"version":3,"file":"1_connection_tcp.d.ts","sourceRoot":"","sources":["../../src/connection/1_connection_tcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAK5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C,qBAAa,aAAc,YAAW,UAAU;;IAU9C,OAAO,EAAE,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAwB;IAC5D,kBAAkB,CAAC,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACtD,QAAQ,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;gBAEtB,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAK1C,IAAI,SAAS,IAAI,OAAO,CAEvB;IAQK,IAAI;IA+CJ,IAAI,CAAC,CAAC,EAAE,UAAU;IAgBlB,KAAK,CAAC,CAAC,EAAE,UAAU;IA0BzB,KAAK;CAON"}
1
+ {"version":3,"file":"1_connection_tcp.d.ts","sourceRoot":"","sources":["../../src/connection/1_connection_tcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAM5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C,qBAAa,aAAc,YAAW,UAAU;;IAU9C,OAAO,EAAE,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAwB;IAC5D,kBAAkB,CAAC,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACtD,QAAQ,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;gBAEtB,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAK1C,IAAI,SAAS,IAAI,OAAO,CAEvB;IAQK,IAAI;IA+CJ,IAAI,CAAC,CAAC,EAAE,UAAU;IAgBlB,KAAK,CAAC,CAAC,EAAE,UAAU;IA4BzB,KAAK;CAON"}
@@ -31,6 +31,7 @@ var _ConnectionTCP_instances, _ConnectionTCP_hostname, _ConnectionTCP_port, _Con
31
31
  */
32
32
  import * as dntShim from "../_dnt.shims.js";
33
33
  import { concat, iterateReader } from "../0_deps.js";
34
+ import { ConnectionError } from "../0_errors.js";
34
35
  import { getLogger, Mutex } from "../1_utilities.js";
35
36
  const L = getLogger("ConnectionTCP");
36
37
  export class ConnectionTCP {
@@ -140,8 +141,11 @@ export class ConnectionTCP {
140
141
  }
141
142
  if (!this.connected) {
142
143
  this.stateChangeHandler?.(false);
144
+ throw new ConnectionError("Connection was closed");
145
+ }
146
+ else {
147
+ throw err;
143
148
  }
144
- throw err;
145
149
  }
146
150
  }
147
151
  }
@@ -159,11 +163,11 @@ export class ConnectionTCP {
159
163
  }
160
164
  _ConnectionTCP_hostname = new WeakMap(), _ConnectionTCP_port = new WeakMap(), _ConnectionTCP_connection = new WeakMap(), _ConnectionTCP_rMutex = new WeakMap(), _ConnectionTCP_wMutex = new WeakMap(), _ConnectionTCP_buffer = new WeakMap(), _ConnectionTCP_nextResolve = new WeakMap(), _ConnectionTCP_canRead = new WeakMap(), _ConnectionTCP_canWrite = new WeakMap(), _ConnectionTCP_instances = new WeakSet(), _ConnectionTCP_assertConnected = function _ConnectionTCP_assertConnected() {
161
165
  if (!this.connected) {
162
- throw new Error("Connection not open");
166
+ throw new ConnectionError("Connection not open");
163
167
  }
164
168
  }, _ConnectionTCP_rejectRead = function _ConnectionTCP_rejectRead() {
165
169
  if (__classPrivateFieldGet(this, _ConnectionTCP_nextResolve, "f") != null) {
166
- __classPrivateFieldGet(this, _ConnectionTCP_nextResolve, "f")[1].reject(new Error("Connection was closed"));
170
+ __classPrivateFieldGet(this, _ConnectionTCP_nextResolve, "f")[1].reject(new ConnectionError("Connection was closed"));
167
171
  __classPrivateFieldSet(this, _ConnectionTCP_nextResolve, null, "f");
168
172
  }
169
173
  };
@@ -33,7 +33,7 @@ import { concat, unreachable } from "../0_deps.js";
33
33
  import { ConnectionError } from "../0_errors.js";
34
34
  import { getLogger, Mutex } from "../1_utilities.js";
35
35
  const L = getLogger("ConnectionWebSocket");
36
- const errConnectionNotOpen = new Error("Connection not open");
36
+ const errConnectionNotOpen = new ConnectionError("Connection not open");
37
37
  export class ConnectionWebSocket {
38
38
  constructor(url) {
39
39
  _ConnectionWebSocket_instances.add(this);