@needle-tools/needle-component-compiler 3.0.17 → 3.0.19
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 +12 -0
- package/dist/cli.js +42 -1
- package/dist/impl/csharp-compiler.js +4 -1
- package/package.json +1 -1
package/Changelog.md
CHANGED
|
@@ -4,6 +4,18 @@ All notable changes to this package will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [3.0.19] - 2026-04-28
|
|
8
|
+
### Fixed
|
|
9
|
+
- C#: skip `= undefined` initializers — `undefined` is not valid in C#
|
|
10
|
+
|
|
11
|
+
## [3.0.18] - 2026-04-28
|
|
12
|
+
### Added
|
|
13
|
+
- CLI: Blender write types automatically
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
- Blender: fix custom enum type parsing
|
|
17
|
+
- Blender: fix missing default values in component.json
|
|
18
|
+
|
|
7
19
|
## [3.0.17] - 2026-04-17
|
|
8
20
|
### Added
|
|
9
21
|
- Support for string literal union types (e.g. `axis: "x" | "y" | "z" = "y"`)
|
package/dist/cli.js
CHANGED
|
@@ -8,6 +8,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
10
|
var log_1 = require("./log");
|
|
11
|
+
var register_types_1 = require("./register-types");
|
|
11
12
|
var pkg = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf-8"));
|
|
12
13
|
var rawArgs = process.argv.slice(2);
|
|
13
14
|
if (rawArgs.includes("--version") || rawArgs.includes("-v")) {
|
|
@@ -24,7 +25,8 @@ if (rawArgs.includes("--help") || rawArgs.includes("-h") || rawArgs.length < 3)
|
|
|
24
25
|
console.log(" input_files one or more .ts source files");
|
|
25
26
|
console.log("");
|
|
26
27
|
console.log("Options:");
|
|
27
|
-
console.log(" --types <path>
|
|
28
|
+
console.log(" --types <path> path to Types.json with extra type mappings");
|
|
29
|
+
console.log(" --register-types <bool> auto-generate register-types (default: true)");
|
|
28
30
|
console.log("");
|
|
29
31
|
console.log("Flags:");
|
|
30
32
|
console.log(" --silent, -s only output errors and CMD: lines");
|
|
@@ -38,11 +40,16 @@ if (rawArgs.includes("--help") || rawArgs.includes("-h") || rawArgs.length < 3)
|
|
|
38
40
|
// Extract flags from anywhere in the args
|
|
39
41
|
var typesPath;
|
|
40
42
|
var silent = false;
|
|
43
|
+
var registerTypes = true;
|
|
41
44
|
var positionalArgs = [];
|
|
42
45
|
for (var i = 0; i < rawArgs.length; i++) {
|
|
43
46
|
if (rawArgs[i] === "--types" && i + 1 < rawArgs.length) {
|
|
44
47
|
typesPath = rawArgs[++i];
|
|
45
48
|
}
|
|
49
|
+
else if (rawArgs[i] === "--register-types" && i + 1 < rawArgs.length) {
|
|
50
|
+
var val = rawArgs[++i].toLowerCase();
|
|
51
|
+
registerTypes = val !== "false" && val !== "0";
|
|
52
|
+
}
|
|
46
53
|
else if (rawArgs[i] === "--silent" || rawArgs[i] === "-s") {
|
|
47
54
|
silent = true;
|
|
48
55
|
}
|
|
@@ -98,6 +105,40 @@ for (var _i = 0, inputFiles_1 = inputFiles; _i < inputFiles_1.length; _i++) {
|
|
|
98
105
|
hasErrors = true;
|
|
99
106
|
}
|
|
100
107
|
}
|
|
108
|
+
// Auto-detect and write register-types files using needle.config.json
|
|
109
|
+
if (registerTypes && target === "blender") {
|
|
110
|
+
var codegenDir = void 0;
|
|
111
|
+
// Search upward from outputDir for needle.config.json
|
|
112
|
+
var searchDir = path.resolve(outputDir);
|
|
113
|
+
while (searchDir !== path.dirname(searchDir)) {
|
|
114
|
+
var configPath = path.join(searchDir, "needle.config.json");
|
|
115
|
+
if (fs.existsSync(configPath)) {
|
|
116
|
+
try {
|
|
117
|
+
var config = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
118
|
+
if (config.codegenDirectory) {
|
|
119
|
+
codegenDir = path.resolve(searchDir, config.codegenDirectory);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch (_e) { }
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
searchDir = path.dirname(searchDir);
|
|
126
|
+
}
|
|
127
|
+
if (codegenDir) {
|
|
128
|
+
var candidates = [
|
|
129
|
+
path.join(codegenDir, "register-types.js"),
|
|
130
|
+
path.join(codegenDir, "register-types.ts"),
|
|
131
|
+
path.join(codegenDir, "register_types.ts"),
|
|
132
|
+
path.join(codegenDir, "register_types.js"),
|
|
133
|
+
];
|
|
134
|
+
for (var _a = 0, candidates_1 = candidates; _a < candidates_1.length; _a++) {
|
|
135
|
+
var candidate = candidates_1[_a];
|
|
136
|
+
if (fs.existsSync(candidate)) {
|
|
137
|
+
(0, register_types_1.writeTypeRegistry)(writer.outputInfo, candidate);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
101
142
|
if (hasErrors) {
|
|
102
143
|
process.exit(1);
|
|
103
144
|
}
|
|
@@ -245,7 +245,10 @@ var CSharpWriter = /** @class */ (function (_super) {
|
|
|
245
245
|
// Resolve assignment
|
|
246
246
|
var assignment = "";
|
|
247
247
|
if (initialValue !== undefined && initialValue !== null) {
|
|
248
|
-
if (initialValue === "
|
|
248
|
+
if (initialValue === "undefined") {
|
|
249
|
+
// skip — `undefined` is not valid in C#
|
|
250
|
+
}
|
|
251
|
+
else if (initialValue === "null") {
|
|
249
252
|
// keep null for reference types, skip for value types
|
|
250
253
|
}
|
|
251
254
|
else if (isArray && initialValue === "[]") {
|