(slot: INodeInputSlot, node: LGraphNode, afterRerouteId?: RerouteId)
| 42 | } |
| 43 | |
| 44 | override connect(slot: INodeInputSlot, node: LGraphNode, afterRerouteId?: RerouteId): LLink | undefined { |
| 45 | const { subgraph } = this.parent |
| 46 | |
| 47 | // Allow nodes to block connection |
| 48 | const inputIndex = node.inputs.indexOf(slot) |
| 49 | if (node.onConnectInput?.(inputIndex, this.type, this, this.parent, -1) === false) return |
| 50 | |
| 51 | // if (slot instanceof SubgraphOutput) { |
| 52 | // // Subgraph IO nodes have no special handling at present. |
| 53 | // return new LLink( |
| 54 | // ++subgraph.state.lastLinkId, |
| 55 | // this.type, |
| 56 | // this.parent.id, |
| 57 | // this.parent.slots.indexOf(this), |
| 58 | // node.id, |
| 59 | // inputIndex, |
| 60 | // afterRerouteId, |
| 61 | // ) |
| 62 | // } |
| 63 | |
| 64 | // Disconnect target input, if it is already connected. |
| 65 | if (slot.link != null) { |
| 66 | subgraph.beforeChange() |
| 67 | const link = subgraph.getLink(slot.link) |
| 68 | this.parent._disconnectNodeInput(node, slot, link) |
| 69 | } |
| 70 | |
| 71 | const inputWidget = node.getWidgetFromSlot(slot) |
| 72 | if (inputWidget) { |
| 73 | if (!this.matchesWidget(inputWidget)) { |
| 74 | console.warn("Target input has invalid widget.", slot, node) |
| 75 | return |
| 76 | } |
| 77 | |
| 78 | this._widget ??= inputWidget |
| 79 | this.events.dispatch("input-connected", { input: slot, widget: inputWidget }) |
| 80 | } |
| 81 | |
| 82 | const link = new LLink( |
| 83 | ++subgraph.state.lastLinkId, |
| 84 | slot.type, |
| 85 | this.parent.id, |
| 86 | this.parent.slots.indexOf(this), |
| 87 | node.id, |
| 88 | inputIndex, |
| 89 | afterRerouteId, |
| 90 | ) |
| 91 | |
| 92 | // Add to graph links list |
| 93 | subgraph._links.set(link.id, link) |
| 94 | |
| 95 | // Set link ID in each slot |
| 96 | this.linkIds.push(link.id) |
| 97 | slot.link = link.id |
| 98 | |
| 99 | // Reroutes |
| 100 | const reroutes = LLink.getReroutes(subgraph, link) |
| 101 | for (const reroute of reroutes) { |
no test coverage detected