@discordjs/voice 0.9.0-dev.1649937819-b01f414 → 0.10.0-dev.1650240533-9ef7ffd
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/CHANGELOG.md +23 -0
- package/dist/index.d.ts +83 -83
- package/dist/index.js +74 -75
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -59
- package/dist/index.mjs.map +1 -1
- package/package.json +17 -17
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
# [0.9.0](https://github.com/discordjs/discord.js/compare/@discordjs/voice@0.8.0...@discordjs/voice@0.9.0) (2022-04-17)
|
|
6
|
+
|
|
7
|
+
## Bug Fixes
|
|
8
|
+
|
|
9
|
+
- Fix some typos (#7393) ([92a04f4](https://github.com/discordjs/discord.js/commit/92a04f4d98f6c6760214034cc8f5a1eaa78893c7))
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- Support sodium-native lib for voice (#7698) ([f0d0242](https://github.com/discordjs/discord.js/commit/f0d0242c76a455bb7a5ea7bd95ca62907c7e9d62))
|
|
14
|
+
- Add API v10 support (#7477) ([72577c4](https://github.com/discordjs/discord.js/commit/72577c4bfd02524a27afb6ff4aebba9301a690d3))
|
|
15
|
+
- Add support for module: NodeNext in TS and ESM (#7598) ([8f1986a](https://github.com/discordjs/discord.js/commit/8f1986a6aa98365e09b00e84ad5f9f354ab61f3d))
|
|
16
|
+
- **builders:** Add attachment command option type (#7203) ([ae0f35f](https://github.com/discordjs/discord.js/commit/ae0f35f51d68dfa5a7dc43d161ef9365171debdb))
|
|
17
|
+
|
|
18
|
+
## Refactor
|
|
19
|
+
|
|
20
|
+
- PresenceUpdate and demuxProbe (#7248) ([1745973](https://github.com/discordjs/discord.js/commit/174597302408f13c5bb685e2fb02ae2137cb481d))
|
|
21
|
+
|
|
22
|
+
## Testing
|
|
23
|
+
|
|
24
|
+
- **voice:** Fix tests ([62c74b8](https://github.com/discordjs/discord.js/commit/62c74b8333066465e5bd295b8b102b35a506751d))
|
|
25
|
+
- Fix voice secretbox tests ([4a2dbd6](https://github.com/discordjs/discord.js/commit/4a2dbd62382f904d596b34da0116d50e724b81c4))
|
|
26
|
+
- Fix voice tests ([b593bd3](https://github.com/discordjs/discord.js/commit/b593bd32a98282a92fa28f2fb0a8ef239866622c))
|
|
27
|
+
|
|
5
28
|
# [0.8.0](https://github.com/discordjs/discord.js/compare/@discordjs/voice@0.7.5...@discordjs/voice@0.8.0) (2021-12-08)
|
|
6
29
|
|
|
7
30
|
## Refactor
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
+
import { TypedEmitter } from 'tiny-typed-emitter';
|
|
1
2
|
import { Readable, ReadableOptions } from 'node:stream';
|
|
2
3
|
import prism from 'prism-media';
|
|
3
|
-
import { TypedEmitter } from 'tiny-typed-emitter';
|
|
4
|
-
import { GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData } from 'discord-api-types/v10';
|
|
5
4
|
import WebSocket, { MessageEvent } from 'ws';
|
|
6
|
-
|
|
7
|
-
declare type Awaited<T> = T | Promise<T>;
|
|
5
|
+
import { GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData } from 'discord-api-types/v10';
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
* The different types of stream that can exist within the pipeline.
|
|
@@ -232,6 +230,8 @@ declare class PlayerSubscription {
|
|
|
232
230
|
unsubscribe(): void;
|
|
233
231
|
}
|
|
234
232
|
|
|
233
|
+
declare type Awaited<T> = T | Promise<T>;
|
|
234
|
+
|
|
235
235
|
/**
|
|
236
236
|
* Describes the behavior of the player when an audio packet is played but there are no available
|
|
237
237
|
* voice connections to play to.
|
|
@@ -542,54 +542,6 @@ declare function getVoiceConnections(group: string): Map<string, VoiceConnection
|
|
|
542
542
|
*/
|
|
543
543
|
declare function getVoiceConnection(guildId: string, group?: string): VoiceConnection | undefined;
|
|
544
544
|
|
|
545
|
-
/**
|
|
546
|
-
* Methods that are provided by the @discordjs/voice library to implementations of
|
|
547
|
-
* Discord gateway DiscordGatewayAdapters.
|
|
548
|
-
*/
|
|
549
|
-
interface DiscordGatewayAdapterLibraryMethods {
|
|
550
|
-
/**
|
|
551
|
-
* Call this when you receive a VOICE_SERVER_UPDATE payload that is relevant to the adapter.
|
|
552
|
-
*
|
|
553
|
-
* @param data - The inner data of the VOICE_SERVER_UPDATE payload
|
|
554
|
-
*/
|
|
555
|
-
onVoiceServerUpdate: (data: GatewayVoiceServerUpdateDispatchData) => void;
|
|
556
|
-
/**
|
|
557
|
-
* Call this when you receive a VOICE_STATE_UPDATE payload that is relevant to the adapter.
|
|
558
|
-
*
|
|
559
|
-
* @param data - The inner data of the VOICE_STATE_UPDATE payload
|
|
560
|
-
*/
|
|
561
|
-
onVoiceStateUpdate: (data: GatewayVoiceStateUpdateDispatchData) => void;
|
|
562
|
-
/**
|
|
563
|
-
* Call this when the adapter can no longer be used (e.g. due to a disconnect from the main gateway)
|
|
564
|
-
*/
|
|
565
|
-
destroy: () => void;
|
|
566
|
-
}
|
|
567
|
-
/**
|
|
568
|
-
* Methods that are provided by the implementer of a Discord gateway DiscordGatewayAdapter.
|
|
569
|
-
*/
|
|
570
|
-
interface DiscordGatewayAdapterImplementerMethods {
|
|
571
|
-
/**
|
|
572
|
-
* Implement this method such that the given payload is sent to the main Discord gateway connection.
|
|
573
|
-
*
|
|
574
|
-
* @param payload - The payload to send to the main Discord gateway connection
|
|
575
|
-
*
|
|
576
|
-
* @returns `false` if the payload definitely failed to send - in this case, the voice connection disconnects
|
|
577
|
-
*/
|
|
578
|
-
sendPayload: (payload: any) => boolean;
|
|
579
|
-
/**
|
|
580
|
-
* This will be called by @discordjs/voice when the adapter can safely be destroyed as it will no
|
|
581
|
-
* longer be used.
|
|
582
|
-
*/
|
|
583
|
-
destroy: () => void;
|
|
584
|
-
}
|
|
585
|
-
/**
|
|
586
|
-
* A function used to build adapters. It accepts a methods parameter that contains functions that
|
|
587
|
-
* can be called by the implementer when new data is received on its gateway connection. In return,
|
|
588
|
-
* the implementer will return some methods that the library can call - e.g. to send messages on
|
|
589
|
-
* the gateway, or to signal that the adapter can be removed.
|
|
590
|
-
*/
|
|
591
|
-
declare type DiscordGatewayAdapterCreator = (methods: DiscordGatewayAdapterLibraryMethods) => DiscordGatewayAdapterImplementerMethods;
|
|
592
|
-
|
|
593
545
|
/**
|
|
594
546
|
* Stores an IP address and port. Used to store socket details for the local client as well as
|
|
595
547
|
* for Discord.
|
|
@@ -1041,37 +993,6 @@ declare class AudioReceiveStream extends Readable {
|
|
|
1041
993
|
_read(): void;
|
|
1042
994
|
}
|
|
1043
995
|
|
|
1044
|
-
/**
|
|
1045
|
-
* The events that a SpeakingMap can emit.
|
|
1046
|
-
*/
|
|
1047
|
-
interface SpeakingMapEvents {
|
|
1048
|
-
/**
|
|
1049
|
-
* Emitted when a user starts speaking.
|
|
1050
|
-
*/
|
|
1051
|
-
start: (userId: string) => Awaited<void>;
|
|
1052
|
-
/**
|
|
1053
|
-
* Emitted when a user stops speaking.
|
|
1054
|
-
*/
|
|
1055
|
-
end: (userId: string) => Awaited<void>;
|
|
1056
|
-
}
|
|
1057
|
-
/**
|
|
1058
|
-
* Tracks the speaking states of users in a voice channel.
|
|
1059
|
-
*/
|
|
1060
|
-
declare class SpeakingMap extends TypedEmitter<SpeakingMapEvents> {
|
|
1061
|
-
/**
|
|
1062
|
-
* The delay after a packet is received from a user until they're marked as not speaking anymore.
|
|
1063
|
-
*/
|
|
1064
|
-
static readonly DELAY = 100;
|
|
1065
|
-
/**
|
|
1066
|
-
* The currently speaking users, mapped to the milliseconds since UNIX epoch at which they started speaking.
|
|
1067
|
-
*/
|
|
1068
|
-
readonly users: Map<string, number>;
|
|
1069
|
-
private readonly speakingTimeouts;
|
|
1070
|
-
constructor();
|
|
1071
|
-
onPacket(userId: string): void;
|
|
1072
|
-
private startTimeout;
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
996
|
/**
|
|
1076
997
|
* The known data for a user in a Discord voice connection.
|
|
1077
998
|
*/
|
|
@@ -1129,6 +1050,37 @@ declare class SSRCMap extends TypedEmitter<SSRCMapEvents> {
|
|
|
1129
1050
|
delete(target: number | string): VoiceUserData | undefined;
|
|
1130
1051
|
}
|
|
1131
1052
|
|
|
1053
|
+
/**
|
|
1054
|
+
* The events that a SpeakingMap can emit.
|
|
1055
|
+
*/
|
|
1056
|
+
interface SpeakingMapEvents {
|
|
1057
|
+
/**
|
|
1058
|
+
* Emitted when a user starts speaking.
|
|
1059
|
+
*/
|
|
1060
|
+
start: (userId: string) => Awaited<void>;
|
|
1061
|
+
/**
|
|
1062
|
+
* Emitted when a user stops speaking.
|
|
1063
|
+
*/
|
|
1064
|
+
end: (userId: string) => Awaited<void>;
|
|
1065
|
+
}
|
|
1066
|
+
/**
|
|
1067
|
+
* Tracks the speaking states of users in a voice channel.
|
|
1068
|
+
*/
|
|
1069
|
+
declare class SpeakingMap extends TypedEmitter<SpeakingMapEvents> {
|
|
1070
|
+
/**
|
|
1071
|
+
* The delay after a packet is received from a user until they're marked as not speaking anymore.
|
|
1072
|
+
*/
|
|
1073
|
+
static readonly DELAY = 100;
|
|
1074
|
+
/**
|
|
1075
|
+
* The currently speaking users, mapped to the milliseconds since UNIX epoch at which they started speaking.
|
|
1076
|
+
*/
|
|
1077
|
+
readonly users: Map<string, number>;
|
|
1078
|
+
private readonly speakingTimeouts;
|
|
1079
|
+
constructor();
|
|
1080
|
+
onPacket(userId: string): void;
|
|
1081
|
+
private startTimeout;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1132
1084
|
/**
|
|
1133
1085
|
* Attaches to a VoiceConnection, allowing you to receive audio packets from other
|
|
1134
1086
|
* users that are speaking.
|
|
@@ -1197,6 +1149,54 @@ declare class VoiceReceiver {
|
|
|
1197
1149
|
subscribe(userId: string, options?: Partial<AudioReceiveStreamOptions>): AudioReceiveStream;
|
|
1198
1150
|
}
|
|
1199
1151
|
|
|
1152
|
+
/**
|
|
1153
|
+
* Methods that are provided by the @discordjs/voice library to implementations of
|
|
1154
|
+
* Discord gateway DiscordGatewayAdapters.
|
|
1155
|
+
*/
|
|
1156
|
+
interface DiscordGatewayAdapterLibraryMethods {
|
|
1157
|
+
/**
|
|
1158
|
+
* Call this when you receive a VOICE_SERVER_UPDATE payload that is relevant to the adapter.
|
|
1159
|
+
*
|
|
1160
|
+
* @param data - The inner data of the VOICE_SERVER_UPDATE payload
|
|
1161
|
+
*/
|
|
1162
|
+
onVoiceServerUpdate: (data: GatewayVoiceServerUpdateDispatchData) => void;
|
|
1163
|
+
/**
|
|
1164
|
+
* Call this when you receive a VOICE_STATE_UPDATE payload that is relevant to the adapter.
|
|
1165
|
+
*
|
|
1166
|
+
* @param data - The inner data of the VOICE_STATE_UPDATE payload
|
|
1167
|
+
*/
|
|
1168
|
+
onVoiceStateUpdate: (data: GatewayVoiceStateUpdateDispatchData) => void;
|
|
1169
|
+
/**
|
|
1170
|
+
* Call this when the adapter can no longer be used (e.g. due to a disconnect from the main gateway)
|
|
1171
|
+
*/
|
|
1172
|
+
destroy: () => void;
|
|
1173
|
+
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Methods that are provided by the implementer of a Discord gateway DiscordGatewayAdapter.
|
|
1176
|
+
*/
|
|
1177
|
+
interface DiscordGatewayAdapterImplementerMethods {
|
|
1178
|
+
/**
|
|
1179
|
+
* Implement this method such that the given payload is sent to the main Discord gateway connection.
|
|
1180
|
+
*
|
|
1181
|
+
* @param payload - The payload to send to the main Discord gateway connection
|
|
1182
|
+
*
|
|
1183
|
+
* @returns `false` if the payload definitely failed to send - in this case, the voice connection disconnects
|
|
1184
|
+
*/
|
|
1185
|
+
sendPayload: (payload: any) => boolean;
|
|
1186
|
+
/**
|
|
1187
|
+
* This will be called by @discordjs/voice when the adapter can safely be destroyed as it will no
|
|
1188
|
+
* longer be used.
|
|
1189
|
+
*/
|
|
1190
|
+
destroy: () => void;
|
|
1191
|
+
}
|
|
1192
|
+
/**
|
|
1193
|
+
* A function used to build adapters. It accepts a methods parameter that contains functions that
|
|
1194
|
+
* can be called by the implementer when new data is received on its gateway connection. In return,
|
|
1195
|
+
* the implementer will return some methods that the library can call - e.g. to send messages on
|
|
1196
|
+
* the gateway, or to signal that the adapter can be removed.
|
|
1197
|
+
*/
|
|
1198
|
+
declare type DiscordGatewayAdapterCreator = (methods: DiscordGatewayAdapterLibraryMethods) => DiscordGatewayAdapterImplementerMethods;
|
|
1199
|
+
|
|
1200
1200
|
/**
|
|
1201
1201
|
* The various status codes a voice connection can hold at any one time.
|
|
1202
1202
|
*/
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,6 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
10
9
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
11
10
|
var __commonJS = (cb, mod) => function __require() {
|
|
12
11
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
@@ -15,22 +14,16 @@ var __export = (target, all) => {
|
|
|
15
14
|
for (var name in all)
|
|
16
15
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
16
|
};
|
|
18
|
-
var
|
|
19
|
-
if (
|
|
20
|
-
for (let key of __getOwnPropNames(
|
|
21
|
-
if (!__hasOwnProp.call(
|
|
22
|
-
__defProp(
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
22
|
}
|
|
24
|
-
return
|
|
25
|
-
};
|
|
26
|
-
var __toESM = (module2, isNodeMode) => {
|
|
27
|
-
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
23
|
+
return to;
|
|
28
24
|
};
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
32
|
-
};
|
|
33
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
27
|
var __publicField = (obj, key, value) => {
|
|
35
28
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
36
29
|
return value;
|
|
@@ -41,7 +34,7 @@ var require_package = __commonJS({
|
|
|
41
34
|
"package.json"(exports, module2) {
|
|
42
35
|
module2.exports = {
|
|
43
36
|
name: "@discordjs/voice",
|
|
44
|
-
version: "0.
|
|
37
|
+
version: "0.10.0-dev",
|
|
45
38
|
description: "Implementation of the Discord Voice API for node.js",
|
|
46
39
|
scripts: {
|
|
47
40
|
build: "tsup && node scripts/postbuild.mjs",
|
|
@@ -91,7 +84,7 @@ var require_package = __commonJS({
|
|
|
91
84
|
},
|
|
92
85
|
homepage: "https://discord.js.org",
|
|
93
86
|
dependencies: {
|
|
94
|
-
"@types/ws": "^8.
|
|
87
|
+
"@types/ws": "^8.5.3",
|
|
95
88
|
"discord-api-types": "^0.29.0",
|
|
96
89
|
"prism-media": "^1.3.2",
|
|
97
90
|
"tiny-typed-emitter": "^2.1.0",
|
|
@@ -99,26 +92,26 @@ var require_package = __commonJS({
|
|
|
99
92
|
ws: "^8.5.0"
|
|
100
93
|
},
|
|
101
94
|
devDependencies: {
|
|
102
|
-
"@babel/core": "^7.17.
|
|
95
|
+
"@babel/core": "^7.17.9",
|
|
103
96
|
"@babel/preset-env": "^7.16.11",
|
|
104
97
|
"@babel/preset-typescript": "^7.16.7",
|
|
105
|
-
"@discordjs/ts-docgen": "^0.
|
|
106
|
-
"@types/jest": "^27.4.
|
|
107
|
-
"@types/node": "^16.11.
|
|
108
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
109
|
-
"@typescript-eslint/parser": "^5.
|
|
110
|
-
eslint: "^8.
|
|
111
|
-
"eslint-config-marine": "^9.
|
|
112
|
-
"eslint-config-prettier": "^8.
|
|
113
|
-
"eslint-plugin-
|
|
98
|
+
"@discordjs/ts-docgen": "^0.4.1",
|
|
99
|
+
"@types/jest": "^27.4.1",
|
|
100
|
+
"@types/node": "^16.11.27",
|
|
101
|
+
"@typescript-eslint/eslint-plugin": "^5.19.0",
|
|
102
|
+
"@typescript-eslint/parser": "^5.19.0",
|
|
103
|
+
eslint: "^8.13.0",
|
|
104
|
+
"eslint-config-marine": "^9.4.1",
|
|
105
|
+
"eslint-config-prettier": "^8.5.0",
|
|
106
|
+
"eslint-plugin-import": "^2.26.0",
|
|
114
107
|
jest: "^27.5.1",
|
|
115
108
|
"jest-websocket-mock": "^2.3.0",
|
|
116
109
|
"mock-socket": "^9.1.2",
|
|
117
|
-
prettier: "^2.
|
|
118
|
-
tsup: "^5.
|
|
110
|
+
prettier: "^2.6.2",
|
|
111
|
+
tsup: "^5.12.5",
|
|
119
112
|
tweetnacl: "^1.0.3",
|
|
120
|
-
typedoc: "^0.22.
|
|
121
|
-
typescript: "^4.
|
|
113
|
+
typedoc: "^0.22.15",
|
|
114
|
+
typescript: "^4.6.3"
|
|
122
115
|
},
|
|
123
116
|
engines: {
|
|
124
117
|
node: ">=16.9.0"
|
|
@@ -160,6 +153,10 @@ __export(src_exports, {
|
|
|
160
153
|
joinVoiceChannel: () => joinVoiceChannel,
|
|
161
154
|
validateDiscordOpusHead: () => validateDiscordOpusHead
|
|
162
155
|
});
|
|
156
|
+
module.exports = __toCommonJS(src_exports);
|
|
157
|
+
|
|
158
|
+
// src/VoiceConnection.ts
|
|
159
|
+
var import_tiny_typed_emitter7 = require("tiny-typed-emitter");
|
|
163
160
|
|
|
164
161
|
// src/DataStore.ts
|
|
165
162
|
var import_v10 = require("discord-api-types/v10");
|
|
@@ -261,6 +258,7 @@ __name(deleteAudioPlayer, "deleteAudioPlayer");
|
|
|
261
258
|
|
|
262
259
|
// src/networking/Networking.ts
|
|
263
260
|
var import_v42 = require("discord-api-types/voice/v4");
|
|
261
|
+
var import_tiny_typed_emitter3 = require("tiny-typed-emitter");
|
|
264
262
|
|
|
265
263
|
// src/networking/VoiceUDPSocket.ts
|
|
266
264
|
var import_node_dgram = require("dgram");
|
|
@@ -365,8 +363,8 @@ __name(VoiceUDPSocket, "VoiceUDPSocket");
|
|
|
365
363
|
|
|
366
364
|
// src/networking/VoiceWebSocket.ts
|
|
367
365
|
var import_v4 = require("discord-api-types/voice/v4");
|
|
368
|
-
var import_ws = __toESM(require("ws"));
|
|
369
366
|
var import_tiny_typed_emitter2 = require("tiny-typed-emitter");
|
|
367
|
+
var import_ws = __toESM(require("ws"));
|
|
370
368
|
var VoiceWebSocket = class extends import_tiny_typed_emitter2.TypedEmitter {
|
|
371
369
|
constructor(address, debug) {
|
|
372
370
|
super();
|
|
@@ -519,7 +517,6 @@ var noop = /* @__PURE__ */ __name(() => {
|
|
|
519
517
|
}, "noop");
|
|
520
518
|
|
|
521
519
|
// src/networking/Networking.ts
|
|
522
|
-
var import_tiny_typed_emitter3 = require("tiny-typed-emitter");
|
|
523
520
|
var CHANNELS = 2;
|
|
524
521
|
var TIMESTAMP_INC = 48e3 / 100 * CHANNELS;
|
|
525
522
|
var MAX_NONCE_SIZE = 2 ** 32 - 1;
|
|
@@ -809,15 +806,15 @@ to ${stringifyState(newState)}`);
|
|
|
809
806
|
};
|
|
810
807
|
__name(Networking, "Networking");
|
|
811
808
|
|
|
812
|
-
// src/VoiceConnection.ts
|
|
813
|
-
var import_tiny_typed_emitter7 = require("tiny-typed-emitter");
|
|
814
|
-
|
|
815
809
|
// src/receive/VoiceReceiver.ts
|
|
816
810
|
var import_v43 = require("discord-api-types/voice/v4");
|
|
817
811
|
|
|
818
812
|
// src/receive/AudioReceiveStream.ts
|
|
819
813
|
var import_node_stream = require("stream");
|
|
820
814
|
|
|
815
|
+
// src/audio/AudioPlayer.ts
|
|
816
|
+
var import_tiny_typed_emitter4 = require("tiny-typed-emitter");
|
|
817
|
+
|
|
821
818
|
// src/audio/AudioPlayerError.ts
|
|
822
819
|
var AudioPlayerError = class extends Error {
|
|
823
820
|
constructor(error, resource) {
|
|
@@ -846,7 +843,6 @@ var PlayerSubscription = class {
|
|
|
846
843
|
__name(PlayerSubscription, "PlayerSubscription");
|
|
847
844
|
|
|
848
845
|
// src/audio/AudioPlayer.ts
|
|
849
|
-
var import_tiny_typed_emitter4 = require("tiny-typed-emitter");
|
|
850
846
|
var SILENCE_FRAME = Buffer.from([248, 255, 254]);
|
|
851
847
|
var NoSubscriberBehavior = /* @__PURE__ */ ((NoSubscriberBehavior2) => {
|
|
852
848
|
NoSubscriberBehavior2["Pause"] = "pause";
|
|
@@ -1162,41 +1158,9 @@ var AudioReceiveStream = class extends import_node_stream.Readable {
|
|
|
1162
1158
|
};
|
|
1163
1159
|
__name(AudioReceiveStream, "AudioReceiveStream");
|
|
1164
1160
|
|
|
1165
|
-
// src/receive/SpeakingMap.ts
|
|
1166
|
-
var import_tiny_typed_emitter5 = require("tiny-typed-emitter");
|
|
1167
|
-
var _SpeakingMap = class extends import_tiny_typed_emitter5.TypedEmitter {
|
|
1168
|
-
constructor() {
|
|
1169
|
-
super();
|
|
1170
|
-
__publicField(this, "users");
|
|
1171
|
-
__publicField(this, "speakingTimeouts");
|
|
1172
|
-
this.users = /* @__PURE__ */ new Map();
|
|
1173
|
-
this.speakingTimeouts = /* @__PURE__ */ new Map();
|
|
1174
|
-
}
|
|
1175
|
-
onPacket(userId) {
|
|
1176
|
-
const timeout = this.speakingTimeouts.get(userId);
|
|
1177
|
-
if (timeout) {
|
|
1178
|
-
clearTimeout(timeout);
|
|
1179
|
-
} else {
|
|
1180
|
-
this.users.set(userId, Date.now());
|
|
1181
|
-
this.emit("start", userId);
|
|
1182
|
-
}
|
|
1183
|
-
this.startTimeout(userId);
|
|
1184
|
-
}
|
|
1185
|
-
startTimeout(userId) {
|
|
1186
|
-
this.speakingTimeouts.set(userId, setTimeout(() => {
|
|
1187
|
-
this.emit("end", userId);
|
|
1188
|
-
this.speakingTimeouts.delete(userId);
|
|
1189
|
-
this.users.delete(userId);
|
|
1190
|
-
}, _SpeakingMap.DELAY));
|
|
1191
|
-
}
|
|
1192
|
-
};
|
|
1193
|
-
var SpeakingMap = _SpeakingMap;
|
|
1194
|
-
__name(SpeakingMap, "SpeakingMap");
|
|
1195
|
-
__publicField(SpeakingMap, "DELAY", 100);
|
|
1196
|
-
|
|
1197
1161
|
// src/receive/SSRCMap.ts
|
|
1198
|
-
var
|
|
1199
|
-
var SSRCMap = class extends
|
|
1162
|
+
var import_tiny_typed_emitter5 = require("tiny-typed-emitter");
|
|
1163
|
+
var SSRCMap = class extends import_tiny_typed_emitter5.TypedEmitter {
|
|
1200
1164
|
constructor() {
|
|
1201
1165
|
super();
|
|
1202
1166
|
__publicField(this, "map");
|
|
@@ -1245,6 +1209,38 @@ var SSRCMap = class extends import_tiny_typed_emitter6.TypedEmitter {
|
|
|
1245
1209
|
};
|
|
1246
1210
|
__name(SSRCMap, "SSRCMap");
|
|
1247
1211
|
|
|
1212
|
+
// src/receive/SpeakingMap.ts
|
|
1213
|
+
var import_tiny_typed_emitter6 = require("tiny-typed-emitter");
|
|
1214
|
+
var _SpeakingMap = class extends import_tiny_typed_emitter6.TypedEmitter {
|
|
1215
|
+
constructor() {
|
|
1216
|
+
super();
|
|
1217
|
+
__publicField(this, "users");
|
|
1218
|
+
__publicField(this, "speakingTimeouts");
|
|
1219
|
+
this.users = /* @__PURE__ */ new Map();
|
|
1220
|
+
this.speakingTimeouts = /* @__PURE__ */ new Map();
|
|
1221
|
+
}
|
|
1222
|
+
onPacket(userId) {
|
|
1223
|
+
const timeout = this.speakingTimeouts.get(userId);
|
|
1224
|
+
if (timeout) {
|
|
1225
|
+
clearTimeout(timeout);
|
|
1226
|
+
} else {
|
|
1227
|
+
this.users.set(userId, Date.now());
|
|
1228
|
+
this.emit("start", userId);
|
|
1229
|
+
}
|
|
1230
|
+
this.startTimeout(userId);
|
|
1231
|
+
}
|
|
1232
|
+
startTimeout(userId) {
|
|
1233
|
+
this.speakingTimeouts.set(userId, setTimeout(() => {
|
|
1234
|
+
this.emit("end", userId);
|
|
1235
|
+
this.speakingTimeouts.delete(userId);
|
|
1236
|
+
this.users.delete(userId);
|
|
1237
|
+
}, _SpeakingMap.DELAY));
|
|
1238
|
+
}
|
|
1239
|
+
};
|
|
1240
|
+
var SpeakingMap = _SpeakingMap;
|
|
1241
|
+
__name(SpeakingMap, "SpeakingMap");
|
|
1242
|
+
__publicField(SpeakingMap, "DELAY", 100);
|
|
1243
|
+
|
|
1248
1244
|
// src/receive/VoiceReceiver.ts
|
|
1249
1245
|
var VoiceReceiver = class {
|
|
1250
1246
|
constructor(voiceConnection) {
|
|
@@ -1702,6 +1698,10 @@ function joinVoiceChannel(options) {
|
|
|
1702
1698
|
}
|
|
1703
1699
|
__name(joinVoiceChannel, "joinVoiceChannel");
|
|
1704
1700
|
|
|
1701
|
+
// src/audio/AudioResource.ts
|
|
1702
|
+
var import_node_stream2 = require("stream");
|
|
1703
|
+
var import_prism_media2 = __toESM(require("prism-media"));
|
|
1704
|
+
|
|
1705
1705
|
// src/audio/TransformerGraph.ts
|
|
1706
1706
|
var import_prism_media = __toESM(require("prism-media"));
|
|
1707
1707
|
var FFMPEG_PCM_ARGUMENTS = ["-analyzeduration", "0", "-loglevel", "0", "-f", "s16le", "-ar", "48000", "-ac", "2"];
|
|
@@ -1846,8 +1846,6 @@ function findPipeline(from, constraint) {
|
|
|
1846
1846
|
__name(findPipeline, "findPipeline");
|
|
1847
1847
|
|
|
1848
1848
|
// src/audio/AudioResource.ts
|
|
1849
|
-
var import_node_stream2 = require("stream");
|
|
1850
|
-
var import_prism_media2 = __toESM(require("prism-media"));
|
|
1851
1849
|
var AudioResource = class {
|
|
1852
1850
|
constructor(edges, streams, metadata, silencePaddingFrames) {
|
|
1853
1851
|
__publicField(this, "playStream");
|
|
@@ -1997,6 +1995,9 @@ function generateDependencyReport() {
|
|
|
1997
1995
|
}
|
|
1998
1996
|
__name(generateDependencyReport, "generateDependencyReport");
|
|
1999
1997
|
|
|
1998
|
+
// src/util/entersState.ts
|
|
1999
|
+
var import_node_events = require("events");
|
|
2000
|
+
|
|
2000
2001
|
// src/util/abortAfter.ts
|
|
2001
2002
|
function abortAfter(delay) {
|
|
2002
2003
|
const ac = new AbortController();
|
|
@@ -2007,7 +2008,6 @@ function abortAfter(delay) {
|
|
|
2007
2008
|
__name(abortAfter, "abortAfter");
|
|
2008
2009
|
|
|
2009
2010
|
// src/util/entersState.ts
|
|
2010
|
-
var import_node_events = require("events");
|
|
2011
2011
|
async function entersState(target, status, timeoutOrSignal) {
|
|
2012
2012
|
if (target.state.status !== status) {
|
|
2013
2013
|
const [ac, signal] = typeof timeoutOrSignal === "number" ? abortAfter(timeoutOrSignal) : [void 0, timeoutOrSignal];
|
|
@@ -2092,7 +2092,6 @@ function demuxProbe(stream, probeSize = 1024, validator = validateDiscordOpusHea
|
|
|
2092
2092
|
});
|
|
2093
2093
|
}
|
|
2094
2094
|
__name(demuxProbe, "demuxProbe");
|
|
2095
|
-
module.exports = __toCommonJS(src_exports);
|
|
2096
2095
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2097
2096
|
0 && (module.exports = {
|
|
2098
2097
|
AudioPlayer,
|