LCOV - code coverage report
Current view: top level - src/renderer/extensions/firstRunTour/tour - canvasCoachTarget.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 0.0 % 20 0
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { useElementBounding, useEventListener } from '@vueuse/core'
       2              : import { effectScope, watch } from 'vue'
       3              : 
       4              : import { LiteGraph } from '@/lib/litegraph/src/litegraph'
       5              : import type { RectTarget } from '@/platform/onboarding/coachmarkRegistry'
       6              : import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
       7              : import { layoutStore } from '@/renderer/core/layout/store/layoutStore'
       8              : import { useTransformState } from '@/renderer/core/layout/transform/useTransformState'
       9              : import type { NodeId } from '@comfyorg/graph-model/nodeId'
      10              : 
      11              : /** A canvas node as a coachmark target, derived from its layout and the camera. */
      12            0 : export function canvasNodeTarget(nodeId: NodeId): RectTarget {
      13            0 :   const { camera } = useTransformState()
      14            0 :   const canvasStore = useCanvasStore()
      15            0 :   const resolvedGraph = canvasStore.currentGraph
      16            0 :   const scope = effectScope(true)
      17            0 :   const layout = resolvedGraph
      18              :     ? scope.run(() =>
      19              :         layoutStore.getNodeLayoutRef(resolvedGraph.rootGraph.id, nodeId)
      20              :       )
      21              :     : null
      22            0 :   const canvasBounds = scope.run(() =>
      23              :     useElementBounding(() => canvasStore.canvas?.canvas)
      24              :   )!
      25              : 
      26            0 :   return {
      27              :     getRect: () => {
      28              :       // Node ids are graph-local, so id 6 in another graph is a different node.
      29            0 :       if (canvasStore.currentGraph !== resolvedGraph) return null
      30              :       // A collapsed node renders no widget for a step to point at.
      31            0 :       if (canvasStore.currentGraph?.getNodeById(nodeId)?.collapsed) return null
      32              : 
      33            0 :       const bounds = layout?.value?.bounds
      34            0 :       if (!bounds) return null
      35              : 
      36              :       // Bounds are the body box; the node renders a title height above it.
      37            0 :       const title = LiteGraph.NODE_TITLE_HEIGHT || 0
      38            0 :       const { x, y, z } = camera
      39            0 :       return new DOMRect(
      40              :         (bounds.x + x) * z + canvasBounds.left.value,
      41              :         (bounds.y - title + y) * z + canvasBounds.top.value,
      42              :         bounds.width * z,
      43              :         (bounds.height + title) * z
      44              :       )
      45              :     },
      46              :     onMove: (notify) => {
      47            0 :       const stopWatch = watch(
      48              :         () => [camera.x, camera.y, camera.z, layout?.value],
      49              :         notify,
      50              :         { flush: 'post' }
      51              :       )
      52            0 :       const stopResize = useEventListener(window, 'resize', notify)
      53            0 :       return () => {
      54            0 :         stopWatch()
      55            0 :         stopResize()
      56              :       }
      57              :     },
      58              :     dispose: () => scope.stop()
      59              :   }
      60              : }
        

Generated by: LCOV version 2.0-1