@discordeno/gateway 19.0.0-next.fd518cb → 19.0.0-next.fda3003

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.
@@ -1,8 +1,7 @@
1
- import type { AtLeastOne, BigString, Camelize, DiscordGatewayPayload, DiscordMember, RequestGuildMembers } from '@discordeno/types';
2
- import { Collection, LeakyBucket } from '@discordeno/utils';
3
- import WebSocket from 'ws';
4
- import type { RequestMemberRequest } from './manager.js';
5
- import type { BotStatusUpdate, ShardEvents, ShardGatewayConfig, ShardHeart, ShardSocketRequest, StatusUpdate, UpdateVoiceState } from './types.js';
1
+ import type { DiscordGatewayPayload } from '@discordeno/types';
2
+ import { LeakyBucket, logger } from '@discordeno/utils';
3
+ import NodeWebSocket from 'ws';
4
+ import type { BotStatusUpdate, ShardEvents, ShardGatewayConfig, ShardHeart, ShardSocketRequest } from './types.js';
6
5
  import { ShardState } from './types.js';
7
6
  export declare class DiscordenoShard {
8
7
  /** The id of the shard */
@@ -20,7 +19,7 @@ export declare class DiscordenoShard {
20
19
  /** Current session id of the shard if present. */
21
20
  sessionId?: string;
22
21
  /** This contains the WebSocket connection to Discord, if currently connected. */
23
- socket?: WebSocket;
22
+ socket?: NodeWebSocket;
24
23
  /** Current internal state of the this. */
25
24
  state: ShardState;
26
25
  /** The url provided by discord to use when resuming a connection for this this. */
@@ -33,22 +32,12 @@ export declare class DiscordenoShard {
33
32
  resolves: Map<"READY" | "RESUMED" | "INVALID_SESSION", (payload: DiscordGatewayPayload) => void>;
34
33
  /** Shard bucket. Only access this if you know what you are doing. Bucket for handling shard request rate limits. */
35
34
  bucket: LeakyBucket;
36
- /** This managers cache related settings. */
37
- cache: {
38
- requestMembers: {
39
- /**
40
- * Whether or not request member requests should be cached.
41
- * @default false
42
- */
43
- enabled: boolean;
44
- /** The pending requests. */
45
- pending: Collection<string, RequestMemberRequest>;
46
- };
47
- };
35
+ /** Logger for the bucket */
36
+ logger: Pick<typeof logger, 'debug' | 'info' | 'warn' | 'error' | 'fatal'>;
48
37
  constructor(options: ShardCreateOptions);
49
38
  /** The gateway configuration which is used to connect to Discord. */
50
39
  get gatewayConfig(): ShardGatewayConfig;
51
- /** The url to connect to. Intially this is the discord gateway url, and then is switched to resume gateway url once a READY is received. */
40
+ /** The url to connect to. Initially this is the discord gateway url, and then is switched to resume gateway url once a READY is received. */
52
41
  get connectionUrl(): string;
53
42
  /** Calculate the amount of requests which can safely be made per rate limit interval, before the gateway gets disconnected due to an exceeded rate limit. */
54
43
  calculateSafeRequests(): number;
@@ -70,12 +59,12 @@ export declare class DiscordenoShard {
70
59
  /** Shutdown the this. Forcefully disconnect the shard from Discord. The shard may not attempt to reconnect with Discord. */
71
60
  shutdown(): Promise<void>;
72
61
  /** Handle a gateway connection close. */
73
- handleClose(close: WebSocket.CloseEvent): Promise<void>;
62
+ handleClose(close: NodeWebSocket.CloseEvent): Promise<void>;
74
63
  /** Handles a incoming gateway packet. */
75
64
  handleDiscordPacket(packet: DiscordGatewayPayload): Promise<void>;
76
65
  forwardToBot(packet: DiscordGatewayPayload): void;
77
66
  /** Handle an incoming gateway message. */
78
- handleMessage(message: WebSocket.MessageEvent): Promise<void>;
67
+ handleMessage(message: NodeWebSocket.MessageEvent): Promise<void>;
79
68
  /**
80
69
  * Override in order to make the shards presence.
81
70
  * async in case devs create the presence based on eg. database values.
@@ -90,74 +79,6 @@ export declare class DiscordenoShard {
90
79
  startHeartbeating(interval: number): void;
91
80
  /** Stop the heartbeating process with discord. */
92
81
  stopHeartbeating(): void;
93
- /**
94
- * Connects the bot user to a voice or stage channel.
95
- *
96
- * This function sends the _Update Voice State_ gateway command over the gateway behind the scenes.
97
- *
98
- * @param guildId - The ID of the guild the voice channel to leave is in.
99
- * @param channelId - The ID of the channel you want to join.
100
- *
101
- * @remarks
102
- * Requires the `CONNECT` permission.
103
- *
104
- * Fires a _Voice State Update_ gateway event.
105
- *
106
- * @see {@link https://discord.com/developers/docs/topics/gateway#update-voice-state}
107
- */
108
- joinVoiceChannel(guildId: BigString, channelId: BigString, options?: AtLeastOne<Omit<UpdateVoiceState, 'guildId' | 'channelId'>>): Promise<void>;
109
- /**
110
- * Edits the bot status in all shards that this gateway manages.
111
- *
112
- * @param data The status data to set the bots status to.
113
- * @returns Promise<void>
114
- */
115
- editBotStatus(data: StatusUpdate): Promise<void>;
116
- /**
117
- * Edits the bot's status on one shard.
118
- *
119
- * @param shardId The shard id to edit the status for.
120
- * @param data The status data to set the bots status to.
121
- * @returns Promise<void>
122
- */
123
- editShardStatus(data: StatusUpdate): Promise<void>;
124
- /**
125
- * Fetches the list of members for a guild over the gateway.
126
- *
127
- * @param guildId - The ID of the guild to get the list of members for.
128
- * @param options - The parameters for the fetching of the members.
129
- *
130
- * @remarks
131
- * If requesting the entire member list:
132
- * - Requires the `GUILD_MEMBERS` intent.
133
- *
134
- * If requesting presences ({@link RequestGuildMembers.presences | presences} set to `true`):
135
- * - Requires the `GUILD_PRESENCES` intent.
136
- *
137
- * If requesting a prefix ({@link RequestGuildMembers.query | query} non-`undefined`):
138
- * - Returns a maximum of 100 members.
139
- *
140
- * If requesting a users by ID ({@link RequestGuildMembers.userIds | userIds} non-`undefined`):
141
- * - Returns a maximum of 100 members.
142
- *
143
- * Fires a _Guild Members Chunk_ gateway event for every 1000 members fetched.
144
- *
145
- * @see {@link https://discord.com/developers/docs/topics/gateway#request-guild-members}
146
- */
147
- requestMembers(guildId: BigString, options?: Omit<RequestGuildMembers, 'guildId'>): Promise<Camelize<DiscordMember[]>>;
148
- /**
149
- * Leaves the voice channel the bot user is currently in.
150
- *
151
- * This function sends the _Update Voice State_ gateway command over the gateway behind the scenes.
152
- *
153
- * @param guildId - The ID of the guild the voice channel to leave is in.
154
- *
155
- * @remarks
156
- * Fires a _Voice State Update_ gateway event.
157
- *
158
- * @see {@link https://discord.com/developers/docs/topics/gateway#update-voice-state}
159
- */
160
- leaveVoiceChannel(guildId: BigString): Promise<void>;
161
82
  }
162
83
  export interface ShardCreateOptions {
163
84
  /** The shard id */
@@ -166,6 +87,8 @@ export interface ShardCreateOptions {
166
87
  connection: ShardGatewayConfig;
167
88
  /** The event handlers for events on the shard. */
168
89
  events: ShardEvents;
90
+ /** The logger for the shard */
91
+ logger?: Pick<typeof logger, 'debug' | 'info' | 'warn' | 'error' | 'fatal'>;
169
92
  /** The handler to request a space to make an identify request. */
170
93
  requestIdentify?: () => Promise<void>;
171
94
  /** The handler to alert the gateway manager that this shard has received a READY event. */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Shard.d.ts","sourceRoot":"","sources":["../../src/Shard.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAA8B,MAAM,mBAAmB,CAAA;AAE1F,OAAO,EAAE,WAAW,EAAmB,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAExE,OAAO,aAAa,MAAM,IAAI,CAAA;AAC9B,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,kBAAkB,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAClH,OAAO,EAAyB,UAAU,EAAE,MAAM,YAAY,CAAA;AAI9D,qBAAa,eAAe;IAC1B,0BAA0B;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,qFAAqF;IACrF,UAAU,EAAE,kBAAkB,CAAA;IAC9B,kDAAkD;IAClD,KAAK,EAAE,UAAU,CAAA;IACjB,4HAA4H;IAC5H,2BAA2B,EAAE,MAAM,CAAM;IACzC,4CAA4C;IAC5C,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAO;IAC5C,8EAA8E;IAC9E,sBAAsB,EAAE,MAAM,CAAQ;IACtC,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,iFAAiF;IACjF,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB,0CAA0C;IAC1C,KAAK,aAAqB;IAC1B,mFAAmF;IACnF,gBAAgB,EAAE,MAAM,CAAK;IAC7B,wCAAwC;IACxC,M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G,OAAO,CAAC,IAAI,CAAC;IAsIvE,YAAY,CAAC,MAAM,EAAE,qBAAqB,GAAG,IAAI;IAMjD,0CAA0C;IACpC,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAevE;;;;OAIG;IACG,YAAY,IAAI,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAK1D,uNAAuN;IACjN,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAEtC,+GAA+G;IACzG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAEnC,4EAA4E;IAC5E,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IA4EzC,kDAAkD;IAClD,gBAAgB,IAAI,IAAI;CAOzB;AAED,MAAM,WAAW,kBAAkB;IACjC,mBAAmB;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,6BAA6B;IAC7B,UAAU,EAAE,kBAAkB,CAAA;IAC9B,kDAAkD;IAClD,MAAM,EAAE,WAAW,CAAA;IACnB,+BAA+B;IAC/B,MAAM,CAAC,EAAE,IAAI,CAAC,OAAO,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,CAAA;IAC3E,kEAAkE;IAClE,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IACrC,2FAA2F;IAC3F,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CACnC;AAED,eAAe,eAAe,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA"}
@@ -1,7 +1,7 @@
1
- import type { AtLeastOne, BigString, Camelize, DiscordGetGatewayBot, DiscordMember, RequestGuildMembers } from '@discordeno/types';
2
- import { Collection } from '@discordeno/utils';
1
+ import { type AtLeastOne, type BigString, type Camelize, type DiscordGetGatewayBot, type DiscordMemberWithUser, type RequestGuildMembers } from '@discordeno/types';
2
+ import { Collection, logger } from '@discordeno/utils';
3
3
  import Shard from './Shard.js';
4
- import type { ShardEvents, StatusUpdate, UpdateVoiceState } from './types.js';
4
+ import type { ShardEvents, ShardSocketRequest, StatusUpdate, UpdateVoiceState } from './types.js';
5
5
  export declare function createGatewayManager(options: CreateGatewayManagerOptions): GatewayManager;
6
6
  export interface CreateGatewayManagerOptions {
7
7
  /**
@@ -82,7 +82,7 @@ export interface CreateGatewayManagerOptions {
82
82
  */
83
83
  version?: number;
84
84
  /** The events handlers */
85
- events: ShardEvents;
85
+ events?: ShardEvents;
86
86
  /** This managers cache related settings. */
87
87
  cache?: {
88
88
  requestMembers?: {
@@ -91,10 +91,13 @@ export interface CreateGatewayManagerOptions {
91
91
  * @default false
92
92
  */
93
93
  enabled?: boolean;
94
- /** The pending requests. */
95
- pending: Collection<string, RequestMemberRequest>;
96
94
  };
97
95
  };
96
+ /**
97
+ * The logger that the gateway manager will use
98
+ * @default logger // The logger exported by `@discordeno/utils`
99
+ */
100
+ logger?: Pick<typeof logger, 'debug' | 'info' | 'warn' | 'error' | 'fatal'>;
98
101
  }
99
102
  export interface GatewayManager extends Required<CreateGatewayManagerOptions> {
100
103
  /** The max concurrency buckets. Those will be created when the `spawnShards` (which calls `prepareBuckets` under the hood) function gets called. */
@@ -108,6 +111,8 @@ export interface GatewayManager extends Required<CreateGatewayManagerOptions> {
108
111
  }>;
109
112
  /** The shards that are created. */
110
113
  shards: Map<number, Shard>;
114
+ /** The logger for the gateway manager */
115
+ logger: Pick<typeof logger, 'debug' | 'info' | 'warn' | 'error' | 'fatal'>;
111
116
  /** Determine max number of shards to use based upon the max concurrency. */
112
117
  calculateTotalShards: () => number;
113
118
  /** Determine the id of the worker which is handling a shard. */
@@ -118,6 +123,7 @@ export interface GatewayManager extends Required<CreateGatewayManagerOptions> {
118
123
  spawnShards: () => Promise<void>;
119
124
  /** Shutdown all shards. */
120
125
  shutdown: (code: number, reason: string) => Promise<void>;
126
+ sendPayload: (shardId: number, payload: ShardSocketRequest) => Promise<void>;
121
127
  /** Allows users to hook in and change to communicate to different workers across different servers or anything they like. For example using redis pubsub to talk to other servers. */
122
128
  tellWorkerToIdentify: (workerId: number, shardId: number, bucketId: number) => Promise<void>;
123
129
  /** Tell the manager to identify a Shard. If this Shard is not already managed this will also add the Shard to the manager. */
@@ -182,7 +188,7 @@ export interface GatewayManager extends Required<CreateGatewayManagerOptions> {
182
188
  *
183
189
  * @see {@link https://discord.com/developers/docs/topics/gateway#request-guild-members}
184
190
  */
185
- requestMembers: (guildId: BigString, options?: Omit<RequestGuildMembers, 'guildId'>) => Promise<Camelize<DiscordMember[]>>;
191
+ requestMembers: (guildId: BigString, options?: Omit<RequestGuildMembers, 'guildId'>) => Promise<Camelize<DiscordMemberWithUser[]>>;
186
192
  /**
187
193
  * Leaves the voice channel the bot user is currently in.
188
194
  *
@@ -196,13 +202,25 @@ export interface GatewayManager extends Required<CreateGatewayManagerOptions> {
196
202
  * @see {@link https://discord.com/developers/docs/topics/gateway#update-voice-state}
197
203
  */
198
204
  leaveVoiceChannel: (guildId: BigString) => Promise<void>;
205
+ /** This managers cache related settings. */
206
+ cache: {
207
+ requestMembers: {
208
+ /**
209
+ * Whether or not request member requests should be cached.
210
+ * @default false
211
+ */
212
+ enabled: boolean;
213
+ /** The pending requests. */
214
+ pending: Collection<string, RequestMemberRequest>;
215
+ };
216
+ };
199
217
  }
200
218
  export interface RequestMemberRequest {
201
219
  /** The unique nonce for this request. */
202
220
  nonce: string;
203
221
  /** The resolver handler to run when all members arrive. */
204
- resolve: (value: Camelize<DiscordMember[]> | PromiseLike<Camelize<DiscordMember[]>>) => void;
222
+ resolve: (value: Camelize<DiscordMemberWithUser[]> | PromiseLike<Camelize<DiscordMemberWithUser[]>>) => void;
205
223
  /** The members that have already arrived for this request. */
206
- members: Camelize<DiscordMember[]>;
224
+ members: DiscordMemberWithUser[];
207
225
  }
208
226
  //# sourceMappingURL=manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/manager.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACzB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,UAAU,EAAS,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC7D,OAAO,KAAK,MAAM,YAAY,CAAA;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAEjG,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,cAAc,CA6UzF;AAED,MAAM,WAAW,2BAA2B;IAC1C;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,oFAAoF;IACpF,UAAU,CAAC,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAA;IAC3C;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,iCAAiC;IACjC,UAAU,CAAC,EAAE;QACX;;;WAGG;QACH,EAAE,EAAE,MAAM,CAAA;QACV;;;WAGG;QACH,OAAO,EAAE,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H,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACvE;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,cAAc,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,SAAS,CAAC,KAAK,OAAO,CAAC,QAAQ,CAAC,qBAAqB,EAAE,CAAC,CAAC,CAAA;IAClI;;;;;;;;;;;OAWG;IACH,iBAAiB,EAAE,CAAC,OAAO,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACxD,4CAA4C;IAC5C,KAAK,EAAE;QACL,cAAc,EAAE;YACd;;;eAGG;YACH,OAAO,EAAE,OAAO,CAAA;YAChB,4BAA4B;YAC5B,OAAO,EAAE,UAAU,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;SAClD,CAAA;KACF,CAAA;CACF;AAED,MAAM,WAAW,oBAAoB;IACnC,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAA;IACb,2DAA2D;IAC3D,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,qBAAqB,EAAE,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,qBAAqB,EAAE,CAAC,CAAC,KAAK,IAAI,CAAA;IAC5G,8DAA8D;IAC9D,OAAO,EAAE,qBAAqB,EAAE,CAAA;CACjC"}
@@ -70,7 +70,7 @@ export interface ShardHeart {
70
70
  /** Interval between heartbeats requested by Discord. */
71
71
  interval: number;
72
72
  /** Id of the interval, which is used for sending the heartbeats. */
73
- intervalId?: NodeJS.Timer;
73
+ intervalId?: NodeJS.Timeout;
74
74
  /** Unix (in milliseconds) timestamp when the last heartbeat ACK was received from Discord. */
75
75
  lastAck?: number;
76
76
  /** Unix timestamp (in milliseconds) when the last heartbeat was sent. */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../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cb",
4
- "main": "./dist/index.js",
5
- "types": "./dist/index.d.ts",
3
+ "version": "19.0.0-next.fda3003",
4
+ "main": "./dist/esm/index.js",
5
+ "exports": {
6
+ "import": "./dist/esm/index.js",
7
+ "require": "./dist/cjs/index.cjs",
8
+ "types": "./dist/types/index.d.ts"
9
+ },
10
+ "types": "./dist/types/index.d.ts",
6
11
  "type": "module",
7
12
  "license": "Apache-2.0",
8
13
  "repository": {
@@ -10,41 +15,41 @@
10
15
  "url": "https://github.com/discordeno/discordeno.git"
11
16
  },
12
17
  "scripts": {
13
- "build": "swc --delete-dir-on-start src --out-dir dist",
14
- "build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist",
18
+ "build": "swc src --strip-leading-paths --delete-dir-on-start src --out-dir dist/esm && swc --strip-leading-paths --delete-dir-on-start src --out-dir dist/cjs -C module.type=commonjs && node ../../scripts/fixCjsExtension.js",
19
+ "build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist/types",
15
20
  "release-build": "yarn build && yarn build:type",
16
21
  "fmt": "eslint --fix \"src/**/*.ts*\"",
17
22
  "lint": "eslint \"src/**/*.ts*\"",
18
23
  "test:unit-coverage": "c8 mocha --no-warnings 'tests/unit/**/*.spec.ts'",
19
24
  "test:unit": "c8 --r lcov mocha --no-warnings 'tests/unit/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js gateway",
20
- "test:deno-unit": "swc tests --delete-dir-on-start --out-dir denoTestsDist && node ../../scripts/fixDenoTestExtension.js && deno test -A --import-map ../../denoImportMap.json denoTestsDist/unit",
25
+ "test:deno-unit": "swc --strip-leading-paths tests --delete-dir-on-start --out-dir denoTestsDist && node ../../scripts/fixDenoTestExtension.js && deno test -A --import-map ../../denoImportMap.json denoTestsDist/unit",
21
26
  "test:unit:watch": "mocha --no-warnings --watch --parallel 'tests/unit/**/*.spec.ts'",
22
27
  "test:integration": "c8 --r lcov mocha --no-warnings 'tests/integration/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js gateway",
23
28
  "test:type": "tsc --noEmit",
24
29
  "test:test-type": "tsc --project tsconfig.test.json"
25
30
  },
26
31
  "dependencies": {
27
- "@discordeno/types": "19.0.0-next.fd518cb",
28
- "@discordeno/utils": "19.0.0-next.fd518cb",
29
- "ws": "^8.13.0"
32
+ "@discordeno/types": "19.0.0-next.fda3003",
33
+ "@discordeno/utils": "19.0.0-next.fda3003",
34
+ "ws": "^8.18.0"
30
35
  },
31
36
  "devDependencies": {
32
- "@swc/cli": "^0.1.62",
33
- "@swc/core": "^1.3.40",
34
- "@types/chai": "^4.3.4",
35
- "@types/mocha": "^10.0.1",
36
- "@types/node": "^18.15.3",
37
- "@types/sinon": "^10.0.13",
38
- "@types/ws": "^8.5.4",
39
- "c8": "^7.13.0",
40
- "chai": "^4.3.7",
41
- "eslint": "^8.36.0",
37
+ "@swc/cli": "^0.3.9",
38
+ "@swc/core": "^1.4.2",
39
+ "@types/chai": "^4.3.11",
40
+ "@types/mocha": "^10.0.7",
41
+ "@types/node": "^20.11.25",
42
+ "@types/sinon": "^17.0.3",
43
+ "@types/ws": "^8.5.10",
44
+ "c8": "^9.1.0",
45
+ "chai": "^5.0.3",
46
+ "eslint": "^8.57.0",
42
47
  "eslint-config-discordeno": "*",
43
- "mocha": "^10.2.0",
44
- "sinon": "^15.0.2",
45
- "ts-node": "^10.9.1",
48
+ "mocha": "^10.5.1",
49
+ "sinon": "^17.0.1",
50
+ "ts-node": "^10.9.2",
46
51
  "tsconfig": "*",
47
- "typescript": "^4.9.5",
52
+ "typescript": "5.4.5",
48
53
  "uWebSockets.js": "https://github.com/uNetworking/uWebSockets.js.git#commit=42c9c0d5d31f46ca4115dc75672b0037ec970f28"
49
54
  }
50
55
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"Shard.d.ts","sourceRoot":"","sources":["../src/Shard.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,QAAQ,EACR,qBAAqB,EAErB,aAAa,EAEb,mBAAmB,EAC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