mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-05 21:20:12 +00:00
Migrate defaultInput widget option (#3364)
Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user