@playcanvas/attribute-parser 1.6.1 → 1.7.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 (78) hide show
  1. package/LICENSE.md +19 -0
  2. package/dist/index.js +445 -0
  3. package/dist/libs.d.ts +50978 -0
  4. package/package.json +50 -10
  5. package/types/index.d.ts +55 -0
  6. package/types/parsers/attribute-parser.d.ts +55 -0
  7. package/types/parsers/parsing-error.d.ts +6 -0
  8. package/types/parsers/script-parser.d.ts +124 -0
  9. package/types/utils/attribute-utils.d.ts +5 -0
  10. package/{src/utils/generic-utils.js → types/utils/generic-utils.d.ts} +1 -10
  11. package/types/utils/tag-utils.d.ts +16 -0
  12. package/types/utils/ts-utils.d.ts +103 -0
  13. package/.github/workflows/ci.yml +0 -49
  14. package/eslint.config.mjs +0 -35
  15. package/renovate.json +0 -25
  16. package/src/index.js +0 -273
  17. package/src/parsers/attribute-parser.js +0 -197
  18. package/src/parsers/parsing-error.js +0 -14
  19. package/src/parsers/script-parser.js +0 -432
  20. package/src/utils/attribute-utils.js +0 -53
  21. package/src/utils/tag-utils.js +0 -73
  22. package/src/utils/ts-utils.js +0 -634
  23. package/test/fixtures/asset.invalid.js +0 -27
  24. package/test/fixtures/asset.invalid.ts +0 -24
  25. package/test/fixtures/asset.valid.js +0 -26
  26. package/test/fixtures/asset.valid.ts +0 -21
  27. package/test/fixtures/checkbox.valid.js +0 -23
  28. package/test/fixtures/color.valid.js +0 -23
  29. package/test/fixtures/conditional.valid.js +0 -22
  30. package/test/fixtures/curve.invalid.js +0 -29
  31. package/test/fixtures/curve.valid.js +0 -49
  32. package/test/fixtures/empty.valid.js +0 -0
  33. package/test/fixtures/entity.valid.js +0 -23
  34. package/test/fixtures/enum.valid.js +0 -66
  35. package/test/fixtures/enum.valid.ts +0 -50
  36. package/test/fixtures/example.dep.js +0 -9
  37. package/test/fixtures/export.import.js +0 -8
  38. package/test/fixtures/export.valid.js +0 -26
  39. package/test/fixtures/inherit.valid.js +0 -45
  40. package/test/fixtures/intellisense.valid.js +0 -40
  41. package/test/fixtures/json.invalid.js +0 -23
  42. package/test/fixtures/json.valid.js +0 -115
  43. package/test/fixtures/json.valid.ts +0 -81
  44. package/test/fixtures/misc.invalid.js +0 -24
  45. package/test/fixtures/misc.valid.js +0 -51
  46. package/test/fixtures/numeric.invalid.js +0 -38
  47. package/test/fixtures/numeric.valid.js +0 -63
  48. package/test/fixtures/playcanvas.d.ts +0 -47963
  49. package/test/fixtures/program.invalid.js +0 -12
  50. package/test/fixtures/program.valid.js +0 -27
  51. package/test/fixtures/text.valid.js +0 -31
  52. package/test/fixtures/vector.invalid.js +0 -14
  53. package/test/fixtures/vector.valid.js +0 -24
  54. package/test/tests/invalid/asset.test.js +0 -47
  55. package/test/tests/invalid/curve.test.js +0 -23
  56. package/test/tests/invalid/json.test.js +0 -27
  57. package/test/tests/invalid/misc.test.js +0 -41
  58. package/test/tests/invalid/numeric.test.js +0 -55
  59. package/test/tests/invalid/program.test.js +0 -17
  60. package/test/tests/invalid/vector.test.js +0 -28
  61. package/test/tests/valid/asset.test.js +0 -59
  62. package/test/tests/valid/checkbox.test.js +0 -57
  63. package/test/tests/valid/color.test.js +0 -49
  64. package/test/tests/valid/conditional.test.js +0 -45
  65. package/test/tests/valid/curve.test.js +0 -76
  66. package/test/tests/valid/empty.test.js +0 -17
  67. package/test/tests/valid/entity.test.js +0 -49
  68. package/test/tests/valid/enum.test.js +0 -79
  69. package/test/tests/valid/export.test.js +0 -67
  70. package/test/tests/valid/inherit.test.js +0 -110
  71. package/test/tests/valid/intellisense.test.js +0 -39
  72. package/test/tests/valid/json.test.js +0 -315
  73. package/test/tests/valid/misc.test.js +0 -54
  74. package/test/tests/valid/numeric.test.js +0 -103
  75. package/test/tests/valid/program.test.js +0 -23
  76. package/test/tests/valid/text.test.js +0 -58
  77. package/test/tests/valid/vector.test.js +0 -53
  78. package/test/utils.js +0 -54
@@ -1,26 +0,0 @@
1
- // eslint-disable-next-line
2
- import { Script, Asset } from 'playcanvas';
3
-
4
- class Example extends Script {
5
- /**
6
- * @attribute
7
- * @type {Asset}
8
- */
9
- a;
10
-
11
- /**
12
- * @attribute
13
- * @type {Asset}
14
- * @resource texture
15
- */
16
- b;
17
-
18
- /**
19
- * @attribute
20
- * @type {Asset[]}
21
- * @resource container
22
- */
23
- c;
24
- }
25
-
26
- export { Example };
@@ -1,21 +0,0 @@
1
- // eslint-disable-next-line
2
- import { Script, Asset } from 'playcanvas';
3
-
4
- class Example extends Script {
5
- /** @attribute */
6
- a : Asset;
7
-
8
- /**
9
- * @attribute
10
- * @resource texture
11
- */
12
- b : Asset;
13
-
14
- /**
15
- * @attribute
16
- * @resource container
17
- */
18
- c : Asset[];
19
- }
20
-
21
- export { Example };
@@ -1,23 +0,0 @@
1
- import { Script } from 'playcanvas';
2
-
3
- class Example extends Script {
4
- /**
5
- * @attribute
6
- * @type {boolean}
7
- */
8
- a;
9
-
10
- /**
11
- * @attribute
12
- */
13
- b = true;
14
-
15
- /**
16
- * @attribute
17
- * @type {boolean[]}
18
- * @size 2
19
- */
20
- c;
21
- }
22
-
23
- export { Example };
@@ -1,23 +0,0 @@
1
- import { Script, Color } from 'playcanvas';
2
-
3
- class Example extends Script {
4
- /**
5
- * @attribute
6
- * @type {Color}
7
- */
8
- a;
9
-
10
- /**
11
- * @attribute
12
- */
13
- b = new Color(1, 0, 0, 1);
14
-
15
- /**
16
- * @attribute
17
- * @type {Color[]}
18
- * @size 2
19
- */
20
- c;
21
- }
22
-
23
- export { Example };
@@ -1,22 +0,0 @@
1
- import { Script } from 'playcanvas';
2
-
3
- class Example extends Script {
4
- /**
5
- * @attribute
6
- * @visibleif {b === 2}
7
- */
8
- a = 1;
9
-
10
- /**
11
- * @attribute
12
- * @enabledif {a === 3}
13
- */
14
- b = 1;
15
-
16
- /**
17
- * @attribute
18
- */
19
- c = 1;
20
- }
21
-
22
- export { Example };
@@ -1,29 +0,0 @@
1
- // eslint-disable-next-line
2
- import { Script, Curve } from 'playcanvas';
3
-
4
- class Example extends Script {
5
- /**
6
- * @attribute
7
- * @type {Curve}
8
- * @color bad
9
- */
10
- a;
11
-
12
- /**
13
- * @attribute
14
- * @type {Curve}
15
- * @color rgb
16
- * @curves ['x', 'y', 'z', 'w']
17
- */
18
- b;
19
-
20
- /**
21
- * @attribute
22
- * @type {Curve}
23
- * @color 1
24
- * @curves 1
25
- */
26
- c;
27
- }
28
-
29
- export { Example };
@@ -1,49 +0,0 @@
1
- import { Script, Curve } from 'playcanvas';
2
-
3
- class Example extends Script {
4
- /**
5
- * @attribute
6
- * @type {Curve}
7
- */
8
- a;
9
-
10
- /**
11
- * @attribute
12
- */
13
- b = new Curve([
14
- 0, 0,
15
- 1, 1
16
- ]);
17
-
18
- /**
19
- * @attribute
20
- * @type {Curve}
21
- * @color r
22
- */
23
- c;
24
-
25
- /**
26
- * @attribute
27
- * @type {Curve}
28
- * @color rgb
29
- * @curves ['x', 'y', 'z']
30
- */
31
- d;
32
-
33
- /**
34
- * @attribute
35
- * @type {Curve[]}
36
- * @size 2
37
- */
38
- e;
39
-
40
- /**
41
- * @attribute
42
- * @type {Curve}
43
- * @color rgba
44
- * @curves ["x", 'y', `z`]
45
- */
46
- f;
47
- }
48
-
49
- export { Example };
File without changes
@@ -1,23 +0,0 @@
1
- import { Script, Entity } from 'playcanvas';
2
-
3
- class Example extends Script {
4
- /**
5
- * @attribute
6
- * @type {Entity}
7
- */
8
- a;
9
-
10
- /**
11
- * @attribute
12
- */
13
- b = new Entity();
14
-
15
- /**
16
- * @attribute
17
- * @type {Entity[]}
18
- * @size 2
19
- */
20
- c;
21
- }
22
-
23
- export { Example };
@@ -1,66 +0,0 @@
1
- import { Script } from 'playcanvas';
2
-
3
- /**
4
- * @enum {number}
5
- */
6
- const NumberEnum = {
7
- A: 13,
8
- B: 14,
9
- C: 23
10
- };
11
-
12
- /**
13
- * @enum {string}
14
- */
15
- // eslint-disable-next-line
16
- const StringEnum = {
17
- A: 'a',
18
- B: 'b',
19
- C: 'c',
20
- 'A string key': 'd'
21
- };
22
-
23
- /**
24
- * @enum {NumberEnum}
25
- */
26
- // eslint-disable-next-line
27
- const NumberNumberEnum = {
28
- A: NumberEnum.A,
29
- B: NumberEnum.B,
30
- C: NumberEnum.C
31
- };
32
-
33
- class Example extends Script {
34
- /**
35
- * @attribute
36
- * @type {NumberEnum}
37
- */
38
- e = NumberEnum.A;
39
-
40
- /**
41
- * @attribute
42
- * @type {NumberEnum}
43
- */
44
- f = 1;
45
-
46
- /**
47
- * @attribute
48
- * @type {NumberEnum[]}
49
- * @size 2
50
- */
51
- g;
52
-
53
- /**
54
- * @attribute
55
- * @type {StringEnum}
56
- */
57
- h;
58
-
59
- /**
60
- * @attribute
61
- * @type {NumberNumberEnum}
62
- */
63
- i = 2;
64
- }
65
-
66
- export { Example };
@@ -1,50 +0,0 @@
1
- import { Script, Vec3 } from 'playcanvas';
2
-
3
- enum NumberEnum {
4
- A = 13,
5
- B = 14,
6
- C = 23
7
- };
8
-
9
- enum StringEnum {
10
- A = 'a',
11
- B = 'b',
12
- C = 'c',
13
- "A string key" = 'd'
14
- };
15
-
16
- enum NumberNumberEnum {
17
- A = NumberEnum.A,
18
- B = NumberEnum.B,
19
- C = NumberEnum.C
20
- };
21
-
22
- class Example extends Script {
23
- /**
24
- * @attribute
25
- */
26
- e : NumberEnum = NumberEnum.A;
27
-
28
- /**
29
- * @attribute
30
- */
31
- f : NumberEnum = 1;
32
-
33
- /**
34
- * @attribute
35
- * @size 2
36
- */
37
- g : NumberEnum[];
38
-
39
- /**
40
- * @attribute
41
- */
42
- h : StringEnum;
43
-
44
- /**
45
- * @attribute
46
- */
47
- i : NumberNumberEnum = 2;
48
- }
49
-
50
- export { Example };
@@ -1,9 +0,0 @@
1
- import { Script } from 'playcanvas';
2
-
3
- export class Example extends Script {
4
- /**
5
- * @attribute
6
- * @type {boolean}
7
- */
8
- a;
9
- }
@@ -1,8 +0,0 @@
1
- import { Script } from 'playcanvas';
2
-
3
- export class ExampleImport extends Script {
4
- /**
5
- * @attribute
6
- */
7
- prop = 10;
8
- }
@@ -1,26 +0,0 @@
1
- import { Script } from 'playcanvas';
2
-
3
- import { ExampleImport } from './export.import.js';
4
-
5
- class ExampleImportExtend extends ExampleImport {}
6
-
7
- export { ExampleImport as ExampleImportAsExport } from './export.import.js';
8
-
9
- class Example extends Script {
10
- /** @attribute */
11
- num = 10;
12
- }
13
-
14
- export default class ExampleDefault extends Script {}
15
-
16
- export class ExampleExport extends Script {}
17
-
18
- // eslint-disable-next-line
19
- class ExampleNotExported extends Script {}
20
-
21
- export {
22
- Example,
23
- Example as ExampleExportAs,
24
- ExampleImport,
25
- ExampleImportExtend
26
- };
@@ -1,45 +0,0 @@
1
- import { Script } from 'playcanvas';
2
-
3
- import { Example } from './example.dep.js';
4
-
5
- class ExampleExtended extends Example {
6
- /**
7
- * @attribute
8
- * @type {number}
9
- */
10
- b;
11
- }
12
-
13
- class ExampleExtendedExtended extends ExampleExtended {
14
- /**
15
- * @attribute
16
- * @type {string}
17
- */
18
- c;
19
- }
20
-
21
- const ScriptAlias = Script;
22
-
23
- class ExampleAlias extends ScriptAlias {
24
- /**
25
- * @attribute
26
- * @type {boolean}
27
- */
28
- a;
29
- }
30
-
31
- class ExampleNoExtend {
32
- /**
33
- * @attribute
34
- * @type {number}
35
- */
36
- a;
37
- }
38
-
39
- export {
40
- Example,
41
- ExampleExtended,
42
- ExampleExtendedExtended,
43
- ExampleAlias,
44
- ExampleNoExtend
45
- };
@@ -1,40 +0,0 @@
1
- /* eslint-disable */
2
- import { Script, Vec3 } from 'playcanvas';
3
-
4
- /**
5
- * @interface
6
- */
7
- class Folder {
8
- /**
9
- * @attribute
10
- */
11
- a;
12
-
13
- b = 10;
14
- }
15
-
16
- export class Example extends Script {
17
-
18
- static scriptName = 'Example';
19
-
20
- /**
21
- * @attribute
22
- */
23
- a;
24
-
25
- b = 10;
26
-
27
- c = true;
28
-
29
- d = 'hello';
30
-
31
- e = {};
32
-
33
- f = new Vec3();
34
-
35
- /**
36
- * @attribute
37
- * @type {Folder}
38
- */
39
- g;
40
- }
@@ -1,23 +0,0 @@
1
- import { Script } from 'playcanvas';
2
-
3
- // eslint-disable-next-line
4
- class NoInterfaceFolder {
5
- /**
6
- * @attribute
7
- * @type {boolean}
8
- */
9
- a;
10
- }
11
-
12
- /**
13
- * @interface
14
- */
15
- class Example extends Script {
16
- /**
17
- * @attribute
18
- * @type {NoInterfaceFolder}
19
- */
20
- o;
21
- }
22
-
23
- export { Example };
@@ -1,115 +0,0 @@
1
- import { Script, Vec3 } from 'playcanvas';
2
-
3
- /**
4
- * @interface
5
- */
6
- // eslint-disable-next-line
7
- class Folder {
8
- /**
9
- * This is some description of the attribute.
10
- * @attribute
11
- * @type {boolean}
12
- */
13
- a;
14
-
15
- /**
16
- * @attribute
17
- * @range [10, 20]
18
- */
19
- b = 10;
20
-
21
- c = 'hello';
22
-
23
- /**
24
- * @attribute
25
- * @type {Vec3[]}
26
- */
27
- d;
28
- }
29
-
30
- /**
31
- * @interface
32
- *
33
- */
34
- // eslint-disable-next-line
35
- class NestedFolder {
36
- /**
37
- * @attribute
38
- * @type {Folder}
39
- */
40
- x;
41
- }
42
-
43
- /**
44
- * @interface
45
- */
46
- class Example extends Script {
47
- /**
48
- * @attribute
49
- * @type {Folder}
50
- */
51
- f;
52
-
53
- /**
54
- * @attribute
55
- * @type {Folder[]}
56
- * @size 2
57
- */
58
- g;
59
-
60
- /**
61
- * @attribute
62
- * @type {NestedFolder}
63
- */
64
- h;
65
-
66
- /**
67
- * @attribute
68
- */
69
- i = {
70
- /** description of a */
71
- a: true,
72
- /** @range [10, 20] */
73
- b: 10,
74
- c: 'hello',
75
- d: [new Vec3(1, 2, 3)]
76
- };
77
-
78
- /**
79
- * @typedef {object} TypeDefFolder
80
- * @property {number} x - The x component
81
- * @property {number} y - The y component
82
- */
83
-
84
- /**
85
- * @attribute
86
- * @type {TypeDefFolder}
87
- */
88
- j;
89
-
90
- /**
91
- * @typedef {{ x: number, y: number }} InlineTypeDefFolder
92
- */
93
-
94
- /**
95
- * @attribute
96
- * @type {InlineTypeDefFolder}
97
- */
98
- k;
99
-
100
- /**
101
- * @attribute
102
- * @type {{ x: number, y: number }}
103
- */
104
- l;
105
-
106
- /**
107
- * @attribute
108
- * @type {Example}
109
- */
110
- m;
111
-
112
- n = 10;
113
- }
114
-
115
- export { Example };
@@ -1,81 +0,0 @@
1
- import { Script, Vec3 } from 'playcanvas';
2
-
3
- interface Folder {
4
- /**
5
- * This is some description of the attribute.
6
- * @attribute
7
- */
8
- a: boolean;
9
-
10
- /**
11
- * @attribute
12
- * @default 10
13
- * @range [10, 20]
14
- */
15
- b: number;
16
-
17
- /**
18
- * @attribute
19
- * @default hello
20
- */
21
- c : string;
22
-
23
- /**
24
- * @attribute
25
- */
26
- d : Vec3[];
27
- }
28
-
29
- interface NestedFolder {
30
- /**
31
- * @attribute
32
- */
33
- x : Folder;
34
- }
35
-
36
- /**
37
- * @interface
38
- */
39
- class Example extends Script {
40
- /**
41
- * @attribute
42
- */
43
- f : Folder;
44
-
45
- /**
46
- * @attribute
47
- * @size 2
48
- */
49
- g : Folder[];
50
-
51
- /**
52
- * @attribute
53
- */
54
- h : NestedFolder;
55
-
56
- /**
57
- * @attribute
58
- */
59
- i = {
60
- /** description of a */
61
- a: true,
62
- /** @range [10, 20] */
63
- b: 10,
64
- c: 'hello',
65
- d: [new Vec3(1, 2, 3)]
66
- };
67
-
68
- /**
69
- * @attribute
70
- */
71
- l : { x: number, y: number };
72
-
73
- /**
74
- * @attribute
75
- */
76
- m : Example;
77
-
78
- n = 10;
79
- }
80
-
81
- export { Example };