@gjsify/domparser 0.4.43 → 0.5.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/README.md +34 -0
- package/package.json +4 -4
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# @gjsify/domparser
|
|
2
|
+
|
|
3
|
+
A minimal `DOMParser.parseFromString` implementation (XML/HTML) with a small DOM surface — `tagName`, `getAttribute`, `children`, `querySelector`/`querySelectorAll`, `textContent`, `innerHTML`. Sized for excalibur-tiled and simple config parsing; runs on GJS, Node.js, and browsers (where the native `DOMParser` is used instead).
|
|
4
|
+
|
|
5
|
+
Part of the [gjsify](https://github.com/gjsify/gjsify) project — Node.js and Web APIs for GJS (GNOME JavaScript).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
gjsify install @gjsify/domparser
|
|
11
|
+
|
|
12
|
+
# npm or yarn also work (e.g. adding it to an existing project):
|
|
13
|
+
npm install @gjsify/domparser
|
|
14
|
+
yarn add @gjsify/domparser
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { DOMParser } from '@gjsify/domparser';
|
|
21
|
+
|
|
22
|
+
const parser = new DOMParser();
|
|
23
|
+
const doc = parser.parseFromString('<map width="20" height="15"><layer name="bg"/></map>', 'text/xml');
|
|
24
|
+
|
|
25
|
+
const map = doc.querySelector('map');
|
|
26
|
+
console.log(map?.getAttribute('width')); // "20"
|
|
27
|
+
|
|
28
|
+
const layers = doc.querySelectorAll('layer');
|
|
29
|
+
console.log(layers[0]?.getAttribute('name')); // "bg"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/domparser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "DOMParser for GJS — self-contained XML parser with minimal DOM (querySelector, getAttribute, children)",
|
|
5
5
|
"module": "lib/esm/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"web-api"
|
|
47
47
|
],
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@gjsify/cli": "^0.
|
|
50
|
-
"@gjsify/unit": "^0.
|
|
51
|
-
"@types/node": "^25.9.
|
|
49
|
+
"@gjsify/cli": "^0.5.0",
|
|
50
|
+
"@gjsify/unit": "^0.5.0",
|
|
51
|
+
"@types/node": "^25.9.2",
|
|
52
52
|
"typescript": "^6.0.3"
|
|
53
53
|
},
|
|
54
54
|
"gjsify": {
|