mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-22 15:54:09 +00:00
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:
@@ -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)
|
||||
}
|
||||
36
src/types/litegraph-augmentation.d.ts
vendored
36
src/types/litegraph-augmentation.d.ts
vendored
@@ -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 }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1
src/types/litegraph-core-augmentation.d.ts
vendored
1
src/types/litegraph-core-augmentation.d.ts
vendored
@@ -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[]
|
||||
|
||||
Reference in New Issue
Block a user