From 3d30a6de680d66afa3bef8639d9099bad79e71de Mon Sep 17 00:00:00 2001 From: rgthree Date: Tue, 25 Mar 2025 22:36:22 -0400 Subject: [PATCH] Fix reroute nodes that stopped positioning their inputs/outputs after ComfyOrg/litegraph deprecated getConnectionPos. Addresses #447 and #449 --- src_web/comfyui/utils.ts | 12 ++++++++++-- web/comfyui/utils.js | 6 ++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src_web/comfyui/utils.ts b/src_web/comfyui/utils.ts index 48be876..cf3a5bd 100644 --- a/src_web/comfyui/utils.ts +++ b/src_web/comfyui/utils.ts @@ -225,12 +225,20 @@ export function addConnectionLayoutSupport( }, }); - // const oldGetConnectionPos = node.prototype.getConnectionPos; + // [🤮] This is deprecated in a https://github.com/Comfy-Org/litegraph.js/pull/716 @v0.9.9 and + // replaced by getInputPos and getOutputPos conveniently added below. node.prototype.getConnectionPos = function (isInput: boolean, slotNumber: number, out: Vector2) { // Purposefully do not need to call the old one. - // oldGetConnectionPos && oldGetConnectionPos.apply(this, [isInput, slotNumber, out]); return getConnectionPosForLayout(this, isInput, slotNumber, out); }; + node.prototype.getInputPos = function(slotNumber: number) : Vector2 { + // Purposefully do not need to call the existing one because we're overriding. + return getConnectionPosForLayout(this, true, slotNumber, [0,0]); + } + node.prototype.getOutputPos = function(slotNumber: number) : Vector2 { + // Purposefully do not need to call the existing one because we're overriding. + return getConnectionPosForLayout(this, false, slotNumber, [0,0]); + } } export function setConnectionsLayout(node: LGraphNode, newLayout: [string, string]) { diff --git a/web/comfyui/utils.js b/web/comfyui/utils.js index 929ba76..b736352 100644 --- a/web/comfyui/utils.js +++ b/web/comfyui/utils.js @@ -147,6 +147,12 @@ export function addConnectionLayoutSupport(node, app, options = [ node.prototype.getConnectionPos = function (isInput, slotNumber, out) { return getConnectionPosForLayout(this, isInput, slotNumber, out); }; + node.prototype.getInputPos = function (slotNumber) { + return getConnectionPosForLayout(this, true, slotNumber, [0, 0]); + }; + node.prototype.getOutputPos = function (slotNumber) { + return getConnectionPosForLayout(this, false, slotNumber, [0, 0]); + }; } export function setConnectionsLayout(node, newLayout) { var _a;