shoukaku-bun 4.2.1 → 4.2.2

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/index.ts CHANGED
@@ -1,9 +1,9 @@
1
- export * as Connectors from './src/connectors/libs';
2
- export * as Constants from './src/Constants';
3
- export * as Utils from './src/Utils';
4
- export * from './src/connectors/Connector';
5
- export * from './src/guild/Connection';
6
- export * from './src/guild/Player';
7
- export * from './src/node/Node';
8
- export * from './src/node/Rest';
9
- export * from './src/Shoukaku';
1
+ export * as Connectors from './src/connectors/libs/index.ts';
2
+ export * as Constants from './src/Constants.ts';
3
+ export * as Utils from './src/Utils.ts';
4
+ export * from './src/connectors/Connector.ts';
5
+ export * from './src/guild/Connection.ts';
6
+ export * from './src/guild/Player.ts';
7
+ export * from './src/node/Node.ts';
8
+ export * from './src/node/Rest.ts';
9
+ export * from './src/Shoukaku.ts';
package/package.json CHANGED
@@ -1,64 +1,65 @@
1
- {
2
- "name": "shoukaku-bun",
3
- "version": "4.2.1",
4
- "description": "Bun-native high-performance fork of Shoukaku. Node-dependencies purged.",
5
- "main": "index.ts",
6
- "module": "index.ts",
7
- "types": "index.ts",
8
- "files": [
9
- "src",
10
- "index.ts"
11
- ],
12
- "exports": {
13
- ".": {
14
- "types": "./index.ts",
15
- "import": "./index.ts",
16
- "require": "./index.ts"
17
- }
18
- },
19
- "scripts": {
20
- "lint": "eslint .",
21
- "test": "bun test"
22
- },
23
- "keywords": [
24
- "bot",
25
- "music",
26
- "lavalink",
27
- "bun",
28
- "high-performance",
29
- "discord",
30
- "websocket",
31
- "zero-dependencies",
32
- "typescript"
33
- ],
34
- "engines": {
35
- "bun": ">=1.3.6"
36
- },
37
- "author": "Saya",
38
- "contributors": [
39
- {
40
- "name": "Luigi Colantuono",
41
- "url": "https://github.com/LuigiColantuono"
42
- }
43
- ],
44
- "license": "MIT",
45
- "homepage": "https://github.com/LuigiColantuono/Shoukaku-Bun#readme",
46
- "repository": {
47
- "type": "git",
48
- "url": "git+https://github.com/LuigiColantuono/Shoukaku-Bun.git"
49
- },
50
- "bugs": {
51
- "url": "https://github.com/LuigiColantuono/Shoukaku-Bun/issues"
52
- },
53
- "funding": {
54
- "type": "individual",
55
- "url": "https://paypal.me/l0g4n7"
56
- },
57
- "dependencies": {},
58
- "devDependencies": {
59
- "@shipgirl/eslint-config": "^0.4.2",
60
- "@types/bun": "latest",
61
- "eslint": "^9.39.2",
62
- "typescript": "^5.9.3"
63
- }
64
- }
1
+ {
2
+ "name": "shoukaku-bun",
3
+ "version": "4.2.2",
4
+ "description": "Bun-native high-performance fork of Shoukaku. Node-dependencies purged.",
5
+ "main": "index.ts",
6
+ "module": "index.ts",
7
+ "types": "index.ts",
8
+ "files": [
9
+ "src",
10
+ "index.ts"
11
+ ],
12
+ "exports": {
13
+ ".": {
14
+ "types": "./index.ts",
15
+ "import": "./index.ts",
16
+ "require": "./index.ts"
17
+ }
18
+ },
19
+ "scripts": {
20
+ "lint": "eslint .",
21
+ "test": "bun test"
22
+ },
23
+ "keywords": [
24
+ "bot",
25
+ "music",
26
+ "lavalink",
27
+ "bun",
28
+ "high-performance",
29
+ "discord",
30
+ "websocket",
31
+ "zero-dependencies",
32
+ "typescript"
33
+ ],
34
+ "engines": {
35
+ "bun": ">=1.3.6"
36
+ },
37
+ "author": "Saya",
38
+ "contributors": [
39
+ {
40
+ "name": "Luigi Colantuono",
41
+ "url": "https://github.com/LuigiColantuono"
42
+ }
43
+ ],
44
+ "license": "MIT",
45
+ "homepage": "https://github.com/LuigiColantuono/Shoukaku-Bun#readme",
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/LuigiColantuono/Shoukaku-Bun.git"
49
+ },
50
+ "bugs": {
51
+ "url": "https://github.com/LuigiColantuono/Shoukaku-Bun/issues"
52
+ },
53
+ "funding": {
54
+ "type": "individual",
55
+ "url": "https://paypal.me/l0g4n7"
56
+ },
57
+ "dependencies": {},
58
+ "devDependencies": {
59
+ "@types/bun": "latest",
60
+ "eslint": "^9.39.2",
61
+ "globals": "^17.2.0",
62
+ "typescript": "^5.9.3",
63
+ "typescript-eslint": "^8.54.0"
64
+ }
65
+ }
package/src/Constants.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Info from '../package.json';
2
- import type { NodeOption, ShoukakuOptions } from './Shoukaku';
2
+ import type { NodeOption, ShoukakuOptions } from './Shoukaku.ts';
3
3
 
4
4
  export enum State {
5
5
  CONNECTING,
package/src/Shoukaku.ts CHANGED
@@ -1,10 +1,11 @@
1
- import { ShoukakuDefaults, VoiceState } from './Constants';
2
- import { Node } from './node/Node';
3
- import { Connector } from './connectors/Connector';
4
- import { Constructor, mergeDefault, TypedEventEmitter } from './Utils';
5
- import { Player } from './guild/Player';
6
- import { Rest } from './node/Rest';
7
- import { Connection } from './guild/Connection';
1
+ import type { Connector } from './connectors/Connector.ts';
2
+ import { ShoukakuDefaults, VoiceState } from './Constants.ts';
3
+ import { Connection } from './guild/Connection.ts';
4
+ import { Player } from './guild/Player.ts';
5
+ import { Node } from './node/Node.ts';
6
+ import type { Rest } from './node/Rest.ts';
7
+ import type { Constructor} from './Utils.ts';
8
+ import { mergeDefault, TypedEventEmitter } from './Utils.ts';
8
9
 
9
10
  export interface Structures {
10
11
  /**
@@ -97,7 +98,7 @@ export interface VoiceChannelOptions {
97
98
 
98
99
  // Interfaces are not final, but types are, and therefore has an index signature
99
100
  // https://stackoverflow.com/a/64970740
100
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
101
+
101
102
  export type ShoukakuEvents = {
102
103
  /**
103
104
  * Emitted when reconnect tries are occurring and how many tries are left
package/src/Utils.ts CHANGED
@@ -31,10 +31,10 @@ export type Constructor<T> = new (...args: unknown[]) => T;
31
31
  * @param given User input
32
32
  * @returns Merged options
33
33
  */
34
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
+
35
35
  export function mergeDefault<T extends Record<string, any>>(def: T, given: T): Required<T> {
36
36
  if (!given) return def as Required<T>;
37
- const defaultKeys: (keyof T)[] = Object.keys(def);
37
+ const defaultKeys: Array<keyof T> = Object.keys(def);
38
38
  for (const key in given) {
39
39
  if (defaultKeys.includes(key)) continue;
40
40
  delete given[key];
@@ -1,8 +1,8 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
2
- import { NodeDefaults } from '../Constants';
3
- import type { ServerUpdate, StateUpdatePartial } from '../guild/Connection';
4
- import type { NodeOption, Shoukaku } from '../Shoukaku';
5
- import { mergeDefault } from '../Utils';
1
+
2
+ import { NodeDefaults } from '../Constants.ts';
3
+ import type { ServerUpdate, StateUpdatePartial } from '../guild/Connection.ts';
4
+ import type { NodeOption, Shoukaku } from '../Shoukaku.ts';
5
+ import { mergeDefault } from '../Utils.ts';
6
6
 
7
7
  export interface ConnectorMethods {
8
8
  sendPacket: any;
@@ -15,7 +15,7 @@ export abstract class Connector {
15
15
  protected readonly client: any;
16
16
  protected manager: Shoukaku | null;
17
17
  constructor(client: any) {
18
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
18
+
19
19
  this.client = client;
20
20
  this.manager = null;
21
21
  }
@@ -1,6 +1,6 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-explicit-any */
2
- import type { NodeOption } from '../../Shoukaku';
3
- import { Connector } from '../Connector';
1
+
2
+ import type { NodeOption } from '../../Shoukaku.ts';
3
+ import { Connector } from '../Connector.ts';
4
4
 
5
5
  export class DiscordJS extends Connector {
6
6
  // sendPacket is where your library send packets to Discord Gateway
@@ -1,6 +1,6 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-explicit-any */
2
- import type { NodeOption } from '../../Shoukaku';
3
- import { Connector } from '../Connector';
1
+
2
+ import type { NodeOption } from '../../Shoukaku.ts';
3
+ import { Connector } from '../Connector.ts';
4
4
 
5
5
  export class Eris extends Connector {
6
6
  // sendPacket is where your library send packets to Discord Gateway
@@ -1,6 +1,6 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-explicit-any */
2
- import type { NodeOption } from '../../Shoukaku';
3
- import { Connector } from '../Connector';
1
+
2
+ import type { NodeOption } from '../../Shoukaku.ts';
3
+ import { Connector } from '../Connector.ts';
4
4
 
5
5
  export class OceanicJS extends Connector {
6
6
  // sendPacket is where your library send packets to Discord Gateway
@@ -1,6 +1,6 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-explicit-any */
2
- import type { NodeOption } from '../../Shoukaku';
3
- import { Connector } from '../Connector';
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ import type { NodeOption } from '../../Shoukaku.ts';
3
+ import { Connector } from '../Connector.ts';
4
4
 
5
5
  export class Seyfert extends Connector {
6
6
  // sendPacket is where your library send packets to Discord Gateway
@@ -1,4 +1,4 @@
1
- export * from './DiscordJS';
2
- export * from './Eris';
3
- export * from './OceanicJS';
4
- export * from './Seyfert';
1
+ export * from './DiscordJS.ts';
2
+ export * from './Eris.ts';
3
+ export * from './OceanicJS.ts';
4
+ export * from './Seyfert.ts';
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter, once } from 'node:events';
2
- import { State, VoiceState } from '../Constants';
3
- import type { Shoukaku, VoiceChannelOptions } from '../Shoukaku';
2
+ import { State, VoiceState } from '../Constants.ts';
3
+ import type { Shoukaku, VoiceChannelOptions } from '../Shoukaku.ts';
4
4
 
5
5
  /**
6
6
  * Represents the partial payload from a stateUpdate event
@@ -1,8 +1,9 @@
1
- import { OpCodes, State } from '../Constants';
2
- import type { Node } from '../node/Node';
3
- import type { Exception, Track, UpdatePlayerInfo, UpdatePlayerOptions } from '../node/Rest';
4
- import { TypedEventEmitter } from '../Utils';
5
- import { Connection } from './Connection';
1
+ import type { OpCodes} from '../Constants.ts';
2
+ import { State } from '../Constants.ts';
3
+ import type { Node } from '../node/Node.ts';
4
+ import type { Exception, Track, UpdatePlayerInfo, UpdatePlayerOptions } from '../node/Rest.ts';
5
+ import { TypedEventEmitter } from '../Utils.ts';
6
+ import type { Connection } from './Connection.ts';
6
7
 
7
8
  export type TrackEndReason = 'finished' | 'loadFailed' | 'stopped' | 'replaced' | 'cleanup';
8
9
  export type PlayOptions = Omit<UpdatePlayerOptions, 'filters' | 'voice'>;
@@ -125,7 +126,7 @@ export interface FilterOptions {
125
126
 
126
127
  // Interfaces are not final, but types are, and therefore has an index signature
127
128
  // https://stackoverflow.com/a/64970740
128
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
129
+
129
130
  export type PlayerEvents = {
130
131
  /**
131
132
  * Emitted when the current playing track ends
@@ -249,7 +250,7 @@ export class Player extends TypedEventEmitter<PlayerEvents> {
249
250
  if (!node || node.name === this.node.name || node.state !== State.CONNECTED) return false;
250
251
 
251
252
  let lastNode = this.node.manager.nodes.get(this.node.name);
252
- if (!lastNode || lastNode.state !== State.CONNECTED)
253
+ if (lastNode?.state !== State.CONNECTED)
253
254
  lastNode = this.node.manager.getIdealNode(connection);
254
255
 
255
256
  await this.destroy();
package/src/node/Node.ts CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- import { OpCodes, ShoukakuClientInfo, State, Versions } from '../Constants';
2
+ import { OpCodes, ShoukakuClientInfo, State, Versions } from '../Constants.ts';
3
3
  import type {
4
4
  PlayerUpdate,
5
5
  TrackEndEvent,
@@ -7,10 +7,10 @@ import type {
7
7
  TrackStartEvent,
8
8
  TrackStuckEvent,
9
9
  WebSocketClosedEvent
10
- } from '../guild/Player';
11
- import type { NodeOption, Shoukaku, ShoukakuEvents } from '../Shoukaku';
12
- import { TypedEventEmitter, wait } from '../Utils';
13
- import { Rest } from './Rest';
10
+ } from '../guild/Player.ts';
11
+ import type { NodeOption, Shoukaku, ShoukakuEvents } from '../Shoukaku.ts';
12
+ import { TypedEventEmitter, wait } from '../Utils.ts';
13
+ import { Rest } from './Rest.ts';
14
14
 
15
15
  export interface Ready {
16
16
  op: OpCodes.READY;
@@ -241,7 +241,7 @@ export class Node extends TypedEventEmitter<NodeEvents> {
241
241
  };
242
242
  server.onerror = (error) => {
243
243
  cleanup();
244
- reject(new Error(`Websocket failed to connect due to: ${(error as any).message || 'Unknown error'}`));
244
+ reject(new Error(`Websocket failed to connect due to: ${(error as { message?: string })?.message ?? 'Unknown error'}`));
245
245
  };
246
246
  });
247
247
  };
@@ -273,7 +273,7 @@ export class Node extends TypedEventEmitter<NodeEvents> {
273
273
  }
274
274
 
275
275
  this.ws!.onclose = event => void this.close(event.code, event.reason);
276
- this.ws!.onerror = event => this.error(new Error(`WebSocket connection error: ${(event as any).message || 'Unknown error'}`));
276
+ this.ws!.onerror = event => this.error(new Error(`WebSocket connection error: ${(event as { message?: string })?.message ?? 'Unknown error'}`));
277
277
  this.ws!.onmessage = event => void this.message(event.data).catch(error => this.error(error as Error));
278
278
  this.open();
279
279
  }
@@ -305,7 +305,7 @@ export class Node extends TypedEventEmitter<NodeEvents> {
305
305
  */
306
306
  private open(): void {
307
307
  this.reconnects = 0;
308
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
308
+
309
309
  this.emit('debug', `[Socket] <-> [${this.name}] : Connection Handshake Done => ${this.url}`);
310
310
  }
311
311
 
@@ -315,7 +315,7 @@ export class Node extends TypedEventEmitter<NodeEvents> {
315
315
  * @internal
316
316
  */
317
317
  private async message(message: unknown): Promise<void> {
318
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
318
+
319
319
  const json: Ready | Stats | PlayerUpdate | TrackStartEvent | TrackEndEvent | TrackStuckEvent | TrackExceptionEvent | WebSocketClosedEvent = JSON.parse(message as string);
320
320
  if (!json) return;
321
321
  this.emit('raw', json);
@@ -367,6 +367,7 @@ export class Node extends TypedEventEmitter<NodeEvents> {
367
367
  break;
368
368
  }
369
369
  default:
370
+
370
371
  this.emit('debug', `[Player] -> [Node] : Unknown Message Op, Data => ${JSON.stringify(json)}`);
371
372
  }
372
373
  }
package/src/node/Rest.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { Versions } from '../Constants';
2
- import type { FilterOptions } from '../guild/Player';
3
- import type { NodeOption } from '../Shoukaku';
4
- import type { Node, NodeInfo, Stats } from './Node';
1
+ import { Versions } from '../Constants.ts';
2
+ import type { FilterOptions } from '../guild/Player.ts';
3
+ import type { NodeOption } from '../Shoukaku.ts';
4
+ import type { Node, NodeInfo, Stats } from './Node.ts';
5
5
 
6
6
  export type Severity = 'common' | 'suspicious' | 'fault';
7
7