@mtcute/core 0.26.2 → 0.26.3

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.
@@ -6,18 +6,24 @@ if (typeof globalThis !== "undefined" && !globalThis._MTCUTE_CJS_DEPRECATION_WAR
6
6
  "use strict";
7
7
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  function withParams(client, params) {
9
- const wrappedCall = (message, extraParams) => client.call(message, extraParams ? { ...params, ...extraParams } : params);
10
- const proxy = new Proxy(client, {
11
- get: (target, prop, receiver) => {
12
- if (prop === "call") {
13
- return wrappedCall;
9
+ const wrappedClientsMap = /* @__PURE__ */ new WeakMap();
10
+ function wrapClient(client2) {
11
+ const existing = wrappedClientsMap.get(client2);
12
+ if (existing) return existing;
13
+ const wrappedCall = (message, extraParams) => client2.call(message, extraParams ? { ...params, ...extraParams } : params);
14
+ const wrapped = new Proxy(client2, {
15
+ get: (target, prop, receiver) => {
16
+ if (prop === "call") return wrappedCall;
17
+ const res = Reflect.get(target, prop, receiver);
18
+ if (res && typeof res === "object" && "storage" in res && "call" in res) {
19
+ return wrapClient(res);
20
+ }
21
+ return res;
14
22
  }
15
- if (prop === "_client") {
16
- return proxy;
17
- }
18
- return Reflect.get(target, prop, receiver);
19
- }
20
- });
21
- return proxy;
23
+ });
24
+ wrappedClientsMap.set(client2, wrapped);
25
+ return wrapped;
26
+ }
27
+ return wrapClient(client);
22
28
  }
23
29
  exports.withParams = withParams;
@@ -1,17 +1,23 @@
1
1
  function withParams(client, params) {
2
- const wrappedCall = (message, extraParams) => client.call(message, extraParams ? { ...params, ...extraParams } : params);
3
- const proxy = new Proxy(client, {
4
- get: (target, prop, receiver) => {
5
- if (prop === "call") {
6
- return wrappedCall;
2
+ const wrappedClientsMap = /* @__PURE__ */ new WeakMap();
3
+ function wrapClient(client2) {
4
+ const existing = wrappedClientsMap.get(client2);
5
+ if (existing) return existing;
6
+ const wrappedCall = (message, extraParams) => client2.call(message, extraParams ? { ...params, ...extraParams } : params);
7
+ const wrapped = new Proxy(client2, {
8
+ get: (target, prop, receiver) => {
9
+ if (prop === "call") return wrappedCall;
10
+ const res = Reflect.get(target, prop, receiver);
11
+ if (res && typeof res === "object" && "storage" in res && "call" in res) {
12
+ return wrapClient(res);
13
+ }
14
+ return res;
7
15
  }
8
- if (prop === "_client") {
9
- return proxy;
10
- }
11
- return Reflect.get(target, prop, receiver);
12
- }
13
- });
14
- return proxy;
16
+ });
17
+ wrappedClientsMap.set(client2, wrapped);
18
+ return wrapped;
19
+ }
20
+ return wrapClient(client);
15
21
  }
16
22
  export {
17
23
  withParams
@@ -225,7 +225,7 @@ class NetworkManager {
225
225
  _: "initConnection",
226
226
  deviceModel,
227
227
  systemVersion: "1.0",
228
- appVersion: "0.26.2",
228
+ appVersion: "0.26.3",
229
229
  systemLangCode: "en",
230
230
  langPack: "",
231
231
  // "langPacks are for official apps only"
@@ -218,7 +218,7 @@ class NetworkManager {
218
218
  _: "initConnection",
219
219
  deviceModel,
220
220
  systemVersion: "1.0",
221
- appVersion: "0.26.2",
221
+ appVersion: "0.26.3",
222
222
  systemLangCode: "en",
223
223
  langPack: "",
224
224
  // "langPacks are for official apps only"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mtcute/core",
3
3
  "type": "module",
4
- "version": "0.26.2",
4
+ "version": "0.26.3",
5
5
  "description": "Type-safe library for MTProto (Telegram API)",
6
6
  "license": "MIT",
7
7
  "scripts": {},