mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-27 06:40:16 +08:00
allow connect primitive to route nodes
This commit is contained in:
parent
9d095c52f3
commit
eee94c1fce
@ -93,6 +93,8 @@ app.registerExtension({
|
|||||||
const nodeOutType = node.inputs && node.inputs[link?.target_slot] && node.inputs[link.target_slot].type ? node.inputs[link.target_slot].type : null;
|
const nodeOutType = node.inputs && node.inputs[link?.target_slot] && node.inputs[link.target_slot].type ? node.inputs[link.target_slot].type : null;
|
||||||
if (inputType && nodeOutType !== inputType) {
|
if (inputType && nodeOutType !== inputType) {
|
||||||
// The output doesnt match our input so disconnect it
|
// The output doesnt match our input so disconnect it
|
||||||
|
console.log("Disconnecting", {"node":node}, "as it doesnt match type of ", {"inputNode":inputNode});
|
||||||
|
|
||||||
node.disconnectInput(link.target_slot);
|
node.disconnectInput(link.target_slot);
|
||||||
} else {
|
} else {
|
||||||
outputType = nodeOutType;
|
outputType = nodeOutType;
|
||||||
|
|||||||
@ -236,10 +236,17 @@ app.registerExtension({
|
|||||||
onConnectOutput(slot, type, input, target_node, target_slot) {
|
onConnectOutput(slot, type, input, target_node, target_slot) {
|
||||||
// Fires before the link is made allowing us to reject it if it isn't valid
|
// Fires before the link is made allowing us to reject it if it isn't valid
|
||||||
|
|
||||||
// No widget, we cant connect
|
console.log("onConnectOutput", { "input": input, "target_node": target_node, "target_slot": target_slot, "slot": slot, "type": type });
|
||||||
if (!input.widget) {
|
if (!input.widget) {
|
||||||
if (!(input.type in ComfyWidgets)) return false;
|
|
||||||
|
if (input.type === '*') {//allow reroute nodes
|
||||||
|
var outputType = target_node.__outputType;
|
||||||
|
if (!(outputType in ComfyWidgets)) return false; //not a ComfyWidgets output
|
||||||
|
}else{
|
||||||
|
if (!(input.type in ComfyWidgets)) return false; //not a ComfyWidgets input
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
console.log("1");
|
||||||
|
|
||||||
if (this.outputs[slot].links?.length) {
|
if (this.outputs[slot].links?.length) {
|
||||||
return this.#isValidConnection(input);
|
return this.#isValidConnection(input);
|
||||||
@ -258,11 +265,21 @@ app.registerExtension({
|
|||||||
const input = theirNode.inputs[link.target_slot];
|
const input = theirNode.inputs[link.target_slot];
|
||||||
if (!input) return;
|
if (!input) return;
|
||||||
|
|
||||||
|
console.log(input);
|
||||||
var _widget;
|
var _widget;
|
||||||
if (!input.widget) {
|
if (!input.widget) {
|
||||||
if (!(input.type in ComfyWidgets)) return;
|
|
||||||
_widget = { "name": input.name, "config": [input.type, {}] }//fake widget
|
if (input.type === '*') { //connected to reroute node
|
||||||
|
var outputType = theirNode.__outputType;
|
||||||
|
console.log("onFirstConnection", { "outputType": outputType });
|
||||||
|
if (!(outputType in ComfyWidgets)) return;
|
||||||
|
_widget = { "name": outputType, "config": [outputType, {}] }//fake widget
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (!(input.type in ComfyWidgets)) return;
|
||||||
|
_widget = { "name": input.name, "config": [input.type, {}] }//fake widget
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_widget = input.widget;
|
_widget = input.widget;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user