@needle-tools/needle-component-compiler 1.9.2-exp → 1.9.2

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 (112) hide show
  1. package/COMPILE.bat +1 -0
  2. package/Changelog.md +3 -2
  3. package/DEV.bat +1 -0
  4. package/INSTALL.bat +1 -0
  5. package/PUBLISH.bat +8 -0
  6. package/RUN_MANUAL_TEST.bat +1 -0
  7. package/RUN_TESTS.bat +1 -0
  8. package/package.json +12 -17
  9. package/schemes/MyNew.component.json +1 -0
  10. package/schemes/MyTest.component.json +1 -0
  11. package/src/component-compiler.js +6 -3
  12. package/src/component-compiler.ts +737 -0
  13. package/src/test.js +24 -26
  14. package/src/test.ts +234 -0
  15. package/test/blender/codegen/basic/expected.component.json +4 -0
  16. package/test/blender/codegen/basic/input.js +26 -0
  17. package/test/blender/codegen/basic/input.ts +3 -0
  18. package/test/blender/codegen/basic/output.component.json +1 -0
  19. package/test/blender/codegen/float field/expected.component.json +8 -0
  20. package/test/blender/codegen/float field/input.js +28 -0
  21. package/test/blender/codegen/float field/input.ts +4 -0
  22. package/test/blender/codegen/float field/output.component.json +1 -0
  23. package/test/blender/codegen/reference_animation/expected.component.json +7 -0
  24. package/test/blender/codegen/reference_animation/input.js +35 -0
  25. package/test/blender/codegen/reference_animation/input.ts +4 -0
  26. package/test/blender/codegen/reference_animation/output.component.json +1 -0
  27. package/test/blender/codegen/reference_behaviour/expected.component.json +7 -0
  28. package/test/blender/codegen/reference_behaviour/input.js +35 -0
  29. package/test/blender/codegen/reference_behaviour/input.ts +5 -0
  30. package/test/blender/codegen/reference_behaviour/output.component.json +1 -0
  31. package/test/component.basic.test.ts +53 -0
  32. package/test/component.methods.test.ts +185 -0
  33. package/test/component.nonserialized.test.ts +45 -0
  34. package/test/component.primitives.test.ts +123 -0
  35. package/test/csharp/codegen/abstract method/expected.cs +14 -0
  36. package/test/csharp/codegen/abstract method/input.js +27 -0
  37. package/test/csharp/codegen/abstract method/input.ts +4 -0
  38. package/test/csharp/codegen/abstract method/output.cs +14 -0
  39. package/test/csharp/codegen/basic/expected.cs +13 -0
  40. package/test/csharp/codegen/basic/input.js +26 -0
  41. package/test/csharp/codegen/basic/input.ts +2 -0
  42. package/test/csharp/codegen/basic/output.cs +13 -0
  43. package/test/csharp/codegen/basic-no-export/expected.cs +0 -0
  44. package/test/csharp/codegen/basic-no-export/input.js +27 -0
  45. package/test/csharp/codegen/basic-no-export/input.ts +4 -0
  46. package/test/csharp/codegen/basic-no-export/output.cs +0 -0
  47. package/test/csharp/codegen/bool/expected.cs +14 -0
  48. package/test/csharp/codegen/bool/input.js +26 -0
  49. package/test/csharp/codegen/bool/input.ts +3 -0
  50. package/test/csharp/codegen/bool/output.cs +14 -0
  51. package/test/csharp/codegen/fields with default values/expected.cs +18 -0
  52. package/test/csharp/codegen/fields with default values/input.js +32 -0
  53. package/test/csharp/codegen/fields with default values/input.ts +7 -0
  54. package/test/csharp/codegen/fields with default values/output.cs +18 -0
  55. package/test/csharp/codegen/method ignore inline type declaration/expected.cs +14 -0
  56. package/test/csharp/codegen/method ignore inline type declaration/input.js +27 -0
  57. package/test/csharp/codegen/method ignore inline type declaration/input.ts +3 -0
  58. package/test/csharp/codegen/method ignore inline type declaration/output.cs +14 -0
  59. package/test/csharp/codegen/nonserialized ignore field/expected.cs +13 -0
  60. package/test/csharp/codegen/nonserialized ignore field/input.js +26 -0
  61. package/test/csharp/codegen/nonserialized ignore field/input.ts +4 -0
  62. package/test/csharp/codegen/nonserialized ignore field/output.cs +13 -0
  63. package/test/csharp/codegen/nonserialized on property does not affect method/expected.cs +14 -0
  64. package/test/csharp/codegen/nonserialized on property does not affect method/input.js +34 -0
  65. package/test/csharp/codegen/nonserialized on property does not affect method/input.ts +8 -0
  66. package/test/csharp/codegen/nonserialized on property does not affect method/output.cs +13 -0
  67. package/test/csharp/codegen/number/expected.cs +14 -0
  68. package/test/csharp/codegen/number/input.js +26 -0
  69. package/test/csharp/codegen/number/input.ts +3 -0
  70. package/test/csharp/codegen/number/output.cs +14 -0
  71. package/test/csharp/codegen/object/expected.cs +14 -0
  72. package/test/csharp/codegen/object/input.js +26 -0
  73. package/test/csharp/codegen/object/input.ts +3 -0
  74. package/test/csharp/codegen/object/output.cs +14 -0
  75. package/test/csharp/codegen/private.methods/expected.cs +13 -0
  76. package/test/csharp/codegen/private.methods/input.js +27 -0
  77. package/test/csharp/codegen/private.methods/input.ts +3 -0
  78. package/test/csharp/codegen/private.methods/output.cs +13 -0
  79. package/test/csharp/codegen/protected.methods/expected.cs +13 -0
  80. package/test/csharp/codegen/protected.methods/input.js +27 -0
  81. package/test/csharp/codegen/protected.methods/input.ts +3 -0
  82. package/test/csharp/codegen/protected.methods/output.cs +13 -0
  83. package/test/csharp/codegen/public method with args/expected.cs +14 -0
  84. package/test/csharp/codegen/public method with args/input.js +27 -0
  85. package/test/csharp/codegen/public method with args/input.ts +3 -0
  86. package/test/csharp/codegen/public method with args/output.cs +14 -0
  87. package/test/csharp/codegen/public method with multiple args/expected.cs +14 -0
  88. package/test/csharp/codegen/public method with multiple args/input.js +27 -0
  89. package/test/csharp/codegen/public method with multiple args/input.ts +3 -0
  90. package/test/csharp/codegen/public method with multiple args/output.cs +14 -0
  91. package/test/csharp/codegen/public.methods/expected.cs +14 -0
  92. package/test/csharp/codegen/public.methods/input.js +27 -0
  93. package/test/csharp/codegen/public.methods/input.ts +3 -0
  94. package/test/csharp/codegen/public.methods/output.cs +14 -0
  95. package/test/csharp/codegen/static method/expected.cs +13 -0
  96. package/test/csharp/codegen/static method/input.js +27 -0
  97. package/test/csharp/codegen/static method/input.ts +3 -0
  98. package/test/csharp/codegen/static method/output.cs +14 -0
  99. package/test/csharp/codegen/string/expected.cs +14 -0
  100. package/test/csharp/codegen/string/input.js +26 -0
  101. package/test/csharp/codegen/string/input.ts +3 -0
  102. package/test/csharp/codegen/string/output.cs +14 -0
  103. package/test/csharp/codegen/stringArray/expected.cs +14 -0
  104. package/test/csharp/codegen/stringArray/input.js +26 -0
  105. package/test/csharp/codegen/stringArray/input.ts +3 -0
  106. package/test/csharp/codegen/stringArray/output.cs +14 -0
  107. package/test/helpers.ts +72 -0
  108. package/workspace.code-workspace +11 -11
  109. package/src/base-compiler.js +0 -404
  110. package/src/blender-compiler.js +0 -100
  111. package/src/commands.js +0 -11
  112. package/src/watcher.js +0 -64
package/src/test.js CHANGED
@@ -20,8 +20,7 @@ var MyTestComponent = /** @class */ (function (_super) {
20
20
  __extends(MyTestComponent, _super);
21
21
  function MyTestComponent() {
22
22
  var _this = _super !== null && _super.apply(this, arguments) || this;
23
- _this.myVector2 = new Vector2(1, .5);
24
- _this.myNumber = 1;
23
+ _this.myVecgfdsgtor2 = new Vector2(1, .5);
25
24
  return _this;
26
25
  }
27
26
  MyTestComponent.prototype.myMethod = function () {
@@ -29,11 +28,31 @@ var MyTestComponent = /** @class */ (function (_super) {
29
28
  return MyTestComponent;
30
29
  }(Behaviour));
31
30
  exports.MyTestComponent = MyTestComponent;
32
- //@type("MyComponent")
31
+ // export class SkipFieldAndMethod extends Behaviour {
32
+ // //@nonSerialized
33
+ // myMethod() {
34
+ // }
35
+ // // @nonSerialized
36
+ // myField : string;
37
+ // }
38
+ // export class ComponentWithUnknownType extends Behaviour {
39
+ // views: SomeUnknownType;
40
+ // }
41
+ // export class ComponentWithAnimationClip extends Behaviour implements IPointerClickHandler {
42
+ // @serializeable(AnimationClip)
43
+ // animation?: THREE.AnimationClip;
44
+ // }
45
+ // export abstract class MyAbstractComponent extends Behaviour {
46
+ // abstract myMethod();
47
+ // }
33
48
  // export class CameraView extends Behaviour {
34
49
  // static views: CameraView[] = [];
35
50
  // }
36
- // export class SocLoader extends Behaviour {
51
+ // export class EventComponent extends Behaviour {
52
+ // @serializeable(EventList)
53
+ // roomChanged: EventList = new EventList();
54
+ // }
55
+ // export class SocLoader extends Behaviour {
37
56
  // @serializeable(AssetReference)
38
57
  // scenes: Array<AssetReference> = [];
39
58
  // }
@@ -53,32 +72,11 @@ exports.MyTestComponent = MyTestComponent;
53
72
  // map2 : Map<object> = new Map<object>();
54
73
  // private myThing : Test123;
55
74
  // }
56
- // // @type UnityEngine.MonoBehaviour
75
+ // //@type UnityEngine.MonoBehaviour
57
76
  // export class ButtonObject extends Interactable implements IPointerClickHandler, ISerializable {
58
77
  // //@type UnityEngine.Transform[]
59
78
  // myType?: SceneFXWindow;
60
79
  // }
61
- // export class EventComponent extends Behaviour {
62
- // @serializeable(EventList)
63
- // roomChanged: EventList = new EventList();
64
- // }
65
- // export class SkipFieldAndMethod extends Behaviour {
66
- // //@nonSerialized
67
- // myMethod() {
68
- // }
69
- // // @nonSerialized
70
- // myField : string;
71
- // }
72
- // export class ComponentWithUnknownType extends Behaviour {
73
- // views: SomeUnknownType;
74
- // }
75
- // export class ComponentWithAnimationClip extends Behaviour implements IPointerClickHandler {
76
- // @serializeable(AnimationClip)
77
- // animation?: THREE.AnimationClip;
78
- // }
79
- // export abstract class MyAbstractComponent extends Behaviour {
80
- // abstract myMethod();
81
- // }
82
80
  // import { Behaviour } from "needle.tiny.engine/engine-components/Component";
83
81
  // import { RoomEntity } from "./Room";
84
82
  // import { Behaviour } from "needle.tiny.engine/engine-components/Component";
package/src/test.ts ADDED
@@ -0,0 +1,234 @@
1
+ import { ThisExpression } from "typescript";
2
+
3
+ export class MyTestComponent extends Behaviour {
4
+ public myVecgfdsgtor2: Vector2 = new Vector2(1, .5);
5
+ private myMethod(){
6
+
7
+ }
8
+ }
9
+
10
+
11
+ // export class SkipFieldAndMethod extends Behaviour {
12
+
13
+ // //@nonSerialized
14
+ // myMethod() {
15
+
16
+ // }
17
+
18
+ // // @nonSerialized
19
+ // myField : string;
20
+
21
+ // }
22
+
23
+
24
+ // export class ComponentWithUnknownType extends Behaviour {
25
+ // views: SomeUnknownType;
26
+ // }
27
+
28
+
29
+ // export class ComponentWithAnimationClip extends Behaviour implements IPointerClickHandler {
30
+
31
+ // @serializeable(AnimationClip)
32
+ // animation?: THREE.AnimationClip;
33
+ // }
34
+
35
+ // export abstract class MyAbstractComponent extends Behaviour {
36
+ // abstract myMethod();
37
+ // }
38
+
39
+
40
+ // export class CameraView extends Behaviour {
41
+ // static views: CameraView[] = [];
42
+ // }
43
+
44
+
45
+ // export class EventComponent extends Behaviour {
46
+ // @serializeable(EventList)
47
+ // roomChanged: EventList = new EventList();
48
+ // }
49
+
50
+ // export class SocLoader extends Behaviour {
51
+
52
+ // @serializeable(AssetReference)
53
+ // scenes: Array<AssetReference> = [];
54
+ // }
55
+ // // class Test123 {}
56
+
57
+ // export class Bla extends Behaviour
58
+ // {
59
+ // myNumber:number = 42;
60
+ // myBool:boolean = true;
61
+ // myString:string = "test";
62
+ // numberArr: number[] = [1,2,3];
63
+ // myColor : THREE.Color = new THREE.Color(255, 0, 0);
64
+ // renderers = new Array<Renderer>();
65
+ // renderers2 : Renderer[] = [];
66
+ // objArr : object[];
67
+ // colArr: THREE.Color[] = [new THREE.Color(1,2,3)];
68
+ // map : Map<string> = new Map<string>();
69
+ // map2 : Map<object> = new Map<object>();
70
+ // private myThing : Test123;
71
+ // }
72
+
73
+ // //@type UnityEngine.MonoBehaviour
74
+ // export class ButtonObject extends Interactable implements IPointerClickHandler, ISerializable {
75
+
76
+ // //@type UnityEngine.Transform[]
77
+ // myType?: SceneFXWindow;
78
+ // }
79
+
80
+ // import { Behaviour } from "needle.tiny.engine/engine-components/Component";
81
+ // import { RoomEntity } from "./Room";
82
+
83
+ // import { Behaviour } from "needle.tiny.engine/engine-components/Component";
84
+
85
+ // export class MyNewScript extends DriveClient
86
+ // {
87
+ // //@type test
88
+ // texture : RenderTexture;
89
+ // }
90
+
91
+ // namespace Hello.World
92
+ // {
93
+ // namespace Deep {
94
+ // export class MyClass extends Behaviour {
95
+ // //@ifdef TEST
96
+ // public myFloat :number;
97
+ // }
98
+ // }
99
+ // }
100
+
101
+ // class OtherClass extends Behaviour {
102
+
103
+ // }
104
+
105
+ //@type (RoomEntity)
106
+ // export class NavigationManager extends RoomEntity {
107
+
108
+ // fl:number = 1;
109
+
110
+ // nav_forward() {
111
+
112
+ // }
113
+
114
+ // nav_backward() {
115
+
116
+ // }
117
+ // }
118
+
119
+ // export abstract class NavComponent extends Behaviour {
120
+
121
+ // abstract next();
122
+ // abstract prev();
123
+ // abstract isAtEnd():boolean;
124
+ // }
125
+
126
+
127
+ // export class PointOfInterest extends Behaviour {
128
+
129
+ // myVal:number = 12;
130
+
131
+ // // @type(HELLO)
132
+ // myFunction(){
133
+
134
+ // }
135
+
136
+ // // @type(UnityEngine.Camera)
137
+ // view?:Camera;
138
+ // test:string = "123";
139
+ // // test
140
+ // }
141
+
142
+ // export class MaterialColorHandler extends Behaviour {
143
+
144
+ // @serializeable(Renderer)
145
+ // renderer?: Renderer[];
146
+ // }
147
+
148
+ // export class MyArray extends Behaviour {
149
+
150
+ // arr? : Array<number> = [1,2,3];
151
+ // }
152
+
153
+ // export class PrivateSerializedField extends Behaviour {
154
+
155
+ // //@serializeField
156
+ // private color? : THREE.Color;
157
+ // }
158
+ // export class MyPropertyClass extends Behaviour {
159
+ // set color(col: THREE.Color) {
160
+ // }
161
+ // }
162
+
163
+ // export class MyClassWithAFloat extends Behaviour {
164
+ // myfloat:number = .5;
165
+ // private myString : string;
166
+ // }
167
+
168
+ // export class GltfExport extends Behaviour {
169
+ // binary: boolean = true;
170
+ // "$serializedTypes" = {
171
+ // url:null
172
+ // }
173
+
174
+ // // @contextmenu enable this
175
+ // test(){
176
+
177
+ // }
178
+ // }
179
+
180
+ // export class SetColor extends Behaviour {
181
+
182
+ // "@serializedTypes" = {
183
+ // col: Number,
184
+ // }
185
+ // }
186
+
187
+ // class Behaviour {
188
+
189
+ // }
190
+
191
+ // export class PlatformerMusic extends Behaviour implements IPlaymodeChangeListener {
192
+ // source?: AudioSource;
193
+ // editMode?: string;
194
+ // playMode?: string;
195
+
196
+ // onPlaymodeChange(playmode: PlayMode): void {
197
+ // console.log(this);
198
+ // if(!this.source) return;
199
+ // const clip = playmode.isInPlayMode ? this.playMode : this.editMode;
200
+ // console.log("PLAY", clip);
201
+ // this.source.play(clip);
202
+ // }
203
+
204
+ // }
205
+
206
+ // // TODO: export UnityEvent like this
207
+ // // disable codegen
208
+ // class UnityEvent {
209
+ // methods: Function[] = [];
210
+ // invoke() {
211
+ // for (const m of this.methods) {
212
+ // m();
213
+ // }
214
+ // }
215
+ // }
216
+
217
+ // export class MyClass extends Behaviour {
218
+ // myFloat: number = 15;
219
+ // myBool: boolean;
220
+ // // just some default values
221
+ // myArray: number[] = [1, 2, 3];
222
+ // // comment for myString
223
+ // myString: string = "this is a string1";
224
+ // myObject: THREE.Object3D;
225
+ // myBool2: boolean;
226
+
227
+ // myFunction() { }
228
+ // myFunctionWithStringParameter(string: string) { }
229
+ // myFunctionWithSomeObjectAndArray(obj: THREE.Object3D, arr: number[]) { }
230
+ // myFunctionWithoutParamTypes(test) { }
231
+
232
+ // someOtherStuff: THREE.Object3D[] | null = null;
233
+ // myEvent: UnityEvent;
234
+ // }
@@ -0,0 +1,4 @@
1
+ {
2
+ "BasicComponent": {
3
+ }
4
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ exports.__esModule = true;
18
+ exports.BasicComponent = void 0;
19
+ var BasicComponent = /** @class */ (function (_super) {
20
+ __extends(BasicComponent, _super);
21
+ function BasicComponent() {
22
+ return _super !== null && _super.apply(this, arguments) || this;
23
+ }
24
+ return BasicComponent;
25
+ }(Behaviour));
26
+ exports.BasicComponent = BasicComponent;
@@ -0,0 +1,3 @@
1
+ export class BasicComponent extends Behaviour {
2
+ }
3
+
@@ -0,0 +1 @@
1
+ {
2
  "BasicComponent": {
1
3
  }
@@ -0,0 +1,8 @@
1
+ {
2
+ "BasicComponent": {
3
+ "myFloat": {
4
+ "type": "float",
5
+ "value": 42
6
+ }
7
+ }
8
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ exports.__esModule = true;
18
+ exports.BasicComponent = void 0;
19
+ var BasicComponent = /** @class */ (function (_super) {
20
+ __extends(BasicComponent, _super);
21
+ function BasicComponent() {
22
+ var _this = _super !== null && _super.apply(this, arguments) || this;
23
+ _this.myFloat = 42;
24
+ return _this;
25
+ }
26
+ return BasicComponent;
27
+ }(Behaviour));
28
+ exports.BasicComponent = BasicComponent;
@@ -0,0 +1,4 @@
1
+ export class BasicComponent extends Behaviour {
2
+ myFloat:number = 42;
3
+ }
4
+
@@ -0,0 +1 @@
1
+ {
2
  "BasicComponent": {
1
3
  "myFloat": {
2
4
  "type": "float",
3
5
  "value": 42
4
6
  }
5
7
  }
@@ -0,0 +1,7 @@
1
+ {
2
+ "BasicComponent": {
3
+ "animation": {
4
+ "type": "comp"
5
+ }
6
+ }
7
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ exports.__esModule = true;
24
+ exports.BasicComponent = void 0;
25
+ var BasicComponent = /** @class */ (function (_super) {
26
+ __extends(BasicComponent, _super);
27
+ function BasicComponent() {
28
+ return _super !== null && _super.apply(this, arguments) || this;
29
+ }
30
+ __decorate([
31
+ serializable(Behaviour)
32
+ ], BasicComponent.prototype, "animation");
33
+ return BasicComponent;
34
+ }(Behaviour));
35
+ exports.BasicComponent = BasicComponent;
@@ -0,0 +1,4 @@
1
+ export class BasicComponent extends Behaviour {
2
+ @serializable(Behaviour)
3
+ animation : Animation;
4
+ }
@@ -0,0 +1 @@
1
+ {
2
  "BasicComponent": {
1
3
  "animation": {
2
4
  "type": "animation"
3
5
  }
4
6
  }
@@ -0,0 +1,7 @@
1
+ {
2
+ "BasicComponent": {
3
+ "basicComponent": {
4
+ "type": "comp"
5
+ }
6
+ }
7
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ exports.__esModule = true;
24
+ exports.BasicComponent = void 0;
25
+ var BasicComponent = /** @class */ (function (_super) {
26
+ __extends(BasicComponent, _super);
27
+ function BasicComponent() {
28
+ return _super !== null && _super.apply(this, arguments) || this;
29
+ }
30
+ __decorate([
31
+ serializable(Behaviour)
32
+ ], BasicComponent.prototype, "basicComponent");
33
+ return BasicComponent;
34
+ }(Behaviour));
35
+ exports.BasicComponent = BasicComponent;
@@ -0,0 +1,5 @@
1
+ export class BasicComponent extends Behaviour {
2
+ @serializable(Behaviour)
3
+ basicComponent : Behaviour;
4
+ }
5
+
@@ -0,0 +1 @@
1
+ {
2
  "BasicComponent": {
1
3
  "basicComponent": {
2
4
  "type": "comp"
3
5
  }
4
6
  }
@@ -0,0 +1,53 @@
1
+ import { compareCodegen, compareCodegenWithDefaultContext } from './helpers';
2
+
3
+
4
+ describe('Basic typescript', () => {
5
+
6
+ it('should generate component', () => {
7
+ compareCodegenWithDefaultContext("basic",
8
+ // INPUT
9
+ `export class BasicComponet extends Behaviour {
10
+ }
11
+ `,
12
+ // EXPECTED
13
+ `public partial class BasicComponet : UnityEngine.MonoBehaviour
14
+ {
15
+ }`
16
+ );
17
+ });
18
+
19
+
20
+
21
+ it('should not generate component', () => {
22
+ compareCodegen("basic-no-export",
23
+ // INPUT
24
+ `
25
+ //@dont-generate-component
26
+ export class BasicComponet extends Behaviour {
27
+ }
28
+ `,
29
+ // EXPECTED
30
+ ``
31
+ );
32
+ });
33
+
34
+
35
+
36
+
37
+ it('should ignore abstract type', () => {
38
+ compareCodegen("basic-no-export",
39
+ // INPUT
40
+ `
41
+ //@dont-generate-component
42
+ export abstract class BasicComponet extends Behaviour {
43
+ }
44
+ `,
45
+ // EXPECTED
46
+ ``
47
+ );
48
+ });
49
+
50
+
51
+ });
52
+
53
+