|
|
import type { LGraphNode, IWidget, SerializedLGraphNode, LGraph } from "./litegraph";
|
|
|
import type {Constructor, SerializedGraph} from './index';
|
|
|
|
|
|
|
|
|
export interface ComfyApp {
|
|
|
extensions: ComfyExtension[];
|
|
|
queuePrompt(number: number, batchCount = 1): void;
|
|
|
graph: LGraph;
|
|
|
registerExtension(extension: ComfyExtension): void;
|
|
|
}
|
|
|
|
|
|
export interface ComfyWidget extends IWidget {
|
|
|
|
|
|
|
|
|
serializeValue(nodeType: TLGraphNode, index: number): Promise<TValue>;
|
|
|
afterQueued(): void;
|
|
|
inputEl?: HTMLTextAreaElement;
|
|
|
width: number;
|
|
|
}
|
|
|
|
|
|
export interface ComfyGraphNode extends LGraphNode {
|
|
|
getExtraMenuOptions: (node: TLGraphNode, options: ContextMenuItem[]) => void;
|
|
|
onExecuted(message: any): void;
|
|
|
}
|
|
|
|
|
|
export interface ComfyNode extends LGraphNode {
|
|
|
comfyClass: string;
|
|
|
}
|
|
|
|
|
|
|
|
|
export interface ComfyNodeConstructor extends Constructor<ComfyNode> {
|
|
|
static title: string;
|
|
|
static type?: string;
|
|
|
static comfyClass: string;
|
|
|
}
|
|
|
|
|
|
export type NodeMode = 0|1|2|3|4|undefined;
|
|
|
|
|
|
|
|
|
export interface ComfyExtension {
|
|
|
|
|
|
|
|
|
|
|
|
name: string;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init?(app: ComfyApp): Promise<void>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setup?(app: ComfyApp): Promise<void>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addCustomNodeDefs?(defs: Record<string, ComfyObjectInfo>, app: ComfyApp): Promise<void>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getCustomWidgets?(
|
|
|
app: ComfyApp
|
|
|
): Promise<
|
|
|
Record<string, (node, inputName, inputData, app) => { widget?: IWidget; minWidth?: number; minHeight?: number }>
|
|
|
>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
beforeRegisterNodeDef?(nodeType: typeof LGraphNode, nodeData: ComfyObjectInfo, app: ComfyApp): Promise<void>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
registerCustomNodes?(app: ComfyApp): void|Promise<void>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
loadedGraphNode?(node: LGraphNode, app: ComfyApp);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nodeCreated?(node: LGraphNode, app: ComfyApp);
|
|
|
}
|
|
|
|
|
|
export type ComfyObjectInfo = {
|
|
|
name: string;
|
|
|
display_name?: string;
|
|
|
description?: string;
|
|
|
category: string;
|
|
|
input?: {
|
|
|
required?: Record<string, ComfyObjectInfoConfig>;
|
|
|
optional?: Record<string, ComfyObjectInfoConfig>;
|
|
|
hidden?: Record<string, ComfyObjectInfoConfig>;
|
|
|
};
|
|
|
output?: string[];
|
|
|
output_name: string[];
|
|
|
|
|
|
output_node?: boolean;
|
|
|
};
|
|
|
|
|
|
export type ComfyObjectInfoConfig = [string | any[]] | [string | any[], any];
|
|
|
|
|
|
|
|
|
type ComfyApiInputLink = [
|
|
|
|
|
|
string,
|
|
|
|
|
|
number,
|
|
|
]
|
|
|
|
|
|
|
|
|
export type ComfyApiFormatNode = {
|
|
|
"inputs": {
|
|
|
[input_name: string]: string|number|boolean|ComfyApiInputLink,
|
|
|
},
|
|
|
"class_type": string,
|
|
|
"_meta": {
|
|
|
"title": string,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
export type ComfyApiFormat = {
|
|
|
[node_id: string]: ComfyApiFormatNode
|
|
|
}
|
|
|
|
|
|
|
|
|
export type ComfyApiPrompt = {
|
|
|
workflow: SerializedGraph,
|
|
|
output: ComfyApiFormat,
|
|
|
}
|
|
|
|
|
|
|
|
|
export type ComfyApiEventDetailStatus = {
|
|
|
exec_info: {
|
|
|
queue_remaining: number;
|
|
|
};
|
|
|
};
|
|
|
|
|
|
|
|
|
export type ComfyApiEventDetailExecutionStart = {
|
|
|
prompt_id: string;
|
|
|
};
|
|
|
|
|
|
|
|
|
export type ComfyApiEventDetailExecuting = null | string;
|
|
|
|
|
|
|
|
|
export type ComfyApiEventDetailProgress = {
|
|
|
node: string;
|
|
|
prompt_id: string;
|
|
|
max: number;
|
|
|
value: number;
|
|
|
};
|
|
|
|
|
|
|
|
|
export type ComfyApiEventDetailExecuted = {
|
|
|
node: string;
|
|
|
prompt_id: string;
|
|
|
output: any;
|
|
|
};
|
|
|
|
|
|
|
|
|
export type ComfyApiEventDetailCached = {
|
|
|
nodes: string[];
|
|
|
prompt_id: string;
|
|
|
};
|
|
|
|
|
|
|
|
|
export type ComfyApiEventDetailExecuted = {
|
|
|
prompt_id: string;
|
|
|
node: string;
|
|
|
output: any;
|
|
|
};
|
|
|
|
|
|
|
|
|
export type ComfyApiEventDetailError = {
|
|
|
prompt_id: string;
|
|
|
exception_type: string;
|
|
|
exception_message: string;
|
|
|
node_id: string;
|
|
|
node_type: string;
|
|
|
node_id: string;
|
|
|
traceback: string;
|
|
|
executed: any[];
|
|
|
current_inputs: {[key: string]: (number[]|string[])};
|
|
|
current_outputs: {[key: string]: (number[]|string[])};
|
|
|
}
|
|
|
|