mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-26 01:09:46 +00:00
fixes
This commit is contained in:
@@ -49,6 +49,7 @@ var LiteGraph = global.LiteGraph = {
|
||||
|
||||
ALWAYS: 0,
|
||||
ON_EVENT: 1,
|
||||
ON_TRIGGER: 1, //the same
|
||||
NEVER: 2,
|
||||
|
||||
proxy: null, //used to redirect calls
|
||||
@@ -279,7 +280,7 @@ var LiteGraph = global.LiteGraph = {
|
||||
{
|
||||
if( !type_a || //generic output
|
||||
!type_b || //generic input
|
||||
type_a == type_a || //same type (is valid for triggers)
|
||||
type_a == type_b || //same type (is valid for triggers)
|
||||
(type_a !== LiteGraph.EVENT && type_b !== LiteGraph.EVENT && type_a.toLowerCase() == type_b.toLowerCase()) ) //same type
|
||||
return true;
|
||||
return false;
|
||||
@@ -1197,7 +1198,7 @@ LGraph.prototype.serialize = function()
|
||||
for(var i in this.links) //links is an OBJECT
|
||||
{
|
||||
var link = this.links[i];
|
||||
links.push([ link.id, link.origin_id, link.origin_slot, link.target_id, link.target_slot ]);
|
||||
links.push([ link.id, link.origin_id, link.origin_slot, link.target_id, link.target_slot, link.type ]);
|
||||
}
|
||||
|
||||
var data = {
|
||||
@@ -1233,7 +1234,7 @@ LGraph.prototype.configure = function(data, keep_old)
|
||||
for(var i = 0; i < data.links.length; ++i)
|
||||
{
|
||||
var link = data.links[i];
|
||||
links[ link[0] ] = { id: link[0], origin_id: link[1], origin_slot: link[2], target_id: link[3], target_slot: link[4] };
|
||||
links[ link[0] ] = { id: link[0], origin_id: link[1], origin_slot: link[2], target_id: link[3], target_slot: link[4], type: link[5] };
|
||||
}
|
||||
data.links = links;
|
||||
}
|
||||
@@ -1606,6 +1607,10 @@ LGraphNode.prototype.setOutputData = function(slot, data)
|
||||
if(!this.outputs)
|
||||
return;
|
||||
|
||||
//this maybe slow and a niche case
|
||||
//if(slot && slot.constructor === String)
|
||||
// slot = this.findOutputSlot(slot);
|
||||
|
||||
if(slot == -1 || slot >= this.outputs.length)
|
||||
return;
|
||||
|
||||
@@ -1644,6 +1649,8 @@ LGraphNode.prototype.getInputData = function( slot, force_update )
|
||||
|
||||
var link_id = this.inputs[slot].link;
|
||||
var link = this.graph.links[ link_id ];
|
||||
if(!link) //bug: weird case but it happens sometimes
|
||||
return null;
|
||||
|
||||
//used to extract data from the incomming connection
|
||||
if(!force_update)
|
||||
@@ -1806,36 +1813,56 @@ LGraphNode.prototype.trigger = function( action, param )
|
||||
|
||||
for(var i = 0; i < this.outputs.length; ++i)
|
||||
{
|
||||
var output = this.outputs[i];
|
||||
if(output.type !== LiteGraph.EVENT || (action && output.name != action) )
|
||||
var output = this.outputs[ slot ];
|
||||
if(!output || output.type !== LiteGraph.EVENT || (action && output.name != action) )
|
||||
continue;
|
||||
this.triggerSlot( slot, param );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers an slot event in this node
|
||||
* @method triggerSlot
|
||||
* @param {Number} slot the index of the output slot
|
||||
* @param {*} param
|
||||
*/
|
||||
LGraphNode.prototype.triggerSlot = function( slot, param )
|
||||
{
|
||||
if( !this.outputs )
|
||||
return;
|
||||
|
||||
var output = this.outputs[ slot ];
|
||||
if( !output )
|
||||
return;
|
||||
|
||||
var links = output.links;
|
||||
if(!links || !links.length)
|
||||
return;
|
||||
|
||||
if(this.graph)
|
||||
this.graph._last_trigger_time = LiteGraph.getTime();
|
||||
|
||||
//for every link attached here
|
||||
for(var k = 0; k < links.length; ++k)
|
||||
{
|
||||
var link_info = this.graph.links[ links[k] ];
|
||||
if(!link_info) //not connected
|
||||
continue;
|
||||
var node = this.graph.getNodeById( link_info.target_id );
|
||||
if(!node) //node not found?
|
||||
continue;
|
||||
|
||||
var links = output.links;
|
||||
if(!links || !links.length)
|
||||
continue;
|
||||
//used to mark events in graph
|
||||
link_info._last_time = LiteGraph.getTime();
|
||||
|
||||
//for every link attached here
|
||||
for(var k = 0; k < links.length; ++k)
|
||||
var target_connection = node.inputs[ link_info.target_slot ];
|
||||
|
||||
if(node.onAction)
|
||||
node.onAction( target_connection.name, param );
|
||||
else if(node.mode === LiteGraph.ON_TRIGGER)
|
||||
{
|
||||
var link_info = this.graph.links[ links[k] ];
|
||||
if(!link_info) //not connected
|
||||
continue;
|
||||
var node = this.graph.getNodeById( link_info.target_id );
|
||||
if(!node) //node not found?
|
||||
continue;
|
||||
|
||||
//used to mark events in graph
|
||||
link_info._last_time = LiteGraph.getTime();
|
||||
|
||||
var target_connection = node.inputs[ link_info.target_slot ];
|
||||
|
||||
if(node.onAction)
|
||||
node.onAction( target_connection.name, param );
|
||||
else if(node.mode === LiteGraph.ON_TRIGGER)
|
||||
{
|
||||
if(node.onExecute)
|
||||
node.onExecute(param);
|
||||
}
|
||||
if(node.onExecute)
|
||||
node.onExecute(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2342,6 +2369,8 @@ LGraphNode.prototype.disconnectOutput = function( slot, target_node )
|
||||
{
|
||||
var link_id = output.links[i];
|
||||
var link_info = this.graph.links[ link_id ];
|
||||
if(!link_info) //bug: it happens sometimes
|
||||
continue;
|
||||
|
||||
var target_node = this.graph.getNodeById( link_info.target_id );
|
||||
var input = null;
|
||||
@@ -2349,10 +2378,10 @@ LGraphNode.prototype.disconnectOutput = function( slot, target_node )
|
||||
{
|
||||
input = target_node.inputs[ link_info.target_slot ];
|
||||
input.link = null; //remove other side link
|
||||
if(target_node.onConnectionsChange)
|
||||
target_node.onConnectionsChange( LiteGraph.INPUT, link_info.target_slot, false, link_info, input ); //link_info hasnt been modified so its ok
|
||||
}
|
||||
delete this.graph.links[ link_id ]; //remove the link from the links pool
|
||||
if(target_node.onConnectionsChange)
|
||||
target_node.onConnectionsChange( LiteGraph.INPUT, link_info.target_slot, false, link_info, input ); //link_info hasnt been modified so its ok
|
||||
if(this.onConnectionsChange)
|
||||
this.onConnectionsChange( LiteGraph.OUTPUT, slot, false, link_info, output );
|
||||
}
|
||||
@@ -3048,7 +3077,8 @@ LGraphCanvas.prototype.getCanvasWindow = function()
|
||||
*/
|
||||
LGraphCanvas.prototype.startRendering = function()
|
||||
{
|
||||
if(this.is_rendering) return; //already rendering
|
||||
if(this.is_rendering)
|
||||
return; //already rendering
|
||||
|
||||
this.is_rendering = true;
|
||||
renderFrame.call(this);
|
||||
|
||||
Reference in New Issue
Block a user