@discordjs/ws 3.0.0-pr-11005.1765454364-f3f6d34e7 → 3.0.0-pr-10758.1765463096-d081e1706
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/defaultWorker.js +33 -12
- package/dist/defaultWorker.js.map +1 -1
- package/dist/defaultWorker.mjs +27 -6
- package/dist/defaultWorker.mjs.map +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +35 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
7
7
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
-
// ../../node_modules/.pnpm/tsup@8.5.
|
|
10
|
+
// ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.55.2_@types+node@22.19.2__jiti@2.6.1_postcss@8.5._f366b06a2b111551fa9c30aa00a19284/node_modules/tsup/assets/esm_shims.js
|
|
11
11
|
import path from "path";
|
|
12
12
|
import { fileURLToPath } from "url";
|
|
13
13
|
var getFilename = /* @__PURE__ */ __name(() => fileURLToPath(import.meta.url), "getFilename");
|
|
@@ -413,10 +413,7 @@ import { Collection as Collection6 } from "@discordjs/collection";
|
|
|
413
413
|
// src/ws/WebSocketShard.ts
|
|
414
414
|
import { Buffer as Buffer2 } from "buffer";
|
|
415
415
|
import { once as once2 } from "events";
|
|
416
|
-
import { clearInterval, clearTimeout, setInterval, setTimeout } from "timers";
|
|
417
416
|
import { setTimeout as sleep2 } from "timers/promises";
|
|
418
|
-
import { URLSearchParams } from "url";
|
|
419
|
-
import { TextDecoder } from "util";
|
|
420
417
|
import { Collection as Collection5 } from "@discordjs/collection";
|
|
421
418
|
import { lazy as lazy2, shouldUseGlobalFetchAndWebSocket } from "@discordjs/util";
|
|
422
419
|
import { AsyncQueue as AsyncQueue2 } from "@sapphire/async-queue";
|
|
@@ -477,13 +474,15 @@ var Encoding = /* @__PURE__ */ ((Encoding2) => {
|
|
|
477
474
|
var CompressionMethod = /* @__PURE__ */ ((CompressionMethod2) => {
|
|
478
475
|
CompressionMethod2[CompressionMethod2["ZlibNative"] = 0] = "ZlibNative";
|
|
479
476
|
CompressionMethod2[CompressionMethod2["ZlibSync"] = 1] = "ZlibSync";
|
|
477
|
+
CompressionMethod2[CompressionMethod2["ZstdNative"] = 2] = "ZstdNative";
|
|
480
478
|
return CompressionMethod2;
|
|
481
479
|
})(CompressionMethod || {});
|
|
482
|
-
var DefaultDeviceProperty = `@discordjs/ws 3.0.0-pr-
|
|
480
|
+
var DefaultDeviceProperty = `@discordjs/ws 3.0.0-pr-10758.1765463096-d081e1706`;
|
|
483
481
|
var getDefaultSessionStore = lazy(() => new Collection4());
|
|
484
482
|
var CompressionParameterMap = {
|
|
485
483
|
[0 /* ZlibNative */]: "zlib-stream",
|
|
486
|
-
[1 /* ZlibSync */]: "zlib-stream"
|
|
484
|
+
[1 /* ZlibSync */]: "zlib-stream",
|
|
485
|
+
[2 /* ZstdNative */]: "zstd-stream"
|
|
487
486
|
};
|
|
488
487
|
var DefaultWebSocketManagerOptions = {
|
|
489
488
|
async buildIdentifyThrottler(manager) {
|
|
@@ -660,7 +659,7 @@ var WebSocketShard = class extends AsyncEventEmitter {
|
|
|
660
659
|
});
|
|
661
660
|
this.nativeInflate = inflate;
|
|
662
661
|
} else {
|
|
663
|
-
console.warn("WebSocketShard: Compression is set to native but node:zlib is not available.");
|
|
662
|
+
console.warn("WebSocketShard: Compression is set to native zlib but node:zlib is not available.");
|
|
664
663
|
params.delete("compress");
|
|
665
664
|
}
|
|
666
665
|
break;
|
|
@@ -678,6 +677,28 @@ var WebSocketShard = class extends AsyncEventEmitter {
|
|
|
678
677
|
}
|
|
679
678
|
break;
|
|
680
679
|
}
|
|
680
|
+
case 2 /* ZstdNative */: {
|
|
681
|
+
const zlib = await getNativeZlib();
|
|
682
|
+
if (zlib && "createZstdDecompress" in zlib) {
|
|
683
|
+
this.inflateBuffer = [];
|
|
684
|
+
const inflate = zlib.createZstdDecompress({
|
|
685
|
+
chunkSize: 65535
|
|
686
|
+
});
|
|
687
|
+
inflate.on("data", (chunk) => {
|
|
688
|
+
this.inflateBuffer.push(chunk);
|
|
689
|
+
});
|
|
690
|
+
inflate.on("error", (error) => {
|
|
691
|
+
this.emit("error" /* Error */, error);
|
|
692
|
+
});
|
|
693
|
+
this.nativeInflate = inflate;
|
|
694
|
+
} else {
|
|
695
|
+
console.warn(
|
|
696
|
+
"WebSocketShard: Compression is set to native zstd but node:zlib is not available or your node version does not support zstd decompression."
|
|
697
|
+
);
|
|
698
|
+
params.delete("compress");
|
|
699
|
+
}
|
|
700
|
+
break;
|
|
701
|
+
}
|
|
681
702
|
}
|
|
682
703
|
}
|
|
683
704
|
if (this.identifyCompressionEnabled) {
|
|
@@ -960,7 +981,7 @@ var WebSocketShard = class extends AsyncEventEmitter {
|
|
|
960
981
|
});
|
|
961
982
|
}
|
|
962
983
|
if (this.transportCompressionEnabled) {
|
|
963
|
-
const flush = decompressable.length >= 4 && decompressable.at(-4) === 0 && decompressable.at(-3) === 0 && decompressable.at(-2) === 255 && decompressable.at(-1) === 255;
|
|
984
|
+
const flush = this.strategy.options.compression === 2 /* ZstdNative */ || decompressable.length >= 4 && decompressable.at(-4) === 0 && decompressable.at(-3) === 0 && decompressable.at(-2) === 255 && decompressable.at(-1) === 255;
|
|
964
985
|
if (this.nativeInflate) {
|
|
965
986
|
const doneWriting = new Promise((resolve2) => {
|
|
966
987
|
this.nativeInflate.write(decompressable, "binary", (error) => {
|
|
@@ -1550,7 +1571,7 @@ var WebSocketManager = class extends AsyncEventEmitter2 {
|
|
|
1550
1571
|
};
|
|
1551
1572
|
|
|
1552
1573
|
// src/index.ts
|
|
1553
|
-
var version = "3.0.0-pr-
|
|
1574
|
+
var version = "3.0.0-pr-10758.1765463096-d081e1706";
|
|
1554
1575
|
export {
|
|
1555
1576
|
CloseCodes,
|
|
1556
1577
|
CompressionMethod,
|