mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-06-08 20:42:11 +08:00
Fix extension widgets not working.
This commit is contained in:
parent
5d5c320054
commit
ec7a00aa96
@ -1,6 +1,5 @@
|
|||||||
import { app } from "../../scripts/app.js";
|
import { app } from "../../scripts/app.js";
|
||||||
import { api } from "../../scripts/api.js";
|
import { api } from "../../scripts/api.js";
|
||||||
import { getWidgetType } from "../../scripts/widgets.js";
|
|
||||||
import { mergeIfValid } from "./widgetInputs.js";
|
import { mergeIfValid } from "./widgetInputs.js";
|
||||||
|
|
||||||
const GROUP = Symbol();
|
const GROUP = Symbol();
|
||||||
@ -332,7 +331,7 @@ export class GroupNodeConfig {
|
|||||||
const converted = new Map();
|
const converted = new Map();
|
||||||
const widgetMap = (this.oldToNewWidgetMap[node.index] = {});
|
const widgetMap = (this.oldToNewWidgetMap[node.index] = {});
|
||||||
for (const inputName of inputNames) {
|
for (const inputName of inputNames) {
|
||||||
let widgetType = getWidgetType(inputs[inputName], inputName);
|
let widgetType = app.getWidgetType(inputs[inputName], inputName);
|
||||||
if (widgetType) {
|
if (widgetType) {
|
||||||
const convertedIndex = node.inputs?.findIndex(
|
const convertedIndex = node.inputs?.findIndex(
|
||||||
(inp) => inp.name === inputName && inp.widget?.name === inputName
|
(inp) => inp.name === inputName && inp.widget?.name === inputName
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { ComfyLogging } from "./logging.js";
|
import { ComfyLogging } from "./logging.js";
|
||||||
import { ComfyWidgets, getWidgetType } from "./widgets.js";
|
import { ComfyWidgets } from "./widgets.js";
|
||||||
import { ComfyUI, $el } from "./ui.js";
|
import { ComfyUI, $el } from "./ui.js";
|
||||||
import { api } from "./api.js";
|
import { api } from "./api.js";
|
||||||
import { defaultGraph } from "./defaultGraph.js";
|
import { defaultGraph } from "./defaultGraph.js";
|
||||||
@ -1377,6 +1377,20 @@ export class ComfyApp {
|
|||||||
await this.#invokeExtensionsAsync("registerCustomNodes");
|
await this.#invokeExtensionsAsync("registerCustomNodes");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getWidgetType(inputData, inputName) {
|
||||||
|
const type = inputData[0];
|
||||||
|
|
||||||
|
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 {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async registerNodeDef(nodeId, nodeData) {
|
async registerNodeDef(nodeId, nodeData) {
|
||||||
const self = this;
|
const self = this;
|
||||||
const node = Object.assign(
|
const node = Object.assign(
|
||||||
@ -1391,7 +1405,7 @@ export class ComfyApp {
|
|||||||
const type = inputData[0];
|
const type = inputData[0];
|
||||||
|
|
||||||
let widgetCreated = true;
|
let widgetCreated = true;
|
||||||
const widgetType = getWidgetType(inputData, inputName);
|
const widgetType = self.getWidgetType(inputData, inputName);
|
||||||
if(widgetType) {
|
if(widgetType) {
|
||||||
if(widgetType === "COMBO") {
|
if(widgetType === "COMBO") {
|
||||||
Object.assign(config, self.widgets.COMBO(this, inputName, inputData, app) || {});
|
Object.assign(config, self.widgets.COMBO(this, inputName, inputData, app) || {});
|
||||||
|
@ -23,20 +23,6 @@ function getNumberDefaults(inputData, defaultStep, precision, enable_rounding) {
|
|||||||
return { val: defaultVal, config: { min, max, step: 10.0 * step, round, precision } };
|
return { val: defaultVal, config: { min, max, step: 10.0 * step, round, precision } };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getWidgetType(inputData, inputName) {
|
|
||||||
const type = inputData[0];
|
|
||||||
|
|
||||||
if (Array.isArray(type)) {
|
|
||||||
return "COMBO";
|
|
||||||
} else if (`${type}:${inputName}` in ComfyWidgets) {
|
|
||||||
return `${type}:${inputName}`;
|
|
||||||
} else if (type in ComfyWidgets) {
|
|
||||||
return type;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function addValueControlWidget(node, targetWidget, defaultValue = "randomize", values, widgetName, inputData) {
|
export function addValueControlWidget(node, targetWidget, defaultValue = "randomize", values, widgetName, inputData) {
|
||||||
let name = inputData[1]?.control_after_generate;
|
let name = inputData[1]?.control_after_generate;
|
||||||
if(typeof name !== "string") {
|
if(typeof name !== "string") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user