merge latest npm release into manhattan

This commit is contained in:
Mark Nadal 2020-04-09 00:01:45 -07:00
parent 407af2db75
commit eae893054a
11 changed files with 404 additions and 983 deletions

14
axe.js
View File

@ -168,7 +168,7 @@
},1000 * 60)
setTimeout(function(tmp){
if(!(tmp = at.stats && at.stats.stay)){ return }
Gun.obj.map((tmp.axe||{}).up, function(url){ mesh.hear.opt({opt: {peers: url}}) })
((tmp.axe||{}).up||[]).forEach(function(url){ mesh.hear.opt({opt: {peers: url}}) })
},1000);
if(at.opt.super){
@ -260,9 +260,9 @@
at.on('bye', function(peer){ this.to.next(peer);
if(peer.url){ delete axe.up[peer.id] }
var S = +new Date;
Gun.obj.map(peer.routes, function(route, hash){
obj_map(peer.routes, function(route, hash){
delete route[peer.id];
if(Gun.obj.empty(route)){
if(Object.empty(route)){
delete axe.routes[hash];
}
});
@ -290,7 +290,7 @@
setTimeout(function(){ // must wait
if(peer.pid !== opt.pid){
// this extra logic checks for duplicate connections between 2 peers.
if(!Gun.obj.map(axe.up, function(p){
if(!obj_map(axe.up, function(p){
if(peer.pid === p.pid && peer !== p){
return yes = true;
}
@ -305,6 +305,12 @@
peer.url = '';
}
}
var obj_map = function(o, f, r){
for(var k in o){
if(!o.hasOwnProperty(k)){ continue }
if((r = f(o[k], k)) !== u){ return r }
}
}
function joindht(dht, soul, pids) {
if (!pids || !soul || !dht) { return; }

View File

@ -22,10 +22,21 @@
[contenteditable]:focus {
outline: none;
}
.meta-on, div:hover, ul:hover, ol:hover, li:hover, p:hover, span:hover, form:hover, button:hover, input:hover, textarea:hover, img:hover {
outline: 1px solid;
animation: meta-on 3s infinite;
transition: none !important;
} @keyframes meta-on {
0% {outline-color: magenta;}
33% {outline-color: cyan;}
66% {outline-color: yellow;}
100% {outline-color: magenta;}
}
</style>
<div class="hold full hue2">
<div id="page" class="max focus gap" style="padding-top: 9%;"></div>
<div id="page" class="max focus gap" style="margin-top: 9%;"></div>
</div>
<script src="../../gun/gun.js"></script>
<script src="../../gun/lib/monotype.js"></script>
@ -37,7 +48,8 @@
<!-- script async src="https://edide.io/music.lib"></script -->
<script>
var gun = Gun(['https://guntest.herokuapp.com/gun', 'http://localhost:8765/gun']);
var gun = Gun();
//var gun = Gun(['https://guntest.herokuapp.com/gun', 'http://localhost:8765/gun']);
;(window.onhashchange = function(){
var file = (location.hash||'').slice(1);
@ -144,26 +156,25 @@ meta.edit({
;(function(){
meta.edit({name: "Layout", combo: ['L']});
meta.edit({name: "Fill", combo: ['L','F'],
meta.edit({name: "Design", combo: ['D']});
meta.edit({name: "Fill", combo: ['D','F'], // TODO!
use: function(eve){},
on: function(eve){
var on = meta.tap();
meta.ask('Color name, code, or URL?', function(color){
on.css('background', color);
});
}, true);
},
up: function(eve){}
});
meta.edit({name: "Add", combo: ['L','A']});
meta.edit({name: "Row", combo: ['L','A', 'R'],
meta.edit({name: "Add", combo: ['D','A']});
meta.edit({name: "Row", combo: ['D','A', 'R'],
on: function(eve){
meta.tap().append('<div style="min-height: 9em; padding: 2%;">');
}
});
meta.edit({name: "Columns", combo: ['L','A','C'],
meta.edit({name: "Columns", combo: ['D','A','C'],
on: function(eve){
var on = meta.tap().addClass('center'), tmp, c;
var html = '<div class="unit col" style="min-height: 9em; padding: 2%;"></div>';
@ -174,14 +185,50 @@ meta.edit({
})
}
});
meta.edit({name: "Text", combo: ['L','A','T'],
meta.edit({name: "Text", combo: ['D','A','T'],
on: function(eve){
var tag = $('<p>text</p>');
meta.tap().append(tag);
tag.focus();
}
});
meta.edit({name: "Delete", combo: ['D','A','D'],
on: function(eve){
meta.tap().remove();
}
});
meta.edit({name: "Turn", combo: ['D','T']});
meta.edit({name: "Size", combo: ['D','S']});
meta.edit({name: "X", combo: ['D','S','X'],
on: function(eve){
var on = this.a = meta.tap().addClass('meta-on'), was = on.width();
$(document).on('mousemove.tmp', function(eve){
var be = was + ((eve.pageX||0) - was);
on.css({'max-width': be, width: '100%'});
});
meta.ask('Width in px, %, or other unit?', function(w){
if(!w){ return }
on.css({'max-width': w, width: '100%'});
}, true);
}, up: function(){
$(document).off('mousemove.tmp');
this.a.removeClass('meta-on');
}
});
meta.edit({name: "Y", combo: ['D','S','Y'],
//on: function(eve){ console.log('on Y') },
on: function(eve){ console.log('use Y')
var on = this.a = meta.tap().addClass('meta-on'), was = on.height();
$(document).on('mousemove.tmp', function(eve){
var be = was + ((eve.pageY||0) - was);
on.css({'min-height': be});
})
}, up: function(){ console.log('up Y')
$(document).off('mousemove.tmp');
this.a.removeClass('meta-on');
}
});
}());
;(function(){
@ -232,9 +279,43 @@ meta.edit({
});
$(document).on('keydown', function(eve){
music.play(String.fromCharCode(eve.which));
if(eve.which === music.which){ return }
music.play(String.fromCharCode(music.which = eve.which));
});
}());
;(function(){
/*
Edit
Bold
Italic
Link
?
Left
Middle
Right
Justify
?
Small
Normal
Header
Title
Design
Add
Row
Column
Text
Delete
Turn
Grab
Size
X
Y
Fill
*/
/*
*/
}());
</script>
</body>

View File

@ -90,7 +90,7 @@
</div>
<div class="focus center row leak">
<!-- just like in real life, looking pretty attracts attention, so show off and look glamorous! -->
<img class="unit blink" src="file:///Users/mark/Downloads/supercatdog.png" style="min-width: 10em; width: 80%;">
<img class="unit blink" src="file:///Users/mark/Pictures/supercatdog.png" style="min-width: 10em; width: 80%;">
</div>
<script>location.hash = ''</script>
<script src="https://cdn.jsdelivr.net/npm/gun/lib/fun.js"></script>
@ -114,7 +114,7 @@
</div>
</div>
<div class="focus center row leak">
<img class="unit blink" src="file:///Users/mark/Downloads/supercatdog.png" style="transform: scaleX(-1); filter: invert(1); min-width: 10em; width: 80%;">
<img class="unit blink" src="file:///Users/mark/Pictures/supercatdog.png" style="transform: scaleX(-1); filter: invert(1); min-width: 10em; width: 80%;">
</div>
</div>

1217
gun.js

File diff suppressed because it is too large Load Diff

View File

@ -38,8 +38,9 @@
return m.flip(false)
} // cancel and close when no action and "meta key" held down (e.g. ctrl+c)
if(!eve.fake && key === k.last){ return }; k.last = key; // jussi: polyfilling eve.repeat?
if(!eve.fake && $(eve.target).closest('input, textarea, [contenteditable=true]').length && !$(eve.target).closest('#meta').length){
if(meta.flip.is() && !withMeta(eve)) eve.preventDefault()
if(!eve.fake && $(eve.target).closest('input, textarea, [contenteditable=true]').length/* && !$(eve.target).closest('#meta').get().length*/){
return;
//if(meta.flip.is() && !withMeta(eve)) eve.preventDefault()
}
m.check('on', key, k.at || (k.at = m.edit));
if(k.meta[key]){ m.flip() }
@ -116,7 +117,7 @@
m.list(at.back);
}));
}
m.ask = function(help, cb){
m.ask = function(help, cb, opt){
var $ul = $('#meta .meta-menu ul').empty();
var $put = $('<input>').attr('id', 'meta-ask').attr('placeholder', help);
var $form = $('<form>').append($put).on('submit', function(eve){
@ -126,6 +127,9 @@
//k.wipe();
m.list(k.at);
});
if(opt){
$form.on('keyup', function(eve){ cb($put.val()) })
}
var $li = $('<li>').append($form);
$ul.append($li);
m.flip(true);
@ -235,6 +239,8 @@
opacity: 1
},
'#meta a': {color: 'black'},
'#meta:hover': {opacity: 1},
'#meta:hover .meta-menu': {display: 'block'},
'#meta .meta-menu ul:before': {
content: "' '",
display: 'block',
@ -264,7 +270,7 @@
})(USE, './metaUI');
;USE(function(module){
var m = meta, k = m.key;
$(window).on('focus', k.wipe.bind(null, false)); // .on('blur', k.wipe.bind(null, false))
//$(window).on('focus', k.wipe.bind(null, false)); // .on('blur', k.wipe.bind(null, false))
$(document).on('mousedown mousemove mouseup', function(eve){
m.tap.eve = eve;
m.tap.x = eve.pageX||0;

View File

@ -8,7 +8,7 @@
var has = (Radisk.has || (Radisk.has = {}))[opt.file];
if(has){ return has }
opt.pack = opt.pack || (opt.memory? (opt.memory * 1000 * 1000) : 1399000000) * 0.3; // max_old_space_size defaults to 1400 MB.
opt.pack = opt.pack || (opt.memory? (opt.memory * 999 * 999) : 300000000) * 0.3;
opt.until = opt.until || opt.wait || 250;
opt.batch = opt.batch || (10 * 1000);
opt.chunk = opt.chunk || (1024 * 1024 * 1); // 1MB
@ -21,8 +21,7 @@
function atomic(v){ return u !== v && (!v || 'object' != typeof v) }
var timediate = (typeof setImmediate === "undefined")? setTimeout : setImmediate;
var puff = setTimeout.puff || timediate;
var map = Gun.obj.map;
var obj_empty = Gun.obj.empty;
var map = Radix.object;
var ST = 0;
if(!opt.store){
@ -107,7 +106,8 @@
if((tmp = r.disk[f]) && (tmp = tmp.tags) && tmp[tag]){ continue }
ack = tag[f];
delete tag[f];
if(!obj_empty(tag)){ continue }
var ne; for(var k in tag){ if(tag.hasOwnProperty(k)){ ne = true; break } } // is not empty?
if(ne){ continue } //if(!obj_empty(tag)){ continue }
delete r.tags[tag];
ack && ack(err, ok);
}
@ -493,7 +493,7 @@
dir = dir || rad;
dir.file = f;
tmp = Q; Q = null;
Gun.list.map(tmp, function(arg){
map(tmp, function(arg){
r.find(arg[0], arg[1]);
});
}

View File

@ -15,7 +15,7 @@
k += key[++i];
}
if(!at){
if(!map(t, function(r, s){
if(!each(t, function(r, s){
var ii = 0, kk = '';
if((s||'').length){ while(s[ii] == key[ii]){
kk += s[ii++];
@ -102,17 +102,17 @@
}
};
Object.keys = Object.keys || function(o){ return map(o, function(v,k,t){t(k)}) }
if(typeof window !== "undefined"){
var Gun = window.Gun;
window.Radix = Radix;
} else {
var Gun = require('../gun');
try{ module.exports = Radix }catch(e){}
}
var map = Gun.obj.map, no = {}, u;
var each = Radix.object = function(o, f, r){
for(var k in o){
if(!o.hasOwnProperty(k)){ continue }
if((r = f(o[k], k)) !== u){ return r }
}
}, no = {}, u;
var _ = String.fromCharCode(24);
}());

View File

@ -19,8 +19,9 @@ Gun.on('opt', function(root){
os.freemem = os.freemem || noop;
os.loadavg = os.loadavg || noop;
os.cpus = os.cpus || noop;
var obj_ify = function(o){try{o = JSON.parse(o)}catch(e){o={}};return o;}
setTimeout(function(){
root.stats = Gun.obj.ify((fs.existsSync(__dirname+'/../stats.'+root.opt.file) && fs.readFileSync(__dirname+'/../stats.'+root.opt.file).toString())) || {};
root.stats = obj_ify((fs.existsSync(__dirname+'/../stats.'+root.opt.file) && fs.readFileSync(__dirname+'/../stats.'+root.opt.file).toString())) || {};
root.stats.up = root.stats.up || {};
root.stats.up.start = root.stats.up.start || +(new Date);
root.stats.up.count = (root.stats.up.count || 0) + 1;

View File

@ -28,7 +28,7 @@ Gun.on('create', function(root){
}, id, DBG && (DBG.r = DBG.r || {}));
DBG && (DBG.sps = DBG.sps || +new Date);
});
var count = {}, obj_empty = Gun.obj.empty;
var count = {}, obj_empty = Object.empty;
root.on('get', function(msg){
this.to.next(msg);
@ -138,7 +138,7 @@ Gun.on('create', function(root){
(graph = graph || {})[soul] = Gun.state.ify(graph[soul], has, state, val, soul);
}
});
var val_is = Gun.val.is
var val_is = Gun.valid;
opt.store.stats = {get:{time:{}, count:0}, put: {time:{}, count:0}}; // STATS!
var statg = 0, statp = 0; // STATS!
});

View File

@ -150,4 +150,4 @@ function value(s){
module.exports = yson;
}());
}());

2
sea.js
View File

@ -1224,7 +1224,7 @@
}).on.on('secure', msg);
return;
}
var link_is = Gun.val.link.is, state_ify = Gun.state.ify;
var valid = Gun.valid, link_is = function(d,l){ return 'string' == typeof (l = valid(d)) && l }, state_ify = Gun.state.ify;
// okay! The security function handles all the heavy lifting.
// It needs to deal read and write of input and output of system data, account/public key data, and regular data.