@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.
@@ -0,0 +1,307 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.CSharpWriter = void 0;
19
+ var base_compiler_1 = require("../base-compiler");
20
+ var BaseWriter_1 = require("../BaseWriter");
21
+ var allowDebugLogs = false;
22
+ /** Inline type dictionary: TypeScript type name → fully-qualified C# type name */
23
+ var TYPE_MAP = {
24
+ // Primitives
25
+ "number": "float",
26
+ "boolean": "bool",
27
+ "string": "string",
28
+ "any": "object",
29
+ "object": "UnityEngine.Object",
30
+ "void": "void",
31
+ // Unity base types
32
+ "Behaviour": "UnityEngine.MonoBehaviour",
33
+ "MonoBehaviour": "UnityEngine.MonoBehaviour",
34
+ "Component": "UnityEngine.Component",
35
+ "ScriptableObject": "UnityEngine.ScriptableObject",
36
+ // GameObjects / Transforms
37
+ "GameObject": "UnityEngine.GameObject",
38
+ "Object3D": "UnityEngine.Transform",
39
+ "Transform": "UnityEngine.Transform",
40
+ "RectTransform": "UnityEngine.RectTransform",
41
+ "AssetReference": "UnityEngine.Transform",
42
+ "THREE.Object3D": "UnityEngine.Transform",
43
+ // Math types
44
+ "Vector2": "UnityEngine.Vector2",
45
+ "Vector3": "UnityEngine.Vector3",
46
+ "Vector4": "UnityEngine.Vector4",
47
+ "Quaternion": "UnityEngine.Quaternion",
48
+ "Color": "UnityEngine.Color",
49
+ "RGBAColor": "UnityEngine.Color",
50
+ "THREE.Color": "UnityEngine.Color",
51
+ "THREE.Vector2": "UnityEngine.Vector2",
52
+ "THREE.Vector3": "UnityEngine.Vector3",
53
+ "THREE.Vector4": "UnityEngine.Vector4",
54
+ "Matrix4": "UnityEngine.Matrix4x4",
55
+ "Box3": "UnityEngine.Bounds",
56
+ // Rendering
57
+ "Renderer": "UnityEngine.Renderer",
58
+ "Material": "UnityEngine.Material",
59
+ "Mesh": "UnityEngine.Mesh",
60
+ "Texture": "UnityEngine.Texture",
61
+ "Texture2D": "UnityEngine.Texture2D",
62
+ "RenderTexture": "UnityEngine.RenderTexture",
63
+ // Audio
64
+ "AudioClip": "UnityEngine.AudioClip",
65
+ "AudioSource": "UnityEngine.AudioSource",
66
+ // Animation
67
+ "Animator": "UnityEngine.Animator",
68
+ "Animation": "UnityEngine.Animation",
69
+ "AnimationClip": "UnityEngine.AnimationClip",
70
+ // Events
71
+ "EventList": "UnityEngine.Events.UnityEvent",
72
+ "UnityEvent": "UnityEngine.Events.UnityEvent",
73
+ // Physics / Colliders
74
+ "ICollider": "UnityEngine.Collider",
75
+ // UI
76
+ "Text": "UnityEngine.UI.Text",
77
+ "Image": "UnityEngine.UI.Image",
78
+ "RawImage": "UnityEngine.UI.RawImage",
79
+ // Camera / Light
80
+ "Camera": "UnityEngine.Camera",
81
+ "Light": "UnityEngine.Light",
82
+ // Timeline / Playables
83
+ "SignalAsset": "UnityEngine.Timeline.SignalAsset",
84
+ "PlayableDirector": "UnityEngine.Playables.PlayableDirector",
85
+ // Miscellaneous
86
+ "Rigidbody": "UnityEngine.Rigidbody",
87
+ "Map": "System.Collections.Generic.Dictionary",
88
+ };
89
+ /** Lifecycle method name mappings: camelCase TS → PascalCase C# */
90
+ var LIFECYCLE_METHODS = {
91
+ "awake": "Awake",
92
+ "start": "Start",
93
+ "onEnable": "OnEnable",
94
+ "onDisable": "OnDisable",
95
+ "update": "Update",
96
+ "lateUpdate": "LateUpdate",
97
+ "fixedUpdate": "FixedUpdate",
98
+ "onDestroy": "OnDestroy",
99
+ "onCollisionEnter": "OnCollisionEnter",
100
+ "onCollisionExit": "OnCollisionExit",
101
+ "onCollisionStay": "OnCollisionStay",
102
+ "onTriggerEnter": "OnTriggerEnter",
103
+ "onTriggerExit": "OnTriggerExit",
104
+ "onTriggerStay": "OnTriggerStay",
105
+ "onApplicationQuit": "OnApplicationQuit",
106
+ "onBecameVisible": "OnBecameVisible",
107
+ "onBecameInvisible": "OnBecameInvisible",
108
+ "onGUI": "OnGUI",
109
+ "onValidate": "OnValidate",
110
+ "reset": "Reset",
111
+ };
112
+ /** UnityEditor types that need #if UNITY_EDITOR wrapping */
113
+ var EDITOR_TYPES = new Set([
114
+ "UnityEditor", "AnimatorController", "EditorApplication",
115
+ "EditorUtility", "SerializedObject", "SerializedProperty",
116
+ ]);
117
+ function isEditorType(typeName) {
118
+ return EDITOR_TYPES.has(typeName) || typeName.startsWith("UnityEditor.");
119
+ }
120
+ var CSharpWriter = /** @class */ (function (_super) {
121
+ __extends(CSharpWriter, _super);
122
+ function CSharpWriter() {
123
+ return _super !== null && _super.apply(this, arguments) || this;
124
+ }
125
+ CSharpWriter.prototype.resolveCSharpTypeName = function (typescriptTypeName) {
126
+ var _a, _b;
127
+ if (!typescriptTypeName)
128
+ return undefined;
129
+ // Strip THREE. prefix for lookup fallback
130
+ var stripped = typescriptTypeName.startsWith("THREE.") ? typescriptTypeName.substring(6) : typescriptTypeName;
131
+ return (_b = (_a = TYPE_MAP[typescriptTypeName]) !== null && _a !== void 0 ? _a : TYPE_MAP[stripped]) !== null && _b !== void 0 ? _b : typescriptTypeName;
132
+ };
133
+ CSharpWriter.prototype.startNewType = function (filePath, typeName, baseTypes, comments) {
134
+ var _a;
135
+ if (comments === null || comments === void 0 ? void 0 : comments.includes("@dont-generate-component"))
136
+ return false;
137
+ // @type override: first comment matching "@type <T>" overrides base class
138
+ var resolvedBase = "UnityEngine.MonoBehaviour";
139
+ var typeOverride = comments === null || comments === void 0 ? void 0 : comments.find(function (c) { return c.startsWith("@type "); });
140
+ if (typeOverride) {
141
+ resolvedBase = typeOverride.substring("@type ".length).trim();
142
+ }
143
+ else if (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) {
144
+ var first = baseTypes[0];
145
+ resolvedBase = (_a = this.resolveCSharpTypeName(first)) !== null && _a !== void 0 ? _a : "UnityEngine.MonoBehaviour";
146
+ }
147
+ // Abstract modifier
148
+ var isAbstract = comments === null || comments === void 0 ? void 0 : comments.includes("@abstract");
149
+ var modifiers = isAbstract ? "abstract partial" : "partial";
150
+ this.writer.writeLine("// NEEDLE_CODEGEN_START");
151
+ this.writer.writeLine("// auto generated code - do not edit directly");
152
+ this.writer.writeLine("");
153
+ this.writer.writeLine("#pragma warning disable");
154
+ this.writer.writeLine("");
155
+ this.writer.beginBlock("namespace Needle.Typescript.GeneratedComponents\n{");
156
+ this.writer.beginBlock("public ".concat(modifiers, " class ").concat(typeName, " : ").concat(resolvedBase, "\n{"));
157
+ };
158
+ CSharpWriter.prototype.endNewType = function (filePath, typeName) {
159
+ this.writer.endBlock("}");
160
+ this.writer.endBlock("}");
161
+ this.writer.writeLine("");
162
+ this.writer.writeLine("// NEEDLE_CODEGEN_END");
163
+ this.writeCSharpScheme(filePath, typeName);
164
+ };
165
+ CSharpWriter.prototype.writeMember = function (visibility, name, isArray, type, initialValue, comments) {
166
+ var _a;
167
+ if (allowDebugLogs)
168
+ console.log("[CSharp] writeMember", name, type, comments);
169
+ // @nonSerialized → skip entirely
170
+ if (comments === null || comments === void 0 ? void 0 : comments.some(function (c) { return c.startsWith("@nonSerialized"); }))
171
+ return;
172
+ // @type override
173
+ var typeOverride = comments === null || comments === void 0 ? void 0 : comments.find(function (c) { return c.startsWith("@type "); });
174
+ var csharpType = typeOverride
175
+ ? typeOverride.substring("@type ".length).trim()
176
+ : ((_a = this.resolveCSharpTypeName(type)) !== null && _a !== void 0 ? _a : type);
177
+ // Determine visibility string
178
+ var vis = "public";
179
+ if (visibility === base_compiler_1.Visibility.Private || visibility === base_compiler_1.Visibility.Protected) {
180
+ vis = visibility === base_compiler_1.Visibility.Protected ? "protected" : "private";
181
+ }
182
+ // @serializeField → add attribute + force private becomes serialized
183
+ var serializeField = comments === null || comments === void 0 ? void 0 : comments.some(function (c) { return c.startsWith("@serializeField") || c.startsWith("@serializable"); });
184
+ // @tooltip
185
+ var tooltipComment = comments === null || comments === void 0 ? void 0 : comments.find(function (c) { return c.startsWith("@tooltip "); });
186
+ var tooltip = tooltipComment ? tooltipComment.substring("@tooltip ".length).trim().replace(/^["']|["']$/g, "") : null;
187
+ // @contextmenu
188
+ var contextMenuComment = comments === null || comments === void 0 ? void 0 : comments.find(function (c) { return c.startsWith("@contextmenu "); });
189
+ var contextMenu = contextMenuComment ? contextMenuComment.substring("@contextmenu ".length).trim() : null;
190
+ // @ifdef
191
+ var ifdefComment = comments === null || comments === void 0 ? void 0 : comments.find(function (c) { return c.startsWith("@ifdef "); });
192
+ var ifdef = ifdefComment ? ifdefComment.substring("@ifdef ".length).trim() : null;
193
+ // Skip private/protected fields unless @serializeField
194
+ if (visibility !== base_compiler_1.Visibility.Public && !serializeField)
195
+ return;
196
+ // Resolve assignment
197
+ var assignment = "";
198
+ if (initialValue !== undefined && initialValue !== null) {
199
+ if (initialValue === "null") {
200
+ // keep null for reference types, skip for value types
201
+ }
202
+ else if (csharpType === "float") {
203
+ assignment = " = ".concat(initialValue, "f");
204
+ }
205
+ else if (csharpType === "bool") {
206
+ assignment = " = ".concat(initialValue.toLowerCase());
207
+ }
208
+ else if (csharpType === "string") {
209
+ assignment = " = \"".concat(initialValue, "\"");
210
+ }
211
+ else if (initialValue.startsWith("new ")) {
212
+ // constructor expression already prefixed with new
213
+ var resolved = this.resolveNewExpression(initialValue);
214
+ assignment = " = ".concat(resolved);
215
+ }
216
+ else {
217
+ assignment = " = ".concat(initialValue);
218
+ }
219
+ }
220
+ // Array suffix
221
+ if (isArray)
222
+ csharpType += "[]";
223
+ // Editor type wrapping
224
+ var needsEditorWrap = isEditorType(csharpType.split("[")[0].split("<")[0]);
225
+ if (ifdef)
226
+ this.writer.writeLine("#ifdef ".concat(ifdef));
227
+ if (needsEditorWrap)
228
+ this.writer.writeLine("#if UNITY_EDITOR");
229
+ // Emit attributes
230
+ if (tooltip)
231
+ this.writer.writeLine("[UnityEngine.Tooltip(\"".concat(tooltip, "\")]"));
232
+ if (contextMenu)
233
+ this.writer.writeLine("[UnityEngine.ContextMenu(\"".concat(contextMenu, "\")]"));
234
+ if (serializeField && visibility !== base_compiler_1.Visibility.Public) {
235
+ this.writer.writeLine("[UnityEngine.SerializeField]");
236
+ }
237
+ // Emit field
238
+ var varName = "@".concat(name);
239
+ this.writer.writeLine("".concat(vis, " ").concat(csharpType, " ").concat(varName).concat(assignment, ";"));
240
+ if (needsEditorWrap)
241
+ this.writer.writeLine("#endif");
242
+ if (ifdef)
243
+ this.writer.writeLine("#endif");
244
+ };
245
+ CSharpWriter.prototype.writeMethod = function (visibility, name, returnType, args, comments) {
246
+ var _this = this;
247
+ var _a, _b;
248
+ if (allowDebugLogs)
249
+ console.log("[CSharp] writeMethod", name, returnType);
250
+ // @contextmenu on method → add attribute
251
+ var contextMenuComment = comments === null || comments === void 0 ? void 0 : comments.find(function (c) { return c.startsWith("@contextmenu "); });
252
+ var contextMenu = contextMenuComment ? contextMenuComment.substring("@contextmenu ".length).trim() : null;
253
+ // Only emit public methods and lifecycle methods (which are always public)
254
+ var lifecycleName = LIFECYCLE_METHODS[name];
255
+ if (visibility !== base_compiler_1.Visibility.Public && !lifecycleName)
256
+ return;
257
+ // Lifecycle methods get PascalCase; regular public methods keep their name as-is
258
+ var methodName = lifecycleName !== null && lifecycleName !== void 0 ? lifecycleName : name;
259
+ // Build parameter list — inline object types (e.g. { x: number }) resolve to "object"
260
+ var paramList = (_a = args === null || args === void 0 ? void 0 : args.map(function (arg) {
261
+ var _a, _b;
262
+ var csharpType;
263
+ if (!arg.type || arg.type.includes("{")) {
264
+ csharpType = "object";
265
+ }
266
+ else {
267
+ csharpType = (_b = (_a = _this.resolveCSharpTypeName(arg.type)) !== null && _a !== void 0 ? _a : arg.type) !== null && _b !== void 0 ? _b : "object";
268
+ }
269
+ return "".concat(csharpType, " @").concat(arg.name);
270
+ }).join(", ")) !== null && _a !== void 0 ? _a : "";
271
+ var csReturnType = returnType
272
+ ? ((_b = this.resolveCSharpTypeName(returnType)) !== null && _b !== void 0 ? _b : returnType)
273
+ : "void";
274
+ if (contextMenu)
275
+ this.writer.writeLine("[UnityEngine.ContextMenu(\"".concat(contextMenu, "\")]"));
276
+ this.writer.writeLine("public ".concat(csReturnType, " ").concat(methodName, "(").concat(paramList, ") {}"));
277
+ };
278
+ CSharpWriter.prototype.writeNewTypeExpression = function (typeName, args) {
279
+ // no-op for C# output
280
+ };
281
+ // ── Helpers ────────────────────────────────────────────────────────────
282
+ /** Converts camelCase to PascalCase for method names */
283
+ CSharpWriter.prototype.toPascalCase = function (name) {
284
+ return name.charAt(0).toUpperCase() + name.slice(1);
285
+ };
286
+ /** Resolve a "new Type(args)" expression: map TS types to C# qualified types */
287
+ CSharpWriter.prototype.resolveNewExpression = function (expr) {
288
+ var _a;
289
+ // expr is already resolved: "new UnityEngine.Vector2(1, 0.5)" → "new UnityEngine.Vector2(1f, 0.5f)"
290
+ var match = expr.match(/^new\s+([\w.]+)\s*\((.*)\)$/s);
291
+ if (!match)
292
+ return expr;
293
+ var typeName = match[1], argsStr = match[2];
294
+ var csharpType = (_a = this.resolveCSharpTypeName(typeName)) !== null && _a !== void 0 ? _a : typeName;
295
+ // Convert numeric literals to float
296
+ var csharpArgs = argsStr.replace(/(\d+\.?\d*)/g, function (n) {
297
+ return n.includes(".") ? "".concat(n, "f") : "".concat(n, "f");
298
+ });
299
+ return "new ".concat(csharpType, "(").concat(csharpArgs, ")");
300
+ };
301
+ /** Override writeScheme to use .cs extension instead of .component.json */
302
+ CSharpWriter.prototype.writeCSharpScheme = function (processingFilePath, component) {
303
+ var res = this.sink.flush(component + ".cs", this.writer.flush());
304
+ };
305
+ return CSharpWriter;
306
+ }(BaseWriter_1.BaseWriter));
307
+ exports.CSharpWriter = CSharpWriter;
@@ -0,0 +1,20 @@
1
+ import { IWriter, Visibility } from "../base-compiler";
2
+ import { TypeSourceInformation } from "../register-types";
3
+ export declare class ReactThreeFiberCompiler implements IWriter {
4
+ get outputInfo(): TypeSourceInformation;
5
+ private readonly _typeSourceInformation;
6
+ constructor();
7
+ resolveCSharpTypeName(typescriptTypeName: string): string | void;
8
+ begin(filePath: string): void;
9
+ end(filePath: string): void;
10
+ startNewType(filePath: string, typeName: string, baseType: string[], comments?: string[]): boolean | void;
11
+ endNewType(filePath: string, typeName: string): void;
12
+ writeMember(visibility: Visibility, name: string, isArray: boolean, type: string, initialValue?: string, comments?: string[]): void;
13
+ writeMethod(visibility: Visibility, name: string, returnType: string, args: {
14
+ name: string;
15
+ type: string;
16
+ defaultValue?: string;
17
+ }[], comments: string[]): void;
18
+ writeNewTypeExpression(typeName: string, args?: string[]): void;
19
+ registerEnum(name: string, members: import("../base-compiler").EnumMember[]): void;
20
+ }
@@ -1,34 +1,36 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ReactThreeFiberCompiler = void 0;
4
- var ReactThreeFiberCompiler = /** @class */ (function () {
5
- function ReactThreeFiberCompiler() {
6
- this._typeSourceInformation = {};
7
- }
8
- Object.defineProperty(ReactThreeFiberCompiler.prototype, "outputInfo", {
9
- get: function () {
10
- return this._typeSourceInformation;
11
- },
12
- enumerable: false,
13
- configurable: true
14
- });
15
- ReactThreeFiberCompiler.prototype.resolveTypeName = function (typescriptTypeName) {
16
- return typescriptTypeName;
17
- };
18
- ReactThreeFiberCompiler.prototype.begin = function (filePath) {
19
- };
20
- ReactThreeFiberCompiler.prototype.end = function (filePath) {
21
- };
22
- ReactThreeFiberCompiler.prototype.startNewType = function (filePath, typeName, baseType, comments) {
23
- };
24
- ReactThreeFiberCompiler.prototype.endNewType = function (filePath, typeName) {
25
- };
26
- ReactThreeFiberCompiler.prototype.writeMember = function (visibility, name, isArray, type, initialValue, comments) {
27
- };
28
- ReactThreeFiberCompiler.prototype.writeMethod = function (visibility, name, returnType, args, comments) {
29
- };
30
- ReactThreeFiberCompiler.prototype.writeNewTypeExpression = function (typeName, args) {
31
- };
32
- return ReactThreeFiberCompiler;
33
- }());
34
- exports.ReactThreeFiberCompiler = ReactThreeFiberCompiler;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReactThreeFiberCompiler = void 0;
4
+ var ReactThreeFiberCompiler = /** @class */ (function () {
5
+ function ReactThreeFiberCompiler() {
6
+ this._typeSourceInformation = {};
7
+ }
8
+ Object.defineProperty(ReactThreeFiberCompiler.prototype, "outputInfo", {
9
+ get: function () {
10
+ return this._typeSourceInformation;
11
+ },
12
+ enumerable: false,
13
+ configurable: true
14
+ });
15
+ ReactThreeFiberCompiler.prototype.resolveCSharpTypeName = function (typescriptTypeName) {
16
+ return typescriptTypeName;
17
+ };
18
+ ReactThreeFiberCompiler.prototype.begin = function (filePath) {
19
+ };
20
+ ReactThreeFiberCompiler.prototype.end = function (filePath) {
21
+ };
22
+ ReactThreeFiberCompiler.prototype.startNewType = function (filePath, typeName, baseType, comments) {
23
+ };
24
+ ReactThreeFiberCompiler.prototype.endNewType = function (filePath, typeName) {
25
+ };
26
+ ReactThreeFiberCompiler.prototype.writeMember = function (visibility, name, isArray, type, initialValue, comments) {
27
+ };
28
+ ReactThreeFiberCompiler.prototype.writeMethod = function (visibility, name, returnType, args, comments) {
29
+ };
30
+ ReactThreeFiberCompiler.prototype.writeNewTypeExpression = function (typeName, args) {
31
+ };
32
+ ReactThreeFiberCompiler.prototype.registerEnum = function (name, members) {
33
+ };
34
+ return ReactThreeFiberCompiler;
35
+ }());
36
+ exports.ReactThreeFiberCompiler = ReactThreeFiberCompiler;
@@ -0,0 +1,5 @@
1
+ export { Compiler } from "./Compiler";
2
+ export { CSharpWriter } from "./impl/csharp-compiler";
3
+ export { BlenderWriter } from "./impl/blender-compiler";
4
+ export { FileSink, MemorySink, CodeTextWriter, Visibility, handleDeletedFile, runFromFile } from "./base-compiler";
5
+ export type { ISink, IWriter, Argument, EnumMember } from "./base-compiler";
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runFromFile = exports.handleDeletedFile = exports.Visibility = exports.CodeTextWriter = exports.MemorySink = exports.FileSink = exports.BlenderWriter = exports.CSharpWriter = exports.Compiler = void 0;
4
+ var Compiler_1 = require("./Compiler");
5
+ Object.defineProperty(exports, "Compiler", { enumerable: true, get: function () { return Compiler_1.Compiler; } });
6
+ var csharp_compiler_1 = require("./impl/csharp-compiler");
7
+ Object.defineProperty(exports, "CSharpWriter", { enumerable: true, get: function () { return csharp_compiler_1.CSharpWriter; } });
8
+ var blender_compiler_1 = require("./impl/blender-compiler");
9
+ Object.defineProperty(exports, "BlenderWriter", { enumerable: true, get: function () { return blender_compiler_1.BlenderWriter; } });
10
+ var base_compiler_1 = require("./base-compiler");
11
+ Object.defineProperty(exports, "FileSink", { enumerable: true, get: function () { return base_compiler_1.FileSink; } });
12
+ Object.defineProperty(exports, "MemorySink", { enumerable: true, get: function () { return base_compiler_1.MemorySink; } });
13
+ Object.defineProperty(exports, "CodeTextWriter", { enumerable: true, get: function () { return base_compiler_1.CodeTextWriter; } });
14
+ Object.defineProperty(exports, "Visibility", { enumerable: true, get: function () { return base_compiler_1.Visibility; } });
15
+ Object.defineProperty(exports, "handleDeletedFile", { enumerable: true, get: function () { return base_compiler_1.handleDeletedFile; } });
16
+ Object.defineProperty(exports, "runFromFile", { enumerable: true, get: function () { return base_compiler_1.runFromFile; } });
@@ -0,0 +1,8 @@
1
+ /**@key is the typescript source file */
2
+ export declare type TypeSourceInformation = {
3
+ [key: string]: {
4
+ componentName: string;
5
+ filePath: string;
6
+ }[];
7
+ };
8
+ export declare function writeTypeRegistry(types: TypeSourceInformation, registerTypesPath: string): void;
@@ -1,34 +1,34 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeTypeRegistry = void 0;
4
- var fs_1 = require("fs");
5
- var path = require("path");
6
- var base_compiler_1 = require("./base-compiler");
7
- function writeTypeRegistry(types, registerTypesPath) {
8
- console.log("Writing type registry to", registerTypesPath);
9
- var directory = path.dirname(registerTypesPath);
10
- if (!(0, fs_1.existsSync)(directory)) {
11
- (0, fs_1.mkdirSync)(directory);
12
- }
13
- var file = (0, fs_1.createWriteStream)(registerTypesPath);
14
- var writer = new base_compiler_1.CodeTextWriter();
15
- writer.writeLine("// This is an auto-generated file. Do not edit!\n");
16
- writer.writeLine("import { TypeStore } from \"@needle-tools/engine\";\n");
17
- for (var sourceFile in types) {
18
- if (!(0, fs_1.existsSync)(sourceFile))
19
- continue;
20
- var generatedFile = types[sourceFile];
21
- var relativePath = path.relative(directory, sourceFile).replace(/\\/g, "/");
22
- for (var _i = 0, generatedFile_1 = generatedFile; _i < generatedFile_1.length; _i++) {
23
- var fileInfo = generatedFile_1[_i];
24
- writer.writeLine("import { ".concat(fileInfo.componentName, " } from \"").concat(relativePath, "\";"));
25
- writer.writeLine("TypeStore.add(\"".concat(fileInfo.componentName, "\", ").concat(fileInfo.componentName, ");"));
26
- }
27
- }
28
- writer.writeLine("\n// Made with 🌵 Needle");
29
- writer.writeLine("// https://needle.tools");
30
- var code = writer.toString();
31
- file.write(code);
32
- file.end();
33
- }
34
- exports.writeTypeRegistry = writeTypeRegistry;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.writeTypeRegistry = void 0;
4
+ var fs_1 = require("fs");
5
+ var path = require("path");
6
+ var base_compiler_1 = require("./base-compiler");
7
+ function writeTypeRegistry(types, registerTypesPath) {
8
+ console.log("Writing type registry to", registerTypesPath);
9
+ var directory = path.dirname(registerTypesPath);
10
+ if (!(0, fs_1.existsSync)(directory)) {
11
+ (0, fs_1.mkdirSync)(directory);
12
+ }
13
+ var file = (0, fs_1.createWriteStream)(registerTypesPath);
14
+ var writer = new base_compiler_1.CodeTextWriter();
15
+ writer.writeLine("// This is an auto-generated file. Do not edit!\n");
16
+ writer.writeLine("import { TypeStore } from \"@needle-tools/engine\";\n");
17
+ for (var sourceFile in types) {
18
+ if (!(0, fs_1.existsSync)(sourceFile))
19
+ continue;
20
+ var generatedFile = types[sourceFile];
21
+ var relativePath = path.relative(directory, sourceFile).replace(/\\/g, "/");
22
+ for (var _i = 0, generatedFile_1 = generatedFile; _i < generatedFile_1.length; _i++) {
23
+ var fileInfo = generatedFile_1[_i];
24
+ writer.writeLine("import { ".concat(fileInfo.componentName, " } from \"").concat(relativePath, "\";"));
25
+ writer.writeLine("TypeStore.add(\"".concat(fileInfo.componentName, "\", ").concat(fileInfo.componentName, ");"));
26
+ }
27
+ }
28
+ writer.writeLine("\n// Made with 🌵 Needle");
29
+ writer.writeLine("// https://needle.tools");
30
+ var code = writer.toString();
31
+ file.write(code);
32
+ file.end();
33
+ }
34
+ exports.writeTypeRegistry = writeTypeRegistry;
@@ -0,0 +1,6 @@
1
+ import { IWriter } from "./base-compiler";
2
+ export declare class DirectoryWatcher {
3
+ private readonly compiler;
4
+ private _typesChanged;
5
+ startWatching(dir: string, writer: IWriter, registerTypesPath: string): void;
6
+ }