mirror of
https://github.com/amark/gun.git
synced 2025-03-30 15:08:33 +00:00

* tmp for hn issue * log top to stats * test for guntest peer * try big messages * parse time? * what bin/node is 11ms? * be normal for hnoon * tolerate 0.5s * try 3s for hnoon? * stop empty gets * tmp for guntest * back to normal * check hash time * back to normal in hear * screen / upload / play / pause * merge latest npm release into manhattan * merge master 0.2020.421 into manhattan manually * WIP * manually merge from master * gatling * Update upload.html * work in progress... * yson panic chat basic * after `.put(` walk * restructure acks * messy but 2 units passing! * put recursive once on map * basics * have NTS use DAM + fix other utils * Rewrote nts * Allow passing test cli args. Before, no CLI args would be passed when running `npm test`. Keeping the `mocha` at the end of the test script allows passing CLI args to Mocha. * put back scan & once tweak * PANIC user paste OK * manhattan sea * stub out nts for now * AXE tweak * tweak for quick first prod testing * tweak for first in-prod testing * tweak * tweak * sketchy in-prod debug attempt * caught it? maybe? now restore * Create download-log.html * stub out yson test prod? * ugh, gotta see what is going on * move dl * gonna stop doing commit messages for in-prod test/tweaks/debugging * a * p * squelch * console stats * stats * stop travis * restore yson * ahhh no file access without sudo * mem * no stub * fix axe * bump * back to in-prod testing, isolate/stub out code * stub all out for 17K ? CPU ? test * stub dup gc * ugh main stub * does this stop url format blocking? * re-add dup * no top :( * will this work? * get ack stats? * a map chain may ask for data not a root soul chain * move proper logic into .get( * how 2019 compat? * a couple more! * more tests passing! :D :) * even more! SO EXCITING :D * Am I alive? * wow I can't believe it works like this * THANK YOU @rogowski !!!!!! * Create trace.html Adding tracing to debuging. * @rogowski is a super star :) :) :) * Update trace.js Change `Gun.logs` to `Gun.traces` and `Gun._log` to `Gun._trace`. * Update trace.html Change `Gun.logs` to `Gun.traces` and `Gun._log` to `Gun._trace`. Overload get,put,on,map * @rogowski approved of these trace changes :) * Update trace.html More decoupled. * Update trace.js More decoupled * 2 steps backwards, 1 step forward? * back where we ( @rogowski ) started :P * YAYAYAYAYAYAYAY past where we started at! * safer to have it here * slight tweak? Let's see how long it lasts. * merge checks we left out during consolidation * ugly common.js for @rogowski * slightly better * amazing map discovery + don't clear on not found if data exists * onto next test... * all caught up!!! Now update tests from graphify to statedisk * Update common.js Tests updated from graphify to statedisk. * easy to debug & fix thanks to @rogowski 's test upgrades & trace! * hmm, IDK if we should support this anymore? * support once chaining? * check if listener order is earlier than write * in-process message passing needs to clean itself of flags for now * ack to chains that can't be reached * call sub chains on clear/empty WIP * call sub chains clear/empty OK! * into unlink. Clean/refactor later. * oh that was nice * self check not needed? * test was poorly constructed? * refactor unlink to cleaner logic * Will you blame me for this? Special case, maybe later move to cleaner place? * use stun's run id instead. * cleaner unlink logic * better map, link, and unlink logic. * unstub relay * refactor unlink * invert * if prev value would have caused unlink, do not unlink again. * w000h00! Best unlink so far. * woops, fix unlinking nested * unsubscribe nested maps (working, tho possible perf regression? check) * put check soul * add default uuid * improved browser peer retry logic, let devices sleep, etc. * Chaining API unit tests passing! * merge new panic tests into here to test * add panic utils * fix long streaming timeout/expiry issue, update examples * yield generating test data * yeah, adapter errors (like out of storage) should not affect sync/networking logic, that was a bad experiment * git glitch? * some mid debugging fixes but maybe scary changes, hopefully safe to revert here except dub * SEA unit tests passing!!! Needed quite a few fixes on async write queue stuff. * optionally make auth async * revise/correct set * Fix reverse boundary check * Add extra tests, catch bad guy, obliterate bug. * chat app with emoji examples * handle empty string keyed objects * starting lex support * tweak for lex * woops! lexical alphabetical oopsies. That was bad. * upload either way * debug * start * fix * fix * clean + feature * update dependencies in package.json (#1086) * rad lex once map once * axe polyfill for now * oops log * oops maybe without this it crashed the peer * what on earth happened to my browser/OS? "unplug & plug it back in" restart seemed to fix it. * oh, don't memory leak req/res asks. :/ duh! * no accidental #soul."" * ugh, still have to sort :(, really should polyfill weakmap then * oops, pluck needs new object to go into * oops, make sure soul is passed * updating deprecated functions * begin AXE. Next: load balance! * Update sea.js * keys are dangerous! * AXE round robin load balance * better ash hash checking * lS reuse in-mem reply chunking * state machine!!! * RAD needs to pass cache misses. * updating deprecated functions (#1088) * update dependencies in package.json * updating deprecated functions * remove where.gundb.io * Bring SEA.certify into manhattan branch (#1092) Co-authored-by: Radu Cioienaru <radu@projectmanager.com> * fix rad, make get() hookable * rad browser tests seem to be passing! * reverse user random side, add err, update styles, + more * fix pack/max, update dom * paste! * of course it'll dedup cause it just called track on hear, fix * 📦 Adding the hub feature to this branch & improvements. (#1102) * 📦 Adding the hub feature to this branch. * 🗑 Removed the container for speed improvement ! * 📝 I added some comments to the code. Co-authored-by: Hector <fairfairytotor@gmail.com> Co-authored-by: Hector <pro.hector.kub@gmail.com> * Update axe.js * 🦅 Wrap everything in a try & catch for error handling… (#1105) * 🦅 Wrap everything in a try & catch for error handling & speed improvement. * 📦 Finally here : opt.file for the hub feature ! * 📦 Finally here : opt.file for the hub feature ! And also : fixed indentation 😋 Co-authored-by: noctisatrae <pro.hector.kub@gmail.com> * probs better this way, safer * moved test/axe tests to test/panic/axe. * New test: axe load balance. * axe test: webrtc data balance(fix paths and file renamed). * test axe: renaming webrtc file. * axe test: separating webrtc test for data_balance. * axe test: test only with the relay(without webrtc). * Update sea.js Same as https://github.com/amark/gun/pull/1062 * Update gun.js var tmp * Update upload.js * merge, update stun * SEA.certify wire logic + unit tests (#1110) * SEA.certify wire logic + unit tests * picking white hair * ack err * axe tests using puppeteer. * change stun system * ~20lines * put use parent soul link if need * handle errors * finally seems fixed * cb not to * relay * nasty bug! Don't crash, tho need to find what causes it * undo local changes/notes to self * deprecation warnings * "old" data to test against * oops, forgot I played with ascii * debug * in-prod check: sites * in-prod isolate * gotta find this, by stubbing out * where? * will this work? * clearly not, lol what's the point then? maybe like this * and again * must we? * USE THIS MANHATTAN VERSION * clean * better panic hints Co-authored-by: Robin Bron <finwo@pm.me> Co-authored-by: Pavel Diatchenko <diatche@users.noreply.github.com> Co-authored-by: rogowski <163828+rogowski@users.noreply.github.com> Co-authored-by: I001962 <i001962@gmail.com> Co-authored-by: Adriano Rogowski <rogowski.adriano@gmail.com> Co-authored-by: Radu <cetatuie@gmail.com> Co-authored-by: Radu Cioienaru <radu@projectmanager.com> Co-authored-by: Hector <46224745+noctisatrae@users.noreply.github.com> Co-authored-by: Hector <fairfairytotor@gmail.com> Co-authored-by: Hector <pro.hector.kub@gmail.com> Co-authored-by: Martti Malmi <sirius@iki.fi> Co-authored-by: mimiza <dev@mimiza.com>
379 lines
10 KiB
HTML
379 lines
10 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<!-- always start with these two lines to set a clean baseline for different devices -->
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link rel="stylesheet" type="text/css" href="style.css">
|
|
<script src="jquery.js"></script>
|
|
|
|
<title>Docs</title>
|
|
</head>
|
|
<body class="black whitet">
|
|
<style>
|
|
/*
|
|
Choose white text on a black background so you can add color in.
|
|
Pick your favorite font and choose a font size.
|
|
*/
|
|
@import url('https://fonts.googleapis.com/css?family=Oxygen');
|
|
html, body {
|
|
font-family: "Oxygen", sans-serif;
|
|
}
|
|
|
|
[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="margin-top: 9%;"></div>
|
|
</div>
|
|
|
|
<script src="../../gun/gun.js"></script>
|
|
<script src="../../gun/lib/monotype.js"></script>
|
|
<script src="../../gun/lib/meta.js"></script>
|
|
<script src="../../gun/lib/normalize.js"></script>
|
|
<script async src="../../gun/lib/fun.js"></script>
|
|
|
|
<script async src="../../gun/lib/wave.js"></script>
|
|
<!-- script async src="https://edide.io/music.lib"></script -->
|
|
|
|
<script>
|
|
var gun = Gun();
|
|
var page = {};
|
|
//var gun = Gun(['https://guntest.herokuapp.com/gun', 'http://localhost:8765/gun']);
|
|
|
|
;(window.onhashchange = function(){
|
|
var file = (location.hash||'').slice(1);
|
|
var S = +new Date;
|
|
$('#page').empty().attr('contenteditable', 'false');
|
|
gun.get('test/gun/docs/'+file).get('what').map().on(function render(data, i, msg, eve){
|
|
var tmp = page[i] || '';
|
|
var last = Gun.state.is(gun._.root.graph[msg.put['#']], i);
|
|
if(last < tmp.last){ return }
|
|
//});
|
|
//if(window.LOCK){ return }
|
|
var p = $('#page').children().get(i);
|
|
if(!p){
|
|
$('#page').append('<p>');
|
|
setTimeout(function(){ render(data, i, msg, eve) },0);
|
|
return;
|
|
}
|
|
var DBG = {s: +new Date};
|
|
var r = monotype(p);
|
|
DBG.mono = +new Date;
|
|
var safe = $.normalize(data);
|
|
DBG.norm = +new Date;
|
|
p.outerHTML = data;
|
|
DBG.html = +new Date;
|
|
r.restore();
|
|
DBG.rest = +new Date;
|
|
//console.log("mono:", DBG.mono - DBG.s, "norm:", DBG.norm - DBG.mono, 'html:', DBG.html - DBG.norm, 'rest:', DBG.rest - DBG.html, ':::', msg, eve);
|
|
});
|
|
})();
|
|
|
|
|
|
window.requestAnimationFrame = window.requestAnimationFrame || setTimeout;
|
|
window.requestAnimationFrame(function frame(){
|
|
window.requestAnimationFrame(frame, 16);
|
|
|
|
}, 16);
|
|
|
|
document.execCommand('defaultParagraphSeparator', false, 'p');
|
|
meta.edit({
|
|
name: "Edit",
|
|
combo: ['E'],
|
|
use: function(eve){
|
|
console.log('on');
|
|
}, on: function(eve){
|
|
if($(eve.target).closest('p').length){ return }
|
|
var edit = this;
|
|
setTimeout(function(){ meta.flip(false) },1);
|
|
edit.init();
|
|
$(document).on('keydown.tmp', '[contenteditable]', function(eve){
|
|
if(eve.which != 13){ return }
|
|
eve.preventDefault();
|
|
var r = window.getSelection().getRangeAt(0);
|
|
var c = r.commonAncestorContainer, p;
|
|
r.deleteContents();
|
|
var p = c.splitText? $(c.splitText(r.startOffset)).parent() : $(c);
|
|
var n = $("<"+p.get(0).tagName+">"), f;
|
|
p.contents().each(function(){
|
|
if(this === c){ return f = true }
|
|
if(!f){ return }
|
|
n.append(this);
|
|
});
|
|
p.after(n);
|
|
edit.select(n.get(0));
|
|
// make sure we re-save & sync each changed paragraph.
|
|
edit.save(p);
|
|
p.nextAll().each(function(){
|
|
edit.save(this);
|
|
});
|
|
}).on('keyup.tmp', '[contenteditable]', function(eve){
|
|
//$('#debug').val(doc.html());
|
|
var p = $(window.getSelection().anchorNode).closest('p'), tmp;
|
|
(tmp = page[p.index()] || (page[p.index()] = {})).last = (+new Date) + 99;
|
|
clearTimeout(tmp.to); tmp.to = setTimeout(function(){
|
|
var DBG = {s: +new Date};
|
|
var r = monotype(p);
|
|
DBG.m = +new Date;
|
|
var html = p.html() || '';
|
|
DBG.g = +new Date;
|
|
if(!html && !p.prev().length && !p.next().length && !$('#page').html()){
|
|
edit.init();
|
|
}
|
|
DBG.i = +new Date;
|
|
var safe = $.normalize(html);
|
|
DBG.n = +new Date;
|
|
p.html(safe);
|
|
DBG.h = +new Date;
|
|
r.restore();
|
|
DBG.r = +new Date;
|
|
edit.save(p);
|
|
DBG.p = +new Date;
|
|
//console.log("save:", DBG.p - DBG.r, "rest:", DBG.r - DBG.h, "html:", DBG.h - DBG.n, "norm:", DBG.n - DBG.i, 'init:', DBG.i - DBG.g, 'grab:', DBG.g - DBG.m, 'mono:', DBG.m - DBG.s);
|
|
},50)});
|
|
},
|
|
up: function(){
|
|
console.log("UP");
|
|
$('[contenteditable=true]').off('.tmp');
|
|
},
|
|
init: function(){
|
|
var edit = this;
|
|
var doc = $('#page').attr('contenteditable', 'true');
|
|
if(!doc.text()){
|
|
doc.html('<p class="loud crack"></p>');
|
|
}
|
|
edit.select(doc.children().first().get(0));
|
|
},
|
|
save: function(p){
|
|
p = $(p);
|
|
var i = p.index();// = Array.prototype.indexOf.call(parent.children, child);
|
|
var file = (location.hash||'').slice(1);
|
|
var data = (p.get(0)||{}).outerHTML||'';
|
|
//data = $.normalize(data); // GOOD TO DO SECURITY ON SENDING SIDE TOO!!!
|
|
window.LOCK = true;
|
|
gun.get('test/gun/docs/'+file).get('what').get(i).put(data);
|
|
window.LOCK = false;
|
|
},
|
|
select: function(p){
|
|
var s = window.getSelection(),
|
|
r = document.createRange();
|
|
if(p.innerHTML){
|
|
r.setStart(p, 0);
|
|
r.collapse(true);
|
|
s.removeAllRanges();
|
|
s.addRange(r);
|
|
return;
|
|
}
|
|
p.innerHTML = '\u00a0';
|
|
r.selectNodeContents(p);
|
|
s.removeAllRanges();
|
|
s.addRange(r);
|
|
document.execCommand('delete', false, null);
|
|
}
|
|
});
|
|
|
|
;(function(){
|
|
|
|
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: ['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: ['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>';
|
|
if(!on.children('.col').length){ html += html }
|
|
c = (tmp = on.append(html).children('.col')).length;
|
|
tmp.each(function(){
|
|
$(this).css('width', (100/c)+'%');
|
|
})
|
|
}
|
|
});
|
|
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(){
|
|
var logic = {};
|
|
|
|
meta.edit({name: "Logic", combo: ['L']});
|
|
|
|
meta.edit({name: "Symbol", combo: ['L','S'],
|
|
on: function(eve){
|
|
console.log(1);
|
|
}
|
|
});
|
|
meta.edit({name: "Action", combo: ['L','A'],
|
|
on: function(eve){
|
|
console.log(2);
|
|
}
|
|
});
|
|
meta.edit({name: "Data", combo: ['L','D'],
|
|
on: function(eve){
|
|
console.log(3);
|
|
}
|
|
});
|
|
}());
|
|
|
|
;(function(){
|
|
var song = {};
|
|
// TODO:
|
|
// 1. Manually OR automatically load music.js API, dependencies, and modules. - FINE for now
|
|
// 2. only export music API, not meta, not dom, not mouselock system, not UI/html, etc. better module isolation and export.
|
|
// 3. `var wave = Wave('a').play()` // also on `Music.now`
|
|
// defaults... instrument: pure tones, volume curve: |\_ , speed curve: 0.5
|
|
// 4. `wave.blur(0.5).itch(0.5);`
|
|
// 5. wave.long(2); // how long in seconds each note plays, optionally: wave.pace(60) is bpm
|
|
// 6. wave.loud(0.5); // 0% to 100% volume loudness of device output.
|
|
// 7. wave.vary(0.5); // slows down or speeds up wiggle per harmonic
|
|
// 8:
|
|
// wave structure, does ToneJS allow us to change the sine wave smoothness/type continuously or is it a pre-fixed type?
|
|
// wave structure: /\/\/, |_|, /|/, \|\| do some research with ToneJS whether these are dynamic or fixed
|
|
// wave.itch(); // changes the shape of the wiggle from smooth sine to square or triangle
|
|
// wave.blur(220hz); // blur may not apply/work on pure notes other than filtering them.
|
|
|
|
meta.edit({name: "Music", combo: ['M']});
|
|
|
|
meta.edit({name: "Play", combo: ['M','P'],
|
|
on: function(eve){
|
|
// TODO: We still need to add to meta API ability to change name.
|
|
if(song.play){
|
|
music.stop();
|
|
song.play = false;
|
|
return;
|
|
}
|
|
song.play = true;
|
|
music.stop();
|
|
setTimeout(function(){
|
|
song.now = wave($('#page').text()).play();
|
|
},250);
|
|
}
|
|
});
|
|
|
|
meta.edit({name: "Blur", combo: ['M','B'],
|
|
on: function(eve){
|
|
$(document).on('mousemove.tmp', function(eve){
|
|
var x = eve.pageX;
|
|
song.now.loud(x/$('body').innerWidth());
|
|
});
|
|
},
|
|
up: function(){
|
|
$(document).off('.tmp');
|
|
}
|
|
});
|
|
|
|
$(document).on('keydown', function(eve){
|
|
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
|
|
Logic
|
|
Symbol
|
|
Action
|
|
Data
|
|
*/
|
|
/*
|
|
|
|
*/
|
|
}());
|
|
</script>
|
|
</body>
|
|
</html> |