@needle-tools/needle-component-compiler 3.0.18 → 3.0.19-next.e2b9a6e

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,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"`)
@@ -8,7 +8,7 @@ export declare abstract class BaseWriter implements IWriter {
8
8
  /** Enum registry: lowercased enum name → members */
9
9
  protected _enumRegistry: Map<string, EnumMember[]>;
10
10
  registerEnum(name: string, members: EnumMember[]): void;
11
- abstract resolveCSharpTypeName(typescriptTypeName: string, baseTypes?: string[]): string | void;
11
+ abstract resolveNeedleTypeName(typescriptTypeName: string, baseTypes?: string[]): string | void;
12
12
  abstract startNewType(filePath: string, typeName: string, baseType: string[], comments?: string[]): boolean | void;
13
13
  abstract endNewType(filePath: string, typeName: string): void;
14
14
  abstract writeMember(visibility: Visibility, name: string, isArray: boolean, type: string, initialValue?: string, comments?: string[]): void;
package/dist/Compiler.js CHANGED
@@ -429,7 +429,7 @@ var Compiler = /** @class */ (function () {
429
429
  return this.resolveTypeFromString(typeNode.getText(), writer);
430
430
  };
431
431
  Compiler.prototype.resolveTypeFromString = function (type, writer) {
432
- var resolved = writer.resolveCSharpTypeName(type);
432
+ var resolved = writer.resolveNeedleTypeName(type);
433
433
  return resolved || type;
434
434
  };
435
435
  Compiler.prototype.isArrayType = function (typeNode) {
@@ -44,7 +44,7 @@ export type EnumMember = {
44
44
  export interface IWriter {
45
45
  get outputInfo(): TypeSourceInformation;
46
46
  begin(filePath: string | null): void;
47
- resolveCSharpTypeName(typescriptTypeName: string, baseTypes?: string[]): string | void;
47
+ resolveNeedleTypeName(typescriptTypeName: string, baseTypes?: string[]): string | void;
48
48
  end(filePath: string | null): void;
49
49
  startNewType(filePath: string | null, typeName: string, baseType: string[], comments?: string[]): void | boolean;
50
50
  endNewType(filePath: string | null, typeName: string): void;
@@ -1,7 +1,7 @@
1
1
  import { Visibility } from "../base-compiler";
2
2
  import { BaseWriter } from "../BaseWriter";
3
3
  export declare class BlenderWriter extends BaseWriter {
4
- resolveCSharpTypeName(typeName: string, comments?: string[]): string | void;
4
+ resolveNeedleTypeName(typeName: string, comments?: string[]): string | void;
5
5
  startNewType(filePath: string | null, typeName: string, baseTypes: string[], comments?: string[]): void | boolean;
6
6
  endNewType(filePath: string | null, typeName: string): void;
7
7
  writeMember(visibility: Visibility, name: string, isArray: boolean, type: string, initialValue?: string, comments?: string[]): void;
@@ -26,7 +26,7 @@ var BlenderWriter = /** @class */ (function (_super) {
26
26
  function BlenderWriter() {
27
27
  return _super !== null && _super.apply(this, arguments) || this;
28
28
  }
29
- BlenderWriter.prototype.resolveCSharpTypeName = function (typeName, comments) {
29
+ BlenderWriter.prototype.resolveNeedleTypeName = function (typeName, comments) {
30
30
  typeName = typeName.toLocaleLowerCase();
31
31
  if (typeName.startsWith("three."))
32
32
  typeName = typeName.substring("three.".length);
@@ -59,17 +59,23 @@ var BlenderWriter = /** @class */ (function (_super) {
59
59
  case "eventlist":
60
60
  return "evt";
61
61
  case "behaviour":
62
- case "animation": // Animation component ref
63
- case "animator": // Animator component ref
64
- case "camera":
65
- case "light":
66
- case "rigidbody":
67
- case "renderer": // Renderer component ref
68
- case "canvas": // Canvas component ref
69
- case "charactercontroller": // CharacterController component ref
70
- case "videoplayer": // VideoPlayer component ref
71
- case "lookatconstraint": // LookAtConstraint component ref
72
62
  return "comp";
63
+ case "animation": return "Animation";
64
+ case "animator": return "Animator";
65
+ case "camera": return "Camera";
66
+ case "light": return "Light";
67
+ case "rigidbody": return "Rigidbody";
68
+ case "renderer": return "Renderer";
69
+ case "canvas": return "Canvas";
70
+ case "videoplayer": return "VideoPlayer";
71
+ case "audiosource": return "AudioSource";
72
+ case "spherecollider": return "SphereCollider";
73
+ case "meshcollider": return "MeshCollider";
74
+ case "boxcollider": return "BoxCollider";
75
+ case "playabledirector": return "PlayableDirector";
76
+ case "dragcontrols": return "DragControls";
77
+ case "button": return "Button";
78
+ case "text": return "Text";
73
79
  case "texture":
74
80
  return "tex";
75
81
  case "image":
@@ -3,7 +3,7 @@ import { BaseWriter } from "../BaseWriter";
3
3
  export declare class CSharpWriter extends BaseWriter {
4
4
  private externalTypes;
5
5
  constructor(sink?: ISink, externalTypes?: Record<string, string>);
6
- resolveCSharpTypeName(typescriptTypeName: string): string | void;
6
+ resolveNeedleTypeName(typescriptTypeName: string): string | void;
7
7
  /** Tries to resolve a C# type name; returns undefined if the type is not known.
8
8
  * Checks TYPE_MAP keys/values and the enum registry. */
9
9
  resolveKnownCSharpTypeName(typeName: string): string | undefined;
@@ -129,7 +129,7 @@ var CSharpWriter = /** @class */ (function (_super) {
129
129
  _this.externalTypes = externalTypes;
130
130
  return _this;
131
131
  }
132
- CSharpWriter.prototype.resolveCSharpTypeName = function (typescriptTypeName) {
132
+ CSharpWriter.prototype.resolveNeedleTypeName = function (typescriptTypeName) {
133
133
  var _a, _b, _c, _d, _e;
134
134
  if (!typescriptTypeName)
135
135
  return undefined;
@@ -191,7 +191,7 @@ var CSharpWriter = /** @class */ (function (_super) {
191
191
  }
192
192
  else if (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) {
193
193
  var first = baseTypes[0];
194
- resolvedBase = (_a = this.resolveCSharpTypeName(first)) !== null && _a !== void 0 ? _a : "UnityEngine.MonoBehaviour";
194
+ resolvedBase = (_a = this.resolveNeedleTypeName(first)) !== null && _a !== void 0 ? _a : "UnityEngine.MonoBehaviour";
195
195
  }
196
196
  // Abstract modifier
197
197
  var isAbstract = comments === null || comments === void 0 ? void 0 : comments.includes("@abstract");
@@ -222,7 +222,7 @@ var CSharpWriter = /** @class */ (function (_super) {
222
222
  var typeOverride = comments === null || comments === void 0 ? void 0 : comments.find(function (c) { return c.startsWith("@type "); });
223
223
  var csharpType = typeOverride
224
224
  ? typeOverride.substring("@type ".length).trim()
225
- : ((_a = this.resolveCSharpTypeName(type)) !== null && _a !== void 0 ? _a : type);
225
+ : ((_a = this.resolveNeedleTypeName(type)) !== null && _a !== void 0 ? _a : type);
226
226
  // Determine visibility string
227
227
  var vis = "public";
228
228
  if (visibility === base_compiler_1.Visibility.Private || visibility === base_compiler_1.Visibility.Protected) {
@@ -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 === "null") {
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 === "[]") {
@@ -387,7 +390,7 @@ var CSharpWriter = /** @class */ (function (_super) {
387
390
  if (!match)
388
391
  return expr;
389
392
  var typeName = match[1], argsStr = match[2];
390
- var csharpType = (_a = this.resolveCSharpTypeName(typeName)) !== null && _a !== void 0 ? _a : typeName;
393
+ var csharpType = (_a = this.resolveNeedleTypeName(typeName)) !== null && _a !== void 0 ? _a : typeName;
391
394
  // Convert numeric literals to float
392
395
  var csharpArgs = argsStr.replace(/(\d+\.?\d*)/g, function (n) {
393
396
  return n.includes(".") ? "".concat(n, "f") : "".concat(n, "f");
@@ -4,7 +4,7 @@ export declare class ReactThreeFiberCompiler implements IWriter {
4
4
  get outputInfo(): TypeSourceInformation;
5
5
  private readonly _typeSourceInformation;
6
6
  constructor();
7
- resolveCSharpTypeName(typescriptTypeName: string): string | void;
7
+ resolveNeedleTypeName(typescriptTypeName: string): string | void;
8
8
  begin(filePath: string): void;
9
9
  end(filePath: string): void;
10
10
  startNewType(filePath: string, typeName: string, baseType: string[], comments?: string[]): boolean | void;
@@ -12,7 +12,7 @@ var ReactThreeFiberCompiler = /** @class */ (function () {
12
12
  enumerable: false,
13
13
  configurable: true
14
14
  });
15
- ReactThreeFiberCompiler.prototype.resolveCSharpTypeName = function (typescriptTypeName) {
15
+ ReactThreeFiberCompiler.prototype.resolveNeedleTypeName = function (typescriptTypeName) {
16
16
  return typescriptTypeName;
17
17
  };
18
18
  ReactThreeFiberCompiler.prototype.begin = function (filePath) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/needle-component-compiler",
3
- "version": "3.0.18",
3
+ "version": "3.0.19-next.e2b9a6e",
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",