@discordjs/voice 0.9.0-dev.1649505804-3c0bbac → 0.9.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/README.md +1 -0
- package/dist/index.d.ts +83 -83
- package/dist/index.js +97 -80
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +88 -64
- package/dist/index.mjs.map +1 -1
- package/package.json +87 -88
- package/CHANGELOG.md +0 -51
package/dist/index.mjs
CHANGED
|
@@ -22,7 +22,7 @@ var require_package = __commonJS({
|
|
|
22
22
|
"package.json"(exports, module) {
|
|
23
23
|
module.exports = {
|
|
24
24
|
name: "@discordjs/voice",
|
|
25
|
-
version: "0.9.0
|
|
25
|
+
version: "0.9.0",
|
|
26
26
|
description: "Implementation of the Discord Voice API for node.js",
|
|
27
27
|
scripts: {
|
|
28
28
|
build: "tsup && node scripts/postbuild.mjs",
|
|
@@ -72,7 +72,7 @@ var require_package = __commonJS({
|
|
|
72
72
|
},
|
|
73
73
|
homepage: "https://discord.js.org",
|
|
74
74
|
dependencies: {
|
|
75
|
-
"@types/ws": "^8.
|
|
75
|
+
"@types/ws": "^8.5.3",
|
|
76
76
|
"discord-api-types": "^0.29.0",
|
|
77
77
|
"prism-media": "^1.3.2",
|
|
78
78
|
"tiny-typed-emitter": "^2.1.0",
|
|
@@ -80,26 +80,26 @@ var require_package = __commonJS({
|
|
|
80
80
|
ws: "^8.5.0"
|
|
81
81
|
},
|
|
82
82
|
devDependencies: {
|
|
83
|
-
"@babel/core": "^7.17.
|
|
83
|
+
"@babel/core": "^7.17.9",
|
|
84
84
|
"@babel/preset-env": "^7.16.11",
|
|
85
85
|
"@babel/preset-typescript": "^7.16.7",
|
|
86
|
-
"@discordjs/ts-docgen": "^0.
|
|
87
|
-
"@types/jest": "^27.4.
|
|
88
|
-
"@types/node": "^16.11.
|
|
89
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
90
|
-
"@typescript-eslint/parser": "^5.
|
|
91
|
-
eslint: "^8.
|
|
92
|
-
"eslint-config-marine": "^9.
|
|
93
|
-
"eslint-config-prettier": "^8.
|
|
94
|
-
"eslint-plugin-
|
|
86
|
+
"@discordjs/ts-docgen": "^0.4.1",
|
|
87
|
+
"@types/jest": "^27.4.1",
|
|
88
|
+
"@types/node": "^16.11.27",
|
|
89
|
+
"@typescript-eslint/eslint-plugin": "^5.19.0",
|
|
90
|
+
"@typescript-eslint/parser": "^5.19.0",
|
|
91
|
+
eslint: "^8.13.0",
|
|
92
|
+
"eslint-config-marine": "^9.4.1",
|
|
93
|
+
"eslint-config-prettier": "^8.5.0",
|
|
94
|
+
"eslint-plugin-import": "^2.26.0",
|
|
95
95
|
jest: "^27.5.1",
|
|
96
96
|
"jest-websocket-mock": "^2.3.0",
|
|
97
97
|
"mock-socket": "^9.1.2",
|
|
98
|
-
prettier: "^2.
|
|
99
|
-
tsup: "^5.
|
|
98
|
+
prettier: "^2.6.2",
|
|
99
|
+
tsup: "^5.12.5",
|
|
100
100
|
tweetnacl: "^1.0.3",
|
|
101
|
-
typedoc: "^0.22.
|
|
102
|
-
typescript: "^4.
|
|
101
|
+
typedoc: "^0.22.15",
|
|
102
|
+
typescript: "^4.6.3"
|
|
103
103
|
},
|
|
104
104
|
engines: {
|
|
105
105
|
node: ">=16.9.0"
|
|
@@ -111,6 +111,9 @@ var require_package = __commonJS({
|
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
+
// src/VoiceConnection.ts
|
|
115
|
+
import { TypedEmitter as TypedEmitter7 } from "tiny-typed-emitter";
|
|
116
|
+
|
|
114
117
|
// src/DataStore.ts
|
|
115
118
|
import { GatewayOpcodes } from "discord-api-types/v10";
|
|
116
119
|
function createJoinVoiceChannelPayload(config) {
|
|
@@ -211,6 +214,7 @@ __name(deleteAudioPlayer, "deleteAudioPlayer");
|
|
|
211
214
|
|
|
212
215
|
// src/networking/Networking.ts
|
|
213
216
|
import { VoiceOpcodes as VoiceOpcodes2 } from "discord-api-types/voice/v4";
|
|
217
|
+
import { TypedEmitter as TypedEmitter3 } from "tiny-typed-emitter";
|
|
214
218
|
|
|
215
219
|
// src/networking/VoiceUDPSocket.ts
|
|
216
220
|
import { createSocket } from "node:dgram";
|
|
@@ -315,8 +319,8 @@ __name(VoiceUDPSocket, "VoiceUDPSocket");
|
|
|
315
319
|
|
|
316
320
|
// src/networking/VoiceWebSocket.ts
|
|
317
321
|
import { VoiceOpcodes } from "discord-api-types/voice/v4";
|
|
318
|
-
import WebSocket from "ws";
|
|
319
322
|
import { TypedEmitter as TypedEmitter2 } from "tiny-typed-emitter";
|
|
323
|
+
import WebSocket from "ws";
|
|
320
324
|
var VoiceWebSocket = class extends TypedEmitter2 {
|
|
321
325
|
constructor(address, debug) {
|
|
322
326
|
super();
|
|
@@ -402,12 +406,29 @@ __name(VoiceWebSocket, "VoiceWebSocket");
|
|
|
402
406
|
|
|
403
407
|
// src/util/Secretbox.ts
|
|
404
408
|
var libs = {
|
|
409
|
+
"sodium-native": (sodium) => ({
|
|
410
|
+
open: (buffer, nonce2, secretKey) => {
|
|
411
|
+
if (buffer) {
|
|
412
|
+
const output = Buffer.allocUnsafe(buffer.length - sodium.crypto_box_MACBYTES);
|
|
413
|
+
if (sodium.crypto_secretbox_open_easy(output, buffer, nonce2, secretKey))
|
|
414
|
+
return output;
|
|
415
|
+
}
|
|
416
|
+
return null;
|
|
417
|
+
},
|
|
418
|
+
close: (opusPacket, nonce2, secretKey) => {
|
|
419
|
+
const output = Buffer.allocUnsafe(opusPacket.length + sodium.crypto_box_MACBYTES);
|
|
420
|
+
sodium.crypto_secretbox_easy(output, opusPacket, nonce2, secretKey);
|
|
421
|
+
return output;
|
|
422
|
+
},
|
|
423
|
+
random: (n, buffer = Buffer.allocUnsafe(n)) => {
|
|
424
|
+
sodium.randombytes_buf(buffer);
|
|
425
|
+
return buffer;
|
|
426
|
+
}
|
|
427
|
+
}),
|
|
405
428
|
sodium: (sodium) => ({
|
|
406
429
|
open: sodium.api.crypto_secretbox_open_easy,
|
|
407
430
|
close: sodium.api.crypto_secretbox_easy,
|
|
408
|
-
random: (n, buffer) => {
|
|
409
|
-
if (!buffer)
|
|
410
|
-
buffer = Buffer.allocUnsafe(n);
|
|
431
|
+
random: (n, buffer = Buffer.allocUnsafe(n)) => {
|
|
411
432
|
sodium.api.randombytes_buf(buffer);
|
|
412
433
|
return buffer;
|
|
413
434
|
}
|
|
@@ -415,12 +436,12 @@ var libs = {
|
|
|
415
436
|
"libsodium-wrappers": (sodium) => ({
|
|
416
437
|
open: sodium.crypto_secretbox_open_easy,
|
|
417
438
|
close: sodium.crypto_secretbox_easy,
|
|
418
|
-
random:
|
|
439
|
+
random: sodium.randombytes_buf
|
|
419
440
|
}),
|
|
420
441
|
tweetnacl: (tweetnacl) => ({
|
|
421
442
|
open: tweetnacl.secretbox.open,
|
|
422
443
|
close: tweetnacl.secretbox,
|
|
423
|
-
random:
|
|
444
|
+
random: tweetnacl.randomBytes
|
|
424
445
|
})
|
|
425
446
|
};
|
|
426
447
|
var fallbackError = /* @__PURE__ */ __name(() => {
|
|
@@ -452,7 +473,6 @@ var noop = /* @__PURE__ */ __name(() => {
|
|
|
452
473
|
}, "noop");
|
|
453
474
|
|
|
454
475
|
// src/networking/Networking.ts
|
|
455
|
-
import { TypedEmitter as TypedEmitter3 } from "tiny-typed-emitter";
|
|
456
476
|
var CHANNELS = 2;
|
|
457
477
|
var TIMESTAMP_INC = 48e3 / 100 * CHANNELS;
|
|
458
478
|
var MAX_NONCE_SIZE = 2 ** 32 - 1;
|
|
@@ -742,15 +762,15 @@ to ${stringifyState(newState)}`);
|
|
|
742
762
|
};
|
|
743
763
|
__name(Networking, "Networking");
|
|
744
764
|
|
|
745
|
-
// src/VoiceConnection.ts
|
|
746
|
-
import { TypedEmitter as TypedEmitter7 } from "tiny-typed-emitter";
|
|
747
|
-
|
|
748
765
|
// src/receive/VoiceReceiver.ts
|
|
749
766
|
import { VoiceOpcodes as VoiceOpcodes3 } from "discord-api-types/voice/v4";
|
|
750
767
|
|
|
751
768
|
// src/receive/AudioReceiveStream.ts
|
|
752
769
|
import { Readable } from "node:stream";
|
|
753
770
|
|
|
771
|
+
// src/audio/AudioPlayer.ts
|
|
772
|
+
import { TypedEmitter as TypedEmitter4 } from "tiny-typed-emitter";
|
|
773
|
+
|
|
754
774
|
// src/audio/AudioPlayerError.ts
|
|
755
775
|
var AudioPlayerError = class extends Error {
|
|
756
776
|
constructor(error, resource) {
|
|
@@ -779,7 +799,6 @@ var PlayerSubscription = class {
|
|
|
779
799
|
__name(PlayerSubscription, "PlayerSubscription");
|
|
780
800
|
|
|
781
801
|
// src/audio/AudioPlayer.ts
|
|
782
|
-
import { TypedEmitter as TypedEmitter4 } from "tiny-typed-emitter";
|
|
783
802
|
var SILENCE_FRAME = Buffer.from([248, 255, 254]);
|
|
784
803
|
var NoSubscriberBehavior = /* @__PURE__ */ ((NoSubscriberBehavior2) => {
|
|
785
804
|
NoSubscriberBehavior2["Pause"] = "pause";
|
|
@@ -1095,41 +1114,9 @@ var AudioReceiveStream = class extends Readable {
|
|
|
1095
1114
|
};
|
|
1096
1115
|
__name(AudioReceiveStream, "AudioReceiveStream");
|
|
1097
1116
|
|
|
1098
|
-
// src/receive/SpeakingMap.ts
|
|
1099
|
-
import { TypedEmitter as TypedEmitter5 } from "tiny-typed-emitter";
|
|
1100
|
-
var _SpeakingMap = class extends TypedEmitter5 {
|
|
1101
|
-
constructor() {
|
|
1102
|
-
super();
|
|
1103
|
-
__publicField(this, "users");
|
|
1104
|
-
__publicField(this, "speakingTimeouts");
|
|
1105
|
-
this.users = /* @__PURE__ */ new Map();
|
|
1106
|
-
this.speakingTimeouts = /* @__PURE__ */ new Map();
|
|
1107
|
-
}
|
|
1108
|
-
onPacket(userId) {
|
|
1109
|
-
const timeout = this.speakingTimeouts.get(userId);
|
|
1110
|
-
if (timeout) {
|
|
1111
|
-
clearTimeout(timeout);
|
|
1112
|
-
} else {
|
|
1113
|
-
this.users.set(userId, Date.now());
|
|
1114
|
-
this.emit("start", userId);
|
|
1115
|
-
}
|
|
1116
|
-
this.startTimeout(userId);
|
|
1117
|
-
}
|
|
1118
|
-
startTimeout(userId) {
|
|
1119
|
-
this.speakingTimeouts.set(userId, setTimeout(() => {
|
|
1120
|
-
this.emit("end", userId);
|
|
1121
|
-
this.speakingTimeouts.delete(userId);
|
|
1122
|
-
this.users.delete(userId);
|
|
1123
|
-
}, _SpeakingMap.DELAY));
|
|
1124
|
-
}
|
|
1125
|
-
};
|
|
1126
|
-
var SpeakingMap = _SpeakingMap;
|
|
1127
|
-
__name(SpeakingMap, "SpeakingMap");
|
|
1128
|
-
__publicField(SpeakingMap, "DELAY", 100);
|
|
1129
|
-
|
|
1130
1117
|
// src/receive/SSRCMap.ts
|
|
1131
|
-
import { TypedEmitter as
|
|
1132
|
-
var SSRCMap = class extends
|
|
1118
|
+
import { TypedEmitter as TypedEmitter5 } from "tiny-typed-emitter";
|
|
1119
|
+
var SSRCMap = class extends TypedEmitter5 {
|
|
1133
1120
|
constructor() {
|
|
1134
1121
|
super();
|
|
1135
1122
|
__publicField(this, "map");
|
|
@@ -1178,6 +1165,38 @@ var SSRCMap = class extends TypedEmitter6 {
|
|
|
1178
1165
|
};
|
|
1179
1166
|
__name(SSRCMap, "SSRCMap");
|
|
1180
1167
|
|
|
1168
|
+
// src/receive/SpeakingMap.ts
|
|
1169
|
+
import { TypedEmitter as TypedEmitter6 } from "tiny-typed-emitter";
|
|
1170
|
+
var _SpeakingMap = class extends TypedEmitter6 {
|
|
1171
|
+
constructor() {
|
|
1172
|
+
super();
|
|
1173
|
+
__publicField(this, "users");
|
|
1174
|
+
__publicField(this, "speakingTimeouts");
|
|
1175
|
+
this.users = /* @__PURE__ */ new Map();
|
|
1176
|
+
this.speakingTimeouts = /* @__PURE__ */ new Map();
|
|
1177
|
+
}
|
|
1178
|
+
onPacket(userId) {
|
|
1179
|
+
const timeout = this.speakingTimeouts.get(userId);
|
|
1180
|
+
if (timeout) {
|
|
1181
|
+
clearTimeout(timeout);
|
|
1182
|
+
} else {
|
|
1183
|
+
this.users.set(userId, Date.now());
|
|
1184
|
+
this.emit("start", userId);
|
|
1185
|
+
}
|
|
1186
|
+
this.startTimeout(userId);
|
|
1187
|
+
}
|
|
1188
|
+
startTimeout(userId) {
|
|
1189
|
+
this.speakingTimeouts.set(userId, setTimeout(() => {
|
|
1190
|
+
this.emit("end", userId);
|
|
1191
|
+
this.speakingTimeouts.delete(userId);
|
|
1192
|
+
this.users.delete(userId);
|
|
1193
|
+
}, _SpeakingMap.DELAY));
|
|
1194
|
+
}
|
|
1195
|
+
};
|
|
1196
|
+
var SpeakingMap = _SpeakingMap;
|
|
1197
|
+
__name(SpeakingMap, "SpeakingMap");
|
|
1198
|
+
__publicField(SpeakingMap, "DELAY", 100);
|
|
1199
|
+
|
|
1181
1200
|
// src/receive/VoiceReceiver.ts
|
|
1182
1201
|
var VoiceReceiver = class {
|
|
1183
1202
|
constructor(voiceConnection) {
|
|
@@ -1635,6 +1654,10 @@ function joinVoiceChannel(options) {
|
|
|
1635
1654
|
}
|
|
1636
1655
|
__name(joinVoiceChannel, "joinVoiceChannel");
|
|
1637
1656
|
|
|
1657
|
+
// src/audio/AudioResource.ts
|
|
1658
|
+
import { pipeline } from "node:stream";
|
|
1659
|
+
import prism2 from "prism-media";
|
|
1660
|
+
|
|
1638
1661
|
// src/audio/TransformerGraph.ts
|
|
1639
1662
|
import prism from "prism-media";
|
|
1640
1663
|
var FFMPEG_PCM_ARGUMENTS = ["-analyzeduration", "0", "-loglevel", "0", "-f", "s16le", "-ar", "48000", "-ac", "2"];
|
|
@@ -1779,8 +1802,6 @@ function findPipeline(from, constraint) {
|
|
|
1779
1802
|
__name(findPipeline, "findPipeline");
|
|
1780
1803
|
|
|
1781
1804
|
// src/audio/AudioResource.ts
|
|
1782
|
-
import { pipeline } from "node:stream";
|
|
1783
|
-
import prism2 from "prism-media";
|
|
1784
1805
|
var AudioResource = class {
|
|
1785
1806
|
constructor(edges, streams, metadata, silencePaddingFrames) {
|
|
1786
1807
|
__publicField(this, "playStream");
|
|
@@ -1913,6 +1934,7 @@ function generateDependencyReport() {
|
|
|
1913
1934
|
addVersion("opusscript");
|
|
1914
1935
|
report.push("");
|
|
1915
1936
|
report.push("Encryption Libraries");
|
|
1937
|
+
addVersion("sodium-native");
|
|
1916
1938
|
addVersion("sodium");
|
|
1917
1939
|
addVersion("libsodium-wrappers");
|
|
1918
1940
|
addVersion("tweetnacl");
|
|
@@ -1929,6 +1951,9 @@ function generateDependencyReport() {
|
|
|
1929
1951
|
}
|
|
1930
1952
|
__name(generateDependencyReport, "generateDependencyReport");
|
|
1931
1953
|
|
|
1954
|
+
// src/util/entersState.ts
|
|
1955
|
+
import { once } from "node:events";
|
|
1956
|
+
|
|
1932
1957
|
// src/util/abortAfter.ts
|
|
1933
1958
|
function abortAfter(delay) {
|
|
1934
1959
|
const ac = new AbortController();
|
|
@@ -1939,7 +1964,6 @@ function abortAfter(delay) {
|
|
|
1939
1964
|
__name(abortAfter, "abortAfter");
|
|
1940
1965
|
|
|
1941
1966
|
// src/util/entersState.ts
|
|
1942
|
-
import { once } from "node:events";
|
|
1943
1967
|
async function entersState(target, status, timeoutOrSignal) {
|
|
1944
1968
|
if (target.state.status !== status) {
|
|
1945
1969
|
const [ac, signal] = typeof timeoutOrSignal === "number" ? abortAfter(timeoutOrSignal) : [void 0, timeoutOrSignal];
|