MCPcopy Index your code
hub / github.com/rgthree/rgthree-comfy / addConnectionLayoutSupport

Function addConnectionLayoutSupport

js/utils.js:67–91  ·  view source on GitHub ↗
(node, app, options = [['Left', 'Right'], ['Right', 'Left']], callback)

Source from the content-addressed store, hash-verified

65 };
66}
67export function addConnectionLayoutSupport(node, app, options = [['Left', 'Right'], ['Right', 'Left']], callback) {
68 addMenuSubMenu(node, app, {
69 name: 'Connections Layout',
70 property: 'connections_layout',
71 options: options.map(option => option[0] + (option[1] ? ' -> ' + option[1] : '')),
72 prepareValue: (value, node) => {
73 var _a;
74 const values = value.split(' -> ');
75 if (!values[1] && !((_a = node.outputs) === null || _a === void 0 ? void 0 : _a.length)) {
76 values[1] = OPPOSITE_LABEL[values[0]];
77 }
78 if (!LAYOUT_LABEL_TO_DATA[values[0]] || !LAYOUT_LABEL_TO_DATA[values[1]]) {
79 throw new Error(`New Layout invalid: [${values[0]}, ${values[1]}]`);
80 }
81 return values;
82 },
83 callback: (node) => {
84 callback && callback(node);
85 app.graph.setDirtyCanvas(true, true);
86 },
87 });
88 node.prototype.getConnectionPos = function (isInput, slotNumber, out) {
89 return getConnectionPosForLayout(this, isInput, slotNumber, out);
90 };
91}
92export function setConnectionsLayout(node, newLayout = ['Left', 'Right']) {
93 var _a;
94 if (!newLayout[1] && !((_a = node.outputs) === null || _a === void 0 ? void 0 : _a.length)) {

Callers 15

registerCustomNodesFunction · 0.90
beforeRegisterNodeDefFunction · 0.90
beforeRegisterNodeDefFunction · 0.90
setUpMethod · 0.90
beforeRegisterNodeDefFunction · 0.90
registerCustomNodesFunction · 0.90
registerCustomNodesFunction · 0.90
registerCustomNodesFunction · 0.90
registerCustomNodesFunction · 0.90
beforeRegisterNodeDefFunction · 0.90
beforeRegisterNodeDefFunction · 0.90
beforeRegisterNodeDefFunction · 0.90

Calls 2

addMenuSubMenuFunction · 0.70

Tested by

no test coverage detected