@needle-tools/needle-component-compiler 3.0.19 → 3.0.20

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,11 @@ 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.20] - 2026-05-05
8
+ ### Changed
9
+ - Fields without `@serializable()` decorator (or `//@serializable` / `//@serializeField` comment directive) are no longer emitted in C# or Blender output. This prevents unresolvable types (e.g. `article: Article | undefined = undefined`) from producing compile errors in generated stubs.
10
+ - Blender: component reference types now emit concrete type names (e.g. `Camera`, `Rigidbody`, `AudioSource`) instead of generic `comp`. Added support for: Animation, Animator, Camera, Light, Rigidbody, Renderer, Canvas, VideoPlayer, AudioSource, SphereCollider, MeshCollider, BoxCollider, PlayableDirector, DragControls, Button, Text.
11
+
7
12
  ## [3.0.19] - 2026-04-28
8
13
  ### Fixed
9
14
  - C#: skip `= undefined` initializers — `undefined` is not valid in C#
@@ -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
@@ -151,7 +151,10 @@ var Compiler = /** @class */ (function () {
151
151
  // If the property has a @serializable() decorator, ensure it's in the comments
152
152
  // so the writer emits private/protected fields with [SerializeField]
153
153
  var hasSerialized = this.hasSerializableDecorator(node);
154
- if (hasSerialized && !comments.some(function (c) { return c.startsWith("@serializable"); })) {
154
+ var hasSerializedComment = comments.some(function (c) { return c.startsWith("@serializable") || c.startsWith("@serializeField"); });
155
+ if (!hasSerialized && !hasSerializedComment)
156
+ return; // only emit fields marked with @serializable() or //@serializable or //@serializeField
157
+ if (!comments.some(function (c) { return c.startsWith("@serializable"); })) {
155
158
  comments.push("@serializable");
156
159
  }
157
160
  var flags = [];
@@ -429,7 +432,7 @@ var Compiler = /** @class */ (function () {
429
432
  return this.resolveTypeFromString(typeNode.getText(), writer);
430
433
  };
431
434
  Compiler.prototype.resolveTypeFromString = function (type, writer) {
432
- var resolved = writer.resolveCSharpTypeName(type);
435
+ var resolved = writer.resolveNeedleTypeName(type);
433
436
  return resolved || type;
434
437
  };
435
438
  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) {
@@ -390,7 +390,7 @@ var CSharpWriter = /** @class */ (function (_super) {
390
390
  if (!match)
391
391
  return expr;
392
392
  var typeName = match[1], argsStr = match[2];
393
- 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;
394
394
  // Convert numeric literals to float
395
395
  var csharpArgs = argsStr.replace(/(\d+\.?\d*)/g, function (n) {
396
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.19",
3
+ "version": "3.0.20",
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",