bun-types-no-globals 1.3.6-canary.20260111T140550 → 1.3.6

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.
Files changed (3) hide show
  1. package/lib/bun.d.ts +92 -32
  2. package/lib/s3.d.ts +19 -7
  3. package/package.json +1 -1
package/lib/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.
package/lib/s3.d.ts CHANGED
@@ -11,9 +11,9 @@ declare module "bun" {
11
11
  * If the file descriptor is not writable yet, the data is buffered.
12
12
  *
13
13
  * @param chunk The data to write
14
- * @returns Number of bytes written
14
+ * @returns Number of bytes written or, if the write is pending, a Promise resolving to the number of bytes
15
15
  */
16
- write(chunk: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer): number;
16
+ write(chunk: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer): number | Promise<number>;
17
17
  /**
18
18
  * Flush the internal buffer, committing the data to disk or the pipe.
19
19
  *
@@ -78,9 +78,9 @@ declare module "bun" {
78
78
  * If the network is not writable yet, the data is buffered.
79
79
  *
80
80
  * @param chunk The data to write
81
- * @returns Number of bytes written
81
+ * @returns Number of bytes written or, if the write is pending, a Promise resolving to the number of bytes
82
82
  */
83
- write(chunk: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer): number;
83
+ write(chunk: string | ArrayBufferView | ArrayBuffer | SharedArrayBuffer): number | Promise<number>;
84
84
  /**
85
85
  * Flush the internal buffer, committing the data to the network.
86
86
  *
@@ -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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bun-types-no-globals",
3
- "version": "1.3.6-canary.20260111T140550",
3
+ "version": "1.3.6",
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",