mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-03 06:47:33 +00:00
Merge remote-tracking branch 'origin/bl-more-slots' into bl-snap
This commit is contained in:
@@ -73,30 +73,8 @@ export class MovingInputLink extends MovingLinkBase {
|
||||
return link
|
||||
}
|
||||
|
||||
connectToOutput(
|
||||
outputNode: LGraphNode,
|
||||
output: INodeOutputSlot,
|
||||
events: CustomEventTarget<LinkConnectorEventMap>
|
||||
): LLink | null | undefined {
|
||||
if (
|
||||
outputNode === this.outputNode &&
|
||||
output === this.outputSlot &&
|
||||
this.inputSlot === this.inputNode.inputs[this.inputIndex]
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
const afterRerouteId = this.fromReroute?.id ?? this.link.parentId
|
||||
|
||||
this.inputNode.disconnectInput(this.inputIndex, true)
|
||||
const newLink = outputNode.connectSlots(
|
||||
output,
|
||||
this.inputNode,
|
||||
this.inputSlot,
|
||||
afterRerouteId
|
||||
)
|
||||
if (newLink) events.dispatch('input-moved', this)
|
||||
return newLink
|
||||
connectToOutput(): never {
|
||||
throw new Error('MovingInputLink cannot connect to an output.')
|
||||
}
|
||||
|
||||
connectToSubgraphInput(): void {
|
||||
|
||||
@@ -46,9 +46,8 @@ export function attachSlotLinkPreviewRenderer(canvas: LGraphCanvas) {
|
||||
if (!linkRenderer) return
|
||||
const context = buildContext(canvas)
|
||||
|
||||
const adapter = createLinkConnectorAdapter()
|
||||
const renderLinks = adapter?.renderLinks
|
||||
if (!adapter || !renderLinks || renderLinks.length === 0) return
|
||||
const renderLinks = createLinkConnectorAdapter()?.renderLinks
|
||||
if (!renderLinks || renderLinks.length === 0) return
|
||||
|
||||
const to: ReadOnlyPoint = candidate?.compatible
|
||||
? [candidate.layout.position.x, candidate.layout.position.y]
|
||||
|
||||
@@ -183,35 +183,12 @@ export function useSlotLinkInteraction({
|
||||
return 'canConnectToReroute' in link
|
||||
}
|
||||
|
||||
type InputConnectableLink = RenderLink & {
|
||||
toType: 'input'
|
||||
canConnectToInput: (node: LGraphNode, input: INodeInputSlot) => boolean
|
||||
}
|
||||
|
||||
type OutputConnectableLink = RenderLink & {
|
||||
toType: 'output'
|
||||
canConnectToOutput: (node: LGraphNode, output: INodeOutputSlot) => boolean
|
||||
}
|
||||
|
||||
function isInputConnectableLink(
|
||||
link: RenderLink
|
||||
): link is InputConnectableLink {
|
||||
return (
|
||||
link.toType === 'input' &&
|
||||
typeof (link as { canConnectToInput?: unknown }).canConnectToInput ===
|
||||
'function'
|
||||
)
|
||||
}
|
||||
|
||||
function isOutputConnectableLink(
|
||||
link: RenderLink
|
||||
): link is OutputConnectableLink {
|
||||
return (
|
||||
link.toType === 'output' &&
|
||||
typeof (link as { canConnectToOutput?: unknown }).canConnectToOutput ===
|
||||
'function'
|
||||
)
|
||||
}
|
||||
type ToInputLink = RenderLink & { toType: 'input' }
|
||||
type ToOutputLink = RenderLink & { toType: 'output' }
|
||||
const isToInputLink = (link: RenderLink): link is ToInputLink =>
|
||||
link.toType === 'input'
|
||||
const isToOutputLink = (link: RenderLink): link is ToOutputLink =>
|
||||
link.toType === 'output'
|
||||
|
||||
function connectLinksToInput(
|
||||
links: ReadonlyArray<RenderLink>,
|
||||
@@ -219,7 +196,7 @@ export function useSlotLinkInteraction({
|
||||
inputSlot: INodeInputSlot
|
||||
): boolean {
|
||||
const validCandidates = links
|
||||
.filter(isInputConnectableLink)
|
||||
.filter(isToInputLink)
|
||||
.filter((link) => link.canConnectToInput(node, inputSlot))
|
||||
|
||||
for (const link of validCandidates) {
|
||||
@@ -235,7 +212,7 @@ export function useSlotLinkInteraction({
|
||||
outputSlot: INodeOutputSlot
|
||||
): boolean {
|
||||
const validCandidates = links
|
||||
.filter(isOutputConnectableLink)
|
||||
.filter(isToOutputLink)
|
||||
.filter((link) => link.canConnectToOutput(node, outputSlot))
|
||||
|
||||
for (const link of validCandidates) {
|
||||
@@ -412,7 +389,7 @@ export function useSlotLinkInteraction({
|
||||
if (results.length && maybeReroutes !== null) {
|
||||
const originalReroutes = maybeReroutes.slice(0, -1).reverse()
|
||||
for (const link of adapter.renderLinks) {
|
||||
if (!isInputConnectableLink(link)) continue
|
||||
if (!isToInputLink(link)) continue
|
||||
for (const result of results) {
|
||||
link.connectToRerouteInput(
|
||||
reroute,
|
||||
@@ -429,7 +406,7 @@ export function useSlotLinkInteraction({
|
||||
if (sourceOutput) {
|
||||
const { node, output } = sourceOutput
|
||||
for (const link of adapter.renderLinks) {
|
||||
if (!isOutputConnectableLink(link)) continue
|
||||
if (!isToOutputLink(link)) continue
|
||||
if (hasCanConnectToReroute(link) && !link.canConnectToReroute(reroute))
|
||||
continue
|
||||
link.connectToRerouteOutput(
|
||||
|
||||
Reference in New Issue
Block a user