bun-types-no-globals 1.3.13 → 1.3.14

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/lib/bun.d.ts CHANGED
@@ -4261,13 +4261,30 @@ declare module "bun" {
4261
4261
  };
4262
4262
  };
4263
4263
 
4264
+ type WebSocketOptionsCompression = {
4265
+ /**
4266
+ * Whether to offer the `permessage-deflate` extension in the WebSocket
4267
+ * upgrade request. Pass `false` to suppress the `Sec-WebSocket-Extensions`
4268
+ * header entirely — matching the `ws` package's `perMessageDeflate: false`
4269
+ * option.
4270
+ *
4271
+ * Defaults to `true` (the upgrade request advertises
4272
+ * `permessage-deflate; client_max_window_bits`). Any falsy value
4273
+ * (`false`, `null`, `0`, `""`, explicit `undefined`) disables the offer.
4274
+ *
4275
+ * @default true
4276
+ */
4277
+ perMessageDeflate?: boolean;
4278
+ };
4279
+
4264
4280
  /**
4265
4281
  * Constructor options for the `Bun.WebSocket` client
4266
4282
  */
4267
4283
  type WebSocketOptions = WebSocketOptionsProtocolsOrProtocol &
4268
4284
  WebSocketOptionsTLS &
4269
4285
  WebSocketOptionsHeaders &
4270
- WebSocketOptionsProxy;
4286
+ WebSocketOptionsProxy &
4287
+ WebSocketOptionsCompression;
4271
4288
 
4272
4289
  interface WebSocketEventMap {
4273
4290
  close: CloseEvent;
@@ -7161,8 +7178,13 @@ declare module "bun" {
7161
7178
 
7162
7179
  /**
7163
7180
  * Access extra file descriptors passed to the `stdio` option in the options object.
7181
+ *
7182
+ * Entries beyond index 2 are `number` for `"pipe"` slots and, on POSIX, for slots
7183
+ * where a raw file descriptor was supplied (the same fd is returned; it remains
7184
+ * owned by the caller and is never closed by the subprocess). Other slots —
7185
+ * including raw fds on Windows — are `null`.
7164
7186
  */
7165
- readonly stdio: [null, null, null, ...number[]];
7187
+ readonly stdio: [null, null, null, ...(number | null)[]];
7166
7188
 
7167
7189
  /**
7168
7190
  * This returns the same value as {@link Subprocess.stdout}
@@ -8141,6 +8163,250 @@ declare module "bun" {
8141
8163
  match(str: string): boolean;
8142
8164
  }
8143
8165
 
8166
+ namespace Image {
8167
+ /**
8168
+ * Stable `error.code` values set on rejections from `Bun.Image` terminals.
8169
+ * Branch on these instead of parsing the message.
8170
+ *
8171
+ * - `ERR_IMAGE_FORMAT_UNSUPPORTED` — the requested format isn't available
8172
+ * on this *machine* (HEIC/AVIF without the OS codec, TIFF on Linux).
8173
+ * Catch this to fall back to a portable format.
8174
+ * - `ERR_IMAGE_TOO_MANY_PIXELS` — header dimensions or resize output
8175
+ * exceed `maxPixels`, or a path-backed input is over the 256 MiB cap.
8176
+ * - `ERR_IMAGE_DECODE_FAILED` / `ERR_IMAGE_ENCODE_FAILED` — codec error.
8177
+ * - `ERR_IMAGE_UNKNOWN_FORMAT` — input bytes didn't match any sniffer.
8178
+ * - `ERR_INVALID_STATE` — the input ArrayBuffer was transferred between
8179
+ * construction and the terminal call.
8180
+ * - File-backed inputs surface the underlying syscall code (`ENOENT`,
8181
+ * `EACCES`, …) directly.
8182
+ */
8183
+ type ErrorCode =
8184
+ | "ERR_IMAGE_FORMAT_UNSUPPORTED"
8185
+ | "ERR_IMAGE_TOO_MANY_PIXELS"
8186
+ | "ERR_IMAGE_DECODE_FAILED"
8187
+ | "ERR_IMAGE_ENCODE_FAILED"
8188
+ | "ERR_IMAGE_UNKNOWN_FORMAT"
8189
+ | "ERR_INVALID_STATE";
8190
+
8191
+ /**
8192
+ * `bmp`/`tiff`/`gif` are decode-only — `metadata().format` may report them
8193
+ * but there are no `.bmp()`/`.tiff()`/`.gif()` encoder methods. `tiff`
8194
+ * decode rejects with `error.code === "ERR_IMAGE_FORMAT_UNSUPPORTED"` on Linux; `gif` decodes the first
8195
+ * frame everywhere.
8196
+ */
8197
+ type Format = "jpeg" | "png" | "webp" | "heic" | "avif" | "bmp" | "tiff" | "gif";
8198
+ type Filter =
8199
+ | "nearest"
8200
+ | "box"
8201
+ | "bilinear"
8202
+ | "linear" // alias for bilinear (Sharp)
8203
+ | "cubic"
8204
+ | "mitchell"
8205
+ | "lanczos2"
8206
+ | "lanczos3"
8207
+ | "mks2013"
8208
+ | "mks2021";
8209
+
8210
+ interface ConstructorOptions {
8211
+ /**
8212
+ * Reject inputs whose `width × height` exceeds this many pixels. The
8213
+ * check runs after the header is read but before any pixel buffer is
8214
+ * allocated, so a tiny file claiming a huge canvas is refused cheaply.
8215
+ * @default 268402689 // 0x3FFF * 0x3FFF, same as Sharp
8216
+ */
8217
+ maxPixels?: number;
8218
+ /**
8219
+ * Apply EXIF Orientation (JPEG) before any other operation.
8220
+ * @default true
8221
+ */
8222
+ autoOrient?: boolean;
8223
+ }
8224
+
8225
+ interface ResizeOptions {
8226
+ /** Resampling kernel. @default "lanczos3" */
8227
+ filter?: Filter;
8228
+ /**
8229
+ * `"fill"` stretches to exactly width×height. `"inside"` preserves
8230
+ * aspect ratio so the result fits *within* width×height.
8231
+ * @default "fill"
8232
+ */
8233
+ fit?: "fill" | "inside";
8234
+ /** Never upscale — if the source is already smaller, leave it. */
8235
+ withoutEnlargement?: boolean;
8236
+ }
8237
+
8238
+ interface ModulateOptions {
8239
+ /** Multiplier; `1` leaves brightness unchanged. */
8240
+ brightness?: number;
8241
+ /** `0` = greyscale, `1` = unchanged, `>1` = more saturated. */
8242
+ saturation?: number;
8243
+ }
8244
+
8245
+ interface Metadata {
8246
+ width: number;
8247
+ height: number;
8248
+ format: Format;
8249
+ }
8250
+ }
8251
+
8252
+ /**
8253
+ * Decode, transform and re-encode images. Ships JPEG, PNG and WebP via
8254
+ * statically-linked libjpeg-turbo / libspng / libwebp; resize and rotate
8255
+ * are SIMD kernels — no native module install, no `sharp`.
8256
+ *
8257
+ * The constructor and every chainable method only *record* settings; the
8258
+ * decode → transform → encode pipeline runs on a worker thread when a
8259
+ * terminal (`bytes`, `buffer`, `blob`, `toBase64`, `metadata`) is awaited.
8260
+ *
8261
+ * Chainables overwrite (calling `.resize()` twice keeps the second). Order
8262
+ * of execution is fixed regardless of call order:
8263
+ * `autoOrient → rotate → flip/flop → resize → modulate`.
8264
+ *
8265
+ * The source ICC colour profile (Display P3, Adobe RGB, Jpegli XYB, etc.)
8266
+ * is preserved through re-encode to JPEG, PNG, and WebP so non-sRGB
8267
+ * images don't shift colour.
8268
+ *
8269
+ * @example
8270
+ * ```ts
8271
+ * const thumb = await new Bun.Image("photo.jpg")
8272
+ * .resize(400, 400, { fit: "inside", withoutEnlargement: true })
8273
+ * .webp({ quality: 80 })
8274
+ * .bytes();
8275
+ * ```
8276
+ */
8277
+ export class Image {
8278
+ /**
8279
+ * Process-global pipeline backend.
8280
+ *
8281
+ * - `"system"` (default on macOS/Windows) — static codecs for
8282
+ * JPEG/PNG/WebP (same bytes as Linux), Accelerate/vImage for `lanczos3`
8283
+ * resize · rotate · flip on macOS, and ImageIO/WIC for HEIC/AVIF.
8284
+ * - `"bun"` — static codecs + Highway geometry only. Byte-identical to a
8285
+ * Linux build; HEIC/AVIF reject with `ERR_IMAGE_FORMAT_UNSUPPORTED`.
8286
+ *
8287
+ * Set before awaiting a pipeline; in-flight tasks read the value as of
8288
+ * when they were scheduled.
8289
+ */
8290
+ static backend: "system" | "bun";
8291
+
8292
+ /**
8293
+ * Read an image from the system clipboard.
8294
+ *
8295
+ * Returns a `Bun.Image` wrapping whatever container the clipboard holds
8296
+ * (PNG, TIFF, HEIC, JPEG, BMP, …); call {@link metadata}, {@link resize},
8297
+ * etc. as usual. `null` if no image is present.
8298
+ *
8299
+ * - **macOS**: NSPasteboard
8300
+ * - **Windows**: registered `"PNG"` / `CF_DIBV5` / `CF_DIB`
8301
+ * - **Linux**: always `null` (use `wl-paste`/`xclip` and pass the bytes
8302
+ * to `new Bun.Image(...)`)
8303
+ */
8304
+ static fromClipboard(): Image | null;
8305
+ /** Cheap probe — true if {@link fromClipboard} would return non-null. */
8306
+ static hasClipboardImage(): boolean;
8307
+ /**
8308
+ * Monotone counter that increments on every system-wide clipboard write.
8309
+ * Poll this and only call {@link hasClipboardImage} when it moves. `-1`
8310
+ * on Linux.
8311
+ */
8312
+ static clipboardChangeCount(): number;
8313
+
8314
+ constructor(input: string | ArrayBuffer | NodeJS.TypedArray | Blob, options?: Image.ConstructorOptions);
8315
+
8316
+ /** Set target dimensions. Omit `height` to keep the source aspect ratio. */
8317
+ resize(width: number, height?: number, options?: Image.ResizeOptions): this;
8318
+ /** Rotate by a multiple of 90°. */
8319
+ rotate(degrees: number): this;
8320
+ /** Mirror about the x-axis (vertical). */
8321
+ flip(): this;
8322
+ /** Mirror about the y-axis (horizontal). */
8323
+ flop(): this;
8324
+ /** Adjust brightness/saturation. */
8325
+ modulate(options: Image.ModulateOptions): this;
8326
+
8327
+ /** Set output format to JPEG. */
8328
+ jpeg(options?: {
8329
+ /** 1–100, default 80. */
8330
+ quality?: number;
8331
+ /** Emit a progressive (multi-scan) JPEG. Default `false`. */
8332
+ progressive?: boolean;
8333
+ }): this;
8334
+ /** Set output format to PNG. */
8335
+ png(options?: {
8336
+ /** zlib level 0–9. */
8337
+ compressionLevel?: number;
8338
+ /** Quantize to a palette and emit indexed (colour-type 3) PNG. */
8339
+ palette?: boolean;
8340
+ /** Max palette size when `palette: true`. 2–256. @default 256 */
8341
+ colors?: number;
8342
+ /** Floyd–Steinberg error-diffusion dither (only with `palette: true`). */
8343
+ dither?: boolean;
8344
+ }): this;
8345
+ /** Set output format to WebP. */
8346
+ webp(options?: { quality?: number; lossless?: boolean }): this;
8347
+ /**
8348
+ * Set output format to HEIC. macOS / Windows-with-HEIF-Extension only —
8349
+ * the terminal rejects with `error.code === "ERR_IMAGE_FORMAT_UNSUPPORTED"`
8350
+ * elsewhere.
8351
+ */
8352
+ heic(options?: { quality?: number }): this;
8353
+ /**
8354
+ * Set output format to AVIF. Requires an OS AV1 encoder (macOS on Apple
8355
+ * Silicon M3+, or Windows with the AV1 Video Extension) — the terminal
8356
+ * rejects with `error.code === "ERR_IMAGE_FORMAT_UNSUPPORTED"` elsewhere.
8357
+ */
8358
+ avif(options?: { quality?: number }): this;
8359
+
8360
+ /**
8361
+ * Run the pipeline and return the encoded bytes. If no format setter was
8362
+ * called, re-encodes in the source format.
8363
+ */
8364
+ bytes(): Promise<Uint8Array>;
8365
+ /** Like {@link bytes} but as a Node `Buffer`. */
8366
+ buffer(): Promise<Buffer>;
8367
+ /** Sharp-compatible alias for {@link buffer}. */
8368
+ toBuffer(): Promise<Buffer>;
8369
+ /**
8370
+ * Run the pipeline and write the encoded result via {@link Bun.write} —
8371
+ * `dest` may be a path string, {@link BunFile}, {@link S3File}, or fd.
8372
+ * Resolves to the number of bytes written.
8373
+ *
8374
+ * If no format method was chained and `dest` is a path string, the format
8375
+ * is inferred from its extension when it's one Bun can encode
8376
+ * (`.jpg`/`.png`/`.webp`/`.heic`/`.avif`); otherwise the source format is
8377
+ * reused.
8378
+ */
8379
+ write(dest: BunFile | S3File | Bun.PathLike | number): Promise<number>;
8380
+ /**
8381
+ * Like {@link toBase64} with a `data:image/{format};base64,` prefix.
8382
+ * Drops straight into `<img src>`.
8383
+ */
8384
+ dataurl(): Promise<string>;
8385
+ /**
8386
+ * A [ThumbHash](https://github.com/evanw/thumbhash)-rendered low-quality
8387
+ * placeholder of the *source* image as a `data:image/png;base64,…` URL —
8388
+ * a ≤32px blur with the right average colour, aspect ratio and rough
8389
+ * structure, ~400–700 bytes. Ready for `<img src>` or Next's
8390
+ * `blurDataURL`; no client-side decoder needed.
8391
+ *
8392
+ * ```ts
8393
+ * const lqip = await Bun.file("hero.jpg").image().placeholder();
8394
+ * // "data:image/png;base64,iVBORw0KGgoAAAANSUhE…"
8395
+ * ```
8396
+ */
8397
+ placeholder(as?: "dataurl"): Promise<string>;
8398
+ /** Run the pipeline and return a `Blob` with the matching `type`. */
8399
+ blob(): Promise<Blob>;
8400
+ /** Run the pipeline and return base64-encoded output. */
8401
+ toBase64(): Promise<string>;
8402
+ /** Decode just enough to read width/height/format. */
8403
+ metadata(): Promise<Image.Metadata>;
8404
+
8405
+ /** Populated after the first awaited terminal; `-1` before. */
8406
+ readonly width: number;
8407
+ readonly height: number;
8408
+ }
8409
+
8144
8410
  namespace WebView {
8145
8411
  type Modifier = "Shift" | "Control" | "Alt" | "Meta";
8146
8412
 
package/lib/fetch.d.ts CHANGED
@@ -17,7 +17,8 @@ declare module "bun" {
17
17
  // Extras that Bun supports:
18
18
  | AsyncIterable<string | ArrayBuffer | ArrayBufferView>
19
19
  | AsyncGenerator<string | ArrayBuffer | ArrayBufferView>
20
- | (() => AsyncGenerator<string | ArrayBuffer | ArrayBufferView>);
20
+ | (() => AsyncGenerator<string | ArrayBuffer | ArrayBufferView>)
21
+ | import("bun").Image;
21
22
 
22
23
  namespace __internal {
23
24
  type LibOrFallbackHeaders = LibDomIsLoaded extends true ? {} : import("undici-types").Headers;
package/lib/ffi.d.ts CHANGED
@@ -342,32 +342,26 @@ declare module "bun:ffi" {
342
342
 
343
343
  type Pointer = number & { __pointer__: null };
344
344
 
345
+ // Only the canonical enum members are listed below. `FFIType` declares
346
+ // several alias members (e.g. `i8` for `int8_t`, `pointer` for `ptr`) that
347
+ // share the same numeric value. Including both an enum member and its alias
348
+ // as computed property keys makes `tsgo` report duplicate identifiers, and
349
+ // the resulting lookup type is identical regardless of which alias is used
350
+ // since both resolve to the same numeric key.
345
351
  interface FFITypeToArgsType {
346
352
  [FFIType.char]: number;
347
353
  [FFIType.int8_t]: number;
348
- [FFIType.i8]: number;
349
354
  [FFIType.uint8_t]: number;
350
- [FFIType.u8]: number;
351
355
  [FFIType.int16_t]: number;
352
- [FFIType.i16]: number;
353
356
  [FFIType.uint16_t]: number;
354
- [FFIType.u16]: number;
355
357
  [FFIType.int32_t]: number;
356
- [FFIType.i32]: number;
357
- [FFIType.int]: number;
358
358
  [FFIType.uint32_t]: number;
359
- [FFIType.u32]: number;
360
359
  [FFIType.int64_t]: number | bigint;
361
- [FFIType.i64]: number | bigint;
362
360
  [FFIType.uint64_t]: number | bigint;
363
- [FFIType.u64]: number | bigint;
364
361
  [FFIType.double]: number;
365
- [FFIType.f64]: number;
366
362
  [FFIType.float]: number;
367
- [FFIType.f32]: number;
368
363
  [FFIType.bool]: boolean;
369
364
  [FFIType.ptr]: NodeJS.TypedArray | Pointer | CString | null;
370
- [FFIType.pointer]: NodeJS.TypedArray | Pointer | CString | null;
371
365
  [FFIType.void]: undefined;
372
366
  [FFIType.cstring]: NodeJS.TypedArray | Pointer | CString | null;
373
367
  [FFIType.i64_fast]: number | bigint;
@@ -380,29 +374,17 @@ declare module "bun:ffi" {
380
374
  interface FFITypeToReturnsType {
381
375
  [FFIType.char]: number;
382
376
  [FFIType.int8_t]: number;
383
- [FFIType.i8]: number;
384
377
  [FFIType.uint8_t]: number;
385
- [FFIType.u8]: number;
386
378
  [FFIType.int16_t]: number;
387
- [FFIType.i16]: number;
388
379
  [FFIType.uint16_t]: number;
389
- [FFIType.u16]: number;
390
380
  [FFIType.int32_t]: number;
391
- [FFIType.i32]: number;
392
- [FFIType.int]: number;
393
381
  [FFIType.uint32_t]: number;
394
- [FFIType.u32]: number;
395
382
  [FFIType.int64_t]: bigint;
396
- [FFIType.i64]: bigint;
397
383
  [FFIType.uint64_t]: bigint;
398
- [FFIType.u64]: bigint;
399
384
  [FFIType.double]: number;
400
- [FFIType.f64]: number;
401
385
  [FFIType.float]: number;
402
- [FFIType.f32]: number;
403
386
  [FFIType.bool]: boolean;
404
387
  [FFIType.ptr]: Pointer | null;
405
- [FFIType.pointer]: Pointer | null;
406
388
  [FFIType.void]: undefined;
407
389
  [FFIType.cstring]: CString;
408
390
  [FFIType.i64_fast]: number | bigint;
@@ -25,6 +25,12 @@ declare module "buffer" {
25
25
  */
26
26
  arrayBuffer(): Promise<ArrayBuffer>;
27
27
 
28
+ /**
29
+ * Wrap this blob in a {@link Bun.Image} pipeline.
30
+ * Equivalent to `new Bun.Image(this, options)`.
31
+ */
32
+ image(options?: Bun.Image.ConstructorOptions): Bun.Image;
33
+
28
34
  /**
29
35
  * Returns a readable stream of the blob's contents
30
36
  */
package/lib/serve.d.ts CHANGED
@@ -757,6 +757,21 @@ declare module "bun" {
757
757
  */
758
758
  ipv6Only?: boolean;
759
759
 
760
+ /**
761
+ * Also listen for HTTP/3 (QUIC) on the same port. Requires {@link tls}.
762
+ * @default false
763
+ * @experimental
764
+ */
765
+ http3?: boolean;
766
+
767
+ /**
768
+ * Listen for HTTP/1.1 over TCP. Set to `false` together with
769
+ * `http3: true` to serve HTTP/3 only.
770
+ * @default true
771
+ * @experimental
772
+ */
773
+ http1?: boolean;
774
+
760
775
  /**
761
776
  * Sets the number of seconds to wait before timing out a connection
762
777
  * due to inactivity.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bun-types-no-globals",
3
- "version": "1.3.13",
3
+ "version": "1.3.14",
4
4
  "main": "./generator/index.ts",
5
5
  "types": "./lib/index.d.ts",
6
6
  "description": "TypeScript type definitions for Bun without global types pollution",