From 6724c199921fad2d0fe7e5d9288d13e0abb9b185 Mon Sep 17 00:00:00 2001 From: huchenlei Date: Tue, 25 Feb 2025 17:38:59 -0500 Subject: [PATCH] Type INodeOutputSlot widget hack on PrimitiveNode --- src/extensions/core/widgetInputs.ts | 6 +++--- src/types/litegraph-augmentation.d.ts | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/extensions/core/widgetInputs.ts b/src/extensions/core/widgetInputs.ts index 5056b2ce3..75bf16b9a 100644 --- a/src/extensions/core/widgetInputs.ts +++ b/src/extensions/core/widgetInputs.ts @@ -1,12 +1,12 @@ // @ts-strict-ignore import { LGraphNode, LiteGraph } from '@comfyorg/litegraph' import type { + IFoundSlot, INodeInputSlot, + INodeOutputSlot, IWidget, LiteGraphCanvasEvent } from '@comfyorg/litegraph' -import type { IFoundSlot } from '@comfyorg/litegraph' -import { INodeSlot } from '@comfyorg/litegraph' import { useNodeDefStore } from '@/stores/nodeDefStore' import { useSettingStore } from '@/stores/settingStore' @@ -422,7 +422,7 @@ export class PrimitiveNode extends LGraphNode { } } -export function getWidgetConfig(slot: INodeSlot) { +export function getWidgetConfig(slot: INodeInputSlot | INodeOutputSlot) { return slot.widget[CONFIG] ?? slot.widget[GET_CONFIG]?.() ?? ['*', {}] } diff --git a/src/types/litegraph-augmentation.d.ts b/src/types/litegraph-augmentation.d.ts index f2cc7c5f2..97f00e221 100644 --- a/src/types/litegraph-augmentation.d.ts +++ b/src/types/litegraph-augmentation.d.ts @@ -148,6 +148,14 @@ declare module '@comfyorg/litegraph' { /** Callback for pasting multiple files into the node */ pasteFiles?(files: File[]): void } + /** + * Only used by the Primitive node. Primitive node is using the widget property + * to store/access the widget config. + * We should remove this hacky solution once we have a proper solution. + */ + interface INodeOutputSlot { + widget?: IWidget + } } /**