mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 18:52:19 +00:00
added graph checkNodeTypes
This commit is contained in:
@@ -147,8 +147,13 @@
|
|||||||
enumerable: true
|
enumerable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var prev = this.registered_node_types[type];
|
||||||
this.registered_node_types[type] = base_class;
|
this.registered_node_types[type] = base_class;
|
||||||
if (base_class.constructor.name) this.Nodes[classname] = base_class;
|
if (base_class.constructor.name) this.Nodes[classname] = base_class;
|
||||||
|
if(LiteGraph.onNodeTypeRegistered)
|
||||||
|
LiteGraph.onNodeTypeRegistered(type,base_class);
|
||||||
|
if( prev && LiteGraph.onNodeTypeReplaced)
|
||||||
|
LiteGraph.onNodeTypeReplaced(type,base_class,prev);
|
||||||
|
|
||||||
//warnings
|
//warnings
|
||||||
if (base_class.prototype.onPropertyChange)
|
if (base_class.prototype.onPropertyChange)
|
||||||
@@ -1165,6 +1170,34 @@
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks that the node type matches the node type registered, used when replacing a nodetype by a newer version during execution
|
||||||
|
* this replaces the ones using the old version with the new version
|
||||||
|
* @method checkNodeTypes
|
||||||
|
*/
|
||||||
|
LGraph.prototype.checkNodeTypes = function() {
|
||||||
|
var changes = false;
|
||||||
|
for (var i = 0; i < this._nodes.length; i++) {
|
||||||
|
var node = this._nodes[i];
|
||||||
|
var ctor = LiteGraph.registered_node_types[ node.type ];
|
||||||
|
if(node.constructor == ctor)
|
||||||
|
continue;
|
||||||
|
console.log("node being replaced by newer version: " + node.type );
|
||||||
|
var newnode = LiteGraph.createNode( node.type );
|
||||||
|
changes = true;
|
||||||
|
this._nodes[i] = newnode;
|
||||||
|
newnode.configure( node.serialize() );
|
||||||
|
newnode.graph = this;
|
||||||
|
this._nodes_by_id[newnode.id] = newnode;
|
||||||
|
if(node.inputs)
|
||||||
|
newnode.inputs = node.inputs.concat();
|
||||||
|
if(node.outputs)
|
||||||
|
newnode.outputs = node.outputs.concat();
|
||||||
|
}
|
||||||
|
this.updateExecutionOrder();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// ********** GLOBALS *****************
|
// ********** GLOBALS *****************
|
||||||
|
|
||||||
LGraph.prototype.onAction = function(action, param) {
|
LGraph.prototype.onAction = function(action, param) {
|
||||||
|
|||||||
Reference in New Issue
Block a user