collecxion START
parent
e24d7cf56e
commit
6f16cffa16
|
|
@ -0,0 +1,54 @@
|
||||||
|
const {Signale} = require('signale');
|
||||||
|
const log = new Signale({
|
||||||
|
scope: 'EXEC'
|
||||||
|
});
|
||||||
|
const path = require('path');
|
||||||
|
const fs = require('fs');
|
||||||
|
const uuid = require('uuid');
|
||||||
|
|
||||||
|
const timeout = 3000;
|
||||||
|
const root = (typeof window === 'undefined' ? global : window)
|
||||||
|
const {Entity} = require('./entity.js')
|
||||||
|
|
||||||
|
|
||||||
|
class System {
|
||||||
|
constructor(cache) {
|
||||||
|
this.cache = cache;
|
||||||
|
this.entities = {};
|
||||||
|
for(const uuid of cache.getInstances()) {
|
||||||
|
this.loadEntity(uuid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async send(name, destination, options) {
|
||||||
|
// log.debug(`sending ${name}`);
|
||||||
|
|
||||||
|
if(!(destination in this.entities)) {
|
||||||
|
this.loadEntity(destination);
|
||||||
|
log.debug('loading entity...')
|
||||||
|
}
|
||||||
|
|
||||||
|
this.entities[destination].dispatch(name, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
loadEntity(uuid) {
|
||||||
|
// log.debug(`spinning up ${uuid}`);
|
||||||
|
log.debug(uuid)
|
||||||
|
if(typeof require === 'function') {
|
||||||
|
let codePath = this.cache.getEntityCodePathFromUuid(uuid);
|
||||||
|
// log.debug(codePath)
|
||||||
|
let data = this.cache.getDataFromUuid(uuid);
|
||||||
|
let instanceData = this.cache.getInstanceFromUuid(uuid);
|
||||||
|
let userCode = require(codePath).entity;
|
||||||
|
this.entities[uuid] = new Entity(userCode, instanceData, this);
|
||||||
|
this.entities[uuid].start();
|
||||||
|
log.debug('starting', uuid)
|
||||||
|
} else {
|
||||||
|
//TODO COMPLICATED EVAL SHIT, MIRRORING REQUIRE FUNCTIONALITY
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {System};
|
||||||
|
|
@ -10,7 +10,8 @@ const timeout = 3000;
|
||||||
const root = (typeof window === 'undefined' ? global : window)
|
const root = (typeof window === 'undefined' ? global : window)
|
||||||
const {Entity} = require('./entity.js')
|
const {Entity} = require('./entity.js')
|
||||||
|
|
||||||
module.exports.System = class System {
|
|
||||||
|
class System {
|
||||||
constructor(cache) {
|
constructor(cache) {
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
this.entities = {};
|
this.entities = {};
|
||||||
|
|
@ -48,4 +49,6 @@ module.exports.System = class System {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports = {System};
|
||||||
13
package.json
13
package.json
|
|
@ -1,10 +1,11 @@
|
||||||
{
|
{
|
||||||
"name": "aquatin",
|
"name": "collexion",
|
||||||
"version": "1.0.0",
|
"version": "0.0.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "./core/Collexion.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
|
"compile": "tsc --watch"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
@ -16,12 +17,14 @@
|
||||||
"url": "https://github.com/marcus13345/AquaTin/issues"
|
"url": "https://github.com/marcus13345/AquaTin/issues"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"aqua": "core/aqua.js"
|
"clx": "core/aqua.js"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/marcus13345/AquaTin#readme",
|
"homepage": "https://github.com/marcus13345/AquaTin#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"aquatin": "file:.",
|
||||||
"rimraf": "^2.6.3",
|
"rimraf": "^2.6.3",
|
||||||
"signale": "^1.4.0",
|
"signale": "^1.4.0",
|
||||||
|
"typescript": "^3.5.3",
|
||||||
"uuid": "^3.3.2",
|
"uuid": "^3.3.2",
|
||||||
"yargs": "^13.2.4"
|
"yargs": "^13.2.4"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
const {System} = require('aquatin/core/system.js');
|
||||||
|
|
||||||
|
console.log(System)
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
const = require('.');
|
||||||
|
console.log(ref)
|
||||||
|
|
||||||
|
// const ExampleModule = require('./module.js.js');
|
||||||
|
|
||||||
|
// module.exports = {
|
||||||
|
// Entities: {
|
||||||
|
// A: {
|
||||||
|
// Code: ExampleModule,
|
||||||
|
// Data: {
|
||||||
|
// thing: ref('B'),
|
||||||
|
// boop: true
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// B: {
|
||||||
|
// Code: ExampleModule,
|
||||||
|
// Data: {
|
||||||
|
// thing: ref('B')
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
const path = require('path');
|
||||||
|
let local = path.join(__dirname, './../modules/')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
Entities: {
|
||||||
|
A: {
|
||||||
|
Name: 'module',
|
||||||
|
From: local,
|
||||||
|
data: {
|
||||||
|
thing: '#B',
|
||||||
|
boop: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
B: {
|
||||||
|
Name: 'module',
|
||||||
|
From: local,
|
||||||
|
data: {
|
||||||
|
thing: '#A'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,22 +1,24 @@
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
let local = path.join(__dirname, './../modules/')
|
|
||||||
|
const ref = require('./node_modules/aqua').Reference;
|
||||||
|
|
||||||
|
const ExampleModule = require('./module.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
Entities: {
|
Entities: {
|
||||||
A: {
|
A: {
|
||||||
Name: 'module',
|
Code: ExampleModule,
|
||||||
From: local,
|
Data: {
|
||||||
data: {
|
thing: ref('B'),
|
||||||
thing: '#B',
|
|
||||||
boop: true
|
boop: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
B: {
|
B: {
|
||||||
Name: 'module',
|
Code: ExampleModule,
|
||||||
From: local,
|
Data: {
|
||||||
data: {
|
thing: ref('B')
|
||||||
thing: '#A'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"include": [
|
||||||
|
"core/*"
|
||||||
|
],
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"module": "commonjs",
|
||||||
|
"sourceMap": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue