@playcanvas/attribute-parser 1.10.2 → 1.11.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 -37
- package/dist/index.js +64 -41
- package/dist/index.node.mjs +23 -0
- package/dist/libs.d.ts +22437 -7555
- package/package.json +68 -65
- package/types/index.d.ts +50 -33
- package/types/parsers/attribute-parser.d.ts +70 -51
- package/types/parsers/parsing-error.d.ts +23 -34
- package/types/parsers/script-parser.d.ts +64 -103
- package/types/utils/attribute-utils.d.ts +30 -4
- package/types/utils/generic-utils.d.ts +4 -4
- package/types/utils/tag-utils.d.ts +9 -8
- package/types/utils/ts-utils.d.ts +102 -58
package/README.md
CHANGED
|
@@ -19,52 +19,51 @@ Given a script like this:
|
|
|
19
19
|
|
|
20
20
|
```javascript
|
|
21
21
|
class Rotator extends ScriptType {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
/**
|
|
23
|
+
* @attribute
|
|
24
|
+
* Speed determines how fast to rotate things
|
|
25
|
+
*/
|
|
26
|
+
speed = new Vec3();
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @attribute
|
|
30
|
+
* An array of Entities to rotate
|
|
31
|
+
*
|
|
32
|
+
* @type {Entity[]}
|
|
33
|
+
*/
|
|
34
|
+
thingsToRotate;
|
|
35
35
|
}
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
The parser outputs:
|
|
39
39
|
|
|
40
|
-
|
|
41
40
|
```json
|
|
42
41
|
{
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
42
|
+
"rotator": {
|
|
43
|
+
"attributes": {
|
|
44
|
+
"speed": {
|
|
45
|
+
"type": "vec3",
|
|
46
|
+
"name": "speed",
|
|
47
|
+
"array": false,
|
|
48
|
+
"description": "Speed determines how fast to rotate things",
|
|
49
|
+
"default": [0, 0, 0]
|
|
50
|
+
},
|
|
51
|
+
"thingsToRotate": {
|
|
52
|
+
"type": "entity",
|
|
53
|
+
"name": "thingsToRotate",
|
|
54
|
+
"array": true,
|
|
55
|
+
"description": "An array of Entities to rotate",
|
|
56
|
+
"default": null
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"errors": []
|
|
60
|
+
}
|
|
62
61
|
}
|
|
63
62
|
```
|
|
64
63
|
|
|
65
64
|
JSDocs tags are parsed and values and outputs the metadata in a serializable format.
|
|
66
65
|
|
|
67
|
-
### Usage
|
|
66
|
+
### Usage
|
|
68
67
|
|
|
69
68
|
```javascript
|
|
70
69
|
// Initialise the parser
|
|
@@ -79,7 +78,7 @@ const scripts = await fetchScripts([...paths, './playcanvas.d.ts']);
|
|
|
79
78
|
parser.updateProgram(scripts);
|
|
80
79
|
|
|
81
80
|
// Parse attributes from the entry point
|
|
82
|
-
const [attributes, errors] = parser.parseAttributes(
|
|
81
|
+
const [attributes, errors] = parser.parseAttributes('./index.js');
|
|
83
82
|
```
|
|
84
83
|
|
|
85
84
|
### Attribute structure
|
|
@@ -89,5 +88,3 @@ See the [test fixtures](https://github.com/playcanvas/attribute-parser/tree/main
|
|
|
89
88
|
### Tests
|
|
90
89
|
|
|
91
90
|
This project includes good test coverage for all supported tag formats and edge cases.
|
|
92
|
-
|
|
93
|
-
|