mirror of
https://github.com/amark/gun.git
synced 2025-06-16 02:56:40 +00:00
Update trace.html
More decoupled.
This commit is contained in:
parent
5f19570191
commit
4b656ad7e8
110
test/trace.html
110
test/trace.html
@ -74,15 +74,13 @@ body {
|
|||||||
background: black;
|
background: black;
|
||||||
color: white;
|
color: white;
|
||||||
padding: 0.3em;
|
padding: 0.3em;
|
||||||
top: 5em;
|
top: 7em;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="trace">
|
<div id="trace">
|
||||||
<h1>GUN internals</h1>
|
<h1>Gun Msg Trace</h1>
|
||||||
<!-- <h3>Chain Log</h3> -->
|
|
||||||
<!-- <div id="logschain"></div> -->
|
|
||||||
<h2></h2>
|
<h2></h2>
|
||||||
<div id="diagram"></div>
|
<div id="diagram"></div>
|
||||||
</div>
|
</div>
|
||||||
@ -98,70 +96,62 @@ body {
|
|||||||
<script>
|
<script>
|
||||||
;(function(){
|
;(function(){
|
||||||
// OVERLOAD GUN FUNCTIONS THAT WE WANT TO TRACE:
|
// OVERLOAD GUN FUNCTIONS THAT WE WANT TO TRACE:
|
||||||
var _get = Gun.on._get; Gun.on._get = function(a,b,c,d,e){ Gun._trace('GET', a); _get.call(this, a,b,c,d,e) }
|
|
||||||
var _put = Gun.on.put; Gun.on.put = function(a,b,c,d,e){ Gun._trace('PUT', a); _put.call(this, a,b,c,d,e) }
|
|
||||||
|
|
||||||
/*var get = Gun.chain.get; Gun.chain.get = function(a,b,c,d,e){ Gun._trace('.get', a); return get.call(this, a,b,c,d,e) }
|
/// GUN protocolo
|
||||||
var put = Gun.chain.put; Gun.chain.put = function(a,b,c,d,e){ Gun._trace('.put', a); return put.call(this, a,b,c,d,e) }
|
var _get = Gun.on._get; Gun.on._get = function(a,b,c,d,e){ Trace.log('GET', a); _get.call(this, a,b,c,d,e) } /// PROTOCOL
|
||||||
var on = Gun.chain.on; Gun.chain.on = function(a,b,c,d,e){ Gun._trace('.on', a); return on.call(this, a,b,c,d,e) }
|
var _put = Gun.on.put; Gun.on.put = function(a,b,c,d,e){ Trace.log('PUT', a); _put.call(this, a,b,c,d,e) } /// PROTOCOL
|
||||||
var map = Gun.chain.map; Gun.chain.map = function(a,b,c,d,e){ Gun._trace('.map', a); return map.call(this, a,b,c,d,e) }*/
|
|
||||||
var once = Gun.chain.once; Gun.chain.once = function(a,b,c,d,e){ Gun._trace('.once', a); return once.call(this, a,b,c,d,e) }
|
|
||||||
|
|
||||||
var input = Gun.on.in; Gun.on.in = function(a,b,c,d,e){ Gun._trace('in', a); input.call(this, a,b,c,d,e) }
|
/// GUN chain
|
||||||
|
// var get = Gun.chain.get; Gun.chain.get = function(a,b,c,d,e){ Trace.log('.get', a); return get.call(this, a,b,c,d,e) } /// chain
|
||||||
|
// var put = Gun.chain.put; Gun.chain.put = function(a,b,c,d,e){ Trace.log('.put', a); return put.call(this, a,b,c,d,e) } /// chain
|
||||||
|
// var map = Gun.chain.map; Gun.chain.map = function(a,b,c,d,e){ Trace.log('.map', a); return map.call(this, a,b,c,d,e) } /// chain
|
||||||
|
// var once = Gun.chain.once; Gun.chain.once = function(a,b,c,d,e){ Trace.log('.once', a); return once.call(this, a,b,c,d,e) } /// chain
|
||||||
|
// var on = Gun.chain.on; Gun.chain.on = function(a,b,c,d,e){ Trace.log('.on', a); return on.call(this, a,b,c,d,e) } /// chain
|
||||||
|
|
||||||
var output = Gun.on.out; Gun.on.out = function(a,b,c,d,e){ Gun._trace('out', a); output.call(this, a,b,c,d,e) }
|
/// GUN events
|
||||||
|
var input = Gun.on.in; Gun.on.in = function(a,b,c,d,e){ Trace.log('in', a); input.call(this, a,b,c,d,e) } /// EVENT
|
||||||
|
|
||||||
//var only = console.only; console.only = function(a,b,c,d,e,f,g){ Gun._trace('ONLY'); return only.apply(console,arguments) }
|
var output = Gun.on.out; Gun.on.out = function(a,b,c,d,e){ Trace.log('out', a); output.call(this, a,b,c,d,e) } /// EVENT
|
||||||
var start = +new Date;
|
|
||||||
setTimeout(function log(){
|
// var only = console.only; console.only = function(a,b,c,d,e,f,g){ Trace.log('ONLY'); return only.apply(console,arguments) }
|
||||||
if((+new Date - start) > 100){ return }
|
// var start = +new Date;
|
||||||
setTimeout(log, 0);
|
// setTimeout(function log(){
|
||||||
Gun._trace("ASYNC");
|
// if((+new Date - start) > 100){ return }
|
||||||
},0);
|
// setTimeout(log, 0);
|
||||||
|
// Trace.log("ASYNC");
|
||||||
|
// },0);
|
||||||
}());
|
}());
|
||||||
|
|
||||||
;(function(){ // PASTE YOUR UNIT TEST INTO HERE TO TRACE IT!
|
;(function(){ // PASTE YOUR UNIT TEST INTO HERE TO TRACE IT!
|
||||||
localStorage.clear();
|
// if (typeof localStorage!=='undefined') { localStorage.clear(); }
|
||||||
var goff = Gun();
|
// var goff = Gun();
|
||||||
Gun.statedisk = function(o,s,cb){
|
// Gun.statedisk = function(o,s,cb){ goff.get(s).put(o, cb, {turn: function(fn){fn()}}); };
|
||||||
goff.get(s).put(o, cb, {turn: function(fn){fn()}});
|
|
||||||
};
|
|
||||||
//Gun._trace('ONLY');
|
|
||||||
Gun._trace('GET');
|
|
||||||
Gun._trace('PUT');
|
|
||||||
Gun._trace('out');
|
|
||||||
Gun._trace('in');
|
|
||||||
//Gun._trace('.get');
|
|
||||||
Gun._trace('.once');
|
|
||||||
//Gun._trace('.put');
|
|
||||||
|
|
||||||
var gun = Gun();
|
var gun = Gun();
|
||||||
var bob = {age: 29, name: "Bob!"};
|
var bob = {age: 29, name: "Bob!"};
|
||||||
var cat = {name: "Fluffy", species: "kitty"};
|
var cat = {name: "Fluffy", species: "kitty"};
|
||||||
var user = {bob: bob};
|
var user = {bob: bob};
|
||||||
bob.pet = cat;
|
bob.pet = cat;
|
||||||
cat.slave = bob;
|
cat.slave = bob;
|
||||||
Gun.statedisk(user, 'nodecircle', function(){
|
Trace.log('START');
|
||||||
console.only.i=1;console.log("=============", gun);
|
// Gun.statedisk(user, 'nodecircle', function(){
|
||||||
//gun.get('nodecircle').get('bob').once(function(data){
|
console.only.i=1;console.log("=============", gun);
|
||||||
gun.get('nodecircle').get('bob').get('pet').get('slave').once(function(data){
|
|
||||||
console.log("*****************", data);//return;
|
// gun.get('nodecircle').put(user, function(ack) { Trace.log('ACK', ack); });
|
||||||
expect(done.to).to.not.be.ok();
|
// gun.get('nodecircle').on(function(ack) { Trace.log('END', ack); });
|
||||||
done.to = setTimeout(function(){
|
gun.get('nodecircle').once(function(ack) { Trace.log('END', ack); });
|
||||||
expect(data.age).to.be(29);
|
// gun.get('nodecircle').get('a').get('b').get('c').on(function(v,k){
|
||||||
expect(data.name).to.be("Bob!");
|
// gun.get('nodecircle').get('bob').on(function(v,k){
|
||||||
expect('string' == typeof Gun.valid(data.pet)).to.ok();
|
// gun.get('nodecircle').get('bob').get('pet').get('slave').once(function(v,k){
|
||||||
done();
|
// });
|
||||||
},300);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}());
|
}());
|
||||||
|
|
||||||
Gun.on('trace.end', function(msg){
|
// Gun.on('trace.end', function(msg){
|
||||||
var code = msg.code, id;
|
setTimeout(function(){
|
||||||
//console.log('_____TOTAL LOGS: ',Gun.traces.length, new Date());
|
console.log('_____TOTAL LOGS: ',Trace.traces.length, new Date());
|
||||||
$('h2:first').text(`Total of steps: ${Gun.traces.length}`);
|
var id, code = Trace.traces.join('\n');
|
||||||
$('title:first').text(`(${Gun.traces.length}) steps | Gun Msg Trace`);
|
$('h2:first').text(`Total of steps: ${Trace.traces.length}`);
|
||||||
|
$('title:first').text(`(${Trace.traces.length}) steps | Gun Msg Trace`);
|
||||||
var diagram = Diagram.parse(code);
|
var diagram = Diagram.parse(code);
|
||||||
diagram.drawSVG(id||'diagram', {theme: 'simple'});
|
diagram.drawSVG(id||'diagram', {theme: 'simple'});
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
@ -169,8 +159,8 @@ Gun.on('trace.end', function(msg){
|
|||||||
var pos = $(this).offset();
|
var pos = $(this).offset();
|
||||||
$("<span class='method'>").text($(this).text()).css({position: 'fixed', left: pos.left}).appendTo('body');
|
$("<span class='method'>").text($(this).text()).css({position: 'fixed', left: pos.left}).appendTo('body');
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
});
|
}, 2000);
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user