LCOV - code coverage report
Current view: top level - src/core/selection - selectionState.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 100.0 % 6 6
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { z } from 'zod'
       2              : 
       3              : import type { GroupId } from '@comfyorg/graph-model/groupId'
       4              : import type { NodeId } from '@comfyorg/graph-model/nodeId'
       5              : import type { RerouteId } from '@comfyorg/graph-model/rerouteId'
       6              : 
       7         2356 : const selectableKindSchema = z.enum(['node', 'group', 'reroute', 'io'])
       8              : export type SelectableKind = z.infer<typeof selectableKindSchema>
       9              : 
      10              : /** `kind:id` identity of one selectable canvas item within a graph scope. */
      11              : export type SelectableKey = `${SelectableKind}:${string}` & {
      12              :   readonly __brand: 'SelectableKey'
      13              : }
      14              : 
      15       237403 : export function toSelectableKey(
      16              :   ...[kind, id]:
      17              :     | [kind: 'node' | 'io', id: NodeId]
      18              :     | [kind: 'group', id: GroupId]
      19              :     | [kind: 'reroute', id: RerouteId]
      20              : ): SelectableKey {
      21       237403 :   return `${kind}:${id}` as SelectableKey
      22              : }
      23              : 
      24        16081 : export function parseSelectableKey(key: SelectableKey): {
      25              :   kind: SelectableKind
      26              :   id: string
      27              : } {
      28        16081 :   const [kind, id] = key.split(/:(.*)/s, 2)
      29        16081 :   return { kind: selectableKindSchema.parse(kind), id }
      30              : }
      31              : 
      32              : export type SelectionCommand =
      33              :   | {
      34              :       readonly type: 'selection.replace'
      35              :       readonly keys: readonly SelectableKey[]
      36              :     }
      37              :   | { readonly type: 'selection.add'; readonly key: SelectableKey }
      38              :   | {
      39              :       readonly type: 'selection.remove'
      40              :       readonly key: SelectableKey
      41              :     }
      42              :   | { readonly type: 'selection.clear' }
        

Generated by: LCOV version 2.0-1