@needle-tools/needle-component-compiler 1.3.0 → 1.6.0
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 +11 -0
- package/Readme.md +2 -1
- package/package.json +1 -1
- package/src/component-compiler.js +71 -10
- package/src/component-compiler.ts +77 -15
- package/src/test.ts +16 -9
- package/dist/GltfExport.cs +0 -11
- package/dist/GltfExportBox.cs +0 -11
- package/dist/MaterialColorHandler.cs +0 -11
- package/dist/MyArray.cs +0 -8
- package/dist/MyClass.cs +0 -10
- package/dist/MyClassWithAFloat.cs +0 -10
- package/dist/NavComponent.cs +0 -13
- package/dist/NavigationManager.cs +0 -13
- package/dist/OtherClass.cs +0 -10
- package/dist/PointOfInterest.cs +0 -14
- package/dist/PrivateSerializedField.cs +0 -9
- package/dist/Test.cs +0 -8
package/Changelog.md
CHANGED
|
@@ -4,6 +4,17 @@ 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
|
+
## [1.6.0] - 2022-07-10
|
|
8
|
+
- add using ``types.json`` json file that will be generated from Unity
|
|
9
|
+
- change ``@type`` annotiation to only work without braces to be consistent
|
|
10
|
+
|
|
11
|
+
## [1.5.0] - 2022-07-07
|
|
12
|
+
- change ``@type`` annotation to work with and without braces (e.g. ``@type My.Type`` or ``@type (My.Type)``)
|
|
13
|
+
|
|
14
|
+
## [1.4.0] - 2022-07-06
|
|
15
|
+
- add CODEGEN_START and END sections to allow adding code before or after a generated componnet
|
|
16
|
+
- add ``@ifdef`` to ifdef fields
|
|
17
|
+
|
|
7
18
|
## [1.3.0] - 2022-06-27
|
|
8
19
|
- add support for typescript namespace
|
|
9
20
|
|
package/Readme.md
CHANGED
|
@@ -11,4 +11,5 @@ Please run ``npm install`` first before using.
|
|
|
11
11
|
- ``@dont-generate-component`` add before class to skip generating a component
|
|
12
12
|
- ``@generate-component`` to enforce generating a component (not required)
|
|
13
13
|
- ``@serializeField`` field decorator, similar to ``[SerializeField]``
|
|
14
|
-
- ``@type
|
|
14
|
+
- ``@type MyNamespace.MyType`` decorator for fields or classes, specifiy C# type of field or class
|
|
15
|
+
- ``@ifdef MY_IFDEF`` field decorator only at the moment
|
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ exports.run = void 0;
|
|
|
4
4
|
var fs_1 = require("fs");
|
|
5
5
|
var ts = require("typescript");
|
|
6
6
|
var fs = require("fs");
|
|
7
|
+
var path = require("path");
|
|
7
8
|
var types = require("./types");
|
|
8
9
|
var dict = types.dict;
|
|
9
10
|
// add either of these two comments above a class to enforce code gen or disable it for the next class
|
|
@@ -11,7 +12,11 @@ var exportNextClassCommand = "@generate-component";
|
|
|
11
12
|
var dontExportNextClassCommand = "@dont-generate-component";
|
|
12
13
|
// add above field to add [SerializeField] attribute
|
|
13
14
|
var serializeCommand = "@serializeField";
|
|
14
|
-
|
|
15
|
+
// https://regex101.com/r/ltpcKT/1
|
|
16
|
+
var typePattern = new RegExp("@type ?(<type>[\w\.]+)");
|
|
17
|
+
var ifdefPattern = new RegExp("@ifdef ?(?<ifdef>.+)");
|
|
18
|
+
var CODEGEN_MARKER_START = "// NEEDLE_CODEGEN_START";
|
|
19
|
+
var CODEGEN_MARKER_END = "// NEEDLE_CODEGEN_END";
|
|
15
20
|
// will be set to true when e.g. a comment for export is found
|
|
16
21
|
var exportNextClass = false;
|
|
17
22
|
var dontExportNextClass = false;
|
|
@@ -20,6 +25,24 @@ function resetExportNextClass() {
|
|
|
20
25
|
dontExportNextClass = false;
|
|
21
26
|
exportNextClass = false;
|
|
22
27
|
}
|
|
28
|
+
var typesFileContent = undefined;
|
|
29
|
+
function tryGetKnownType(str) {
|
|
30
|
+
if (typesFileContent === undefined) {
|
|
31
|
+
typesFileContent = null;
|
|
32
|
+
var filePath = path.dirname(__dirname) + "/src/types.json";
|
|
33
|
+
if (fs.existsSync(filePath)) {
|
|
34
|
+
console.log("Reading types file");
|
|
35
|
+
var content = fs.readFileSync(filePath, "utf8");
|
|
36
|
+
typesFileContent = JSON.parse(content);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (typesFileContent) {
|
|
40
|
+
var fullType = typesFileContent[str];
|
|
41
|
+
console.log(fullType);
|
|
42
|
+
return fullType;
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
23
46
|
// https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API
|
|
24
47
|
// const exportDir = "../dist";
|
|
25
48
|
var commentStarts = [];
|
|
@@ -51,10 +74,8 @@ var ExportContext = /** @class */ (function () {
|
|
|
51
74
|
if (this.textBuffer.length <= 0)
|
|
52
75
|
return;
|
|
53
76
|
var dir = this.outputDir + "/";
|
|
54
|
-
if (!fs.existsSync(dir)) {
|
|
55
|
-
fs.mkdirSync(dir);
|
|
56
|
-
}
|
|
57
77
|
var path = dir + this.fileName;
|
|
78
|
+
this.replaceGeneratedCodeSection(path);
|
|
58
79
|
console.log("Write to " + path);
|
|
59
80
|
fs.writeFileSync(path, this.textBuffer);
|
|
60
81
|
this.reset();
|
|
@@ -63,10 +84,25 @@ var ExportContext = /** @class */ (function () {
|
|
|
63
84
|
this.textBuffer = "";
|
|
64
85
|
this.classEnd = -1;
|
|
65
86
|
};
|
|
87
|
+
ExportContext.prototype.replaceGeneratedCodeSection = function (path) {
|
|
88
|
+
this.textBuffer = CODEGEN_MARKER_START + "\n" + this.textBuffer + "\n" + CODEGEN_MARKER_END;
|
|
89
|
+
if (fs.existsSync(path)) {
|
|
90
|
+
var existing = fs.readFileSync(path, "utf8");
|
|
91
|
+
var regex = new RegExp("(?<before>.*?)\/\/ ?NEEDLE_CODEGEN_START.+\/\/ ?NEEDLE_CODEGEN_END(?<after>.*)", "s");
|
|
92
|
+
var matches = regex.exec(existing);
|
|
93
|
+
if (matches === null || matches === void 0 ? void 0 : matches.groups) {
|
|
94
|
+
console.log("Found codegen sections");
|
|
95
|
+
var before = matches.groups.before;
|
|
96
|
+
var after = matches.groups.after;
|
|
97
|
+
this.textBuffer = before + this.textBuffer + after;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
66
101
|
return ExportContext;
|
|
67
102
|
}());
|
|
68
103
|
var contexts = [];
|
|
69
104
|
var lastTypeFound = null;
|
|
105
|
+
var ifdefSections = [];
|
|
70
106
|
function run(program, outputDir, sourceFile) {
|
|
71
107
|
if (!fs.existsSync(outputDir)) {
|
|
72
108
|
console.error("Output directory does not exist: \"" + outputDir + "\"");
|
|
@@ -114,15 +150,21 @@ function run(program, outputDir, sourceFile) {
|
|
|
114
150
|
exportNextClass = true;
|
|
115
151
|
if (comment.includes(dontExportNextClassCommand))
|
|
116
152
|
dontExportNextClass = true;
|
|
117
|
-
var
|
|
118
|
-
if (
|
|
153
|
+
var typeMatch = typePattern.exec(comment);
|
|
154
|
+
if (typeMatch && typeMatch.groups) {
|
|
119
155
|
// for some reason our regex does also match surrounding ( ) even tho: https://regex101.com/r/PoWK6V/1
|
|
120
156
|
// so we remove them
|
|
121
|
-
var type =
|
|
157
|
+
var type = typeMatch.groups["type"];
|
|
122
158
|
type = type.replace(/\(/, "").replace(/\)/, "");
|
|
123
159
|
console.log("found type: ", type);
|
|
124
160
|
lastTypeFound = type;
|
|
125
161
|
}
|
|
162
|
+
var ifdefMatch = ifdefPattern.exec(comment);
|
|
163
|
+
if (ifdefMatch && ifdefMatch.groups) {
|
|
164
|
+
var ifdef = ifdefMatch.groups["ifdef"];
|
|
165
|
+
if (ifdef)
|
|
166
|
+
ifdefSections.push(ifdef);
|
|
167
|
+
}
|
|
126
168
|
}
|
|
127
169
|
}
|
|
128
170
|
switch (node.kind) {
|
|
@@ -217,14 +259,23 @@ function run(program, outputDir, sourceFile) {
|
|
|
217
259
|
console.log("SERIALIZE");
|
|
218
260
|
context.appendLine("[UnityEngine.SerializeField]");
|
|
219
261
|
}
|
|
262
|
+
var requireEndIf = false;
|
|
263
|
+
if (ifdefSections.length > 0) {
|
|
264
|
+
requireEndIf = true;
|
|
265
|
+
context.appendLine("#ifdef " + ifdefSections.pop());
|
|
266
|
+
}
|
|
220
267
|
context.append(prefix + visibility + " " + typeString + " " + varName + assignment + ";\n");
|
|
221
268
|
lastTypeFound = null;
|
|
269
|
+
if (requireEndIf) {
|
|
270
|
+
context.appendLine("#endif");
|
|
271
|
+
}
|
|
222
272
|
break;
|
|
223
273
|
case ts.SyntaxKind.ClassDeclaration:
|
|
224
274
|
serializeField = false;
|
|
225
275
|
var dec = node;
|
|
226
276
|
// a class must inherit a component
|
|
227
|
-
|
|
277
|
+
var inheritsComponent = testInheritsComponent(node);
|
|
278
|
+
if (!dontExportNextClass && (lastTypeFound || exportNextClass || inheritsComponent)) {
|
|
228
279
|
resetExportNextClass();
|
|
229
280
|
var name_2 = (_d = dec.name) === null || _d === void 0 ? void 0 : _d.escapedText;
|
|
230
281
|
console.log("Found class: ", name_2);
|
|
@@ -240,6 +291,8 @@ function run(program, outputDir, sourceFile) {
|
|
|
240
291
|
newContext.indentLevel += 1;
|
|
241
292
|
// newContext.appendLine("// source: " + path.resolve(sourceFile.fileName));
|
|
242
293
|
var typeName = lastTypeFound !== null && lastTypeFound !== void 0 ? lastTypeFound : "UnityEngine.MonoBehaviour";
|
|
294
|
+
if (typeof inheritsComponent === "string")
|
|
295
|
+
typeName = inheritsComponent;
|
|
243
296
|
console.log(name_2 + " inherits " + typeName);
|
|
244
297
|
newContext.appendLine("public partial class " + name_2 + " : " + typeName);
|
|
245
298
|
newContext.appendLine("{");
|
|
@@ -263,10 +316,15 @@ function run(program, outputDir, sourceFile) {
|
|
|
263
316
|
var type = _c[_b];
|
|
264
317
|
// const symbol = program.getTypeChecker().getSymbolAtLocation(type.expression);
|
|
265
318
|
// console.log(symbol);
|
|
266
|
-
|
|
319
|
+
var text = type.expression.getText();
|
|
320
|
+
if (text === "Component")
|
|
267
321
|
return true;
|
|
268
|
-
if (
|
|
322
|
+
if (text === "Behaviour")
|
|
269
323
|
return true;
|
|
324
|
+
console.log(text);
|
|
325
|
+
var known = tryGetKnownType(text);
|
|
326
|
+
if (known)
|
|
327
|
+
return known;
|
|
270
328
|
}
|
|
271
329
|
}
|
|
272
330
|
}
|
|
@@ -331,6 +389,9 @@ function run(program, outputDir, sourceFile) {
|
|
|
331
389
|
// console.log(node);
|
|
332
390
|
return res;
|
|
333
391
|
}
|
|
392
|
+
var knownType = tryGetKnownType(typeName);
|
|
393
|
+
if (knownType)
|
|
394
|
+
return knownType;
|
|
334
395
|
// console.log("Unknown type: " + typeName);
|
|
335
396
|
switch (node.kind) {
|
|
336
397
|
case ts.SyntaxKind.SyntaxList:
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { readFileSync } from "fs";
|
|
2
2
|
import * as ts from "typescript";
|
|
3
3
|
import * as fs from "fs";
|
|
4
|
-
import * as path from
|
|
4
|
+
import * as path from 'path';
|
|
5
5
|
|
|
6
6
|
import * as types from "./types";
|
|
7
|
-
import { traceDeprecation } from "process";
|
|
8
7
|
const dict = types.dict;
|
|
9
8
|
|
|
10
9
|
// add either of these two comments above a class to enforce code gen or disable it for the next class
|
|
@@ -12,7 +11,12 @@ const exportNextClassCommand = "@generate-component";
|
|
|
12
11
|
const dontExportNextClassCommand = "@dont-generate-component";
|
|
13
12
|
// add above field to add [SerializeField] attribute
|
|
14
13
|
const serializeCommand = "@serializeField";
|
|
15
|
-
|
|
14
|
+
// https://regex101.com/r/ltpcKT/1
|
|
15
|
+
const typePattern = new RegExp("@type ?(<type>[\w\.]+)");
|
|
16
|
+
const ifdefPattern = new RegExp("@ifdef ?(?<ifdef>.+)")
|
|
17
|
+
|
|
18
|
+
const CODEGEN_MARKER_START = "// NEEDLE_CODEGEN_START";
|
|
19
|
+
const CODEGEN_MARKER_END = "// NEEDLE_CODEGEN_END";
|
|
16
20
|
|
|
17
21
|
// will be set to true when e.g. a comment for export is found
|
|
18
22
|
let exportNextClass: boolean = false;
|
|
@@ -24,6 +28,27 @@ function resetExportNextClass() {
|
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
|
|
31
|
+
let typesFileContent: object | undefined | null = undefined;
|
|
32
|
+
function tryGetKnownType(str: string): string | null {
|
|
33
|
+
|
|
34
|
+
if (typesFileContent === undefined) {
|
|
35
|
+
typesFileContent = null;
|
|
36
|
+
const filePath = path.dirname(__dirname) + "/src/types.json";
|
|
37
|
+
if (fs.existsSync(filePath)) {
|
|
38
|
+
console.log("Reading types file");
|
|
39
|
+
const content = fs.readFileSync(filePath, "utf8");
|
|
40
|
+
typesFileContent = JSON.parse(content);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (typesFileContent) {
|
|
45
|
+
const fullType = typesFileContent[str];
|
|
46
|
+
console.log(fullType);
|
|
47
|
+
return fullType;
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
27
52
|
// https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API
|
|
28
53
|
|
|
29
54
|
// const exportDir = "../dist";
|
|
@@ -65,10 +90,8 @@ class ExportContext {
|
|
|
65
90
|
flush() {
|
|
66
91
|
if (this.textBuffer.length <= 0) return;
|
|
67
92
|
const dir = this.outputDir + "/";
|
|
68
|
-
if (!fs.existsSync(dir)) {
|
|
69
|
-
fs.mkdirSync(dir);
|
|
70
|
-
}
|
|
71
93
|
const path = dir + this.fileName;
|
|
94
|
+
this.replaceGeneratedCodeSection(path);
|
|
72
95
|
console.log("Write to " + path);
|
|
73
96
|
fs.writeFileSync(path, this.textBuffer);
|
|
74
97
|
this.reset();
|
|
@@ -78,11 +101,27 @@ class ExportContext {
|
|
|
78
101
|
this.textBuffer = "";
|
|
79
102
|
this.classEnd = -1;
|
|
80
103
|
}
|
|
104
|
+
|
|
105
|
+
private replaceGeneratedCodeSection(path: string) {
|
|
106
|
+
this.textBuffer = CODEGEN_MARKER_START + "\n" + this.textBuffer + "\n" + CODEGEN_MARKER_END;
|
|
107
|
+
if (fs.existsSync(path)) {
|
|
108
|
+
const existing = fs.readFileSync(path, "utf8");
|
|
109
|
+
const regex = new RegExp("(?<before>.*?)\/\/ ?NEEDLE_CODEGEN_START.+\/\/ ?NEEDLE_CODEGEN_END(?<after>.*)", "s");
|
|
110
|
+
const matches = regex.exec(existing);
|
|
111
|
+
if (matches?.groups) {
|
|
112
|
+
console.log("Found codegen sections")
|
|
113
|
+
const before = matches.groups.before;
|
|
114
|
+
const after = matches.groups.after;
|
|
115
|
+
this.textBuffer = before + this.textBuffer + after;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
81
119
|
}
|
|
82
120
|
|
|
83
121
|
const contexts: ExportContext[] = [];
|
|
84
122
|
|
|
85
123
|
let lastTypeFound: string | null = null;
|
|
124
|
+
let ifdefSections: string[] = [];
|
|
86
125
|
|
|
87
126
|
export function run(program: ts.Program, outputDir: string, sourceFile: ts.SourceFile) {
|
|
88
127
|
|
|
@@ -136,15 +175,22 @@ export function run(program: ts.Program, outputDir: string, sourceFile: ts.Sourc
|
|
|
136
175
|
exportNextClass = true;
|
|
137
176
|
if (comment.includes(dontExportNextClassCommand))
|
|
138
177
|
dontExportNextClass = true;
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
178
|
+
const typeMatch = typePattern.exec(comment);
|
|
179
|
+
if (typeMatch && typeMatch.groups) {
|
|
141
180
|
// for some reason our regex does also match surrounding ( ) even tho: https://regex101.com/r/PoWK6V/1
|
|
142
181
|
// so we remove them
|
|
143
|
-
let type =
|
|
182
|
+
let type = typeMatch.groups["type"];
|
|
144
183
|
type = type.replace(/\(/, "").replace(/\)/, "");
|
|
145
184
|
console.log("found type: ", type);
|
|
146
185
|
lastTypeFound = type;
|
|
147
186
|
}
|
|
187
|
+
|
|
188
|
+
const ifdefMatch = ifdefPattern.exec(comment);
|
|
189
|
+
if (ifdefMatch && ifdefMatch.groups) {
|
|
190
|
+
const ifdef = ifdefMatch.groups["ifdef"];
|
|
191
|
+
if (ifdef)
|
|
192
|
+
ifdefSections.push(ifdef);
|
|
193
|
+
}
|
|
148
194
|
}
|
|
149
195
|
}
|
|
150
196
|
|
|
@@ -234,15 +280,24 @@ export function run(program: ts.Program, outputDir: string, sourceFile: ts.Sourc
|
|
|
234
280
|
console.log("SERIALIZE");
|
|
235
281
|
context.appendLine("[UnityEngine.SerializeField]");
|
|
236
282
|
}
|
|
283
|
+
let requireEndIf = false;
|
|
284
|
+
if (ifdefSections.length > 0) {
|
|
285
|
+
requireEndIf = true;
|
|
286
|
+
context.appendLine("#ifdef " + ifdefSections.pop());
|
|
287
|
+
}
|
|
237
288
|
context.append(prefix + visibility + " " + typeString + " " + varName + assignment + ";\n");
|
|
238
289
|
lastTypeFound = null;
|
|
290
|
+
if (requireEndIf) {
|
|
291
|
+
context.appendLine("#endif");
|
|
292
|
+
}
|
|
239
293
|
break;
|
|
240
294
|
|
|
241
295
|
case ts.SyntaxKind.ClassDeclaration:
|
|
242
296
|
serializeField = false;
|
|
243
297
|
const dec = <ts.ClassDeclaration>node;
|
|
244
298
|
// a class must inherit a component
|
|
245
|
-
|
|
299
|
+
const inheritsComponent = testInheritsComponent(node);
|
|
300
|
+
if (!dontExportNextClass && (lastTypeFound || exportNextClass || inheritsComponent)) {
|
|
246
301
|
resetExportNextClass();
|
|
247
302
|
const name = dec.name?.escapedText;
|
|
248
303
|
console.log("Found class: ", name);
|
|
@@ -257,7 +312,8 @@ export function run(program: ts.Program, outputDir: string, sourceFile: ts.Sourc
|
|
|
257
312
|
newContext.appendLine("{");
|
|
258
313
|
newContext.indentLevel += 1;
|
|
259
314
|
// newContext.appendLine("// source: " + path.resolve(sourceFile.fileName));
|
|
260
|
-
|
|
315
|
+
let typeName = lastTypeFound ?? "UnityEngine.MonoBehaviour";
|
|
316
|
+
if (typeof inheritsComponent === "string") typeName = inheritsComponent;
|
|
261
317
|
console.log(name + " inherits " + typeName);
|
|
262
318
|
newContext.appendLine("public partial class " + name + " : " + typeName);
|
|
263
319
|
newContext.appendLine("{");
|
|
@@ -269,7 +325,7 @@ export function run(program: ts.Program, outputDir: string, sourceFile: ts.Sourc
|
|
|
269
325
|
break;
|
|
270
326
|
}
|
|
271
327
|
|
|
272
|
-
function testInheritsComponent(node: ts.Node): boolean {
|
|
328
|
+
function testInheritsComponent(node: ts.Node): boolean | string {
|
|
273
329
|
switch (node.kind) {
|
|
274
330
|
case ts.SyntaxKind.ClassDeclaration:
|
|
275
331
|
const dec = <ts.ClassDeclaration>node;
|
|
@@ -279,8 +335,11 @@ export function run(program: ts.Program, outputDir: string, sourceFile: ts.Sourc
|
|
|
279
335
|
for (const type of h.types) {
|
|
280
336
|
// const symbol = program.getTypeChecker().getSymbolAtLocation(type.expression);
|
|
281
337
|
// console.log(symbol);
|
|
282
|
-
|
|
283
|
-
if (
|
|
338
|
+
const text = type.expression.getText();
|
|
339
|
+
if (text === "Component") return true;
|
|
340
|
+
if (text === "Behaviour") return true;
|
|
341
|
+
const known = tryGetKnownType(text);
|
|
342
|
+
if (known) return known;
|
|
284
343
|
}
|
|
285
344
|
}
|
|
286
345
|
}
|
|
@@ -313,7 +372,7 @@ export function run(program: ts.Program, outputDir: string, sourceFile: ts.Sourc
|
|
|
313
372
|
case ts.SyntaxKind.Identifier:
|
|
314
373
|
const id = ch as ts.Identifier;
|
|
315
374
|
if (id.text) {
|
|
316
|
-
if(!namespace) namespace = "";
|
|
375
|
+
if (!namespace) namespace = "";
|
|
317
376
|
namespace = id.text + (namespace ? "." : "") + namespace;
|
|
318
377
|
}
|
|
319
378
|
break;
|
|
@@ -347,6 +406,9 @@ export function run(program: ts.Program, outputDir: string, sourceFile: ts.Sourc
|
|
|
347
406
|
// console.log(node);
|
|
348
407
|
return res;
|
|
349
408
|
}
|
|
409
|
+
const knownType = tryGetKnownType(typeName);
|
|
410
|
+
if (knownType)
|
|
411
|
+
return knownType;
|
|
350
412
|
// console.log("Unknown type: " + typeName);
|
|
351
413
|
|
|
352
414
|
switch (node.kind) {
|
package/src/test.ts
CHANGED
|
@@ -2,19 +2,26 @@
|
|
|
2
2
|
// import { Behaviour } from "needle.tiny.engine/engine-components/Component";
|
|
3
3
|
// import { RoomEntity } from "./Room";
|
|
4
4
|
|
|
5
|
+
import { Behaviour } from "needle.tiny.engine/engine-components/Component";
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
export class MyNewScript extends DriveClient
|
|
7
8
|
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
texture : RenderTexture;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// namespace Hello.World
|
|
13
|
+
// {
|
|
14
|
+
// namespace Deep {
|
|
15
|
+
// export class MyClass extends Behaviour {
|
|
16
|
+
// //@ifdef TEST
|
|
17
|
+
// public myFloat :number;
|
|
18
|
+
// }
|
|
19
|
+
// }
|
|
20
|
+
// }
|
|
14
21
|
|
|
15
|
-
class OtherClass extends Behaviour {
|
|
22
|
+
// class OtherClass extends Behaviour {
|
|
16
23
|
|
|
17
|
-
}
|
|
24
|
+
// }
|
|
18
25
|
|
|
19
26
|
//@type (RoomEntity)
|
|
20
27
|
// export class NavigationManager extends RoomEntity {
|
package/dist/GltfExport.cs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// auto generated code - do not edit
|
|
2
|
-
namespace Needle.Typescript.GeneratedComponents
|
|
3
|
-
{
|
|
4
|
-
// source: C:\git\needle-tiny-playground\modules\needle-tiny\component-compiler\src\test.ts
|
|
5
|
-
public class GltfExport : UnityEngine.MonoBehaviour
|
|
6
|
-
{
|
|
7
|
-
public bool @binary = true;
|
|
8
|
-
[UnityEngine.ContextMenu("enable this")]
|
|
9
|
-
public void test(){}
|
|
10
|
-
}
|
|
11
|
-
}
|
package/dist/GltfExportBox.cs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// auto generated code - do not edit
|
|
2
|
-
namespace Needle.Typescript.GeneratedComponents
|
|
3
|
-
{
|
|
4
|
-
// source: C:\git\needle-tiny-playground\modules\needle-tiny\component-compiler\src\test.ts
|
|
5
|
-
public class GltfExportBox : UnityEngine.MonoBehaviour
|
|
6
|
-
{
|
|
7
|
-
public UnityEngine.Transform @sceneRoot;
|
|
8
|
-
public void start(){}
|
|
9
|
-
public void updateGltfBox(){}
|
|
10
|
-
}
|
|
11
|
-
}
|
package/dist/MyArray.cs
DELETED
package/dist/MyClass.cs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// auto generated code - do not edit
|
|
2
|
-
namespace Needle.Typescript.GeneratedComponents
|
|
3
|
-
{
|
|
4
|
-
// source: C:\git\needle-tiny-playground\modules\needle-tiny\component-compiler\src\test.ts
|
|
5
|
-
public class MyClassWithAFloat : UnityEngine.MonoBehaviour
|
|
6
|
-
{
|
|
7
|
-
public float @myfloat = 0.5f;
|
|
8
|
-
private string @myString;
|
|
9
|
-
}
|
|
10
|
-
}
|
package/dist/NavComponent.cs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// auto generated code - do not edit directly
|
|
2
|
-
|
|
3
|
-
#pragma warning disable
|
|
4
|
-
|
|
5
|
-
namespace Needle.Typescript.GeneratedComponents
|
|
6
|
-
{
|
|
7
|
-
public partial class NavComponent : UnityEngine.MonoBehaviour
|
|
8
|
-
{
|
|
9
|
-
public void next(){}
|
|
10
|
-
public void prev(){}
|
|
11
|
-
public void isAtEnd(){}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// auto generated code - do not edit directly
|
|
2
|
-
|
|
3
|
-
#pragma warning disable
|
|
4
|
-
|
|
5
|
-
namespace Needle.Typescript.GeneratedComponents
|
|
6
|
-
{
|
|
7
|
-
public partial class NavigationManager : RoomEntity
|
|
8
|
-
{
|
|
9
|
-
public float @fl = 1f;
|
|
10
|
-
public void nav_forward(){}
|
|
11
|
-
public void nav_backward(){}
|
|
12
|
-
}
|
|
13
|
-
}
|
package/dist/OtherClass.cs
DELETED
package/dist/PointOfInterest.cs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// auto generated code - do not edit directly
|
|
2
|
-
|
|
3
|
-
#pragma warning disable
|
|
4
|
-
|
|
5
|
-
namespace Needle.Typescript.GeneratedComponents
|
|
6
|
-
{
|
|
7
|
-
public partial class PointOfInterest : UnityEngine.MonoBehaviour
|
|
8
|
-
{
|
|
9
|
-
public float @myVal = 12f;
|
|
10
|
-
public void myFunction(){}
|
|
11
|
-
public UnityEngine.Camera @view;
|
|
12
|
-
public string @test = "123";
|
|
13
|
-
}
|
|
14
|
-
}
|
package/dist/Test.cs
DELETED