mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 03:01:54 +00:00
Option to use UUIDs instead of integers for node IDs
This commit is contained in:
@@ -142,6 +142,10 @@
|
|||||||
|
|
||||||
ctrl_shift_v_paste_connect_unselected_outputs: false, //[true!] allows ctrl + shift + v to paste nodes with the outputs of the unselected nodes connected with the inputs of the newly pasted nodes
|
ctrl_shift_v_paste_connect_unselected_outputs: false, //[true!] allows ctrl + shift + v to paste nodes with the outputs of the unselected nodes connected with the inputs of the newly pasted nodes
|
||||||
|
|
||||||
|
// if true, all newly created nodes/links will use string UUIDs for their id fields instead of integers.
|
||||||
|
// use this if you must have node IDs that are unique across all graphs and subgraphs.
|
||||||
|
use_uuids: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a node class so it can be listed when the user wants to create a new one
|
* Register a node class so it can be listed when the user wants to create a new one
|
||||||
* @method registerNodeType
|
* @method registerNodeType
|
||||||
@@ -601,6 +605,13 @@
|
|||||||
return target;
|
return target;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
* https://gist.github.com/jed/982883?permalink_comment_id=852670#gistcomment-852670
|
||||||
|
*/
|
||||||
|
uuidv4: function() {
|
||||||
|
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,a=>(a^Math.random()*16>>a/4).toString(16));
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if the types of two slots are compatible (taking into account wildcards, etc)
|
* Returns if the types of two slots are compatible (taking into account wildcards, etc)
|
||||||
* @method isValidConnection
|
* @method isValidConnection
|
||||||
@@ -1405,7 +1416,12 @@
|
|||||||
console.warn(
|
console.warn(
|
||||||
"LiteGraph: there is already a node with this ID, changing it"
|
"LiteGraph: there is already a node with this ID, changing it"
|
||||||
);
|
);
|
||||||
node.id = ++this.last_node_id;
|
if (LiteGraph.use_uuids) {
|
||||||
|
node.id = LiteGraph.uuidv4();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
node.id = ++this.last_node_id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._nodes.length >= LiteGraph.MAX_NUMBER_OF_NODES) {
|
if (this._nodes.length >= LiteGraph.MAX_NUMBER_OF_NODES) {
|
||||||
@@ -1413,10 +1429,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//give him an id
|
//give him an id
|
||||||
if (node.id == null || node.id == -1) {
|
if (LiteGraph.use_uuids) {
|
||||||
node.id = ++this.last_node_id;
|
if (node.id == null || node.id == -1)
|
||||||
} else if (this.last_node_id < node.id) {
|
node.id = LiteGraph.uuidv4();
|
||||||
this.last_node_id = node.id;
|
}
|
||||||
|
else {
|
||||||
|
if (node.id == null || node.id == -1) {
|
||||||
|
node.id = ++this.last_node_id;
|
||||||
|
} else if (this.last_node_id < node.id) {
|
||||||
|
this.last_node_id = node.id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
node.graph = this;
|
node.graph = this;
|
||||||
@@ -2412,7 +2434,12 @@
|
|||||||
enumerable: true
|
enumerable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
this.id = -1; //not know till not added
|
if (LiteGraph.use_uuids) {
|
||||||
|
this.id = LiteGraph.uuidv4();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.id = -1; //not know till not added
|
||||||
|
}
|
||||||
this.type = null;
|
this.type = null;
|
||||||
|
|
||||||
//inputs available: array of inputs
|
//inputs available: array of inputs
|
||||||
@@ -2626,6 +2653,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete data["id"];
|
delete data["id"];
|
||||||
|
|
||||||
|
if (LiteGraph.use_uuids) {
|
||||||
|
data["id"] = LiteGraph.uuidv4()
|
||||||
|
}
|
||||||
|
|
||||||
//remove links
|
//remove links
|
||||||
node.configure(data);
|
node.configure(data);
|
||||||
|
|
||||||
@@ -4264,10 +4296,16 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var nextId
|
||||||
|
if (LiteGraph.use_uuids)
|
||||||
|
nextId = LiteGraph.uuidv4();
|
||||||
|
else
|
||||||
|
nextId = ++this.graph.last_link_id;
|
||||||
|
|
||||||
//create link class
|
//create link class
|
||||||
link_info = new LLink(
|
link_info = new LLink(
|
||||||
++this.graph.last_link_id,
|
nextId,
|
||||||
input.type || output.type,
|
input.type || output.type,
|
||||||
this.id,
|
this.id,
|
||||||
slot,
|
slot,
|
||||||
|
|||||||
Reference in New Issue
Block a user