@medievalrain/binance-ts 0.5.4 → 0.6.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.
- package/dist/index.d.ts +2 -1
- package/dist/index.js +12 -23
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import z$1, { z } from "zod";
|
|
2
2
|
import { Client, WebSocket } from "undici";
|
|
3
3
|
import * as z4 from "zod/v4/core";
|
|
4
|
+
import { CallbackOptions } from "@medievalrain/emitter";
|
|
4
5
|
|
|
5
6
|
//#region src/rest/futures/schema.d.ts
|
|
6
7
|
declare const FuturesTestConnectivitySchema: z.ZodObject<{}, z.core.$strip>;
|
|
@@ -1491,7 +1492,7 @@ type OptArgs<CM extends ChannelsMap, K extends keyof CM> = CM[K]["subscriptionOp
|
|
|
1491
1492
|
type WebsocketClient<CM extends ChannelsMap> = { [K in keyof CM]: {
|
|
1492
1493
|
subscribe: (symbols: string[], ...args: OptArgs<CM, K>) => Promise<void>;
|
|
1493
1494
|
unsubscribe: (symbols: string[], ...args: OptArgs<CM, K>) => Promise<void>;
|
|
1494
|
-
addEventListener: (cb: (data: CM[K]["messageSchema"]) => void, options?:
|
|
1495
|
+
addEventListener: (cb: (data: CM[K]["messageSchema"]) => void, options?: CallbackOptions) => void;
|
|
1495
1496
|
} };
|
|
1496
1497
|
//#endregion
|
|
1497
1498
|
//#region src/websocket/futures/types.d.ts
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import z$1, { z } from "zod";
|
|
|
2
2
|
import { Client, WebSocket } from "undici";
|
|
3
3
|
import * as z4 from "zod/v4/core";
|
|
4
4
|
import { createHmac } from "node:crypto";
|
|
5
|
+
import { createEmitter } from "@medievalrain/emitter";
|
|
5
6
|
|
|
6
7
|
//#region src/rest/futures/schema.ts
|
|
7
8
|
const FuturesTestConnectivitySchema = z.object({});
|
|
@@ -1035,23 +1036,6 @@ var BinanceRestClient = class {
|
|
|
1035
1036
|
}
|
|
1036
1037
|
};
|
|
1037
1038
|
|
|
1038
|
-
//#endregion
|
|
1039
|
-
//#region src/websocket/base/typed-event-emitter.ts
|
|
1040
|
-
const createEmitter = () => {
|
|
1041
|
-
const eventTarget = new EventTarget();
|
|
1042
|
-
const addEventListener = (event, callback, options) => {
|
|
1043
|
-
eventTarget.addEventListener(event, (event$1) => callback(...event$1.detail), options);
|
|
1044
|
-
};
|
|
1045
|
-
const emit = (event, ...data) => {
|
|
1046
|
-
eventTarget.dispatchEvent(new CustomEvent(event, { detail: data }));
|
|
1047
|
-
};
|
|
1048
|
-
return {
|
|
1049
|
-
addEventListener,
|
|
1050
|
-
removeEventListener,
|
|
1051
|
-
emit
|
|
1052
|
-
};
|
|
1053
|
-
};
|
|
1054
|
-
|
|
1055
1039
|
//#endregion
|
|
1056
1040
|
//#region src/websocket/base/client.ts
|
|
1057
1041
|
const makeSection = (baseUrl) => {
|
|
@@ -1124,7 +1108,7 @@ const makeSection = (baseUrl) => {
|
|
|
1124
1108
|
return resolve();
|
|
1125
1109
|
}
|
|
1126
1110
|
};
|
|
1127
|
-
emitter.
|
|
1111
|
+
emitter.on("connectionMessage", handleSubscription, { signal: controller.signal });
|
|
1128
1112
|
});
|
|
1129
1113
|
if (delayed.length) return subscribe(delayed);
|
|
1130
1114
|
};
|
|
@@ -1160,18 +1144,22 @@ const makeSection = (baseUrl) => {
|
|
|
1160
1144
|
return resolve();
|
|
1161
1145
|
}
|
|
1162
1146
|
};
|
|
1163
|
-
emitter.
|
|
1147
|
+
emitter.on("connectionMessage", handleSubscription, { signal: controller.signal });
|
|
1164
1148
|
});
|
|
1165
1149
|
if (delayed.length) return unsubscribe(delayed);
|
|
1166
1150
|
};
|
|
1167
|
-
const
|
|
1168
|
-
emitter.
|
|
1151
|
+
const onMarketEvent = (callback, options) => {
|
|
1152
|
+
emitter.on("marketMessage", callback, options);
|
|
1153
|
+
};
|
|
1154
|
+
const offMarketEvent = (callback, options) => {
|
|
1155
|
+
emitter.on("marketMessage", callback, options);
|
|
1169
1156
|
};
|
|
1170
1157
|
return {
|
|
1171
1158
|
socket,
|
|
1172
1159
|
subscriptions,
|
|
1173
1160
|
connectionId,
|
|
1174
|
-
|
|
1161
|
+
on: onMarketEvent,
|
|
1162
|
+
off: offMarketEvent,
|
|
1175
1163
|
subscribe,
|
|
1176
1164
|
unsubscribe
|
|
1177
1165
|
};
|
|
@@ -1195,7 +1183,8 @@ const createWebsocketClient = (baseUrl, symbolConverter$1) => {
|
|
|
1195
1183
|
unsubscribe: (symbols, ...args) => {
|
|
1196
1184
|
return section.unsubscribe(symbols.map((s) => converter(s, ...args)));
|
|
1197
1185
|
},
|
|
1198
|
-
|
|
1186
|
+
on: section.on,
|
|
1187
|
+
off: section.off
|
|
1199
1188
|
});
|
|
1200
1189
|
} });
|
|
1201
1190
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medievalrain/binance-ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Binance API SDK",
|
|
5
5
|
"access": "public",
|
|
6
6
|
"type": "module",
|
|
@@ -21,19 +21,20 @@
|
|
|
21
21
|
"test": "vitest"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
+
"@types/node": "24.5.0",
|
|
24
25
|
"date-fns": "4.1.0",
|
|
25
26
|
"dotenv": "17.2.2",
|
|
26
27
|
"oxlint": "1.15.0",
|
|
27
28
|
"prettier": "3.6.2",
|
|
28
29
|
"tsdown": "0.15.1",
|
|
29
30
|
"typescript": "5.9.2",
|
|
30
|
-
"vitest": "4.0.0-beta.11"
|
|
31
|
-
"@types/node": "24.4.0"
|
|
31
|
+
"vitest": "4.0.0-beta.11"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"zod": "^4"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
+
"@medievalrain/emitter": "0.1.0",
|
|
37
38
|
"undici": "7.16.0"
|
|
38
39
|
},
|
|
39
40
|
"repository": {
|