@needle-tools/needle-component-compiler 2.2.0-pre.1 → 2.4.0-pre
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 +9 -0
- package/Readme.md +4 -1
- package/package.json +9 -8
- package/src/base-compiler.js +74 -15
- package/src/blender-compiler.js +27 -17
- package/src/csharp-compiler.js +58 -0
- package/src/react-three-fiber-compiler.js +34 -0
- package/src/test.js +52 -25
- package/src/watcher.js +2 -1
- package/test/component.basic.test.js +1 -1
- package/test/component.methods.test.js +1 -1
- package/test/component.nonserialized.test.js +1 -1
- package/test/component.primitives.test.js +1 -1
- package/test/helpers.js +1 -1
- package/tsconfig.json +0 -9
- package/workspace.code-workspace +0 -12
package/Changelog.md
CHANGED
|
@@ -4,6 +4,15 @@ 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
|
+
## [2.4.0-pre] - 2022-11-22
|
|
8
|
+
# Blender compiler
|
|
9
|
+
- Add: emit types from declared class implementing `IComponent` e.g. ``declare class MyComp implements IComponent``
|
|
10
|
+
|
|
11
|
+
## [2.3.0-pre] - 2022-11-22
|
|
12
|
+
# Blender compiler
|
|
13
|
+
- Add emit array
|
|
14
|
+
- Add emit types by class name if unknown
|
|
15
|
+
|
|
7
16
|
## [2.2.0-pre.1] - 2022-11-13
|
|
8
17
|
- Add: watcher now also generates the register_types file
|
|
9
18
|
- Add: deleting code files now also deletes the generated files and reports it
|
package/Readme.md
CHANGED
|
@@ -13,4 +13,7 @@ Please run ``npm install`` first before using.
|
|
|
13
13
|
- ``@serializeField`` field decorator, similar to ``[SerializeField]`` in Unity
|
|
14
14
|
- ``@nonSerialized`` field or method decorator to skip generating c# code for a field or a method, similar to ``[NonSerialized]`` in Unity
|
|
15
15
|
- ``@type MyNamespace.MyType`` decorator for fields or classes, specifiy C# type of field or class
|
|
16
|
-
- ``@ifdef MY_IFDEF`` field decorator only at the moment
|
|
16
|
+
- ``@ifdef MY_IFDEF`` field decorator only at the moment
|
|
17
|
+
|
|
18
|
+
### Test
|
|
19
|
+
- Run single test: `` npm run test:single -- -r ts-node/register "./test/blender/blender.from_typedef.test.ts"``
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/needle-component-compiler",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0-pre",
|
|
4
4
|
"description": "Compile mock unity components from typescript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"tsc": "tsc",
|
|
8
8
|
"dev": "npm-watch compile || exit 1",
|
|
9
9
|
"compile": "tsc",
|
|
10
|
-
"test": "
|
|
10
|
+
"test" : "npm run test:csharp & npm run test:blender",
|
|
11
|
+
"test:csharp": "mocha -r ts-node/register test/csharp/**.test.ts",
|
|
12
|
+
"test:blender": "mocha -r ts-node/register test/blender/**.test.ts",
|
|
13
|
+
"test:single": "mocha"
|
|
11
14
|
},
|
|
12
15
|
"dependencies": {
|
|
13
16
|
"chokidar": "^3.5.3",
|
|
@@ -25,11 +28,9 @@
|
|
|
25
28
|
"watch": {
|
|
26
29
|
"compile": {
|
|
27
30
|
"patterns": [
|
|
28
|
-
"src
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"src/watcher.ts",
|
|
32
|
-
"src/register-types.ts"
|
|
31
|
+
"src/**/*.ts",
|
|
32
|
+
"test/*/*.ts",
|
|
33
|
+
"test/*.ts"
|
|
33
34
|
],
|
|
34
35
|
"ignore": "src/test.ts",
|
|
35
36
|
"extensions": "ts",
|
|
@@ -45,4 +46,4 @@
|
|
|
45
46
|
"type": "git",
|
|
46
47
|
"url": "git+https://github.com/needle-tools/needle-tiny-component-compiler.git"
|
|
47
48
|
}
|
|
48
|
-
}
|
|
49
|
+
}
|
package/src/base-compiler.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Compiler = exports.runFromFile = exports.handleDeletedFile = exports.CodeTextWriter = exports.Visibility = void 0;
|
|
3
|
+
exports.Compiler = exports.runFromFile = exports.handleDeletedFile = exports.CodeTextWriter = exports.MemorySink = exports.FileSink = exports.Visibility = void 0;
|
|
4
4
|
var fs_1 = require("fs");
|
|
5
5
|
var ts = require("typescript");
|
|
6
6
|
var fs = require("fs");
|
|
@@ -11,6 +11,36 @@ var Visibility;
|
|
|
11
11
|
Visibility[Visibility["Protected"] = 1] = "Protected";
|
|
12
12
|
Visibility[Visibility["Private"] = 2] = "Private";
|
|
13
13
|
})(Visibility = exports.Visibility || (exports.Visibility = {}));
|
|
14
|
+
var FileSink = /** @class */ (function () {
|
|
15
|
+
function FileSink(directory) {
|
|
16
|
+
this.directory = directory;
|
|
17
|
+
}
|
|
18
|
+
FileSink.prototype.flush = function (id, str) {
|
|
19
|
+
if (!fs.existsSync(this.directory)) {
|
|
20
|
+
fs.mkdirSync(this.directory, { recursive: true });
|
|
21
|
+
}
|
|
22
|
+
console.log("Writing " + id + " to " + this.directory);
|
|
23
|
+
var fullPath = this.directory + "/" + id;
|
|
24
|
+
fs.writeFileSync(fullPath, str);
|
|
25
|
+
return fs.realpathSync(fullPath);
|
|
26
|
+
};
|
|
27
|
+
return FileSink;
|
|
28
|
+
}());
|
|
29
|
+
exports.FileSink = FileSink;
|
|
30
|
+
var MemorySink = /** @class */ (function () {
|
|
31
|
+
function MemorySink() {
|
|
32
|
+
this.results = [];
|
|
33
|
+
}
|
|
34
|
+
MemorySink.prototype.clear = function () {
|
|
35
|
+
this.results.length = 0;
|
|
36
|
+
};
|
|
37
|
+
MemorySink.prototype.flush = function (id, str) {
|
|
38
|
+
this.results.push(str);
|
|
39
|
+
return "";
|
|
40
|
+
};
|
|
41
|
+
return MemorySink;
|
|
42
|
+
}());
|
|
43
|
+
exports.MemorySink = MemorySink;
|
|
14
44
|
var CodeTextWriter = /** @class */ (function () {
|
|
15
45
|
function CodeTextWriter() {
|
|
16
46
|
this.indent = 0;
|
|
@@ -69,18 +99,20 @@ var CodeTextWriter = /** @class */ (function () {
|
|
|
69
99
|
// }
|
|
70
100
|
// endArray() {
|
|
71
101
|
// }
|
|
72
|
-
CodeTextWriter.prototype.flush = function (
|
|
73
|
-
|
|
74
|
-
return;
|
|
75
|
-
if (!fs.existsSync(directory)) {
|
|
76
|
-
fs.mkdirSync(directory, { recursive: true });
|
|
77
|
-
}
|
|
78
|
-
console.log("Writing " + filename + " to " + directory);
|
|
79
|
-
var content = this.toString();
|
|
102
|
+
CodeTextWriter.prototype.flush = function () {
|
|
103
|
+
var str = this.toString();
|
|
80
104
|
this.lines.length = 0;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
105
|
+
return str;
|
|
106
|
+
// if (this.lines.length === 0) return;
|
|
107
|
+
// if (!fs.existsSync(directory)) {
|
|
108
|
+
// fs.mkdirSync(directory, { recursive: true });
|
|
109
|
+
// }
|
|
110
|
+
// console.log("Writing " + filename + " to " + directory);
|
|
111
|
+
// const content = this.toString();
|
|
112
|
+
// this.lines.length = 0;
|
|
113
|
+
// const fullPath = directory + "/" + filename;
|
|
114
|
+
// fs.writeFileSync(fullPath, content);
|
|
115
|
+
// return fs.realpathSync(fullPath);
|
|
84
116
|
};
|
|
85
117
|
CodeTextWriter.prototype.clear = function () {
|
|
86
118
|
this.lines.length = 0;
|
|
@@ -172,9 +204,22 @@ var Compiler = /** @class */ (function () {
|
|
|
172
204
|
Compiler.prototype.visitClassDeclaration = function (filePath, node, writer) {
|
|
173
205
|
var _this = this;
|
|
174
206
|
var name = node.name.text;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
207
|
+
// get all parent types
|
|
208
|
+
var baseTypes = [];
|
|
209
|
+
if (node.heritageClauses) {
|
|
210
|
+
for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) {
|
|
211
|
+
var clause = _a[_i];
|
|
212
|
+
if (clause.token == ts.SyntaxKind.ExtendsKeyword || clause.token == ts.SyntaxKind.ImplementsKeyword) {
|
|
213
|
+
for (var _b = 0, _c = clause.types; _b < _c.length; _b++) {
|
|
214
|
+
var type = _c[_b];
|
|
215
|
+
var typeName = type.expression.getText();
|
|
216
|
+
baseTypes.push(typeName);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
this.debugLog("CLASS START", name, baseTypes);
|
|
222
|
+
var res = writer.startNewType(filePath, name, baseTypes, this.getComments(node));
|
|
178
223
|
if (res === false) {
|
|
179
224
|
this.debugLog("CLASS SKIPPED", name);
|
|
180
225
|
return;
|
|
@@ -282,6 +327,7 @@ var Compiler = /** @class */ (function () {
|
|
|
282
327
|
}
|
|
283
328
|
};
|
|
284
329
|
Compiler.prototype.resolveType = function (typeNode, writer) {
|
|
330
|
+
var _a;
|
|
285
331
|
if (!typeNode)
|
|
286
332
|
return undefined;
|
|
287
333
|
// check if its an array
|
|
@@ -330,6 +376,19 @@ var Compiler = /** @class */ (function () {
|
|
|
330
376
|
console.error("!!!!! ----- Unknown array type", typeNode.getText());
|
|
331
377
|
}
|
|
332
378
|
var type = typeNode.getText();
|
|
379
|
+
var baseTypes = [];
|
|
380
|
+
if (typeNode.kind === ts.SyntaxKind.TypeReference) {
|
|
381
|
+
var typeReference = typeNode;
|
|
382
|
+
if ((_a = typeReference.typeArguments) === null || _a === void 0 ? void 0 : _a.length) {
|
|
383
|
+
for (var _i = 0, _b = typeReference.typeArguments; _i < _b.length; _i++) {
|
|
384
|
+
var arg = _b[_i];
|
|
385
|
+
var type_1 = this.resolveType(arg, writer);
|
|
386
|
+
if (type_1) {
|
|
387
|
+
baseTypes.push(type_1);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
333
392
|
return this.resolveTypeFromString(type, writer);
|
|
334
393
|
};
|
|
335
394
|
Compiler.prototype.resolveTypeFromString = function (type, writer) {
|
package/src/blender-compiler.js
CHANGED
|
@@ -4,13 +4,14 @@ exports.BlenderWriter = void 0;
|
|
|
4
4
|
var fs_1 = require("fs");
|
|
5
5
|
var base_compiler_1 = require("./base-compiler");
|
|
6
6
|
var commands_1 = require("./commands");
|
|
7
|
-
var supportedTypes = ["string", "float", "int", "bool", "col", "obj", "evt", "fn", "vec2", "vec3"];
|
|
7
|
+
var supportedTypes = ["string", "float", "int", "bool", "col", "obj", "evt", "fn", "vec2", "vec3", "comp"];
|
|
8
|
+
var knownBaseTypes = ["Behaviour", "IComponent"];
|
|
8
9
|
var BlenderWriter = /** @class */ (function () {
|
|
9
|
-
function BlenderWriter(
|
|
10
|
+
function BlenderWriter(_sink) {
|
|
11
|
+
this._sink = _sink;
|
|
10
12
|
this.writer = new base_compiler_1.CodeTextWriter();
|
|
11
13
|
this._createdSchemesPerFile = {};
|
|
12
14
|
this._currentlyProcessingFiles = {};
|
|
13
|
-
this._outputDirectory = outputDirectory;
|
|
14
15
|
}
|
|
15
16
|
Object.defineProperty(BlenderWriter.prototype, "outputInfo", {
|
|
16
17
|
get: function () {
|
|
@@ -19,9 +20,9 @@ var BlenderWriter = /** @class */ (function () {
|
|
|
19
20
|
enumerable: false,
|
|
20
21
|
configurable: true
|
|
21
22
|
});
|
|
22
|
-
Object.defineProperty(BlenderWriter.prototype, "
|
|
23
|
+
Object.defineProperty(BlenderWriter.prototype, "sink", {
|
|
23
24
|
get: function () {
|
|
24
|
-
return this.
|
|
25
|
+
return this._sink;
|
|
25
26
|
},
|
|
26
27
|
enumerable: false,
|
|
27
28
|
configurable: true
|
|
@@ -55,9 +56,10 @@ var BlenderWriter = /** @class */ (function () {
|
|
|
55
56
|
return "col";
|
|
56
57
|
case "eventlist":
|
|
57
58
|
return "evt";
|
|
58
|
-
case "
|
|
59
|
+
case "behaviour":
|
|
59
60
|
return "comp";
|
|
60
61
|
}
|
|
62
|
+
return typeName;
|
|
61
63
|
};
|
|
62
64
|
BlenderWriter.prototype.begin = function (filePath) {
|
|
63
65
|
if (!this._currentlyProcessingFiles[filePath]) {
|
|
@@ -103,8 +105,16 @@ var BlenderWriter = /** @class */ (function () {
|
|
|
103
105
|
}
|
|
104
106
|
delete this._currentlyProcessingFiles[filePath];
|
|
105
107
|
};
|
|
106
|
-
BlenderWriter.prototype.startNewType = function (filePath, typeName,
|
|
107
|
-
|
|
108
|
+
BlenderWriter.prototype.startNewType = function (filePath, typeName, baseTypes, comments) {
|
|
109
|
+
var isSupportedType = false;
|
|
110
|
+
for (var i = 0; i < knownBaseTypes.length; i++) {
|
|
111
|
+
if (baseTypes.includes(knownBaseTypes[i])) {
|
|
112
|
+
isSupportedType = true;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// console.log(baseTypes, knownBaseTypes, isSupportedType)
|
|
117
|
+
if (!isSupportedType)
|
|
108
118
|
return false;
|
|
109
119
|
this.writer.beginBlock("{");
|
|
110
120
|
if (comments)
|
|
@@ -119,10 +129,10 @@ var BlenderWriter = /** @class */ (function () {
|
|
|
119
129
|
BlenderWriter.prototype.writeMember = function (visibility, name, isArray, type, initialValue, comments) {
|
|
120
130
|
if (visibility !== base_compiler_1.Visibility.Public)
|
|
121
131
|
return;
|
|
122
|
-
if (!supportedTypes.includes(type)) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
132
|
+
// if (!supportedTypes.includes(type)) {
|
|
133
|
+
// console.log("-- unsupported type:", type);
|
|
134
|
+
// return;
|
|
135
|
+
// }
|
|
126
136
|
this.writer.beginBlock("\"" + name + "\": {");
|
|
127
137
|
this.writer.writeLine("\"type\": \"" + type + "\",");
|
|
128
138
|
if (initialValue && !isArray) {
|
|
@@ -139,7 +149,7 @@ var BlenderWriter = /** @class */ (function () {
|
|
|
139
149
|
this.writer.writeLine("\"value\": " + initialValue);
|
|
140
150
|
}
|
|
141
151
|
if (isArray) {
|
|
142
|
-
this.writer.writeLine("\"
|
|
152
|
+
this.writer.writeLine("\"value\": []");
|
|
143
153
|
}
|
|
144
154
|
this.writer.endBlock("},");
|
|
145
155
|
};
|
|
@@ -154,13 +164,13 @@ var BlenderWriter = /** @class */ (function () {
|
|
|
154
164
|
console.log("new type:", typeName);
|
|
155
165
|
};
|
|
156
166
|
BlenderWriter.prototype.writeScheme = function (processingFilePath, component) {
|
|
157
|
-
var
|
|
167
|
+
var res = this.sink.flush(component + ".component.json", this.writer.flush());
|
|
158
168
|
// if an output path is returned it means a file has been written to that path
|
|
159
|
-
if (
|
|
160
|
-
(0, commands_1.sendFileWrittenCommand)(
|
|
169
|
+
if (res && (0, fs_1.existsSync)(res)) {
|
|
170
|
+
(0, commands_1.sendFileWrittenCommand)(res);
|
|
161
171
|
// add the scheme to the list of created schemes
|
|
162
172
|
if (processingFilePath && this._currentlyProcessingFiles[processingFilePath]) {
|
|
163
|
-
this._currentlyProcessingFiles[processingFilePath].push({ componentName: component, filePath:
|
|
173
|
+
this._currentlyProcessingFiles[processingFilePath].push({ componentName: component, filePath: res });
|
|
164
174
|
}
|
|
165
175
|
}
|
|
166
176
|
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CSharpWriter = void 0;
|
|
4
|
+
var fs_1 = require("fs");
|
|
5
|
+
var path = require("path");
|
|
6
|
+
var allowDebugLogs = false;
|
|
7
|
+
var CSharpWriter = /** @class */ (function () {
|
|
8
|
+
function CSharpWriter(_outputDir) {
|
|
9
|
+
this._outputDir = _outputDir;
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(CSharpWriter.prototype, "outputInfo", {
|
|
12
|
+
get: function () {
|
|
13
|
+
return this._outputInfo;
|
|
14
|
+
},
|
|
15
|
+
enumerable: false,
|
|
16
|
+
configurable: true
|
|
17
|
+
});
|
|
18
|
+
CSharpWriter.prototype.resolveTypeName = function (typescriptTypeName) {
|
|
19
|
+
if (this._typesFileContent === undefined) {
|
|
20
|
+
this._typesFileContent = null;
|
|
21
|
+
var filePath = path.dirname(__dirname) + "/src/types.json";
|
|
22
|
+
if ((0, fs_1.existsSync)(filePath)) {
|
|
23
|
+
if (allowDebugLogs)
|
|
24
|
+
console.log("Reading types file");
|
|
25
|
+
var content = (0, fs_1.readFileSync)(filePath, "utf8");
|
|
26
|
+
this._typesFileContent = JSON.parse(content);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (this._typesFileContent) {
|
|
30
|
+
var fullType = this._typesFileContent[typescriptTypeName];
|
|
31
|
+
if (fullType && allowDebugLogs)
|
|
32
|
+
console.log(fullType);
|
|
33
|
+
return fullType;
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
};
|
|
37
|
+
CSharpWriter.prototype.begin = function (filePath) {
|
|
38
|
+
};
|
|
39
|
+
CSharpWriter.prototype.end = function (filePath) {
|
|
40
|
+
};
|
|
41
|
+
CSharpWriter.prototype.startNewType = function (filePath, typeName, baseType, comments) {
|
|
42
|
+
throw new Error("Method not implemented.");
|
|
43
|
+
};
|
|
44
|
+
CSharpWriter.prototype.endNewType = function (filePath, typeName) {
|
|
45
|
+
throw new Error("Method not implemented.");
|
|
46
|
+
};
|
|
47
|
+
CSharpWriter.prototype.writeMember = function (visibility, name, isArray, type, initialValue, comments) {
|
|
48
|
+
throw new Error("Method not implemented.");
|
|
49
|
+
};
|
|
50
|
+
CSharpWriter.prototype.writeMethod = function (visibility, name, returnType, args, comments) {
|
|
51
|
+
throw new Error("Method not implemented.");
|
|
52
|
+
};
|
|
53
|
+
CSharpWriter.prototype.writeNewTypeExpression = function (typeName, args) {
|
|
54
|
+
throw new Error("Method not implemented.");
|
|
55
|
+
};
|
|
56
|
+
return CSharpWriter;
|
|
57
|
+
}());
|
|
58
|
+
exports.CSharpWriter = CSharpWriter;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReactThreeFiberCompiler = void 0;
|
|
4
|
+
var ReactThreeFiberCompiler = /** @class */ (function () {
|
|
5
|
+
function ReactThreeFiberCompiler() {
|
|
6
|
+
this._typeSourceInformation = {};
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(ReactThreeFiberCompiler.prototype, "outputInfo", {
|
|
9
|
+
get: function () {
|
|
10
|
+
return this._typeSourceInformation;
|
|
11
|
+
},
|
|
12
|
+
enumerable: false,
|
|
13
|
+
configurable: true
|
|
14
|
+
});
|
|
15
|
+
ReactThreeFiberCompiler.prototype.resolveTypeName = function (typescriptTypeName) {
|
|
16
|
+
return typescriptTypeName;
|
|
17
|
+
};
|
|
18
|
+
ReactThreeFiberCompiler.prototype.begin = function (filePath) {
|
|
19
|
+
};
|
|
20
|
+
ReactThreeFiberCompiler.prototype.end = function (filePath) {
|
|
21
|
+
};
|
|
22
|
+
ReactThreeFiberCompiler.prototype.startNewType = function (filePath, typeName, baseType, comments) {
|
|
23
|
+
};
|
|
24
|
+
ReactThreeFiberCompiler.prototype.endNewType = function (filePath, typeName) {
|
|
25
|
+
};
|
|
26
|
+
ReactThreeFiberCompiler.prototype.writeMember = function (visibility, name, isArray, type, initialValue, comments) {
|
|
27
|
+
};
|
|
28
|
+
ReactThreeFiberCompiler.prototype.writeMethod = function (visibility, name, returnType, args, comments) {
|
|
29
|
+
};
|
|
30
|
+
ReactThreeFiberCompiler.prototype.writeNewTypeExpression = function (typeName, args) {
|
|
31
|
+
};
|
|
32
|
+
return ReactThreeFiberCompiler;
|
|
33
|
+
}());
|
|
34
|
+
exports.ReactThreeFiberCompiler = ReactThreeFiberCompiler;
|
package/src/test.js
CHANGED
|
@@ -1,10 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
exports.__esModule = true;
|
|
18
|
+
exports.MyTestComponent = void 0;
|
|
19
|
+
var MyTestComponent = /** @class */ (function (_super) {
|
|
20
|
+
__extends(MyTestComponent, _super);
|
|
21
|
+
function MyTestComponent() {
|
|
22
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
23
|
+
_this.myVector2 = new Vector2(1, .5);
|
|
24
|
+
return _this;
|
|
25
|
+
}
|
|
26
|
+
MyTestComponent.prototype.myMethod = function () {
|
|
27
|
+
};
|
|
28
|
+
return MyTestComponent;
|
|
29
|
+
}(Behaviour));
|
|
30
|
+
exports.MyTestComponent = MyTestComponent;
|
|
31
|
+
// export class SkipFieldAndMethod extends Behaviour {
|
|
32
|
+
// //@nonSerialized
|
|
33
|
+
// myMethod() {
|
|
34
|
+
// }
|
|
35
|
+
// // @nonSerialized
|
|
36
|
+
// myField : string;
|
|
37
|
+
// }
|
|
38
|
+
// export class ComponentWithUnknownType extends Behaviour {
|
|
39
|
+
// views: SomeUnknownType;
|
|
40
|
+
// }
|
|
41
|
+
// export class ComponentWithAnimationClip extends Behaviour implements IPointerClickHandler {
|
|
42
|
+
// @serializeable(AnimationClip)
|
|
43
|
+
// animation?: THREE.AnimationClip;
|
|
44
|
+
// }
|
|
45
|
+
// export abstract class MyAbstractComponent extends Behaviour {
|
|
46
|
+
// abstract myMethod();
|
|
47
|
+
// }
|
|
4
48
|
// export class CameraView extends Behaviour {
|
|
5
49
|
// static views: CameraView[] = [];
|
|
6
50
|
// }
|
|
7
|
-
// export class
|
|
51
|
+
// export class EventComponent extends Behaviour {
|
|
52
|
+
// @serializeable(EventList)
|
|
53
|
+
// roomChanged: EventList = new EventList();
|
|
54
|
+
// }
|
|
55
|
+
// export class SocLoader extends Behaviour {
|
|
8
56
|
// @serializeable(AssetReference)
|
|
9
57
|
// scenes: Array<AssetReference> = [];
|
|
10
58
|
// }
|
|
@@ -24,32 +72,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
24
72
|
// map2 : Map<object> = new Map<object>();
|
|
25
73
|
// private myThing : Test123;
|
|
26
74
|
// }
|
|
27
|
-
//
|
|
75
|
+
// //@type UnityEngine.MonoBehaviour
|
|
28
76
|
// export class ButtonObject extends Interactable implements IPointerClickHandler, ISerializable {
|
|
29
77
|
// //@type UnityEngine.Transform[]
|
|
30
78
|
// myType?: SceneFXWindow;
|
|
31
79
|
// }
|
|
32
|
-
// export class EventComponent extends Behaviour {
|
|
33
|
-
// @serializeable(EventList)
|
|
34
|
-
// roomChanged: EventList = new EventList();
|
|
35
|
-
// }
|
|
36
|
-
// export class SkipFieldAndMethod extends Behaviour {
|
|
37
|
-
// //@nonSerialized
|
|
38
|
-
// myMethod() {
|
|
39
|
-
// }
|
|
40
|
-
// // @nonSerialized
|
|
41
|
-
// myField : string;
|
|
42
|
-
// }
|
|
43
|
-
// export class ComponentWithUnknownType extends Behaviour {
|
|
44
|
-
// views: SomeUnknownType;
|
|
45
|
-
// }
|
|
46
|
-
// export class ComponentWithAnimationClip extends Behaviour implements IPointerClickHandler {
|
|
47
|
-
// @serializeable(AnimationClip)
|
|
48
|
-
// animation?: THREE.AnimationClip;
|
|
49
|
-
// }
|
|
50
|
-
// export abstract class MyAbstractComponent extends Behaviour {
|
|
51
|
-
// abstract myMethod();
|
|
52
|
-
// }
|
|
53
80
|
// import { Behaviour } from "needle.tiny.engine/engine-components/Component";
|
|
54
81
|
// import { RoomEntity } from "./Room";
|
|
55
82
|
// import { Behaviour } from "needle.tiny.engine/engine-components/Component";
|
package/src/watcher.js
CHANGED
|
@@ -74,4 +74,5 @@ if (fs.existsSync(outputDirectory))
|
|
|
74
74
|
fs.rmSync(outputDirectory, { recursive: true });
|
|
75
75
|
console.log("Watch: " + directoryToWatch + " and output to: " + outputDirectory);
|
|
76
76
|
var watcher = new DirectoryWatcher();
|
|
77
|
-
|
|
77
|
+
var sink = new base_compiler_1.FileSink(outputDirectory);
|
|
78
|
+
watcher.startWatching(directoryToWatch, new blender_compiler_1.BlenderWriter(sink), registerTypesPath);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
exports.__esModule = true;
|
|
3
3
|
var helpers_1 = require("./helpers");
|
|
4
4
|
describe('Typescript with public methods', function () {
|
|
5
5
|
it('should generate component with public method', function () {
|
package/test/helpers.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
exports.__esModule = true;
|
|
3
3
|
exports.compareCodegenWithDefaultContext = exports.compareCodegen = exports.testCompile = void 0;
|
|
4
4
|
var component_compiler_1 = require("../src/component-compiler");
|
|
5
5
|
var chai_1 = require("chai");
|
package/tsconfig.json
DELETED