@mtcute/core 0.23.2 → 0.24.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 (131) hide show
  1. package/client.cjs +21 -2
  2. package/client.js +21 -2
  3. package/highlevel/base.cjs +15 -3
  4. package/highlevel/base.d.cts +4 -1
  5. package/highlevel/base.d.ts +4 -1
  6. package/highlevel/base.js +15 -3
  7. package/highlevel/client.d.cts +56 -7
  8. package/highlevel/client.d.ts +56 -7
  9. package/highlevel/client.types.d.cts +2 -1
  10. package/highlevel/client.types.d.ts +2 -1
  11. package/highlevel/methods/chats/get-chat-event-log.cjs +5 -3
  12. package/highlevel/methods/chats/get-chat-event-log.js +3 -1
  13. package/highlevel/methods/files/download-iterable.cjs +1 -1
  14. package/highlevel/methods/files/download-iterable.js +1 -1
  15. package/highlevel/methods/premium/_normalize-input-star-gift.cjs +6 -0
  16. package/highlevel/methods/premium/_normalize-input-star-gift.js +6 -0
  17. package/highlevel/methods/premium/buy-resale-gift.cjs +30 -0
  18. package/highlevel/methods/premium/buy-resale-gift.d.cts +13 -0
  19. package/highlevel/methods/premium/buy-resale-gift.d.ts +13 -0
  20. package/highlevel/methods/premium/buy-resale-gift.js +25 -0
  21. package/highlevel/methods/premium/get-resale-star-gifts.cjs +107 -0
  22. package/highlevel/methods/premium/get-resale-star-gifts.d.cts +45 -0
  23. package/highlevel/methods/premium/get-resale-star-gifts.d.ts +45 -0
  24. package/highlevel/methods/premium/get-resale-star-gifts.js +102 -0
  25. package/highlevel/methods/premium/get-unique-star-gift.cjs +1 -1
  26. package/highlevel/methods/premium/get-unique-star-gift.js +1 -1
  27. package/highlevel/methods/premium/set-gift-resale-price.cjs +19 -0
  28. package/highlevel/methods/premium/set-gift-resale-price.d.cts +9 -0
  29. package/highlevel/methods/premium/set-gift-resale-price.d.ts +9 -0
  30. package/highlevel/methods/premium/set-gift-resale-price.js +14 -0
  31. package/highlevel/methods/premium/transfer-star-gift.cjs +28 -13
  32. package/highlevel/methods/premium/transfer-star-gift.d.cts +1 -1
  33. package/highlevel/methods/premium/transfer-star-gift.d.ts +1 -1
  34. package/highlevel/methods/premium/transfer-star-gift.js +28 -13
  35. package/highlevel/methods/premium/upgrade-star-gift.cjs +26 -11
  36. package/highlevel/methods/premium/upgrade-star-gift.js +26 -11
  37. package/highlevel/methods/users/resolve-peer.cjs +63 -70
  38. package/highlevel/methods/users/resolve-peer.d.cts +2 -1
  39. package/highlevel/methods/users/resolve-peer.d.ts +2 -1
  40. package/highlevel/methods/users/resolve-peer.js +61 -68
  41. package/highlevel/methods/users/resolve-phone-number.cjs +36 -0
  42. package/highlevel/methods/users/resolve-phone-number.d.cts +10 -0
  43. package/highlevel/methods/users/resolve-phone-number.d.ts +10 -0
  44. package/highlevel/methods/users/resolve-phone-number.js +31 -0
  45. package/highlevel/methods.d.cts +10 -4
  46. package/highlevel/methods.d.ts +10 -4
  47. package/highlevel/types/messages/message-action.cjs +8 -2
  48. package/highlevel/types/messages/message-action.d.cts +6 -0
  49. package/highlevel/types/messages/message-action.d.ts +6 -0
  50. package/highlevel/types/messages/message-action.js +8 -2
  51. package/highlevel/types/peers/chat-event/actions.cjs +49 -1
  52. package/highlevel/types/peers/chat-event/actions.d.cts +60 -2
  53. package/highlevel/types/peers/chat-event/actions.d.ts +60 -2
  54. package/highlevel/types/peers/chat-event/actions.js +49 -1
  55. package/highlevel/types/peers/chat-event/filters.cjs +9 -0
  56. package/highlevel/types/peers/chat-event/filters.js +9 -0
  57. package/highlevel/types/peers/chat-event/index.cjs +3 -2
  58. package/highlevel/types/peers/chat-event/index.d.cts +2 -1
  59. package/highlevel/types/peers/chat-event/index.d.ts +2 -1
  60. package/highlevel/types/peers/chat-event/index.js +3 -2
  61. package/highlevel/types/peers/chat.cjs +5 -4
  62. package/highlevel/types/peers/chat.d.cts +2 -0
  63. package/highlevel/types/peers/chat.d.ts +2 -0
  64. package/highlevel/types/peers/chat.js +5 -4
  65. package/highlevel/types/peers/peer.d.cts +2 -3
  66. package/highlevel/types/peers/peer.d.ts +2 -3
  67. package/highlevel/types/peers/user.cjs +1 -4
  68. package/highlevel/types/peers/user.js +1 -4
  69. package/highlevel/types/premium/saved-star-gift.cjs +8 -0
  70. package/highlevel/types/premium/saved-star-gift.d.cts +4 -0
  71. package/highlevel/types/premium/saved-star-gift.d.ts +4 -0
  72. package/highlevel/types/premium/saved-star-gift.js +8 -0
  73. package/highlevel/types/premium/stars-gift-unique.cjs +13 -2
  74. package/highlevel/types/premium/stars-gift-unique.d.cts +6 -2
  75. package/highlevel/types/premium/stars-gift-unique.d.ts +6 -2
  76. package/highlevel/types/premium/stars-gift-unique.js +13 -2
  77. package/highlevel/types/premium/stars-gift.cjs +11 -1
  78. package/highlevel/types/premium/stars-gift.d.cts +8 -1
  79. package/highlevel/types/premium/stars-gift.d.ts +8 -1
  80. package/highlevel/types/premium/stars-gift.js +11 -1
  81. package/highlevel/types/premium/stars-transaction.cjs +7 -1
  82. package/highlevel/types/premium/stars-transaction.d.cts +9 -2
  83. package/highlevel/types/premium/stars-transaction.d.ts +9 -2
  84. package/highlevel/types/premium/stars-transaction.js +7 -1
  85. package/highlevel/types/reactions/emoji-status.cjs +6 -0
  86. package/highlevel/types/reactions/emoji-status.d.cts +1 -0
  87. package/highlevel/types/reactions/emoji-status.d.ts +1 -0
  88. package/highlevel/types/reactions/emoji-status.js +6 -0
  89. package/highlevel/types/utils.d.cts +4 -0
  90. package/highlevel/types/utils.d.ts +4 -0
  91. package/highlevel/updates/manager.cjs +35 -26
  92. package/highlevel/updates/manager.d.cts +6 -6
  93. package/highlevel/updates/manager.d.ts +6 -6
  94. package/highlevel/updates/manager.js +35 -26
  95. package/highlevel/updates/types.d.cts +6 -6
  96. package/highlevel/updates/types.d.ts +6 -6
  97. package/highlevel/utils/misc-utils.cjs +8 -0
  98. package/highlevel/utils/misc-utils.d.cts +2 -1
  99. package/highlevel/utils/misc-utils.d.ts +2 -1
  100. package/highlevel/utils/misc-utils.js +8 -0
  101. package/highlevel/worker/port.cjs +7 -5
  102. package/highlevel/worker/port.d.cts +3 -2
  103. package/highlevel/worker/port.d.ts +3 -2
  104. package/highlevel/worker/port.js +7 -5
  105. package/methods.cjs +8 -0
  106. package/methods.js +8 -0
  107. package/network/client.cjs +12 -8
  108. package/network/client.d.cts +4 -1
  109. package/network/client.d.ts +4 -1
  110. package/network/client.js +12 -8
  111. package/network/network-manager.cjs +1 -1
  112. package/network/network-manager.js +1 -1
  113. package/network/session-connection.cjs +1 -0
  114. package/network/session-connection.js +1 -0
  115. package/package.json +2 -2
  116. package/utils/binary/compat.cjs +9 -0
  117. package/utils/binary/compat.js +9 -0
  118. package/utils/index.d.cts +0 -1
  119. package/utils/index.d.ts +0 -1
  120. package/utils/sorted-array.cjs +6 -0
  121. package/utils/sorted-array.d.cts +2 -0
  122. package/utils/sorted-array.d.ts +2 -0
  123. package/utils/sorted-array.js +6 -0
  124. package/utils.cjs +1 -2
  125. package/utils.js +2 -3
  126. package/utils/linked-list.cjs +0 -65
  127. package/utils/linked-list.d.cts +0 -21
  128. package/utils/linked-list.d.ts +0 -21
  129. package/utils/linked-list.js +0 -60
  130. package/utils/linked-list.test.d.cts +0 -1
  131. package/utils/linked-list.test.d.ts +0 -1
@@ -19,7 +19,8 @@ class TelegramWorkerPort {
19
19
  const bind = this._invoker.makeBinder("client");
20
20
  this.prepare = bind("prepare");
21
21
  this._connect = bind("connect");
22
- this.close = bind("close");
22
+ this.disconnect = bind("disconnect");
23
+ this.destroy_ = bind("destroy");
23
24
  this.notifyLoggedIn = bind("notifyLoggedIn");
24
25
  this.notifyLoggedOut = bind("notifyLoggedOut");
25
26
  this.notifyChannelOpened = bind("notifyChannelOpened");
@@ -53,7 +54,8 @@ class TelegramWorkerPort {
53
54
  // bound methods
54
55
  prepare;
55
56
  _connect;
56
- close;
57
+ disconnect;
58
+ destroy_;
57
59
  notifyLoggedIn;
58
60
  notifyLoggedOut;
59
61
  notifyChannelOpened;
@@ -113,14 +115,14 @@ class TelegramWorkerPort {
113
115
  }
114
116
  };
115
117
  _destroyed = false;
116
- destroy(terminate = false) {
118
+ async destroy(terminate = false) {
117
119
  if (this._destroyed) return;
120
+ await this.destroy_();
118
121
  this.timers.destroy();
119
122
  this._connection[1]();
120
123
  this._destroyed = true;
121
124
  if (terminate && "terminate" in this.options.worker) {
122
- Promise.resolve(this.options.worker.terminate()).catch(() => {
123
- });
125
+ await Promise.resolve(this.options.worker.terminate());
124
126
  }
125
127
  }
126
128
  invokeCustom(method, ...args) {
package/methods.cjs CHANGED
@@ -188,6 +188,7 @@ const removeCloudPassword = require("./highlevel/methods/password/remove-cloud-p
188
188
  const _normalizeInputStarGift = require("./highlevel/methods/premium/_normalize-input-star-gift.cjs");
189
189
  const acceptStarGift = require("./highlevel/methods/premium/accept-star-gift.cjs");
190
190
  const applyBoost = require("./highlevel/methods/premium/apply-boost.cjs");
191
+ const buyResaleGift = require("./highlevel/methods/premium/buy-resale-gift.cjs");
191
192
  const canApplyBoost = require("./highlevel/methods/premium/can-apply-boost.cjs");
192
193
  const createBusinessChatLink = require("./highlevel/methods/premium/create-business-chat-link.cjs");
193
194
  const editBusinessChatLink = require("./highlevel/methods/premium/edit-business-chat-link.cjs");
@@ -196,6 +197,7 @@ const getBoosts = require("./highlevel/methods/premium/get-boosts.cjs");
196
197
  const getBusinessChatLinks = require("./highlevel/methods/premium/get-business-chat-links.cjs");
197
198
  const getBusinessConnection = require("./highlevel/methods/premium/get-business-connection.cjs");
198
199
  const getMyBoostSlots = require("./highlevel/methods/premium/get-my-boost-slots.cjs");
200
+ const getResaleStarGifts = require("./highlevel/methods/premium/get-resale-star-gifts.cjs");
199
201
  const getSavedStarGiftsById = require("./highlevel/methods/premium/get-saved-star-gifts-by-id.cjs");
200
202
  const getSavedStarGifts = require("./highlevel/methods/premium/get-saved-star-gifts.cjs");
201
203
  const getStarGiftOptions = require("./highlevel/methods/premium/get-star-gift-options.cjs");
@@ -209,6 +211,7 @@ const pinStarGift = require("./highlevel/methods/premium/pin-star-gift.cjs");
209
211
  const sendStarGift = require("./highlevel/methods/premium/send-star-gift.cjs");
210
212
  const setBusinessIntro = require("./highlevel/methods/premium/set-business-intro.cjs");
211
213
  const setBusinessWorkHours = require("./highlevel/methods/premium/set-business-work-hours.cjs");
214
+ const setGiftResalePrice = require("./highlevel/methods/premium/set-gift-resale-price.cjs");
212
215
  const transferStarGift = require("./highlevel/methods/premium/transfer-star-gift.cjs");
213
216
  const upgradeStarGift = require("./highlevel/methods/premium/upgrade-star-gift.cjs");
214
217
  const addStickerToSet = require("./highlevel/methods/stickers/add-sticker-to-set.cjs");
@@ -257,6 +260,7 @@ const isPeerAvailable = require("./highlevel/methods/users/is-peer-available.cjs
257
260
  const iterProfilePhotos = require("./highlevel/methods/users/iter-profile-photos.cjs");
258
261
  const resolvePeerMany = require("./highlevel/methods/users/resolve-peer-many.cjs");
259
262
  const resolvePeer = require("./highlevel/methods/users/resolve-peer.cjs");
263
+ const resolvePhoneNumber = require("./highlevel/methods/users/resolve-phone-number.cjs");
260
264
  const setEmojiStatus = require("./highlevel/methods/users/set-emoji-status.cjs");
261
265
  const setGlobalTtl = require("./highlevel/methods/users/set-global-ttl.cjs");
262
266
  const setMyBirthday = require("./highlevel/methods/users/set-my-birthday.cjs");
@@ -466,6 +470,7 @@ exports.removeCloudPassword = removeCloudPassword.removeCloudPassword;
466
470
  exports._normalizeInputStarGift = _normalizeInputStarGift._normalizeInputStarGift;
467
471
  exports.acceptStarGift = acceptStarGift.acceptStarGift;
468
472
  exports.applyBoost = applyBoost.applyBoost;
473
+ exports.buyResaleGift = buyResaleGift.buyResaleGift;
469
474
  exports.canApplyBoost = canApplyBoost.canApplyBoost;
470
475
  exports.createBusinessChatLink = createBusinessChatLink.createBusinessChatLink;
471
476
  exports.deleteBusinessChatLink = editBusinessChatLink.deleteBusinessChatLink;
@@ -475,6 +480,7 @@ exports.getBoosts = getBoosts.getBoosts;
475
480
  exports.getBusinessChatLinks = getBusinessChatLinks.getBusinessChatLinks;
476
481
  exports.getBusinessConnection = getBusinessConnection.getBusinessConnection;
477
482
  exports.getMyBoostSlots = getMyBoostSlots.getMyBoostSlots;
483
+ exports.getResaleOptions = getResaleStarGifts.getResaleOptions;
478
484
  exports.getSavedStarGiftsById = getSavedStarGiftsById.getSavedStarGiftsById;
479
485
  exports.getSavedStarGifts = getSavedStarGifts.getSavedStarGifts;
480
486
  exports.getStarGiftOptions = getStarGiftOptions.getStarGiftOptions;
@@ -488,6 +494,7 @@ exports.togglePinnedStarGifts = pinStarGift.togglePinnedStarGifts;
488
494
  exports.sendStarGift = sendStarGift.sendStarGift;
489
495
  exports.setBusinessIntro = setBusinessIntro.setBusinessIntro;
490
496
  exports.setBusinessWorkHours = setBusinessWorkHours.setBusinessWorkHours;
497
+ exports.setResaleStarGiftPrice = setGiftResalePrice.setResaleStarGiftPrice;
491
498
  exports.transferStarGift = transferStarGift.transferStarGift;
492
499
  exports.upgradeStarGift = upgradeStarGift.upgradeStarGift;
493
500
  exports.addStickerToSet = addStickerToSet.addStickerToSet;
@@ -540,6 +547,7 @@ exports.resolvePeerMany = resolvePeerMany.resolvePeerMany;
540
547
  exports.resolveChannel = resolvePeer.resolveChannel;
541
548
  exports.resolvePeer = resolvePeer.resolvePeer;
542
549
  exports.resolveUser = resolvePeer.resolveUser;
550
+ exports.resolvePhoneNumber = resolvePhoneNumber.resolvePhoneNumber;
543
551
  exports.setEmojiStatus = setEmojiStatus.setEmojiStatus;
544
552
  exports.setMyEmojiStatus = setEmojiStatus.setMyEmojiStatus;
545
553
  exports.setGlobalTtl = setGlobalTtl.setGlobalTtl;
package/methods.js CHANGED
@@ -181,6 +181,7 @@ import { removeCloudPassword } from "./highlevel/methods/password/remove-cloud-p
181
181
  import { _normalizeInputStarGift } from "./highlevel/methods/premium/_normalize-input-star-gift.js";
182
182
  import { acceptStarGift } from "./highlevel/methods/premium/accept-star-gift.js";
183
183
  import { applyBoost } from "./highlevel/methods/premium/apply-boost.js";
184
+ import { buyResaleGift } from "./highlevel/methods/premium/buy-resale-gift.js";
184
185
  import { canApplyBoost } from "./highlevel/methods/premium/can-apply-boost.js";
185
186
  import { createBusinessChatLink } from "./highlevel/methods/premium/create-business-chat-link.js";
186
187
  import { deleteBusinessChatLink, editBusinessChatLink } from "./highlevel/methods/premium/edit-business-chat-link.js";
@@ -189,6 +190,7 @@ import { getBoosts } from "./highlevel/methods/premium/get-boosts.js";
189
190
  import { getBusinessChatLinks } from "./highlevel/methods/premium/get-business-chat-links.js";
190
191
  import { getBusinessConnection } from "./highlevel/methods/premium/get-business-connection.js";
191
192
  import { getMyBoostSlots } from "./highlevel/methods/premium/get-my-boost-slots.js";
193
+ import { getResaleOptions } from "./highlevel/methods/premium/get-resale-star-gifts.js";
192
194
  import { getSavedStarGiftsById } from "./highlevel/methods/premium/get-saved-star-gifts-by-id.js";
193
195
  import { getSavedStarGifts } from "./highlevel/methods/premium/get-saved-star-gifts.js";
194
196
  import { getStarGiftOptions } from "./highlevel/methods/premium/get-star-gift-options.js";
@@ -202,6 +204,7 @@ import { togglePinnedStarGifts } from "./highlevel/methods/premium/pin-star-gift
202
204
  import { sendStarGift } from "./highlevel/methods/premium/send-star-gift.js";
203
205
  import { setBusinessIntro } from "./highlevel/methods/premium/set-business-intro.js";
204
206
  import { setBusinessWorkHours } from "./highlevel/methods/premium/set-business-work-hours.js";
207
+ import { setResaleStarGiftPrice } from "./highlevel/methods/premium/set-gift-resale-price.js";
205
208
  import { transferStarGift } from "./highlevel/methods/premium/transfer-star-gift.js";
206
209
  import { upgradeStarGift } from "./highlevel/methods/premium/upgrade-star-gift.js";
207
210
  import { addStickerToSet } from "./highlevel/methods/stickers/add-sticker-to-set.js";
@@ -250,6 +253,7 @@ import { isPeerAvailable } from "./highlevel/methods/users/is-peer-available.js"
250
253
  import { iterProfilePhotos } from "./highlevel/methods/users/iter-profile-photos.js";
251
254
  import { resolvePeerMany } from "./highlevel/methods/users/resolve-peer-many.js";
252
255
  import { resolveChannel, resolvePeer, resolveUser } from "./highlevel/methods/users/resolve-peer.js";
256
+ import { resolvePhoneNumber } from "./highlevel/methods/users/resolve-phone-number.js";
253
257
  import { setEmojiStatus, setMyEmojiStatus } from "./highlevel/methods/users/set-emoji-status.js";
254
258
  import { setGlobalTtl } from "./highlevel/methods/users/set-global-ttl.js";
255
259
  import { setMyBirthday } from "./highlevel/methods/users/set-my-birthday.js";
@@ -277,6 +281,7 @@ export {
277
281
  archiveChats,
278
282
  banChatMember,
279
283
  blockUser,
284
+ buyResaleGift,
280
285
  canApplyBoost,
281
286
  canSendStory,
282
287
  cancelPasswordEmail,
@@ -391,6 +396,7 @@ export {
391
396
  getProfileStories,
392
397
  getReactionUsers,
393
398
  getReplyTo,
399
+ getResaleOptions,
394
400
  getSavedStarGifts,
395
401
  getSavedStarGiftsById,
396
402
  getScheduledMessages,
@@ -463,6 +469,7 @@ export {
463
469
  resolveChannel,
464
470
  resolvePeer,
465
471
  resolvePeerMany,
472
+ resolvePhoneNumber,
466
473
  resolveUser,
467
474
  restrictChatMember,
468
475
  revokeInviteLink,
@@ -511,6 +518,7 @@ export {
511
518
  setMyProfilePhoto,
512
519
  setMyUsername,
513
520
  setOnline,
521
+ setResaleStarGiftPrice,
514
522
  setSlowMode,
515
523
  setStickerSetThumb,
516
524
  setTyping,
@@ -142,19 +142,23 @@ class MtClient {
142
142
  async connect() {
143
143
  return this._connect.run();
144
144
  }
145
- /**
146
- * Close all connections and finalize the client.
147
- */
148
- async close() {
149
- this.log.debug("closing client");
150
- this._config.destroy();
145
+ async disconnect() {
151
146
  await this.network.destroy();
152
147
  await this.storage.save();
153
- await this.storage.destroy?.();
148
+ this._config.destroy();
154
149
  this._prepare.reset();
155
150
  this._connect.reset();
156
151
  this._abortController.abort();
157
- this.log.debug("client closed successfully");
152
+ this.log.debug("client disconnected");
153
+ }
154
+ /**
155
+ * Close all connections and finalize the client.
156
+ *
157
+ * **Note**: must be called *after* {@link disconnect}
158
+ */
159
+ async destroy() {
160
+ await this.storage.destroy();
161
+ this.log.debug("client destroyed");
158
162
  }
159
163
  /**
160
164
  * Make an RPC call.
@@ -194,10 +194,13 @@ export declare class MtClient {
194
194
  * implicitly the first time you call {@link call}.
195
195
  */
196
196
  connect(): Promise<void>;
197
+ disconnect(): Promise<void>;
197
198
  /**
198
199
  * Close all connections and finalize the client.
200
+ *
201
+ * **Note**: must be called *after* {@link disconnect}
199
202
  */
200
- close(): Promise<void>;
203
+ destroy(): Promise<void>;
201
204
  /**
202
205
  * Make an RPC call.
203
206
  *
@@ -194,10 +194,13 @@ export declare class MtClient {
194
194
  * implicitly the first time you call {@link call}.
195
195
  */
196
196
  connect(): Promise<void>;
197
+ disconnect(): Promise<void>;
197
198
  /**
198
199
  * Close all connections and finalize the client.
200
+ *
201
+ * **Note**: must be called *after* {@link disconnect}
199
202
  */
200
- close(): Promise<void>;
203
+ destroy(): Promise<void>;
201
204
  /**
202
205
  * Make an RPC call.
203
206
  *
package/network/client.js CHANGED
@@ -135,19 +135,23 @@ class MtClient {
135
135
  async connect() {
136
136
  return this._connect.run();
137
137
  }
138
- /**
139
- * Close all connections and finalize the client.
140
- */
141
- async close() {
142
- this.log.debug("closing client");
143
- this._config.destroy();
138
+ async disconnect() {
144
139
  await this.network.destroy();
145
140
  await this.storage.save();
146
- await this.storage.destroy?.();
141
+ this._config.destroy();
147
142
  this._prepare.reset();
148
143
  this._connect.reset();
149
144
  this._abortController.abort();
150
- this.log.debug("client closed successfully");
145
+ this.log.debug("client disconnected");
146
+ }
147
+ /**
148
+ * Close all connections and finalize the client.
149
+ *
150
+ * **Note**: must be called *after* {@link disconnect}
151
+ */
152
+ async destroy() {
153
+ await this.storage.destroy();
154
+ this.log.debug("client destroyed");
151
155
  }
152
156
  /**
153
157
  * Make an RPC call.
@@ -220,7 +220,7 @@ class NetworkManager {
220
220
  _: "initConnection",
221
221
  deviceModel,
222
222
  systemVersion: "1.0",
223
- appVersion: "0.23.2",
223
+ appVersion: "0.24.0",
224
224
  systemLangCode: "en",
225
225
  langPack: "",
226
226
  // "langPacks are for official apps only"
@@ -213,7 +213,7 @@ class NetworkManager {
213
213
  _: "initConnection",
214
214
  deviceModel,
215
215
  systemVersion: "1.0",
216
- appVersion: "0.23.2",
216
+ appVersion: "0.24.0",
217
217
  systemLangCode: "en",
218
218
  langPack: "",
219
219
  // "langPacks are for official apps only"
@@ -112,6 +112,7 @@ class SessionConnection extends persistentConnection.PersistentConnection {
112
112
  this._session.initConnectionCalled = false;
113
113
  this._flushTimer.reset();
114
114
  this._salts.isFetching = false;
115
+ this._session.resetLastPing(true);
115
116
  if (forever) {
116
117
  utils.timers.clearTimeout(this._pfsUpdateTimeout);
117
118
  this.onDisconnect.clear();
@@ -105,6 +105,7 @@ class SessionConnection extends PersistentConnection {
105
105
  this._session.initConnectionCalled = false;
106
106
  this._flushTimer.reset();
107
107
  this._salts.isFetching = false;
108
+ this._session.resetLastPing(true);
108
109
  if (forever) {
109
110
  timers.clearTimeout(this._pfsUpdateTimeout);
110
111
  this.onDisconnect.clear();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mtcute/core",
3
3
  "type": "module",
4
- "version": "0.23.2",
4
+ "version": "0.24.0",
5
5
  "description": "Type-safe library for MTProto (Telegram API)",
6
6
  "license": "MIT",
7
7
  "scripts": {},
@@ -10,7 +10,7 @@
10
10
  "@fuman/net": "0.0.14",
11
11
  "@fuman/utils": "0.0.14",
12
12
  "@mtcute/file-id": "^0.23.0",
13
- "@mtcute/tl": "^202.0.0",
13
+ "@mtcute/tl": "^203.0.0",
14
14
  "@mtcute/tl-runtime": "^0.23.0",
15
15
  "@types/events": "3.0.0",
16
16
  "long": "5.2.3"
@@ -30,7 +30,10 @@ function mapCompatStarGift(obj) {
30
30
  ownerId: obj.ownerId ? { _: "peerUser", userId: obj.ownerId } : void 0
31
31
  };
32
32
  case "starGiftUnique_layer198":
33
+ case "starGiftUnique_layer202":
33
34
  return replaceType(obj, "starGiftUnique");
35
+ case "starGift_layer202":
36
+ return replaceType(obj, "starGift");
34
37
  default:
35
38
  return obj;
36
39
  }
@@ -58,6 +61,7 @@ function mapCompatMessageMedia(obj) {
58
61
  function mapCompatMessageAction(obj) {
59
62
  switch (obj._) {
60
63
  case "messageActionStarGiftUnique_layer197":
64
+ case "messageActionStarGiftUnique_layer202":
61
65
  return {
62
66
  ...obj,
63
67
  _: "messageActionStarGiftUnique",
@@ -77,6 +81,8 @@ function mapCompatObject(obj) {
77
81
  switch (obj._) {
78
82
  case "starGiftUnique_layer197":
79
83
  case "starGiftUnique_layer198":
84
+ case "starGiftUnique_layer202":
85
+ case "starGift_layer202":
80
86
  return mapCompatStarGift(obj);
81
87
  case "emojiStatus_layer197":
82
88
  return mapCompatEmojiStatus(obj);
@@ -86,6 +92,7 @@ function mapCompatObject(obj) {
86
92
  return replaceType(obj, "channelFull");
87
93
  case "messageActionStarGiftUnique_layer197":
88
94
  case "messageActionStarGift_layer197":
95
+ case "messageActionStarGiftUnique_layer202":
89
96
  return mapCompatMessageAction(obj);
90
97
  case "userFull_layer199":
91
98
  return replaceType(dropFields(obj, ["premiumGifts"]), "userFull");
@@ -109,6 +116,8 @@ function mapCompatObject(obj) {
109
116
  _: "message",
110
117
  media: obj.media ? mapCompatMessageMedia(obj.media) : void 0
111
118
  };
119
+ case "phoneCallDiscardReasonAllowGroupCall_layer202":
120
+ return { _: "phoneCallDiscardReasonMissed" };
112
121
  default:
113
122
  return obj;
114
123
  }
@@ -23,7 +23,10 @@ function mapCompatStarGift(obj) {
23
23
  ownerId: obj.ownerId ? { _: "peerUser", userId: obj.ownerId } : void 0
24
24
  };
25
25
  case "starGiftUnique_layer198":
26
+ case "starGiftUnique_layer202":
26
27
  return replaceType(obj, "starGiftUnique");
28
+ case "starGift_layer202":
29
+ return replaceType(obj, "starGift");
27
30
  default:
28
31
  return obj;
29
32
  }
@@ -51,6 +54,7 @@ function mapCompatMessageMedia(obj) {
51
54
  function mapCompatMessageAction(obj) {
52
55
  switch (obj._) {
53
56
  case "messageActionStarGiftUnique_layer197":
57
+ case "messageActionStarGiftUnique_layer202":
54
58
  return {
55
59
  ...obj,
56
60
  _: "messageActionStarGiftUnique",
@@ -70,6 +74,8 @@ function mapCompatObject(obj) {
70
74
  switch (obj._) {
71
75
  case "starGiftUnique_layer197":
72
76
  case "starGiftUnique_layer198":
77
+ case "starGiftUnique_layer202":
78
+ case "starGift_layer202":
73
79
  return mapCompatStarGift(obj);
74
80
  case "emojiStatus_layer197":
75
81
  return mapCompatEmojiStatus(obj);
@@ -79,6 +85,7 @@ function mapCompatObject(obj) {
79
85
  return replaceType(obj, "channelFull");
80
86
  case "messageActionStarGiftUnique_layer197":
81
87
  case "messageActionStarGift_layer197":
88
+ case "messageActionStarGiftUnique_layer202":
82
89
  return mapCompatMessageAction(obj);
83
90
  case "userFull_layer199":
84
91
  return replaceType(dropFields(obj, ["premiumGifts"]), "userFull");
@@ -102,6 +109,8 @@ function mapCompatObject(obj) {
102
109
  _: "message",
103
110
  media: obj.media ? mapCompatMessageMedia(obj.media) : void 0
104
111
  };
112
+ case "phoneCallDiscardReasonAllowGroupCall_layer202":
113
+ return { _: "phoneCallDiscardReasonMissed" };
105
114
  default:
106
115
  return obj;
107
116
  }
package/utils/index.d.cts CHANGED
@@ -10,7 +10,6 @@ export * from './crypto/index.js';
10
10
  export * from './dcs.js';
11
11
  export * from './early-timer.js';
12
12
  export * from './function-utils.js';
13
- export * from './linked-list.js';
14
13
  export * from './links/index.js';
15
14
  export * from './logger.js';
16
15
  export * from './long-utils.js';
package/utils/index.d.ts CHANGED
@@ -10,7 +10,6 @@ export * from './crypto/index.js';
10
10
  export * from './dcs.js';
11
11
  export * from './early-timer.js';
12
12
  export * from './function-utils.js';
13
- export * from './linked-list.js';
14
13
  export * from './links/index.js';
15
14
  export * from './logger.js';
16
15
  export * from './long-utils.js';
@@ -65,6 +65,9 @@ class SortedArray {
65
65
  if (idx === -1) return;
66
66
  this.raw.splice(idx, 1);
67
67
  }
68
+ removeIndex(idx) {
69
+ this.raw.splice(idx, 1);
70
+ }
68
71
  includes(item) {
69
72
  return this.index(item) !== -1;
70
73
  }
@@ -75,5 +78,8 @@ class SortedArray {
75
78
  clear() {
76
79
  this.raw.length = 0;
77
80
  }
81
+ popFront() {
82
+ return this.raw.shift();
83
+ }
78
84
  }
79
85
  exports.SortedArray = SortedArray;
@@ -11,7 +11,9 @@ export declare class SortedArray<T> {
11
11
  insert(item: T | T[]): number;
12
12
  index(item: T, closest?: boolean): number;
13
13
  remove(item: T): void;
14
+ removeIndex(idx: number): void;
14
15
  includes(item: T): boolean;
15
16
  find(item: T): T | null;
16
17
  clear(): void;
18
+ popFront(): T | undefined;
17
19
  }
@@ -11,7 +11,9 @@ export declare class SortedArray<T> {
11
11
  insert(item: T | T[]): number;
12
12
  index(item: T, closest?: boolean): number;
13
13
  remove(item: T): void;
14
+ removeIndex(idx: number): void;
14
15
  includes(item: T): boolean;
15
16
  find(item: T): T | null;
16
17
  clear(): void;
18
+ popFront(): T | undefined;
17
19
  }
@@ -58,6 +58,9 @@ class SortedArray {
58
58
  if (idx === -1) return;
59
59
  this.raw.splice(idx, 1);
60
60
  }
61
+ removeIndex(idx) {
62
+ this.raw.splice(idx, 1);
63
+ }
61
64
  includes(item) {
62
65
  return this.index(item) !== -1;
63
66
  }
@@ -68,6 +71,9 @@ class SortedArray {
68
71
  clear() {
69
72
  this.raw.length = 0;
70
73
  }
74
+ popFront() {
75
+ return this.raw.shift();
76
+ }
71
77
  }
72
78
  export {
73
79
  SortedArray
package/utils.cjs CHANGED
@@ -15,7 +15,6 @@ const serialization = require("./utils/binary/serialization.cjs");
15
15
  const dcs = require("./utils/dcs.cjs");
16
16
  const earlyTimer = require("./utils/early-timer.cjs");
17
17
  const functionUtils = require("./utils/function-utils.cjs");
18
- const linkedList = require("./utils/linked-list.cjs");
19
18
  const logger = require("./utils/logger.cjs");
20
19
  const longUtils = require("./utils/long-utils.cjs");
21
20
  const miscUtils$1 = require("./utils/misc-utils.cjs");
@@ -64,7 +63,6 @@ exports.serializeBasicDcOption = dcs.serializeBasicDcOption;
64
63
  exports.EarlyTimer = earlyTimer.EarlyTimer;
65
64
  exports.asyncResettable = functionUtils.asyncResettable;
66
65
  exports.throttle = functionUtils.throttle;
67
- exports.SortedLinkedList = linkedList.SortedLinkedList;
68
66
  exports.LogManager = logger.LogManager;
69
67
  exports.Logger = logger.Logger;
70
68
  exports.LongMap = longUtils.LongMap;
@@ -111,6 +109,7 @@ exports.normalizeInlineId = inlineUtils.normalizeInlineId;
111
109
  exports.parseInlineMessageId = inlineUtils.parseInlineMessageId;
112
110
  exports.makeInspectable = inspectable.makeInspectable;
113
111
  exports.makeArrayPaginated = miscUtils.makeArrayPaginated;
112
+ exports.makeArrayPaginatedWithMeta = miscUtils.makeArrayPaginatedWithMeta;
114
113
  exports.makeArrayWithTotal = miscUtils.makeArrayWithTotal;
115
114
  exports.normalizeDate = miscUtils.normalizeDate;
116
115
  exports.normalizeMessageId = miscUtils.normalizeMessageId;
package/utils.js CHANGED
@@ -8,7 +8,6 @@ import { deserializeObject, deserializePeersIndex, serializeObject, serializePee
8
8
  import { defaultProductionDc, defaultProductionIpv6Dc, defaultTestDc, defaultTestIpv6Dc, parseBasicDcOption, serializeBasicDcOption } from "./utils/dcs.js";
9
9
  import { EarlyTimer } from "./utils/early-timer.js";
10
10
  import { asyncResettable, throttle } from "./utils/function-utils.js";
11
- import { SortedLinkedList } from "./utils/linked-list.js";
12
11
  import { LogManager, Logger } from "./utils/logger.js";
13
12
  import { LongMap, LongSet, compareLongs, longFromBuffer, longFromFastString, longToFastString, randomLong, removeFromLongArray } from "./utils/long-utils.js";
14
13
  import { getRandomInt, sleepWithAbort } from "./utils/misc-utils.js";
@@ -22,7 +21,7 @@ import { joinTextWithEntities } from "./highlevel/utils/entities.js";
22
21
  import { determinePartSize, extractFileName, inflateSvgPath, isProbablyPlainText, strippedPhotoToJpg, svgPathToFile } from "./highlevel/utils/file-utils.js";
23
22
  import { encodeInlineMessageId, normalizeInlineId, parseInlineMessageId } from "./highlevel/utils/inline-utils.js";
24
23
  import { makeInspectable } from "./highlevel/utils/inspectable.js";
25
- import { makeArrayPaginated, makeArrayWithTotal, normalizeDate, normalizeMessageId, normalizePhoneNumber, resolveMaybeDynamic } from "./highlevel/utils/misc-utils.js";
24
+ import { makeArrayPaginated, makeArrayPaginatedWithMeta, makeArrayWithTotal, normalizeDate, normalizeMessageId, normalizePhoneNumber, resolveMaybeDynamic } from "./highlevel/utils/misc-utils.js";
26
25
  import { INVITE_LINK_REGEX, extractUsernames, inputPeerToPeer, isInputPeerChannel, isInputPeerChat, isInputPeerUser, toInputChannel, toInputPeer, toInputUser } from "./highlevel/utils/peer-utils.js";
27
26
  import { RpsMeter } from "./highlevel/utils/rps-meter.js";
28
27
  import { streamToBuffer } from "./highlevel/utils/stream-utils.js";
@@ -48,7 +47,6 @@ export {
48
47
  LongSet,
49
48
  RpsMeter,
50
49
  SortedArray,
51
- SortedLinkedList,
52
50
  UpdatesStateService,
53
51
  addPublicKey,
54
52
  assertTrue,
@@ -105,6 +103,7 @@ export {
105
103
  longFromFastString,
106
104
  longToFastString,
107
105
  makeArrayPaginated,
106
+ makeArrayPaginatedWithMeta,
108
107
  makeArrayWithTotal,
109
108
  makeInspectable,
110
109
  millerRabin,
@@ -1,65 +0,0 @@
1
- if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
2
- globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true;
3
- console.warn("[@mtcute/core] CommonJS support is deprecated and will be removed in 0.25.0. Please consider switching to ESM, it's " + (/* @__PURE__ */ new Date()).getFullYear() + " already.");
4
- console.warn("[@mtcute/core] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c");
5
- }
6
- "use strict";
7
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
- class SortedLinkedList {
9
- constructor(comparator) {
10
- this.comparator = comparator;
11
- }
12
- _first;
13
- _last;
14
- _size = 0;
15
- get length() {
16
- return this._size;
17
- }
18
- _remove(item) {
19
- if (this._first === item) {
20
- this._first = item.n;
21
- }
22
- if (this._last === item) {
23
- this._last = item.p;
24
- }
25
- if (item.p) item.p.n = item.n;
26
- if (item.n) item.n.p = item.p;
27
- this._size -= 1;
28
- }
29
- popFront() {
30
- if (!this._first) return void 0;
31
- const it = this._first;
32
- this._first = this._first.n;
33
- if (!this._first) this._last = void 0;
34
- this._size -= 1;
35
- return it.v;
36
- }
37
- add(item) {
38
- const it = { v: item };
39
- if (!this._first) {
40
- this._first = this._last = it;
41
- } else {
42
- let cur = this._first;
43
- while (cur && this.comparator(cur.v, it.v) < 0) {
44
- cur = cur.n;
45
- }
46
- if (!cur) {
47
- this._last.n = it;
48
- it.p = this._last;
49
- this._last = it;
50
- } else {
51
- it.n = cur;
52
- it.p = cur.p;
53
- if (cur.p) cur.p.n = it;
54
- cur.p = it;
55
- if (cur === this._first) this._first = it;
56
- }
57
- }
58
- this._size += 1;
59
- }
60
- clear() {
61
- this._first = this._last = void 0;
62
- this._size = 0;
63
- }
64
- }
65
- exports.SortedLinkedList = SortedLinkedList;
@@ -1,21 +0,0 @@
1
- interface LinkedListItem<T> {
2
- v: T;
3
- n?: LinkedListItem<T>;
4
- p?: LinkedListItem<T>;
5
- }
6
- /**
7
- * A sorted linked list.
8
- */
9
- export declare class SortedLinkedList<T> {
10
- private comparator;
11
- _first?: LinkedListItem<T>;
12
- _last?: LinkedListItem<T>;
13
- _size: number;
14
- constructor(comparator: (a: T, b: T) => number);
15
- get length(): number;
16
- _remove(item: LinkedListItem<T>): void;
17
- popFront(): T | undefined;
18
- add(item: T): void;
19
- clear(): void;
20
- }
21
- export {};
@@ -1,21 +0,0 @@
1
- interface LinkedListItem<T> {
2
- v: T;
3
- n?: LinkedListItem<T>;
4
- p?: LinkedListItem<T>;
5
- }
6
- /**
7
- * A sorted linked list.
8
- */
9
- export declare class SortedLinkedList<T> {
10
- private comparator;
11
- _first?: LinkedListItem<T>;
12
- _last?: LinkedListItem<T>;
13
- _size: number;
14
- constructor(comparator: (a: T, b: T) => number);
15
- get length(): number;
16
- _remove(item: LinkedListItem<T>): void;
17
- popFront(): T | undefined;
18
- add(item: T): void;
19
- clear(): void;
20
- }
21
- export {};