Update widget types to match Litegraph changes (#3808)

This commit is contained in:
filtered
2025-05-08 06:56:53 +10:00
committed by GitHub
parent 6fdef0308b
commit 3aea2c120a
11 changed files with 45 additions and 44 deletions

View File

@@ -1,4 +1,4 @@
import { LGraphCanvas, LiteGraph } from '@comfyorg/litegraph'
import { LGraphCanvas, LiteGraph, isComboWidget } from '@comfyorg/litegraph'
import { app } from '../../scripts/app'
@@ -33,7 +33,7 @@ const ext = {
const clickedComboValue = currentNode?.widgets
?.filter(
(w) =>
w.type === 'combo' && w.options.values?.length === values.length
isComboWidget(w) && w.options.values?.length === values.length
)
.find((w) =>
// @ts-expect-error Poorly typed; filter above "should" mitigate exceptions

View File

@@ -1231,7 +1231,6 @@ export class GroupNodeHandler {
const widgetName = self.groupData.oldToNewWidgetMap[n][w]
const widget = this.widgets.find((w) => w.name === widgetName)
if (widget) {
// @ts-expect-error fixme ts strict error
widget.type = 'hidden'
widget.computeSize = () => [0, -4]
}

View File

@@ -1,4 +1,7 @@
import type { IStringWidget } from '@comfyorg/litegraph/dist/types/widgets'
import type {
IComboWidget,
IStringWidget
} from '@comfyorg/litegraph/dist/types/widgets'
import { nextTick } from 'vue'
import Load3D from '@/components/load3d/Load3D.vue'
@@ -116,7 +119,7 @@ useExtensionService().registerExtension({
if (fileInput.files?.length) {
const modelWidget = node.widgets?.find(
(w) => w.name === 'model_file'
) as IStringWidget
) as IComboWidget & { options: { values: string[] } }
node.properties['Texture'] = undefined
@@ -138,7 +141,6 @@ useExtensionService().registerExtension({
if (uploadPath && modelWidget) {
if (!modelWidget.options?.values?.includes(uploadPath)) {
// @ts-expect-error Fails due to earlier type-assertion of IStringWidget
modelWidget.options?.values?.push(uploadPath)
}
@@ -292,7 +294,6 @@ useExtensionService().registerExtension({
if (uploadPath && modelWidget) {
if (!modelWidget.options?.values?.includes(uploadPath)) {
// @ts-expect-error Fails due to earlier type-assertion of IStringWidget
modelWidget.options?.values?.push(uploadPath)
}

View File

@@ -1,4 +1,4 @@
import type { IWidget } from '@comfyorg/litegraph'
import type { IBaseWidget } from '@comfyorg/litegraph/dist/types/widgets'
import Load3d from '@/extensions/core/load3d/Load3d'
import Load3dUtils from '@/extensions/core/load3d/Load3dUtils'
@@ -15,17 +15,20 @@ class Load3DConfiguration {
configure(
loadFolder: 'input' | 'output',
modelWidget: IWidget,
modelWidget: IBaseWidget,
cameraState?: any,
width: IWidget | null = null,
height: IWidget | null = null
width: IBaseWidget | null = null,
height: IBaseWidget | null = null
) {
this.setupModelHandling(modelWidget, loadFolder, cameraState)
this.setupTargetSize(width, height)
this.setupDefaultProperties()
}
private setupTargetSize(width: IWidget | null, height: IWidget | null) {
private setupTargetSize(
width: IBaseWidget | null,
height: IBaseWidget | null
) {
if (width && height) {
this.load3d.setTargetSize(width.value as number, height.value as number)
@@ -51,7 +54,7 @@ class Load3DConfiguration {
}
private setupModelHandling(
modelWidget: IWidget,
modelWidget: IBaseWidget,
loadFolder: 'input' | 'output',
cameraState?: any
) {

View File

@@ -3,11 +3,11 @@ import type {
INodeInputSlot,
INodeOutputSlot,
ISlotType,
IWidget,
LLink,
Vector2
} from '@comfyorg/litegraph'
import type { CanvasMouseEvent } from '@comfyorg/litegraph/dist/types/events'
import type { IBaseWidget } from '@comfyorg/litegraph/dist/types/widgets'
import {
type CallbackParams,
@@ -226,7 +226,7 @@ export class PrimitiveNode extends LGraphNode {
// Store current size as addWidget resizes the node
const [oldWidth, oldHeight] = this.size
let widget: IWidget | undefined
let widget: IBaseWidget | undefined
if (type in ComfyWidgets) {
widget = (ComfyWidgets[type](this, 'value', inputData, app) || {}).widget
} else {
@@ -426,7 +426,7 @@ function getConfig(this: LGraphNode, widgetName: string) {
*/
export function convertToInput(
node: LGraphNode,
widget: IWidget
widget: IBaseWidget
): INodeInputSlot | undefined {
console.warn(
'Please remove call to convertToInput. Widget to socket conversion is no longer necessary, as they co-exist now.'