LCOV - code coverage report
Current view: top level - packages/layer-editor/src/kinds - group.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 27.3 % 22 6
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { defaultMode } from '#/mode'
       2              : import type { NodeKind } from '#/nodeKind'
       3              : import { getNodeKind } from '#/nodeKind'
       4              : import type { GroupData, Transform } from '#/node'
       5              : import type { CompactRect as Rect } from '@comfyorg/shared-frontend-utils/geometry'
       6              : import { generateId } from '#/id'
       7              : 
       8            0 : function fullTransform(): Transform {
       9            0 :   return { x: 0, y: 0, w: 0, h: 0, rotation: 0 }
      10              : }
      11              : 
      12            2 : export const groupKind: NodeKind<GroupData> = {
      13              :   kind: 'group',
      14              : 
      15              :   create(init: Partial<GroupData> = {}): GroupData {
      16            0 :     return {
      17              :       kind: 'group',
      18              :       id: init.id ?? generateId('group'),
      19              :       name: init.name ?? 'Group',
      20              :       visible: init.visible ?? true,
      21              :       opacity: init.opacity ?? 1,
      22              :       mode: init.mode ?? defaultMode('normal'),
      23              :       transform: init.transform ?? fullTransform(),
      24              :       locks: init.locks ?? {
      25              :         content: false,
      26              :         position: false,
      27              :         visibility: false
      28              :       },
      29              :       children: init.children ?? [],
      30              :       passThrough: init.passThrough ?? false,
      31              :       mask: init.mask
      32              :     }
      33              :   },
      34              : 
      35              :   contentIds(node: GroupData): string[] {
      36           13 :     const ids: string[] = []
      37           13 :     if (node.mask) ids.push(node.mask.contentId)
      38           13 :     for (const c of node.children)
      39           29 :       ids.push(...getNodeKind(c.kind).contentIds(c))
      40           13 :     return ids.filter(Boolean)
      41              :   },
      42              : 
      43              :   renderNode(): null {
      44            0 :     return null
      45              :   },
      46              : 
      47              :   bbox(node: GroupData): Rect {
      48            0 :     if (node.children.length === 0) return { x: 0, y: 0, w: 0, h: 0 }
      49            0 :     let minX = Infinity
      50            0 :     let minY = Infinity
      51            0 :     let maxX = -Infinity
      52            0 :     let maxY = -Infinity
      53            0 :     for (const c of node.children) {
      54            0 :       const b = getNodeKind(c.kind).bbox(c)
      55            0 :       minX = Math.min(minX, b.x)
      56            0 :       minY = Math.min(minY, b.y)
      57            0 :       maxX = Math.max(maxX, b.x + b.w)
      58            0 :       maxY = Math.max(maxY, b.y + b.h)
      59              :     }
      60            0 :     return { x: minX, y: minY, w: maxX - minX, h: maxY - minY }
      61              :   }
      62              : }
        

Generated by: LCOV version 2.0-1