Fix reroute nodes that stopped positioning their inputs/outputs after ComfyOrg/litegraph deprecated getConnectionPos. Addresses #447 and #449

This commit is contained in:
rgthree
2025-03-25 22:36:22 -04:00
parent ab37a0bd37
commit 3d30a6de68
2 changed files with 16 additions and 2 deletions
+10 -2
View File
@@ -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]) {
+6
View File
@@ -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;