@discordjs/ws 3.0.0-pr-11006.1765452229-e636950b2 → 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/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.1_@microsoft+api-extractor@7.55.2_@types+node@22.19.1__jiti@2.6.1_postcss@8.5._fc13ebfd5f92c667b15f2cc793b0626e/node_modules/tsup/assets/esm_shims.js
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");
@@ -474,13 +474,15 @@ var Encoding = /* @__PURE__ */ ((Encoding2) => {
474
474
  var CompressionMethod = /* @__PURE__ */ ((CompressionMethod2) => {
475
475
  CompressionMethod2[CompressionMethod2["ZlibNative"] = 0] = "ZlibNative";
476
476
  CompressionMethod2[CompressionMethod2["ZlibSync"] = 1] = "ZlibSync";
477
+ CompressionMethod2[CompressionMethod2["ZstdNative"] = 2] = "ZstdNative";
477
478
  return CompressionMethod2;
478
479
  })(CompressionMethod || {});
479
- var DefaultDeviceProperty = `@discordjs/ws 3.0.0-pr-11006.1765452229-e636950b2`;
480
+ var DefaultDeviceProperty = `@discordjs/ws 3.0.0-pr-10758.1765463096-d081e1706`;
480
481
  var getDefaultSessionStore = lazy(() => new Collection4());
481
482
  var CompressionParameterMap = {
482
483
  [0 /* ZlibNative */]: "zlib-stream",
483
- [1 /* ZlibSync */]: "zlib-stream"
484
+ [1 /* ZlibSync */]: "zlib-stream",
485
+ [2 /* ZstdNative */]: "zstd-stream"
484
486
  };
485
487
  var DefaultWebSocketManagerOptions = {
486
488
  async buildIdentifyThrottler(manager) {
@@ -657,7 +659,7 @@ var WebSocketShard = class extends AsyncEventEmitter {
657
659
  });
658
660
  this.nativeInflate = inflate;
659
661
  } else {
660
- 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.");
661
663
  params.delete("compress");
662
664
  }
663
665
  break;
@@ -675,6 +677,28 @@ var WebSocketShard = class extends AsyncEventEmitter {
675
677
  }
676
678
  break;
677
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
+ }
678
702
  }
679
703
  }
680
704
  if (this.identifyCompressionEnabled) {
@@ -957,7 +981,7 @@ var WebSocketShard = class extends AsyncEventEmitter {
957
981
  });
958
982
  }
959
983
  if (this.transportCompressionEnabled) {
960
- 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;
961
985
  if (this.nativeInflate) {
962
986
  const doneWriting = new Promise((resolve2) => {
963
987
  this.nativeInflate.write(decompressable, "binary", (error) => {
@@ -1445,7 +1469,6 @@ var WebSocketManager = class extends AsyncEventEmitter2 {
1445
1469
  if (typeof options.fetchGatewayInformation !== "function") {
1446
1470
  throw new TypeError("fetchGatewayInformation is required");
1447
1471
  }
1448
- console.log("woah. new. NEW! NEW!!!!!!! \u203C\uFE0F \u{1F5E3}\uFE0F \u{1F525}");
1449
1472
  super();
1450
1473
  this.options = {
1451
1474
  ...DefaultWebSocketManagerOptions,
@@ -1548,7 +1571,7 @@ var WebSocketManager = class extends AsyncEventEmitter2 {
1548
1571
  };
1549
1572
 
1550
1573
  // src/index.ts
1551
- var version = "3.0.0-pr-11006.1765452229-e636950b2";
1574
+ var version = "3.0.0-pr-10758.1765463096-d081e1706";
1552
1575
  export {
1553
1576
  CloseCodes,
1554
1577
  CompressionMethod,