Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TS type on InputSpec #901

Merged
merged 1 commit into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/extensions/core/noteNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ app.registerExtension({
// Should we extends LGraphNode? Yesss
this,
'',
// @ts-expect-error
['', { default: this.properties.text, multiline: true }],
app
)
Expand Down
29 changes: 12 additions & 17 deletions src/scripts/widgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { api } from './api'
import './domWidget'
import type { ComfyApp } from './app'
import type { IWidget, LGraphNode } from '@comfyorg/litegraph'
import { ComfyNodeDef } from '@/types/apiTypes'
import { InputSpec } from '@/types/apiTypes'
import { useSettingStore } from '@/stores/settingStore'

export type ComfyWidgetConstructor = (
node: LGraphNode,
inputName: string,
inputData: ComfyNodeDef,
inputData: InputSpec,
app?: ComfyApp,
widgetName?: string
) => { widget: IWidget; minWidth?: number; minHeight?: number }
Expand All @@ -27,7 +27,7 @@ const IS_CONTROL_WIDGET = Symbol()
const HAS_EXECUTED = Symbol()

function getNumberDefaults(
inputData: ComfyNodeDef,
inputData: InputSpec,
defaultStep,
precision,
enable_rounding
Expand Down Expand Up @@ -62,7 +62,7 @@ export function addValueControlWidget(
defaultValue = 'randomize',
values,
widgetName,
inputData: ComfyNodeDef
inputData: InputSpec
) {
let name = inputData[1]?.control_after_generate
if (typeof name !== 'string') {
Expand All @@ -86,7 +86,7 @@ export function addValueControlWidgets(
targetWidget,
defaultValue = 'randomize',
options,
inputData: ComfyNodeDef
inputData: InputSpec
) {
if (!defaultValue) defaultValue = 'randomize'
if (!options) options = {}
Expand Down Expand Up @@ -259,7 +259,7 @@ export function addValueControlWidgets(
return widgets
}

function seedWidget(node, inputName, inputData: ComfyNodeDef, app, widgetName) {
function seedWidget(node, inputName, inputData: InputSpec, app, widgetName) {
const seed = createIntWidget(node, inputName, inputData, app, true)
const seedControl = addValueControlWidget(
node,
Expand All @@ -277,7 +277,7 @@ function seedWidget(node, inputName, inputData: ComfyNodeDef, app, widgetName) {
function createIntWidget(
node,
inputName,
inputData: ComfyNodeDef,
inputData: InputSpec,
app,
isSeedInput: boolean = false
) {
Expand Down Expand Up @@ -382,7 +382,7 @@ export function initWidgets(app) {
export const ComfyWidgets: Record<string, ComfyWidgetConstructor> = {
'INT:seed': seedWidget,
'INT:noise_seed': seedWidget,
FLOAT(node, inputName, inputData: ComfyNodeDef, app) {
FLOAT(node, inputName, inputData: InputSpec, app) {
let widgetType: 'number' | 'slider' = isSlider(inputData[1]['display'], app)
let precision = app.ui.settings.getSettingValue(
'Comfy.FloatRoundingPrecision'
Expand Down Expand Up @@ -416,7 +416,7 @@ export const ComfyWidgets: Record<string, ComfyWidgetConstructor> = {
)
}
},
INT(node, inputName, inputData: ComfyNodeDef, app) {
INT(node, inputName, inputData: InputSpec, app) {
return createIntWidget(node, inputName, inputData, app)
},
BOOLEAN(node, inputName, inputData) {
Expand All @@ -431,7 +431,7 @@ export const ComfyWidgets: Record<string, ComfyWidgetConstructor> = {
widget: node.addWidget('toggle', inputName, defaultVal, () => {}, options)
}
},
STRING(node, inputName, inputData: ComfyNodeDef, app) {
STRING(node, inputName, inputData: InputSpec, app) {
const defaultVal = inputData[1].default || ''
const multiline = !!inputData[1].multiline

Expand All @@ -454,7 +454,7 @@ export const ComfyWidgets: Record<string, ComfyWidgetConstructor> = {

return res
},
COMBO(node, inputName, inputData: ComfyNodeDef) {
COMBO(node, inputName, inputData: InputSpec) {
const type = inputData[0]
let defaultValue = type[0]
if (inputData[1] && inputData[1].default) {
Expand All @@ -477,12 +477,7 @@ export const ComfyWidgets: Record<string, ComfyWidgetConstructor> = {
}
return res
},
IMAGEUPLOAD(
node: LGraphNode,