mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-10 21:42:37 +08:00
support outputs
This commit is contained in:
parent
b419cd29f9
commit
4a8c36b403
@ -26,13 +26,16 @@ export async function checkBeforeAndAfterReload(graph, cb) {
|
|||||||
/**
|
/**
|
||||||
* @param { string } name
|
* @param { string } name
|
||||||
* @param { Record<string, string | [string | string[], any]> } input
|
* @param { Record<string, string | [string | string[], any]> } input
|
||||||
* @returns { import("../../web/types/comfy").ComfyObjectInfo }
|
* @param { (string | string[])[] | Record<string, string | string[]> } output
|
||||||
|
* @returns { Record<string, import("../../web/types/comfy").ComfyObjectInfo> }
|
||||||
*/
|
*/
|
||||||
export function makeNodeDef(name, input) {
|
export function makeNodeDef(name, input, output = {}) {
|
||||||
const nodeDef = {
|
const nodeDef = {
|
||||||
name,
|
name,
|
||||||
category: "test",
|
category: "test",
|
||||||
|
output: [],
|
||||||
output_name: [],
|
output_name: [],
|
||||||
|
output_is_list: [],
|
||||||
input: {
|
input: {
|
||||||
required: {}
|
required: {}
|
||||||
},
|
},
|
||||||
@ -40,7 +43,19 @@ export function makeNodeDef(name, input) {
|
|||||||
for(const k in input) {
|
for(const k in input) {
|
||||||
nodeDef.input.required[k] = typeof input[k] === "string" ? [input[k], {}] : [...input[k]];
|
nodeDef.input.required[k] = typeof input[k] === "string" ? [input[k], {}] : [...input[k]];
|
||||||
}
|
}
|
||||||
return nodeDef;
|
if(output instanceof Array) {
|
||||||
|
output = output.reduce((p, c) => {
|
||||||
|
p[c] = c;
|
||||||
|
return p;
|
||||||
|
}, {})
|
||||||
|
}
|
||||||
|
for(const k in output) {
|
||||||
|
nodeDef.output.push(output[k]);
|
||||||
|
nodeDef.output_name.push(k);
|
||||||
|
nodeDef.output_is_list.push(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return { [name]: nodeDef };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user