MCPcopy Create free account
hub / github.com/Comfy-Org/litegraph.js / connectByType

Method connectByType

src/subgraph/SubgraphInputNode.ts:98–120  ·  view source on GitHub ↗
(
    slot: number,
    target_node: LGraphNode,
    target_slotType: ISlotType,
    optsIn?: { afterRerouteId?: RerouteId },
  )

Source from the content-addressed store, hash-verified

96 // #region Legacy LGraphNode compatibility
97
98 connectByType(
99 slot: number,
100 target_node: LGraphNode,
101 target_slotType: ISlotType,
102 optsIn?: { afterRerouteId?: RerouteId },
103 ): LLink | undefined {
104 const inputSlot = target_node.findInputByType(target_slotType)
105 if (!inputSlot) return
106
107 if (slot === -1) {
108 // This indicates a connection is being made from the "Empty" slot.
109 // We need to create a new, concrete input on the subgraph that matches the target.
110 const newSubgraphInput = this.subgraph.addInput(inputSlot.slot.name, String(inputSlot.slot.type ?? ""))
111 const newSlotIndex = this.slots.indexOf(newSubgraphInput)
112 if (newSlotIndex === -1) {
113 console.error("Could not find newly created subgraph input slot.")
114 return
115 }
116 slot = newSlotIndex
117 }
118
119 return this.slots[slot].connect(inputSlot.slot, target_node, optsIn?.afterRerouteId)
120 }
121
122 findOutputSlot(name: string): SubgraphInput | undefined {
123 return this.slots.find(output => output.name === name)

Callers

nothing calls this directly

Calls 3

findInputByTypeMethod · 0.45
addInputMethod · 0.45
connectMethod · 0.45

Tested by

no test coverage detected