@dooboostore/dom-parser 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/README.MD +47 -94
  2. package/package.json +3 -10
package/README.MD CHANGED
@@ -4,21 +4,20 @@
4
4
  [![Build and Test](https://github.com/dooboostore-develop/packages/actions/workflows/main.yaml/badge.svg?branch=main)](https://github.com/dooboostore-develop/packages/actions/workflows/main.yaml)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
6
6
 
7
- **Full Documentation:** [https://dooboostore-develop.github.io/packages/dom-parser](https://dooboostore-develop.github.io/packages/dom-parser)
7
+ **Full Documentation:** [https://dooboostore-develop.github.io/@dooboostore/dom-parser](https://dooboostore-develop.github.io/@dooboostore/dom-parser)
8
8
 
9
- A lightweight DOM parser for server-side HTML parsing and manipulation with full DOM API support. Features advanced JavaScript expression parsing for modern framework templates.
9
+ A lightweight DOM parser for server-side HTML parsing and manipulation with full DOM API support.
10
10
 
11
11
  ---
12
12
 
13
13
  ## Features
14
14
 
15
- - **🚀 Advanced JavaScript Expression Parsing**: Handles complex expressions like `${(data) => @this@?.handleChange?.(data)}$`
16
- - **ðŸŽŊ Framework Template Support**: Perfect for parsing modern framework templates with custom syntax
17
- - **⚡ Server-Side DOM**: Complete DOM implementation for Node.js environments without browser dependencies
18
- - **🔍 CSS Selector Queries**: Full support for `querySelector` and `querySelectorAll` with complex selectors
19
- - **ðŸ“Ķ Multi-Format Support**: Available as ESM, CJS, and UMD bundles
20
- - **ðŸ›Ąïļ TypeScript Support**: Full TypeScript definitions for type-safe development
21
- - **ðŸŠķ Lightweight**: Zero dependencies with fast parsing performance
15
+ - **⚡ Server-Side DOM**: Complete DOM implementation for Node.js environments
16
+ - **🔍 CSS Selector Support**: Full `querySelector` and `querySelectorAll` support
17
+ - **ðŸ“Ķ Multi-Format**: Available as ESM, CJS, and UMD bundles
18
+ - **ðŸ›Ąïļ TypeScript**: Full TypeScript definitions included
19
+ - **ðŸŠķ Zero Dependencies**: Lightweight with fast parsing performance
20
+ - **ðŸŽŊ HTML Templates**: Handles complex HTML templates and attributes
22
21
 
23
22
  ## Installation
24
23
 
@@ -80,40 +79,30 @@ global.window = window;
80
79
  global.document = document;
81
80
  ```
82
81
 
83
- ### Advanced: Framework Template Parsing
82
+ ### Template Processing
84
83
 
85
84
  ```typescript
86
85
  import { DomParser } from '@dooboostore/dom-parser';
87
86
 
88
- // Parse complex framework templates with JavaScript expressions
87
+ // Parse HTML templates with complex attributes
89
88
  const templateHtml = `
90
89
  <div class="container">
91
- <dr-select
92
- changeSelected="\${(data) => @this@?.handleSelectChange?.(data, #it#)}$"
93
- items="@this@.items"
94
- >
95
- <option value="1">Option 1</option>
96
- </dr-select>
97
- <dr-button
98
- onClick="\${() => @this@.submit?.()}$"
99
- disabled="@this@.loading ? 'true' : 'false'"
100
- >
101
- Submit
102
- </dr-button>
90
+ <button onclick="handleClick(data)" disabled="false">
91
+ Click Me
92
+ </button>
93
+ <input value="user.name" placeholder="Enter name" />
103
94
  </div>
104
95
  `;
105
96
 
106
97
  const parser = new DomParser(templateHtml);
107
98
  const document = parser.document;
108
99
 
109
- // Access complex attributes
110
- const select = document.querySelector('dr-select');
111
- console.log(select?.getAttribute('changeSelected'));
112
- // "${(data) => @this@?.handleSelectChange?.(data, #it#)}$"
100
+ // Access and modify elements
101
+ const button = document.querySelector('button');
102
+ console.log(button?.getAttribute('onclick')); // "handleClick(data)"
113
103
 
114
- const button = document.querySelector('dr-button');
115
- console.log(button?.getAttribute('onClick'));
116
- // "${() => @this@.submit?.()}$"
104
+ const input = document.querySelector('input');
105
+ input?.setAttribute('value', 'new value');
117
106
  ```
118
107
 
119
108
  ## API Reference
@@ -130,7 +119,13 @@ Creates a new DOM parser instance with the provided HTML string.
130
119
  **Parameters:**
131
120
  - `html`: HTML string to parse
132
121
  - `options`: Optional configuration object
133
- - `href?: string`: Base URL for the document
122
+
123
+ **DomParserOptions:**
124
+ ```typescript
125
+ interface DomParserOptions {
126
+ href?: string; // Base URL for the document
127
+ }
128
+ ```
134
129
 
135
130
  #### Properties
136
131
 
@@ -163,25 +158,7 @@ const h1 = document.querySelector('h1');
163
158
  console.log(h1?.textContent); // "Hello"
164
159
  ```
165
160
 
166
- ### Key Features
167
-
168
- #### 🚀 Advanced JavaScript Expression Support
169
-
170
- Handles complex JavaScript expressions that would break other parsers:
171
-
172
- ```typescript
173
- // ✅ Supported: Arrow functions with '>' operators
174
- changeSelected="${(data) => data.value > 0 ? data : null}$"
175
-
176
- // ✅ Supported: Ternary operators with nested expressions
177
- condition="${user?.role === 'admin' ? 'show' : 'hide'}$"
178
-
179
- // ✅ Supported: Framework-specific syntax
180
- items="@this@.items"
181
- handler="#item#.onClick"
182
- ```
183
-
184
- #### 🔍 Complete DOM API Support
161
+ ### Supported DOM APIs
185
162
 
186
163
  - `document.querySelector()` / `document.querySelectorAll()`
187
164
  - `document.getElementById()` / `document.getElementsByClassName()`
@@ -193,29 +170,30 @@ handler="#item#.onClick"
193
170
 
194
171
  ## Use Cases
195
172
 
196
- ### ðŸŽŊ Framework Template Processing
197
-
198
- Perfect for processing modern framework templates with complex JavaScript expressions:
173
+ ### ðŸŽŊ HTML Processing & Manipulation
199
174
 
200
175
  ```typescript
201
176
  import { DomParser } from '@dooboostore/dom-parser';
202
177
 
203
- // Parse framework components with complex expressions
204
- const componentHtml = `
205
- <my-component
206
- data-handler="\${(event) => @this@?.onEvent?.(event)}$"
207
- condition="@user@.isLoggedIn ? 'show' : 'hide'"
208
- >
209
- <nested-component items="@data@.items" />
210
- </my-component>
211
- `;
212
-
213
- const parser = new DomParser(componentHtml);
214
- const component = parser.document.querySelector('my-component');
215
-
216
- // Extract and process JavaScript expressions
217
- const handler = component?.getAttribute('data-handler');
218
- // Safely parse complex expressions without breaking on '>' characters
178
+ function processHtml(html: string) {
179
+ const parser = new DomParser(html);
180
+ const document = parser.document;
181
+
182
+ // Modify the DOM
183
+ const title = document.querySelector('title');
184
+ if (title) {
185
+ title.textContent = 'Processed Title';
186
+ }
187
+
188
+ // Add meta tags
189
+ const head = document.querySelector('head');
190
+ const meta = document.createElement('meta');
191
+ meta.setAttribute('name', 'description');
192
+ meta.setAttribute('content', 'Processed content');
193
+ head?.appendChild(meta);
194
+
195
+ return document.documentElement.outerHTML;
196
+ }
219
197
  ```
220
198
 
221
199
  ### 🔧 Server-Side Rendering (SSR)
@@ -243,37 +221,12 @@ global.document = parser.document;
243
221
  global.window = parser.window;
244
222
  ```
245
223
 
246
- ### 📝 HTML Processing & Manipulation
247
224
 
248
- ```typescript
249
- import { DomParser } from '@dooboostore/dom-parser';
250
-
251
- function processHtml(html: string) {
252
- const parser = new DomParser(html);
253
- const document = parser.document;
254
-
255
- // Modify the DOM
256
- const title = document.querySelector('title');
257
- if (title) {
258
- title.textContent = 'Processed Title';
259
- }
260
-
261
- // Add meta tags
262
- const head = document.querySelector('head');
263
- const meta = document.createElement('meta');
264
- meta.setAttribute('name', 'description');
265
- meta.setAttribute('content', 'Processed content');
266
- head?.appendChild(meta);
267
-
268
- return document.documentElement.outerHTML;
269
- }
270
- ```
271
225
 
272
226
  ## Learn More
273
227
 
274
228
  The detailed API documentation, including all supported DOM methods and usage examples, is available on our documentation website.
275
229
 
276
- **[Explore the full @dooboostore/dom-parser documentation &raquo;](https://dooboostore-develop.github.io/packages/dom-parser)**
277
230
 
278
231
  ## License
279
232
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dooboostore/dom-parser",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -17,7 +17,7 @@
17
17
  ]
18
18
  }
19
19
  },
20
- "description": "A lightweight DOM parser for server-side HTML parsing and manipulation with advanced JavaScript expression support for modern framework templates",
20
+ "description": "A lightweight DOM parser for server-side HTML parsing and manipulation with full DOM API support",
21
21
  "keywords": [
22
22
  "dom",
23
23
  "parser",
@@ -31,14 +31,7 @@
31
31
  "typescript",
32
32
  "node",
33
33
  "browser",
34
- "template",
35
- "framework",
36
- "javascript-expressions",
37
- "ssr",
38
- "template-parsing",
39
- "framework-templates",
40
- "arrow-functions",
41
- "complex-expressions"
34
+ "ssr"
42
35
  ],
43
36
  "files": [
44
37
  "dist",