mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-06-21 23:39:35 +08:00
improve support for 'ANY' type
This commit is contained in:
parent
c9b11405f5
commit
9bc420464b
@ -431,7 +431,7 @@ def validate_inputs(prompt, item, validated):
|
|||||||
o_id = val[0]
|
o_id = val[0]
|
||||||
o_class_type = prompt[o_id]['class_type']
|
o_class_type = prompt[o_id]['class_type']
|
||||||
r = nodes.NODE_CLASS_MAPPINGS[o_class_type].RETURN_TYPES
|
r = nodes.NODE_CLASS_MAPPINGS[o_class_type].RETURN_TYPES
|
||||||
if r[val[1]] != type_input:
|
if r[val[1]] != type_input and type_input != "*":
|
||||||
received_type = r[val[1]]
|
received_type = r[val[1]]
|
||||||
details = f"{x}, {received_type} != {type_input}"
|
details = f"{x}, {received_type} != {type_input}"
|
||||||
error = {
|
error = {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { ComfyWidgets, addValueControlWidget } from "../../scripts/widgets.js";
|
|||||||
import { app } from "../../scripts/app.js";
|
import { app } from "../../scripts/app.js";
|
||||||
|
|
||||||
const CONVERTED_TYPE = "converted-widget";
|
const CONVERTED_TYPE = "converted-widget";
|
||||||
const VALID_TYPES = ["STRING", "combo", "number", "BOOLEAN"];
|
const VALID_TYPES = ["STRING", "combo", "number", "BOOLEAN", "*"];
|
||||||
|
|
||||||
function isConvertableWidget(widget, config) {
|
function isConvertableWidget(widget, config) {
|
||||||
return VALID_TYPES.includes(widget.type) || VALID_TYPES.includes(config[0]);
|
return VALID_TYPES.includes(widget.type) || VALID_TYPES.includes(config[0]);
|
||||||
@ -169,8 +169,8 @@ app.registerExtension({
|
|||||||
const input = this.inputs[slot];
|
const input = this.inputs[slot];
|
||||||
if (!input.widget || !input[ignoreDblClick]) {
|
if (!input.widget || !input[ignoreDblClick]) {
|
||||||
// Not a widget input or already handled input
|
// Not a widget input or already handled input
|
||||||
if (!(input.type in ComfyWidgets) && !(input.widget.config?.[0] instanceof Array)) {
|
if (!(input.type in ComfyWidgets) && input.type != "*" && !(input.widget.config?.[0] instanceof Array)) {
|
||||||
return r; //also Not a ComfyWidgets input or combo (do nothing)
|
return r; //also Not a ComfyWidgets input, 'ANY' or combo (do nothing)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,7 +287,7 @@ app.registerExtension({
|
|||||||
if (!input) return;
|
if (!input) return;
|
||||||
|
|
||||||
|
|
||||||
var _widget;
|
let _widget;
|
||||||
if (!input.widget) {
|
if (!input.widget) {
|
||||||
if (!(input.type in ComfyWidgets)) return;
|
if (!(input.type in ComfyWidgets)) return;
|
||||||
_widget = { "name": input.name, "config": [input.type, {}] }//fake widget
|
_widget = { "name": input.name, "config": [input.type, {}] }//fake widget
|
||||||
@ -315,6 +315,8 @@ app.registerExtension({
|
|||||||
let widget;
|
let widget;
|
||||||
if (type in ComfyWidgets) {
|
if (type in ComfyWidgets) {
|
||||||
widget = (ComfyWidgets[type](this, "value", inputData, app) || {}).widget;
|
widget = (ComfyWidgets[type](this, "value", inputData, app) || {}).widget;
|
||||||
|
} else if (type == "*") {
|
||||||
|
widget = (ComfyWidgets.STRING(this, "value", ["STRING", {"default": ""}], app) || {}).widget;
|
||||||
} else {
|
} else {
|
||||||
widget = this.addWidget(type, "value", null, () => { }, {});
|
widget = this.addWidget(type, "value", null, () => { }, {});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1155,6 +1155,9 @@ export class ComfyApp {
|
|||||||
} else if (type in widgets) {
|
} else if (type in widgets) {
|
||||||
// Standard type widgets
|
// Standard type widgets
|
||||||
Object.assign(config, widgets[type](this, inputName, inputData, app) || {});
|
Object.assign(config, widgets[type](this, inputName, inputData, app) || {});
|
||||||
|
} else if (type == "*") {
|
||||||
|
// 'ANY' type widgets
|
||||||
|
Object.assign(config, widgets.STRING(this, inputName, ["STRING", {}], app) || {});
|
||||||
} else {
|
} else {
|
||||||
// Node connection inputs
|
// Node connection inputs
|
||||||
this.addInput(inputName, type);
|
this.addInput(inputName, type);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user