@needle-tools/needle-component-compiler 3.0.6 → 3.0.8
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/Compiler.js
CHANGED
|
@@ -141,11 +141,14 @@ var Compiler = /** @class */ (function () {
|
|
|
141
141
|
};
|
|
142
142
|
Compiler.prototype.hasSerializableDecorator = function (node) {
|
|
143
143
|
var _a;
|
|
144
|
-
|
|
144
|
+
// TS 5+: use ts.getDecorators(); TS 4.x: fall back to node.decorators
|
|
145
|
+
var decorators = typeof ts.getDecorators === "function"
|
|
146
|
+
? ts.getDecorators(node)
|
|
147
|
+
: node.decorators;
|
|
145
148
|
return (_a = decorators === null || decorators === void 0 ? void 0 : decorators.some(function (d) { return d.expression.getText().startsWith("serializable"); })) !== null && _a !== void 0 ? _a : false;
|
|
146
149
|
};
|
|
147
150
|
Compiler.prototype.visitAccessorDeclaration = function (node, writer) {
|
|
148
|
-
var _a, _b;
|
|
151
|
+
var _a, _b, _c;
|
|
149
152
|
// Only emit if the accessor has a @serializable() decorator
|
|
150
153
|
if (!this.hasSerializableDecorator(node))
|
|
151
154
|
return;
|
|
@@ -169,7 +172,12 @@ var Compiler = /** @class */ (function () {
|
|
|
169
172
|
return;
|
|
170
173
|
var isArray = typeNode ? this.isArrayType(typeNode) : false;
|
|
171
174
|
var visibility = this.getVisibility(node);
|
|
172
|
-
|
|
175
|
+
var comments = (_c = this.getComments(node)) !== null && _c !== void 0 ? _c : [];
|
|
176
|
+
// Ensure @serializable is in the comments so the writer knows to emit private/protected fields
|
|
177
|
+
if (!comments.some(function (c) { return c.startsWith("@serializable"); })) {
|
|
178
|
+
comments.push("@serializable");
|
|
179
|
+
}
|
|
180
|
+
writer.writeMember(visibility, name, isArray, type, undefined, comments);
|
|
173
181
|
};
|
|
174
182
|
Compiler.prototype.visitMethodDeclaration = function (node, writer) {
|
|
175
183
|
var _a;
|
package/dist/base-compiler.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare class CodeTextWriter {
|
|
|
37
37
|
toString(): string;
|
|
38
38
|
}
|
|
39
39
|
export declare function handleDeletedFile(filePath: string, types: TypeSourceInformation): void;
|
|
40
|
-
export
|
|
40
|
+
export type EnumMember = {
|
|
41
41
|
name: string;
|
|
42
42
|
value: number | string;
|
|
43
43
|
};
|
package/dist/base-compiler.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.CodeTextWriter = exports.MemorySink = exports.FileSink = exports.Visibility = void 0;
|
|
4
|
+
exports.handleDeletedFile = handleDeletedFile;
|
|
5
|
+
exports.runFromFile = runFromFile;
|
|
4
6
|
var fs_1 = require("fs");
|
|
5
7
|
var fs = require("fs");
|
|
6
8
|
var commands_1 = require("./commands");
|
|
@@ -10,7 +12,7 @@ var Visibility;
|
|
|
10
12
|
Visibility[Visibility["Public"] = 0] = "Public";
|
|
11
13
|
Visibility[Visibility["Protected"] = 1] = "Protected";
|
|
12
14
|
Visibility[Visibility["Private"] = 2] = "Private";
|
|
13
|
-
})(Visibility
|
|
15
|
+
})(Visibility || (exports.Visibility = Visibility = {}));
|
|
14
16
|
var FileSink = /** @class */ (function () {
|
|
15
17
|
function FileSink(directory) {
|
|
16
18
|
this.directory = directory;
|
|
@@ -168,7 +170,6 @@ function handleDeletedFile(filePath, types) {
|
|
|
168
170
|
}
|
|
169
171
|
}
|
|
170
172
|
}
|
|
171
|
-
exports.handleDeletedFile = handleDeletedFile;
|
|
172
173
|
function runFromFile(writer, path) {
|
|
173
174
|
if (!fs.existsSync(path)) {
|
|
174
175
|
console.error("File not found", path);
|
|
@@ -179,4 +180,3 @@ function runFromFile(writer, path) {
|
|
|
179
180
|
compiler.compile(writer, code, path);
|
|
180
181
|
return compiler;
|
|
181
182
|
}
|
|
182
|
-
exports.runFromFile = runFromFile;
|
package/dist/commands.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.sendReloadCommand = sendReloadCommand;
|
|
4
|
+
exports.sendFileWrittenCommand = sendFileWrittenCommand;
|
|
5
|
+
exports.sendFileDeletedCommand = sendFileDeletedCommand;
|
|
4
6
|
function sendReloadCommand() {
|
|
5
7
|
process.stdout.write("CMD:reload\r");
|
|
6
8
|
}
|
|
7
|
-
exports.sendReloadCommand = sendReloadCommand;
|
|
8
9
|
function sendFileWrittenCommand(path) {
|
|
9
10
|
process.stdout.write("CMD:writefile " + path + "\r");
|
|
10
11
|
}
|
|
11
|
-
exports.sendFileWrittenCommand = sendFileWrittenCommand;
|
|
12
12
|
function sendFileDeletedCommand(path) {
|
|
13
13
|
process.stdout.write("CMD:deletedfile " + path + "\r");
|
|
14
14
|
}
|
|
15
|
-
exports.sendFileDeletedCommand = sendFileDeletedCommand;
|
|
@@ -346,7 +346,7 @@ var CSharpWriter = /** @class */ (function (_super) {
|
|
|
346
346
|
CSharpWriter.prototype.resolveNewExpression = function (expr) {
|
|
347
347
|
var _a;
|
|
348
348
|
// expr is already resolved: "new UnityEngine.Vector2(1, 0.5)" → "new UnityEngine.Vector2(1f, 0.5f)"
|
|
349
|
-
var match = expr.match(/^new\s+([\w.]+)\s*\((
|
|
349
|
+
var match = expr.match(/^new\s+([\w.]+)\s*\(([\s\S]*)\)$/);
|
|
350
350
|
if (!match)
|
|
351
351
|
return expr;
|
|
352
352
|
var typeName = match[1], argsStr = match[2];
|
package/dist/register-types.d.ts
CHANGED
package/dist/register-types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.writeTypeRegistry =
|
|
3
|
+
exports.writeTypeRegistry = writeTypeRegistry;
|
|
4
4
|
var fs_1 = require("fs");
|
|
5
5
|
var path = require("path");
|
|
6
6
|
var base_compiler_1 = require("./base-compiler");
|
|
@@ -31,4 +31,3 @@ function writeTypeRegistry(types, registerTypesPath) {
|
|
|
31
31
|
file.write(code);
|
|
32
32
|
file.end();
|
|
33
33
|
}
|
|
34
|
-
exports.writeTypeRegistry = writeTypeRegistry;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/needle-component-compiler",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.8",
|
|
4
4
|
"description": "Compile Editor components for Needle Engine for C# and Blender",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": "dist/cli.js",
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"chokidar": "^3.5.3",
|
|
26
|
-
"typescript": "^
|
|
26
|
+
"typescript": "^5.0.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/chai": "^4.3.3",
|
|
30
30
|
"@types/mocha": "^10",
|
|
31
|
-
"@types/node": "^
|
|
31
|
+
"@types/node": "^22.19.15",
|
|
32
32
|
"chai": "^4.3.6",
|
|
33
33
|
"mocha": "^10.0.0",
|
|
34
34
|
"npm-watch": "^0.11.0",
|