mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-14 17:37:46 +00:00
Migrate defaultInput widget option (#3364)
Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
53
browser_tests/assets/default_input.json
Normal file
53
browser_tests/assets/default_input.json
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"id": "9bcb9451-8319-492a-88d4-fb711d8c3d25",
|
||||
"revision": 0,
|
||||
"last_node_id": 6,
|
||||
"last_link_id": 0,
|
||||
"nodes": [
|
||||
{
|
||||
"id": 6,
|
||||
"type": "DevToolsNodeWithDefaultInput",
|
||||
"pos": [
|
||||
8.39722728729248,
|
||||
29.727279663085938
|
||||
],
|
||||
"size": [
|
||||
315,
|
||||
82
|
||||
],
|
||||
"flags": {},
|
||||
"order": 0,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "float_input",
|
||||
"shape": 7,
|
||||
"type": "FLOAT",
|
||||
"link": null
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"properties": {
|
||||
"Node name for S&R": "DevToolsNodeWithDefaultInput"
|
||||
},
|
||||
"widgets_values": [
|
||||
0,
|
||||
1,
|
||||
0
|
||||
]
|
||||
}
|
||||
],
|
||||
"links": [],
|
||||
"groups": [],
|
||||
"config": {},
|
||||
"extra": {
|
||||
"ds": {
|
||||
"scale": 2.1600300525920346,
|
||||
"offset": [
|
||||
63.071794466403446,
|
||||
75.18055335968394
|
||||
]
|
||||
}
|
||||
},
|
||||
"version": 0.4
|
||||
}
|
||||
@@ -25,6 +25,11 @@ test.describe('Optional input', () => {
|
||||
await expect(comfyPage.canvas).toHaveScreenshot('force_input.png')
|
||||
})
|
||||
|
||||
test('Default input', async ({ comfyPage }) => {
|
||||
await comfyPage.loadWorkflow('default_input')
|
||||
await expect(comfyPage.canvas).toHaveScreenshot('default_input.png')
|
||||
})
|
||||
|
||||
test('Only optional inputs', async ({ comfyPage }) => {
|
||||
await comfyPage.loadWorkflow('only_optional_inputs')
|
||||
expect(await comfyPage.getGraphNodesCount()).toBe(1)
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
@@ -1,5 +1,6 @@
|
||||
import type { LGraphNode } from '@comfyorg/litegraph'
|
||||
import axios from 'axios'
|
||||
import _ from 'lodash'
|
||||
import { defineStore } from 'pinia'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
@@ -69,7 +70,41 @@ export class ComfyNodeDefImpl
|
||||
// ComfyNodeDefImpl fields
|
||||
readonly nodeSource: NodeSource
|
||||
|
||||
constructor(obj: ComfyNodeDefV1) {
|
||||
/**
|
||||
* @internal
|
||||
* Migrate default input options to forceInput.
|
||||
*/
|
||||
static #migrateDefaultInput(nodeDef: ComfyNodeDefV1): ComfyNodeDefV1 {
|
||||
const def = _.cloneDeep(nodeDef)
|
||||
def.input ??= {}
|
||||
// For required inputs, now we have the input socket always present. Specifying
|
||||
// it now has no effect.
|
||||
for (const [name, spec] of Object.entries(def.input.required ?? {})) {
|
||||
const inputOptions = spec[1]
|
||||
if (inputOptions && inputOptions.defaultInput) {
|
||||
console.warn(
|
||||
`Use of defaultInput on required input ${nodeDef.python_module}:${nodeDef.name}:${name} is deprecated. Please drop the defaultInput option.`
|
||||
)
|
||||
}
|
||||
}
|
||||
// For optional inputs, defaultInput is used to distinguish the null state.
|
||||
// We migrate it to forceInput. One example is the "seed_override" input usage.
|
||||
// User can connect the socket to override the seed.
|
||||
for (const [name, spec] of Object.entries(def.input.optional ?? {})) {
|
||||
const inputOptions = spec[1]
|
||||
if (inputOptions && inputOptions.defaultInput) {
|
||||
console.warn(
|
||||
`Use of defaultInput on optional input ${nodeDef.python_module}:${nodeDef.name}:${name} is deprecated. Please use forceInput instead.`
|
||||
)
|
||||
inputOptions.forceInput = true
|
||||
}
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
constructor(def: ComfyNodeDefV1) {
|
||||
const obj = ComfyNodeDefImpl.#migrateDefaultInput(def)
|
||||
|
||||
/**
|
||||
* Assign extra fields to `this` for compatibility with group node feature.
|
||||
* TODO: Remove this once group node feature is removed.
|
||||
|
||||
7
src/types/litegraph-augmentation.d.ts
vendored
7
src/types/litegraph-augmentation.d.ts
vendored
@@ -26,13 +26,6 @@ declare module '@comfyorg/litegraph/dist/types/widgets' {
|
||||
* The minimum size of the node if the widget is present.
|
||||
*/
|
||||
minNodeSize?: Size
|
||||
/**
|
||||
* Whether the widget defaults to input state. Can still be converted back
|
||||
* to widget state.
|
||||
* @deprecated Widget to input conversion is no longer necessary, as they co-exist now.
|
||||
* This option no longer has any effect.
|
||||
*/
|
||||
defaultInput?: boolean
|
||||
}
|
||||
|
||||
interface IBaseWidget {
|
||||
|
||||
Reference in New Issue
Block a user