bun-types 1.1.44-canary.20250112T140558 → 1.1.44-canary.20250113T140648

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.
@@ -13,46 +13,70 @@ declare namespace HTMLRewriterTypes {
13
13
  }
14
14
 
15
15
  interface Text {
16
+ /** The text content */
16
17
  readonly text: string;
18
+ /** Whether this chunk is the last piece of text in a text node */
17
19
  readonly lastInTextNode: boolean;
20
+ /** Whether this chunk was removed */
18
21
  readonly removed: boolean;
22
+ /** Insert content before this chunk */
19
23
  before(content: Content, options?: ContentOptions): Text;
24
+ /** Insert content after this chunk */
20
25
  after(content: Content, options?: ContentOptions): Text;
26
+ /** Replace this chunk with new content */
21
27
  replace(content: Content, options?: ContentOptions): Text;
28
+ /** Remove this chunk */
22
29
  remove(): Text;
23
30
  }
24
31
 
25
32
  interface Doctype {
33
+ /** The doctype name (e.g. "html" for <!DOCTYPE html>) */
26
34
  readonly name: string | null;
35
+ /** The doctype public identifier */
27
36
  readonly publicId: string | null;
37
+ /** The doctype system identifier */
28
38
  readonly systemId: string | null;
39
+ /** Whether this doctype was removed */
29
40
  readonly removed: boolean;
41
+ /** Remove this doctype */
30
42
  remove(): Doctype;
31
43
  }
32
44
 
33
45
  interface DocumentEnd {
46
+ /** Append content at the end of the document */
34
47
  append(content: Content, options?: ContentOptions): DocumentEnd;
35
48
  }
36
49
 
37
50
  interface ContentOptions {
51
+ /** Whether to parse the content as HTML */
38
52
  html?: boolean;
39
53
  }
54
+
40
55
  type Content = string;
41
56
 
42
57
  interface Comment {
58
+ /** The comment text */
43
59
  text: string;
60
+ /** Whether this comment was removed */
44
61
  readonly removed: boolean;
62
+ /** Insert content before this comment */
45
63
  before(content: Content, options?: ContentOptions): Comment;
64
+ /** Insert content after this comment */
46
65
  after(content: Content, options?: ContentOptions): Comment;
66
+ /** Replace this comment with new content */
47
67
  replace(content: Content, options?: ContentOptions): Comment;
68
+ /** Remove this comment */
48
69
  remove(): Comment;
49
70
  }
50
71
 
51
72
  interface Element {
73
+ /** The tag name in lowercase (e.g. "div", "span") */
52
74
  tagName: string;
75
+ /** Iterator for the element's attributes */
53
76
  readonly attributes: IterableIterator<[string, string]>;
77
+ /** Whether this element was removed */
54
78
  readonly removed: boolean;
55
- /** Whether the element is explicitly self-closing, e.g. `<foo />` */
79
+ /** Whether the element is explicitly self-closing, e.g. <foo /> */
56
80
  readonly selfClosing: boolean;
57
81
  /**
58
82
  * Whether the element can have inner content. Returns `true` unless
@@ -60,26 +84,44 @@ declare namespace HTMLRewriterTypes {
60
84
  * - or it's self-closing in a foreign context (eg. in SVG, MathML).
61
85
  */
62
86
  readonly canHaveContent: boolean;
87
+ /** The element's namespace URI */
63
88
  readonly namespaceURI: string;
89
+ /** Get an attribute value by name */
64
90
  getAttribute(name: string): string | null;
91
+ /** Check if an attribute exists */
65
92
  hasAttribute(name: string): boolean;
93
+ /** Set an attribute value */
66
94
  setAttribute(name: string, value: string): Element;
95
+ /** Remove an attribute */
67
96
  removeAttribute(name: string): Element;
97
+ /** Insert content before this element */
68
98
  before(content: Content, options?: ContentOptions): Element;
99
+ /** Insert content after this element */
69
100
  after(content: Content, options?: ContentOptions): Element;
101
+ /** Insert content at the start of this element */
70
102
  prepend(content: Content, options?: ContentOptions): Element;
103
+ /** Insert content at the end of this element */
71
104
  append(content: Content, options?: ContentOptions): Element;
105
+ /** Replace this element with new content */
72
106
  replace(content: Content, options?: ContentOptions): Element;
107
+ /** Remove this element and its contents */
73
108
  remove(): Element;
109
+ /** Remove this element but keep its contents */
74
110
  removeAndKeepContent(): Element;
111
+ /** Set the inner content of this element */
75
112
  setInnerContent(content: Content, options?: ContentOptions): Element;
113
+ /** Add a handler for the end tag of this element */
76
114
  onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
77
115
  }
78
116
 
79
117
  interface EndTag {
118
+ /** The tag name in lowercase */
80
119
  name: string;
120
+ /** Insert content before this end tag */
81
121
  before(content: Content, options?: ContentOptions): EndTag;
122
+ /** Insert content after this end tag */
82
123
  after(content: Content, options?: ContentOptions): EndTag;
124
+ /** Remove this end tag */
83
125
  remove(): EndTag;
84
126
  }
85
127
  }
@@ -108,24 +150,38 @@ declare namespace HTMLRewriterTypes {
108
150
  */
109
151
  declare class HTMLRewriter {
110
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
+ */
111
158
  on(
112
159
  selector: string,
113
160
  handlers: HTMLRewriterTypes.HTMLRewriterElementContentHandlers,
114
161
  ): HTMLRewriter;
162
+
163
+ /**
164
+ * Add handlers for document-level events
165
+ * @param handlers - Object containing handler functions for doctype, comments, text nodes and document end
166
+ */
115
167
  onDocument(
116
168
  handlers: HTMLRewriterTypes.HTMLRewriterDocumentContentHandlers,
117
169
  ): HTMLRewriter;
170
+
118
171
  /**
172
+ * Transform HTML content
119
173
  * @param input - The HTML to transform
120
174
  * @returns A new {@link Response} with the transformed HTML
121
175
  */
122
176
  transform(input: Response | Blob | Bun.BufferSource): Response;
123
177
  /**
178
+ * Transform HTML content
124
179
  * @param input - The HTML string to transform
125
180
  * @returns A new {@link String} containing the transformed HTML
126
181
  */
127
182
  transform(input: string): string;
128
183
  /**
184
+ * Transform HTML content
129
185
  * @param input - The HTML to transform as a {@link ArrayBuffer}
130
186
  * @returns A new {@link ArrayBuffer} with the transformed HTML
131
187
  */
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.44-canary.20250112T140558",
2
+ "version": "1.1.44-canary.20250113T140648",
3
3
  "name": "bun-types",
4
4
  "license": "MIT",
5
5
  "main": "",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "scripts": {
26
26
  "prebuild": "echo $(pwd)",
27
- "copy-docs": "rm -rf docs && cp -r ../../docs/ ./docs",
27
+ "copy-docs": "rm -rf docs && cp -rL ../../docs/ ./docs && sed -i 's/\\$BUN_LATEST_VERSION/'\"${BUN_VERSION:-1.0.0}\"'/g' ./docs/**/*.md",
28
28
  "build": "bun run copy-docs && bun scripts/build.ts && bun run fmt",
29
29
  "test": "tsc",
30
30
  "fmt": "echo $(which biome) && biome format --write ."