bun-types 1.2.6 → 1.2.7
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/README.md +1 -3
- package/bun.d.ts +7186 -7604
- package/bun.ns.d.ts +7 -0
- package/deprecated.d.ts +53 -58
- package/devserver.d.ts +177 -183
- package/docs/api/cookie.md +449 -0
- package/docs/api/fetch.md +1 -1
- package/docs/api/http.md +78 -0
- package/docs/api/spawn.md +1 -1
- package/docs/cli/publish.md +1 -1
- package/docs/guides/ecosystem/nuxt.md +1 -1
- package/docs/guides/install/add-peer.md +2 -2
- package/docs/guides/install/from-npm-install-to-bun-install.md +1 -1
- package/docs/guides/runtime/typescript.md +7 -6
- package/docs/guides/test/run-tests.md +3 -3
- package/docs/guides/test/snapshot.md +3 -3
- package/docs/guides/test/update-snapshots.md +1 -1
- package/docs/guides/util/version.md +1 -1
- package/docs/installation.md +4 -4
- package/docs/runtime/debugger.md +3 -3
- package/docs/runtime/nodejs-apis.md +1 -1
- package/docs/test/dom.md +1 -1
- package/docs/typescript.md +7 -6
- package/extensions.d.ts +31 -0
- package/fetch.d.ts +62 -159
- package/ffi.d.ts +1084 -1108
- package/globals.d.ts +1721 -1949
- package/html-rewriter.d.ts +146 -151
- package/index.d.ts +13 -11
- package/jsc.d.ts +216 -230
- package/overrides.d.ts +106 -63
- package/package.json +39 -31
- package/s3.d.ts +825 -0
- package/sqlite.d.ts +1143 -1172
- package/test.d.ts +2130 -2241
- package/wasm.d.ts +190 -288
- package/ambient.d.ts +0 -31
package/docs/installation.md
CHANGED
|
@@ -14,7 +14,7 @@ Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1. Us
|
|
|
14
14
|
```bash#macOS/Linux_(curl)
|
|
15
15
|
$ curl -fsSL https://bun.sh/install | bash # for macOS, Linux, and WSL
|
|
16
16
|
# to install a specific version
|
|
17
|
-
$ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.
|
|
17
|
+
$ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.7"
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
```bash#npm
|
|
@@ -189,10 +189,10 @@ Since Bun is a single binary, you can install older versions of Bun by re-runnin
|
|
|
189
189
|
|
|
190
190
|
### Installing a specific version of Bun on Linux/Mac
|
|
191
191
|
|
|
192
|
-
To install a specific version of Bun, you can pass the git tag of the version you want to install to the install script, such as `bun-v1.2.0` or `bun-v1.2.
|
|
192
|
+
To install a specific version of Bun, you can pass the git tag of the version you want to install to the install script, such as `bun-v1.2.0` or `bun-v1.2.7`.
|
|
193
193
|
|
|
194
194
|
```sh
|
|
195
|
-
$ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.
|
|
195
|
+
$ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.7"
|
|
196
196
|
```
|
|
197
197
|
|
|
198
198
|
### Installing a specific version of Bun on Windows
|
|
@@ -201,7 +201,7 @@ On Windows, you can install a specific version of Bun by passing the version num
|
|
|
201
201
|
|
|
202
202
|
```sh
|
|
203
203
|
# PowerShell:
|
|
204
|
-
$ iex "& {$(irm https://bun.sh/install.ps1)} -Version 1.2.
|
|
204
|
+
$ iex "& {$(irm https://bun.sh/install.ps1)} -Version 1.2.7"
|
|
205
205
|
```
|
|
206
206
|
|
|
207
207
|
## Downloading Bun binaries directly
|
package/docs/runtime/debugger.md
CHANGED
|
@@ -124,11 +124,11 @@ await fetch("https://example.com", {
|
|
|
124
124
|
This prints the `fetch` request as a single-line `curl` command to let you copy-paste into your terminal to replicate the request.
|
|
125
125
|
|
|
126
126
|
```sh
|
|
127
|
-
[fetch] $ curl --http1.1 "https://example.com/" -X POST -H "content-type: application/json" -H "Connection: keep-alive" -H "User-Agent: Bun/1.2.
|
|
127
|
+
[fetch] $ curl --http1.1 "https://example.com/" -X POST -H "content-type: application/json" -H "Connection: keep-alive" -H "User-Agent: Bun/1.2.7" -H "Accept: */*" -H "Host: example.com" -H "Accept-Encoding: gzip, deflate, br" --compressed -H "Content-Length: 13" --data-raw "{\"foo\":\"bar\"}"
|
|
128
128
|
[fetch] > HTTP/1.1 POST https://example.com/
|
|
129
129
|
[fetch] > content-type: application/json
|
|
130
130
|
[fetch] > Connection: keep-alive
|
|
131
|
-
[fetch] > User-Agent: Bun/1.2.
|
|
131
|
+
[fetch] > User-Agent: Bun/1.2.7
|
|
132
132
|
[fetch] > Accept: */*
|
|
133
133
|
[fetch] > Host: example.com
|
|
134
134
|
[fetch] > Accept-Encoding: gzip, deflate, br
|
|
@@ -170,7 +170,7 @@ This prints the following to the console:
|
|
|
170
170
|
[fetch] > HTTP/1.1 POST https://example.com/
|
|
171
171
|
[fetch] > content-type: application/json
|
|
172
172
|
[fetch] > Connection: keep-alive
|
|
173
|
-
[fetch] > User-Agent: Bun/1.2.
|
|
173
|
+
[fetch] > User-Agent: Bun/1.2.7
|
|
174
174
|
[fetch] > Accept: */*
|
|
175
175
|
[fetch] > Host: example.com
|
|
176
176
|
[fetch] > Accept-Encoding: gzip, deflate, br
|
|
@@ -104,7 +104,7 @@ This page is updated regularly to reflect compatibility status of the latest ver
|
|
|
104
104
|
|
|
105
105
|
### [`node:crypto`](https://nodejs.org/api/crypto.html)
|
|
106
106
|
|
|
107
|
-
🟡 Missing `
|
|
107
|
+
🟡 Missing `secureHeapUsed` `setEngine` `setFips`
|
|
108
108
|
|
|
109
109
|
Some methods are not optimized yet.
|
|
110
110
|
|
package/docs/test/dom.md
CHANGED
package/docs/typescript.md
CHANGED
|
@@ -17,7 +17,7 @@ Bun supports things like top-level await, JSX, and extensioned `.ts` imports, wh
|
|
|
17
17
|
```jsonc
|
|
18
18
|
{
|
|
19
19
|
"compilerOptions": {
|
|
20
|
-
//
|
|
20
|
+
// Environment setup & latest features
|
|
21
21
|
"lib": ["ESNext"],
|
|
22
22
|
"target": "ESNext",
|
|
23
23
|
"module": "ESNext",
|
|
@@ -35,12 +35,13 @@ Bun supports things like top-level await, JSX, and extensioned `.ts` imports, wh
|
|
|
35
35
|
"strict": true,
|
|
36
36
|
"skipLibCheck": true,
|
|
37
37
|
"noFallthroughCasesInSwitch": true,
|
|
38
|
+
"noUncheckedIndexedAccess": true,
|
|
38
39
|
|
|
39
|
-
// Some stricter flags
|
|
40
|
-
"noUnusedLocals":
|
|
41
|
-
"noUnusedParameters":
|
|
42
|
-
"noPropertyAccessFromIndexSignature":
|
|
43
|
-
}
|
|
40
|
+
// Some stricter flags (disabled by default)
|
|
41
|
+
"noUnusedLocals": false,
|
|
42
|
+
"noUnusedParameters": false,
|
|
43
|
+
"noPropertyAccessFromIndexSignature": false,
|
|
44
|
+
},
|
|
44
45
|
}
|
|
45
46
|
```
|
|
46
47
|
|
package/extensions.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
declare module "*.txt" {
|
|
2
|
+
var text: string;
|
|
3
|
+
export = text;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare module "*.toml" {
|
|
7
|
+
var contents: any;
|
|
8
|
+
export = contents;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare module "*.jsonc" {
|
|
12
|
+
var contents: any;
|
|
13
|
+
export = contents;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare module "*/bun.lock" {
|
|
17
|
+
var contents: import("bun").BunLockFile;
|
|
18
|
+
export = contents;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare module "*.html" {
|
|
22
|
+
// In Bun v1.2, this might change to Bun.HTMLBundle
|
|
23
|
+
var contents: any;
|
|
24
|
+
export = contents;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare module "*.svg" {
|
|
28
|
+
// Bun 1.2.3 added support for frontend dev server
|
|
29
|
+
var content: `${string}.svg`;
|
|
30
|
+
export = content;
|
|
31
|
+
}
|
package/fetch.d.ts
CHANGED
|
@@ -1,169 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Convert {@link Headers} to a plain JavaScript object.
|
|
4
|
-
*
|
|
5
|
-
* About 10x faster than `Object.fromEntries(headers.entries())`
|
|
6
|
-
*
|
|
7
|
-
* Called when you run `JSON.stringify(headers)`
|
|
8
|
-
*
|
|
9
|
-
* Does not preserve insertion order. Well-known header names are lowercased. Other header names are left as-is.
|
|
10
|
-
*/
|
|
11
|
-
toJSON(): Record<string, string>;
|
|
12
|
-
/**
|
|
13
|
-
* Get the total number of headers
|
|
14
|
-
*/
|
|
15
|
-
readonly count: number;
|
|
16
|
-
/**
|
|
17
|
-
* Get all headers matching the name
|
|
18
|
-
*
|
|
19
|
-
* Only supports `"Set-Cookie"`. All other headers are empty arrays.
|
|
20
|
-
*
|
|
21
|
-
* @param name - The header name to get
|
|
22
|
-
*
|
|
23
|
-
* @returns An array of header values
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```ts
|
|
27
|
-
* const headers = new Headers();
|
|
28
|
-
* headers.append("Set-Cookie", "foo=bar");
|
|
29
|
-
* headers.append("Set-Cookie", "baz=qux");
|
|
30
|
-
* headers.getAll("Set-Cookie"); // ["foo=bar", "baz=qux"]
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
getAll(name: "set-cookie" | "Set-Cookie"): string[];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
var Headers: {
|
|
37
|
-
prototype: Headers;
|
|
38
|
-
new (init?: Bun.HeadersInit): Headers;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
interface Request {
|
|
42
|
-
headers: Headers;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
var Request: {
|
|
46
|
-
prototype: Request;
|
|
47
|
-
new (requestInfo: string, requestInit?: RequestInit): Request;
|
|
48
|
-
new (requestInfo: RequestInit & { url: string }): Request;
|
|
49
|
-
new (requestInfo: Request, requestInit?: RequestInit): Request;
|
|
50
|
-
};
|
|
1
|
+
/*
|
|
51
2
|
|
|
52
|
-
|
|
53
|
-
new (
|
|
54
|
-
body?: Bun.BodyInit | null | undefined,
|
|
55
|
-
init?: Bun.ResponseInit | undefined,
|
|
56
|
-
): Response;
|
|
57
|
-
/**
|
|
58
|
-
* Create a new {@link Response} with a JSON body
|
|
59
|
-
*
|
|
60
|
-
* @param body - The body of the response
|
|
61
|
-
* @param options - options to pass to the response
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
*
|
|
65
|
-
* ```ts
|
|
66
|
-
* const response = Response.json({hi: "there"});
|
|
67
|
-
* console.assert(
|
|
68
|
-
* await response.text(),
|
|
69
|
-
* `{"hi":"there"}`
|
|
70
|
-
* );
|
|
71
|
-
* ```
|
|
72
|
-
* -------
|
|
73
|
-
*
|
|
74
|
-
* This is syntactic sugar for:
|
|
75
|
-
* ```js
|
|
76
|
-
* new Response(JSON.stringify(body), {headers: { "Content-Type": "application/json" }})
|
|
77
|
-
* ```
|
|
78
|
-
* @link https://github.com/whatwg/fetch/issues/1389
|
|
79
|
-
*/
|
|
80
|
-
json(body?: any, options?: Bun.ResponseInit | number): Response;
|
|
3
|
+
This file does not declare any global types.
|
|
81
4
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
* @param url - the URL to redirect to
|
|
86
|
-
* @param status - the HTTP status code to use for the redirect
|
|
87
|
-
*/
|
|
88
|
-
// tslint:disable-next-line:unified-signatures
|
|
89
|
-
redirect(url: string, status?: number): Response;
|
|
5
|
+
That should only happen in [./globals.d.ts](./globals.d.ts)
|
|
6
|
+
so that our documentation generator can pick it up, as it
|
|
7
|
+
expects all globals to be declared in one file.
|
|
90
8
|
|
|
91
|
-
|
|
92
|
-
* Create a new {@link Response} that redirects to url
|
|
93
|
-
*
|
|
94
|
-
* @param url - the URL to redirect to
|
|
95
|
-
* @param options - options to pass to the response
|
|
96
|
-
*/
|
|
97
|
-
// tslint:disable-next-line:unified-signatures
|
|
98
|
-
redirect(url: string, options?: Bun.ResponseInit): Response;
|
|
9
|
+
*/
|
|
99
10
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
error(): Response;
|
|
104
|
-
};
|
|
11
|
+
declare module "bun" {
|
|
12
|
+
type HeadersInit = string[][] | Record<string, string | ReadonlyArray<string>> | Headers;
|
|
13
|
+
type BodyInit = ReadableStream | Bun.XMLHttpRequestBodyInit | URLSearchParams | AsyncGenerator<Uint8Array>;
|
|
105
14
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
15
|
+
namespace __internal {
|
|
16
|
+
type LibOrFallbackHeaders = LibDomIsLoaded extends true ? {} : import("undici-types").Headers;
|
|
17
|
+
type LibOrFallbackRequest = LibDomIsLoaded extends true ? {} : import("undici-types").Request;
|
|
18
|
+
type LibOrFallbackResponse = LibDomIsLoaded extends true ? {} : import("undici-types").Response;
|
|
19
|
+
type LibOrFallbackResponseInit = LibDomIsLoaded extends true ? {} : import("undici-types").ResponseInit;
|
|
20
|
+
type LibOrFallbackRequestInit = LibDomIsLoaded extends true
|
|
21
|
+
? {}
|
|
22
|
+
: Omit<import("undici-types").RequestInit, "body" | "headers"> & {
|
|
23
|
+
body?: Bun.BodyInit | null | undefined;
|
|
24
|
+
headers?: Bun.HeadersInit;
|
|
25
|
+
};
|
|
118
26
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
tls?: BunFetchRequestInitTLS;
|
|
131
|
-
}
|
|
27
|
+
interface BunHeadersOverride extends LibOrFallbackHeaders {
|
|
28
|
+
/**
|
|
29
|
+
* Convert {@link Headers} to a plain JavaScript object.
|
|
30
|
+
*
|
|
31
|
+
* About 10x faster than `Object.fromEntries(headers.entries())`
|
|
32
|
+
*
|
|
33
|
+
* Called when you run `JSON.stringify(headers)`
|
|
34
|
+
*
|
|
35
|
+
* Does not preserve insertion order. Well-known header names are lowercased. Other header names are left as-is.
|
|
36
|
+
*/
|
|
37
|
+
toJSON(): Record<string, string>;
|
|
132
38
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
* @param request Request object
|
|
138
|
-
* @param init A structured value that contains settings for the fetch() request.
|
|
139
|
-
*
|
|
140
|
-
* @returns A promise that resolves to {@link Response} object.
|
|
141
|
-
*/
|
|
142
|
-
(request: Request, init?: BunFetchRequestInit): Promise<Response>;
|
|
39
|
+
/**
|
|
40
|
+
* Get the total number of headers
|
|
41
|
+
*/
|
|
42
|
+
readonly count: number;
|
|
143
43
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Get all headers matching the name
|
|
46
|
+
*
|
|
47
|
+
* Only supports `"Set-Cookie"`. All other headers are empty arrays.
|
|
48
|
+
*
|
|
49
|
+
* @param name - The header name to get
|
|
50
|
+
*
|
|
51
|
+
* @returns An array of header values
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* const headers = new Headers();
|
|
56
|
+
* headers.append("Set-Cookie", "foo=bar");
|
|
57
|
+
* headers.append("Set-Cookie", "baz=qux");
|
|
58
|
+
* headers.getAll("Set-Cookie"); // ["foo=bar", "baz=qux"]
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
getAll(name: "set-cookie" | "Set-Cookie"): string[];
|
|
62
|
+
}
|
|
153
63
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
): Promise<Response>;
|
|
64
|
+
interface BunRequestOverride extends LibOrFallbackRequest {
|
|
65
|
+
headers: BunHeadersOverride;
|
|
66
|
+
}
|
|
158
67
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
* long-running task that will delay the request starting.
|
|
165
|
-
*
|
|
166
|
-
* This is a bun-specific API and is not part of the Fetch API specification.
|
|
167
|
-
*/
|
|
168
|
-
preconnect(url: string | URL): void;
|
|
169
|
-
};
|
|
68
|
+
interface BunResponseOverride extends LibOrFallbackResponse {
|
|
69
|
+
headers: BunHeadersOverride;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|