@discordeno/gateway 22.0.1-next.4d5acdb → 22.0.1-next.4db65e0
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/Shard.d.ts +42 -14
- package/dist/Shard.d.ts.map +1 -1
- package/dist/Shard.js +180 -143
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/manager.d.ts +15 -5
- package/dist/manager.d.ts.map +1 -1
- package/dist/manager.js +51 -23
- package/dist/types.d.ts +13 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -3
- package/package.json +29 -28
package/dist/Shard.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import zlib from 'node:zlib';
|
|
1
|
+
import { type Inflate, type ZstdDecompress } from 'node:zlib';
|
|
3
2
|
import type { DiscordGatewayPayload, DiscordUpdatePresence } from '@discordeno/types';
|
|
4
3
|
import { LeakyBucket, logger } from '@discordeno/utils';
|
|
5
|
-
import type { Decompress as FZstdDecompress } from 'fzstd';
|
|
6
4
|
import { type ShardEvents, type ShardGatewayConfig, type ShardHeart, type ShardSocketRequest, ShardState } from './types.js';
|
|
7
5
|
export declare class DiscordenoShard {
|
|
8
6
|
/** The id of the shard. */
|
|
@@ -47,21 +45,24 @@ export declare class DiscordenoShard {
|
|
|
47
45
|
goingOffline: boolean;
|
|
48
46
|
/** Text decoder used for compressed payloads. */
|
|
49
47
|
textDecoder: TextDecoder;
|
|
50
|
-
/** zlib Inflate or zstd decompress
|
|
51
|
-
inflate?:
|
|
52
|
-
/**
|
|
48
|
+
/** zlib Inflate or zstd decompress instance for transport payloads. */
|
|
49
|
+
inflate?: Inflate | ZstdDecompress;
|
|
50
|
+
/** zlib inflate/zstd buffer. */
|
|
53
51
|
inflateBuffer: Uint8Array | null;
|
|
54
|
-
/** ZStd Decompress instance for ZStd-stream transport payloads. */
|
|
55
|
-
zstdDecompress?: FZstdDecompress;
|
|
56
|
-
/** Queue for compressed payloads for Zstd Decompress */
|
|
57
|
-
decompressionPromisesQueue: ((data: DiscordGatewayPayload) => void)[];
|
|
58
52
|
/**
|
|
59
|
-
* A function that will be called once the socket is closed and
|
|
53
|
+
* A function that will be called once the socket is closed and the internal states have been updated.
|
|
60
54
|
*
|
|
61
55
|
* @private
|
|
62
56
|
* This is for internal purposes only, and subject to breaking changes.
|
|
63
57
|
*/
|
|
64
|
-
resolveAfterClose?: (
|
|
58
|
+
resolveAfterClose?: () => void;
|
|
59
|
+
/**
|
|
60
|
+
* A function that stops the connection attempts {@link connectWithRetries} is making, if there are any.
|
|
61
|
+
*
|
|
62
|
+
* @private
|
|
63
|
+
* This is for internal purposes only, and subject to breaking changes.
|
|
64
|
+
*/
|
|
65
|
+
cancelConnectRetries?: () => void;
|
|
65
66
|
constructor(options: ShardCreateOptions);
|
|
66
67
|
/** The gateway configuration which is used to connect to Discord. */
|
|
67
68
|
get gatewayConfig(): ShardGatewayConfig;
|
|
@@ -79,6 +80,20 @@ export declare class DiscordenoShard {
|
|
|
79
80
|
* @param bypassRequest - Whether to bypass the requestIdentify handler and identify immediately. This should be used carefully as it can cause invalid sessions.
|
|
80
81
|
*/
|
|
81
82
|
identify(bypassRequest?: boolean): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Connect the shard with the gateway, trying again with an exponential backoff for as long as the opening handshake fails.
|
|
85
|
+
*
|
|
86
|
+
* @param options.waitForTurn - Awaited before every attempt, for example to wait until the shard is allowed to identify.
|
|
87
|
+
* @param options.beforeAttempt - Called right before every attempt, unless the shard has been asked to close while waiting for its turn.
|
|
88
|
+
* @returns Whether the shard is connected. `false` when the shard has been asked to close before an attempt succeeded.
|
|
89
|
+
*
|
|
90
|
+
* @private
|
|
91
|
+
* This is for internal purposes only, and subject to breaking changes.
|
|
92
|
+
*/
|
|
93
|
+
connectWithRetries(options: {
|
|
94
|
+
waitForTurn?: () => Promise<void>;
|
|
95
|
+
beforeAttempt: () => void;
|
|
96
|
+
}): Promise<boolean>;
|
|
82
97
|
/** Check whether the connection to Discord is currently open. */
|
|
83
98
|
isOpen(): boolean;
|
|
84
99
|
/** Attempt to resume the previous shards session with the gateway. */
|
|
@@ -90,18 +105,31 @@ export declare class DiscordenoShard {
|
|
|
90
105
|
send(message: ShardSocketRequest, highPriority?: boolean): Promise<void>;
|
|
91
106
|
/** Shutdown the this. Forcefully disconnect the shard from Discord. The shard may not attempt to reconnect with Discord. */
|
|
92
107
|
shutdown(): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Put the shard offline after its opening handshake failed or was aborted.
|
|
110
|
+
*
|
|
111
|
+
* @remarks
|
|
112
|
+
* Runtimes report a socket which never opened differently: Node 22 fires only an error, and a handshake aborted by {@link close} reports a close
|
|
113
|
+
* event first on Node 24. This is therefore called from whichever of the two arrives first, instead of {@link handleClose}. There is no session
|
|
114
|
+
* and no heartbeat to clean up at this point, and no reconnect is attempted here: {@link connect} rejects, and {@link identify} and
|
|
115
|
+
* {@link resume} try again through {@link connectWithRetries}.
|
|
116
|
+
*
|
|
117
|
+
* @private
|
|
118
|
+
* This is for internal purposes only, and subject to breaking changes.
|
|
119
|
+
*/
|
|
120
|
+
handleFailedHandshake(): void;
|
|
93
121
|
/** Handle a gateway connection error */
|
|
94
122
|
handleError(error: Event): void;
|
|
95
123
|
/** Handle a gateway connection close. */
|
|
96
124
|
handleClose(close: CloseEvent): Promise<void>;
|
|
97
125
|
/** Handle an incoming gateway message. */
|
|
98
|
-
handleMessage(message: MessageEvent): Promise<void>;
|
|
126
|
+
handleMessage(message: MessageEvent<ArrayBuffer | string>): Promise<void>;
|
|
99
127
|
/**
|
|
100
128
|
* Decompress a zlib/zstd compressed packet
|
|
101
129
|
*
|
|
102
130
|
* @private
|
|
103
131
|
*/
|
|
104
|
-
decompressPacket(data: ArrayBuffer
|
|
132
|
+
decompressPacket(data: ArrayBuffer): Promise<string | null>;
|
|
105
133
|
/** Handles a incoming gateway packet. */
|
|
106
134
|
handleDiscordPacket(packet: DiscordGatewayPayload): Promise<void>;
|
|
107
135
|
/**
|
package/dist/Shard.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Shard.d.ts","sourceRoot":"","sources":["../src/Shard.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Shard.d.ts","sourceRoot":"","sources":["../src/Shard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,KAAK,OAAO,EAAe,KAAK,cAAc,EAA8B,MAAM,WAAW,CAAC;AAC5I,OAAO,KAAK,EAAE,qBAAqB,EAA8B,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAElH,OAAO,EAAS,WAAW,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,UAAU,EAEf,KAAK,kBAAkB,EACvB,UAAU,EAEX,MAAM,YAAY,CAAC;AAOpB,qBAAa,eAAe;IAC1B,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,qFAAqF;IACrF,UAAU,EAAE,kBAAkB,CAAC;IAC/B,kDAAkD;IAClD,KAAK,EAAE,UAAU,CAAC;IAClB,4HAA4H;IAC5H,2BAA2B,EAAE,MAAM,CAAO;IAC1C,4CAA4C;IAC5C,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC7C,8EAA8E;IAC9E,sBAAsB,EAAE,MAAM,CAAS;IACvC,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iFAAiF;IACjF,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,0CAA0C;IAC1C,KAAK,aAAsB;IAC3B,mFAAmF;IACnF,gBAAgB,EAAE,MAAM,CAAM;IAC9B,wCAAwC;IACxC,MAAM,EAAE,WAAW,CAAM;IACzB,qGAAqG;IACrG,gBAAgB,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,CAAM;IAC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