@needle-tools/needle-component-compiler 1.9.1 → 2.0.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 +3 -0
- package/package.json +17 -12
- package/src/base-compiler.js +405 -0
- package/src/blender-compiler.js +141 -0
- package/src/commands.js +11 -0
- package/src/test.js +24 -51
- package/src/watcher.js +72 -0
- package/COMPILE.bat +0 -1
- package/DEV.bat +0 -1
- package/INSTALL.bat +0 -1
- package/PUBLISH.bat +0 -8
- package/RUN_MANUAL_TEST.bat +0 -1
- package/RUN_TESTS.bat +0 -1
- package/src/component-compiler.ts +0 -734
- package/src/test.ts +0 -234
- package/test/component.basic.test.ts +0 -52
- package/test/component.methods.test.ts +0 -185
- package/test/component.nonserialized.test.ts +0 -45
- package/test/component.primitives.test.ts +0 -123
- package/test/helpers.ts +0 -72
package/src/test.js
CHANGED
|
@@ -1,58 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
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
2
|
exports.__esModule = true;
|
|
18
|
-
|
|
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
|
-
// }
|
|
3
|
+
//@type("MyComponent")
|
|
48
4
|
// export class CameraView extends Behaviour {
|
|
49
5
|
// static views: CameraView[] = [];
|
|
50
6
|
// }
|
|
51
|
-
// export class
|
|
52
|
-
// @serializeable(EventList)
|
|
53
|
-
// roomChanged: EventList = new EventList();
|
|
54
|
-
// }
|
|
55
|
-
// export class SocLoader extends Behaviour {
|
|
7
|
+
// export class SocLoader extends Behaviour {
|
|
56
8
|
// @serializeable(AssetReference)
|
|
57
9
|
// scenes: Array<AssetReference> = [];
|
|
58
10
|
// }
|
|
@@ -72,11 +24,32 @@ exports.MyTestComponent = MyTestComponent;
|
|
|
72
24
|
// map2 : Map<object> = new Map<object>();
|
|
73
25
|
// private myThing : Test123;
|
|
74
26
|
// }
|
|
75
|
-
//
|
|
27
|
+
// // @type UnityEngine.MonoBehaviour
|
|
76
28
|
// export class ButtonObject extends Interactable implements IPointerClickHandler, ISerializable {
|
|
77
29
|
// //@type UnityEngine.Transform[]
|
|
78
30
|
// myType?: SceneFXWindow;
|
|
79
31
|
// }
|
|
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
|
+
// }
|
|
80
53
|
// import { Behaviour } from "needle.tiny.engine/engine-components/Component";
|
|
81
54
|
// import { RoomEntity } from "./Room";
|
|
82
55
|
// import { Behaviour } from "needle.tiny.engine/engine-components/Component";
|
package/src/watcher.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
_this.compiler.compile(writer, fs.readFileSync(path).toString(), path);
|
|
24
|
+
_this._needReload = true;
|
|
25
|
+
break;
|
|
26
|
+
case "change":
|
|
27
|
+
console.log("File", path, "has been changed");
|
|
28
|
+
_this.compiler.compile(writer, fs.readFileSync(path).toString(), path);
|
|
29
|
+
_this._needReload = true;
|
|
30
|
+
break;
|
|
31
|
+
case "unlink":
|
|
32
|
+
console.log("File", path, "has been removed");
|
|
33
|
+
break;
|
|
34
|
+
default:
|
|
35
|
+
console.log("File unhandled event", event, path);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
console.error(err);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
// call reload cmd
|
|
43
|
+
setInterval(function () {
|
|
44
|
+
if (_this._needReload) {
|
|
45
|
+
_this._needReload = false;
|
|
46
|
+
(0, commands_1.sendReloadCommand)();
|
|
47
|
+
}
|
|
48
|
+
}, 2000);
|
|
49
|
+
};
|
|
50
|
+
return DirectoryWatcher;
|
|
51
|
+
}());
|
|
52
|
+
exports.DirectoryWatcher = DirectoryWatcher;
|
|
53
|
+
// listen to process exit
|
|
54
|
+
process.on('exit', function () {
|
|
55
|
+
// console.log('Bye node');
|
|
56
|
+
});
|
|
57
|
+
var args = process.argv.slice(2);
|
|
58
|
+
if (args.length < 2) {
|
|
59
|
+
console.error("Missing arguments, usage: node watcher.js <directory> <output>");
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
var directoryToWatch = args[0].replace("\"", "");
|
|
63
|
+
var outputDirectory = args[1].replace("\"", "");
|
|
64
|
+
if (!fs.existsSync(directoryToWatch)) {
|
|
65
|
+
console.error("Directory to watch does not exist");
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
if (fs.existsSync(outputDirectory))
|
|
69
|
+
fs.rmdirSync(outputDirectory, { recursive: true });
|
|
70
|
+
console.log("Watch: " + directoryToWatch + " and output to: " + outputDirectory);
|
|
71
|
+
var watcher = new DirectoryWatcher();
|
|
72
|
+
watcher.startWatching(directoryToWatch, new blender_compiler_1.BlenderWriter(outputDirectory));
|
package/COMPILE.bat
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npm run tsc src/component-compiler
|
package/DEV.bat
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npm install && npm run dev
|
package/INSTALL.bat
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npm install && timeout 10
|
package/PUBLISH.bat
DELETED
package/RUN_MANUAL_TEST.bat
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npm run tsc src/component-compiler && node src/component-compiler.js dist src/test.ts
|
package/RUN_TESTS.bat
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npm run test & pause
|