@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
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|