mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-13 15:02:37 +08:00
allow reroute pipe
fix control_after_generate configure
This commit is contained in:
parent
8415ef81d5
commit
fbbaca00eb
@ -12,20 +12,20 @@ function getLinks(config) {
|
|||||||
|
|
||||||
// Extract links for easy lookup
|
// Extract links for easy lookup
|
||||||
for (const l of config.links) {
|
for (const l of config.links) {
|
||||||
const [outputNodeId, outputNodeSlot, inputNodeId, inputNodeSlot] = l;
|
const [sourceNodeId, sourceNodeSlot, targetNodeId, targetNodeSlot] = l;
|
||||||
|
|
||||||
// Skip links outside the copy config
|
// Skip links outside the copy config
|
||||||
if (outputNodeId == null) continue;
|
if (sourceNodeId == null) continue;
|
||||||
|
|
||||||
if (!linksFrom[outputNodeId]) {
|
if (!linksFrom[sourceNodeId]) {
|
||||||
linksFrom[outputNodeId] = {};
|
linksFrom[sourceNodeId] = {};
|
||||||
}
|
}
|
||||||
linksFrom[outputNodeId][outputNodeSlot] = l;
|
linksFrom[sourceNodeId][sourceNodeSlot] = l;
|
||||||
|
|
||||||
if (!linksTo[inputNodeId]) {
|
if (!linksTo[targetNodeId]) {
|
||||||
linksTo[inputNodeId] = {};
|
linksTo[targetNodeId] = {};
|
||||||
}
|
}
|
||||||
linksTo[inputNodeId][inputNodeSlot] = l;
|
linksTo[targetNodeId][targetNodeSlot] = l;
|
||||||
}
|
}
|
||||||
return { linksTo, linksFrom };
|
return { linksTo, linksFrom };
|
||||||
}
|
}
|
||||||
@ -76,13 +76,21 @@ function buildNodeDef(config, nodeName, defs, workflow) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let rerouteType;
|
let rerouteType = "*";
|
||||||
if (linksFrom) {
|
if (linksFrom) {
|
||||||
const [, , id, slot] = linksFrom["0"];
|
const [, , id, slot] = linksFrom["0"];
|
||||||
rerouteType = config.nodes[id].inputs[slot].type;
|
rerouteType = config.nodes[id].inputs[slot].type;
|
||||||
} else {
|
} else if (linksTo) {
|
||||||
const [id, slot] = linksTo["0"];
|
const [id, slot] = linksTo["0"];
|
||||||
rerouteType = config.nodes[id].outputs[slot].type;
|
rerouteType = config.nodes[id].outputs[slot].type;
|
||||||
|
} else {
|
||||||
|
// Reroute used as a pipe
|
||||||
|
for (const l of config.links) {
|
||||||
|
if (l[2] === nodeId) {
|
||||||
|
rerouteType = l[5];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def = {
|
def = {
|
||||||
@ -195,6 +203,14 @@ class ConvertToGroupAction {
|
|||||||
app.canvas.copyToClipboard();
|
app.canvas.copyToClipboard();
|
||||||
const config = JSON.parse(localStorage.getItem("litegrapheditor_clipboard"));
|
const config = JSON.parse(localStorage.getItem("litegrapheditor_clipboard"));
|
||||||
localStorage.setItem("litegrapheditor_clipboard", backup);
|
localStorage.setItem("litegrapheditor_clipboard", backup);
|
||||||
|
|
||||||
|
// Store link types to allow reconstructing reroute types
|
||||||
|
for (const link of config.links) {
|
||||||
|
const origin = app.graph.getNodeById(link[4]);
|
||||||
|
const type = origin.outputs[link[1]].type;
|
||||||
|
link.push(type);
|
||||||
|
}
|
||||||
|
|
||||||
const def = buildNodeDef(config, name, globalDefs, true);
|
const def = buildNodeDef(config, name, globalDefs, true);
|
||||||
await app.registerNodeDef("workflow/" + name, def);
|
await app.registerNodeDef("workflow/" + name, def);
|
||||||
return { config, def };
|
return { config, def };
|
||||||
@ -349,9 +365,9 @@ const ext = {
|
|||||||
let seedShift = 0;
|
let seedShift = 0;
|
||||||
for (let i = 0; i < names.length; i++) {
|
for (let i = 0; i < names.length; i++) {
|
||||||
if (values[i + seedShift] == null) continue;
|
if (values[i + seedShift] == null) continue;
|
||||||
const widget = this.widgets.find((w) => w.name === names[i]);
|
const widgetIndex = this.widgets.findIndex((w) => w.name === names[i]);
|
||||||
if (widget) {
|
if (widgetIndex > -1) {
|
||||||
widget.value = values[i + seedShift];
|
this.widgets[widgetIndex].value = values[i + seedShift];
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to shift the value lookup for the widget values if its a seed
|
// We need to shift the value lookup for the widget values if its a seed
|
||||||
@ -360,8 +376,9 @@ const ext = {
|
|||||||
names[i] === "noise_seed" ||
|
names[i] === "noise_seed" ||
|
||||||
def.input.required[names[i]]?.[1]?.control_after_generate
|
def.input.required[names[i]]?.[1]?.control_after_generate
|
||||||
) {
|
) {
|
||||||
// TODO: need to populate control_after_generate values
|
|
||||||
seedShift++;
|
seedShift++;
|
||||||
|
// As this is a seed we need to populate control_after_generate, which will be the next widget
|
||||||
|
this.widgets[widgetIndex + 1].value = values[i + seedShift];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user