LCOV - code coverage report
Current view: top level - packages/layer-editor/src/editor - overlayList.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 25.0 % 16 4
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import type { Point2D as Vec2 } from '@comfyorg/shared-frontend-utils/geometry'
       2              : import type { CanvasItem, Overlay } from '#/tool'
       3              : 
       4            2 : export class OverlayList implements Overlay {
       5              :   items: CanvasItem[] = []
       6              :   private paused = 0
       7              : 
       8            2 :   constructor(private readonly onRedraw: () => void = () => {}) {}
       9              : 
      10              :   clear(): void {
      11           22 :     this.items = []
      12              :   }
      13              : 
      14              :   add(item: CanvasItem): void {
      15          154 :     this.items.push(item)
      16              :   }
      17              : 
      18              :   pause(): void {
      19            0 :     this.paused += 1
      20              :   }
      21              : 
      22              :   resume(): void {
      23            0 :     if (this.paused > 0) this.paused -= 1
      24            0 :     if (this.paused === 0) this.onRedraw()
      25              :   }
      26              : 
      27              :   hitHandle(pt: Vec2, screenTolerance: number): string | null {
      28            0 :     let best: string | null = null
      29            0 :     let bestD = screenTolerance
      30            0 :     for (const item of this.items) {
      31            0 :       if (item.type !== 'handle' || !item.id) continue
      32            0 :       const d = Math.hypot(pt.x - item.pos.x, pt.y - item.pos.y)
      33            0 :       if (d <= bestD) {
      34            0 :         bestD = d
      35            0 :         best = item.id
      36              :       }
      37              :     }
      38            0 :     return best
      39              :   }
      40              : }
        

Generated by: LCOV version 2.0-1