[Refactor] Update Litegraph widget types / cleanup (#3782)

This commit is contained in:
filtered
2025-05-06 19:40:30 +10:00
committed by GitHub
parent 6a3cf9e698
commit 0da6be5cdc
6 changed files with 20 additions and 6 deletions

View File

@@ -71,10 +71,12 @@ const addComboWidget = (node: LGraphNode, inputSpec: ComboInputSpec) => {
if (inputSpec.remote.refresh_button) remoteWidget.addRefreshButton()
const origOptions = widget.options
widget.options = new Proxy(origOptions as Record<string | symbol, any>, {
get(target, prop: string | symbol) {
if (prop !== 'values') return target[prop]
return remoteWidget.getValue()
widget.options = new Proxy(origOptions, {
get(target, prop) {
// Assertion: Proxy handler passthrough
return prop !== 'values'
? target[prop as keyof typeof target]
: remoteWidget.getValue()
}
})
}

View File

@@ -237,14 +237,14 @@ const renderPreview = (
class ImagePreviewWidget implements ICustomWidget {
readonly type: 'custom'
readonly name: string
readonly options: IWidgetOptions<unknown>
readonly options: IWidgetOptions<string | object>
/** Dummy value to satisfy type requirements. */
value: string
y: number = 0
/** Don't serialize the widget value. */
serialize: boolean = false
constructor(name: string, options: IWidgetOptions<unknown>) {
constructor(name: string, options: IWidgetOptions<string | object>) {
this.type = 'custom'
this.name = name
this.options = options