bun-types-no-globals 1.3.6-canary.20260109T140758 → 1.3.6-canary.20260111T140550
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 +290 -0
- package/package.json +1 -1
package/lib/bun.d.ts
CHANGED
|
@@ -6965,6 +6965,296 @@ declare module "bun" {
|
|
|
6965
6965
|
match(str: string): boolean;
|
|
6966
6966
|
}
|
|
6967
6967
|
|
|
6968
|
+
/**
|
|
6969
|
+
* Input data for creating an archive. Can be:
|
|
6970
|
+
* - An object mapping paths to file contents (string, Blob, TypedArray, or ArrayBuffer)
|
|
6971
|
+
* - A Blob containing existing archive data
|
|
6972
|
+
* - A TypedArray or ArrayBuffer containing existing archive data
|
|
6973
|
+
*/
|
|
6974
|
+
type ArchiveInput = Record<string, BlobPart> | Blob | ArrayBufferView | ArrayBufferLike;
|
|
6975
|
+
|
|
6976
|
+
/**
|
|
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)
|
|
6982
|
+
*
|
|
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
|
+
*/
|
|
6986
|
+
type ArchiveCompression = "gzip" | boolean;
|
|
6987
|
+
|
|
6988
|
+
/**
|
|
6989
|
+
* Options for extracting archive contents.
|
|
6990
|
+
*/
|
|
6991
|
+
interface ArchiveExtractOptions {
|
|
6992
|
+
/**
|
|
6993
|
+
* Glob pattern(s) to filter which entries are extracted.
|
|
6994
|
+
* Uses the same syntax as {@link Bun.Glob}, including support for wildcards (`*`, `**`),
|
|
6995
|
+
* character classes (`[abc]`), alternation (`{a,b}`), and negation (`!pattern`).
|
|
6996
|
+
*
|
|
6997
|
+
* Patterns are matched against archive entry paths normalized to use forward slashes (`/`),
|
|
6998
|
+
* regardless of the host operating system. Always write patterns using `/` as the separator.
|
|
6999
|
+
*
|
|
7000
|
+
* - Positive patterns: Only entries matching at least one pattern will be extracted.
|
|
7001
|
+
* - Negative patterns (prefixed with `!`): Entries matching these patterns will be excluded.
|
|
7002
|
+
* Negative patterns are applied after positive patterns.
|
|
7003
|
+
*
|
|
7004
|
+
* If not specified, all entries are extracted.
|
|
7005
|
+
*
|
|
7006
|
+
* @example
|
|
7007
|
+
* ```ts
|
|
7008
|
+
* // Extract only TypeScript files
|
|
7009
|
+
* await archive.extract("./out", { glob: "**" + "/*.ts" });
|
|
7010
|
+
*
|
|
7011
|
+
* // Extract files from multiple directories
|
|
7012
|
+
* await archive.extract("./out", { glob: ["src/**", "lib/**"] });
|
|
7013
|
+
*
|
|
7014
|
+
* // Exclude node_modules using negative pattern
|
|
7015
|
+
* await archive.extract("./out", { glob: ["**", "!node_modules/**"] });
|
|
7016
|
+
*
|
|
7017
|
+
* // Extract source files but exclude tests
|
|
7018
|
+
* await archive.extract("./out", { glob: ["src/**", "!**" + "/*.test.ts"] });
|
|
7019
|
+
* ```
|
|
7020
|
+
*/
|
|
7021
|
+
glob?: string | readonly string[];
|
|
7022
|
+
}
|
|
7023
|
+
|
|
7024
|
+
/**
|
|
7025
|
+
* A class for creating and extracting tar archives with optional gzip compression.
|
|
7026
|
+
*
|
|
7027
|
+
* `Bun.Archive` provides a fast, native implementation for working with tar archives.
|
|
7028
|
+
* It supports creating archives from in-memory data or extracting existing archives
|
|
7029
|
+
* to disk or memory.
|
|
7030
|
+
*
|
|
7031
|
+
* @example
|
|
7032
|
+
* **Create an archive from an object:**
|
|
7033
|
+
* ```ts
|
|
7034
|
+
* const archive = Bun.Archive.from({
|
|
7035
|
+
* "hello.txt": "Hello, World!",
|
|
7036
|
+
* "data.json": JSON.stringify({ foo: "bar" }),
|
|
7037
|
+
* "binary.bin": new Uint8Array([1, 2, 3, 4]),
|
|
7038
|
+
* });
|
|
7039
|
+
* ```
|
|
7040
|
+
*
|
|
7041
|
+
* @example
|
|
7042
|
+
* **Extract an archive to disk:**
|
|
7043
|
+
* ```ts
|
|
7044
|
+
* const archive = Bun.Archive.from(tarballBytes);
|
|
7045
|
+
* const entryCount = await archive.extract("./output");
|
|
7046
|
+
* console.log(`Extracted ${entryCount} entries`);
|
|
7047
|
+
* ```
|
|
7048
|
+
*
|
|
7049
|
+
* @example
|
|
7050
|
+
* **Get archive contents as a Map of File objects:**
|
|
7051
|
+
* ```ts
|
|
7052
|
+
* const archive = Bun.Archive.from(tarballBytes);
|
|
7053
|
+
* const entries = await archive.files();
|
|
7054
|
+
* for (const [path, file] of entries) {
|
|
7055
|
+
* console.log(path, await file.text());
|
|
7056
|
+
* }
|
|
7057
|
+
* ```
|
|
7058
|
+
*
|
|
7059
|
+
* @example
|
|
7060
|
+
* **Write a gzipped archive directly to disk:**
|
|
7061
|
+
* ```ts
|
|
7062
|
+
* await Bun.Archive.write("bundle.tar.gz", {
|
|
7063
|
+
* "src/index.ts": sourceCode,
|
|
7064
|
+
* "package.json": packageJson,
|
|
7065
|
+
* }, "gzip");
|
|
7066
|
+
* ```
|
|
7067
|
+
*/
|
|
7068
|
+
export class Archive {
|
|
7069
|
+
/**
|
|
7070
|
+
* Create an `Archive` instance from input data.
|
|
7071
|
+
*
|
|
7072
|
+
* @param data - The input data for the archive:
|
|
7073
|
+
* - **Object**: Creates a new tarball with the object's keys as file paths and values as file contents
|
|
7074
|
+
* - **Blob/TypedArray/ArrayBuffer**: Wraps existing archive data (tar or tar.gz)
|
|
7075
|
+
*
|
|
7076
|
+
* @returns A new `Archive` instance
|
|
7077
|
+
*
|
|
7078
|
+
* @example
|
|
7079
|
+
* **From an object (creates new tarball):**
|
|
7080
|
+
* ```ts
|
|
7081
|
+
* const archive = Bun.Archive.from({
|
|
7082
|
+
* "hello.txt": "Hello, World!",
|
|
7083
|
+
* "nested/file.txt": "Nested content",
|
|
7084
|
+
* });
|
|
7085
|
+
* ```
|
|
7086
|
+
*
|
|
7087
|
+
* @example
|
|
7088
|
+
* **From existing archive data:**
|
|
7089
|
+
* ```ts
|
|
7090
|
+
* const response = await fetch("https://example.com/package.tar.gz");
|
|
7091
|
+
* const archive = Bun.Archive.from(await response.blob());
|
|
7092
|
+
* ```
|
|
7093
|
+
*/
|
|
7094
|
+
static from(data: ArchiveInput): Archive;
|
|
7095
|
+
|
|
7096
|
+
/**
|
|
7097
|
+
* Create and write an archive directly to disk in one operation.
|
|
7098
|
+
*
|
|
7099
|
+
* This is more efficient than creating an archive and then writing it separately,
|
|
7100
|
+
* as it streams the data directly to disk.
|
|
7101
|
+
*
|
|
7102
|
+
* @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
|
|
7105
|
+
*
|
|
7106
|
+
* @returns A promise that resolves when the write is complete
|
|
7107
|
+
*
|
|
7108
|
+
* @example
|
|
7109
|
+
* **Write uncompressed tarball:**
|
|
7110
|
+
* ```ts
|
|
7111
|
+
* await Bun.Archive.write("output.tar", {
|
|
7112
|
+
* "file1.txt": "content1",
|
|
7113
|
+
* "file2.txt": "content2",
|
|
7114
|
+
* });
|
|
7115
|
+
* ```
|
|
7116
|
+
*
|
|
7117
|
+
* @example
|
|
7118
|
+
* **Write gzipped tarball:**
|
|
7119
|
+
* ```ts
|
|
7120
|
+
* await Bun.Archive.write("output.tar.gz", files, "gzip");
|
|
7121
|
+
* ```
|
|
7122
|
+
*/
|
|
7123
|
+
static write(path: string, data: ArchiveInput | Archive, compress?: ArchiveCompression): Promise<void>;
|
|
7124
|
+
|
|
7125
|
+
/**
|
|
7126
|
+
* Extract the archive contents to a directory on disk.
|
|
7127
|
+
*
|
|
7128
|
+
* Creates the target directory and any necessary parent directories if they don't exist.
|
|
7129
|
+
* Existing files will be overwritten.
|
|
7130
|
+
*
|
|
7131
|
+
* @param path - The directory path to extract to
|
|
7132
|
+
* @param options - Optional extraction options
|
|
7133
|
+
* @param options.glob - Glob pattern(s) to filter entries (positive patterns include, negative patterns starting with `!` exclude)
|
|
7134
|
+
* @returns A promise that resolves with the number of entries extracted (files, directories, and symlinks)
|
|
7135
|
+
*
|
|
7136
|
+
* @example
|
|
7137
|
+
* **Extract all entries:**
|
|
7138
|
+
* ```ts
|
|
7139
|
+
* const archive = Bun.Archive.from(tarballBytes);
|
|
7140
|
+
* const count = await archive.extract("./extracted");
|
|
7141
|
+
* console.log(`Extracted ${count} entries`);
|
|
7142
|
+
* ```
|
|
7143
|
+
*
|
|
7144
|
+
* @example
|
|
7145
|
+
* **Extract only TypeScript files:**
|
|
7146
|
+
* ```ts
|
|
7147
|
+
* const count = await archive.extract("./src", { glob: "**" + "/*.ts" });
|
|
7148
|
+
* ```
|
|
7149
|
+
*
|
|
7150
|
+
* @example
|
|
7151
|
+
* **Extract everything except tests:**
|
|
7152
|
+
* ```ts
|
|
7153
|
+
* const count = await archive.extract("./dist", { glob: ["**", "!**" + "/*.test.*"] });
|
|
7154
|
+
* ```
|
|
7155
|
+
*
|
|
7156
|
+
* @example
|
|
7157
|
+
* **Extract source files but exclude tests:**
|
|
7158
|
+
* ```ts
|
|
7159
|
+
* const count = await archive.extract("./output", {
|
|
7160
|
+
* glob: ["src/**", "lib/**", "!**" + "/*.test.ts", "!**" + "/__tests__/**"]
|
|
7161
|
+
* });
|
|
7162
|
+
* ```
|
|
7163
|
+
*/
|
|
7164
|
+
extract(path: string, options?: ArchiveExtractOptions): Promise<number>;
|
|
7165
|
+
|
|
7166
|
+
/**
|
|
7167
|
+
* Get the archive contents as a `Blob`.
|
|
7168
|
+
*
|
|
7169
|
+
* @param compress - Optional compression: `"gzip"`, `true` for gzip, or `false`/`undefined` for none
|
|
7170
|
+
* @returns A promise that resolves with the archive data as a Blob
|
|
7171
|
+
*
|
|
7172
|
+
* @example
|
|
7173
|
+
* **Get uncompressed tarball:**
|
|
7174
|
+
* ```ts
|
|
7175
|
+
* const blob = await archive.blob();
|
|
7176
|
+
* ```
|
|
7177
|
+
*
|
|
7178
|
+
* @example
|
|
7179
|
+
* **Get gzipped tarball:**
|
|
7180
|
+
* ```ts
|
|
7181
|
+
* const gzippedBlob = await archive.blob("gzip");
|
|
7182
|
+
* ```
|
|
7183
|
+
*/
|
|
7184
|
+
blob(compress?: ArchiveCompression): Promise<Blob>;
|
|
7185
|
+
|
|
7186
|
+
/**
|
|
7187
|
+
* Get the archive contents as a `Uint8Array`.
|
|
7188
|
+
*
|
|
7189
|
+
* @param compress - Optional compression: `"gzip"`, `true` for gzip, or `false`/`undefined` for none
|
|
7190
|
+
* @returns A promise that resolves with the archive data as a Uint8Array
|
|
7191
|
+
*
|
|
7192
|
+
* @example
|
|
7193
|
+
* **Get uncompressed tarball bytes:**
|
|
7194
|
+
* ```ts
|
|
7195
|
+
* const bytes = await archive.bytes();
|
|
7196
|
+
* ```
|
|
7197
|
+
*
|
|
7198
|
+
* @example
|
|
7199
|
+
* **Get gzipped tarball bytes:**
|
|
7200
|
+
* ```ts
|
|
7201
|
+
* const gzippedBytes = await archive.bytes("gzip");
|
|
7202
|
+
* ```
|
|
7203
|
+
*/
|
|
7204
|
+
bytes(compress?: ArchiveCompression): Promise<Uint8Array<ArrayBuffer>>;
|
|
7205
|
+
|
|
7206
|
+
/**
|
|
7207
|
+
* Get the archive contents as a `Map` of `File` objects.
|
|
7208
|
+
*
|
|
7209
|
+
* Each file in the archive is returned as a `File` object with:
|
|
7210
|
+
* - `name`: The file path within the archive
|
|
7211
|
+
* - `lastModified`: The file's modification time from the archive
|
|
7212
|
+
* - Standard Blob methods (`text()`, `arrayBuffer()`, `stream()`, etc.)
|
|
7213
|
+
*
|
|
7214
|
+
* Only regular files are included; directories are not returned.
|
|
7215
|
+
* File contents are loaded into memory, so for large archives consider using `extract()` instead.
|
|
7216
|
+
*
|
|
7217
|
+
* @param glob - Optional glob pattern(s) to filter files. Supports the same syntax as {@link Bun.Glob},
|
|
7218
|
+
* including negation patterns (prefixed with `!`). Patterns are matched against paths normalized
|
|
7219
|
+
* to use forward slashes (`/`).
|
|
7220
|
+
* @returns A promise that resolves with a Map where keys are file paths (always using forward slashes `/` as separators) and values are File objects
|
|
7221
|
+
*
|
|
7222
|
+
* @example
|
|
7223
|
+
* **Get all files:**
|
|
7224
|
+
* ```ts
|
|
7225
|
+
* const entries = await archive.files();
|
|
7226
|
+
* for (const [path, file] of entries) {
|
|
7227
|
+
* console.log(`${path}: ${file.size} bytes`);
|
|
7228
|
+
* }
|
|
7229
|
+
* ```
|
|
7230
|
+
*
|
|
7231
|
+
* @example
|
|
7232
|
+
* **Filter by glob pattern:**
|
|
7233
|
+
* ```ts
|
|
7234
|
+
* const tsFiles = await archive.files("**" + "/*.ts");
|
|
7235
|
+
* const srcFiles = await archive.files(["src/**", "lib/**"]);
|
|
7236
|
+
* ```
|
|
7237
|
+
*
|
|
7238
|
+
* @example
|
|
7239
|
+
* **Exclude files with negative patterns:**
|
|
7240
|
+
* ```ts
|
|
7241
|
+
* // Get all source files except tests
|
|
7242
|
+
* const srcFiles = await archive.files(["src/**", "!**" + "/*.test.ts"]);
|
|
7243
|
+
* ```
|
|
7244
|
+
*
|
|
7245
|
+
* @example
|
|
7246
|
+
* **Read file contents:**
|
|
7247
|
+
* ```ts
|
|
7248
|
+
* const entries = await archive.files();
|
|
7249
|
+
* const readme = entries.get("README.md");
|
|
7250
|
+
* if (readme) {
|
|
7251
|
+
* console.log(await readme.text());
|
|
7252
|
+
* }
|
|
7253
|
+
* ```
|
|
7254
|
+
*/
|
|
7255
|
+
files(glob?: string | readonly string[]): Promise<Map<string, File>>;
|
|
7256
|
+
}
|
|
7257
|
+
|
|
6968
7258
|
/**
|
|
6969
7259
|
* Generate a UUIDv7, which is a sequential ID based on the current timestamp with a random component.
|
|
6970
7260
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bun-types-no-globals",
|
|
3
|
-
"version": "1.3.6-canary.
|
|
3
|
+
"version": "1.3.6-canary.20260111T140550",
|
|
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",
|