From ba4e4ed0b86d9dd69d3640d23f78f8618cd4879e Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Wed, 5 Mar 2025 13:32:47 -0500 Subject: [PATCH] Deprecate widgetType:widgetName key in widgets map (#2879) --- src/composables/widgets/useIntWidget.ts | 10 +++++++++- src/scripts/app.ts | 2 -- src/scripts/widgets.ts | 9 --------- src/stores/widgetStore.ts | 18 +----------------- 4 files changed, 10 insertions(+), 29 deletions(-) diff --git a/src/composables/widgets/useIntWidget.ts b/src/composables/widgets/useIntWidget.ts index 1a445f1a5..f73c27a37 100644 --- a/src/composables/widgets/useIntWidget.ts +++ b/src/composables/widgets/useIntWidget.ts @@ -71,7 +71,15 @@ export const useIntWidget = () => { } ) - if (inputSpec.control_after_generate) { + const controlAfterGenerate = + inputSpec.control_after_generate ?? + /** + * Compatibility with legacy node convention. Int input with name + * 'seed' or 'noise_seed' get automatically added a control widget. + */ + ['seed', 'noise_seed'].includes(inputSpec.name) + + if (controlAfterGenerate) { const seedControl = addValueControlWidget( node, widget, diff --git a/src/scripts/app.ts b/src/scripts/app.ts index 0d1378103..94a456490 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -934,8 +934,6 @@ export class ComfyApp { if (Array.isArray(type)) { return 'COMBO' - } else if (`${type}:${inputName}` in this.widgets) { - return `${type}:${inputName}` } else if (type in this.widgets) { return type } else { diff --git a/src/scripts/widgets.ts b/src/scripts/widgets.ts index 052991d45..f599c4029 100644 --- a/src/scripts/widgets.ts +++ b/src/scripts/widgets.ts @@ -278,16 +278,7 @@ export function addValueControlWidgets( return widgets } -const seedWidget = transformWidgetConstructorV2ToV1((node, inputSpec) => { - return useIntWidget()(node, { - ...inputSpec, - control_after_generate: true - }) -}) - export const ComfyWidgets: Record = { - 'INT:seed': seedWidget, - 'INT:noise_seed': seedWidget, INT: transformWidgetConstructorV2ToV1(useIntWidget()), FLOAT: transformWidgetConstructorV2ToV1(useFloatWidget()), BOOLEAN: transformWidgetConstructorV2ToV1(useBooleanWidget()), diff --git a/src/stores/widgetStore.ts b/src/stores/widgetStore.ts index 51ff4373b..0bbd63048 100644 --- a/src/stores/widgetStore.ts +++ b/src/stores/widgetStore.ts @@ -12,23 +12,8 @@ export const useWidgetStore = defineStore('widget', () => { ...coreWidgets })) - function getWidgetType(type: string, inputName: string) { - if (type === 'COMBO') { - return 'COMBO' - /** - * @deprecated Group node logic. Remove once group node feature is removed. - */ - } else if (`${type}:${inputName}` in widgets.value) { - return `${type}:${inputName}` - } else if (type in widgets.value) { - return type - } else { - return null - } - } - function inputIsWidget(spec: InputSpecV2) { - return getWidgetType(spec.type, spec.name) !== null + return spec.type in widgets.value } function registerCustomWidgets( @@ -42,7 +27,6 @@ export const useWidgetStore = defineStore('widget', () => { return { widgets, - getWidgetType, inputIsWidget, registerCustomWidgets }