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.
@@ -1,129 +1,129 @@
1
1
  declare namespace HTMLRewriterTypes {
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
- }
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
- 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
- }
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
- 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
- }
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
- 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
- }
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
- interface DocumentEnd {
46
- /** Append content at the end of the document */
47
- append(content: Content, options?: ContentOptions): DocumentEnd;
48
- }
45
+ interface DocumentEnd {
46
+ /** Append content at the end of the document */
47
+ append(content: Content, options?: ContentOptions): DocumentEnd;
48
+ }
49
49
 
50
- interface ContentOptions {
51
- /** Whether to parse the content as HTML */
52
- html?: boolean;
53
- }
50
+ interface ContentOptions {
51
+ /** Whether to parse the content as HTML */
52
+ html?: boolean;
53
+ }
54
54
 
55
- type Content = string;
55
+ type Content = string;
56
56
 
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
- }
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
- 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
- }
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
- 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
- }
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
- 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(
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
- * Add handlers for document-level events
165
- * @param handlers - Object containing handler functions for doctype, comments, text nodes and document end
166
- */
167
- onDocument(
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
- * Transform HTML content
173
- * @param input - The HTML to transform
174
- * @returns A new {@link Response} with the transformed HTML
175
- */
176
- transform(input: Response | Blob | Bun.BufferSource): Response;
177
- /**
178
- * Transform HTML content
179
- * @param input - The HTML string to transform
180
- * @returns A new {@link String} containing the transformed HTML
181
- */
182
- transform(input: string): string;
183
- /**
184
- * Transform HTML content
185
- * @param input - The HTML to transform as a {@link ArrayBuffer}
186
- * @returns A new {@link ArrayBuffer} with the transformed HTML
187
- */
188
- transform(input: ArrayBuffer): ArrayBuffer;
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: Jarred Sumner <https://github.com/Jarred-Sumner>
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="./overrides.d.ts" />
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
- /// <reference path="./ambient.d.ts" />
24
- /// <reference path="./devserver.d.ts" />
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;