@needle-tools/needle-component-compiler 3.0.0-alpha → 3.0.0-alpha.1.42c96bd

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 CHANGED
@@ -1,89 +1,134 @@
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
- ## [2.4.1-pre] - 2023-04-03
8
- # Blender compiler
9
- - Add: typenames
10
-
11
- ## [2.4.0-pre] - 2023-03-31
12
- # Blender compiler
13
- - Add: emit types from declared class implementing `IComponent` e.g. ``declare class MyComp implements IComponent``
14
-
15
- ## [2.3.0-pre] - 2022-11-22
16
- # Blender compiler
17
- - Add emit array
18
- - Add emit types by class name if unknown
19
-
20
- ## [2.2.0-pre.1] - 2022-11-13
21
- - Add: watcher now also generates the register_types file
22
- - Add: deleting code files now also deletes the generated files and reports it
23
-
24
- ## [2.1.0-pre] - 2022-11-12
25
- - Add blender scheme compiler for creating and updating schemes (or removing them when the component gets deleted)
26
-
27
- ## [1.9.1] - 2022-11-05
28
- - Fix ``new Vector2(1, .5)`` generating invalid C# where number arguments were emitted as double instead of float
29
-
30
- ## [1.9.0] - 2022-10-18
31
- - Change: emit ``onEnable`` as ``OnEnable`` and ``onDisable`` as ``OnDisable`` so Unity creates component checkboxes
32
- - Change: ignore private and protected methods
33
-
34
- ## [1.8.0] - 2022-09-02
35
- - Add ``@nonSerialized`` decorator for fields and methods
36
- - Fix comment gen for unknown types
37
-
38
- ## [1.7.3] - 2022-09-02
39
- - Fix codegen for unknown array types
40
- - Fix codegen for abstract classes
41
- - Fix codegen for types imported as e.g. THREE.AnimationClip
42
-
43
- ## [1.7.2] - 2022-07-27
44
- - fix UnityEvent codegen
45
-
46
- ## [1.7.1] - 2022-07-25
47
- - fix array type codegen, for example ``scenes: Array<AssetReference> = [];``, see issue https://github.com/needle-tools/needle-tiny-playground/issues/285
48
-
49
- ## [1.7.0] - 2022-07-14
50
- - change: skip non-serializeable variables (private without ``@serializable``)
51
- - improve member type generation
52
- - fix bug in type generation for array types
53
- - add/improve initial assignment codegen for object types
54
-
55
- ## [1.6.3] - 2022-07-12
56
- - add warning when class type is unknown
57
-
58
- ## [1.6.2] - 2022-07-11
59
- - fix ``@type`` for class declaration
60
-
61
- ## [1.6.1] - 2022-07-10
62
- - add using ``types.json`` json file that will be generated from Unity
63
- - change ``@type`` annotiation to only work without braces to be consistent
64
-
65
- ## [1.5.0] - 2022-07-07
66
- - change ``@type`` annotation to work with and without braces (e.g. ``@type My.Type`` or ``@type (My.Type)``)
67
-
68
- ## [1.4.0] - 2022-07-06
69
- - add CODEGEN_START and END sections to allow adding code before or after a generated componnet
70
- - add ``@ifdef`` to ifdef fields
71
-
72
- ## [1.3.0] - 2022-06-27
73
- - add support for typescript namespace
74
-
75
- ## [1.2.1] - 2022-06-15
76
- - allow adding ``@type(MyNamespace.MyType)`` to class declaration
77
-
78
- ## [1.1.0] - 2022-06-13
79
- - add ``@type(MyNamespace.MyType)`` decorator for fields to specifiy C# type
80
- - add minimal docs to readme
81
- - dont emit comments anymore
82
- - make created classes partial
83
-
84
- ## [1.0.1] - 2022-05-29
85
- - disable all warnings for generated scripts
86
- - add mesh and texture types
87
-
88
- ## [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
+ ## [3.0.0-alpha.1] - 2026-03-02
8
+ - Fix: destructured method parameters (e.g. `{xr}`) now emit as `object @obj` instead of invalid `object @{xr}`
9
+ - Fix: `Object3D` type now correctly maps to `UnityEngine.Transform`
10
+ - Add: `RectTransform` type mapping to `UnityEngine.RectTransform`
11
+
12
+ ## [2.4.1-pre] - 2023-04-03
13
+ # Blender compiler
14
+ - Add: typenames
15
+
16
+ ## [2.4.0-pre] - 2023-03-31
17
+ # Blender compiler
18
+ - Add: emit types from declared class implementing `IComponent` e.g. ``declare class MyComp implements IComponent``
19
+
20
+ ## [2.3.0-pre] - 2022-11-22
21
+ # Blender compiler
22
+ - Add emit array
23
+ - Add emit types by class name if unknown
24
+
25
+ ## [2.2.0-pre.1] - 2022-11-13
26
+ - Add: watcher now also generates the register_types file
27
+ - Add: deleting code files now also deletes the generated files and reports it
28
+
29
+ ## [2.1.0-pre] - 2022-11-12
30
+ - Add blender scheme compiler for creating and updating schemes (or removing them when the component gets deleted)
31
+
32
+ ## [1.12.2] - 2025-06-06
33
+ - Fix: Private fields decorated with `@serializable()` should be annotated with `UnityEngine.SerializeField`
34
+ - Fix: Comment for `// @serializeField` should not affect subsequent fields
35
+
36
+ ## [1.12.0] - 2025-06-02
37
+ - Add: Support to serialize unknown classes when annotated with `// @type object`
38
+
39
+ ## [1.11.2] - 2023-12-16
40
+ - Fix: property setter emitting invalid C# code
41
+
42
+ ## [1.11.1] - 2023-12-02
43
+ - Fix: Use Unity AnimatorController type
44
+ - Fix: method inline anonymous type declaration (e.g. `myMethod(arg: {x:number})`)
45
+
46
+ ## [1.11.0] - 2023-11-18
47
+ - Add: support to wrap fields with `#if UNITY_EDITOR` if their namespace contains UnityEditor
48
+ - Add: more threejs types to generate Unity Material fields for
49
+
50
+ ## [1.10.3] - 2023-09-08
51
+ - Add: Needle Engine type `RGBAColor` is now automatically emitted as `UnityEngine.Color`
52
+
53
+ ## [1.10.2] - 2023-09-08
54
+ - Fix: `@type` was not properly applied for `new expression` cases (e.g. `new RGBAColor` should produce a `new Color` when decorated with `@type Color`)
55
+
56
+ ## [1.10.1] - 2023-08-02
57
+ - Add: use `@tooltip` to emit a UnityEngine.Tooltip
58
+ - Update Readme
59
+
60
+ ## [1.9.4] - 2023-05-24
61
+ - Change: `Object3D` now emits `GameObject` field instead of `Transform`
62
+ - Fix: ignore `static` methods
63
+ - Fix: ignore `abstract` methods
64
+
65
+ ## [1.9.3] - 2022-12-30
66
+ - Add debug logs for when no file or target directory was passed in. Also wrapping core with try catch
67
+
68
+ ## [1.9.2] - 2022-11-29
69
+ - Fix codegen deleting code added manually outside of codegen sections
70
+ - Fix codegen creating output directory if it does not exist yet
71
+
72
+ ## [1.9.1] - 2022-11-05
73
+ - Fix ``new Vector2(1, .5)`` generating invalid C# where number arguments were emitted as double instead of float
74
+
75
+ ## [1.9.0] - 2022-10-18
76
+ - Change: emit ``onEnable`` as ``OnEnable`` and ``onDisable`` as ``OnDisable`` so Unity creates component checkboxes
77
+ - Change: ignore private and protected methods
78
+
79
+ ## [1.8.0] - 2022-09-02
80
+ - Add ``@nonSerialized`` decorator for fields and methods
81
+ - Fix comment gen for unknown types
82
+
83
+ ## [1.7.3] - 2022-09-02
84
+ - Fix codegen for unknown array types
85
+ - Fix codegen for abstract classes
86
+ - Fix codegen for types imported as e.g. THREE.AnimationClip
87
+
88
+ ## [1.7.2] - 2022-07-27
89
+ - fix UnityEvent codegen
90
+
91
+ ## [1.7.1] - 2022-07-25
92
+ - fix array type codegen, for example ``scenes: Array<AssetReference> = [];``, see issue https://github.com/needle-tools/needle-tiny-playground/issues/285
93
+
94
+ ## [1.7.0] - 2022-07-14
95
+ - change: skip non-serializeable variables (private without ``@serializable``)
96
+ - improve member type generation
97
+ - fix bug in type generation for array types
98
+ - add/improve initial assignment codegen for object types
99
+
100
+ ## [1.6.3] - 2022-07-12
101
+ - add warning when class type is unknown
102
+
103
+ ## [1.6.2] - 2022-07-11
104
+ - fix ``@type`` for class declaration
105
+
106
+ ## [1.6.1] - 2022-07-10
107
+ - add using ``types.json`` json file that will be generated from Unity
108
+ - change ``@type`` annotiation to only work without braces to be consistent
109
+
110
+ ## [1.5.0] - 2022-07-07
111
+ - change ``@type`` annotation to work with and without braces (e.g. ``@type My.Type`` or ``@type (My.Type)``)
112
+
113
+ ## [1.4.0] - 2022-07-06
114
+ - add CODEGEN_START and END sections to allow adding code before or after a generated componnet
115
+ - add ``@ifdef`` to ifdef fields
116
+
117
+ ## [1.3.0] - 2022-06-27
118
+ - add support for typescript namespace
119
+
120
+ ## [1.2.1] - 2022-06-15
121
+ - allow adding ``@type(MyNamespace.MyType)`` to class declaration
122
+
123
+ ## [1.1.0] - 2022-06-13
124
+ - add ``@type(MyNamespace.MyType)`` decorator for fields to specifiy C# type
125
+ - add minimal docs to readme
126
+ - dont emit comments anymore
127
+ - make created classes partial
128
+
129
+ ## [1.0.1] - 2022-05-29
130
+ - disable all warnings for generated scripts
131
+ - add mesh and texture types
132
+
133
+ ## [1.0.0] - 2022-04-22
89
134
  - initial release
package/Readme.md CHANGED
@@ -1,19 +1,93 @@
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
-
18
- ### Test
19
- - Run single test: `` npm run test:single -- -r ts-node/register "./test/blender/blender.from_typedef.test.ts"``
1
+ ## Needle Engine Component Compiler
2
+
3
+ Compiles TypeScript component definitions into **Unity C#** component stubs and **Blender** Python component schemas for Needle Engine.
4
+
5
+ ```
6
+ npm install @needle-tools/needle-component-compiler
7
+ ```
8
+
9
+ ### Supported TypeScript Features
10
+
11
+ - Classes extending `Behaviour`, `MonoBehaviour`, or implementing `IComponent`
12
+ - Public, protected, and private fields with type annotations
13
+ - Default values (primitives, `new` expressions, literals)
14
+ - Array types: `T[]`, `Array<T>`
15
+ - Union types (nullable types like `Object3D | null` resolve to the concrete type)
16
+ - Enums (with value initialization)
17
+ - Methods with parameters and return types
18
+ - Destructured parameters (compiled as `object`)
19
+
20
+ ### Comment Directives
21
+
22
+ Use `//` comments above classes, fields, or methods to control code generation:
23
+
24
+ | Directive | Target | Description |
25
+ |---|---|---|
26
+ | `@generate-component` | Class | Force generation (not required, classes are generated by default) |
27
+ | `@dont-generate-component` | Class | Skip generating this class entirely |
28
+ | `@type MyNamespace.MyType` | Class / Field | Override the resolved C# type or base class |
29
+ | `@abstract` | Class | Mark the generated class as `abstract` |
30
+ | `@serializeField` | Field | Emit `[UnityEngine.SerializeField]` attribute |
31
+ | `@nonSerialized` | Field / Method | Skip generating C# code for this member |
32
+ | `@tooltip "My text"` | Field | Emit `[UnityEngine.Tooltip("My text")]` (C#) or `"description"` (Blender) |
33
+ | `@contextmenu "Label"` | Method | Emit `[UnityEngine.ContextMenu("Label")]` |
34
+ | `@ifdef MY_DEFINE` | Field | Wrap field in `#if MY_DEFINE` / `#endif` |
35
+
36
+ ### JSDoc Tooltips
37
+
38
+ JSDoc comments (`/** ... */`) on fields are automatically converted to tooltips. The text is sanitized (inline code, URLs, images, and JSDoc tags are stripped) to produce clean tooltip text.
39
+
40
+ ```ts
41
+ export class MyComponent extends Behaviour {
42
+ /** The movement speed of the character */
43
+ public speed: number = 5;
44
+ }
45
+ ```
46
+
47
+ **C# output:**
48
+ ```csharp
49
+ [UnityEngine.Tooltip("The movement speed of the character")]
50
+ public float @speed = 5f;
51
+ ```
52
+
53
+ **Blender output:**
54
+ ```json
55
+ "speed": {
56
+ "type": "float",
57
+ "value": 5,
58
+ "description": "The movement speed of the character"
59
+ }
60
+ ```
61
+
62
+ An explicit `// @tooltip` directive takes priority over a JSDoc comment on the same field.
63
+
64
+ ### Codegen Fences
65
+
66
+ Generated C# files are wrapped in codegen fences:
67
+
68
+ ```csharp
69
+ // NEEDLE_CODEGEN_START
70
+ // auto generated code - do not edit directly
71
+
72
+ #pragma warning disable
73
+
74
+ namespace Needle.Typescript.GeneratedComponents
75
+ {
76
+ public partial class MyComponent : UnityEngine.MonoBehaviour
77
+ {
78
+ public float @speed = 5f;
79
+ }
80
+ }
81
+
82
+ // NEEDLE_CODEGEN_END
83
+ ```
84
+
85
+ This allows you to add custom code outside the fences that will be preserved when the file is regenerated.
86
+
87
+ # Contact ✒️
88
+ <b>[🌵 Needle](https://needle.tools)</b> •
89
+ [Github](https://github.com/needle-tools) •
90
+ [Twitter](https://twitter.com/NeedleTools) •
91
+ [Discord](https://discord.needle.tools) •
92
+ [Forum](https://forum.needle.tools) •
93
+ [Youtube](https://youtube.com/@needle-tools)
@@ -1,23 +1,23 @@
1
- import { Argument, CodeTextWriter, EnumMember, ISink, IWriter, Visibility } from "./base-compiler";
2
- import { TypeSourceInformation } from "./register-types";
3
- export declare abstract class BaseWriter implements IWriter {
4
- private _sink?;
5
- protected writer: CodeTextWriter;
6
- get sink(): ISink;
7
- constructor(_sink?: ISink);
8
- /** Enum registry: lowercased enum name → members */
9
- protected _enumRegistry: Map<string, EnumMember[]>;
10
- registerEnum(name: string, members: EnumMember[]): void;
11
- abstract resolveCSharpTypeName(typescriptTypeName: string, baseTypes?: string[]): string | void;
12
- abstract startNewType(filePath: string, typeName: string, baseType: string[], comments?: string[]): boolean | void;
13
- abstract endNewType(filePath: string, typeName: string): void;
14
- abstract writeMember(visibility: Visibility, name: string, isArray: boolean, type: string, initialValue?: string, comments?: string[]): void;
15
- abstract writeMethod(visibility: Visibility, name: string, returnType: string, args: Argument[], comments: string[]): void;
16
- abstract writeNewTypeExpression(typeName: string, args?: string[]): void;
17
- private _currentlyProcessingFiles;
18
- get outputInfo(): TypeSourceInformation;
19
- private _createdSchemesPerFile;
20
- begin(filePath: string | null): void;
21
- end(filePath: string | null): void;
22
- protected writeScheme(processingFilePath: string | null, component: string): void;
23
- }
1
+ import { Argument, CodeTextWriter, EnumMember, ISink, IWriter, Visibility } from "./base-compiler";
2
+ import { TypeSourceInformation } from "./register-types";
3
+ export declare abstract class BaseWriter implements IWriter {
4
+ private _sink?;
5
+ protected writer: CodeTextWriter;
6
+ get sink(): ISink;
7
+ constructor(_sink?: ISink);
8
+ /** Enum registry: lowercased enum name → members */
9
+ protected _enumRegistry: Map<string, EnumMember[]>;
10
+ registerEnum(name: string, members: EnumMember[]): void;
11
+ abstract resolveCSharpTypeName(typescriptTypeName: string, baseTypes?: string[]): string | void;
12
+ abstract startNewType(filePath: string, typeName: string, baseType: string[], comments?: string[]): boolean | void;
13
+ abstract endNewType(filePath: string, typeName: string): void;
14
+ abstract writeMember(visibility: Visibility, name: string, isArray: boolean, type: string, initialValue?: string, comments?: string[]): void;
15
+ abstract writeMethod(visibility: Visibility, name: string, returnType: string, args: Argument[], comments: string[]): void;
16
+ abstract writeNewTypeExpression(typeName: string, args?: string[]): void;
17
+ private _currentlyProcessingFiles;
18
+ get outputInfo(): TypeSourceInformation;
19
+ private _createdSchemesPerFile;
20
+ begin(filePath: string | null): void;
21
+ end(filePath: string | null): void;
22
+ protected writeScheme(processingFilePath: string | null, component: string): void;
23
+ }
@@ -1,90 +1,90 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseWriter = void 0;
4
- var fs_1 = require("fs");
5
- var base_compiler_1 = require("./base-compiler");
6
- var commands_1 = require("./commands");
7
- var BaseWriter = /** @class */ (function () {
8
- function BaseWriter(_sink) {
9
- this._sink = _sink;
10
- this.writer = new base_compiler_1.CodeTextWriter();
11
- /** Enum registry: lowercased enum name → members */
12
- this._enumRegistry = new Map();
13
- this._currentlyProcessingFiles = {};
14
- this._createdSchemesPerFile = {};
15
- }
16
- Object.defineProperty(BaseWriter.prototype, "sink", {
17
- get: function () {
18
- return this._sink;
19
- },
20
- enumerable: false,
21
- configurable: true
22
- });
23
- BaseWriter.prototype.registerEnum = function (name, members) {
24
- this._enumRegistry.set(name.toLowerCase(), members);
25
- };
26
- Object.defineProperty(BaseWriter.prototype, "outputInfo", {
27
- get: function () {
28
- return this._createdSchemesPerFile;
29
- },
30
- enumerable: false,
31
- configurable: true
32
- });
33
- BaseWriter.prototype.begin = function (filePath) {
34
- if (!this._currentlyProcessingFiles[filePath]) {
35
- this._currentlyProcessingFiles[filePath] = [];
36
- }
37
- };
38
- BaseWriter.prototype.end = function (filePath) {
39
- var results = this._currentlyProcessingFiles[filePath];
40
- console.log("Writing schemes for", filePath, results);
41
- if (results) {
42
- var previousResultsFromThisFile = this._createdSchemesPerFile[filePath];
43
- if (previousResultsFromThisFile) {
44
- for (var _i = 0, previousResultsFromThisFile_1 = previousResultsFromThisFile; _i < previousResultsFromThisFile_1.length; _i++) {
45
- var previouslyCreated = previousResultsFromThisFile_1[_i];
46
- var foundInAny = false;
47
- for (var _a = 0, results_1 = results; _a < results_1.length; _a++) {
48
- var res = results_1[_a];
49
- if (res.filePath === previouslyCreated.filePath) {
50
- foundInAny = true;
51
- break;
52
- }
53
- }
54
- if (!foundInAny) {
55
- for (var sourcePath in this._createdSchemesPerFile) {
56
- if (foundInAny)
57
- break;
58
- if (sourcePath === filePath)
59
- continue;
60
- var otherSourceSchemes = this._createdSchemesPerFile[sourcePath];
61
- if (otherSourceSchemes.includes(previouslyCreated)) {
62
- // the file was moved to another source file
63
- foundInAny = true;
64
- }
65
- }
66
- }
67
- if (!foundInAny && (0, fs_1.existsSync)(previouslyCreated.filePath)) {
68
- (0, fs_1.unlinkSync)(previouslyCreated.filePath);
69
- (0, commands_1.sendFileDeletedCommand)(previouslyCreated.filePath);
70
- }
71
- }
72
- }
73
- this._createdSchemesPerFile[filePath] = results;
74
- }
75
- delete this._currentlyProcessingFiles[filePath];
76
- };
77
- BaseWriter.prototype.writeScheme = function (processingFilePath, component) {
78
- var res = this.sink.flush(component + ".component.json", this.writer.flush());
79
- // if an output path is returned it means a file has been written to that path
80
- if (res && (0, fs_1.existsSync)(res)) {
81
- (0, commands_1.sendFileWrittenCommand)(res);
82
- // add the scheme to the list of created schemes
83
- if (processingFilePath && this._currentlyProcessingFiles[processingFilePath]) {
84
- this._currentlyProcessingFiles[processingFilePath].push({ componentName: component, filePath: res });
85
- }
86
- }
87
- };
88
- return BaseWriter;
89
- }());
90
- exports.BaseWriter = BaseWriter;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseWriter = void 0;
4
+ var fs_1 = require("fs");
5
+ var base_compiler_1 = require("./base-compiler");
6
+ var commands_1 = require("./commands");
7
+ var BaseWriter = /** @class */ (function () {
8
+ function BaseWriter(_sink) {
9
+ this._sink = _sink;
10
+ this.writer = new base_compiler_1.CodeTextWriter();
11
+ /** Enum registry: lowercased enum name → members */
12
+ this._enumRegistry = new Map();
13
+ this._currentlyProcessingFiles = {};
14
+ this._createdSchemesPerFile = {};
15
+ }
16
+ Object.defineProperty(BaseWriter.prototype, "sink", {
17
+ get: function () {
18
+ return this._sink;
19
+ },
20
+ enumerable: false,
21
+ configurable: true
22
+ });
23
+ BaseWriter.prototype.registerEnum = function (name, members) {
24
+ this._enumRegistry.set(name.toLowerCase(), members);
25
+ };
26
+ Object.defineProperty(BaseWriter.prototype, "outputInfo", {
27
+ get: function () {
28
+ return this._createdSchemesPerFile;
29
+ },
30
+ enumerable: false,
31
+ configurable: true
32
+ });
33
+ BaseWriter.prototype.begin = function (filePath) {
34
+ if (!this._currentlyProcessingFiles[filePath]) {
35
+ this._currentlyProcessingFiles[filePath] = [];
36
+ }
37
+ };
38
+ BaseWriter.prototype.end = function (filePath) {
39
+ var results = this._currentlyProcessingFiles[filePath];
40
+ console.log("Writing schemes for", filePath, results);
41
+ if (results) {
42
+ var previousResultsFromThisFile = this._createdSchemesPerFile[filePath];
43
+ if (previousResultsFromThisFile) {
44
+ for (var _i = 0, previousResultsFromThisFile_1 = previousResultsFromThisFile; _i < previousResultsFromThisFile_1.length; _i++) {
45
+ var previouslyCreated = previousResultsFromThisFile_1[_i];
46
+ var foundInAny = false;
47
+ for (var _a = 0, results_1 = results; _a < results_1.length; _a++) {
48
+ var res = results_1[_a];
49
+ if (res.filePath === previouslyCreated.filePath) {
50
+ foundInAny = true;
51
+ break;
52
+ }
53
+ }
54
+ if (!foundInAny) {
55
+ for (var sourcePath in this._createdSchemesPerFile) {
56
+ if (foundInAny)
57
+ break;
58
+ if (sourcePath === filePath)
59
+ continue;
60
+ var otherSourceSchemes = this._createdSchemesPerFile[sourcePath];
61
+ if (otherSourceSchemes.includes(previouslyCreated)) {
62
+ // the file was moved to another source file
63
+ foundInAny = true;
64
+ }
65
+ }
66
+ }
67
+ if (!foundInAny && (0, fs_1.existsSync)(previouslyCreated.filePath)) {
68
+ (0, fs_1.unlinkSync)(previouslyCreated.filePath);
69
+ (0, commands_1.sendFileDeletedCommand)(previouslyCreated.filePath);
70
+ }
71
+ }
72
+ }
73
+ this._createdSchemesPerFile[filePath] = results;
74
+ }
75
+ delete this._currentlyProcessingFiles[filePath];
76
+ };
77
+ BaseWriter.prototype.writeScheme = function (processingFilePath, component) {
78
+ var res = this.sink.flush(component + ".component.json", this.writer.flush());
79
+ // if an output path is returned it means a file has been written to that path
80
+ if (res && (0, fs_1.existsSync)(res)) {
81
+ (0, commands_1.sendFileWrittenCommand)(res);
82
+ // add the scheme to the list of created schemes
83
+ if (processingFilePath && this._currentlyProcessingFiles[processingFilePath]) {
84
+ this._currentlyProcessingFiles[processingFilePath].push({ componentName: component, filePath: res });
85
+ }
86
+ }
87
+ };
88
+ return BaseWriter;
89
+ }());
90
+ exports.BaseWriter = BaseWriter;
@@ -1,20 +1,22 @@
1
- import { IWriter } from "./base-compiler";
2
- /** Typescript Walker */
3
- export declare class Compiler {
4
- compile(writer: IWriter, code: string, sourceFilePath: string | null): void;
5
- private run;
6
- private visitEnumDeclaration;
7
- private visit;
8
- private visitClassDeclaration;
9
- private visitPropertyDeclaration;
10
- private visitMethodDeclaration;
11
- private resolveParameters;
12
- private debugLog;
13
- private getComments;
14
- private getVisibility;
15
- private tryResolveTypeFromExpression;
16
- private resolveType;
17
- private resolveTypeFromString;
18
- private isArrayType;
19
- private resolveExpression;
20
- }
1
+ import { IWriter } from "./base-compiler";
2
+ /** Typescript Walker */
3
+ export declare class Compiler {
4
+ compile(writer: IWriter, code: string, sourceFilePath: string | null): void;
5
+ private run;
6
+ private visitEnumDeclaration;
7
+ private visit;
8
+ private visitClassDeclaration;
9
+ private visitPropertyDeclaration;
10
+ private visitMethodDeclaration;
11
+ private resolveParameters;
12
+ private debugLog;
13
+ private getComments;
14
+ /** Strip markdown/code/images/URLs/JSDoc tags to produce a plain-text tooltip */
15
+ private static sanitizeJsdocForTooltip;
16
+ private getVisibility;
17
+ private tryResolveTypeFromExpression;
18
+ private resolveType;
19
+ private resolveTypeFromString;
20
+ private isArrayType;
21
+ private resolveExpression;
22
+ }