forked from ltdrdata/ComfyUI-Impact-Pack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
comboBoolMigration.js
35 lines (28 loc) · 800 Bytes
/
comboBoolMigration.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { ComfyApp, app } from "../../scripts/app.js";
let conflict_check = undefined;
app.registerExtension({
name: "Comfy.impact.comboBoolMigration",
nodeCreated(node, app) {
for(let i in node.widgets) {
let widget = node.widgets[i];
if(conflict_check == undefined) {
conflict_check = !!app.extensions.find((ext) => ext.name === "Comfy.comboBoolMigration");
}
if(conflict_check)
return;
if(widget.type == "toggle") {
let value = widget.value;
var v = Object.getOwnPropertyDescriptor(widget, 'value');
if(!v) {
Object.defineProperty(widget, "value", {
set: (value) => {
delete widget.value;
widget.value = value == true || value == widget.options.on;
},
get: () => { return value; }
});
}
}
}
}
});