diff --git a/src/scripts/domWidget.ts b/src/scripts/domWidget.ts index 7b94eeab7..965099b6f 100644 --- a/src/scripts/domWidget.ts +++ b/src/scripts/domWidget.ts @@ -152,7 +152,7 @@ abstract class BaseDOMWidgetImpl this.options.onDraw?.(this) } - onRemove(): void { + override onRemove(): void { useDomWidgetStore().unregisterWidget(this.id) } } @@ -175,7 +175,7 @@ export class DOMWidgetImpl } /** Extract DOM widget size info */ - computeLayoutSize(node: LGraphNode) { + override computeLayoutSize(node: LGraphNode) { if (this.type === 'hidden') { return { minHeight: 0, @@ -239,7 +239,7 @@ export class ComponentWidgetImpl this.inputSpec = obj.inputSpec } - computeLayoutSize() { + override computeLayoutSize() { const minHeight = this.options.getMinHeight?.() ?? 50 const maxHeight = this.options.getMaxHeight?.() return { diff --git a/src/types/litegraph-augmentation.d.ts b/src/types/litegraph-augmentation.d.ts index b4bee6e72..43d405f2a 100644 --- a/src/types/litegraph-augmentation.d.ts +++ b/src/types/litegraph-augmentation.d.ts @@ -32,15 +32,15 @@ declare module '@comfyorg/litegraph/dist/types/widgets' { } interface IBaseWidget { - onRemove?: () => void - beforeQueued?: () => unknown - afterQueued?: () => unknown + onRemove?(): void + beforeQueued?(): unknown + afterQueued?(): unknown serializeValue?(node: LGraphNode, index: number): Promise | unknown /** * Refreshes the widget's value or options from its remote source. */ - refresh?: () => unknown + refresh?(): unknown /** * If the widget supports dynamic prompts, this will be set to true. @@ -54,6 +54,8 @@ declare module '@comfyorg/litegraph/dist/types/widgets' { * ComfyUI extensions of litegraph */ declare module '@comfyorg/litegraph' { + import type { IBaseWidget } from '@comfyorg/litegraph/dist/types/widgets' + interface LGraphNodeConstructor { type?: string comfyClass: string @@ -63,13 +65,9 @@ declare module '@comfyorg/litegraph' { new (): T } - interface TextWidget { - dynamicPrompts?: boolean - } - - interface BaseWidget { - serializeValue?(node: LGraphNode, index: number): Promise | unknown - } + // Add interface augmentations into the class itself + // eslint-disable-next-line @typescript-eslint/no-empty-object-type + interface BaseWidget extends IBaseWidget {} interface LGraphNode { constructor: LGraphNodeConstructor