(node, app, options = [['Left', 'Right'], ['Right', 'Left']], callback)
| 65 | }; |
| 66 | } |
| 67 | export 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 | } |
| 92 | export function setConnectionsLayout(node, newLayout = ['Left', 'Right']) { |
| 93 | var _a; |
| 94 | if (!newLayout[1] && !((_a = node.outputs) === null || _a === void 0 ? void 0 : _a.length)) { |
no test coverage detected