shoukaku-bun 4.2.0-d → 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/README.md +5 -13
- package/index.ts +9 -9
- package/package.json +4 -4
- package/src/Constants.ts +1 -1
- package/src/Shoukaku.ts +9 -8
- package/src/Utils.ts +2 -2
- package/src/connectors/Connector.ts +6 -6
- package/src/connectors/libs/DiscordJS.ts +3 -3
- package/src/connectors/libs/Eris.ts +3 -3
- package/src/connectors/libs/OceanicJS.ts +3 -3
- package/src/connectors/libs/Seyfert.ts +3 -3
- package/src/connectors/libs/index.ts +4 -4
- package/src/guild/Connection.ts +2 -2
- package/src/guild/Player.ts +8 -7
- package/src/node/Node.ts +10 -9
- package/src/node/Rest.ts +4 -4
package/README.md
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
## Shoukaku-Bun
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[](https://paypal.me/l0g4n7)
|
|
5
|
-
[](https://www.npmjs.com/package/shoukaku-bun)
|
|
6
|
-

|
|
7
|
-

|
|
8
|
-

|
|
3
|
+
<p align="center"><a href="https://github.com/sponsors/LuigiColantuono"><img src="https://img.shields.io/github/sponsors/LuigiColantuono?style=social"></a> <a href="https://paypal.me/l0g4n7"><img src="https://img.shields.io/badge/💖-Support-ff69b4"></a> <img src="https://img.shields.io/npm/v/shoukaku-bun"> <img src="https://img.shields.io/npm/dm/shoukaku-bun?label=downloads"> <img src="https://img.shields.io/npm/l/shoukaku-bun"> <img src="https://img.shields.io/github/repo-size/LuigiColantuono/Shoukaku-Bun"> <a href="https://github.com/LuigiColantuono/Shoukaku-Bun"><img src="https://img.shields.io/badge/Bun-Networking-black?logo=bun"></a></p>
|
|
9
4
|
|
|
10
5
|
> Powerful, Lightweight wrapper around Lavalink
|
|
11
6
|
|
|
12
7
|
<p align="center">
|
|
13
|
-
<img src="https://azurlane.netojuu.com/images/thumb/d/dc/ShoukakuWeddingWithoutBG.png/767px-ShoukakuWeddingWithoutBG.png">
|
|
8
|
+
<img src="https://azurlane.netojuu.com/images/thumb/d/dc/ShoukakuWeddingWithoutBG.png/767px-ShoukakuWeddingWithoutBG.png" width="400">
|
|
14
9
|
</p>
|
|
15
10
|
|
|
16
11
|
### Features
|
|
@@ -29,7 +24,7 @@
|
|
|
29
24
|
| shoukaku | 366 kB | ws (~300 kB) | **~666 kB** |
|
|
30
25
|
| shoukaku-bun | 72.9 kB | **NONE** | **72.9 kB** |
|
|
31
26
|
|
|
32
|
-
**89% smaller install size!**
|
|
27
|
+
**89% smaller install size!**
|
|
33
28
|
|
|
34
29
|
## 🎵 The Story
|
|
35
30
|
|
|
@@ -39,7 +34,7 @@ entire Shoukaku stack could be rewritten to be faster and lighter.
|
|
|
39
34
|
|
|
40
35
|
**Result?** Zero warnings. Noticeably faster. Way more fun to work with.
|
|
41
36
|
|
|
42
|
-
If this solved your problems too, [consider supporting the project](https://paypal.me/
|
|
37
|
+
If this solved your problems too, [consider supporting the project](https://paypal.me/l0g4n7)!
|
|
43
38
|
Even a coffee helps keep the motivation high! ☕
|
|
44
39
|
|
|
45
40
|
### Installation
|
|
@@ -54,13 +49,10 @@ bun add shoukaku-bun
|
|
|
54
49
|
> https://github.com/shipgirlproject/Shoukaku
|
|
55
50
|
|
|
56
51
|
## Performance
|
|
57
|
-
|
|
58
|
-
)
|
|
52
|
+
<img width="380" height="" alt="B R U C I U S 🎵" src="https://i.imgur.com/zZsPzm6.png" />
|
|
59
53
|
|
|
60
54
|
## Support
|
|
61
55
|
> Kazagumo support server: https://discord.gg/nPPW2Gzqg2 (anywhere lmao)
|
|
62
56
|
> Shoukaku support server: https://discord.gg/FVqbtGu (#development)
|
|
63
57
|
> Brucius support server: https://discord.gg/XqJw52d35R
|
|
64
58
|
|
|
65
|
-
### Code made with ❤ by @ichimakase (Saya) & Luigi
|
|
66
|
-
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shoukaku-bun",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.2",
|
|
4
4
|
"description": "Bun-native high-performance fork of Shoukaku. Node-dependencies purged.",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"module": "index.ts",
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@shipgirl/eslint-config": "^0.4.2",
|
|
60
59
|
"@types/bun": "latest",
|
|
61
60
|
"eslint": "^9.39.2",
|
|
62
|
-
"
|
|
63
|
-
"typescript": "^5.9.3"
|
|
61
|
+
"globals": "^17.2.0",
|
|
62
|
+
"typescript": "^5.9.3",
|
|
63
|
+
"typescript-eslint": "^8.54.0"
|
|
64
64
|
}
|
|
65
65
|
}
|
package/src/Constants.ts
CHANGED
package/src/Shoukaku.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { Rest } from './node/Rest';
|
|
7
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
18
|
+
|
|
19
19
|
this.client = client;
|
|
20
20
|
this.manager = null;
|
|
21
21
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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';
|
package/src/guild/Connection.ts
CHANGED
|
@@ -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
|
package/src/guild/Player.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { OpCodes
|
|
2
|
-
import
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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
|
-
|
|
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 (
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|