collecxion START

master
Marcus 2019-09-18 00:03:29 -04:00
parent e24d7cf56e
commit 6f16cffa16
10 changed files with 141 additions and 17 deletions

54
core/Collexion.js 100644
View File

@ -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};

View File

View File

@ -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 = {};
@ -49,3 +50,5 @@ module.exports.System = class System {
}
module.exports = {System};

View File

@ -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"
}

3
test.js 100644
View File

@ -0,0 +1,3 @@
const {System} = require('aquatin/core/system.js');
console.log(System)

View File

@ -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')
// }
// }
// }
// }

View File

@ -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'
}
}
}
}

View File

@ -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')
}
}
}
}

14
tsconfig.json 100644
View File

@ -0,0 +1,14 @@
{
"include": [
"core/*"
],
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true
}
}