Socket
Socket
Sign inDemoInstall

node-codein

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

libraries/dragscrollable.js

36

debugger.js

@@ -5,4 +5,6 @@ var file_exists = function(f){ try{ require('fs').lstatSync(f); return true; }catch(e){ return false; }};

var get_constr = function(v){ return(v===null)?"[object Null]":Object.prototype.toString.call(v); };
// var fnprefix = (["FUNCTION"].concat(process.hrtime()).concat(process.hrtime())).join('.'); // ONLY WORKS IN LATER Vs
var fnprefix = 'TYPE_FUNC_'+(new Date().getTime());
var jsencr = function(o){ var e = []; return JSON.stringify(o, function(k,v){
if(typeof(v)==='function') return v.toString();
if(typeof(v)==='function') return fnprefix+v.toString();
if(typeof(v)!=='object' || v===null) return v;

@@ -116,2 +118,3 @@ for(var i in e){ if(e[i]===v){ return "Circular"; }};

case 'sse':
q.socket.setTimeout(0);
var thiscon = dbg.cons.push(s);

@@ -139,18 +142,21 @@ break;

execute: function(q,s){
var b = '';
q.on('data', function(c){ b+=c; });
var post = '';
q.on('data', function(c){ post+=c; });
q.on('end', function(){
b = require('querystring').parse(b);
if(typeof(b.command)==='string'){
post = require('querystring').parse(post);
if(typeof(post.command)==='string'){
var r = {error:false};
try{
r.cnt = eval(b.command);
r.type = (typeof(r.cnt)==='object' && r.cnt!==null) ? get_constr(r.cnt) : typeof(r.cnt);
r.fnprefix = fnprefix;
r.cnt = eval.apply(global, [post.command]);
r.type = (typeof(r.cnt)==='object' && r.cnt!==null) ?
get_constr(r.cnt) :
typeof(r.cnt);
}catch(e){ r.error=e.toString(); }
s.end(jsencr(r));
} else if(typeof(b.getsug)==='string'){
} else if(typeof(post.getsug)==='string'){
try{ var r = jsencr(dbg.getsug(JSON.parse(b.getsug))); }
try{ var r = jsencr(dbg.getsug(JSON.parse(post.getsug))); }
catch(e){ var r = "[]"; }

@@ -179,6 +185,6 @@

if(typeof(o[0])!=='string' || o[0]===''){
if(typeof(module)=='object') for(var i in module){
/* if(typeof(module)=='object') for(var i in module){
if(o[1]===''){ r.push(i); continue; };
if(i.split(o[1])[0]==='') r.push(i);
}
}; */

@@ -188,3 +194,3 @@ for(var i in global){

if(i.split(o[1])[0]==='') r.push(i);
}
};
}else{try{

@@ -214,4 +220,4 @@ var tgt = eval(o[0]); if(typeof(tgt)!=='object') return r;

process.on('uncaughtException', function (e) {console.error.call(console, e.toString()); });
process.on('uncaughtException', function (e) {console.error.call(console, e + ""); });
global.nodecodein = module;
},

@@ -239,3 +245,3 @@

dbg.consolewrap();
process.on('exit', function(){ try{dbg.sv.close();}catch(e){}; });
process.on('exit', function(){ console.log('Closing debug server'); try{dbg.sv.close();}catch(e){}; });
}

@@ -242,0 +248,0 @@

@@ -6,3 +6,3 @@ {

"keywords": ["console","inspect","inspector","object","tree","outline","viewer","debug","debugger","webkit","runtime","eval"],
"version": "1.0.0",
"version": "1.0.1",
"homepage": "https://github.com/ketamynx/node-codein",

@@ -9,0 +9,0 @@ "repository": {

@@ -8,6 +8,7 @@ <h1>NodeJS Console Object Debug Inspector </h1>

<h2>License</h2>
<p>Released under MIT License (included)</p>
<p>Released under MIT License (included); some components have their own licenses but I kept all the comments in their headers so if you're a really really boring person (lawyer, attorney, prosecutor, whatever) you can check the files under libraries/.</p>
<h2>Minimum requirements</h2>
<p>NodeJS v0.8.0+, Chrome 19.xx.xxxx.xx+, Win XP+</p>
<h2>Requirements</h2>
<p>Recommended: NodeJS v0.8.0+, Chrome 19.xx.xxxx.xx+ <br />
Minimum: any OS that supports a browser that supports javascript (my Nokia N8 almost worked lol)</p>
<h2>Deployment instructions</h2>

@@ -24,5 +25,14 @@ <ol>

<h2>Changelog</h2>
<ul>
<li> <b>v1.0.1</b> <br /><ul>
<li> removed the buggy, CPU-clogging jsTree</li>
<li> updated UI colors </li>
<li> modified small real-estate features </li>
<li> added progressive rendering </li>
<li> exposed the whole module on <b>global.nodecodein</b> </li>
</ul> </li>
</ul>
<h2>Main features</h2>
<ul>

@@ -72,4 +82,3 @@ <li>Displays objects in tree format, with expand/collapse controls</li>

<li>typing suggestions and autocomplete</li>
<li>double-click a property name in the message window to insert it</li>
<li>shit+enter for new lines </li>
<li>shift+enter for new lines </li>
<li>tab key indents</li>

@@ -80,22 +89,24 @@ </ul>

<h2>Known bugs</h2>
<p>Lots of them. Because I had to took a day off from work to build this, so there's was no time to organize nor bughunt.</p>
<h2>Known limitations</h2>
<ul>
<li>Console log may not pass through every now and again or so. I planned on using EventSource but it wasn't working (maybe buffering instead of flushing, I don't know, can't WireShark locally). So what it does is it keeps connections in a waiting state and when it gets something, it writes and closes those connections. Then clients are supposed to connect back. </li>
<li>Console log sometimes doesn't pass data (rarely... very... rarely). I planned on using EventSource but didn't stick to it because one end doesn't buffer the response and there's no flush command like in PHP. So what it does instead is it keeps connections in a waiting state and when it gets something, it writes the response, closing those connections. Then clients will automatically reconnect but in that split-second if there is any pre-connected client (as in managed to connect before any others), that client will get the logs and those who connected the millisecond later, won't get anything. </li>
<li>Autocomplete spams your server. Lag is in place and can be tweaked but it'll basically chop-off words when you hit enter.</li>
<li>iScroll + expand all + ctrl+f to find properties will lock the whole browser; not sure why, don't care much, just disable iScroll if you're using this tecnhique to find properties.</li>
<li>Autocomplete may not appear after using left / right arrow keys or escape. This is intentional, those 3 keys are GTFO master keys, but if you want the list of suggestions back, type some gibberish and press backspace.</li>
<li>The whole source code is haywired.</li>
<li>Autocomplete may not appear after using left / right arrow keys or escape. This is intentional, because those 3 keys are GTFO master keys, but if you want the list of suggestions back, type some gibberish and press backspace.</li>
<li>The whole source code is haywired or almost haywired.</li>
<li>There's no syntax highlighting on the input. It will generate lags.</li>
</ul>
<h2>FAQ</h2>
<ul><li><b>What's wrong about the regular console?</b><br />
Its overall buffer size, no syntax coloring, hard to use, no direct input, so forth. If you're familar to webkit's &quot;Inspect Element&quot; console tab, you'll see the differences.</li>
<ul><li><b>Where are the variables from my own module? / How do I debug my module?</b><br />
This console normally doesn't see them, as it doesn't see scoped (private) variables. Take it as a javascript security feature. But you can always assign them to an object (like "module") and make that object global. (module.variable = ...; global.MyModule = module)
</li>
<li><b>What's wrong about the regular console?</b><br />
Its overall buffer size, no syntax coloring, hard to use, no direct input, so forth. If you're familar to webkit's &quot;Inspect Element&quot; console tab, you'll see there are some differences.</li>
<li><b>Then what's wrong with Eclipse's V8 Debugger?</b><br />
A debugger is something totally different. Well not really but you still need to set breakpoints, stop executions, scope variables, etc. Plus you have to restart Node to put code in. I can make more excuses if necessary. </li>
<li><b>Why not just fix node-inspector?</b><br />
I tried. I first tried to pass back stringified objects and decode them in the local console. The problem was that there was a hardcoded limit of 80 characters beyond which the string turned into &quot;str... (length: 2219)&quot;. I'm not sure where this came from but I believe it was built into v8 when it was compiled with Node. I also tried fixing the 0:0:0 (context:scope:handle) but it seemed to pass back blank values no matter what. I didn't had time for that.</li>
I tried. I first tried to pass back stringified objects and decode them in the local console. The problem was that there was a hardcoded limit of 80 characters beyond which the string turned into &quot;str... (length: 2219)&quot;. I'm not sure where this came from but I believe it was built into v8 when it was compiled with Node. I also tried fixing scope:frame:handle problem but it seemed to pass back zeros no matter what. </li>
<li><b>Can you help me do X / can you add X / can you fix X?</b><br />
I'll do everything that doesn't take more than 5 minutes to do. I'm really in a time crisis, but even if I wasn't, I'm highly capitalistic about all my work. </li>
Open an issue here on GitHub, 3rd row, 4th button (or something like that), and let's have a look</li>
</ul>

@@ -102,0 +113,0 @@

@@ -10,12 +10,6 @@ function is_numeric(mixed_var){return(typeof(mixed_var)==='number'||typeof(mixed_var)==='string')&&mixed_var!==''&&!isNaN(mixed_var);}

var c = $('#command');
var vw = $('#output_viewer');
var vwr = $('#output_wrappr');
var vwscr = {scrollTo:function(x,y){ vwr.scrollTop(Math.abs(y)); vwr.scrollLeft(Math.abs(x)); }};
var dvwscr = {
refresh:function(){}, destroy:function(){ return null; }, disable:function(){},
scrollTo:function(x,y){ vwr.scrollTop(Math.abs(y)); vwr.scrollLeft(Math.abs(x)); }};
var vwscr = dvwscr;
var vwscrint = 0;
var encd = function(v){ return $('<div />').text(v).html();};

@@ -27,3 +21,3 @@ var decd = function(v){ return $('<div />').html(v).text();};

var treefiy_obj = function(o, n, c){
var r = { data:"<span class='fn'>" + n + "</span>", state:!!c ? 'open' : 'closed', children:[] };
var r = { data:"<span class='fn' title='"+n+"'>"+n+"</span>", state:!!c ? 'open' : 'closed', children:[] };
for(var i in o){

@@ -35,11 +29,11 @@ if(typeof(o[i])==='object' && o[i]!==null)

// if(val.length>100) val = '<span>'+val.substr(0,100)+'... (length: '+val.length+')</span>';
o[i] = "<span class='fn'>"+i+"</span>: &nbsp; <span class='undef'>"+val+'</span>';
}
o[i] = "<span class='fn' title='"+i+"'>"+i+"</span><span class='undef'>"+val+'</span>';
};
r.children.push(o[i]);
};
return r;
}
};
window.focusLastMessage = function(){ vwscr.scrollTo(0,vw.height()); };
window.showAnError = function(err, type){

@@ -49,74 +43,21 @@ if(typeof(type)!=='string') type='error';

resp.html(' <span class="eicon">W</span> '+encd(err));
vwscr.refresh();
vwscr.scrollTo(0,-1*vw.height());
focusLastMessage();
};
window.showAResponse = function(r, expand){
window.showAResponse = function(r){
var resp = $('<div class="output"></div>').appendTo(vw);
var tpo = typeof(r.cnt);
if(typeof(r.fnprefix)==='string') window.fnprefix = r.fnprefix;
if(r.cnt===null) tpo = 'null';
switch(tpo){
case 'null':
case 'undefined':
resp.addClass('undef').html(tpo);
case 'object':
createTreeFromObj({'[object Object]':r.cnt}, $('.autoexpand').is('.sel')).appendTo(resp);
break;
case 'boolean':
case 'number':
resp.addClass(tpo).html(typeof(r.cnt)!=='boolean' ? r.cnt : (!!r.cnt ? 'true' : 'false'));
break;
case 'string':
resp.html('"<span class="str">' + encd(r.cnt) + '</span>"');
break;
default:
var nobj = $.extend(true, {}, r.cnt);
nobj = treefiy_obj(nobj, r.type, $('.autoexpand').is('.sel') || !!expand);
resp.addClass('obj').jstree({
sort:function(x,y){ var a=$(x).text(); var b=$(y).text(); return a>b? 1 : (a<b ? -1 : 0); },
core:{animation:0,'html_titles' : true},
json_data:{ data: nobj, ajax:false },
ui:{select_limit:0},
themes:{url:'./style.jstree.css', theme:'classic', icons:false, dots:true},
plugins: ['themes','json_data','sort','ui'],
onselect: function(n, t) { t.toggle_branch(n);}
}).delegate(".jstree-open>a", "click.jstree", function(event){
if($('.dotstruct').is('.sel'))
$.jstree._reference(this).close_node(this,false,false);
vwscr.refresh();
}).delegate(".jstree-closed>a", "click.jstree", function(event){
if($('.dotstruct').is('.sel'))
$.jstree._reference(this).open_node(this,false,false);
vwscr.refresh();
}).bind("dblclick.jstree", function (event) {
var how = $.cookie(NS+'dotstruct');
if(typeof(how)==null || (typeof(how)==='string' && how.toString()==='no')) return;
var node = $(event.target).closest("li");
var sel = "> a > span.fn";
var address = node.find(sel).toArray().concat(node.parents('li').find(sel).toArray());
address.reverse();
if(address.length<2) return;
address[0] = '';
var r = "";
$(address).each(function(){
var t = $(this).text();
if(!t.length || !trim(t).length) return;
if(is_numeric(t.charAt(0))) r+='["'+t+'"]';
else r+='.'+t;
});
commandInsertVal(r);
});
$(formatStaticValue(r.cnt,false)).appendTo(resp);
break;
}
// if(typeof(r.type)=='string' && r.type!=='') resp.attr("title",r.type);
setTimeout(function(){
resp.find('a[href=#]').removeAttr('href');
vwscr.refresh();
vwscr.scrollTo(0,-1*vw.height());
},60);
};
focusLastMessage();
};

@@ -134,5 +75,7 @@

var readd = $('<div class="cli"></div>').appendTo(vw)
readd.html(encd(v));
// readd.click(function(){c.focus().val(v);});
var insertOriginalCommand = function(){
var readd = $('<div class="cli"></div>').appendTo(vw)
readd.html(encd(v));
// readd.click(function(){c.focus().val(v);});
}

@@ -143,8 +86,11 @@ var p = $.cookie(NS+'preserve');

try{ var pa = JSON.parse(r.responseText); }catch(e){
return showAnError('Failed to parse response ('+e+')') ;
insertOriginalCommand ();
showAnError('Failed to parse response ('+e+')') ;
};
if(typeof(pa.error)==='string') return showAnError('ERROR: ('+pa.error+')');
return showAResponse(pa);
if(typeof(pa.error)==='string') return showAnError(pa.error);
insertOriginalCommand();
showAResponse(pa);
}});

@@ -180,3 +126,2 @@ };

$('#output_wrappr').height( $('#wrap').height()-nsr );
vwscr.refresh();
};

@@ -190,9 +135,2 @@ window.onresize = function(){ doResizeWin(); };

// INITIALIZE JQTREE & CO.
$('<div />').hide().jstree({
json_data:{data:{data:'',children:[]},ajax:false},
themes:{url:'./style.jstree.css', theme:'classic',icons:0, dots:0},
plugins: ['themes','json_data','sort','ui']})
// ISCROLL

@@ -203,14 +141,12 @@ var iscr = $('.iScroll');

if(null==how || how.toString()!=='yes'){
$('#output_wrappr').removeClass('dragscrollable');
iscr.removeClass('sel').text('Scrolling');
vwscr.disable();
vwscr = vwscr.destroy();
vwscr = dvwscr;
clearInterval(vwscrint);
$('#output_wrappr').css({'overflow': 'auto'});
vw.removeAttr('style');
$('#output_wrappr').unbind();
$('#output_viewer').unbind();
}else{
$('#output_wrappr').scrollTop(0).scrollLeft(0);
$('#output_wrappr').addClass('dragscrollable');
iscr.addClass('sel').text('Panning'); ;
vwscr = new iScroll('output_wrappr',{fadeScrollbar:1,hideScrollbar:1,wheelAction:'none'});
vwscrint = setInterval(function(){ vwscr.refresh(); }, 2000);
$('#output_wrappr').css({'overflow': 'hidden'});
$('#output_wrappr').dragscrollable({dragSelector: '#output_viewer', acceptPropagatedEvent: true});
}

@@ -222,3 +158,5 @@ };

}); actiscr();
// setTimeout(function(){ window.showAResponse({fnprefix:'FUNCTION_A_A', tpo:'object', cnt:{ string:'Some string', fn:function(){}, fn1:'FUNCTION_A_A'+'function(){ blabla; }', numb:1234, inf:NaN, tru:true,fal:false } }); },500);
});

@@ -1,3 +0,3 @@

$(document).ready(function(){
$(document).ready(function(){ setTimeout(function(){
var constat = $('.constat');

@@ -59,3 +59,3 @@ var conmsg = constat.find('.msg');

reconnect();
});
}, 1000); });

@@ -64,3 +64,3 @@ $(document).ready(function(){

var el = $("<li />");
el.text(data[i]); if(i==0) el.addClass('sel');
el.text(data[i]); // if(i==0) el.addClass('sel');
el.attr('ins', data[i].replace(part,''));

@@ -103,3 +103,3 @@ el.click(function(){ insertVal($(this).attr('ins')); });

if(ISENT){
if(!curpos.length) return;
if(!curpos.length) return hideSug();
curpos.trigger('click');

@@ -106,0 +106,0 @@ }

@@ -65,3 +65,3 @@ $(document).ready(function(){

$('.clear-console').click(function(){ return clearConsole(); });
$('.clear-console').click(function(){ clearConsole(); focusLastMessage(); });
$('.ui-resizable-n').on('dblclick', function(){ swa.click(); });

@@ -90,4 +90,14 @@ $('.reload').click(function(){ return window.location.reload(); });

$('.expand-all').click(function(){ vw.find('.jstree-closed > .jstree-icon').click(); });
$('.collapse-all').click(function(){ vw.find('.jstree-open > .jstree-icon').click(); });
$('.expand-all').click(function(){
var acoll = vw.find('.arrow-collapsed');
while(acoll.length){
acoll.click();
acoll = vw.find('.arrow-collapsed');
};
});
$('.collapse-all').click(function(){
vw.find('.arrow-expanded').click();
vw.find('.expandable > .object').remove();
focusLastMessage();
});

@@ -99,2 +109,2 @@ t_sw.click(function(){

});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc