@discordjs/voice 0.9.0-dev.1647216468.87a6b84 → 0.9.0-dev.1648166871.cedd053

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Readable, ReadableOptions } from 'node:stream';
2
2
  import prism from 'prism-media';
3
3
  import { TypedEmitter } from 'tiny-typed-emitter';
4
- import { GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData } from 'discord-api-types/v9';
4
+ import { GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData } from 'discord-api-types/v10';
5
5
  import WebSocket, { MessageEvent } from 'ws';
6
6
 
7
7
  declare type Awaited<T> = T | Promise<T>;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var ze=Object.create;var A=Object.defineProperty;var Ye=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Ze=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty;var et=(i,e,t)=>e in i?A(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var ne=i=>A(i,"__esModule",{value:!0}),r=(i,e)=>A(i,"name",{value:e,configurable:!0});var tt=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),it=(i,e)=>{for(var t in e)A(i,t,{get:e[t],enumerable:!0})},re=(i,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Xe(e))!Qe.call(i,s)&&(t||s!=="default")&&A(i,s,{get:()=>e[s],enumerable:!(o=Ye(e,s))||o.enumerable});return i},I=(i,e)=>re(ne(A(i!=null?ze(Ze(i)):{},"default",!e&&i&&i.__esModule?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i),ot=(i=>(e,t)=>i&&i.get(e)||(t=re(ne({}),e,1),i&&i.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var a=(i,e,t)=>(et(i,typeof e!="symbol"?e+"":e,t),t);var je=tt((qi,Pt)=>{Pt.exports={name:"@discordjs/voice",version:"0.9.0-dev",description:"Implementation of the Discord Voice API for node.js",scripts:{build:"tsup && node scripts/postbuild.mjs",test:"jest --pass-with-no-tests --collect-coverage",lint:"prettier --check . && eslint src __tests__ --ext mjs,js,ts",format:"prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",docs:"typedoc --json docs/typedoc-out.json src/index.ts && node scripts/docs.mjs",prepublishOnly:"yarn build && yarn lint && yarn test",changelog:"git cliff --prepend ./CHANGELOG.md -l -c ./cliff.toml -r ../../ --include-path 'packages/voice/*'"},main:"./dist/index.js",module:"./dist/index.mjs",typings:"./dist/index.d.ts",exports:{import:"./dist/index.mjs",require:"./dist/index.js",types:"./dist/index.d.ts"},directories:{lib:"src",test:"__tests__"},files:["dist"],contributors:["Crawl <icrawltogo@gmail.com>","Amish Shah <amishshah.2k@gmail.com>","SpaceEEC <spaceeec@yahoo.com>","Vlad Frangu <kingdgrizzle@gmail.com>","Antonio Roman <kyradiscord@gmail.com>"],license:"Apache-2.0",keywords:["discord","discord.js","audio","voice","streaming"],repository:{type:"git",url:"git+https://github.com/discordjs/discord.js.git"},bugs:{url:"https://github.com/discordjs/discord.js/issues"},homepage:"https://discord.js.org",dependencies:{"@types/ws":"^8.2.2","discord-api-types":"^0.27.0","prism-media":"^1.3.2","tiny-typed-emitter":"^2.1.0",tslib:"^2.3.1",ws:"^8.5.0"},devDependencies:{"@babel/core":"^7.17.2","@babel/preset-env":"^7.16.11","@babel/preset-typescript":"^7.16.7","@discordjs/ts-docgen":"^0.3.4","@types/jest":"^27.4.0","@types/node":"^16.11.24","@typescript-eslint/eslint-plugin":"^5.11.0","@typescript-eslint/parser":"^5.11.0",eslint:"^8.9.0","eslint-config-marine":"^9.3.2","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^4.0.0",jest:"^27.5.1","jest-websocket-mock":"^2.3.0","mock-socket":"^9.1.2",prettier:"^2.5.1",tsup:"^5.11.13",tweetnacl:"^1.0.3",typedoc:"^0.22.11",typescript:"^4.5.5"},engines:{node:">=16.9.0"},publishConfig:{access:"public"}}});var Dt={};it(Dt,{AudioPlayer:()=>N,AudioPlayerError:()=>w,AudioPlayerStatus:()=>Z,AudioReceiveStream:()=>B,AudioResource:()=>R,EndBehaviorType:()=>Ee,NoSubscriberBehavior:()=>X,PlayerSubscription:()=>x,SSRCMap:()=>M,SpeakingMap:()=>D,StreamType:()=>E,VoiceConnection:()=>W,VoiceConnectionDisconnectReason:()=>te,VoiceConnectionStatus:()=>L,VoiceReceiver:()=>U,createAudioPlayer:()=>Ve,createAudioResource:()=>Fe,createDefaultAudioReceiveStreamOptions:()=>Q,demuxProbe:()=>Vt,entersState:()=>xt,generateDependencyReport:()=>wt,getGroups:()=>ce,getVoiceConnection:()=>_,getVoiceConnections:()=>j,joinVoiceChannel:()=>yt,validateDiscordOpusHead:()=>qe});var ae=require("discord-api-types/v9");function P(i){return{op:ae.GatewayOpcodes.VoiceStateUpdate,d:{guild_id:i.guildId,channel_id:i.channelId,self_deaf:i.selfDeaf,self_mute:i.selfMute}}}r(P,"createJoinVoiceChannelPayload");var T=new Map;T.set("default",new Map);function st(i){let e=T.get(i);if(e)return e;let t=new Map;return T.set(i,t),t}r(st,"getOrCreateGroup");function ce(){return T}r(ce,"getGroups");function j(i="default"){return T.get(i)}r(j,"getVoiceConnections");function _(i,e="default"){return j(e)?.get(i)}r(_,"getVoiceConnection");function de(i){return j(i.joinConfig.group)?.delete(i.joinConfig.guildId)}r(de,"untrackVoiceConnection");function ue(i){return st(i.joinConfig.group).set(i.joinConfig.guildId,i)}r(ue,"trackVoiceConnection");var nt=20,K,v=-1,S=[];function pe(){if(v===-1)return;v+=nt;let i=S.filter(e=>e.checkPlayable());i.forEach(e=>e._stepDispatch()),le(i)}r(pe,"audioCycleStep");function le(i){let e=i.shift();if(!e){v!==-1&&(K=setTimeout(()=>pe(),v-Date.now()));return}e._stepPrepare(),setImmediate(()=>le(i))}r(le,"prepareNextAudioFrame");function rt(i){return S.includes(i)}r(rt,"hasAudioPlayer");function fe(i){return rt(i)||(S.push(i),S.length===1&&(v=Date.now(),setImmediate(()=>pe()))),i}r(fe,"addAudioPlayer");function he(i){let e=S.indexOf(i);e!==-1&&(S.splice(e,1),S.length===0&&(v=-1,typeof K!="undefined"&&clearTimeout(K)))}r(he,"deleteAudioPlayer");var h=require("discord-api-types/voice/v4");var me=require("dgram"),ge=require("net"),ye=require("tiny-typed-emitter");function at(i){let e=Buffer.from(i),t=e.slice(8,e.indexOf(0,8)).toString("utf-8");if(!(0,ge.isIPv4)(t))throw new Error("Malformed IP address");let o=e.readUInt16BE(e.length-2);return{ip:t,port:o}}r(at,"parseLocalPacket");var ct=5e3,dt=12,ut=2**32-1,G=class extends ye.TypedEmitter{constructor(e,t=!1){super();a(this,"socket");a(this,"remote");a(this,"keepAlives");a(this,"keepAliveCounter",0);a(this,"keepAliveBuffer");a(this,"keepAliveInterval");a(this,"ping");a(this,"debug");this.socket=(0,me.createSocket)("udp4"),this.socket.on("error",o=>this.emit("error",o)),this.socket.on("message",o=>this.onMessage(o)),this.socket.on("close",()=>this.emit("close")),this.remote=e,this.keepAlives=[],this.keepAliveBuffer=Buffer.alloc(8),this.keepAliveInterval=setInterval(()=>this.keepAlive(),ct),setImmediate(()=>this.keepAlive()),this.debug=t?o=>this.emit("debug",o):null}onMessage(e){if(e.length===8){let t=e.readUInt32LE(0),o=this.keepAlives.findIndex(({value:s})=>s===t);if(o===-1)return;this.ping=Date.now()-this.keepAlives[o].timestamp,this.keepAlives.splice(0,o)}this.emit("message",e)}keepAlive(){if(this.keepAlives.length>=dt){this.debug?.("UDP socket has not received enough responses from Discord - closing socket"),this.destroy();return}this.keepAliveBuffer.writeUInt32LE(this.keepAliveCounter,0),this.send(this.keepAliveBuffer),this.keepAlives.push({value:this.keepAliveCounter,timestamp:Date.now()}),this.keepAliveCounter++,this.keepAliveCounter>ut&&(this.keepAliveCounter=0)}send(e){return this.socket.send(e,this.remote.port,this.remote.ip)}destroy(){try{this.socket.close()}catch{}clearInterval(this.keepAliveInterval)}performIPDiscovery(e){return new Promise((t,o)=>{let s=r(c=>{try{if(c.readUInt16BE(0)!==2)return;let u=at(c);this.socket.off("message",s),t(u)}catch{}},"listener");this.socket.on("message",s),this.socket.once("close",()=>o(new Error("Cannot perform IP discovery - socket closed")));let n=Buffer.alloc(74);n.writeUInt16BE(1,0),n.writeUInt16BE(70,2),n.writeUInt32BE(e,4),this.send(n)})}};r(G,"VoiceUDPSocket");var z=require("discord-api-types/voice/v4"),be=I(require("ws")),Se=require("tiny-typed-emitter"),H=class extends Se.TypedEmitter{constructor(e,t){super();a(this,"heartbeatInterval");a(this,"lastHeartbeatAck");a(this,"lastHeartbeatSend");a(this,"missedHeartbeats",0);a(this,"ping");a(this,"debug");a(this,"ws");this.ws=new be.default(e),this.ws.onmessage=o=>this.onMessage(o),this.ws.onopen=o=>this.emit("open",o),this.ws.onerror=o=>this.emit("error",o instanceof Error?o:o.error),this.ws.onclose=o=>this.emit("close",o),this.lastHeartbeatAck=0,this.lastHeartbeatSend=0,this.debug=t?o=>this.emit("debug",o):null}destroy(){try{this.debug?.("destroyed"),this.setHeartbeatInterval(-1),this.ws.close(1e3)}catch(e){let t=e;this.emit("error",t)}}onMessage(e){if(typeof e.data!="string")return;this.debug?.(`<< ${e.data}`);let t;try{t=JSON.parse(e.data)}catch(o){let s=o;this.emit("error",s);return}t.op===z.VoiceOpcodes.HeartbeatAck&&(this.lastHeartbeatAck=Date.now(),this.missedHeartbeats=0,this.ping=this.lastHeartbeatAck-this.lastHeartbeatSend),this.emit("packet",t)}sendPacket(e){try{let t=JSON.stringify(e);return this.debug?.(`>> ${t}`),this.ws.send(t)}catch(t){let o=t;this.emit("error",o)}}sendHeartbeat(){this.lastHeartbeatSend=Date.now(),this.missedHeartbeats++;let e=this.lastHeartbeatSend;return this.sendPacket({op:z.VoiceOpcodes.Heartbeat,d:e})}setHeartbeatInterval(e){typeof this.heartbeatInterval!="undefined"&&clearInterval(this.heartbeatInterval),e>0&&(this.heartbeatInterval=setInterval(()=>{this.lastHeartbeatSend!==0&&this.missedHeartbeats>=3&&(this.ws.close(),this.setHeartbeatInterval(-1)),this.sendHeartbeat()},e))}};r(H,"VoiceWebSocket");var Ce={sodium:i=>({open:i.api.crypto_secretbox_open_easy,close:i.api.crypto_secretbox_easy,random:(e,t)=>(t||(t=Buffer.allocUnsafe(e)),i.api.randombytes_buf(t),t)}),"libsodium-wrappers":i=>({open:i.crypto_secretbox_open_easy,close:i.crypto_secretbox_easy,random:e=>i.randombytes_buf(e)}),tweetnacl:i=>({open:i.secretbox.open,close:i.secretbox,random:e=>i.randomBytes(e)})},Y=r(()=>{throw new Error(`Cannot play audio as no valid encryption package is installed.
1
+ var ze=Object.create;var A=Object.defineProperty;var Ye=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Ze=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty;var et=(i,e,t)=>e in i?A(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var ne=i=>A(i,"__esModule",{value:!0}),r=(i,e)=>A(i,"name",{value:e,configurable:!0});var tt=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),it=(i,e)=>{for(var t in e)A(i,t,{get:e[t],enumerable:!0})},re=(i,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Xe(e))!Qe.call(i,s)&&(t||s!=="default")&&A(i,s,{get:()=>e[s],enumerable:!(o=Ye(e,s))||o.enumerable});return i},I=(i,e)=>re(ne(A(i!=null?ze(Ze(i)):{},"default",!e&&i&&i.__esModule?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i),ot=(i=>(e,t)=>i&&i.get(e)||(t=re(ne({}),e,1),i&&i.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var a=(i,e,t)=>(et(i,typeof e!="symbol"?e+"":e,t),t);var je=tt((qi,Pt)=>{Pt.exports={name:"@discordjs/voice",version:"0.9.0-dev",description:"Implementation of the Discord Voice API for node.js",scripts:{build:"tsup && node scripts/postbuild.mjs",test:"jest --pass-with-no-tests --collect-coverage",lint:"prettier --check . && eslint src __tests__ --ext mjs,js,ts",format:"prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",docs:"typedoc --json docs/typedoc-out.json src/index.ts && node scripts/docs.mjs",prepublishOnly:"yarn build && yarn lint && yarn test",changelog:"git cliff --prepend ./CHANGELOG.md -l -c ./cliff.toml -r ../../ --include-path 'packages/voice/*'"},main:"./dist/index.js",module:"./dist/index.mjs",typings:"./dist/index.d.ts",exports:{import:"./dist/index.mjs",require:"./dist/index.js",types:"./dist/index.d.ts"},directories:{lib:"src",test:"__tests__"},files:["dist"],contributors:["Crawl <icrawltogo@gmail.com>","Amish Shah <amishshah.2k@gmail.com>","SpaceEEC <spaceeec@yahoo.com>","Vlad Frangu <kingdgrizzle@gmail.com>","Antonio Roman <kyradiscord@gmail.com>"],license:"Apache-2.0",keywords:["discord","discord.js","audio","voice","streaming"],repository:{type:"git",url:"git+https://github.com/discordjs/discord.js.git"},bugs:{url:"https://github.com/discordjs/discord.js/issues"},homepage:"https://discord.js.org",dependencies:{"@types/ws":"^8.2.2","discord-api-types":"^0.29.0","prism-media":"^1.3.2","tiny-typed-emitter":"^2.1.0",tslib:"^2.3.1",ws:"^8.5.0"},devDependencies:{"@babel/core":"^7.17.2","@babel/preset-env":"^7.16.11","@babel/preset-typescript":"^7.16.7","@discordjs/ts-docgen":"^0.3.4","@types/jest":"^27.4.0","@types/node":"^16.11.24","@typescript-eslint/eslint-plugin":"^5.11.0","@typescript-eslint/parser":"^5.11.0",eslint:"^8.9.0","eslint-config-marine":"^9.3.2","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^4.0.0",jest:"^27.5.1","jest-websocket-mock":"^2.3.0","mock-socket":"^9.1.2",prettier:"^2.5.1",tsup:"^5.11.13",tweetnacl:"^1.0.3",typedoc:"^0.22.11",typescript:"^4.5.5"},engines:{node:">=16.9.0"},publishConfig:{access:"public"}}});var Dt={};it(Dt,{AudioPlayer:()=>N,AudioPlayerError:()=>w,AudioPlayerStatus:()=>Z,AudioReceiveStream:()=>B,AudioResource:()=>R,EndBehaviorType:()=>Ee,NoSubscriberBehavior:()=>X,PlayerSubscription:()=>x,SSRCMap:()=>M,SpeakingMap:()=>D,StreamType:()=>E,VoiceConnection:()=>W,VoiceConnectionDisconnectReason:()=>te,VoiceConnectionStatus:()=>L,VoiceReceiver:()=>U,createAudioPlayer:()=>Ve,createAudioResource:()=>Fe,createDefaultAudioReceiveStreamOptions:()=>Q,demuxProbe:()=>Vt,entersState:()=>xt,generateDependencyReport:()=>wt,getGroups:()=>ce,getVoiceConnection:()=>_,getVoiceConnections:()=>j,joinVoiceChannel:()=>yt,validateDiscordOpusHead:()=>qe});var ae=require("discord-api-types/v10");function P(i){return{op:ae.GatewayOpcodes.VoiceStateUpdate,d:{guild_id:i.guildId,channel_id:i.channelId,self_deaf:i.selfDeaf,self_mute:i.selfMute}}}r(P,"createJoinVoiceChannelPayload");var T=new Map;T.set("default",new Map);function st(i){let e=T.get(i);if(e)return e;let t=new Map;return T.set(i,t),t}r(st,"getOrCreateGroup");function ce(){return T}r(ce,"getGroups");function j(i="default"){return T.get(i)}r(j,"getVoiceConnections");function _(i,e="default"){return j(e)?.get(i)}r(_,"getVoiceConnection");function de(i){return j(i.joinConfig.group)?.delete(i.joinConfig.guildId)}r(de,"untrackVoiceConnection");function ue(i){return st(i.joinConfig.group).set(i.joinConfig.guildId,i)}r(ue,"trackVoiceConnection");var nt=20,K,v=-1,S=[];function pe(){if(v===-1)return;v+=nt;let i=S.filter(e=>e.checkPlayable());i.forEach(e=>e._stepDispatch()),le(i)}r(pe,"audioCycleStep");function le(i){let e=i.shift();if(!e){v!==-1&&(K=setTimeout(()=>pe(),v-Date.now()));return}e._stepPrepare(),setImmediate(()=>le(i))}r(le,"prepareNextAudioFrame");function rt(i){return S.includes(i)}r(rt,"hasAudioPlayer");function fe(i){return rt(i)||(S.push(i),S.length===1&&(v=Date.now(),setImmediate(()=>pe()))),i}r(fe,"addAudioPlayer");function he(i){let e=S.indexOf(i);e!==-1&&(S.splice(e,1),S.length===0&&(v=-1,typeof K!="undefined"&&clearTimeout(K)))}r(he,"deleteAudioPlayer");var h=require("discord-api-types/voice/v4");var me=require("dgram"),ge=require("net"),ye=require("tiny-typed-emitter");function at(i){let e=Buffer.from(i),t=e.slice(8,e.indexOf(0,8)).toString("utf-8");if(!(0,ge.isIPv4)(t))throw new Error("Malformed IP address");let o=e.readUInt16BE(e.length-2);return{ip:t,port:o}}r(at,"parseLocalPacket");var ct=5e3,dt=12,ut=2**32-1,G=class extends ye.TypedEmitter{constructor(e,t=!1){super();a(this,"socket");a(this,"remote");a(this,"keepAlives");a(this,"keepAliveCounter",0);a(this,"keepAliveBuffer");a(this,"keepAliveInterval");a(this,"ping");a(this,"debug");this.socket=(0,me.createSocket)("udp4"),this.socket.on("error",o=>this.emit("error",o)),this.socket.on("message",o=>this.onMessage(o)),this.socket.on("close",()=>this.emit("close")),this.remote=e,this.keepAlives=[],this.keepAliveBuffer=Buffer.alloc(8),this.keepAliveInterval=setInterval(()=>this.keepAlive(),ct),setImmediate(()=>this.keepAlive()),this.debug=t?o=>this.emit("debug",o):null}onMessage(e){if(e.length===8){let t=e.readUInt32LE(0),o=this.keepAlives.findIndex(({value:s})=>s===t);if(o===-1)return;this.ping=Date.now()-this.keepAlives[o].timestamp,this.keepAlives.splice(0,o)}this.emit("message",e)}keepAlive(){if(this.keepAlives.length>=dt){this.debug?.("UDP socket has not received enough responses from Discord - closing socket"),this.destroy();return}this.keepAliveBuffer.writeUInt32LE(this.keepAliveCounter,0),this.send(this.keepAliveBuffer),this.keepAlives.push({value:this.keepAliveCounter,timestamp:Date.now()}),this.keepAliveCounter++,this.keepAliveCounter>ut&&(this.keepAliveCounter=0)}send(e){return this.socket.send(e,this.remote.port,this.remote.ip)}destroy(){try{this.socket.close()}catch{}clearInterval(this.keepAliveInterval)}performIPDiscovery(e){return new Promise((t,o)=>{let s=r(c=>{try{if(c.readUInt16BE(0)!==2)return;let u=at(c);this.socket.off("message",s),t(u)}catch{}},"listener");this.socket.on("message",s),this.socket.once("close",()=>o(new Error("Cannot perform IP discovery - socket closed")));let n=Buffer.alloc(74);n.writeUInt16BE(1,0),n.writeUInt16BE(70,2),n.writeUInt32BE(e,4),this.send(n)})}};r(G,"VoiceUDPSocket");var z=require("discord-api-types/voice/v4"),be=I(require("ws")),Se=require("tiny-typed-emitter"),H=class extends Se.TypedEmitter{constructor(e,t){super();a(this,"heartbeatInterval");a(this,"lastHeartbeatAck");a(this,"lastHeartbeatSend");a(this,"missedHeartbeats",0);a(this,"ping");a(this,"debug");a(this,"ws");this.ws=new be.default(e),this.ws.onmessage=o=>this.onMessage(o),this.ws.onopen=o=>this.emit("open",o),this.ws.onerror=o=>this.emit("error",o instanceof Error?o:o.error),this.ws.onclose=o=>this.emit("close",o),this.lastHeartbeatAck=0,this.lastHeartbeatSend=0,this.debug=t?o=>this.emit("debug",o):null}destroy(){try{this.debug?.("destroyed"),this.setHeartbeatInterval(-1),this.ws.close(1e3)}catch(e){let t=e;this.emit("error",t)}}onMessage(e){if(typeof e.data!="string")return;this.debug?.(`<< ${e.data}`);let t;try{t=JSON.parse(e.data)}catch(o){let s=o;this.emit("error",s);return}t.op===z.VoiceOpcodes.HeartbeatAck&&(this.lastHeartbeatAck=Date.now(),this.missedHeartbeats=0,this.ping=this.lastHeartbeatAck-this.lastHeartbeatSend),this.emit("packet",t)}sendPacket(e){try{let t=JSON.stringify(e);return this.debug?.(`>> ${t}`),this.ws.send(t)}catch(t){let o=t;this.emit("error",o)}}sendHeartbeat(){this.lastHeartbeatSend=Date.now(),this.missedHeartbeats++;let e=this.lastHeartbeatSend;return this.sendPacket({op:z.VoiceOpcodes.Heartbeat,d:e})}setHeartbeatInterval(e){typeof this.heartbeatInterval!="undefined"&&clearInterval(this.heartbeatInterval),e>0&&(this.heartbeatInterval=setInterval(()=>{this.lastHeartbeatSend!==0&&this.missedHeartbeats>=3&&(this.ws.close(),this.setHeartbeatInterval(-1)),this.sendHeartbeat()},e))}};r(H,"VoiceWebSocket");var Ce={sodium:i=>({open:i.api.crypto_secretbox_open_easy,close:i.api.crypto_secretbox_easy,random:(e,t)=>(t||(t=Buffer.allocUnsafe(e)),i.api.randombytes_buf(t),t)}),"libsodium-wrappers":i=>({open:i.crypto_secretbox_open_easy,close:i.crypto_secretbox_easy,random:e=>i.randombytes_buf(e)}),tweetnacl:i=>({open:i.secretbox.open,close:i.secretbox,random:e=>i.randomBytes(e)})},Y=r(()=>{throw new Error(`Cannot play audio as no valid encryption package is installed.
2
2
  - Install sodium, libsodium-wrappers, or tweetnacl.
3
3
  - Use the generateDependencyReport() function for more information.
4
4
  `)},"fallbackError"),y={open:Y,close:Y,random:Y};(async()=>{for(let i of Object.keys(Ce))try{let e=require(i);i==="libsodium-wrappers"&&e.ready&&await e.ready,Object.assign(y,Ce[i](e));break}catch{}})();var l=r(()=>{},"noop");var ke=require("tiny-typed-emitter"),lt=2,ft=48e3/100*lt,ht=2**32-1,mt=["xsalsa20_poly1305_lite","xsalsa20_poly1305_suffix","xsalsa20_poly1305"];var Ae=Buffer.alloc(24);function Pe(i){return JSON.stringify({...i,ws:Reflect.has(i,"ws"),udp:Reflect.has(i,"udp")})}r(Pe,"stringifyState");function gt(i){let e=i.find(t=>mt.includes(t));if(!e)throw new Error(`No compatible encryption modes. Available include: ${i.join(", ")}`);return e}r(gt,"chooseEncryptionMode");function ve(i){return Math.floor(Math.random()*2**i)}r(ve,"randomNBit");var J=class extends ke.TypedEmitter{constructor(e,t){super();a(this,"_state");a(this,"debug");this.onWsOpen=this.onWsOpen.bind(this),this.onChildError=this.onChildError.bind(this),this.onWsPacket=this.onWsPacket.bind(this),this.onWsClose=this.onWsClose.bind(this),this.onWsDebug=this.onWsDebug.bind(this),this.onUdpDebug=this.onUdpDebug.bind(this),this.onUdpClose=this.onUdpClose.bind(this),this.debug=t?o=>this.emit("debug",o):null,this._state={code:0,ws:this.createWebSocket(e.endpoint),connectionOptions:e}}destroy(){this.state={code:6}}get state(){return this._state}set state(e){let t=Reflect.get(this._state,"ws"),o=Reflect.get(e,"ws");t&&t!==o&&(t.off("debug",this.onWsDebug),t.on("error",l),t.off("error",this.onChildError),t.off("open",this.onWsOpen),t.off("packet",this.onWsPacket),t.off("close",this.onWsClose),t.destroy());let s=Reflect.get(this._state,"udp"),n=Reflect.get(e,"udp");s&&s!==n&&(s.on("error",l),s.off("error",this.onChildError),s.off("close",this.onUdpClose),s.off("debug",this.onUdpDebug),s.destroy());let c=this._state;this._state=e,this.emit("stateChange",c,e),this.debug?.(`state change: