mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-23 07:50:15 +00:00
[TS] Properly type slot widget (#876)
INodeSlot.widget is not real widget references at runtime. This PR narrows the type so that we don't run into unexpected issues.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { CanvasColour, Dictionary, INodeInputSlot, INodeOutputSlot, INodeSlot, ISlotType, IWidgetInputSlot, Point, SharedIntersection } from "./interfaces"
|
||||
import type { CanvasColour, Dictionary, INodeInputSlot, INodeOutputSlot, INodeSlot, ISlotType, IWidgetInputSlot, IWidgetLocator, Point, SharedIntersection } from "./interfaces"
|
||||
import type { LinkId } from "./LLink"
|
||||
import type { IWidget } from "./types/widgets"
|
||||
|
||||
@@ -96,7 +96,7 @@ export abstract class NodeSlot implements INodeSlot {
|
||||
locked?: boolean
|
||||
nameLocked?: boolean
|
||||
pos?: Point
|
||||
widget?: IWidget
|
||||
widget?: IWidgetLocator
|
||||
hasErrors?: boolean
|
||||
|
||||
constructor(slot: INodeSlot) {
|
||||
|
||||
@@ -3,7 +3,6 @@ import type { LGraphNode, NodeId } from "./LGraphNode"
|
||||
import type { LinkId, LLink } from "./LLink"
|
||||
import type { Reroute, RerouteId } from "./Reroute"
|
||||
import type { LinkDirection, RenderShape } from "./types/globalEnums"
|
||||
import type { IWidget } from "./types/widgets"
|
||||
import type { LayoutElement } from "./utils/layout"
|
||||
|
||||
export type Dictionary<T> = { [key: string]: T }
|
||||
@@ -306,17 +305,25 @@ export interface INodeFlags {
|
||||
keepAllLinksOnBypass?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* A widget that is linked to a slot.
|
||||
*
|
||||
* This is set by the ComfyUI_frontend logic. See
|
||||
* https://github.com/Comfy-Org/ComfyUI_frontend/blob/b80e0e1a3c74040f328c4e344326c969c97f67e0/src/extensions/core/widgetInputs.ts#L659
|
||||
*/
|
||||
export interface IWidgetLocator {
|
||||
name: string
|
||||
[key: string | symbol]: unknown
|
||||
}
|
||||
|
||||
export interface INodeInputSlot extends INodeSlot {
|
||||
link: LinkId | null
|
||||
_layoutElement?: LayoutElement<INodeInputSlot>
|
||||
/**
|
||||
* A widget that is linked to this input slot.
|
||||
*/
|
||||
widget?: IWidget
|
||||
widget?: IWidgetLocator
|
||||
}
|
||||
|
||||
export interface IWidgetInputSlot extends INodeInputSlot {
|
||||
widget: IWidget
|
||||
widget: IWidgetLocator
|
||||
}
|
||||
|
||||
export interface INodeOutputSlot extends INodeSlot {
|
||||
|
||||
Reference in New Issue
Block a user