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/bun.ns.d.ts
ADDED
package/deprecated.d.ts
CHANGED
|
@@ -1,71 +1,66 @@
|
|
|
1
1
|
declare module "bun" {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* File path to a TLS certificate
|
|
17
|
-
*
|
|
18
|
-
* To enable TLS, this option is required.
|
|
19
|
-
*
|
|
20
|
-
* @deprecated since v0.6.3 - Use `cert: Bun.file(path)` instead.
|
|
21
|
-
*/
|
|
22
|
-
certFile?: string;
|
|
23
|
-
/**
|
|
24
|
-
* File path to a .pem file for a custom root CA
|
|
25
|
-
*
|
|
26
|
-
* @deprecated since v0.6.3 - Use `ca: Bun.file(path)` instead.
|
|
27
|
-
*/
|
|
28
|
-
caFile?: string;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
2
|
+
interface BunMessageEvent<T> {
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated
|
|
5
|
+
*/
|
|
6
|
+
initMessageEvent(
|
|
7
|
+
type: string,
|
|
8
|
+
bubbles?: boolean,
|
|
9
|
+
cancelable?: boolean,
|
|
10
|
+
data?: any,
|
|
11
|
+
origin?: string,
|
|
12
|
+
lastEventId?: string,
|
|
13
|
+
source?: null,
|
|
14
|
+
): void;
|
|
15
|
+
}
|
|
31
16
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Renamed to `ErrorLike`
|
|
19
|
+
*/
|
|
20
|
+
type Errorlike = ErrorLike;
|
|
21
|
+
interface TLSOptions {
|
|
22
|
+
/**
|
|
23
|
+
* File path to a TLS key
|
|
24
|
+
*
|
|
25
|
+
* To enable TLS, this option is required.
|
|
26
|
+
*
|
|
27
|
+
* @deprecated since v0.6.3 - Use `key: Bun.file(path)` instead.
|
|
28
|
+
*/
|
|
29
|
+
keyFile?: string;
|
|
30
|
+
/**
|
|
31
|
+
* File path to a TLS certificate
|
|
32
|
+
*
|
|
33
|
+
* To enable TLS, this option is required.
|
|
34
|
+
*
|
|
35
|
+
* @deprecated since v0.6.3 - Use `cert: Bun.file(path)` instead.
|
|
36
|
+
*/
|
|
37
|
+
certFile?: string;
|
|
38
|
+
/**
|
|
39
|
+
* File path to a .pem file for a custom root CA
|
|
40
|
+
*
|
|
41
|
+
* @deprecated since v0.6.3 - Use `ca: Bun.file(path)` instead.
|
|
42
|
+
*/
|
|
43
|
+
caFile?: string;
|
|
44
|
+
}
|
|
39
45
|
}
|
|
40
46
|
|
|
41
|
-
declare namespace
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
data?: any,
|
|
49
|
-
origin?: string,
|
|
50
|
-
lastEventId?: string,
|
|
51
|
-
source?: null,
|
|
52
|
-
): void;
|
|
53
|
-
}
|
|
47
|
+
declare namespace NodeJS {
|
|
48
|
+
interface Process {
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated This is deprecated; use the "node:assert" module instead.
|
|
51
|
+
*/
|
|
52
|
+
assert(value: unknown, message?: string | Error): asserts value;
|
|
53
|
+
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
interface CustomEvent<T = any> {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
type: string,
|
|
60
|
-
bubbles?: boolean,
|
|
61
|
-
cancelable?: boolean,
|
|
62
|
-
detail?: T,
|
|
63
|
-
): void;
|
|
57
|
+
/** @deprecated */
|
|
58
|
+
initCustomEvent(type: string, bubbles?: boolean, cancelable?: boolean, detail?: T): void;
|
|
64
59
|
}
|
|
65
60
|
|
|
66
61
|
interface DOMException {
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
/** @deprecated */
|
|
63
|
+
readonly code: number;
|
|
69
64
|
}
|
|
70
65
|
|
|
71
66
|
/**
|
package/devserver.d.ts
CHANGED
|
@@ -1,195 +1,189 @@
|
|
|
1
|
-
|
|
1
|
+
declare module "bun" {
|
|
2
|
+
type HMREventNames =
|
|
3
|
+
| "beforeUpdate"
|
|
4
|
+
| "afterUpdate"
|
|
5
|
+
| "beforeFullReload"
|
|
6
|
+
| "beforePrune"
|
|
7
|
+
| "invalidate"
|
|
8
|
+
| "error"
|
|
9
|
+
| "ws:disconnect"
|
|
10
|
+
| "ws:connect";
|
|
2
11
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
| "bun:afterUpdate"
|
|
9
|
-
| "bun:beforeFullReload"
|
|
10
|
-
| "bun:beforePrune"
|
|
11
|
-
| "bun:invalidate"
|
|
12
|
-
| "bun:error"
|
|
13
|
-
| "bun:ws:disconnect"
|
|
14
|
-
| "bun:ws:connect";
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The event names for the dev server
|
|
18
|
-
*/
|
|
19
|
-
type HMREvent = `bun:${HMREventNames}` | (string & {});
|
|
20
|
-
}
|
|
12
|
+
/**
|
|
13
|
+
* The event names for the dev server
|
|
14
|
+
*/
|
|
15
|
+
type HMREvent = `bun:${HMREventNames}` | (string & {});
|
|
16
|
+
}
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
18
|
+
interface ImportMeta {
|
|
19
|
+
/**
|
|
20
|
+
* Hot module replacement APIs. This value is `undefined` in production and
|
|
21
|
+
* can be used in an `if` statement to check if HMR APIs are available
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* if (import.meta.hot) {
|
|
25
|
+
* // HMR APIs are available
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* However, this check is usually not needed as Bun will dead-code-eliminate
|
|
30
|
+
* calls to all of the HMR APIs in production builds.
|
|
31
|
+
*
|
|
32
|
+
* https://bun.sh/docs/bundler/hmr
|
|
33
|
+
*/
|
|
34
|
+
hot: {
|
|
35
|
+
/**
|
|
36
|
+
* `import.meta.hot.data` maintains state between module instances during
|
|
37
|
+
* hot replacement, enabling data transfer from previous to new versions.
|
|
38
|
+
* When `import.meta.hot.data` is written to, Bun will mark this module as
|
|
39
|
+
* capable of self-accepting (equivalent of calling `accept()`).
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const root = import.meta.hot.data.root ??= createRoot(elem);
|
|
44
|
+
* root.render(<App />); // re-use an existing root
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* In production, `data` is inlined to be `{}`. This is handy because Bun
|
|
48
|
+
* knows it can minify `{}.prop ??= value` into `value` in production.
|
|
49
|
+
*
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
data: any;
|
|
55
53
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Indicate that this module can be replaced simply by re-evaluating the
|
|
56
|
+
* file. After a hot update, importers of this module will be
|
|
57
|
+
* automatically patched.
|
|
58
|
+
*
|
|
59
|
+
* When `import.meta.hot.accept` is not used, the page will reload when
|
|
60
|
+
* the file updates, and a console message shows which files were checked.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* import { getCount } from "./foo";
|
|
65
|
+
*
|
|
66
|
+
* console.log("count is ", getCount());
|
|
67
|
+
*
|
|
68
|
+
* import.meta.hot.accept();
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
accept(): void;
|
|
74
72
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Indicate that this module can be replaced by evaluating the new module,
|
|
75
|
+
* and then calling the callback with the new module. In this mode, the
|
|
76
|
+
* importers do not get patched. This is to match Vite, which is unable
|
|
77
|
+
* to patch their import statements. Prefer using `import.meta.hot.accept()`
|
|
78
|
+
* without an argument as it usually makes your code easier to understand.
|
|
79
|
+
*
|
|
80
|
+
* When `import.meta.hot.accept` is not used, the page will reload when
|
|
81
|
+
* the file updates, and a console message shows which files were checked.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* export const count = 0;
|
|
86
|
+
*
|
|
87
|
+
* import.meta.hot.accept((newModule) => {
|
|
88
|
+
* if (newModule) {
|
|
89
|
+
* // newModule is undefined when SyntaxError happened
|
|
90
|
+
* console.log('updated: count is now ', newModule.count)
|
|
91
|
+
* }
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* In production, calls to this are dead-code-eliminated.
|
|
96
|
+
*/
|
|
97
|
+
accept(cb: (newModule: any | undefined) => void): void;
|
|
100
98
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Indicate that a dependency's module can be accepted. When the dependency
|
|
101
|
+
* is updated, the callback will be called with the new module.
|
|
102
|
+
*
|
|
103
|
+
* When `import.meta.hot.accept` is not used, the page will reload when
|
|
104
|
+
* the file updates, and a console message shows which files were checked.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* import.meta.hot.accept('./foo', (newModule) => {
|
|
109
|
+
* if (newModule) {
|
|
110
|
+
* // newModule is undefined when SyntaxError happened
|
|
111
|
+
* console.log('updated: count is now ', newModule.count)
|
|
112
|
+
* }
|
|
113
|
+
* });
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
accept(specifier: string, callback: (newModule: any) => void): void;
|
|
119
117
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
specifiers: string[],
|
|
130
|
-
callback: (newModules: (any | undefined)[]) => void,
|
|
131
|
-
): void;
|
|
118
|
+
/**
|
|
119
|
+
* Indicate that a dependency's module can be accepted. This variant
|
|
120
|
+
* accepts an array of dependencies, where the callback will receive
|
|
121
|
+
* the one updated module, and `undefined` for the rest.
|
|
122
|
+
*
|
|
123
|
+
* When `import.meta.hot.accept` is not used, the page will reload when
|
|
124
|
+
* the file updates, and a console message shows which files were checked.
|
|
125
|
+
*/
|
|
126
|
+
accept(specifiers: string[], callback: (newModules: (any | undefined)[]) => void): void;
|
|
132
127
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
128
|
+
/**
|
|
129
|
+
* Attach an on-dispose callback. This is called:
|
|
130
|
+
* - Just before the module is replaced with another copy (before the next is loaded)
|
|
131
|
+
* - After the module is detached (removing all imports to this module)
|
|
132
|
+
*
|
|
133
|
+
* This callback is not called on route navigation or when the browser tab closes.
|
|
134
|
+
*
|
|
135
|
+
* Returning a promise will delay module replacement until the module is
|
|
136
|
+
* disposed. All dispose callbacks are called in parallel.
|
|
137
|
+
*/
|
|
138
|
+
dispose(cb: (data: any) => void | Promise<void>): void;
|
|
144
139
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
140
|
+
/**
|
|
141
|
+
* No-op
|
|
142
|
+
* @deprecated
|
|
143
|
+
*/
|
|
144
|
+
decline(): void;
|
|
150
145
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
146
|
+
// NOTE TO CONTRIBUTORS ////////////////////////////////////////
|
|
147
|
+
// Callback is currently never called for `.prune()` //
|
|
148
|
+
// so the types are commented out until we support it. //
|
|
149
|
+
////////////////////////////////////////////////////////////////
|
|
150
|
+
// /**
|
|
151
|
+
// * Attach a callback that is called when the module is removed from the module graph.
|
|
152
|
+
// *
|
|
153
|
+
// * This can be used to clean up resources that were created when the module was loaded.
|
|
154
|
+
// * Unlike `import.meta.hot.dispose()`, this pairs much better with `accept` and `data` to manage stateful resources.
|
|
155
|
+
// *
|
|
156
|
+
// * @example
|
|
157
|
+
// * ```ts
|
|
158
|
+
// * export const ws = (import.meta.hot.data.ws ??= new WebSocket(location.origin));
|
|
159
|
+
// *
|
|
160
|
+
// * import.meta.hot.prune(() => {
|
|
161
|
+
// * ws.close();
|
|
162
|
+
// * });
|
|
163
|
+
// * ```
|
|
164
|
+
// */
|
|
165
|
+
// prune(callback: () => void): void;
|
|
171
166
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
167
|
+
/**
|
|
168
|
+
* Listen for an event from the dev server
|
|
169
|
+
*
|
|
170
|
+
* For compatibility with Vite, event names are also available via vite:* prefix instead of bun:*.
|
|
171
|
+
*
|
|
172
|
+
* https://bun.sh/docs/bundler/hmr#import-meta-hot-on-and-off
|
|
173
|
+
* @param event The event to listen to
|
|
174
|
+
* @param callback The callback to call when the event is emitted
|
|
175
|
+
*/
|
|
176
|
+
on(event: Bun.HMREvent, callback: () => void): void;
|
|
182
177
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
178
|
+
/**
|
|
179
|
+
* Stop listening for an event from the dev server
|
|
180
|
+
*
|
|
181
|
+
* For compatibility with Vite, event names are also available via vite:* prefix instead of bun:*.
|
|
182
|
+
*
|
|
183
|
+
* https://bun.sh/docs/bundler/hmr#import-meta-hot-on-and-off
|
|
184
|
+
* @param event The event to stop listening to
|
|
185
|
+
* @param callback The callback to stop listening to
|
|
186
|
+
*/
|
|
187
|
+
off(event: Bun.HMREvent, callback: () => void): void;
|
|
188
|
+
};
|
|
195
189
|
}
|