@needle-tools/needle-component-compiler 2.4.0-pre → 3.0.0-68ab237

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,85 +1,184 @@
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.0-pre] - 2022-11-22
8
- # Blender compiler
9
- - Add: emit types from declared class implementing `IComponent` e.g. ``declare class MyComp implements IComponent``
10
-
11
- ## [2.3.0-pre] - 2022-11-22
12
- # Blender compiler
13
- - Add emit array
14
- - Add emit types by class name if unknown
15
-
16
- ## [2.2.0-pre.1] - 2022-11-13
17
- - Add: watcher now also generates the register_types file
18
- - Add: deleting code files now also deletes the generated files and reports it
19
-
20
- ## [2.1.0-pre] - 2022-11-12
21
- - Add blender scheme compiler for creating and updating schemes (or removing them when the component gets deleted)
22
-
23
- ## [1.9.1] - 2022-11-05
24
- - Fix ``new Vector2(1, .5)`` generating invalid C# where number arguments were emitted as double instead of float
25
-
26
- ## [1.9.0] - 2022-10-18
27
- - Change: emit ``onEnable`` as ``OnEnable`` and ``onDisable`` as ``OnDisable`` so Unity creates component checkboxes
28
- - Change: ignore private and protected methods
29
-
30
- ## [1.8.0] - 2022-09-02
31
- - Add ``@nonSerialized`` decorator for fields and methods
32
- - Fix comment gen for unknown types
33
-
34
- ## [1.7.3] - 2022-09-02
35
- - Fix codegen for unknown array types
36
- - Fix codegen for abstract classes
37
- - Fix codegen for types imported as e.g. THREE.AnimationClip
38
-
39
- ## [1.7.2] - 2022-07-27
40
- - fix UnityEvent codegen
41
-
42
- ## [1.7.1] - 2022-07-25
43
- - fix array type codegen, for example ``scenes: Array<AssetReference> = [];``, see issue https://github.com/needle-tools/needle-tiny-playground/issues/285
44
-
45
- ## [1.7.0] - 2022-07-14
46
- - change: skip non-serializeable variables (private without ``@serializable``)
47
- - improve member type generation
48
- - fix bug in type generation for array types
49
- - add/improve initial assignment codegen for object types
50
-
51
- ## [1.6.3] - 2022-07-12
52
- - add warning when class type is unknown
53
-
54
- ## [1.6.2] - 2022-07-11
55
- - fix ``@type`` for class declaration
56
-
57
- ## [1.6.1] - 2022-07-10
58
- - add using ``types.json`` json file that will be generated from Unity
59
- - change ``@type`` annotiation to only work without braces to be consistent
60
-
61
- ## [1.5.0] - 2022-07-07
62
- - change ``@type`` annotation to work with and without braces (e.g. ``@type My.Type`` or ``@type (My.Type)``)
63
-
64
- ## [1.4.0] - 2022-07-06
65
- - add CODEGEN_START and END sections to allow adding code before or after a generated componnet
66
- - add ``@ifdef`` to ifdef fields
67
-
68
- ## [1.3.0] - 2022-06-27
69
- - add support for typescript namespace
70
-
71
- ## [1.2.1] - 2022-06-15
72
- - allow adding ``@type(MyNamespace.MyType)`` to class declaration
73
-
74
- ## [1.1.0] - 2022-06-13
75
- - add ``@type(MyNamespace.MyType)`` decorator for fields to specifiy C# type
76
- - add minimal docs to readme
77
- - dont emit comments anymore
78
- - make created classes partial
79
-
80
- ## [1.0.1] - 2022-05-29
81
- - disable all warnings for generated scripts
82
- - add mesh and texture types
83
-
84
- ## [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] - 2026-03-04
8
+
9
+ ### Changed
10
+ - Rewritten compiler architecture with a new `Compiler` (TypeScript walker) + `IWriter` (output backend) design, enabling pluggable output targets
11
+ - CLI interface: `needle-component-compiler <target> <output_dir> <input_files...>` where target is `csharp` or `blender`
12
+
13
+ ### Added
14
+
15
+ #### Architecture
16
+ - New `BaseWriter` / `IWriter` interface allows pluggable output backends (C#, Blender, and future targets like React Three Fiber)
17
+ - New `ISink` / `FileSink` abstraction for output, with `NEEDLE_CODEGEN_START` / `NEEDLE_CODEGEN_END` fence support to preserve hand-written code sections
18
+ - Standalone CLI (`npx @needle-tools/needle-component-compiler`) with `--help` and `--version` flags
19
+
20
+ #### C# Compiler
21
+ - Enum declarations with numeric and string initializers
22
+ - Union type fields (e.g. `field: string | number`) emit as `object` with a doc comment listing the union members
23
+ - Inferred types from initializers (e.g. `speed = 5` infers `float`, `name = "hello"` infers `string`, `new Vector3()` infers `Vector3`)
24
+ - `@dont-generate-component` decorator to skip class generation
25
+ - `@nonSerialized` support for fields (skips serialization)
26
+ - `@type` override decorator for fields and classes
27
+ - `@tooltip` decorator emits `[Tooltip("...")]` attribute
28
+ - `@serializable` / `@serializeField` for private field serialization
29
+ - `@ifdef` / `#if UNITY_EDITOR` wrapping for editor-only fields
30
+ - `NEEDLE_CODEGEN` fences in generated output to preserve manual code sections
31
+ - Static and abstract member handling (static fields skipped, static/abstract methods ignored)
32
+ - Method return type emission (void, primitive types, mapped types)
33
+ - Support for `declare class` with `IComponent` interface
34
+
35
+ #### Blender Compiler
36
+ - Full Blender panel schema generation from TypeScript components
37
+ - Property type mapping: `number` `FloatProperty`, `string` → `StringProperty`, `boolean` → `BoolProperty`, enums → `EnumProperty`, arrays → `CollectionProperty`
38
+ - Inferred types from initializers (numbers, strings, booleans, `new` expressions)
39
+ - Enum support with `EnumProperty` items generation
40
+ - `@tooltip` decorator maps to Blender `description` field
41
+ - `@nonSerialized` decorator to skip properties
42
+ - `@dont-generate-component` decorator to skip class generation
43
+ - `@type` override decorator
44
+ - Missing/unknown type handling with sensible defaults
45
+ - `register_types` generation for Blender add-on registration
46
+ - File watcher for automatic recompilation on source changes
47
+ - Per-component output files with automatic cleanup on deletion
48
+
49
+ ### Fixed
50
+ - Destructured method parameters (e.g. `{xr}`) now emit as `object @obj` instead of invalid `object @{xr}`
51
+ - `Object3D` type correctly maps to `UnityEngine.GameObject` (not `Transform`)
52
+ - `new` expression type inference for explicit types (e.g. `new RGBAColor()`)
53
+ - `RGBAColor` → `Color` automatic type mapping
54
+ - Method inline anonymous type declarations (e.g. `myMethod(arg: {x: number})`)
55
+ - Codegen no longer deletes manually added code outside of codegen sections
56
+ - Output directory is created automatically if it doesn't exist
57
+
58
+ ### Testing
59
+ - Comprehensive test suite with separate C# and Blender test runners (`npm test`, `npm run test:csharp`, `npm run test:blender`)
60
+ - Test coverage for: basic fields, primitives, enums, unions, tooltips, inferred types, advanced features, codegen fences, methods, and extended type mappings
61
+
62
+ ## [2.4.1-pre] - 2023-04-03
63
+ # Blender compiler
64
+ - Add: typenames
65
+
66
+ ## [2.4.0-pre] - 2023-03-31
67
+ # Blender compiler
68
+ - Add: emit types from declared class implementing `IComponent` e.g. ``declare class MyComp implements IComponent``
69
+
70
+ ## [2.3.0-pre] - 2022-11-22
71
+ # Blender compiler
72
+ - Add emit array
73
+ - Add emit types by class name if unknown
74
+
75
+ ## [2.2.0-pre.1] - 2022-11-13
76
+ - Add: watcher now also generates the register_types file
77
+ - Add: deleting code files now also deletes the generated files and reports it
78
+
79
+ ## [2.1.0-pre] - 2022-11-12
80
+ - Add blender scheme compiler for creating and updating schemes (or removing them when the component gets deleted)
81
+
82
+ ## [1.12.2] - 2025-06-06
83
+ - Fix: Private fields decorated with `@serializable()` should be annotated with `UnityEngine.SerializeField`
84
+ - Fix: Comment for `// @serializeField` should not affect subsequent fields
85
+
86
+ ## [1.12.0] - 2025-06-02
87
+ - Add: Support to serialize unknown classes when annotated with `// @type object`
88
+
89
+ ## [1.11.2] - 2023-12-16
90
+ - Fix: property setter emitting invalid C# code
91
+
92
+ ## [1.11.1] - 2023-12-02
93
+ - Fix: Use Unity AnimatorController type
94
+ - Fix: method inline anonymous type declaration (e.g. `myMethod(arg: {x:number})`)
95
+
96
+ ## [1.11.0] - 2023-11-18
97
+ - Add: support to wrap fields with `#if UNITY_EDITOR` if their namespace contains UnityEditor
98
+ - Add: more threejs types to generate Unity Material fields for
99
+
100
+ ## [1.10.3] - 2023-09-08
101
+ - Add: Needle Engine type `RGBAColor` is now automatically emitted as `UnityEngine.Color`
102
+
103
+ ## [1.10.2] - 2023-09-08
104
+ - Fix: `@type` was not properly applied for `new expression` cases (e.g. `new RGBAColor` should produce a `new Color` when decorated with `@type Color`)
105
+
106
+ ## [1.10.1] - 2023-08-02
107
+ - Add: use `@tooltip` to emit a UnityEngine.Tooltip
108
+ - Update Readme
109
+
110
+ ## [1.9.4] - 2023-05-24
111
+ - Change: `Object3D` now emits `GameObject` field instead of `Transform`
112
+ - Fix: ignore `static` methods
113
+ - Fix: ignore `abstract` methods
114
+
115
+ ## [1.9.3] - 2022-12-30
116
+ - Add debug logs for when no file or target directory was passed in. Also wrapping core with try catch
117
+
118
+ ## [1.9.2] - 2022-11-29
119
+ - Fix codegen deleting code added manually outside of codegen sections
120
+ - Fix codegen creating output directory if it does not exist yet
121
+
122
+ ## [1.9.1] - 2022-11-05
123
+ - Fix ``new Vector2(1, .5)`` generating invalid C# where number arguments were emitted as double instead of float
124
+
125
+ ## [1.9.0] - 2022-10-18
126
+ - Change: emit ``onEnable`` as ``OnEnable`` and ``onDisable`` as ``OnDisable`` so Unity creates component checkboxes
127
+ - Change: ignore private and protected methods
128
+
129
+ ## [1.8.0] - 2022-09-02
130
+ - Add ``@nonSerialized`` decorator for fields and methods
131
+ - Fix comment gen for unknown types
132
+
133
+ ## [1.7.3] - 2022-09-02
134
+ - Fix codegen for unknown array types
135
+ - Fix codegen for abstract classes
136
+ - Fix codegen for types imported as e.g. THREE.AnimationClip
137
+
138
+ ## [1.7.2] - 2022-07-27
139
+ - fix UnityEvent codegen
140
+
141
+ ## [1.7.1] - 2022-07-25
142
+ - fix array type codegen, for example ``scenes: Array<AssetReference> = [];``, see issue https://github.com/needle-tools/needle-tiny-playground/issues/285
143
+
144
+ ## [1.7.0] - 2022-07-14
145
+ - change: skip non-serializeable variables (private without ``@serializable``)
146
+ - improve member type generation
147
+ - fix bug in type generation for array types
148
+ - add/improve initial assignment codegen for object types
149
+
150
+ ## [1.6.3] - 2022-07-12
151
+ - add warning when class type is unknown
152
+
153
+ ## [1.6.2] - 2022-07-11
154
+ - fix ``@type`` for class declaration
155
+
156
+ ## [1.6.1] - 2022-07-10
157
+ - add using ``types.json`` json file that will be generated from Unity
158
+ - change ``@type`` annotiation to only work without braces to be consistent
159
+
160
+ ## [1.5.0] - 2022-07-07
161
+ - change ``@type`` annotation to work with and without braces (e.g. ``@type My.Type`` or ``@type (My.Type)``)
162
+
163
+ ## [1.4.0] - 2022-07-06
164
+ - add CODEGEN_START and END sections to allow adding code before or after a generated componnet
165
+ - add ``@ifdef`` to ifdef fields
166
+
167
+ ## [1.3.0] - 2022-06-27
168
+ - add support for typescript namespace
169
+
170
+ ## [1.2.1] - 2022-06-15
171
+ - allow adding ``@type(MyNamespace.MyType)`` to class declaration
172
+
173
+ ## [1.1.0] - 2022-06-13
174
+ - add ``@type(MyNamespace.MyType)`` decorator for fields to specifiy C# type
175
+ - add minimal docs to readme
176
+ - dont emit comments anymore
177
+ - make created classes partial
178
+
179
+ ## [1.0.1] - 2022-05-29
180
+ - disable all warnings for generated scripts
181
+ - add mesh and texture types
182
+
183
+ ## [1.0.0] - 2022-04-22
85
184
  - initial release
package/Readme.md CHANGED
@@ -1,19 +1,134 @@
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
+ ### Quick Start
6
+
7
+ No install required run directly with `npx`:
8
+
9
+ ```bash
10
+ npx @needle-tools/needle-component-compiler <target> <output_dir> <input_files...>
11
+ ```
12
+
13
+ | Argument | Description |
14
+ |---|---|
15
+ | `target` | `csharp` or `blender` |
16
+ | `output_dir` | Directory for generated files |
17
+ | `input_files` | One or more `.ts` source files (globs supported) |
18
+
19
+ #### Examples
20
+
21
+ ```bash
22
+ # Generate C# component stubs
23
+ npx @needle-tools/needle-component-compiler csharp ./codegen ./src/MyComponent.ts
24
+
25
+ # Generate Blender component schemas
26
+ npx @needle-tools/needle-component-compiler blender ./codegen ./src/MyComponent.ts
27
+
28
+ # Process multiple files
29
+ npx @needle-tools/needle-component-compiler csharp ./codegen ./src/**/*.ts
30
+
31
+ # Print version
32
+ npx @needle-tools/needle-component-compiler --version
33
+ ```
34
+
35
+ ### Programmatic API
36
+
37
+ ```
38
+ npm install @needle-tools/needle-component-compiler
39
+ ```
40
+
41
+ ```ts
42
+ import { Compiler, CSharpWriter, FileSink } from "@needle-tools/needle-component-compiler";
43
+
44
+ const sink = new FileSink("./output");
45
+ const writer = new CSharpWriter(sink);
46
+ const compiler = new Compiler();
47
+ compiler.compile(writer, code, "MyComponent.ts");
48
+ ```
49
+
50
+ ### Supported TypeScript Features
51
+
52
+ - Classes extending `Behaviour`, `MonoBehaviour`, or implementing `IComponent`
53
+ - Public, protected, and private fields with type annotations
54
+ - Default values (primitives, `new` expressions, literals)
55
+ - Array types: `T[]`, `Array<T>`
56
+ - Union types (nullable types like `Object3D | null` resolve to the concrete type)
57
+ - Enums (with value initialization)
58
+ - Methods with parameters and return types
59
+ - Destructured parameters (compiled as `object`)
60
+
61
+ ### Comment Directives
62
+
63
+ Use `//` comments above classes, fields, or methods to control code generation:
64
+
65
+ | Directive | Target | Description |
66
+ |---|---|---|
67
+ | `@generate-component` | Class | Force generation (not required, classes are generated by default) |
68
+ | `@dont-generate-component` | Class | Skip generating this class entirely |
69
+ | `@type MyNamespace.MyType` | Class / Field | Override the resolved C# type or base class |
70
+ | `@abstract` | Class | Mark the generated class as `abstract` |
71
+ | `@serializeField` | Field | Emit `[UnityEngine.SerializeField]` attribute |
72
+ | `@nonSerialized` | Field / Method | Skip generating C# code for this member |
73
+ | `@tooltip "My text"` | Field | Emit `[UnityEngine.Tooltip("My text")]` (C#) or `"description"` (Blender) |
74
+ | `@contextmenu "Label"` | Method | Emit `[UnityEngine.ContextMenu("Label")]` |
75
+ | `@ifdef MY_DEFINE` | Field | Wrap field in `#if MY_DEFINE` / `#endif` |
76
+
77
+ ### JSDoc Tooltips
78
+
79
+ 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.
80
+
81
+ ```ts
82
+ export class MyComponent extends Behaviour {
83
+ /** The movement speed of the character */
84
+ public speed: number = 5;
85
+ }
86
+ ```
87
+
88
+ **C# output:**
89
+ ```csharp
90
+ [UnityEngine.Tooltip("The movement speed of the character")]
91
+ public float @speed = 5f;
92
+ ```
93
+
94
+ **Blender output:**
95
+ ```json
96
+ "speed": {
97
+ "type": "float",
98
+ "value": 5,
99
+ "description": "The movement speed of the character"
100
+ }
101
+ ```
102
+
103
+ An explicit `// @tooltip` directive takes priority over a JSDoc comment on the same field.
104
+
105
+ ### Codegen Fences
106
+
107
+ Generated C# files are wrapped in codegen fences:
108
+
109
+ ```csharp
110
+ // NEEDLE_CODEGEN_START
111
+ // auto generated code - do not edit directly
112
+
113
+ #pragma warning disable
114
+
115
+ namespace Needle.Typescript.GeneratedComponents
116
+ {
117
+ public partial class MyComponent : UnityEngine.MonoBehaviour
118
+ {
119
+ public float @speed = 5f;
120
+ }
121
+ }
122
+
123
+ // NEEDLE_CODEGEN_END
124
+ ```
125
+
126
+ This allows you to add custom code outside the fences that will be preserved when the file is regenerated.
127
+
128
+ # Contact ✒️
129
+ <b>[🌵 Needle](https://needle.tools)</b> •
130
+ [Github](https://github.com/needle-tools) •
131
+ [Twitter](https://twitter.com/NeedleTools) •
132
+ [Discord](https://discord.needle.tools) •
133
+ [Forum](https://forum.needle.tools) •
134
+ [Youtube](https://youtube.com/@needle-tools)
@@ -0,0 +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
+ }
@@ -0,0 +1,91 @@
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
+ this._enumRegistry.clear();
35
+ if (!this._currentlyProcessingFiles[filePath]) {
36
+ this._currentlyProcessingFiles[filePath] = [];
37
+ }
38
+ };
39
+ BaseWriter.prototype.end = function (filePath) {
40
+ var results = this._currentlyProcessingFiles[filePath];
41
+ console.log("Writing schemes for", filePath, results);
42
+ if (results) {
43
+ var previousResultsFromThisFile = this._createdSchemesPerFile[filePath];
44
+ if (previousResultsFromThisFile) {
45
+ for (var _i = 0, previousResultsFromThisFile_1 = previousResultsFromThisFile; _i < previousResultsFromThisFile_1.length; _i++) {
46
+ var previouslyCreated = previousResultsFromThisFile_1[_i];
47
+ var foundInAny = false;
48
+ for (var _a = 0, results_1 = results; _a < results_1.length; _a++) {
49
+ var res = results_1[_a];
50
+ if (res.filePath === previouslyCreated.filePath) {
51
+ foundInAny = true;
52
+ break;
53
+ }
54
+ }
55
+ if (!foundInAny) {
56
+ for (var sourcePath in this._createdSchemesPerFile) {
57
+ if (foundInAny)
58
+ break;
59
+ if (sourcePath === filePath)
60
+ continue;
61
+ var otherSourceSchemes = this._createdSchemesPerFile[sourcePath];
62
+ if (otherSourceSchemes.includes(previouslyCreated)) {
63
+ // the file was moved to another source file
64
+ foundInAny = true;
65
+ }
66
+ }
67
+ }
68
+ if (!foundInAny && (0, fs_1.existsSync)(previouslyCreated.filePath)) {
69
+ (0, fs_1.unlinkSync)(previouslyCreated.filePath);
70
+ (0, commands_1.sendFileDeletedCommand)(previouslyCreated.filePath);
71
+ }
72
+ }
73
+ }
74
+ this._createdSchemesPerFile[filePath] = results;
75
+ }
76
+ delete this._currentlyProcessingFiles[filePath];
77
+ };
78
+ BaseWriter.prototype.writeScheme = function (processingFilePath, component) {
79
+ var res = this.sink.flush(component + ".component.json", this.writer.flush());
80
+ // if an output path is returned it means a file has been written to that path
81
+ if (res && (0, fs_1.existsSync)(res)) {
82
+ (0, commands_1.sendFileWrittenCommand)(res);
83
+ // add the scheme to the list of created schemes
84
+ if (processingFilePath && this._currentlyProcessingFiles[processingFilePath]) {
85
+ this._currentlyProcessingFiles[processingFilePath].push({ componentName: component, filePath: res });
86
+ }
87
+ }
88
+ };
89
+ return BaseWriter;
90
+ }());
91
+ exports.BaseWriter = BaseWriter;
@@ -0,0 +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
+ /** 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
+ }