Line data Source code
1 : import { computed, toValue } from 'vue'
2 : import type { MaybeRefOrGetter } from 'vue'
3 :
4 : import { app } from '@/scripts/app'
5 : import type { NodeId } from '@comfyorg/graph-model/nodeId'
6 : import type { NodeLocatorId } from '@comfyorg/graph-model/nodeIdentification'
7 : import { getNodeByLocatorId } from '@/utils/graphTraversalUtil'
8 :
9 20 : export function useWidgetHostNode(
10 : nodeLocatorId: MaybeRefOrGetter<NodeLocatorId | undefined>,
11 : nodeId: MaybeRefOrGetter<NodeId>
12 : ) {
13 20 : return computed(() => {
14 20 : const locatorId = toValue(nodeLocatorId)
15 : const owner = locatorId && getNodeByLocatorId(app.rootGraph, locatorId)
16 20 : return owner || app.canvas.graph?.getNodeById(toValue(nodeId))
17 : })
18 : }
|