Line data Source code
1 : import type { LGraph } from '@/lib/litegraph/src/litegraph'
2 : import type { MissingMediaCandidate } from '@/platform/workflowErrors/missingMedia/types'
3 : import { getNodeByExecutionId } from '@/utils/graphTraversalUtil'
4 :
5 0 : export function refreshDownloadedTemplateInputBindings(
6 : rootGraph: LGraph,
7 : candidates: readonly MissingMediaCandidate[],
8 : completedInputNames: ReadonlySet<string>
9 : ): void {
10 0 : const refreshedWidgets = new Set<string>()
11 :
12 0 : for (const candidate of candidates) {
13 0 : if (!completedInputNames.has(candidate.name)) continue
14 :
15 0 : const widgetId = `${String(candidate.nodeId)}\0${candidate.widgetName}`
16 0 : if (refreshedWidgets.has(widgetId)) continue
17 :
18 0 : const node = getNodeByExecutionId(rootGraph, String(candidate.nodeId))
19 0 : const widget = node?.widgets?.find(
20 : ({ name }) => name === candidate.widgetName
21 : )
22 0 : if (!node || widget?.value !== candidate.name || !widget.callback) continue
23 :
24 0 : refreshedWidgets.add(widgetId)
25 0 : widget.callback(widget.value, undefined, node)
26 : }
27 : }
|