bun-types 1.2.6 → 1.2.8-canary.20250327T140605
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 +7187 -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/html-rewriter.d.ts
CHANGED
|
@@ -1,129 +1,129 @@
|
|
|
1
1
|
declare namespace HTMLRewriterTypes {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
interface HTMLRewriterElementContentHandlers {
|
|
3
|
+
element?(element: Element): void | Promise<void>;
|
|
4
|
+
comments?(comment: Comment): void | Promise<void>;
|
|
5
|
+
text?(text: Text): void | Promise<void>;
|
|
6
|
+
}
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
interface HTMLRewriterDocumentContentHandlers {
|
|
9
|
+
doctype?(doctype: Doctype): void | Promise<void>;
|
|
10
|
+
comments?(comment: Comment): void | Promise<void>;
|
|
11
|
+
text?(text: Text): void | Promise<void>;
|
|
12
|
+
end?(end: DocumentEnd): void | Promise<void>;
|
|
13
|
+
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
15
|
+
interface Text {
|
|
16
|
+
/** The text content */
|
|
17
|
+
readonly text: string;
|
|
18
|
+
/** Whether this chunk is the last piece of text in a text node */
|
|
19
|
+
readonly lastInTextNode: boolean;
|
|
20
|
+
/** Whether this chunk was removed */
|
|
21
|
+
readonly removed: boolean;
|
|
22
|
+
/** Insert content before this chunk */
|
|
23
|
+
before(content: Content, options?: ContentOptions): Text;
|
|
24
|
+
/** Insert content after this chunk */
|
|
25
|
+
after(content: Content, options?: ContentOptions): Text;
|
|
26
|
+
/** Replace this chunk with new content */
|
|
27
|
+
replace(content: Content, options?: ContentOptions): Text;
|
|
28
|
+
/** Remove this chunk */
|
|
29
|
+
remove(): Text;
|
|
30
|
+
}
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
interface Doctype {
|
|
33
|
+
/** The doctype name (e.g. "html" for <!DOCTYPE html>) */
|
|
34
|
+
readonly name: string | null;
|
|
35
|
+
/** The doctype public identifier */
|
|
36
|
+
readonly publicId: string | null;
|
|
37
|
+
/** The doctype system identifier */
|
|
38
|
+
readonly systemId: string | null;
|
|
39
|
+
/** Whether this doctype was removed */
|
|
40
|
+
readonly removed: boolean;
|
|
41
|
+
/** Remove this doctype */
|
|
42
|
+
remove(): Doctype;
|
|
43
|
+
}
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
interface DocumentEnd {
|
|
46
|
+
/** Append content at the end of the document */
|
|
47
|
+
append(content: Content, options?: ContentOptions): DocumentEnd;
|
|
48
|
+
}
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
interface ContentOptions {
|
|
51
|
+
/** Whether to parse the content as HTML */
|
|
52
|
+
html?: boolean;
|
|
53
|
+
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
type Content = string;
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
57
|
+
interface Comment {
|
|
58
|
+
/** The comment text */
|
|
59
|
+
text: string;
|
|
60
|
+
/** Whether this comment was removed */
|
|
61
|
+
readonly removed: boolean;
|
|
62
|
+
/** Insert content before this comment */
|
|
63
|
+
before(content: Content, options?: ContentOptions): Comment;
|
|
64
|
+
/** Insert content after this comment */
|
|
65
|
+
after(content: Content, options?: ContentOptions): Comment;
|
|
66
|
+
/** Replace this comment with new content */
|
|
67
|
+
replace(content: Content, options?: ContentOptions): Comment;
|
|
68
|
+
/** Remove this comment */
|
|
69
|
+
remove(): Comment;
|
|
70
|
+
}
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
72
|
+
interface Element {
|
|
73
|
+
/** The tag name in lowercase (e.g. "div", "span") */
|
|
74
|
+
tagName: string;
|
|
75
|
+
/** Iterator for the element's attributes */
|
|
76
|
+
readonly attributes: IterableIterator<[string, string]>;
|
|
77
|
+
/** Whether this element was removed */
|
|
78
|
+
readonly removed: boolean;
|
|
79
|
+
/** Whether the element is explicitly self-closing, e.g. <foo /> */
|
|
80
|
+
readonly selfClosing: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Whether the element can have inner content. Returns `true` unless
|
|
83
|
+
* - the element is an [HTML void element](https://html.spec.whatwg.org/multipage/syntax.html#void-elements)
|
|
84
|
+
* - or it's self-closing in a foreign context (eg. in SVG, MathML).
|
|
85
|
+
*/
|
|
86
|
+
readonly canHaveContent: boolean;
|
|
87
|
+
/** The element's namespace URI */
|
|
88
|
+
readonly namespaceURI: string;
|
|
89
|
+
/** Get an attribute value by name */
|
|
90
|
+
getAttribute(name: string): string | null;
|
|
91
|
+
/** Check if an attribute exists */
|
|
92
|
+
hasAttribute(name: string): boolean;
|
|
93
|
+
/** Set an attribute value */
|
|
94
|
+
setAttribute(name: string, value: string): Element;
|
|
95
|
+
/** Remove an attribute */
|
|
96
|
+
removeAttribute(name: string): Element;
|
|
97
|
+
/** Insert content before this element */
|
|
98
|
+
before(content: Content, options?: ContentOptions): Element;
|
|
99
|
+
/** Insert content after this element */
|
|
100
|
+
after(content: Content, options?: ContentOptions): Element;
|
|
101
|
+
/** Insert content at the start of this element */
|
|
102
|
+
prepend(content: Content, options?: ContentOptions): Element;
|
|
103
|
+
/** Insert content at the end of this element */
|
|
104
|
+
append(content: Content, options?: ContentOptions): Element;
|
|
105
|
+
/** Replace this element with new content */
|
|
106
|
+
replace(content: Content, options?: ContentOptions): Element;
|
|
107
|
+
/** Remove this element and its contents */
|
|
108
|
+
remove(): Element;
|
|
109
|
+
/** Remove this element but keep its contents */
|
|
110
|
+
removeAndKeepContent(): Element;
|
|
111
|
+
/** Set the inner content of this element */
|
|
112
|
+
setInnerContent(content: Content, options?: ContentOptions): Element;
|
|
113
|
+
/** Add a handler for the end tag of this element */
|
|
114
|
+
onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
|
|
115
|
+
}
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
117
|
+
interface EndTag {
|
|
118
|
+
/** The tag name in lowercase */
|
|
119
|
+
name: string;
|
|
120
|
+
/** Insert content before this end tag */
|
|
121
|
+
before(content: Content, options?: ContentOptions): EndTag;
|
|
122
|
+
/** Insert content after this end tag */
|
|
123
|
+
after(content: Content, options?: ContentOptions): EndTag;
|
|
124
|
+
/** Remove this end tag */
|
|
125
|
+
remove(): EndTag;
|
|
126
|
+
}
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
/**
|
|
@@ -149,41 +149,36 @@ declare namespace HTMLRewriterTypes {
|
|
|
149
149
|
* ```
|
|
150
150
|
*/
|
|
151
151
|
declare class HTMLRewriter {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
selector: string,
|
|
160
|
-
handlers: HTMLRewriterTypes.HTMLRewriterElementContentHandlers,
|
|
161
|
-
): HTMLRewriter;
|
|
152
|
+
constructor();
|
|
153
|
+
/**
|
|
154
|
+
* Add handlers for elements matching a CSS selector
|
|
155
|
+
* @param selector - A CSS selector (e.g. "div", "a[href]", ".class")
|
|
156
|
+
* @param handlers - Object containing handler functions for elements, comments, and text nodes
|
|
157
|
+
*/
|
|
158
|
+
on(selector: string, handlers: HTMLRewriterTypes.HTMLRewriterElementContentHandlers): HTMLRewriter;
|
|
162
159
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
handlers: HTMLRewriterTypes.HTMLRewriterDocumentContentHandlers,
|
|
169
|
-
): HTMLRewriter;
|
|
160
|
+
/**
|
|
161
|
+
* Add handlers for document-level events
|
|
162
|
+
* @param handlers - Object containing handler functions for doctype, comments, text nodes and document end
|
|
163
|
+
*/
|
|
164
|
+
onDocument(handlers: HTMLRewriterTypes.HTMLRewriterDocumentContentHandlers): HTMLRewriter;
|
|
170
165
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Transform HTML content
|
|
168
|
+
* @param input - The HTML to transform
|
|
169
|
+
* @returns A new {@link Response} with the transformed HTML
|
|
170
|
+
*/
|
|
171
|
+
transform(input: Response | Blob | Bun.BufferSource): Response;
|
|
172
|
+
/**
|
|
173
|
+
* Transform HTML content
|
|
174
|
+
* @param input - The HTML string to transform
|
|
175
|
+
* @returns A new {@link String} containing the transformed HTML
|
|
176
|
+
*/
|
|
177
|
+
transform(input: string): string;
|
|
178
|
+
/**
|
|
179
|
+
* Transform HTML content
|
|
180
|
+
* @param input - The HTML to transform as a {@link ArrayBuffer}
|
|
181
|
+
* @returns A new {@link ArrayBuffer} with the transformed HTML
|
|
182
|
+
*/
|
|
183
|
+
transform(input: ArrayBuffer): ArrayBuffer;
|
|
189
184
|
}
|
package/index.d.ts
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
// Project: https://github.com/oven-sh/bun
|
|
2
|
-
// Definitions by:
|
|
2
|
+
// Definitions by: Bun Contributors <https://github.com/oven-sh/bun/graphs/contributors>
|
|
3
3
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
4
4
|
|
|
5
|
-
/// <reference lib="esnext" />
|
|
6
|
-
/// <reference types="ws" />
|
|
7
5
|
/// <reference types="node" />
|
|
8
6
|
|
|
9
|
-
// contributors: uncomment this to detect conflicts with lib.dom.d.ts
|
|
10
|
-
// /// <reference lib="dom" />
|
|
11
|
-
|
|
12
|
-
/// <reference path="./bun.d.ts" />
|
|
13
7
|
/// <reference path="./globals.d.ts" />
|
|
8
|
+
/// <reference path="./s3.d.ts" />
|
|
14
9
|
/// <reference path="./fetch.d.ts" />
|
|
15
|
-
/// <reference path="./
|
|
10
|
+
/// <reference path="./bun.d.ts" />
|
|
11
|
+
/// <reference path="./extensions.d.ts" />
|
|
12
|
+
/// <reference path="./devserver.d.ts" />
|
|
16
13
|
/// <reference path="./ffi.d.ts" />
|
|
17
|
-
/// <reference path="./test.d.ts" />
|
|
18
14
|
/// <reference path="./html-rewriter.d.ts" />
|
|
19
15
|
/// <reference path="./jsc.d.ts" />
|
|
20
16
|
/// <reference path="./sqlite.d.ts" />
|
|
17
|
+
/// <reference path="./test.d.ts" />
|
|
21
18
|
/// <reference path="./wasm.d.ts" />
|
|
19
|
+
/// <reference path="./overrides.d.ts" />
|
|
22
20
|
/// <reference path="./deprecated.d.ts" />
|
|
23
|
-
|
|
24
|
-
/// <reference path="./
|
|
21
|
+
|
|
22
|
+
/// <reference path="./bun.ns.d.ts" />
|
|
23
|
+
|
|
24
|
+
// @ts-ignore Must disable this so it doesn't conflict with the DOM onmessage type, but still
|
|
25
|
+
// allows us to declare our own globals that Node's types can "see" and not conflict with
|
|
26
|
+
declare var onmessage: never;
|