mesh css simplification
This commit is contained in:
parent
cbec4b2e87
commit
44933dd1b4
9 changed files with 115 additions and 141 deletions
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
(function() {
|
||||
|
||||
let MOTO = self.moto = self.moto || {},
|
||||
let moto = self.moto = self.moto || {},
|
||||
time = function() { return new Date().getTime() },
|
||||
restarting = false,
|
||||
running = {},
|
||||
|
|
@ -12,8 +12,10 @@ let MOTO = self.moto = self.moto || {},
|
|||
worker = null,
|
||||
seqid = 1;
|
||||
|
||||
if (moto.client) return;
|
||||
|
||||
/**
|
||||
* @param {Function} fn name of function in MOTO.worker
|
||||
* @param {Function} fn name of function in moto.worker
|
||||
* @param {Object} data to send to server
|
||||
* @param {Function} onreply function to call on reply messages
|
||||
* @param {Object[]} zerocopy array of objects to pass using zerocopy
|
||||
|
|
@ -39,7 +41,7 @@ function send(fn, data, onreply, zerocopy) {
|
|||
}
|
||||
|
||||
// code is running in the browser / client context
|
||||
let CLIENT = MOTO.client = {
|
||||
let client = moto.client = {
|
||||
send: send,
|
||||
|
||||
// factory can be overridden
|
||||
|
|
@ -69,7 +71,7 @@ let CLIENT = MOTO.client = {
|
|||
|
||||
// same as restart
|
||||
start: function(url) {
|
||||
CLIENT.restart(url);
|
||||
client.restart(url);
|
||||
},
|
||||
|
||||
restart: function(url) {
|
||||
|
|
@ -78,7 +80,7 @@ let CLIENT = MOTO.client = {
|
|||
return;
|
||||
}
|
||||
|
||||
CLIENT.stop();
|
||||
client.stop();
|
||||
|
||||
restarting = true;
|
||||
|
||||
|
|
@ -90,15 +92,20 @@ let CLIENT = MOTO.client = {
|
|||
}
|
||||
|
||||
running = {};
|
||||
worker = CLIENT.newWorker(url);
|
||||
worker = client.newWorker(url);
|
||||
|
||||
// bind to CLIENT to enable synth injections
|
||||
CLIENT.onmessage = worker.onmessage = function(e) {
|
||||
// bind to client to enable synth injections
|
||||
client.onmessage = worker.onmessage = function(e) {
|
||||
let now = time(),
|
||||
reply = e.data,
|
||||
record = running[reply.seq],
|
||||
onreply = record ? record.fn : undefined;
|
||||
|
||||
if (reply.register) {
|
||||
// console.log({register: reply.register});
|
||||
return;
|
||||
}
|
||||
|
||||
if (reply.done) {
|
||||
delete running[reply.seq];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
(function() {
|
||||
|
||||
if (!self.moto) self.moto = {};
|
||||
if (self.moto.Storage) return;
|
||||
let moto = self.moto = self.moto || {};
|
||||
if (moto.IDB) return;
|
||||
|
||||
self.moto.Storage = Storage;
|
||||
moto.IDB = moto.Storage = Storage;
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
|
||||
|
||||
|
|
@ -4,14 +4,9 @@
|
|||
|
||||
(function() {
|
||||
|
||||
if (!self.moto) self.moto = {};
|
||||
if (self.moto.KV) return;
|
||||
let moto = self.moto = self.moto = {};
|
||||
if (moto.KV) return;
|
||||
|
||||
/**
|
||||
* @param {String} dbname
|
||||
* @param {number} [version]
|
||||
* @constructor
|
||||
*/
|
||||
function KV() {
|
||||
this.__data__ = {};
|
||||
this.__mem__ = true;
|
||||
|
|
@ -33,22 +28,18 @@
|
|||
};
|
||||
|
||||
KP.clear = function() {
|
||||
var d = this.__data__, key;
|
||||
for (key in d) {
|
||||
if (d.hasOwnProperty(key)) {
|
||||
delete d[key];
|
||||
delete this[key];
|
||||
}
|
||||
}
|
||||
this.__data__ = {};
|
||||
};
|
||||
|
||||
try {
|
||||
self.moto.KV = self.localStorage;
|
||||
self.moto.KV.setItem('__test', 1);
|
||||
self.moto.KV.getItem('__test');
|
||||
let KV = moto.KV = self.localStorage,
|
||||
testkey = '__test';
|
||||
KV.setItem(testkey, 1);
|
||||
KV.getItem(testkey);
|
||||
KV.removeItem(testkey);
|
||||
} catch (e) {
|
||||
self.moto.KV = new KV();
|
||||
let msg = "in private or restricted browsing mode. local storage blocked. application may not function.";
|
||||
moto.KV = new KV();
|
||||
let msg = "in private or restricted browsing mode. local storage blocked. application may not function properly.";
|
||||
console.log(msg);
|
||||
alert(msg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,29 +4,48 @@
|
|||
|
||||
(function() {
|
||||
|
||||
let MOTO = self.moto = self.moto || {},
|
||||
let moto = self.moto = self.moto || {},
|
||||
time = Date.now;
|
||||
|
||||
if (moto.worker) return;
|
||||
|
||||
// allow license to inject module
|
||||
self.gapp = self.gapp || MOTO;
|
||||
self.gapp = self.gapp || moto;
|
||||
|
||||
let isinit = false;
|
||||
let endpoints = {};
|
||||
|
||||
// code is running in the worker / server context
|
||||
const dispatch = MOTO.worker = {
|
||||
const dispatch = moto.worker = {
|
||||
|
||||
register: (name, fn) => {
|
||||
endpoints[name] = fn;
|
||||
sync(name);
|
||||
},
|
||||
|
||||
send: (msg) => {
|
||||
self.postMessage(msg);
|
||||
},
|
||||
|
||||
sync: (name) => {
|
||||
if (name) {
|
||||
if (isinit) dispatch.send({register: [name]});
|
||||
} else {
|
||||
dispatch.send({register: Object.keys(endpoints)});
|
||||
}
|
||||
},
|
||||
|
||||
onmessage: (e) => {
|
||||
|
||||
if (e.data === '--init--') {
|
||||
console.log('worker got init');
|
||||
isinit = true;
|
||||
dispatch.sync();
|
||||
return;
|
||||
}
|
||||
|
||||
let time_recv = time(),
|
||||
msg = e.data || {},
|
||||
run = dispatch[msg.task],
|
||||
run = endpoints[msg.task],
|
||||
send = {
|
||||
data : function(data,direct) {
|
||||
dispatch.send({
|
||||
|
|
|
|||
Loading…
Reference in a new issue