bun-types 1.3.6-canary.20260112T140924 → 1.3.6-canary.20260114T140911

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/bun.d.ts CHANGED
@@ -750,7 +750,7 @@ declare module "bun" {
750
750
  */
751
751
  function write(
752
752
  destination: BunFile | S3File | PathLike,
753
- input: Blob | NodeJS.TypedArray | ArrayBufferLike | string | BlobPart[],
753
+ input: Blob | NodeJS.TypedArray | ArrayBufferLike | string | BlobPart[] | Archive,
754
754
  options?: {
755
755
  /**
756
756
  * If writing to a PathLike, set the permissions of the file.
@@ -6975,15 +6975,44 @@ declare module "bun" {
6975
6975
 
6976
6976
  /**
6977
6977
  * Compression format for archive output.
6978
- * - `"gzip"` - Compress with gzip
6979
- * - `true` - Same as `"gzip"`
6980
- * - `false` - Explicitly disable compression (no compression)
6981
- * - `undefined` - No compression (default behavior when omitted)
6978
+ * Currently only `"gzip"` is supported.
6979
+ */
6980
+ type ArchiveCompression = "gzip";
6981
+
6982
+ /**
6983
+ * Options for creating an Archive instance.
6982
6984
  *
6983
- * Both `false` and `undefined` result in no compression; `false` can be used
6984
- * to explicitly indicate "no compression" in code where the intent should be clear.
6985
+ * By default, archives are not compressed. Use `{ compress: "gzip" }` to enable compression.
6986
+ *
6987
+ * @example
6988
+ * ```ts
6989
+ * // No compression (default)
6990
+ * new Bun.Archive(data);
6991
+ *
6992
+ * // Enable gzip with default level (6)
6993
+ * new Bun.Archive(data, { compress: "gzip" });
6994
+ *
6995
+ * // Specify compression level
6996
+ * new Bun.Archive(data, { compress: "gzip", level: 9 });
6997
+ * ```
6985
6998
  */
6986
- type ArchiveCompression = "gzip" | boolean;
6999
+ interface ArchiveOptions {
7000
+ /**
7001
+ * Compression algorithm to use.
7002
+ * Currently only "gzip" is supported.
7003
+ * If not specified, no compression is applied.
7004
+ */
7005
+ compress?: ArchiveCompression;
7006
+ /**
7007
+ * Compression level (1-12). Only applies when `compress` is set.
7008
+ * - 1: Fastest compression, lowest ratio
7009
+ * - 6: Default balance of speed and ratio
7010
+ * - 12: Best compression ratio, slowest
7011
+ *
7012
+ * @default 6
7013
+ */
7014
+ level?: number;
7015
+ }
6987
7016
 
6988
7017
  /**
6989
7018
  * Options for extracting archive contents.
@@ -7031,7 +7060,7 @@ declare module "bun" {
7031
7060
  * @example
7032
7061
  * **Create an archive from an object:**
7033
7062
  * ```ts
7034
- * const archive = Bun.Archive.from({
7063
+ * const archive = new Bun.Archive({
7035
7064
  * "hello.txt": "Hello, World!",
7036
7065
  * "data.json": JSON.stringify({ foo: "bar" }),
7037
7066
  * "binary.bin": new Uint8Array([1, 2, 3, 4]),
@@ -7039,9 +7068,20 @@ declare module "bun" {
7039
7068
  * ```
7040
7069
  *
7041
7070
  * @example
7071
+ * **Create a gzipped archive:**
7072
+ * ```ts
7073
+ * const archive = new Bun.Archive({
7074
+ * "hello.txt": "Hello, World!",
7075
+ * }, { compress: "gzip" });
7076
+ *
7077
+ * // Or with a specific compression level (1-12)
7078
+ * const archive = new Bun.Archive(data, { compress: "gzip", level: 9 });
7079
+ * ```
7080
+ *
7081
+ * @example
7042
7082
  * **Extract an archive to disk:**
7043
7083
  * ```ts
7044
- * const archive = Bun.Archive.from(tarballBytes);
7084
+ * const archive = new Bun.Archive(tarballBytes);
7045
7085
  * const entryCount = await archive.extract("./output");
7046
7086
  * console.log(`Extracted ${entryCount} entries`);
7047
7087
  * ```
@@ -7049,7 +7089,7 @@ declare module "bun" {
7049
7089
  * @example
7050
7090
  * **Get archive contents as a Map of File objects:**
7051
7091
  * ```ts
7052
- * const archive = Bun.Archive.from(tarballBytes);
7092
+ * const archive = new Bun.Archive(tarballBytes);
7053
7093
  * const entries = await archive.files();
7054
7094
  * for (const [path, file] of entries) {
7055
7095
  * console.log(path, await file.text());
@@ -7062,36 +7102,50 @@ declare module "bun" {
7062
7102
  * await Bun.Archive.write("bundle.tar.gz", {
7063
7103
  * "src/index.ts": sourceCode,
7064
7104
  * "package.json": packageJson,
7065
- * }, "gzip");
7105
+ * }, { compress: "gzip" });
7066
7106
  * ```
7067
7107
  */
7068
7108
  export class Archive {
7069
7109
  /**
7070
7110
  * Create an `Archive` instance from input data.
7071
7111
  *
7112
+ * By default, archives are not compressed. Use `{ compress: "gzip" }` to enable compression.
7113
+ *
7072
7114
  * @param data - The input data for the archive:
7073
7115
  * - **Object**: Creates a new tarball with the object's keys as file paths and values as file contents
7074
7116
  * - **Blob/TypedArray/ArrayBuffer**: Wraps existing archive data (tar or tar.gz)
7075
- *
7076
- * @returns A new `Archive` instance
7117
+ * @param options - Optional archive options including compression settings.
7118
+ * Defaults to no compression if omitted.
7077
7119
  *
7078
7120
  * @example
7079
- * **From an object (creates new tarball):**
7121
+ * **From an object (creates uncompressed tarball):**
7080
7122
  * ```ts
7081
- * const archive = Bun.Archive.from({
7123
+ * const archive = new Bun.Archive({
7082
7124
  * "hello.txt": "Hello, World!",
7083
7125
  * "nested/file.txt": "Nested content",
7084
7126
  * });
7085
7127
  * ```
7086
7128
  *
7087
7129
  * @example
7130
+ * **With gzip compression:**
7131
+ * ```ts
7132
+ * const archive = new Bun.Archive(data, { compress: "gzip" });
7133
+ * ```
7134
+ *
7135
+ * @example
7136
+ * **With explicit gzip compression level:**
7137
+ * ```ts
7138
+ * const archive = new Bun.Archive(data, { compress: "gzip", level: 12 });
7139
+ * ```
7140
+ *
7141
+ * @example
7088
7142
  * **From existing archive data:**
7089
7143
  * ```ts
7090
7144
  * const response = await fetch("https://example.com/package.tar.gz");
7091
- * const archive = Bun.Archive.from(await response.blob());
7145
+ * const archive = new Bun.Archive(await response.blob());
7092
7146
  * ```
7093
7147
  */
7094
- static from(data: ArchiveInput): Archive;
7148
+ constructor(data: ArchiveInput, options?: ArchiveOptions);
7095
7149
 
7096
7150
  /**
7097
7151
  * Create and write an archive directly to disk in one operation.
@@ -7100,8 +7154,8 @@ declare module "bun" {
7100
7154
  * as it streams the data directly to disk.
7101
7155
  *
7102
7156
  * @param path - The file path to write the archive to
7103
- * @param data - The input data for the archive (same as `Archive.from()`)
7104
- * @param compress - Optional compression: `"gzip"`, `true` for gzip, or `false`/`undefined` for none
7157
+ * @param data - The input data for the archive (same as `new Archive()`)
7158
+ * @param options - Optional archive options including compression settings
7105
7159
  *
7106
7160
  * @returns A promise that resolves when the write is complete
7107
7161
  *
@@ -7117,10 +7171,10 @@ declare module "bun" {
7117
7171
  * @example
7118
7172
  * **Write gzipped tarball:**
7119
7173
  * ```ts
7120
- * await Bun.Archive.write("output.tar.gz", files, "gzip");
7174
+ * await Bun.Archive.write("output.tar.gz", files, { compress: "gzip" });
7121
7175
  * ```
7122
7176
  */
7123
- static write(path: string, data: ArchiveInput | Archive, compress?: ArchiveCompression): Promise<void>;
7177
+ static write(path: string, data: ArchiveInput | Archive, options?: ArchiveOptions): Promise<void>;
7124
7178
 
7125
7179
  /**
7126
7180
  * Extract the archive contents to a directory on disk.
@@ -7136,7 +7190,7 @@ declare module "bun" {
7136
7190
  * @example
7137
7191
  * **Extract all entries:**
7138
7192
  * ```ts
7139
- * const archive = Bun.Archive.from(tarballBytes);
7193
+ * const archive = new Bun.Archive(tarballBytes);
7140
7194
  * const count = await archive.extract("./extracted");
7141
7195
  * console.log(`Extracted ${count} entries`);
7142
7196
  * ```
@@ -7166,42 +7220,48 @@ declare module "bun" {
7166
7220
  /**
7167
7221
  * Get the archive contents as a `Blob`.
7168
7222
  *
7169
- * @param compress - Optional compression: `"gzip"`, `true` for gzip, or `false`/`undefined` for none
7223
+ * Uses the compression settings specified when the Archive was created.
7224
+ *
7170
7225
  * @returns A promise that resolves with the archive data as a Blob
7171
7226
  *
7172
7227
  * @example
7173
- * **Get uncompressed tarball:**
7228
+ * **Get tarball as Blob:**
7174
7229
  * ```ts
7230
+ * const archive = new Bun.Archive(data);
7175
7231
  * const blob = await archive.blob();
7176
7232
  * ```
7177
7233
  *
7178
7234
  * @example
7179
- * **Get gzipped tarball:**
7235
+ * **Get gzipped tarball as Blob:**
7180
7236
  * ```ts
7181
- * const gzippedBlob = await archive.blob("gzip");
7237
+ * const archive = new Bun.Archive(data, { compress: "gzip" });
7238
+ * const gzippedBlob = await archive.blob();
7182
7239
  * ```
7183
7240
  */
7184
- blob(compress?: ArchiveCompression): Promise<Blob>;
7241
+ blob(): Promise<Blob>;
7185
7242
 
7186
7243
  /**
7187
7244
  * Get the archive contents as a `Uint8Array`.
7188
7245
  *
7189
- * @param compress - Optional compression: `"gzip"`, `true` for gzip, or `false`/`undefined` for none
7246
+ * Uses the compression settings specified when the Archive was created.
7247
+ *
7190
7248
  * @returns A promise that resolves with the archive data as a Uint8Array
7191
7249
  *
7192
7250
  * @example
7193
- * **Get uncompressed tarball bytes:**
7251
+ * **Get tarball bytes:**
7194
7252
  * ```ts
7253
+ * const archive = new Bun.Archive(data);
7195
7254
  * const bytes = await archive.bytes();
7196
7255
  * ```
7197
7256
  *
7198
7257
  * @example
7199
7258
  * **Get gzipped tarball bytes:**
7200
7259
  * ```ts
7201
- * const gzippedBytes = await archive.bytes("gzip");
7260
+ * const archive = new Bun.Archive(data, { compress: "gzip" });
7261
+ * const gzippedBytes = await archive.bytes();
7202
7262
  * ```
7203
7263
  */
7204
- bytes(compress?: ArchiveCompression): Promise<Uint8Array<ArrayBuffer>>;
7264
+ bytes(): Promise<Uint8Array<ArrayBuffer>>;
7205
7265
 
7206
7266
  /**
7207
7267
  * Get the archive contents as a `Map` of `File` objects.
@@ -10,21 +10,21 @@ Bun provides a fast, native implementation for working with tar archives through
10
10
  **Create an archive from files:**
11
11
 
12
12
  ```ts
13
- const archive = Bun.Archive.from({
13
+ const archive = new Bun.Archive({
14
14
  "hello.txt": "Hello, World!",
15
15
  "data.json": JSON.stringify({ foo: "bar" }),
16
16
  "nested/file.txt": "Nested content",
17
17
  });
18
18
 
19
19
  // Write to disk
20
- await Bun.Archive.write("bundle.tar", archive);
20
+ await Bun.write("bundle.tar", archive);
21
21
  ```
22
22
 
23
23
  **Extract an archive:**
24
24
 
25
25
  ```ts
26
26
  const tarball = await Bun.file("package.tar.gz").bytes();
27
- const archive = Bun.Archive.from(tarball);
27
+ const archive = new Bun.Archive(tarball);
28
28
  const entryCount = await archive.extract("./output");
29
29
  console.log(`Extracted ${entryCount} entries`);
30
30
  ```
@@ -33,7 +33,7 @@ console.log(`Extracted ${entryCount} entries`);
33
33
 
34
34
  ```ts
35
35
  const tarball = await Bun.file("package.tar.gz").bytes();
36
- const archive = Bun.Archive.from(tarball);
36
+ const archive = new Bun.Archive(tarball);
37
37
  const files = await archive.files();
38
38
 
39
39
  for (const [path, file] of files) {
@@ -43,10 +43,11 @@ for (const [path, file] of files) {
43
43
 
44
44
  ## Creating Archives
45
45
 
46
- Use `Bun.Archive.from()` to create an archive from an object where keys are file paths and values are file contents:
46
+ Use `new Bun.Archive()` to create an archive from an object where keys are file paths and values are file contents. By default, archives are uncompressed:
47
47
 
48
48
  ```ts
49
- const archive = Bun.Archive.from({
49
+ // Creates an uncompressed tar archive (default)
50
+ const archive = new Bun.Archive({
50
51
  "README.md": "# My Project",
51
52
  "src/index.ts": "console.log('Hello');",
52
53
  "package.json": JSON.stringify({ name: "my-project" }),
@@ -64,7 +65,7 @@ File contents can be:
64
65
  const data = "binary data";
65
66
  const arrayBuffer = new ArrayBuffer(8);
66
67
 
67
- const archive = Bun.Archive.from({
68
+ const archive = new Bun.Archive({
68
69
  "text.txt": "Plain text",
69
70
  "blob.bin": new Blob([data]),
70
71
  "bytes.bin": new Uint8Array([1, 2, 3, 4]),
@@ -74,18 +75,19 @@ const archive = Bun.Archive.from({
74
75
 
75
76
  ### Writing Archives to Disk
76
77
 
77
- Use `Bun.Archive.write()` to create and write an archive in one operation:
78
+ Use `Bun.write()` to write an archive to disk:
78
79
 
79
80
  ```ts
80
- // Write uncompressed tar
81
- await Bun.Archive.write("output.tar", {
81
+ // Write uncompressed tar (default)
82
+ const archive = new Bun.Archive({
82
83
  "file1.txt": "content1",
83
84
  "file2.txt": "content2",
84
85
  });
86
+ await Bun.write("output.tar", archive);
85
87
 
86
88
  // Write gzipped tar
87
- const files = { "src/index.ts": "console.log('Hello');" };
88
- await Bun.Archive.write("output.tar.gz", files, "gzip");
89
+ const compressed = new Bun.Archive({ "src/index.ts": "console.log('Hello');" }, { compress: "gzip" });
90
+ await Bun.write("output.tar.gz", compressed);
89
91
  ```
90
92
 
91
93
  ### Getting Archive Bytes
@@ -93,8 +95,7 @@ await Bun.Archive.write("output.tar.gz", files, "gzip");
93
95
  Get the archive data as bytes or a Blob:
94
96
 
95
97
  ```ts
96
- const files = { "hello.txt": "Hello, World!" };
97
- const archive = Bun.Archive.from(files);
98
+ const archive = new Bun.Archive({ "hello.txt": "Hello, World!" });
98
99
 
99
100
  // As Uint8Array
100
101
  const bytes = await archive.bytes();
@@ -102,9 +103,10 @@ const bytes = await archive.bytes();
102
103
  // As Blob
103
104
  const blob = await archive.blob();
104
105
 
105
- // With gzip compression
106
- const gzippedBytes = await archive.bytes("gzip");
107
- const gzippedBlob = await archive.blob("gzip");
106
+ // With gzip compression (set at construction)
107
+ const gzipped = new Bun.Archive({ "hello.txt": "Hello, World!" }, { compress: "gzip" });
108
+ const gzippedBytes = await gzipped.bytes();
109
+ const gzippedBlob = await gzipped.blob();
108
110
  ```
109
111
 
110
112
  ## Extracting Archives
@@ -116,13 +118,13 @@ Create an archive from existing tar/tar.gz data:
116
118
  ```ts
117
119
  // From a file
118
120
  const tarball = await Bun.file("package.tar.gz").bytes();
119
- const archiveFromFile = Bun.Archive.from(tarball);
121
+ const archiveFromFile = new Bun.Archive(tarball);
120
122
  ```
121
123
 
122
124
  ```ts
123
125
  // From a fetch response
124
126
  const response = await fetch("https://example.com/archive.tar.gz");
125
- const archiveFromFetch = Bun.Archive.from(await response.blob());
127
+ const archiveFromFetch = new Bun.Archive(await response.blob());
126
128
  ```
127
129
 
128
130
  ### Extracting to Disk
@@ -131,7 +133,7 @@ Use `.extract()` to write all files to a directory:
131
133
 
132
134
  ```ts
133
135
  const tarball = await Bun.file("package.tar.gz").bytes();
134
- const archive = Bun.Archive.from(tarball);
136
+ const archive = new Bun.Archive(tarball);
135
137
  const count = await archive.extract("./extracted");
136
138
  console.log(`Extracted ${count} entries`);
137
139
  ```
@@ -148,7 +150,7 @@ Use glob patterns to extract only specific files. Patterns are matched against a
148
150
 
149
151
  ```ts
150
152
  const tarball = await Bun.file("package.tar.gz").bytes();
151
- const archive = Bun.Archive.from(tarball);
153
+ const archive = new Bun.Archive(tarball);
152
154
 
153
155
  // Extract only TypeScript files
154
156
  const tsCount = await archive.extract("./extracted", { glob: "**/*.ts" });
@@ -181,7 +183,7 @@ Use `.files()` to get archive contents as a `Map` of `File` objects without extr
181
183
 
182
184
  ```ts
183
185
  const tarball = await Bun.file("package.tar.gz").bytes();
184
- const archive = Bun.Archive.from(tarball);
186
+ const archive = new Bun.Archive(tarball);
185
187
  const files = await archive.files();
186
188
 
187
189
  for (const [path, file] of files) {
@@ -206,7 +208,7 @@ Archive operations can fail due to corrupted data, I/O errors, or invalid paths.
206
208
  ```ts
207
209
  try {
208
210
  const tarball = await Bun.file("package.tar.gz").bytes();
209
- const archive = Bun.Archive.from(tarball);
211
+ const archive = new Bun.Archive(tarball);
210
212
  const count = await archive.extract("./output");
211
213
  console.log(`Extracted ${count} entries`);
212
214
  } catch (e: unknown) {
@@ -227,7 +229,7 @@ try {
227
229
 
228
230
  Common error scenarios:
229
231
 
230
- - **Corrupted/truncated archives** - `Archive.from()` loads the archive data; errors may be deferred until read/extract operations
232
+ - **Corrupted/truncated archives** - `new Archive()` loads the archive data; errors may be deferred until read/extract operations
231
233
  - **Permission denied** - `extract()` throws if the target directory is not writable
232
234
  - **Disk full** - `extract()` throws if there's insufficient space
233
235
  - **Invalid paths** - Operations throw for malformed file paths
@@ -239,7 +241,7 @@ The count returned by `extract()` includes all successfully written entries (fil
239
241
  For additional security with untrusted archives, you can enumerate and validate paths before extraction:
240
242
 
241
243
  ```ts
242
- const archive = Bun.Archive.from(untrustedData);
244
+ const archive = new Bun.Archive(untrustedData);
243
245
  const files = await archive.files();
244
246
 
245
247
  // Optional: Custom validation for additional checks
@@ -298,26 +300,28 @@ See [Bun.Glob](/docs/api/glob) for the full glob syntax including escaping and a
298
300
 
299
301
  ## Compression
300
302
 
301
- Bun.Archive supports gzip compression for both reading and writing:
303
+ Bun.Archive creates uncompressed tar archives by default. Use `{ compress: "gzip" }` to enable gzip compression:
302
304
 
303
305
  ```ts
306
+ // Default: uncompressed tar
307
+ const archive = new Bun.Archive({ "hello.txt": "Hello, World!" });
308
+
304
309
  // Reading: automatically detects gzip
305
310
  const gzippedTarball = await Bun.file("archive.tar.gz").bytes();
306
- const archive = Bun.Archive.from(gzippedTarball);
311
+ const readArchive = new Bun.Archive(gzippedTarball);
307
312
 
308
- // Writing: specify compression
309
- const files = { "hello.txt": "Hello, World!" };
310
- await Bun.Archive.write("output.tar.gz", files, "gzip");
313
+ // Enable gzip compression
314
+ const compressed = new Bun.Archive({ "hello.txt": "Hello, World!" }, { compress: "gzip" });
311
315
 
312
- // Getting bytes: specify compression
313
- const gzippedBytes = await archive.bytes("gzip");
316
+ // Gzip with custom level (1-12)
317
+ const maxCompression = new Bun.Archive({ "hello.txt": "Hello, World!" }, { compress: "gzip", level: 12 });
314
318
  ```
315
319
 
316
- The compression argument accepts:
320
+ The options accept:
317
321
 
318
- - `"gzip"` - Enable gzip compression
319
- - `true` - Same as `"gzip"`
320
- - `false` or `undefined` - No compression
322
+ - No options or `undefined` - Uncompressed tar (default)
323
+ - `{ compress: "gzip" }` - Enable gzip compression at level 6
324
+ - `{ compress: "gzip", level: number }` - Gzip with custom level 1-12 (1 = fastest, 12 = smallest)
321
325
 
322
326
  ## Examples
323
327
 
@@ -339,15 +343,16 @@ for await (const path of glob.scan(".")) {
339
343
  // Add package.json
340
344
  files["package.json"] = await Bun.file("package.json").text();
341
345
 
342
- // Create compressed archive
343
- await Bun.Archive.write("bundle.tar.gz", files, "gzip");
346
+ // Create compressed archive and write to disk
347
+ const archive = new Bun.Archive(files, { compress: "gzip" });
348
+ await Bun.write("bundle.tar.gz", archive);
344
349
  ```
345
350
 
346
351
  ### Extract and Process npm Package
347
352
 
348
353
  ```ts
349
354
  const response = await fetch("https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz");
350
- const archive = Bun.Archive.from(await response.blob());
355
+ const archive = new Bun.Archive(await response.blob());
351
356
 
352
357
  // Get package.json
353
358
  const files = await archive.files("package/package.json");
@@ -365,7 +370,7 @@ if (packageJson) {
365
370
  import { readdir } from "node:fs/promises";
366
371
  import { join } from "node:path";
367
372
 
368
- async function archiveDirectory(dir: string): Promise<Bun.Archive> {
373
+ async function archiveDirectory(dir: string, compress = false): Promise<Bun.Archive> {
369
374
  const files: Record<string, Blob> = {};
370
375
 
371
376
  async function walk(currentDir: string, prefix: string = "") {
@@ -384,11 +389,11 @@ async function archiveDirectory(dir: string): Promise<Bun.Archive> {
384
389
  }
385
390
 
386
391
  await walk(dir);
387
- return Bun.Archive.from(files);
392
+ return new Bun.Archive(files, compress ? { compress: "gzip" } : undefined);
388
393
  }
389
394
 
390
- const archive = await archiveDirectory("./my-project");
391
- await Bun.Archive.write("my-project.tar.gz", archive, "gzip");
395
+ const archive = await archiveDirectory("./my-project", true);
396
+ await Bun.write("my-project.tar.gz", archive);
392
397
  ```
393
398
 
394
399
  ## Reference
@@ -396,14 +401,19 @@ await Bun.Archive.write("my-project.tar.gz", archive, "gzip");
396
401
  > **Note**: The following type signatures are simplified for documentation purposes. See [`packages/bun-types/bun.d.ts`](https://github.com/oven-sh/bun/blob/main/packages/bun-types/bun.d.ts) for the full type definitions.
397
402
 
398
403
  ```ts
399
- type ArchiveCompression = "gzip" | boolean;
400
-
401
404
  type ArchiveInput =
402
405
  | Record<string, string | Blob | Bun.ArrayBufferView | ArrayBufferLike>
403
406
  | Blob
404
407
  | Bun.ArrayBufferView
405
408
  | ArrayBufferLike;
406
409
 
410
+ type ArchiveOptions = {
411
+ /** Compression algorithm. Currently only "gzip" is supported. */
412
+ compress?: "gzip";
413
+ /** Compression level 1-12 (default 6 when gzip is enabled). */
414
+ level?: number;
415
+ };
416
+
407
417
  interface ArchiveExtractOptions {
408
418
  /** Glob pattern(s) to filter extraction. Supports negative patterns with "!" prefix. */
409
419
  glob?: string | readonly string[];
@@ -412,13 +422,11 @@ interface ArchiveExtractOptions {
412
422
  class Archive {
413
423
  /**
414
424
  * Create an Archive from input data
425
+ * @param data - Files to archive (as object) or existing archive data (as bytes/blob)
426
+ * @param options - Compression options. Uncompressed by default.
427
+ * Pass { compress: "gzip" } to enable compression.
415
428
  */
416
- static from(data: ArchiveInput): Archive;
417
-
418
- /**
419
- * Write an archive directly to disk
420
- */
421
- static write(path: string, data: ArchiveInput | Archive, compress?: ArchiveCompression): Promise<void>;
429
+ constructor(data: ArchiveInput, options?: ArchiveOptions);
422
430
 
423
431
  /**
424
432
  * Extract archive to a directory
@@ -427,14 +435,14 @@ class Archive {
427
435
  extract(path: string, options?: ArchiveExtractOptions): Promise<number>;
428
436
 
429
437
  /**
430
- * Get archive as a Blob
438
+ * Get archive as a Blob (uses compression setting from constructor)
431
439
  */
432
- blob(compress?: ArchiveCompression): Promise<Blob>;
440
+ blob(): Promise<Blob>;
433
441
 
434
442
  /**
435
- * Get archive as a Uint8Array
443
+ * Get archive as a Uint8Array (uses compression setting from constructor)
436
444
  */
437
- bytes(compress?: ArchiveCompression): Promise<Uint8Array<ArrayBuffer>>;
445
+ bytes(): Promise<Uint8Array<ArrayBuffer>>;
438
446
 
439
447
  /**
440
448
  * Get archive contents as File objects (regular files only, no directories)
package/package.json CHANGED
@@ -33,5 +33,5 @@
33
33
  "bun.js",
34
34
  "types"
35
35
  ],
36
- "version": "1.3.6-canary.20260112T140924"
36
+ "version": "1.3.6-canary.20260114T140911"
37
37
  }
package/s3.d.ts CHANGED
@@ -609,7 +609,17 @@ declare module "bun" {
609
609
  * });
610
610
  */
611
611
  write(
612
- data: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer | Request | Response | BunFile | S3File | Blob,
612
+ data:
613
+ | string
614
+ | ArrayBufferView
615
+ | ArrayBuffer
616
+ | SharedArrayBuffer
617
+ | Request
618
+ | Response
619
+ | BunFile
620
+ | S3File
621
+ | Blob
622
+ | Archive,
613
623
  options?: S3Options,
614
624
  ): Promise<number>;
615
625
 
@@ -920,7 +930,8 @@ declare module "bun" {
920
930
  | BunFile
921
931
  | S3File
922
932
  | Blob
923
- | File,
933
+ | File
934
+ | Archive,
924
935
  options?: S3Options,
925
936
  ): Promise<number>;
926
937
 
@@ -970,7 +981,8 @@ declare module "bun" {
970
981
  | BunFile
971
982
  | S3File
972
983
  | Blob
973
- | File,
984
+ | File
985
+ | Archive,
974
986
  options?: S3Options,
975
987
  ): Promise<number>;
976
988