Add TS types / merge ComfyLGraphNode (#902)

* Add TS type for LGraphNodeConstructor

* Add TS type & move shared prop to parent

* Add TS types - Comfy augmentations

* nit - TS type

* Merge ComfyLGNode into existing augmentations

* nit - fix missed explicit type on import
This commit is contained in:
filtered
2024-09-21 19:18:27 +10:00
committed by GitHub
parent 88acabb355
commit c7f123766e
7 changed files with 42 additions and 42 deletions

View File

@@ -1,11 +0,0 @@
import type { LGraphNode } from '@comfyorg/litegraph'
import type { ComfyNodeDef } from './apiTypes'
export declare class ComfyLGraphNode extends LGraphNode {
static comfyClass: string
static title: string
static nodeData?: ComfyNodeDef
static category?: string
constructor(title?: string)
}

View File

@@ -1,14 +1,33 @@
import '@comfyorg/litegraph'
import type { ComfyNodeDef } from '@/types/apiTypes'
import type { LLink } from '@comfyorg/litegraph'
/**
* ComfyUI extensions of litegraph
*/
declare module '@comfyorg/litegraph' {
interface LGraphNodeConstructor<T extends LGraphNode = LGraphNode> {
type?: string
comfyClass: string
title: string
nodeData?: ComfyNodeDef
category?: string
new (): T
}
interface LGraphNode {
constructor: LGraphNodeConstructor
/**
* Callback fired on each node after the graph is configured
*/
onAfterGraphConfigured?(): void
onNodeCreated?(this: LGraphNode): void
setInnerNodes?(nodes: LGraphNode[]): void
applyToGraph?(extraLinks?: LLink[]): void
updateLink?(link: LLink): LLink | null
comfyClass?: string
/**
* If the node is a frontend only node and should not be serialized into the prompt.
@@ -24,25 +43,30 @@ declare module '@comfyorg/litegraph' {
}
interface IWidget<TValue = any, TOptions = any> {
type?: string
/**
* Allows for additional cleanup when removing a widget when converting to input.
*/
onRemove?(): void
serializeValue?(node?: LGraphNode, i?: string)
beforeQueued?(): void
/**
* DOM element used for the widget
*/
element?: HTMLElement
tooltip?: string
origType?: IWidget['type']
origComputeSize?: IWidget['computeSize']
origSerializeValue?: IWidget['serializeValue']
}
interface INodeOutputSlot {
widget?: unknown
}
interface INodeInputSlot {
widget?: unknown
interface INodeSlot {
widget?: unknown & { name?: string }
}
}

View File

@@ -6,6 +6,7 @@ declare module '@comfyorg/litegraph' {
interface LiteGraphExtended {
search_filter_enabled: boolean
middle_click_slot_add_default_node: boolean
registered_node_types: Record<string, LGraphNodeConstructor>
registered_slot_out_types: Record<string, { nodes: string[] }>
registered_slot_in_types: Record<string, { nodes: string[] }>
slot_types_out: string[]