mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-22 07:44:11 +00:00
Those who type
This commit is contained in:
@@ -11,6 +11,7 @@ import type {
|
||||
} from '@/lib/litegraph/src/interfaces'
|
||||
import type { SubgraphInput } from '@/lib/litegraph/src/subgraph/SubgraphInput'
|
||||
import type { SubgraphOutput } from '@/lib/litegraph/src/subgraph/SubgraphOutput'
|
||||
import type { NodeLike } from '@/lib/litegraph/src/types/NodeLike'
|
||||
import { LinkDirection } from '@/lib/litegraph/src/types/globalEnums'
|
||||
|
||||
import type { RenderLink } from './RenderLink'
|
||||
@@ -99,6 +100,14 @@ export abstract class MovingLinkBase implements RenderLink {
|
||||
this.inputPos = inputNode.getInputPos(inputIndex)
|
||||
}
|
||||
|
||||
abstract canConnectToInput(
|
||||
inputNode: NodeLike,
|
||||
input: INodeInputSlot
|
||||
): boolean
|
||||
abstract canConnectToOutput(
|
||||
outputNode: NodeLike,
|
||||
output: INodeOutputSlot
|
||||
): boolean
|
||||
abstract connectToInput(
|
||||
node: LGraphNode,
|
||||
input: INodeInputSlot,
|
||||
|
||||
@@ -11,6 +11,7 @@ import type {
|
||||
import type { SubgraphIONodeBase } from '@/lib/litegraph/src/subgraph/SubgraphIONodeBase'
|
||||
import type { SubgraphInput } from '@/lib/litegraph/src/subgraph/SubgraphInput'
|
||||
import type { SubgraphOutput } from '@/lib/litegraph/src/subgraph/SubgraphOutput'
|
||||
import type { NodeLike } from '@/lib/litegraph/src/types/NodeLike'
|
||||
import type { LinkDirection } from '@/lib/litegraph/src/types/globalEnums'
|
||||
|
||||
export interface RenderLink {
|
||||
@@ -38,6 +39,17 @@ export interface RenderLink {
|
||||
/** The reroute that the link is being connected from. */
|
||||
readonly fromReroute?: Reroute
|
||||
|
||||
/**
|
||||
* Capability checks used for hit-testing and validation during drag.
|
||||
* Implementations should return `false` when a connection is not possible
|
||||
* rather than throwing.
|
||||
*/
|
||||
canConnectToInput(node: NodeLike, input: INodeInputSlot): boolean
|
||||
canConnectToOutput(node: NodeLike, output: INodeOutputSlot): boolean
|
||||
/** Optional: only some links support validating subgraph IO or reroutes. */
|
||||
canConnectToSubgraphInput?(input: SubgraphInput): boolean
|
||||
canConnectToReroute?(reroute: Reroute): boolean
|
||||
|
||||
connectToInput(
|
||||
node: LGraphNode,
|
||||
input: INodeInputSlot,
|
||||
|
||||
@@ -115,8 +115,8 @@ export class LinkConnectorAdapter {
|
||||
const node = this.network.getNodeById(nodeId)
|
||||
const output = node?.outputs?.[outputIndex]
|
||||
if (!node || !output) return false
|
||||
return (this.linkConnector.renderLinks as any[]).some(
|
||||
(link) => link?.canConnectToOutput?.(node, output) === true
|
||||
return this.linkConnector.renderLinks.some((link) =>
|
||||
link.canConnectToOutput(node, output)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user