Switch Power Puter and Power Primitive to use BOOLEAN, not BOOL. Fixes #520

This commit is contained in:
rgthree
2025-06-22 22:49:44 -04:00
parent 417d485ac8
commit 51bc089334
9 changed files with 48 additions and 26 deletions
+2 -2
View File
@@ -175,7 +175,7 @@ Note, you can right-click on a bunch of the rgthree-comfy nodes and select `🛟
## Power Primitive
> A single node that can output primitives (STRING, INT, FLOAT, BOOL). If connecting an input, it will cast/convert the primitive input to the desired output.
> A single node that can output primitives (STRING, INT, FLOAT, BOOLEAN). If connecting an input, it will cast/convert the primitive input to the desired output.
> <details>
> <summary>ℹ️ <i>More Information</i></summary>
>
@@ -192,7 +192,7 @@ Note, you can right-click on a bunch of the rgthree-comfy nodes and select `🛟
> <details>
> <summary>ℹ️ <i>More Information</i></summary>
>
> - Evaluate almost any kind of input and more, and choose your output from INT, FLOAT, STRING, or BOOL.
> - Evaluate almost any kind of input and more, and choose your output from INT, FLOAT, STRING, or BOOLEAN.
> - Connect some nodes and do simply math operations like `a + b` or `ceil(1 / 2)`.
> - Or do more advanced things, like input an image, and get the width like `a.shape[2]`.
> - Even more powerful, you can target nodes in the prompt that's sent to the backend. For instance; if you have a Power Lora Loader node at id #5, and want to get a comma-delimited list of the enabled loras, you could enter:
+5
View File
@@ -43,6 +43,11 @@ output_to_type = {
'cast': lambda x: int(cast_to_float(x)),
'null': 0,
},
'BOOLEAN': {
'cast': cast_to_bool,
'null': False,
},
# This can be removed soon, there was a bug where this should have been BOOLEAN
'BOOL': {
'cast': cast_to_bool,
'null': False,
+4 -1
View File
@@ -230,7 +230,10 @@ class RgthreePowerPuter:
value = int(value)
elif output == 'FLOAT':
value = float(value)
elif output == 'BOOL':
# Accidentally defined "BOOL" when should have been "BOOLEAN."
# TODO: Can prob get rid of BOOl after a bit when UIs would be updated from sending
# BOOL incorrectly.
elif output in ('BOOL', 'BOOLEAN'):
value = bool(value)
elif output == 'STRING':
if isinstance(value, (dict, list)):
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "rgthree-comfy"
description = "Making ComfyUI more comfortable."
version = "1.0.2506222201"
version = "1.0.2506222249"
license = { file = "LICENSE" }
dependencies = []
+6 -2
View File
@@ -24,7 +24,7 @@ const PRIMITIVES = {
// "STRING (multiline)": "STRING",
INT: "INT",
FLOAT: "FLOAT",
BOOL: "BOOL",
BOOLEAN: "BOOLEAN",
};
class RgthreePowerPrimitive extends RgthreeBaseServerNode {
@@ -65,6 +65,10 @@ class RgthreePowerPrimitive extends RgthreeBaseServerNode {
*/
override configure(info: ISerialisedNode): void {
super.configure(info);
// Update BOOL to BOOLEAN due to a bug using BOOL instead of BOOLEAN.
if (this.outputTypeWidget.value === 'BOOL') {
this.outputTypeWidget.value = 'BOOLEAN';
}
setTimeout(() => {
this.setTypedData();
});
@@ -157,7 +161,7 @@ class RgthreePowerPrimitive extends RgthreeBaseServerNode {
value = Number(value);
value = value == null || isNaN(value) ? 0 : value;
newWidget.value = value;
} else if (type === "BOOL") {
} else if (type === "BOOLEAN") {
newWidget = this.addWidget("toggle", name, !!(value ?? true), undefined, {
on: "true",
off: "false",
+17 -7
View File
@@ -7,6 +7,7 @@ import type {
} from "@comfyorg/litegraph";
import type {ComfyNodeDef} from "typings/comfy.js";
import type {CanvasMouseEvent} from "@comfyorg/litegraph/dist/types/events.js";
import type {ISerialisedNode} from "@comfyorg/litegraph/dist/types/serialisation.js";
import {app} from "scripts/app.js";
import {RgthreeBaseServerNode} from "./base_node.js";
@@ -26,7 +27,7 @@ import {rgthree} from "./rgthree.js";
const ALPHABET = "abcdefghijklmnopqrstuv".split("");
const OUTPUT_TYPES = ["STRING", "INT", "FLOAT", "BOOL", "*"];
const OUTPUT_TYPES = ["STRING", "INT", "FLOAT", "BOOLEAN", "*"];
class RgthreePowerPuter extends RgthreeBaseServerNode {
static override title = NodeTypesString.POWER_PUTER;
@@ -44,6 +45,16 @@ class RgthreePowerPuter extends RgthreeBaseServerNode {
this.addInitialWidgets();
}
// /**
// * We need to patch in the configure to fix a bug where Power Puter was using BOOL instead of
// * BOOLEAN.
// */
// override configure(info: ISerialisedNode): void {
// super.configure(info);
// // Update BOOL to BOOLEAN due to a bug using BOOL instead of BOOLEAN.
// this.outputTypeWidget
// }
static override setUp(comfyClass: LGraphNodeConstructor, nodeData: ComfyNodeDef) {
RgthreeBaseServerNode.registerForOverride(comfyClass, nodeData, NODE_CLASS);
}
@@ -112,7 +123,7 @@ class RgthreePowerPuter extends RgthreeBaseServerNode {
<ul>
<li><p>
Evaluate almost any kind of input and more, and choose your output from INT, FLOAT,
STRING, or BOOL.
STRING, or BOOLEAN.
</p></li>
<li><p>
Connect some nodes and do simply math operations like <code>a + b</code> or
@@ -196,11 +207,10 @@ class OutputsWidget extends RgthreeBaseWidget<OutputsWidgetValue> {
set value(v: OutputsWidgetValue) {
// Handle a string being passed in, as the original Power Puter output widget was a string.
if (typeof v === "string") {
this._value.outputs = [v];
} else {
this._value.outputs = [...v.outputs];
}
let outputs = typeof v === "string" ? [v] : [...v.outputs];
// Handle a case where the initial version used "BOOL" instead of "BOOLEAN" incorrectly.
outputs = outputs.map(o => o === 'BOOL' ? 'BOOLEAN' : o)
this._value.outputs = outputs;
}
get value(): OutputsWidgetValue {
+3 -3
View File
@@ -35,9 +35,9 @@ describe("TestPowerPuter", async () => {
// FLOAT
["1", "1.0", "FLOAT"],
["1.3 + 2.8", "4.1", "FLOAT"],
// BOOL
["1", "True", "BOOL"],
["1 - 1", "False", "BOOL"],
// BOOLEAN
["1", "True", "BOOLEAN"],
["1 - 1", "False", "BOOLEAN"],
];
for (const data of checks) {
setPowerPuterValue(powerPuter, data[0], data[2]);
+5 -2
View File
@@ -8,7 +8,7 @@ const PRIMITIVES = {
STRING: "STRING",
INT: "INT",
FLOAT: "FLOAT",
BOOL: "BOOL",
BOOLEAN: "BOOLEAN",
};
class RgthreePowerPrimitive extends RgthreeBaseServerNode {
constructor(title = NODE_CLASS.title) {
@@ -26,6 +26,9 @@ class RgthreePowerPrimitive extends RgthreeBaseServerNode {
}
configure(info) {
super.configure(info);
if (this.outputTypeWidget.value === 'BOOL') {
this.outputTypeWidget.value = 'BOOLEAN';
}
setTimeout(() => {
this.setTypedData();
});
@@ -95,7 +98,7 @@ class RgthreePowerPrimitive extends RgthreeBaseServerNode {
value = value == null || isNaN(value) ? 0 : value;
newWidget.value = value;
}
else if (type === "BOOL") {
else if (type === "BOOLEAN") {
newWidget = this.addWidget("toggle", name, !!(value !== null && value !== void 0 ? value : true), undefined, {
on: "true",
off: "false",
+5 -8
View File
@@ -8,7 +8,7 @@ import { RgthreeBaseWidget } from "./utils_widgets.js";
import { drawPlusIcon, drawRoundedRectangle, drawWidgetButton, isLowQuality, measureText, } from "./utils_canvas.js";
import { rgthree } from "./rgthree.js";
const ALPHABET = "abcdefghijklmnopqrstuv".split("");
const OUTPUT_TYPES = ["STRING", "INT", "FLOAT", "BOOL", "*"];
const OUTPUT_TYPES = ["STRING", "INT", "FLOAT", "BOOLEAN", "*"];
class RgthreePowerPuter extends RgthreeBaseServerNode {
constructor(title = NODE_CLASS.title) {
super(title);
@@ -72,7 +72,7 @@ class RgthreePowerPuter extends RgthreeBaseServerNode {
<ul>
<li><p>
Evaluate almost any kind of input and more, and choose your output from INT, FLOAT,
STRING, or BOOL.
STRING, or BOOLEAN.
</p></li>
<li><p>
Connect some nodes and do simply math operations like <code>a + b</code> or
@@ -127,12 +127,9 @@ class OutputsWidget extends RgthreeBaseWidget {
this.node = node;
}
set value(v) {
if (typeof v === "string") {
this._value.outputs = [v];
}
else {
this._value.outputs = [...v.outputs];
}
let outputs = typeof v === "string" ? [v] : [...v.outputs];
outputs = outputs.map(o => o === 'BOOL' ? 'BOOLEAN' : o);
this._value.outputs = outputs;
}
get value() {
return this._value;