html-element-registry 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 html-element-registry contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,213 @@
1
+ # html-element-registry
2
+
3
+ > A lightweight, type-safe npm library containing a scraped database of all standard HTML elements.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/html-element-registry.svg)](https://www.npmjs.com/package/html-element-registry)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## Features
9
+
10
+ - 📦 **Comprehensive Database** - All standard HTML elements scraped from MDN Web Docs
11
+ - 🔍 **Type-Safe** - Full TypeScript support with detailed type definitions
12
+ - 🎯 **Element Classification** - Query elements by type (block, inline, table, form, etc.)
13
+ - 🏷️ **Category Support** - Access MDN content categories for each element
14
+ - ⚡ **Zero Runtime Dependencies** - Pure data, no external runtime dependencies
15
+ - 🔒 **Immutable** - All returned data is immutable to prevent accidental mutations
16
+ - 🤖 **Auto-Updated** - Weekly automated scraping keeps data fresh
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install html-element-registry
22
+ ```
23
+
24
+ ```bash
25
+ yarn add html-element-registry
26
+ ```
27
+
28
+ ```bash
29
+ pnpm add html-element-registry
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ ### Basic Element Lookup
35
+
36
+ ```typescript
37
+ import { getElement } from 'html-element-registry';
38
+
39
+ const div = getElement('div');
40
+ console.log(div);
41
+ // {
42
+ // tag: 'div',
43
+ // description: 'The generic container for flow content.',
44
+ // type: 'block',
45
+ // category: 'Text content',
46
+ // url: 'https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/div',
47
+ // isVoid: false
48
+ // }
49
+ ```
50
+
51
+ ### Type Checking
52
+
53
+ ```typescript
54
+ import { isBlock, isInline, isVoid, isForm } from 'html-element-registry';
55
+
56
+ isBlock('div'); // true
57
+ isInline('span'); // true
58
+ isVoid('img'); // true
59
+ isForm('input'); // true
60
+ ```
61
+
62
+ ### Filter by Type or Category
63
+
64
+ ```typescript
65
+ import { getElementsByType, getElementsByCategory } from 'html-element-registry';
66
+
67
+ // Get all form elements
68
+ const formElements = getElementsByType('form');
69
+ // [{ tag: 'button', ... }, { tag: 'input', ... }, ...]
70
+
71
+ // Get all elements in "Text content" category
72
+ const textElements = getElementsByCategory('Text content');
73
+ // [{ tag: 'div', ... }, { tag: 'p', ... }, ...]
74
+ ```
75
+
76
+ ### Get Metadata
77
+
78
+ ```typescript
79
+ import { getAllCategories, getAllTypes, getVoidElements } from 'html-element-registry';
80
+
81
+ // Get all unique categories
82
+ const categories = getAllCategories();
83
+ // ['Main root', 'Document metadata', 'Content sectioning', ...]
84
+
85
+ // Get all element types
86
+ const types = getAllTypes();
87
+ // ['block', 'inline', 'meta', 'table', 'form', ...]
88
+
89
+ // Get all void (self-closing) elements
90
+ const voidElements = getVoidElements();
91
+ // [{ tag: 'br', ... }, { tag: 'img', ... }, ...]
92
+ ```
93
+
94
+ ## API Reference
95
+
96
+ ### Element Lookup
97
+
98
+ - **`getElement(tagName: string): ElementSummary | null`**
99
+ Get an element by its tag name (case-insensitive). Returns a copy to prevent mutation.
100
+
101
+ ### Type Checkers
102
+
103
+ - **`isElementType(tag: string, type: ElementType): boolean`**
104
+ Check if an element matches a specific type.
105
+
106
+ - **`isBlock(tag: string): boolean`**
107
+ Check if element is block-level.
108
+
109
+ - **`isInline(tag: string): boolean`**
110
+ Check if element is inline.
111
+
112
+ - **`isMeta(tag: string): boolean`**
113
+ Check if element is metadata.
114
+
115
+ - **`isTable(tag: string): boolean`**
116
+ Check if element is table-related.
117
+
118
+ - **`isForm(tag: string): boolean`**
119
+ Check if element is form-related.
120
+
121
+ - **`isMultimedia(tag: string): boolean`**
122
+ Check if element is multimedia.
123
+
124
+ - **`isScript(tag: string): boolean`**
125
+ Check if element is script-related.
126
+
127
+ - **`isVoid(tag: string): boolean`**
128
+ Check if element is void (self-closing).
129
+
130
+ ### Filters
131
+
132
+ - **`getElementsByCategory(category: string): ElementSummary[]`**
133
+ Get all elements in a specific category (case-insensitive).
134
+
135
+ - **`getElementsByType(type: ElementType): ElementSummary[]`**
136
+ Get all elements of a specific type.
137
+
138
+ - **`getVoidElements(): ElementSummary[]`**
139
+ Get all void elements.
140
+
141
+ ### Metadata
142
+
143
+ - **`getAllCategories(): string[]`**
144
+ Get list of all unique categories.
145
+
146
+ - **`getAllTypes(): ElementType[]`**
147
+ Get list of all unique element types.
148
+
149
+ ## TypeScript Types
150
+
151
+ ```typescript
152
+ export type ElementType =
153
+ | 'block'
154
+ | 'inline'
155
+ | 'meta'
156
+ | 'root'
157
+ | 'body'
158
+ | 'multimedia'
159
+ | 'script'
160
+ | 'table'
161
+ | 'form';
162
+
163
+ export type ElementSummary = {
164
+ tag: string;
165
+ description: string;
166
+ url: string;
167
+ category: string;
168
+ type: ElementType;
169
+ isVoid: boolean;
170
+ };
171
+ ```
172
+
173
+ ## Data Source
174
+
175
+ All element data is scraped from [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements), the authoritative source for web standards documentation.
176
+
177
+ The scraper runs weekly via GitHub Actions to keep the data up-to-date with the latest HTML specifications.
178
+
179
+ ## Development
180
+
181
+ ```bash
182
+ # Install dependencies
183
+ npm install
184
+
185
+ # Run the scraper
186
+ npm run scrape
187
+
188
+ # Build the library
189
+ npm run build
190
+
191
+ # Run tests
192
+ npm test
193
+ ```
194
+
195
+ ## Contributing
196
+
197
+ Contributions are welcome! Please feel free to submit a Pull Request.
198
+
199
+ 1. Fork the repository
200
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
201
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
202
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
203
+ 5. Open a Pull Request
204
+
205
+ ## License
206
+
207
+ MIT © [html-element-registry contributors](LICENSE)
208
+
209
+ ## Acknowledgments
210
+
211
+ - Data sourced from [MDN Web Docs](https://developer.mozilla.org/)
212
+ - Built with [TypeScript](https://www.typescriptlang.org/)
213
+ - Bundled with [tsup](https://tsup.egoist.dev/)