@needle-tools/needle-component-compiler 3.0.9 → 3.0.11
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/dist/BaseWriter.js +4 -1
- package/dist/Compiler.d.ts +2 -1
- package/dist/Compiler.js +40 -33
- package/dist/base-compiler.js +2 -1
- package/dist/cli.js +12 -3
- package/dist/impl/csharp-compiler.js +10 -2
- package/dist/log.d.ts +8 -0
- package/dist/log.js +30 -0
- package/dist/watcher.js +6 -5
- package/package.json +1 -1
package/dist/BaseWriter.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.BaseWriter = void 0;
|
|
|
4
4
|
var fs_1 = require("fs");
|
|
5
5
|
var base_compiler_1 = require("./base-compiler");
|
|
6
6
|
var commands_1 = require("./commands");
|
|
7
|
+
var log_1 = require("./log");
|
|
7
8
|
var BaseWriter = /** @class */ (function () {
|
|
8
9
|
function BaseWriter(_sink) {
|
|
9
10
|
this._sink = _sink;
|
|
@@ -38,7 +39,9 @@ var BaseWriter = /** @class */ (function () {
|
|
|
38
39
|
};
|
|
39
40
|
BaseWriter.prototype.end = function (filePath) {
|
|
40
41
|
var results = this._currentlyProcessingFiles[filePath];
|
|
41
|
-
|
|
42
|
+
if (results === null || results === void 0 ? void 0 : results.length) {
|
|
43
|
+
log_1.logger.log(" Schemes:", results.map(function (r) { return r.componentName; }).join(", "));
|
|
44
|
+
}
|
|
42
45
|
if (results) {
|
|
43
46
|
var previousResultsFromThisFile = this._createdSchemesPerFile[filePath];
|
|
44
47
|
if (previousResultsFromThisFile) {
|
package/dist/Compiler.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export declare class Compiler {
|
|
|
6
6
|
private visitEnumDeclaration;
|
|
7
7
|
private visit;
|
|
8
8
|
private visitClassDeclaration;
|
|
9
|
+
/** Format a structured log line for a member */
|
|
10
|
+
private logMember;
|
|
9
11
|
private visitPropertyDeclaration;
|
|
10
12
|
private hasSerializableDecorator;
|
|
11
13
|
/** Track accessor names already emitted per class to avoid duplicates when both getter and setter have @serializable() */
|
|
@@ -13,7 +15,6 @@ export declare class Compiler {
|
|
|
13
15
|
private visitAccessorDeclaration;
|
|
14
16
|
private visitMethodDeclaration;
|
|
15
17
|
private resolveParameters;
|
|
16
|
-
private debugLog;
|
|
17
18
|
private getComments;
|
|
18
19
|
/** Strip markdown/code/images/URLs/JSDoc tags to produce a plain-text tooltip */
|
|
19
20
|
private static sanitizeJsdocForTooltip;
|
package/dist/Compiler.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Compiler = void 0;
|
|
4
4
|
var ts = require("typescript");
|
|
5
5
|
var base_compiler_1 = require("./base-compiler");
|
|
6
|
+
var log_1 = require("./log");
|
|
6
7
|
/** Typescript Walker */
|
|
7
8
|
var Compiler = /** @class */ (function () {
|
|
8
9
|
function Compiler() {
|
|
@@ -17,7 +18,7 @@ var Compiler = /** @class */ (function () {
|
|
|
17
18
|
};
|
|
18
19
|
Compiler.prototype.run = function (prog, writer, sourceFile, filePath) {
|
|
19
20
|
var _this = this;
|
|
20
|
-
|
|
21
|
+
log_1.logger.log("Compiling", filePath);
|
|
21
22
|
writer.begin(filePath);
|
|
22
23
|
// Pre-scan: collect enum declarations so type resolution works for class fields
|
|
23
24
|
ts.forEachChild(sourceFile, function (node) {
|
|
@@ -62,7 +63,7 @@ var Compiler = /** @class */ (function () {
|
|
|
62
63
|
}
|
|
63
64
|
members.push({ name: memberName, value: value });
|
|
64
65
|
}
|
|
65
|
-
|
|
66
|
+
log_1.logger.log(" enum", name, "(" + members.length + " members)");
|
|
66
67
|
writer.registerEnum(name, members);
|
|
67
68
|
};
|
|
68
69
|
Compiler.prototype.visit = function (filePath, node, writer) {
|
|
@@ -102,10 +103,10 @@ var Compiler = /** @class */ (function () {
|
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
|
-
|
|
106
|
+
log_1.logger.log(" class " + name + (baseTypes.length ? " extends " + baseTypes.join(", ") : ""));
|
|
106
107
|
var res = writer.startNewType(filePath, name, baseTypes, this.getComments(node));
|
|
107
108
|
if (res === false) {
|
|
108
|
-
|
|
109
|
+
log_1.logger.log(" (skipped)");
|
|
109
110
|
return;
|
|
110
111
|
}
|
|
111
112
|
this._emittedAccessors.clear();
|
|
@@ -113,13 +114,23 @@ var Compiler = /** @class */ (function () {
|
|
|
113
114
|
_this.visit(filePath, node, writer);
|
|
114
115
|
});
|
|
115
116
|
writer.endNewType(filePath, name);
|
|
116
|
-
|
|
117
|
+
};
|
|
118
|
+
/** Format a structured log line for a member */
|
|
119
|
+
Compiler.prototype.logMember = function (kind, visibility, name, type, initialValue, flags) {
|
|
120
|
+
var parts = [];
|
|
121
|
+
parts.push(base_compiler_1.Visibility[visibility].toLowerCase());
|
|
122
|
+
if (flags && flags.length)
|
|
123
|
+
parts.push.apply(parts, flags);
|
|
124
|
+
var detail = parts.length ? " (" + parts.join(", ") + ")" : "";
|
|
125
|
+
var valStr = initialValue !== undefined && initialValue !== null ? " = " + initialValue : "";
|
|
126
|
+
log_1.logger.log(" " + kind + " " + name + ": " + (type || "?") + valStr + detail);
|
|
117
127
|
};
|
|
118
128
|
Compiler.prototype.visitPropertyDeclaration = function (node, writer) {
|
|
129
|
+
var _a;
|
|
119
130
|
// Skip static and abstract properties — they don't map to serialized fields
|
|
120
131
|
if (node.modifiers) {
|
|
121
|
-
for (var _i = 0,
|
|
122
|
-
var modifier =
|
|
132
|
+
for (var _i = 0, _b = node.modifiers; _i < _b.length; _i++) {
|
|
133
|
+
var modifier = _b[_i];
|
|
123
134
|
if (modifier.kind === ts.SyntaxKind.StaticKeyword ||
|
|
124
135
|
modifier.kind === ts.SyntaxKind.AbstractKeyword) {
|
|
125
136
|
return;
|
|
@@ -134,10 +145,22 @@ var Compiler = /** @class */ (function () {
|
|
|
134
145
|
if (!type && node.initializer) {
|
|
135
146
|
type = this.tryResolveTypeFromExpression(node.initializer, writer);
|
|
136
147
|
}
|
|
137
|
-
this.debugLog("[COMPILER] PROPERTY", base_compiler_1.Visibility[visibility], name, isArray, type, initialValue);
|
|
138
148
|
if (!type)
|
|
139
149
|
return; // cannot determine type — skip the field
|
|
140
|
-
|
|
150
|
+
var comments = (_a = this.getComments(node)) !== null && _a !== void 0 ? _a : [];
|
|
151
|
+
// If the property has a @serializable() decorator, ensure it's in the comments
|
|
152
|
+
// so the writer emits private/protected fields with [SerializeField]
|
|
153
|
+
var hasSerialized = this.hasSerializableDecorator(node);
|
|
154
|
+
if (hasSerialized && !comments.some(function (c) { return c.startsWith("@serializable"); })) {
|
|
155
|
+
comments.push("@serializable");
|
|
156
|
+
}
|
|
157
|
+
var flags = [];
|
|
158
|
+
if (isArray)
|
|
159
|
+
flags.push("array");
|
|
160
|
+
if (hasSerialized)
|
|
161
|
+
flags.push("@serializable");
|
|
162
|
+
this.logMember("+", visibility, name, type, initialValue, flags);
|
|
163
|
+
writer.writeMember(visibility, name, isArray, type, initialValue, comments);
|
|
141
164
|
};
|
|
142
165
|
Compiler.prototype.hasSerializableDecorator = function (node) {
|
|
143
166
|
var _a;
|
|
@@ -167,7 +190,6 @@ var Compiler = /** @class */ (function () {
|
|
|
167
190
|
typeNode = (_b = (_a = node.parameters) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.type;
|
|
168
191
|
}
|
|
169
192
|
type = this.resolveType(typeNode, writer);
|
|
170
|
-
this.debugLog("[COMPILER] ACCESSOR (serializable)", name, type);
|
|
171
193
|
if (!type)
|
|
172
194
|
return;
|
|
173
195
|
var isArray = typeNode ? this.isArrayType(typeNode) : false;
|
|
@@ -177,6 +199,10 @@ var Compiler = /** @class */ (function () {
|
|
|
177
199
|
if (!comments.some(function (c) { return c.startsWith("@serializable"); })) {
|
|
178
200
|
comments.push("@serializable");
|
|
179
201
|
}
|
|
202
|
+
var flags = ["accessor", "@serializable"];
|
|
203
|
+
if (isArray)
|
|
204
|
+
flags.push("array");
|
|
205
|
+
this.logMember("+", visibility, name, type, undefined, flags);
|
|
180
206
|
writer.writeMember(visibility, name, isArray, type, undefined, comments);
|
|
181
207
|
};
|
|
182
208
|
Compiler.prototype.visitMethodDeclaration = function (node, writer) {
|
|
@@ -198,7 +224,8 @@ var Compiler = /** @class */ (function () {
|
|
|
198
224
|
if ((_a = node.parameters) === null || _a === void 0 ? void 0 : _a.length) {
|
|
199
225
|
args = this.resolveParameters(node.parameters, writer);
|
|
200
226
|
}
|
|
201
|
-
|
|
227
|
+
var argsStr = (args === null || args === void 0 ? void 0 : args.length) ? "(" + args.map(function (a) { return (a.type || "?") + " " + a.name; }).join(", ") + ")" : "()";
|
|
228
|
+
this.logMember("+", visibility, name + argsStr, returnType || "void");
|
|
202
229
|
writer.writeMethod(visibility, name, returnType, args, this.getComments(node));
|
|
203
230
|
};
|
|
204
231
|
Compiler.prototype.resolveParameters = function (parameters, writer) {
|
|
@@ -213,13 +240,6 @@ var Compiler = /** @class */ (function () {
|
|
|
213
240
|
}
|
|
214
241
|
return result;
|
|
215
242
|
};
|
|
216
|
-
Compiler.prototype.debugLog = function () {
|
|
217
|
-
var args = [];
|
|
218
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
219
|
-
args[_i] = arguments[_i];
|
|
220
|
-
}
|
|
221
|
-
console.log.apply(console, args);
|
|
222
|
-
};
|
|
223
243
|
Compiler.prototype.getComments = function (node) {
|
|
224
244
|
var commentRanges = ts.getLeadingCommentRanges(node.getFullText(), 0);
|
|
225
245
|
if (commentRanges) {
|
|
@@ -305,19 +325,15 @@ var Compiler = /** @class */ (function () {
|
|
|
305
325
|
}
|
|
306
326
|
// Infer type from literal initializers (no explicit type annotation)
|
|
307
327
|
if (ts.isNumericLiteral(exp)) {
|
|
308
|
-
// e.g. speed = 5 or ratio = 5.5 → number → float
|
|
309
328
|
return this.resolveTypeFromString("number", write);
|
|
310
329
|
}
|
|
311
330
|
if (ts.isStringLiteral(exp)) {
|
|
312
|
-
// e.g. label = "hello" → string
|
|
313
331
|
return this.resolveTypeFromString("string", write);
|
|
314
332
|
}
|
|
315
333
|
if (exp.kind === ts.SyntaxKind.TrueKeyword || exp.kind === ts.SyntaxKind.FalseKeyword) {
|
|
316
|
-
// e.g. active = true → boolean → bool
|
|
317
334
|
return this.resolveTypeFromString("boolean", write);
|
|
318
335
|
}
|
|
319
336
|
if (ts.isPrefixUnaryExpression(exp) && ts.isNumericLiteral(exp.operand)) {
|
|
320
|
-
// e.g. speed = -5 or ratio = -1.5 → number → float
|
|
321
337
|
return this.resolveTypeFromString("number", write);
|
|
322
338
|
}
|
|
323
339
|
};
|
|
@@ -361,13 +377,7 @@ var Compiler = /** @class */ (function () {
|
|
|
361
377
|
}
|
|
362
378
|
}
|
|
363
379
|
}
|
|
364
|
-
|
|
365
|
-
// if (typeNode.kind === ts.SyntaxKind.TypeReference) {
|
|
366
|
-
// const typeReference = typeNode as ts.TypeReferenceNode;
|
|
367
|
-
// const typeArgument = typeReference.typeArguments && typeReference.typeArguments[0];
|
|
368
|
-
// return this.resolveType(typeArgument, writer);
|
|
369
|
-
// }
|
|
370
|
-
console.error("!!!!! ----- Unknown array type", typeNode.getText());
|
|
380
|
+
log_1.logger.warn("Unknown array type:", typeNode.getText());
|
|
371
381
|
}
|
|
372
382
|
// Union types: Object3D | null | undefined → resolve the first concrete member
|
|
373
383
|
if (ts.isUnionTypeNode(typeNode)) {
|
|
@@ -499,14 +509,11 @@ var Compiler = /** @class */ (function () {
|
|
|
499
509
|
else if (ts.isNewExpression(node)) {
|
|
500
510
|
var typeName = this.resolveTypeFromString(node.expression.getText(), writer);
|
|
501
511
|
if (typeName) {
|
|
502
|
-
console.log("TODO: new expression");
|
|
503
512
|
var args = node.arguments.map(function (a) { return _this.resolveExpression(a, writer); }).filter(function (a) { return a; });
|
|
504
|
-
// writer.writeNewTypeExpression(typeName, args);
|
|
505
|
-
// return;
|
|
506
513
|
return "new " + typeName + "(" + args.join(", ") + ")";
|
|
507
514
|
}
|
|
508
515
|
}
|
|
509
|
-
|
|
516
|
+
log_1.logger.warn("Unknown expression:", ts.SyntaxKind[node.kind], node.getText());
|
|
510
517
|
};
|
|
511
518
|
return Compiler;
|
|
512
519
|
}());
|
package/dist/base-compiler.js
CHANGED
|
@@ -6,6 +6,7 @@ exports.runFromFile = runFromFile;
|
|
|
6
6
|
var fs_1 = require("fs");
|
|
7
7
|
var fs = require("fs");
|
|
8
8
|
var commands_1 = require("./commands");
|
|
9
|
+
var log_1 = require("./log");
|
|
9
10
|
var Compiler_1 = require("./Compiler");
|
|
10
11
|
var Visibility;
|
|
11
12
|
(function (Visibility) {
|
|
@@ -21,7 +22,7 @@ var FileSink = /** @class */ (function () {
|
|
|
21
22
|
if (!fs.existsSync(this.directory)) {
|
|
22
23
|
fs.mkdirSync(this.directory, { recursive: true });
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
+
log_1.logger.log(" → Writing " + id);
|
|
25
26
|
var fullPath = this.directory + "/" + id;
|
|
26
27
|
// If the file already exists and contains codegen fences,
|
|
27
28
|
// preserve content outside the fences
|
package/dist/cli.js
CHANGED
|
@@ -7,6 +7,7 @@ var Compiler_1 = require("./Compiler");
|
|
|
7
7
|
var base_compiler_1 = require("./base-compiler");
|
|
8
8
|
var csharp_compiler_1 = require("./impl/csharp-compiler");
|
|
9
9
|
var blender_compiler_1 = require("./impl/blender-compiler");
|
|
10
|
+
var log_1 = require("./log");
|
|
10
11
|
var pkg = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf-8"));
|
|
11
12
|
var rawArgs = process.argv.slice(2);
|
|
12
13
|
if (rawArgs.includes("--version") || rawArgs.includes("-v")) {
|
|
@@ -26,6 +27,7 @@ if (rawArgs.includes("--help") || rawArgs.includes("-h") || rawArgs.length < 3)
|
|
|
26
27
|
console.log(" --types <path> path to Types.json with extra type mappings");
|
|
27
28
|
console.log("");
|
|
28
29
|
console.log("Flags:");
|
|
30
|
+
console.log(" --silent, -s only output errors and CMD: lines");
|
|
29
31
|
console.log(" --version, -v print version");
|
|
30
32
|
console.log(" --help, -h print this help");
|
|
31
33
|
if (rawArgs.length < 3 && !rawArgs.includes("--help") && !rawArgs.includes("-h")) {
|
|
@@ -33,17 +35,24 @@ if (rawArgs.includes("--help") || rawArgs.includes("-h") || rawArgs.length < 3)
|
|
|
33
35
|
}
|
|
34
36
|
process.exit(0);
|
|
35
37
|
}
|
|
36
|
-
// Extract
|
|
38
|
+
// Extract flags from anywhere in the args
|
|
37
39
|
var typesPath;
|
|
40
|
+
var silent = false;
|
|
38
41
|
var positionalArgs = [];
|
|
39
42
|
for (var i = 0; i < rawArgs.length; i++) {
|
|
40
43
|
if (rawArgs[i] === "--types" && i + 1 < rawArgs.length) {
|
|
41
44
|
typesPath = rawArgs[++i];
|
|
42
45
|
}
|
|
46
|
+
else if (rawArgs[i] === "--silent" || rawArgs[i] === "-s") {
|
|
47
|
+
silent = true;
|
|
48
|
+
}
|
|
43
49
|
else {
|
|
44
50
|
positionalArgs.push(rawArgs[i]);
|
|
45
51
|
}
|
|
46
52
|
}
|
|
53
|
+
if (silent) {
|
|
54
|
+
log_1.logger.silent = true;
|
|
55
|
+
}
|
|
47
56
|
var target = positionalArgs[0];
|
|
48
57
|
var outputDir = positionalArgs[1];
|
|
49
58
|
var inputFiles = positionalArgs.slice(2);
|
|
@@ -60,7 +69,7 @@ if (typesPath) {
|
|
|
60
69
|
else {
|
|
61
70
|
try {
|
|
62
71
|
externalTypes = JSON.parse(fs.readFileSync(typesPath, "utf-8"));
|
|
63
|
-
|
|
72
|
+
log_1.logger.log("Loaded ".concat(Object.keys(externalTypes).length, " external type mappings from ").concat(typesPath));
|
|
64
73
|
}
|
|
65
74
|
catch (e) {
|
|
66
75
|
console.error("Error reading types file: ".concat(e));
|
|
@@ -68,7 +77,7 @@ if (typesPath) {
|
|
|
68
77
|
}
|
|
69
78
|
}
|
|
70
79
|
}
|
|
71
|
-
|
|
80
|
+
log_1.logger.log("needle-component-compiler v".concat(pkg.version));
|
|
72
81
|
var sink = new base_compiler_1.FileSink(outputDir);
|
|
73
82
|
var writer = target === "csharp" ? new csharp_compiler_1.CSharpWriter(sink, externalTypes) : new blender_compiler_1.BlenderWriter(sink);
|
|
74
83
|
var compiler = new Compiler_1.Compiler();
|
|
@@ -128,12 +128,20 @@ var CSharpWriter = /** @class */ (function (_super) {
|
|
|
128
128
|
return _this;
|
|
129
129
|
}
|
|
130
130
|
CSharpWriter.prototype.resolveCSharpTypeName = function (typescriptTypeName) {
|
|
131
|
-
var _a, _b, _c, _d, _e
|
|
131
|
+
var _a, _b, _c, _d, _e;
|
|
132
132
|
if (!typescriptTypeName)
|
|
133
133
|
return undefined;
|
|
134
134
|
// Strip THREE. prefix for lookup fallback
|
|
135
135
|
var stripped = typescriptTypeName.startsWith("THREE.") ? typescriptTypeName.substring(6) : typescriptTypeName;
|
|
136
|
-
|
|
136
|
+
// Check built-in TYPE_MAP first (TS→C# mapping)
|
|
137
|
+
var builtIn = (_a = TYPE_MAP[typescriptTypeName]) !== null && _a !== void 0 ? _a : TYPE_MAP[stripped];
|
|
138
|
+
if (builtIn)
|
|
139
|
+
return builtIn;
|
|
140
|
+
// If the name is already a known C# type (e.g. "float"), return it as-is
|
|
141
|
+
// to prevent external types from overriding it (e.g. "float" → "System.Single")
|
|
142
|
+
if (KNOWN_CSHARP_TYPES.has(typescriptTypeName))
|
|
143
|
+
return typescriptTypeName;
|
|
144
|
+
return (_e = (_c = (_b = this.externalTypes) === null || _b === void 0 ? void 0 : _b[typescriptTypeName]) !== null && _c !== void 0 ? _c : (_d = this.externalTypes) === null || _d === void 0 ? void 0 : _d[stripped]) !== null && _e !== void 0 ? _e : typescriptTypeName;
|
|
137
145
|
};
|
|
138
146
|
/** Tries to resolve a C# type name; returns undefined if the type is not known.
|
|
139
147
|
* Checks TYPE_MAP keys/values and the enum registry. */
|
package/dist/log.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Simple logger that can be silenced via the `silent` flag.
|
|
2
|
+
* Errors and CMD: lines are always emitted regardless of silent mode. */
|
|
3
|
+
export declare const logger: {
|
|
4
|
+
silent: boolean;
|
|
5
|
+
log(...args: any[]): void;
|
|
6
|
+
warn(...args: any[]): void;
|
|
7
|
+
error(...args: any[]): void;
|
|
8
|
+
};
|
package/dist/log.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logger = void 0;
|
|
4
|
+
/** Simple logger that can be silenced via the `silent` flag.
|
|
5
|
+
* Errors and CMD: lines are always emitted regardless of silent mode. */
|
|
6
|
+
exports.logger = {
|
|
7
|
+
silent: false,
|
|
8
|
+
log: function () {
|
|
9
|
+
var args = [];
|
|
10
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11
|
+
args[_i] = arguments[_i];
|
|
12
|
+
}
|
|
13
|
+
if (!this.silent)
|
|
14
|
+
console.log.apply(console, args);
|
|
15
|
+
},
|
|
16
|
+
warn: function () {
|
|
17
|
+
var args = [];
|
|
18
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
19
|
+
args[_i] = arguments[_i];
|
|
20
|
+
}
|
|
21
|
+
console.warn.apply(console, args);
|
|
22
|
+
},
|
|
23
|
+
error: function () {
|
|
24
|
+
var args = [];
|
|
25
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
26
|
+
args[_i] = arguments[_i];
|
|
27
|
+
}
|
|
28
|
+
console.error.apply(console, args);
|
|
29
|
+
},
|
|
30
|
+
};
|
package/dist/watcher.js
CHANGED
|
@@ -7,6 +7,7 @@ var Compiler_1 = require("./Compiler");
|
|
|
7
7
|
var blender_compiler_1 = require("./impl/blender-compiler");
|
|
8
8
|
var chokidar = require("chokidar");
|
|
9
9
|
var commands_1 = require("./commands");
|
|
10
|
+
var log_1 = require("./log");
|
|
10
11
|
var register_types_1 = require("./register-types");
|
|
11
12
|
// https://github.com/paulmillr/chokidar
|
|
12
13
|
var DirectoryWatcher = /** @class */ (function () {
|
|
@@ -21,22 +22,22 @@ var DirectoryWatcher = /** @class */ (function () {
|
|
|
21
22
|
try {
|
|
22
23
|
switch (event) {
|
|
23
24
|
case "add":
|
|
24
|
-
|
|
25
|
+
log_1.logger.log("File added:", path);
|
|
25
26
|
_this.compiler.compile(writer, fs.readFileSync(path).toString(), path);
|
|
26
27
|
_this._typesChanged = true;
|
|
27
28
|
break;
|
|
28
29
|
case "change":
|
|
29
|
-
|
|
30
|
+
log_1.logger.log("File changed:", path);
|
|
30
31
|
_this.compiler.compile(writer, fs.readFileSync(path).toString(), path);
|
|
31
32
|
_this._typesChanged = true;
|
|
32
33
|
break;
|
|
33
34
|
case "unlink":
|
|
34
|
-
|
|
35
|
+
log_1.logger.log("File removed:", path);
|
|
35
36
|
(0, base_compiler_1.handleDeletedFile)(path, writer.outputInfo);
|
|
36
37
|
_this._typesChanged = true;
|
|
37
38
|
break;
|
|
38
39
|
default:
|
|
39
|
-
|
|
40
|
+
log_1.logger.log("File unhandled event:", event, path);
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
catch (err) {
|
|
@@ -73,7 +74,7 @@ if (!fs.existsSync(directoryToWatch)) {
|
|
|
73
74
|
}
|
|
74
75
|
if (fs.existsSync(outputDirectory))
|
|
75
76
|
fs.rmSync(outputDirectory, { recursive: true });
|
|
76
|
-
|
|
77
|
+
log_1.logger.log("Watch:", directoryToWatch, "→", outputDirectory);
|
|
77
78
|
var watcher = new DirectoryWatcher();
|
|
78
79
|
var sink = new base_compiler_1.FileSink(outputDirectory);
|
|
79
80
|
watcher.startWatching(directoryToWatch, new blender_compiler_1.BlenderWriter(sink), registerTypesPath);
|