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

            Line data    Source code
       1              : import { defineStore } from 'pinia'
       2              : 
       3              : import type {
       4              :   GraphScope,
       5              :   OwningGraphId,
       6              :   RootGraphId
       7              : } from '@comfyorg/graph-model/graphScopeId'
       8              : import type { NodeId } from '@comfyorg/graph-model/nodeId'
       9              : 
      10         2356 : export const useExecutionOrderStore = defineStore('executionOrder', () => {
      11         2355 :   const orders = new Map<RootGraphId, Map<OwningGraphId, Map<NodeId, number>>>()
      12              : 
      13        29276 :   function graphOrders(scope: GraphScope): Map<NodeId, number> {
      14        29276 :     let root = orders.get(scope.rootGraphId)
      15        29276 :     if (!root) {
      16         4213 :       root = new Map()
      17         4213 :       orders.set(scope.rootGraphId, root)
      18              :     }
      19        29276 :     let graph = root.get(scope.owningGraphId)
      20        29276 :     if (!graph) {
      21         4770 :       graph = new Map()
      22         4770 :       root.set(scope.owningGraphId, graph)
      23              :     }
      24        29276 :     return graph
      25              :   }
      26              : 
      27       110067 :   function get(scope: GraphScope, nodeId: NodeId): number | undefined {
      28       110067 :     return orders.get(scope.rootGraphId)?.get(scope.owningGraphId)?.get(nodeId)
      29              :   }
      30              : 
      31        23442 :   function set(scope: GraphScope, nodeId: NodeId, order: number): void {
      32        23442 :     graphOrders(scope).set(nodeId, order)
      33              :   }
      34              : 
      35         5834 :   function replace(scope: GraphScope, nodeIds: readonly NodeId[]): void {
      36         5834 :     const graph = graphOrders(scope)
      37         5834 :     graph.clear()
      38         5834 :     nodeIds.forEach((nodeId, order) => graph.set(nodeId, order))
      39              :   }
      40              : 
      41          212 :   function remove(scope: GraphScope, nodeId: NodeId): void {
      42          212 :     orders.get(scope.rootGraphId)?.get(scope.owningGraphId)?.delete(nodeId)
      43              :   }
      44              : 
      45         3142 :   function clearGraph(scope: GraphScope): void {
      46         3142 :     orders.get(scope.rootGraphId)?.delete(scope.owningGraphId)
      47              :   }
      48              : 
      49         7828 :   function clearRoot(rootGraphId: RootGraphId): void {
      50         7828 :     orders.delete(rootGraphId)
      51              :   }
      52              : 
      53         2355 :   return { clearGraph, clearRoot, get, remove, replace, set }
      54              : })
        

Generated by: LCOV version 2.0-1