mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
add brotli and zstd to CompressionStream and DecompressionStream types (#25374)
### What does this PR do? - removes the `Unimplemented in Bun` comment on `CompressionStream` and `DecompressionStream` - updates the types for `CompressionStream` and `DecompressionStream` to add a new internal `CompressionFormat` type to the constructor, which adds `brotli` and `zstd` to the union - adds tests for brotli and zstd usage - adds lib.dom.d.ts exclusions for brotli and zstd as these don't exist in the DOM version of CompressionFormat fixes #25367 ### How did you verify your code works? typechecks and tests
This commit is contained in:
3
packages/bun-types/bun.d.ts
vendored
3
packages/bun-types/bun.d.ts
vendored
@@ -3887,6 +3887,9 @@ declare module "bun" {
|
||||
static readonly byteLength: 32;
|
||||
}
|
||||
|
||||
/** Extends the standard web formats with `brotli` and `zstd` support. */
|
||||
type CompressionFormat = "gzip" | "deflate" | "deflate-raw" | "brotli" | "zstd";
|
||||
|
||||
/** Compression options for `Bun.deflateSync` and `Bun.gzipSync` */
|
||||
interface ZlibCompressionOptions {
|
||||
/**
|
||||
|
||||
42
packages/bun-types/globals.d.ts
vendored
42
packages/bun-types/globals.d.ts
vendored
@@ -83,6 +83,24 @@ declare var WritableStream: Bun.__internal.UseLibDomIfAvailable<
|
||||
}
|
||||
>;
|
||||
|
||||
interface CompressionStream extends Bun.__internal.LibEmptyOrNodeStreamWebCompressionStream {}
|
||||
declare var CompressionStream: Bun.__internal.UseLibDomIfAvailable<
|
||||
"CompressionStream",
|
||||
{
|
||||
prototype: CompressionStream;
|
||||
new (format: Bun.CompressionFormat): CompressionStream;
|
||||
}
|
||||
>;
|
||||
|
||||
interface DecompressionStream extends Bun.__internal.LibEmptyOrNodeStreamWebDecompressionStream {}
|
||||
declare var DecompressionStream: Bun.__internal.UseLibDomIfAvailable<
|
||||
"DecompressionStream",
|
||||
{
|
||||
prototype: DecompressionStream;
|
||||
new (format: Bun.CompressionFormat): DecompressionStream;
|
||||
}
|
||||
>;
|
||||
|
||||
interface Worker extends Bun.__internal.LibWorkerOrBunWorker {}
|
||||
declare var Worker: Bun.__internal.UseLibDomIfAvailable<
|
||||
"Worker",
|
||||
@@ -278,30 +296,6 @@ declare var Event: {
|
||||
new (type: string, eventInitDict?: Bun.EventInit): Event;
|
||||
};
|
||||
|
||||
/**
|
||||
* Unimplemented in Bun
|
||||
*/
|
||||
interface CompressionStream extends Bun.__internal.LibEmptyOrNodeStreamWebCompressionStream {}
|
||||
/**
|
||||
* Unimplemented in Bun
|
||||
*/
|
||||
declare var CompressionStream: Bun.__internal.UseLibDomIfAvailable<
|
||||
"CompressionStream",
|
||||
typeof import("node:stream/web").CompressionStream
|
||||
>;
|
||||
|
||||
/**
|
||||
* Unimplemented in Bun
|
||||
*/
|
||||
interface DecompressionStream extends Bun.__internal.LibEmptyOrNodeStreamWebCompressionStream {}
|
||||
/**
|
||||
* Unimplemented in Bun
|
||||
*/
|
||||
declare var DecompressionStream: Bun.__internal.UseLibDomIfAvailable<
|
||||
"DecompressionStream",
|
||||
typeof import("node:stream/web").DecompressionStream
|
||||
>;
|
||||
|
||||
interface EventTarget {
|
||||
/**
|
||||
* Adds a new handler for the `type` event. Any given `listener` is added only once per `type` and per `capture` option value.
|
||||
|
||||
Reference in New Issue
Block a user