mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-27 10:14:06 +00:00
[TS] Fix / consolidate DOM widget types (#3830)
This commit is contained in:
@@ -152,7 +152,7 @@ abstract class BaseDOMWidgetImpl<V extends object | string>
|
|||||||
this.options.onDraw?.(this)
|
this.options.onDraw?.(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
onRemove(): void {
|
override onRemove(): void {
|
||||||
useDomWidgetStore().unregisterWidget(this.id)
|
useDomWidgetStore().unregisterWidget(this.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,7 +175,7 @@ export class DOMWidgetImpl<T extends HTMLElement, V extends object | string>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Extract DOM widget size info */
|
/** Extract DOM widget size info */
|
||||||
computeLayoutSize(node: LGraphNode) {
|
override computeLayoutSize(node: LGraphNode) {
|
||||||
if (this.type === 'hidden') {
|
if (this.type === 'hidden') {
|
||||||
return {
|
return {
|
||||||
minHeight: 0,
|
minHeight: 0,
|
||||||
@@ -239,7 +239,7 @@ export class ComponentWidgetImpl<V extends object | string>
|
|||||||
this.inputSpec = obj.inputSpec
|
this.inputSpec = obj.inputSpec
|
||||||
}
|
}
|
||||||
|
|
||||||
computeLayoutSize() {
|
override computeLayoutSize() {
|
||||||
const minHeight = this.options.getMinHeight?.() ?? 50
|
const minHeight = this.options.getMinHeight?.() ?? 50
|
||||||
const maxHeight = this.options.getMaxHeight?.()
|
const maxHeight = this.options.getMaxHeight?.()
|
||||||
return {
|
return {
|
||||||
|
|||||||
20
src/types/litegraph-augmentation.d.ts
vendored
20
src/types/litegraph-augmentation.d.ts
vendored
@@ -32,15 +32,15 @@ declare module '@comfyorg/litegraph/dist/types/widgets' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface IBaseWidget {
|
interface IBaseWidget {
|
||||||
onRemove?: () => void
|
onRemove?(): void
|
||||||
beforeQueued?: () => unknown
|
beforeQueued?(): unknown
|
||||||
afterQueued?: () => unknown
|
afterQueued?(): unknown
|
||||||
serializeValue?(node: LGraphNode, index: number): Promise<unknown> | unknown
|
serializeValue?(node: LGraphNode, index: number): Promise<unknown> | unknown
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refreshes the widget's value or options from its remote source.
|
* 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.
|
* 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
|
* ComfyUI extensions of litegraph
|
||||||
*/
|
*/
|
||||||
declare module '@comfyorg/litegraph' {
|
declare module '@comfyorg/litegraph' {
|
||||||
|
import type { IBaseWidget } from '@comfyorg/litegraph/dist/types/widgets'
|
||||||
|
|
||||||
interface LGraphNodeConstructor<T extends LGraphNode = LGraphNode> {
|
interface LGraphNodeConstructor<T extends LGraphNode = LGraphNode> {
|
||||||
type?: string
|
type?: string
|
||||||
comfyClass: string
|
comfyClass: string
|
||||||
@@ -63,13 +65,9 @@ declare module '@comfyorg/litegraph' {
|
|||||||
new (): T
|
new (): T
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TextWidget {
|
// Add interface augmentations into the class itself
|
||||||
dynamicPrompts?: boolean
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
||||||
}
|
interface BaseWidget extends IBaseWidget {}
|
||||||
|
|
||||||
interface BaseWidget {
|
|
||||||
serializeValue?(node: LGraphNode, index: number): Promise<unknown> | unknown
|
|
||||||
}
|
|
||||||
|
|
||||||
interface LGraphNode {
|
interface LGraphNode {
|
||||||
constructor: LGraphNodeConstructor
|
constructor: LGraphNodeConstructor
|
||||||
|
|||||||
Reference in New Issue
Block a user