mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00
smarter SEA parsing, fix broken heroku deplou
This commit is contained in:
parent
a4d559900d
commit
32befdc1e6
37
lib/time.js
37
lib/time.js
@ -1,17 +1,27 @@
|
||||
;(function(){
|
||||
var ify = Gun.node.ify, u;
|
||||
Gun.chain.time = function(data, cb, opt){
|
||||
if(Gun.is(data)){
|
||||
var soul = data._.soul;
|
||||
if(!soul){ return cb({err: "Only root level node references supported currently, hopefully will change this in the future."}), this }
|
||||
data = Gun.val.rel.ify(soul);
|
||||
}
|
||||
Gun.chain.time = function(data, a, b){
|
||||
if(data instanceof Function){
|
||||
return travel(data, cb, opt, this);
|
||||
return travel(data, a, b, this);
|
||||
}
|
||||
opt = opt || {};
|
||||
var t = new Date(Gun.state()).toISOString().split(/[\-t\:\.z]/ig);
|
||||
var gun = this, root = gun.back(-1);
|
||||
var cb = (a instanceof Function && a) || (b instanceof Function && b);
|
||||
if(Gun.is(data)){
|
||||
data = data._.soul;
|
||||
if(!data){
|
||||
/*data.get('_', function(msg, ev){
|
||||
ev.off();
|
||||
|
||||
})
|
||||
return gun;*/
|
||||
cb && cb({err: "Only root level node references supported currently, hopefully will change this in the future."});
|
||||
return gun;
|
||||
}
|
||||
data = Gun.val.rel.ify(data);
|
||||
}
|
||||
opt = (cb === a)? b : a;
|
||||
opt = Gun.text.is(opt)? {key: opt} : opt || {};
|
||||
var t = new Date(Gun.state()).toISOString().split(/[\-t\:\.z]/ig);
|
||||
var p, tmp = t.pop();
|
||||
//gun.get('_', function(msg, ev){ ev.off();
|
||||
//var id = (msg.put && msg.put['#']) || (((gun._).soul || (root.back('opt.uuid') || Gun.text.random)(6)) + ':'); // TODO: BUG! THIS SHOULD NOT BE HARDCODED.
|
||||
@ -20,7 +30,7 @@
|
||||
if(!p){ return cb({err: "For now, a timegraph can only be saved as a root node."}), this }
|
||||
// could shrink this into a loop. Do later?
|
||||
t = [p].concat(t);
|
||||
var rid = (root.back('opt.uuid') || Gun.text.random)(9);
|
||||
var rid = opt.key || (root.back('opt.uuid') || Gun.text.random)(9);
|
||||
var milli = ify({}, t.join(':'));
|
||||
milli[rid] = data;
|
||||
tmp = t.pop();
|
||||
@ -87,8 +97,9 @@
|
||||
if(7 < at.length){
|
||||
var l = Object.keys(msg.put).length;
|
||||
if(l === o.seen[t]){ return }
|
||||
var when = +(toDate(at));
|
||||
Gun.node.is(msg.put, function(v, k){
|
||||
cb(v, k, ev);
|
||||
cb(v, k, when, ev);
|
||||
if(o.last){ --o.last }
|
||||
});
|
||||
o.seen[t] = l;
|
||||
@ -124,4 +135,8 @@
|
||||
});
|
||||
})
|
||||
}
|
||||
function toDate(at){
|
||||
at = at.slice(-7);
|
||||
return new Date(Date.UTC(at[0], parseFloat(at[1])-1, at[2], at[3], at[4], at[5], at[6]));
|
||||
}
|
||||
}());
|
1203
package-lock.json
generated
1203
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gun",
|
||||
"version": "0.9.995",
|
||||
"version": "0.9.996",
|
||||
"description": "A realtime, decentralized, offline-first, graph data synchronization engine.",
|
||||
"main": "index.js",
|
||||
"browser": "gun.min.js",
|
||||
@ -51,17 +51,11 @@
|
||||
"ws": "~>4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@std/esm": "^0.8.3",
|
||||
"@trust/webcrypto": "^0.7.1",
|
||||
"aws-sdk": ">=2.153.0",
|
||||
"express": ">=4.15.2",
|
||||
"fake-indexeddb": "^2.0.3",
|
||||
"hapi": "^17.2.0",
|
||||
"inert": "^5.1.0",
|
||||
"ip": "^1.1.5",
|
||||
"mocha": ">=3.2.0",
|
||||
"node-localstorage": "^1.3.0",
|
||||
"node-webcrypto-ossl": "^1.0.36",
|
||||
"panic-manager": "^1.2.0",
|
||||
"panic-server": "^1.1.1",
|
||||
"text-encoding": "^0.6.4",
|
||||
|
6
sea.js
6
sea.js
@ -407,7 +407,9 @@
|
||||
SEA.verify = async (data, pair, cb) => { try {
|
||||
const json = parse(data)
|
||||
if(false === pair){ // don't verify!
|
||||
const raw = (json === data)? json : parse(json.m)
|
||||
const raw = (json !== data)?
|
||||
(json.s && json.m)? parse(json.m) : data
|
||||
: json;
|
||||
if(cb){ cb(raw) }
|
||||
return raw;
|
||||
}
|
||||
@ -1387,7 +1389,7 @@
|
||||
var to = this.to, vertex = (msg.gun._).put, c = 0, d;
|
||||
Gun.node.is(msg.put, function(val, key, node){ c++; // for each property on the node
|
||||
// TODO: consider async/await use here...
|
||||
SEA.verify(val, false).then(function(data){ c--; // false just extracts the plain data.
|
||||
SEA.verify(val, false, function(data){ c--; // false just extracts the plain data.
|
||||
node[key] = val = data; // transform to plain value.
|
||||
if(d && !c && (c = -1)){ to.next(msg) }
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user