allow multiple images

This commit is contained in:
pythongosssss 2023-10-14 14:30:44 +01:00
parent fbbaca00eb
commit 0764885874
2 changed files with 29 additions and 4 deletions

View File

@ -312,14 +312,17 @@ const ext = {
new ConvertToGroupAction().addOption(options, options.length);
return options;
};
api.addEventListener("executing", ({ detail }) => {
if (detail) {
const node = app.graph.getNodeById(detail);
if (!node) {
const split = detail.split(":");
if (split.length === 2) {
api.dispatchEvent(new CustomEvent("executing", { detail: split[0] }));
const outerNode = app.graph.getNodeById(+split[0]);
if (outerNode?.constructor.nodeData?.[IS_GROUP_NODE]) {
api.dispatchEvent(new CustomEvent("executing", { detail: split[0] }));
}
}
}
}
@ -330,7 +333,11 @@ const ext = {
if (!node) {
const split = detail.node.split(":");
if (split.length === 2) {
api.dispatchEvent(new CustomEvent("executed", { detail: { ...detail, node: split[0] } }));
const outerNode = app.graph.getNodeById(+split[0]);
if(outerNode?.constructor.nodeData?.[IS_GROUP_NODE]) {
api.dispatchEvent(new CustomEvent("executed", { detail: { ...detail, node: split[0], merge: !outerNode.resetExecution } }));
outerNode.resetExecution = false;
}
}
}
});
@ -353,6 +360,12 @@ const ext = {
const config = def[GROUP_DATA];
const slots = def[GROUP_SLOTS];
const onExecutionStart = node.onExecutionStart;
node.onExecutionStart = function() {
node.resetExecution = true;
return onExecutionStart?.apply(this, arguments);
}
const onNodeCreated = node.onNodeCreated;
node.onNodeCreated = function () {
for (let innerNodeId = 0; innerNodeId < config.nodes.length; innerNodeId++) {

View File

@ -1135,7 +1135,19 @@ export class ComfyApp {
});
api.addEventListener("executed", ({ detail }) => {
this.nodeOutputs[detail.node] = detail.output;
const output = this.nodeOutputs[detail.node];
if (detail.merge && output) {
for (const k in detail.output ?? {}) {
const v = output[k];
if (v instanceof Array) {
output[k] = v.concat(detail.output[k]);
} else {
output[k] = detail.output[k];
}
}
} else {
this.nodeOutputs[detail.node] = detail.output;
}
const node = this.graph.getNodeById(detail.node);
if (node) {
if (node.onExecuted)