improve support for 'ANY' type

This commit is contained in:
Sebastian 2023-08-13 21:09:42 +02:00
parent c9b11405f5
commit 9bc420464b
3 changed files with 10 additions and 5 deletions

View File

@ -431,7 +431,7 @@ def validate_inputs(prompt, item, validated):
o_id = val[0]
o_class_type = prompt[o_id]['class_type']
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]]
details = f"{x}, {received_type} != {type_input}"
error = {

View File

@ -2,7 +2,7 @@ import { ComfyWidgets, addValueControlWidget } from "../../scripts/widgets.js";
import { app } from "../../scripts/app.js";
const CONVERTED_TYPE = "converted-widget";
const VALID_TYPES = ["STRING", "combo", "number", "BOOLEAN"];
const VALID_TYPES = ["STRING", "combo", "number", "BOOLEAN", "*"];
function isConvertableWidget(widget, config) {
return VALID_TYPES.includes(widget.type) || VALID_TYPES.includes(config[0]);
@ -169,8 +169,8 @@ app.registerExtension({
const input = this.inputs[slot];
if (!input.widget || !input[ignoreDblClick]) {
// Not a widget input or already handled input
if (!(input.type in ComfyWidgets) && !(input.widget.config?.[0] instanceof Array)) {
return r; //also Not a ComfyWidgets input or combo (do nothing)
if (!(input.type in ComfyWidgets) && input.type != "*" && !(input.widget.config?.[0] instanceof Array)) {
return r; //also Not a ComfyWidgets input, 'ANY' or combo (do nothing)
}
}
@ -287,7 +287,7 @@ app.registerExtension({
if (!input) return;
var _widget;
let _widget;
if (!input.widget) {
if (!(input.type in ComfyWidgets)) return;
_widget = { "name": input.name, "config": [input.type, {}] }//fake widget
@ -315,6 +315,8 @@ app.registerExtension({
let widget;
if (type in ComfyWidgets) {
widget = (ComfyWidgets[type](this, "value", inputData, app) || {}).widget;
} else if (type == "*") {
widget = (ComfyWidgets.STRING(this, "value", ["STRING", {"default": ""}], app) || {}).widget;
} else {
widget = this.addWidget(type, "value", null, () => { }, {});
}

View File

@ -1155,6 +1155,9 @@ export class ComfyApp {
} else if (type in widgets) {
// Standard type widgets
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 {
// Node connection inputs
this.addInput(inputName, type);