Use LiteGraph validation for node search->create (#822)

Adds LiteGraph type to augmentation until LG types are auto-generated
Removes @ts-expect-error
This commit is contained in:
filtered
2024-09-14 09:36:48 +10:00
committed by GitHub
parent 48f84a46cd
commit c98ea5ba01
3 changed files with 6 additions and 5 deletions

View File

@@ -130,7 +130,6 @@ app.registerExtension({
: null
if (
inputType &&
// @ts-expect-error Will self-resolve when LiteGraph types are generated
!LiteGraph.isValidConnection(inputType, nodeOutType)
) {
// The output doesnt match our input so disconnect it

View File

@@ -11,6 +11,8 @@ declare module '@comfyorg/litegraph' {
slot_types_out: string[]
slot_types_default_out: Record<string, string[]>
slot_types_default_in: Record<string, string[]>
isValidConnection(type_a: ISlotType, type_b: ISlotType): boolean
}
import type { LiteGraph as LG } from '@comfyorg/litegraph/dist/litegraph'

View File

@@ -1,4 +1,4 @@
import {
import type {
ConnectingLink,
LGraphNode,
Vector2,
@@ -6,6 +6,7 @@ import {
INodeOutputSlot,
INodeSlot
} from '@comfyorg/litegraph'
import { LiteGraph } from '@comfyorg/litegraph'
export class ConnectingLinkImpl implements ConnectingLink {
node: LGraphNode
@@ -56,9 +57,8 @@ export class ConnectingLinkImpl implements ConnectingLink {
this.releaseSlotType === 'output' ? newNode.outputs : newNode.inputs
if (!newNodeSlots) return
const newNodeSlot = newNodeSlots.findIndex(
(slot: INodeSlot) =>
slot.type === this.type || slot.type === '*' || this.type === '*'
const newNodeSlot = newNodeSlots.findIndex((slot: INodeSlot) =>
LiteGraph.isValidConnection(slot.type, this.type)
)
if (newNodeSlot === -1) {