@needle-tools/needle-component-compiler 3.0.0 → 3.0.1

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
@@ -4,6 +4,13 @@ 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.1] - 2026-03-04
8
+
9
+ ### Fixed
10
+ - Fix string enum values being double-quoted in Blender output (e.g. `"\"A\""` instead of `"A"`)
11
+ - Fix user-defined enums whose name collides with a built-in type (e.g. `Color`) being mapped to the built-in type instead of emitting as enum
12
+ - Fix enum registry leaking across compilations, causing stale enum definitions from previous files to affect subsequent compilations
13
+
7
14
  ## [3.0.0] - 2026-03-04
8
15
 
9
16
  ### Changed
@@ -31,6 +31,7 @@ var BaseWriter = /** @class */ (function () {
31
31
  configurable: true
32
32
  });
33
33
  BaseWriter.prototype.begin = function (filePath) {
34
+ this._enumRegistry.clear();
34
35
  if (!this._currentlyProcessingFiles[filePath]) {
35
36
  this._currentlyProcessingFiles[filePath] = [];
36
37
  }
package/dist/Compiler.js CHANGED
@@ -16,13 +16,13 @@ var Compiler = /** @class */ (function () {
16
16
  Compiler.prototype.run = function (prog, writer, sourceFile, filePath) {
17
17
  var _this = this;
18
18
  console.log("Starting compilation of " + filePath);
19
+ writer.begin(filePath);
19
20
  // Pre-scan: collect enum declarations so type resolution works for class fields
20
21
  ts.forEachChild(sourceFile, function (node) {
21
22
  if (ts.isEnumDeclaration(node)) {
22
23
  _this.visitEnumDeclaration(node, writer);
23
24
  }
24
25
  });
25
- writer.begin(filePath);
26
26
  ts.forEachChild(sourceFile, function (node) {
27
27
  _this.visit(filePath, node, writer);
28
28
  });
@@ -46,8 +46,12 @@ var Compiler = /** @class */ (function () {
46
46
  value = parseFloat(ts.tokenToString(member.initializer.operator) + member.initializer.operand.getText());
47
47
  nextValue = value + 1;
48
48
  }
49
+ else if (ts.isStringLiteral(member.initializer)) {
50
+ // String enum value — use .text to get the raw string without surrounding quotes
51
+ value = member.initializer.text;
52
+ }
49
53
  else {
50
- // String or computed value — store as-is
54
+ // Other computed value — store as-is
51
55
  value = member.initializer.getText();
52
56
  }
53
57
  }
@@ -29,6 +29,9 @@ var BlenderWriter = /** @class */ (function (_super) {
29
29
  typeName = typeName.toLocaleLowerCase();
30
30
  if (typeName.startsWith("three."))
31
31
  typeName = typeName.substring("three.".length);
32
+ // If the type is a registered enum, return as-is so writeMember handles it
33
+ if (this._enumRegistry.has(typeName))
34
+ return typeName;
32
35
  switch (typeName) {
33
36
  case "number":
34
37
  return "float";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/needle-component-compiler",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Compile Editor components for Needle Engine for C# and Blender",
5
5
  "main": "dist/index.js",
6
6
  "bin": {