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 {Entity} = require('./entity.js')
|
||||
|
||||
module.exports.System = class System {
|
||||
|
||||
class System {
|
||||
constructor(cache) {
|
||||
this.cache = cache;
|
||||
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",
|
||||
"version": "1.0.0",
|
||||
"name": "collexion",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"main": "./core/Collexion.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"compile": "tsc --watch"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
@ -16,12 +17,14 @@
|
|||
"url": "https://github.com/marcus13345/AquaTin/issues"
|
||||
},
|
||||
"bin": {
|
||||
"aqua": "core/aqua.js"
|
||||
"clx": "core/aqua.js"
|
||||
},
|
||||
"homepage": "https://github.com/marcus13345/AquaTin#readme",
|
||||
"dependencies": {
|
||||
"aquatin": "file:.",
|
||||
"rimraf": "^2.6.3",
|
||||
"signale": "^1.4.0",
|
||||
"typescript": "^3.5.3",
|
||||
"uuid": "^3.3.2",
|
||||
"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');
|
||||
let local = path.join(__dirname, './../modules/')
|
||||
|
||||
const ref = require('./node_modules/aqua').Reference;
|
||||
|
||||
const ExampleModule = require('./module.js');
|
||||
|
||||
module.exports = {
|
||||
Entities: {
|
||||
A: {
|
||||
Name: 'module',
|
||||
From: local,
|
||||
data: {
|
||||
thing: '#B',
|
||||
Code: ExampleModule,
|
||||
Data: {
|
||||
thing: ref('B'),
|
||||
boop: true
|
||||
}
|
||||
},
|
||||
B: {
|
||||
Name: 'module',
|
||||
From: local,
|
||||
data: {
|
||||
thing: '#A'
|
||||
Code: ExampleModule,
|
||||
Data: {
|
||||
thing: ref('B')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"include": [
|
||||
"core/*"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"sourceMap": true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue