diff --git a/build/litegraph.js b/build/litegraph.js index 0eb78a211..53e255dd0 100644 --- a/build/litegraph.js +++ b/build/litegraph.js @@ -1055,6 +1055,12 @@ LGraphNode.prototype.getInputData = function(slot) return null; } +LGraphNode.prototype.isInputConnected = function(slot) +{ + if(!this.inputs) return null; + return (slot < this.inputs.length && this.inputs[slot].link != null); +} + LGraphNode.prototype.getInputInfo = function(slot) { if(!this.inputs) return null; @@ -1072,6 +1078,12 @@ LGraphNode.prototype.getOutputInfo = function(slot) return null; } +LGraphNode.prototype.isOutputConnected = function(slot) +{ + if(!this.outputs) return null; + return (slot < this.outputs.length && this.outputs[slot].links && this.outputs[slot].links.length); +} + LGraphNode.prototype.getOutputNodes = function(slot) { if(!this.outputs || this.outputs.length == 0) return null; @@ -1796,6 +1808,8 @@ LGraphNode.prototype.trace = function(msg) if(!this.console) this.console = []; this.console.push(msg); + if(this.console.length > LGraphNode.MAX_CONSOLE) + this.console.shift(); this.graph.onNodeTrace(this,msg); } diff --git a/build/litegraph.min.js b/build/litegraph.min.js index 835367380..f7c4d74f2 100644 --- a/build/litegraph.min.js +++ b/build/litegraph.min.js @@ -23,9 +23,10 @@ function LGraphNode(a){this.name=a||"Unnamed";this.size=[LiteGraph.NODE_WIDTH,60 LGraphNode.prototype.objectivize=function(){var a={id:this.id,name:this.name,type:this.type,pos:this.pos,size:this.size,data:this.data,properties:jQuery.extend({},this.properties),flags:jQuery.extend({},this.flags),inputs:this.inputs,outputs:this.outputs};a.type||(a.type=this.constructor.type);this.color&&(a.color=this.color);this.bgcolor&&(a.bgcolor=this.bgcolor);this.boxcolor&&(a.boxcolor=this.boxcolor);this.shape&&(a.shape=this.shape);return a}; LGraphNode.prototype.reducedObjectivize=function(){var a=this.objectivize(),b=LiteGraph.getNodeType(a.type);b.name==a.name&&delete a.name;b.size&&compareObjects(a.size,b.size)&&delete a.size;b.properties&&compareObjects(a.properties,b.properties)&&delete a.properties;return a};LGraphNode.prototype.serialize=function(){if(this.onSerialize)this.onSerialize();return JSON.stringify(this.reducedObjectivize())}; LGraphNode.prototype.setOutputData=function(a,b){if(this.outputs&&-1a&&this.pos[1]-cb)return!0;return!1};LGraphNode.prototype.findInputSlot=function(a){if(!this.inputs)return-1;for(var b=0,c=this.inputs.length;bLGraphNode.MAX_CONSOLE&&this.console.shift();this.graph.onNodeTrace(this,a)};LGraphNode.prototype.setDirtyCanvas=function(a,b){this.graph&&this.graph.canvas&&(a&&(this.graph.canvas.dirty_canvas=!0),b&&(this.graph.canvas.dirty_bgcanvas=!0))}; +LGraphNode.prototype.loadImage=function(a){var b=new Image;b.src=LiteGraph.node_images_path+a;b.ready=!1;var c=this;b.onload=function(){this.ready=!0;c.setDirtyCanvas(!0)};return b}; LGraphNode.prototype.executeAction=function(a){if(""==a)return!1;if(-1!=a.indexOf(";")||-1!=a.indexOf("}"))return this.trace("Error: Action contains unsafe characters"),!1;var b=a.split("(")[0];if("function"!=typeof this[b])return this.trace("Error: Action not found on node: "+b),!1;try{b=eval,eval=null,(new Function("with(this) { "+a+"}")).call(this),eval=b}catch(c){return this.trace("Error executing action {"+a+"} :"+c),!1}return!0}; LGraphNode.prototype.captureInput=function(a){this.graph&&this.graph.canvas&&(a||this.graph.canvas.node_capturing_input==this)&&(this.graph.canvas.node_capturing_input=a?this:null,this.graph.debug&&console.log(this.name+": Capturing input "+(a?"ON":"OFF")))};LGraphNode.prototype.collapse=function(){this.flags.collapsed=this.flags.collapsed?!1:!0;this.setDirtyCanvas(!0,!0)};LGraphNode.prototype.pin=function(){this.flags.pinned=this.flags.pinned?!1:!0}; LGraphNode.prototype.localToScreen=function(a,b){return[(a+this.pos[0])*this.graph.config.canvas_scale+this.graph.config.canvas_offset[0],(b+this.pos[1])*this.graph.config.canvas_scale+this.graph.config.canvas_offset[1]]}; diff --git a/src/litegraph.js b/src/litegraph.js index 9ac2d5c1e..c6ed3420a 100644 --- a/src/litegraph.js +++ b/src/litegraph.js @@ -1054,6 +1054,12 @@ LGraphNode.prototype.getInputData = function(slot) return null; } +LGraphNode.prototype.isInputConnected = function(slot) +{ + if(!this.inputs) return null; + return (slot < this.inputs.length && this.inputs[slot].link != null); +} + LGraphNode.prototype.getInputInfo = function(slot) { if(!this.inputs) return null; @@ -1071,6 +1077,12 @@ LGraphNode.prototype.getOutputInfo = function(slot) return null; } +LGraphNode.prototype.isOutputConnected = function(slot) +{ + if(!this.outputs) return null; + return (slot < this.outputs.length && this.outputs[slot].links && this.outputs[slot].links.length); +} + LGraphNode.prototype.getOutputNodes = function(slot) { if(!this.outputs || this.outputs.length == 0) return null; @@ -1795,6 +1807,8 @@ LGraphNode.prototype.trace = function(msg) if(!this.console) this.console = []; this.console.push(msg); + if(this.console.length > LGraphNode.MAX_CONSOLE) + this.console.shift(); this.graph.onNodeTrace(this,msg); }