Adds support for LiteGraph LiteGraph ES6 classes

This should continue to work unchanged on old versions of ComfyUI.

The changes just allow the set/get nodes to also work with the latest version of litegraph - conversion to proper classes is slowly going on.
This commit is contained in:
filtered 2024-08-13 01:16:21 +10:00
parent b751e34383
commit 7235a3dccf

View File

@ -30,6 +30,7 @@ function setColorAndBgColor(type) {
} }
let isAlertShown = false; let isAlertShown = false;
let disablePrefix = app.ui.settings.getSettingValue("KJNodes.disablePrefix") let disablePrefix = app.ui.settings.getSettingValue("KJNodes.disablePrefix")
const LGraphNode = LiteGraph.LGraphNode
function showAlertWithThrottle(message, delay) { function showAlertWithThrottle(message, delay) {
if (!isAlertShown) { if (!isAlertShown) {
@ -41,7 +42,7 @@ function showAlertWithThrottle(message, delay) {
app.registerExtension({ app.registerExtension({
name: "SetNode", name: "SetNode",
registerCustomNodes() { registerCustomNodes() {
class SetNode { class SetNode extends LGraphNode {
defaultVisibility = true; defaultVisibility = true;
serialize_widgets = true; serialize_widgets = true;
drawConnection = false; drawConnection = false;
@ -50,7 +51,8 @@ app.registerExtension({
canvas = app.canvas; canvas = app.canvas;
menuEntry = "Show connections"; menuEntry = "Show connections";
constructor() { constructor(title) {
super(title)
if (!this.properties) { if (!this.properties) {
this.properties = { this.properties = {
"previousName": "" "previousName": ""
@ -370,7 +372,7 @@ app.registerExtension({
app.registerExtension({ app.registerExtension({
name: "GetNode", name: "GetNode",
registerCustomNodes() { registerCustomNodes() {
class GetNode { class GetNode extends LGraphNode {
defaultVisibility = true; defaultVisibility = true;
serialize_widgets = true; serialize_widgets = true;
@ -379,7 +381,8 @@ app.registerExtension({
currentSetter = null; currentSetter = null;
canvas = app.canvas; canvas = app.canvas;
constructor() { constructor(title) {
super(title)
if (!this.properties) { if (!this.properties) {
this.properties = {}; this.properties = {};
} }