From e4f449910eb31b58b264f49494657529747fa4b7 Mon Sep 17 00:00:00 2001 From: jessesep Date: Fri, 5 Dec 2025 02:15:01 +0100 Subject: [PATCH] Add debug logging and fix node type paths --- web/simplevariables.js | 70 ++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/web/simplevariables.js b/web/simplevariables.js index c63e047..d4dfc56 100644 --- a/web/simplevariables.js +++ b/web/simplevariables.js @@ -12,41 +12,45 @@ app.registerExtension({ constructor(title) { super(title); + const node = this; + this.properties = this.properties || {}; this.properties.variableName = ""; // Variable name widget this.addWidget("text", "name", "", (value) => { - this.properties.variableName = value; - this.title = value ? `Set: ${value}` : "Set Variable"; - this.updateGetters(); + node.properties.variableName = value; + node.title = value ? `Set: ${value}` : "Set Variable"; + node.updateGetters(); }); // Input and passthrough output this.addInput("value", "*"); this.addOutput("value", "*"); - this.onConnectionsChange = (slotType, slot, isConnect, linkInfo) => { - if (slotType === 1 && this.inputs[0]) { // Input changed + this.onConnectionsChange = function(slotType, slot, isConnect, linkInfo) { + if (slotType === 1 && node.inputs[0]) { // Input changed if (isConnect && linkInfo) { - const type = this.getInputType(0); + const type = node.getInputType(0); if (type) { - this.inputs[0].type = type; - this.inputs[0].name = type; - this.outputs[0].type = type; - this.outputs[0].name = type; + node.inputs[0].type = type; + node.inputs[0].name = type; + node.outputs[0].type = type; + node.outputs[0].name = type; } } else if (!isConnect) { - this.inputs[0].type = "*"; - this.inputs[0].name = "value"; - this.outputs[0].type = "*"; - this.outputs[0].name = "value"; + node.inputs[0].type = "*"; + node.inputs[0].name = "value"; + node.outputs[0].type = "*"; + node.outputs[0].name = "value"; } - this.updateGetters(); + node.updateGetters(); } }; this.isVirtualNode = true; + + console.log("[SimpleVariables] SetVariableNode created, type:", this.type); } getInputType(slot) { @@ -63,9 +67,11 @@ app.registerExtension({ updateGetters() { if (!this.graph) return; const name = this.properties.variableName; - this.graph._nodes.forEach(node => { - if (node.type === "GetVariableNode" && node.properties.variableName === name) { - node.syncWithSetter(); + console.log("[SimpleVariables] Updating getters for:", name); + this.graph._nodes.forEach(n => { + console.log("[SimpleVariables] Checking node:", n.type, n.properties?.variableName); + if (n.type === "SetVariableNode/variables" || n.type === "GetVariableNode/variables") { + console.log("[SimpleVariables] Found variable node"); } }); } @@ -75,10 +81,11 @@ app.registerExtension({ } } - LiteGraph.registerNodeType("SetVariableNode", Object.assign(SetVariableNode, { + LiteGraph.registerNodeType("SetVariableNode/variables", Object.assign(SetVariableNode, { title: "Set Variable", })); - SetVariableNode.category = "variables"; + + console.log("[SimpleVariables] SetVariableNode registered"); } }); @@ -101,12 +108,21 @@ app.registerExtension({ node.syncWithSetter(); }, { values: () => { - if (!node.graph) return [""]; - const setters = node.graph._nodes.filter(n => n.type === "SetVariableNode"); + if (!node.graph) { + console.log("[SimpleVariables] No graph available"); + return [""]; + } + console.log("[SimpleVariables] Looking for setters in", node.graph._nodes.length, "nodes"); + const setters = node.graph._nodes.filter(n => { + const isSet = n.type === "SetVariableNode/variables"; + if (isSet) console.log("[SimpleVariables] Found setter:", n.properties?.variableName, n.widgets?.[0]?.value); + return isSet; + }); const names = setters .map(n => n.properties?.variableName || n.widgets?.[0]?.value || "") .filter(n => n !== "") .sort(); + console.log("[SimpleVariables] Available names:", names); return ["", ...names]; } }); @@ -118,13 +134,15 @@ app.registerExtension({ }; this.isVirtualNode = true; + + console.log("[SimpleVariables] GetVariableNode created, type:", this.type); } findSetter() { if (!this.graph || !this.properties.variableName) return null; const name = this.properties.variableName; return this.graph._nodes.find(n => - n.type === "SetVariableNode" && + n.type === "SetVariableNode/variables" && (n.properties?.variableName === name || n.widgets?.[0]?.value === name) ); } @@ -143,7 +161,6 @@ app.registerExtension({ validateLinks() { if (!this.outputs[0].links || this.outputs[0].type === "*") return; - // Remove incompatible links const linksToRemove = []; this.outputs[0].links.forEach(linkId => { const link = this.graph.links[linkId]; @@ -168,9 +185,10 @@ app.registerExtension({ } } - LiteGraph.registerNodeType("GetVariableNode", Object.assign(GetVariableNode, { + LiteGraph.registerNodeType("GetVariableNode/variables", Object.assign(GetVariableNode, { title: "Get Variable", })); - GetVariableNode.category = "variables"; + + console.log("[SimpleVariables] GetVariableNode registered"); } });