mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 10:03:31 +01:00
refactor: native zlib support (#10243)
* refactor: remove zlib-sync * fix: bad length check * refactor: support both options BREAKING CHANGE: renamed compression related options * chore: fix doc comment * chore: update debug messages * chore: better wording Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> * chore: suggested changes * chore: better naming * refactor: lazy node:zlib import and lib detection * chore: zlib capitalization * fix: use proper var * refactor: better inflate check Co-authored-by: Aura <kyradiscord@gmail.com> * chore: debug label Co-authored-by: Superchupu <53496941+SuperchupuDev@users.noreply.github.com> --------- Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: Aura <kyradiscord@gmail.com> Co-authored-by: Superchupu <53496941+SuperchupuDev@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -18,13 +18,19 @@ export enum Encoding {
|
||||
* Valid compression methods
|
||||
*/
|
||||
export enum CompressionMethod {
|
||||
ZlibStream = 'zlib-stream',
|
||||
ZlibNative,
|
||||
ZlibSync,
|
||||
}
|
||||
|
||||
export const DefaultDeviceProperty = `@discordjs/ws [VI]{{inject}}[/VI]` as `@discordjs/ws ${string}`;
|
||||
|
||||
const getDefaultSessionStore = lazy(() => new Collection<number, SessionInfo | null>());
|
||||
|
||||
export const CompressionParameterMap = {
|
||||
[CompressionMethod.ZlibNative]: 'zlib-stream',
|
||||
[CompressionMethod.ZlibSync]: 'zlib-stream',
|
||||
} as const satisfies Record<CompressionMethod, string>;
|
||||
|
||||
/**
|
||||
* Default options used by the manager
|
||||
*/
|
||||
@@ -46,6 +52,7 @@ export const DefaultWebSocketManagerOptions = {
|
||||
version: APIVersion,
|
||||
encoding: Encoding.JSON,
|
||||
compression: null,
|
||||
useIdentifyCompression: false,
|
||||
retrieveSessionInfo(shardId) {
|
||||
const store = getDefaultSessionStore();
|
||||
return store.get(shardId) ?? null;
|
||||
|
||||
Reference in New Issue
Block a user