@needle-tools/needle-component-compiler 1.9.2-exp → 1.9.2
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/COMPILE.bat +1 -0
- package/Changelog.md +3 -2
- package/DEV.bat +1 -0
- package/INSTALL.bat +1 -0
- package/PUBLISH.bat +8 -0
- package/RUN_MANUAL_TEST.bat +1 -0
- package/RUN_TESTS.bat +1 -0
- package/package.json +12 -17
- package/schemes/MyNew.component.json +1 -0
- package/schemes/MyTest.component.json +1 -0
- package/src/component-compiler.js +6 -3
- package/src/component-compiler.ts +737 -0
- package/src/test.js +24 -26
- package/src/test.ts +234 -0
- package/test/blender/codegen/basic/expected.component.json +4 -0
- package/test/blender/codegen/basic/input.js +26 -0
- package/test/blender/codegen/basic/input.ts +3 -0
- package/test/blender/codegen/basic/output.component.json +1 -0
- package/test/blender/codegen/float field/expected.component.json +8 -0
- package/test/blender/codegen/float field/input.js +28 -0
- package/test/blender/codegen/float field/input.ts +4 -0
- package/test/blender/codegen/float field/output.component.json +1 -0
- package/test/blender/codegen/reference_animation/expected.component.json +7 -0
- package/test/blender/codegen/reference_animation/input.js +35 -0
- package/test/blender/codegen/reference_animation/input.ts +4 -0
- package/test/blender/codegen/reference_animation/output.component.json +1 -0
- package/test/blender/codegen/reference_behaviour/expected.component.json +7 -0
- package/test/blender/codegen/reference_behaviour/input.js +35 -0
- package/test/blender/codegen/reference_behaviour/input.ts +5 -0
- package/test/blender/codegen/reference_behaviour/output.component.json +1 -0
- package/test/component.basic.test.ts +53 -0
- package/test/component.methods.test.ts +185 -0
- package/test/component.nonserialized.test.ts +45 -0
- package/test/component.primitives.test.ts +123 -0
- package/test/csharp/codegen/abstract method/expected.cs +14 -0
- package/test/csharp/codegen/abstract method/input.js +27 -0
- package/test/csharp/codegen/abstract method/input.ts +4 -0
- package/test/csharp/codegen/abstract method/output.cs +14 -0
- package/test/csharp/codegen/basic/expected.cs +13 -0
- package/test/csharp/codegen/basic/input.js +26 -0
- package/test/csharp/codegen/basic/input.ts +2 -0
- package/test/csharp/codegen/basic/output.cs +13 -0
- package/test/csharp/codegen/basic-no-export/expected.cs +0 -0
- package/test/csharp/codegen/basic-no-export/input.js +27 -0
- package/test/csharp/codegen/basic-no-export/input.ts +4 -0
- package/test/csharp/codegen/basic-no-export/output.cs +0 -0
- package/test/csharp/codegen/bool/expected.cs +14 -0
- package/test/csharp/codegen/bool/input.js +26 -0
- package/test/csharp/codegen/bool/input.ts +3 -0
- package/test/csharp/codegen/bool/output.cs +14 -0
- package/test/csharp/codegen/fields with default values/expected.cs +18 -0
- package/test/csharp/codegen/fields with default values/input.js +32 -0
- package/test/csharp/codegen/fields with default values/input.ts +7 -0
- package/test/csharp/codegen/fields with default values/output.cs +18 -0
- package/test/csharp/codegen/method ignore inline type declaration/expected.cs +14 -0
- package/test/csharp/codegen/method ignore inline type declaration/input.js +27 -0
- package/test/csharp/codegen/method ignore inline type declaration/input.ts +3 -0
- package/test/csharp/codegen/method ignore inline type declaration/output.cs +14 -0
- package/test/csharp/codegen/nonserialized ignore field/expected.cs +13 -0
- package/test/csharp/codegen/nonserialized ignore field/input.js +26 -0
- package/test/csharp/codegen/nonserialized ignore field/input.ts +4 -0
- package/test/csharp/codegen/nonserialized ignore field/output.cs +13 -0
- package/test/csharp/codegen/nonserialized on property does not affect method/expected.cs +14 -0
- package/test/csharp/codegen/nonserialized on property does not affect method/input.js +34 -0
- package/test/csharp/codegen/nonserialized on property does not affect method/input.ts +8 -0
- package/test/csharp/codegen/nonserialized on property does not affect method/output.cs +13 -0
- package/test/csharp/codegen/number/expected.cs +14 -0
- package/test/csharp/codegen/number/input.js +26 -0
- package/test/csharp/codegen/number/input.ts +3 -0
- package/test/csharp/codegen/number/output.cs +14 -0
- package/test/csharp/codegen/object/expected.cs +14 -0
- package/test/csharp/codegen/object/input.js +26 -0
- package/test/csharp/codegen/object/input.ts +3 -0
- package/test/csharp/codegen/object/output.cs +14 -0
- package/test/csharp/codegen/private.methods/expected.cs +13 -0
- package/test/csharp/codegen/private.methods/input.js +27 -0
- package/test/csharp/codegen/private.methods/input.ts +3 -0
- package/test/csharp/codegen/private.methods/output.cs +13 -0
- package/test/csharp/codegen/protected.methods/expected.cs +13 -0
- package/test/csharp/codegen/protected.methods/input.js +27 -0
- package/test/csharp/codegen/protected.methods/input.ts +3 -0
- package/test/csharp/codegen/protected.methods/output.cs +13 -0
- package/test/csharp/codegen/public method with args/expected.cs +14 -0
- package/test/csharp/codegen/public method with args/input.js +27 -0
- package/test/csharp/codegen/public method with args/input.ts +3 -0
- package/test/csharp/codegen/public method with args/output.cs +14 -0
- package/test/csharp/codegen/public method with multiple args/expected.cs +14 -0
- package/test/csharp/codegen/public method with multiple args/input.js +27 -0
- package/test/csharp/codegen/public method with multiple args/input.ts +3 -0
- package/test/csharp/codegen/public method with multiple args/output.cs +14 -0
- package/test/csharp/codegen/public.methods/expected.cs +14 -0
- package/test/csharp/codegen/public.methods/input.js +27 -0
- package/test/csharp/codegen/public.methods/input.ts +3 -0
- package/test/csharp/codegen/public.methods/output.cs +14 -0
- package/test/csharp/codegen/static method/expected.cs +13 -0
- package/test/csharp/codegen/static method/input.js +27 -0
- package/test/csharp/codegen/static method/input.ts +3 -0
- package/test/csharp/codegen/static method/output.cs +14 -0
- package/test/csharp/codegen/string/expected.cs +14 -0
- package/test/csharp/codegen/string/input.js +26 -0
- package/test/csharp/codegen/string/input.ts +3 -0
- package/test/csharp/codegen/string/output.cs +14 -0
- package/test/csharp/codegen/stringArray/expected.cs +14 -0
- package/test/csharp/codegen/stringArray/input.js +26 -0
- package/test/csharp/codegen/stringArray/input.ts +3 -0
- package/test/csharp/codegen/stringArray/output.cs +14 -0
- package/test/helpers.ts +72 -0
- package/workspace.code-workspace +11 -11
- package/src/base-compiler.js +0 -404
- package/src/blender-compiler.js +0 -100
- package/src/commands.js +0 -11
- package/src/watcher.js +0 -64
package/src/blender-compiler.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.BlenderWriter = void 0;
|
|
4
|
-
var base_compiler_1 = require("./base-compiler");
|
|
5
|
-
var commands_1 = require("./commands");
|
|
6
|
-
var supportedTypes = ["string", "float", "int", "bool", "col", "obj", "evt", "fn"];
|
|
7
|
-
var BlenderWriter = /** @class */ (function () {
|
|
8
|
-
function BlenderWriter(outputDirectory) {
|
|
9
|
-
this.writer = new base_compiler_1.CodeTextWriter();
|
|
10
|
-
this.outputDirectory = outputDirectory;
|
|
11
|
-
}
|
|
12
|
-
BlenderWriter.prototype.resolveTypeName = function (typeName, comments) {
|
|
13
|
-
typeName = typeName.toLocaleLowerCase();
|
|
14
|
-
if (typeName.startsWith("three."))
|
|
15
|
-
typeName = typeName.substring("three.".length);
|
|
16
|
-
switch (typeName) {
|
|
17
|
-
case "number":
|
|
18
|
-
return "float";
|
|
19
|
-
case "int":
|
|
20
|
-
return "int";
|
|
21
|
-
case "boolean":
|
|
22
|
-
return "bool";
|
|
23
|
-
case "string":
|
|
24
|
-
return "string";
|
|
25
|
-
case "void":
|
|
26
|
-
return "void";
|
|
27
|
-
case "any":
|
|
28
|
-
return "any";
|
|
29
|
-
case "vector2":
|
|
30
|
-
return "vec2";
|
|
31
|
-
case "color":
|
|
32
|
-
return "col";
|
|
33
|
-
case "renderer":
|
|
34
|
-
return "comp";
|
|
35
|
-
case "eventlist":
|
|
36
|
-
return "evt";
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
BlenderWriter.prototype.begin = function () {
|
|
40
|
-
// this.writer.beginBlock("{")
|
|
41
|
-
};
|
|
42
|
-
BlenderWriter.prototype.end = function () {
|
|
43
|
-
// this.writer.endBlock("}");
|
|
44
|
-
// this.writer.flush(this.outputFilePath);
|
|
45
|
-
};
|
|
46
|
-
BlenderWriter.prototype.startNewType = function (typeName, baseType, comments) {
|
|
47
|
-
if (baseType !== "Behaviour")
|
|
48
|
-
return false;
|
|
49
|
-
this.writer.beginBlock("{");
|
|
50
|
-
if (comments)
|
|
51
|
-
console.log(comments);
|
|
52
|
-
this.writer.beginBlock("\"" + typeName + "\": {");
|
|
53
|
-
};
|
|
54
|
-
BlenderWriter.prototype.endNewType = function (typeName) {
|
|
55
|
-
this.writer.endBlock("},");
|
|
56
|
-
this.writer.endBlock("}");
|
|
57
|
-
this.writeScheme(typeName);
|
|
58
|
-
};
|
|
59
|
-
BlenderWriter.prototype.writeMember = function (visibility, name, isArray, type, initialValue, comments) {
|
|
60
|
-
if (!supportedTypes.includes(type)) {
|
|
61
|
-
console.log("-- unsupported type:", type);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
this.writer.beginBlock("\"" + name + "\": {");
|
|
65
|
-
this.writer.writeLine("\"type\": \"" + type + "\",");
|
|
66
|
-
if (initialValue && !isArray) {
|
|
67
|
-
if (initialValue.startsWith("new "))
|
|
68
|
-
initialValue = undefined;
|
|
69
|
-
switch (type) {
|
|
70
|
-
case "bool":
|
|
71
|
-
initialValue = initialValue.toLowerCase();
|
|
72
|
-
break;
|
|
73
|
-
case "string":
|
|
74
|
-
initialValue = "\"" + initialValue + "\"";
|
|
75
|
-
}
|
|
76
|
-
if (initialValue)
|
|
77
|
-
this.writer.writeLine("\"value\": " + initialValue);
|
|
78
|
-
}
|
|
79
|
-
if (isArray) {
|
|
80
|
-
this.writer.writeLine("\"isArray\": true");
|
|
81
|
-
}
|
|
82
|
-
this.writer.endBlock("},");
|
|
83
|
-
};
|
|
84
|
-
BlenderWriter.prototype.writeMethod = function (visibility, name, returnType, args, comments) {
|
|
85
|
-
this.writer.beginBlock("\"" + name + "\": {");
|
|
86
|
-
this.writer.writeLine("\"type\": \"fn\",");
|
|
87
|
-
this.writer.endBlock("},");
|
|
88
|
-
};
|
|
89
|
-
BlenderWriter.prototype.writeNewTypeExpression = function (typeName, args) {
|
|
90
|
-
console.log("new type:", typeName);
|
|
91
|
-
};
|
|
92
|
-
BlenderWriter.prototype.writeScheme = function (component) {
|
|
93
|
-
var outputPath = this.writer.flush(this.outputDirectory, component + ".component.json");
|
|
94
|
-
if (outputPath)
|
|
95
|
-
(0, commands_1.sendFileWrittenCommand)(outputPath);
|
|
96
|
-
};
|
|
97
|
-
return BlenderWriter;
|
|
98
|
-
}());
|
|
99
|
-
exports.BlenderWriter = BlenderWriter;
|
|
100
|
-
// runFromFile(new BlenderWriter("dist"), "src\\test.ts");
|
package/src/commands.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.sendFileWrittenCommand = exports.sendReloadCommand = void 0;
|
|
4
|
-
function sendReloadCommand() {
|
|
5
|
-
process.stdout.write("CMD:reload\r");
|
|
6
|
-
}
|
|
7
|
-
exports.sendReloadCommand = sendReloadCommand;
|
|
8
|
-
function sendFileWrittenCommand(path) {
|
|
9
|
-
process.stdout.write("CMD:writefile " + path + "\r");
|
|
10
|
-
}
|
|
11
|
-
exports.sendFileWrittenCommand = sendFileWrittenCommand;
|
package/src/watcher.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.DirectoryWatcher = void 0;
|
|
4
|
-
var fs = require("fs");
|
|
5
|
-
var base_compiler_1 = require("./base-compiler");
|
|
6
|
-
var blender_compiler_1 = require("./blender-compiler");
|
|
7
|
-
var chokidar = require("chokidar");
|
|
8
|
-
var commands_1 = require("./commands");
|
|
9
|
-
// https://github.com/paulmillr/chokidar
|
|
10
|
-
var DirectoryWatcher = /** @class */ (function () {
|
|
11
|
-
function DirectoryWatcher() {
|
|
12
|
-
this.compiler = new base_compiler_1.Compiler();
|
|
13
|
-
this._needReload = false;
|
|
14
|
-
}
|
|
15
|
-
DirectoryWatcher.prototype.startWatching = function (dir, writer) {
|
|
16
|
-
var _this = this;
|
|
17
|
-
// console.log("Start watching", dir);
|
|
18
|
-
chokidar.watch(dir + "/**/*.ts").on('all', function (event, path) {
|
|
19
|
-
try {
|
|
20
|
-
switch (event) {
|
|
21
|
-
case "add":
|
|
22
|
-
console.log("File", path, "has been added");
|
|
23
|
-
break;
|
|
24
|
-
case "change":
|
|
25
|
-
console.log("File", path, "has been changed");
|
|
26
|
-
_this.compiler.compile(writer, fs.readFileSync(path).toString());
|
|
27
|
-
_this._needReload = true;
|
|
28
|
-
break;
|
|
29
|
-
case "unlink":
|
|
30
|
-
console.log("File", path, "has been removed");
|
|
31
|
-
break;
|
|
32
|
-
default:
|
|
33
|
-
console.log("File unhandled event", event, path);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
catch (err) {
|
|
37
|
-
console.error(err);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
// call reload cmd
|
|
41
|
-
setInterval(function () {
|
|
42
|
-
if (_this._needReload) {
|
|
43
|
-
_this._needReload = false;
|
|
44
|
-
(0, commands_1.sendReloadCommand)();
|
|
45
|
-
}
|
|
46
|
-
}, 2000);
|
|
47
|
-
};
|
|
48
|
-
return DirectoryWatcher;
|
|
49
|
-
}());
|
|
50
|
-
exports.DirectoryWatcher = DirectoryWatcher;
|
|
51
|
-
// listen to process exit
|
|
52
|
-
process.on('exit', function () {
|
|
53
|
-
console.log('Bye node');
|
|
54
|
-
});
|
|
55
|
-
var args = process.argv.slice(2);
|
|
56
|
-
if (args.length < 2) {
|
|
57
|
-
console.error("Missing arguments, usage: node watcher.js <directory> <output>");
|
|
58
|
-
process.exit(1);
|
|
59
|
-
}
|
|
60
|
-
var directoryToWatch = args[0].replace("\"", "");
|
|
61
|
-
var outputDirectory = args[1].replace("\"", "");
|
|
62
|
-
console.log("Watch: " + directoryToWatch + " and output to: " + outputDirectory);
|
|
63
|
-
var watcher = new DirectoryWatcher();
|
|
64
|
-
watcher.startWatching(directoryToWatch, new blender_compiler_1.BlenderWriter(outputDirectory));
|