LCOV - code coverage report
Current view: top level - src/composables - widgetHistoryScope.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 80.0 % 10 8
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import type { LGraph } from '@/lib/litegraph/src/litegraph'
       2              : import { app } from '@/scripts/app'
       3              : import type { WidgetHistoryScope } from '@/stores/widgetHistoryStore'
       4              : import type { NodeId } from '@comfyorg/graph-model/nodeId'
       5              : import { parseNodeLocatorId } from '@comfyorg/graph-model/nodeIdentification'
       6              : import type { SimplifiedWidget } from '@/types/simplifiedWidget'
       7              : import { widgetId } from '@comfyorg/graph-model/widgetId'
       8              : 
       9              : export type LocatedWidget = Pick<SimplifiedWidget, 'name' | 'nodeLocatorId'>
      10              : 
      11          567 : export function locateWidgetNode(
      12              :   widget: LocatedWidget,
      13              :   fallbackNodeId?: NodeId
      14              : ): { graph: LGraph; nodeId: NodeId } | null {
      15          567 :   const located = widget.nodeLocatorId
      16              :     ? parseNodeLocatorId(widget.nodeLocatorId)
      17              :     : null
      18          567 :   if (!located) {
      19            0 :     const graph = app.canvas.graph
      20            0 :     return graph && fallbackNodeId !== undefined
      21              :       ? { graph, nodeId: fallbackNodeId }
      22              :       : null
      23              :   }
      24          567 :   const graph = located.subgraphUuid
      25              :     ? app.rootGraph.subgraphs.get(located.subgraphUuid)
      26              :     : app.rootGraph
      27          567 :   return graph ? { graph, nodeId: located.localNodeId } : null
      28              : }
      29              : 
      30          487 : export function widgetHistoryScope(
      31              :   widget: LocatedWidget,
      32              :   fallbackNodeId?: NodeId
      33              : ): WidgetHistoryScope | null {
      34          487 :   const location = locateWidgetNode(widget, fallbackNodeId)
      35          487 :   return location
      36              :     ? {
      37              :         rootGraphId: app.rootGraph.id,
      38              :         widgetId: widgetId(location.graph.id, location.nodeId, widget.name)
      39              :       }
      40              :     : null
      41              : }
        

Generated by: LCOV version 2.0-1