@fluxerjs/voice 1.2.3 → 1.3.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.js +36 -10
- package/dist/index.mjs +36 -10
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -49,6 +49,7 @@ var thumbnail = MINIMAL_PNG_BASE64;
|
|
|
49
49
|
|
|
50
50
|
// src/VoiceConnection.ts
|
|
51
51
|
var import_events = require("events");
|
|
52
|
+
var import_util = require("@fluxerjs/util");
|
|
52
53
|
var nacl = __toESM(require("tweetnacl"));
|
|
53
54
|
var dgram = __toESM(require("dgram"));
|
|
54
55
|
var ws = __toESM(require("ws"));
|
|
@@ -210,8 +211,11 @@ var VoiceConnection = class extends import_events.EventEmitter {
|
|
|
210
211
|
async getWebSocketConstructor() {
|
|
211
212
|
try {
|
|
212
213
|
return ws.default;
|
|
213
|
-
} catch {
|
|
214
|
-
throw new
|
|
214
|
+
} catch (err) {
|
|
215
|
+
throw new import_util.FluxerError('Install "ws" for voice support: pnpm add ws', {
|
|
216
|
+
code: import_util.ErrorCodes.VoiceWebSocketRequired,
|
|
217
|
+
cause: err instanceof Error ? err : void 0
|
|
218
|
+
});
|
|
215
219
|
}
|
|
216
220
|
}
|
|
217
221
|
sendVoiceOp(op, d) {
|
|
@@ -298,11 +302,18 @@ var VoiceConnection = class extends import_events.EventEmitter {
|
|
|
298
302
|
if (typeof urlOrStream === "string") {
|
|
299
303
|
try {
|
|
300
304
|
const response = await fetch(urlOrStream);
|
|
301
|
-
if (!response.ok)
|
|
302
|
-
|
|
305
|
+
if (!response.ok) {
|
|
306
|
+
throw new import_util.FluxerError(`HTTP ${response.status}`, { code: import_util.ErrorCodes.VoiceHttpError });
|
|
307
|
+
}
|
|
308
|
+
if (!response.body) {
|
|
309
|
+
throw new import_util.FluxerError("No response body", { code: import_util.ErrorCodes.VoiceNoResponseBody });
|
|
310
|
+
}
|
|
303
311
|
inputStream = import_node_stream.Readable.fromWeb(response.body);
|
|
304
312
|
} catch (e) {
|
|
305
|
-
const err = e instanceof
|
|
313
|
+
const err = e instanceof import_util.FluxerError ? e : new import_util.FluxerError(e instanceof Error ? e.message : String(e), {
|
|
314
|
+
code: import_util.ErrorCodes.FileFetchFailed,
|
|
315
|
+
cause: e instanceof Error ? e : void 0
|
|
316
|
+
});
|
|
306
317
|
this.emit("error", err);
|
|
307
318
|
return;
|
|
308
319
|
}
|
|
@@ -404,6 +415,7 @@ var VoiceConnection = class extends import_events.EventEmitter {
|
|
|
404
415
|
// src/LiveKitRtcConnection.ts
|
|
405
416
|
var import_node_child_process = require("child_process");
|
|
406
417
|
var import_events2 = require("events");
|
|
418
|
+
var import_util2 = require("@fluxerjs/util");
|
|
407
419
|
var import_rtc_node = require("@livekit/rtc-node");
|
|
408
420
|
|
|
409
421
|
// src/livekit.ts
|
|
@@ -911,11 +923,17 @@ var LiveKitRtcConnection = class extends import_events2.EventEmitter {
|
|
|
911
923
|
if (typeof urlOrBuffer === "string") {
|
|
912
924
|
try {
|
|
913
925
|
const response = await fetch(urlOrBuffer);
|
|
914
|
-
if (!response.ok)
|
|
926
|
+
if (!response.ok) {
|
|
927
|
+
throw new import_util2.FluxerError(`HTTP ${response.status}`, { code: import_util2.ErrorCodes.VoiceHttpError });
|
|
928
|
+
}
|
|
915
929
|
const buf = await response.arrayBuffer();
|
|
916
930
|
arrayBuffer = buf;
|
|
917
931
|
} catch (e) {
|
|
918
|
-
|
|
932
|
+
const err = e instanceof import_util2.FluxerError ? e : new import_util2.FluxerError(e instanceof Error ? e.message : String(e), {
|
|
933
|
+
code: import_util2.ErrorCodes.FileFetchFailed,
|
|
934
|
+
cause: e instanceof Error ? e : void 0
|
|
935
|
+
});
|
|
936
|
+
this.emit("error", err);
|
|
919
937
|
return;
|
|
920
938
|
}
|
|
921
939
|
} else if (urlOrBuffer instanceof Uint8Array) {
|
|
@@ -1695,11 +1713,19 @@ var LiveKitRtcConnection = class extends import_events2.EventEmitter {
|
|
|
1695
1713
|
if (typeof urlOrStream === "string") {
|
|
1696
1714
|
try {
|
|
1697
1715
|
const response = await fetch(urlOrStream);
|
|
1698
|
-
if (!response.ok)
|
|
1699
|
-
|
|
1716
|
+
if (!response.ok) {
|
|
1717
|
+
throw new import_util2.FluxerError(`HTTP ${response.status}`, { code: import_util2.ErrorCodes.VoiceHttpError });
|
|
1718
|
+
}
|
|
1719
|
+
if (!response.body) {
|
|
1720
|
+
throw new import_util2.FluxerError("No response body", { code: import_util2.ErrorCodes.VoiceNoResponseBody });
|
|
1721
|
+
}
|
|
1700
1722
|
inputStream = import_node_stream2.Readable.fromWeb(response.body);
|
|
1701
1723
|
} catch (e) {
|
|
1702
|
-
|
|
1724
|
+
const err = e instanceof import_util2.FluxerError ? e : new import_util2.FluxerError(e instanceof Error ? e.message : String(e), {
|
|
1725
|
+
code: import_util2.ErrorCodes.FileFetchFailed,
|
|
1726
|
+
cause: e instanceof Error ? e : void 0
|
|
1727
|
+
});
|
|
1728
|
+
this.emit("error", err);
|
|
1703
1729
|
return;
|
|
1704
1730
|
}
|
|
1705
1731
|
} else {
|
package/dist/index.mjs
CHANGED
|
@@ -9,6 +9,7 @@ var thumbnail = MINIMAL_PNG_BASE64;
|
|
|
9
9
|
|
|
10
10
|
// src/VoiceConnection.ts
|
|
11
11
|
import { EventEmitter } from "events";
|
|
12
|
+
import { ErrorCodes, FluxerError } from "@fluxerjs/util";
|
|
12
13
|
import * as nacl from "tweetnacl";
|
|
13
14
|
import * as dgram from "dgram";
|
|
14
15
|
import * as ws from "ws";
|
|
@@ -170,8 +171,11 @@ var VoiceConnection = class extends EventEmitter {
|
|
|
170
171
|
async getWebSocketConstructor() {
|
|
171
172
|
try {
|
|
172
173
|
return ws.default;
|
|
173
|
-
} catch {
|
|
174
|
-
throw new
|
|
174
|
+
} catch (err) {
|
|
175
|
+
throw new FluxerError('Install "ws" for voice support: pnpm add ws', {
|
|
176
|
+
code: ErrorCodes.VoiceWebSocketRequired,
|
|
177
|
+
cause: err instanceof Error ? err : void 0
|
|
178
|
+
});
|
|
175
179
|
}
|
|
176
180
|
}
|
|
177
181
|
sendVoiceOp(op, d) {
|
|
@@ -258,11 +262,18 @@ var VoiceConnection = class extends EventEmitter {
|
|
|
258
262
|
if (typeof urlOrStream === "string") {
|
|
259
263
|
try {
|
|
260
264
|
const response = await fetch(urlOrStream);
|
|
261
|
-
if (!response.ok)
|
|
262
|
-
|
|
265
|
+
if (!response.ok) {
|
|
266
|
+
throw new FluxerError(`HTTP ${response.status}`, { code: ErrorCodes.VoiceHttpError });
|
|
267
|
+
}
|
|
268
|
+
if (!response.body) {
|
|
269
|
+
throw new FluxerError("No response body", { code: ErrorCodes.VoiceNoResponseBody });
|
|
270
|
+
}
|
|
263
271
|
inputStream = Readable.fromWeb(response.body);
|
|
264
272
|
} catch (e) {
|
|
265
|
-
const err = e instanceof
|
|
273
|
+
const err = e instanceof FluxerError ? e : new FluxerError(e instanceof Error ? e.message : String(e), {
|
|
274
|
+
code: ErrorCodes.FileFetchFailed,
|
|
275
|
+
cause: e instanceof Error ? e : void 0
|
|
276
|
+
});
|
|
266
277
|
this.emit("error", err);
|
|
267
278
|
return;
|
|
268
279
|
}
|
|
@@ -364,6 +375,7 @@ var VoiceConnection = class extends EventEmitter {
|
|
|
364
375
|
// src/LiveKitRtcConnection.ts
|
|
365
376
|
import { execFile, spawn } from "child_process";
|
|
366
377
|
import { EventEmitter as EventEmitter2 } from "events";
|
|
378
|
+
import { ErrorCodes as ErrorCodes2, FluxerError as FluxerError2 } from "@fluxerjs/util";
|
|
367
379
|
import {
|
|
368
380
|
AudioStream,
|
|
369
381
|
Room,
|
|
@@ -885,11 +897,17 @@ var LiveKitRtcConnection = class extends EventEmitter2 {
|
|
|
885
897
|
if (typeof urlOrBuffer === "string") {
|
|
886
898
|
try {
|
|
887
899
|
const response = await fetch(urlOrBuffer);
|
|
888
|
-
if (!response.ok)
|
|
900
|
+
if (!response.ok) {
|
|
901
|
+
throw new FluxerError2(`HTTP ${response.status}`, { code: ErrorCodes2.VoiceHttpError });
|
|
902
|
+
}
|
|
889
903
|
const buf = await response.arrayBuffer();
|
|
890
904
|
arrayBuffer = buf;
|
|
891
905
|
} catch (e) {
|
|
892
|
-
|
|
906
|
+
const err = e instanceof FluxerError2 ? e : new FluxerError2(e instanceof Error ? e.message : String(e), {
|
|
907
|
+
code: ErrorCodes2.FileFetchFailed,
|
|
908
|
+
cause: e instanceof Error ? e : void 0
|
|
909
|
+
});
|
|
910
|
+
this.emit("error", err);
|
|
893
911
|
return;
|
|
894
912
|
}
|
|
895
913
|
} else if (urlOrBuffer instanceof Uint8Array) {
|
|
@@ -1669,11 +1687,19 @@ var LiveKitRtcConnection = class extends EventEmitter2 {
|
|
|
1669
1687
|
if (typeof urlOrStream === "string") {
|
|
1670
1688
|
try {
|
|
1671
1689
|
const response = await fetch(urlOrStream);
|
|
1672
|
-
if (!response.ok)
|
|
1673
|
-
|
|
1690
|
+
if (!response.ok) {
|
|
1691
|
+
throw new FluxerError2(`HTTP ${response.status}`, { code: ErrorCodes2.VoiceHttpError });
|
|
1692
|
+
}
|
|
1693
|
+
if (!response.body) {
|
|
1694
|
+
throw new FluxerError2("No response body", { code: ErrorCodes2.VoiceNoResponseBody });
|
|
1695
|
+
}
|
|
1674
1696
|
inputStream = Readable2.fromWeb(response.body);
|
|
1675
1697
|
} catch (e) {
|
|
1676
|
-
|
|
1698
|
+
const err = e instanceof FluxerError2 ? e : new FluxerError2(e instanceof Error ? e.message : String(e), {
|
|
1699
|
+
code: ErrorCodes2.FileFetchFailed,
|
|
1700
|
+
cause: e instanceof Error ? e : void 0
|
|
1701
|
+
});
|
|
1702
|
+
this.emit("error", err);
|
|
1677
1703
|
return;
|
|
1678
1704
|
}
|
|
1679
1705
|
} else {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.3.0",
|
|
7
7
|
"description": "Voice support for Fluxer bots",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -39,9 +39,10 @@
|
|
|
39
39
|
"prism-media": "^1.3.5",
|
|
40
40
|
"tweetnacl": "^1.0.3",
|
|
41
41
|
"ws": "^8.18.0",
|
|
42
|
-
"@fluxerjs/collection": "1.
|
|
43
|
-
"@fluxerjs/core": "1.
|
|
44
|
-
"@fluxerjs/
|
|
42
|
+
"@fluxerjs/collection": "1.3.0",
|
|
43
|
+
"@fluxerjs/core": "1.3.0",
|
|
44
|
+
"@fluxerjs/util": "1.3.0",
|
|
45
|
+
"@fluxerjs/types": "1.3.0"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@types/node": "^20.0.0",
|