Handle change in ComfyUI widget config dropping minWidth/minHeight. Fixes #443

This commit is contained in:
rgthree
2025-03-17 21:08:16 -04:00
parent 32142fe476
commit 4c87142dda
2 changed files with 21 additions and 5 deletions
+13 -2
View File
@@ -7,6 +7,7 @@ import type {
ContextMenuItem,
INodeOutputSlot,
INodeInputSlot,
Vector2,
} from "typings/litegraph.js";
import type { RgthreeBaseServerNodeConstructor, RgthreeBaseVirtualNodeConstructor } from "typings/rgthree.js";
@@ -317,6 +318,12 @@ export class RgthreeBaseServerNode extends RgthreeBaseNode {
return ComfyWidgets;
}
override computeSize(out?: Vector2): [number, number] {
const v = super.computeSize(out);
console.log('comuteSize', v);
return v;
}
/**
* This takes the server data and builds out the inputs, outputs and widgets. It's similar to the
* ComfyNode constructor in registerNodes in ComfyUI's app.js, but is more stable and thus
@@ -396,8 +403,12 @@ export class RgthreeBaseServerNode extends RgthreeBaseNode {
}
const s = this.computeSize();
s[0] = Math.max(config.minWidth, s[0] * 1.5);
s[1] = Math.max(config.minHeight, s[1]);
// Sometime around v1.12.6 this broke as `minWidth` and `minHeight` were being explicitly set
// to `undefined` in the above Object.assign call (specifically for `WIDGETS[INT]`. We can avoid
// that by ensureing we're at a number in that case.
// See https://github.com/Comfy-Org/ComfyUI_frontend/issues/3045
s[0] = Math.max(config.minWidth ?? 1, s[0] * 1.5);
s[1] = Math.max(config.minHeight ?? 1, s[1]);
this.size = s;
this.serialize_widgets = true;
}
+8 -3
View File
@@ -193,8 +193,13 @@ export class RgthreeBaseServerNode extends RgthreeBaseNode {
getWidgets() {
return ComfyWidgets;
}
computeSize(out) {
const v = super.computeSize(out);
console.log('comuteSize', v);
return v;
}
async setupFromServerNodeData() {
var _a, _b, _c;
var _a, _b, _c, _d, _e;
const nodeData = this.constructor.nodeData;
if (!nodeData) {
throw Error("No node data");
@@ -254,8 +259,8 @@ export class RgthreeBaseServerNode extends RgthreeBaseNode {
this.addOutput(outputName, output, { shape: outputShape });
}
const s = this.computeSize();
s[0] = Math.max(config.minWidth, s[0] * 1.5);
s[1] = Math.max(config.minHeight, s[1]);
s[0] = Math.max((_d = config.minWidth) !== null && _d !== void 0 ? _d : 1, s[0] * 1.5);
s[1] = Math.max((_e = config.minHeight) !== null && _e !== void 0 ? _e : 1, s[1]);
this.size = s;
this.serialize_widgets = true;
}