@needle-tools/needle-component-compiler 1.11.2 → 1.12.0-da2e0be
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/Changelog.md +101 -101
- package/Readme.md +17 -17
- package/package.json +46 -42
- package/src/component-compiler.js +788 -784
- package/src/types.js +58 -58
- package/tsconfig.json +7 -7
- package/workspace.code-workspace +14 -11
- package/src/component-compiler.ts +0 -822
package/Changelog.md
CHANGED
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
All notable changes to this package will be documented in this file.
|
|
3
|
-
|
|
4
|
-
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
5
|
-
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
|
-
|
|
7
|
-
## [1.11.2] - 2023-12-16
|
|
8
|
-
- Fix: property setter emitting invalid C# code
|
|
9
|
-
|
|
10
|
-
## [1.11.1] - 2023-12-02
|
|
11
|
-
- Fix: Use Unity AnimatorController type
|
|
12
|
-
- Fix: method inline anonymous type declaration (e.g. `myMethod(arg: {x:number})`)
|
|
13
|
-
|
|
14
|
-
## [1.11.0] - 2023-11-18
|
|
15
|
-
- Add: support to wrap fields with `#if UNITY_EDITOR` if their namespace contains UnityEditor
|
|
16
|
-
- Add: more threejs types to generate Unity Material fields for
|
|
17
|
-
|
|
18
|
-
## [1.10.3] - 2023-09-08
|
|
19
|
-
- Add: Needle Engine type `RGBAColor` is now automatically emitted as `UnityEngine.Color`
|
|
20
|
-
|
|
21
|
-
## [1.10.2] - 2023-09-08
|
|
22
|
-
- Fix: `@type` was not properly applied for `new expression` cases (e.g. `new RGBAColor` should produce a `new Color` when decorated with `@type Color`)
|
|
23
|
-
|
|
24
|
-
## [1.10.1] - 2023-08-02
|
|
25
|
-
- Add: use `@tooltip` to emit a UnityEngine.Tooltip
|
|
26
|
-
- Update Readme
|
|
27
|
-
|
|
28
|
-
## [1.9.4] - 2023-05-24
|
|
29
|
-
- Change: `Object3D` now emits `GameObject` field instead of `Transform`
|
|
30
|
-
- Fix: ignore `static` methods
|
|
31
|
-
- Fix: ignore `abstract` methods
|
|
32
|
-
|
|
33
|
-
## [1.9.3] - 2022-12-30
|
|
34
|
-
- Add debug logs for when no file or target directory was passed in. Also wrapping core with try catch
|
|
35
|
-
|
|
36
|
-
## [1.9.2] - 2022-11-29
|
|
37
|
-
- Fix codegen deleting code added manually outside of codegen sections
|
|
38
|
-
- Fix codegen creating output directory if it does not exist yet
|
|
39
|
-
|
|
40
|
-
## [1.9.1] - 2022-11-05
|
|
41
|
-
- Fix ``new Vector2(1, .5)`` generating invalid C# where number arguments were emitted as double instead of float
|
|
42
|
-
|
|
43
|
-
## [1.9.0] - 2022-10-18
|
|
44
|
-
- Change: emit ``onEnable`` as ``OnEnable`` and ``onDisable`` as ``OnDisable`` so Unity creates component checkboxes
|
|
45
|
-
- Change: ignore private and protected methods
|
|
46
|
-
|
|
47
|
-
## [1.8.0] - 2022-09-02
|
|
48
|
-
- Add ``@nonSerialized`` decorator for fields and methods
|
|
49
|
-
- Fix comment gen for unknown types
|
|
50
|
-
|
|
51
|
-
## [1.7.3] - 2022-09-02
|
|
52
|
-
- Fix codegen for unknown array types
|
|
53
|
-
- Fix codegen for abstract classes
|
|
54
|
-
- Fix codegen for types imported as e.g. THREE.AnimationClip
|
|
55
|
-
|
|
56
|
-
## [1.7.2] - 2022-07-27
|
|
57
|
-
- fix UnityEvent codegen
|
|
58
|
-
|
|
59
|
-
## [1.7.1] - 2022-07-25
|
|
60
|
-
- fix array type codegen, for example ``scenes: Array<AssetReference> = [];``, see issue https://github.com/needle-tools/needle-tiny-playground/issues/285
|
|
61
|
-
|
|
62
|
-
## [1.7.0] - 2022-07-14
|
|
63
|
-
- change: skip non-serializeable variables (private without ``@serializable``)
|
|
64
|
-
- improve member type generation
|
|
65
|
-
- fix bug in type generation for array types
|
|
66
|
-
- add/improve initial assignment codegen for object types
|
|
67
|
-
|
|
68
|
-
## [1.6.3] - 2022-07-12
|
|
69
|
-
- add warning when class type is unknown
|
|
70
|
-
|
|
71
|
-
## [1.6.2] - 2022-07-11
|
|
72
|
-
- fix ``@type`` for class declaration
|
|
73
|
-
|
|
74
|
-
## [1.6.1] - 2022-07-10
|
|
75
|
-
- add using ``types.json`` json file that will be generated from Unity
|
|
76
|
-
- change ``@type`` annotiation to only work without braces to be consistent
|
|
77
|
-
|
|
78
|
-
## [1.5.0] - 2022-07-07
|
|
79
|
-
- change ``@type`` annotation to work with and without braces (e.g. ``@type My.Type`` or ``@type (My.Type)``)
|
|
80
|
-
|
|
81
|
-
## [1.4.0] - 2022-07-06
|
|
82
|
-
- add CODEGEN_START and END sections to allow adding code before or after a generated componnet
|
|
83
|
-
- add ``@ifdef`` to ifdef fields
|
|
84
|
-
|
|
85
|
-
## [1.3.0] - 2022-06-27
|
|
86
|
-
- add support for typescript namespace
|
|
87
|
-
|
|
88
|
-
## [1.2.1] - 2022-06-15
|
|
89
|
-
- allow adding ``@type(MyNamespace.MyType)`` to class declaration
|
|
90
|
-
|
|
91
|
-
## [1.1.0] - 2022-06-13
|
|
92
|
-
- add ``@type(MyNamespace.MyType)`` decorator for fields to specifiy C# type
|
|
93
|
-
- add minimal docs to readme
|
|
94
|
-
- dont emit comments anymore
|
|
95
|
-
- make created classes partial
|
|
96
|
-
|
|
97
|
-
## [1.0.1] - 2022-05-29
|
|
98
|
-
- disable all warnings for generated scripts
|
|
99
|
-
- add mesh and texture types
|
|
100
|
-
|
|
101
|
-
## [1.0.0] - 2022-04-22
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this package will be documented in this file.
|
|
3
|
+
|
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [1.11.2] - 2023-12-16
|
|
8
|
+
- Fix: property setter emitting invalid C# code
|
|
9
|
+
|
|
10
|
+
## [1.11.1] - 2023-12-02
|
|
11
|
+
- Fix: Use Unity AnimatorController type
|
|
12
|
+
- Fix: method inline anonymous type declaration (e.g. `myMethod(arg: {x:number})`)
|
|
13
|
+
|
|
14
|
+
## [1.11.0] - 2023-11-18
|
|
15
|
+
- Add: support to wrap fields with `#if UNITY_EDITOR` if their namespace contains UnityEditor
|
|
16
|
+
- Add: more threejs types to generate Unity Material fields for
|
|
17
|
+
|
|
18
|
+
## [1.10.3] - 2023-09-08
|
|
19
|
+
- Add: Needle Engine type `RGBAColor` is now automatically emitted as `UnityEngine.Color`
|
|
20
|
+
|
|
21
|
+
## [1.10.2] - 2023-09-08
|
|
22
|
+
- Fix: `@type` was not properly applied for `new expression` cases (e.g. `new RGBAColor` should produce a `new Color` when decorated with `@type Color`)
|
|
23
|
+
|
|
24
|
+
## [1.10.1] - 2023-08-02
|
|
25
|
+
- Add: use `@tooltip` to emit a UnityEngine.Tooltip
|
|
26
|
+
- Update Readme
|
|
27
|
+
|
|
28
|
+
## [1.9.4] - 2023-05-24
|
|
29
|
+
- Change: `Object3D` now emits `GameObject` field instead of `Transform`
|
|
30
|
+
- Fix: ignore `static` methods
|
|
31
|
+
- Fix: ignore `abstract` methods
|
|
32
|
+
|
|
33
|
+
## [1.9.3] - 2022-12-30
|
|
34
|
+
- Add debug logs for when no file or target directory was passed in. Also wrapping core with try catch
|
|
35
|
+
|
|
36
|
+
## [1.9.2] - 2022-11-29
|
|
37
|
+
- Fix codegen deleting code added manually outside of codegen sections
|
|
38
|
+
- Fix codegen creating output directory if it does not exist yet
|
|
39
|
+
|
|
40
|
+
## [1.9.1] - 2022-11-05
|
|
41
|
+
- Fix ``new Vector2(1, .5)`` generating invalid C# where number arguments were emitted as double instead of float
|
|
42
|
+
|
|
43
|
+
## [1.9.0] - 2022-10-18
|
|
44
|
+
- Change: emit ``onEnable`` as ``OnEnable`` and ``onDisable`` as ``OnDisable`` so Unity creates component checkboxes
|
|
45
|
+
- Change: ignore private and protected methods
|
|
46
|
+
|
|
47
|
+
## [1.8.0] - 2022-09-02
|
|
48
|
+
- Add ``@nonSerialized`` decorator for fields and methods
|
|
49
|
+
- Fix comment gen for unknown types
|
|
50
|
+
|
|
51
|
+
## [1.7.3] - 2022-09-02
|
|
52
|
+
- Fix codegen for unknown array types
|
|
53
|
+
- Fix codegen for abstract classes
|
|
54
|
+
- Fix codegen for types imported as e.g. THREE.AnimationClip
|
|
55
|
+
|
|
56
|
+
## [1.7.2] - 2022-07-27
|
|
57
|
+
- fix UnityEvent codegen
|
|
58
|
+
|
|
59
|
+
## [1.7.1] - 2022-07-25
|
|
60
|
+
- fix array type codegen, for example ``scenes: Array<AssetReference> = [];``, see issue https://github.com/needle-tools/needle-tiny-playground/issues/285
|
|
61
|
+
|
|
62
|
+
## [1.7.0] - 2022-07-14
|
|
63
|
+
- change: skip non-serializeable variables (private without ``@serializable``)
|
|
64
|
+
- improve member type generation
|
|
65
|
+
- fix bug in type generation for array types
|
|
66
|
+
- add/improve initial assignment codegen for object types
|
|
67
|
+
|
|
68
|
+
## [1.6.3] - 2022-07-12
|
|
69
|
+
- add warning when class type is unknown
|
|
70
|
+
|
|
71
|
+
## [1.6.2] - 2022-07-11
|
|
72
|
+
- fix ``@type`` for class declaration
|
|
73
|
+
|
|
74
|
+
## [1.6.1] - 2022-07-10
|
|
75
|
+
- add using ``types.json`` json file that will be generated from Unity
|
|
76
|
+
- change ``@type`` annotiation to only work without braces to be consistent
|
|
77
|
+
|
|
78
|
+
## [1.5.0] - 2022-07-07
|
|
79
|
+
- change ``@type`` annotation to work with and without braces (e.g. ``@type My.Type`` or ``@type (My.Type)``)
|
|
80
|
+
|
|
81
|
+
## [1.4.0] - 2022-07-06
|
|
82
|
+
- add CODEGEN_START and END sections to allow adding code before or after a generated componnet
|
|
83
|
+
- add ``@ifdef`` to ifdef fields
|
|
84
|
+
|
|
85
|
+
## [1.3.0] - 2022-06-27
|
|
86
|
+
- add support for typescript namespace
|
|
87
|
+
|
|
88
|
+
## [1.2.1] - 2022-06-15
|
|
89
|
+
- allow adding ``@type(MyNamespace.MyType)`` to class declaration
|
|
90
|
+
|
|
91
|
+
## [1.1.0] - 2022-06-13
|
|
92
|
+
- add ``@type(MyNamespace.MyType)`` decorator for fields to specifiy C# type
|
|
93
|
+
- add minimal docs to readme
|
|
94
|
+
- dont emit comments anymore
|
|
95
|
+
- make created classes partial
|
|
96
|
+
|
|
97
|
+
## [1.0.1] - 2022-05-29
|
|
98
|
+
- disable all warnings for generated scripts
|
|
99
|
+
- add mesh and texture types
|
|
100
|
+
|
|
101
|
+
## [1.0.0] - 2022-04-22
|
|
102
102
|
- initial release
|
package/Readme.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
## Typescript to Unity component
|
|
2
|
-
|
|
3
|
-
Little helper package to transpile typescript files to Unity C# components.
|
|
4
|
-
Please run ``npm install`` first before using.
|
|
5
|
-
|
|
6
|
-
### Usage
|
|
7
|
-
``node <path to>/component-compiler.js <output_directory> <path_to/my_script.ts>``
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
### Command decorators
|
|
11
|
-
- ``@dont-generate-component`` add before class to skip generating a component
|
|
12
|
-
- ``@generate-component`` to enforce generating a component (not required)
|
|
13
|
-
- ``@serializeField`` field decorator, similar to ``[SerializeField]`` in Unity
|
|
14
|
-
- ``@nonSerialized`` field or method decorator to skip generating c# code for a field or a method, similar to ``[NonSerialized]`` in Unity
|
|
15
|
-
- ``@type MyNamespace.MyType`` decorator for fields or classes, specifiy C# type of field or class
|
|
16
|
-
- ``@ifdef MY_IFDEF`` field decorator only at the moment
|
|
17
|
-
- ``@tooltip My Text`` field decorator, generates a Unity `[Tooltip("My Text")]`
|
|
1
|
+
## Typescript to Unity component
|
|
2
|
+
|
|
3
|
+
Little helper package to transpile typescript files to Unity C# components.
|
|
4
|
+
Please run ``npm install`` first before using.
|
|
5
|
+
|
|
6
|
+
### Usage
|
|
7
|
+
``node <path to>/component-compiler.js <output_directory> <path_to/my_script.ts>``
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Command decorators
|
|
11
|
+
- ``@dont-generate-component`` add before class to skip generating a component
|
|
12
|
+
- ``@generate-component`` to enforce generating a component (not required)
|
|
13
|
+
- ``@serializeField`` field decorator, similar to ``[SerializeField]`` in Unity
|
|
14
|
+
- ``@nonSerialized`` field or method decorator to skip generating c# code for a field or a method, similar to ``[NonSerialized]`` in Unity
|
|
15
|
+
- ``@type MyNamespace.MyType`` decorator for fields or classes, specifiy C# type of field or class
|
|
16
|
+
- ``@ifdef MY_IFDEF`` field decorator only at the moment
|
|
17
|
+
- ``@tooltip My Text`` field decorator, generates a Unity `[Tooltip("My Text")]`
|
|
18
18
|
- ``@contextmenu MethodName`` method decorator, generates a `[ContextMenu("MethodName")]`
|
package/package.json
CHANGED
|
@@ -1,42 +1,46 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@needle-tools/needle-component-compiler",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Compile mock unity components from typescript",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"tsc": "tsc",
|
|
8
|
-
"dev": "npm-watch compile",
|
|
9
|
-
"compile"
|
|
10
|
-
"test": "mocha -r ts-node/register test
|
|
11
|
-
},
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"typescript": "^4.5.5"
|
|
14
|
-
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"@types/chai": "^4.3.3",
|
|
17
|
-
"@types/mocha": "^9.1.1",
|
|
18
|
-
"@types/node": "^18.7.18",
|
|
19
|
-
"chai": "^4.3.6",
|
|
20
|
-
"mocha": "^10.0.0",
|
|
21
|
-
"ts-node": "^10.9.1",
|
|
22
|
-
"npm-watch": "^0.13.0"
|
|
23
|
-
},
|
|
24
|
-
"watch": {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
"author": {
|
|
34
|
-
"name": "Needle",
|
|
35
|
-
"email": "help@needle.tools",
|
|
36
|
-
"url": "https://needle.tools/"
|
|
37
|
-
},
|
|
38
|
-
"repository": {
|
|
39
|
-
"type": "git",
|
|
40
|
-
"url": "git+https://github.com/needle-tools/needle-tiny-component-compiler.git"
|
|
41
|
-
}
|
|
42
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@needle-tools/needle-component-compiler",
|
|
3
|
+
"version": "1.12.0-da2e0be",
|
|
4
|
+
"description": "Compile mock unity components from typescript",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"tsc": "tsc",
|
|
8
|
+
"dev": "npm-watch compile",
|
|
9
|
+
"compile": "tsc src/component-compiler.ts",
|
|
10
|
+
"test": "mocha -r ts-node/register test/**/*serializable.test.ts"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"typescript": "^4.5.5"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/chai": "^4.3.3",
|
|
17
|
+
"@types/mocha": "^9.1.1",
|
|
18
|
+
"@types/node": "^18.7.18",
|
|
19
|
+
"chai": "^4.3.6",
|
|
20
|
+
"mocha": "^10.0.0",
|
|
21
|
+
"ts-node": "^10.9.1",
|
|
22
|
+
"npm-watch": "^0.13.0"
|
|
23
|
+
},
|
|
24
|
+
"watch": {
|
|
25
|
+
"compile": {
|
|
26
|
+
"patterns": [
|
|
27
|
+
"src/component-compiler.ts"
|
|
28
|
+
],
|
|
29
|
+
"extensions": "ts",
|
|
30
|
+
"quiet": false
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"author": {
|
|
34
|
+
"name": "Needle",
|
|
35
|
+
"email": "help@needle.tools",
|
|
36
|
+
"url": "https://needle.tools/"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/needle-tools/needle-tiny-component-compiler.git"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public",
|
|
44
|
+
"registry": "https://registry.npmjs.org/"
|
|
45
|
+
}
|
|
46
|
+
}
|