File size: 765 Bytes
baa8e90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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;
				Object.defineProperty(widget, "value", {
					set: (value) => {
							delete widget.value;
							widget.value = value == true || value == widget.options.on;
						},
					get: () => { return value; }
				});
			}
		}
	}
});