LCOV - code coverage report
Current view: top level - src/renderer/core/canvas/litegraph - arrangeForLegacyRender.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 94.1 % 17 16
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import type { LGraph, LGraphNode } from '@comfyorg/graph-model/entityRegistry'
       2              : import log from 'loglevel'
       3              : 
       4              : import { layoutStore } from '@/renderer/core/layout/store/layoutStore'
       5              : import { compareNodeIds } from '@comfyorg/graph-model/nodeId'
       6              : 
       7         2356 : const logger = log.getLogger('arrangeForLegacyRender')
       8              : 
       9              : interface RenderOrderCacheEntry {
      10              :   graphVersion: number
      11              :   layoutVersion: number
      12              :   nodes: LGraphNode[]
      13              : }
      14              : 
      15         2356 : const renderOrderCache = new WeakMap<LGraph, RenderOrderCacheEntry>()
      16              : 
      17       136908 : export function nodesInRenderOrder(graph: LGraph): LGraphNode[] {
      18       136908 :   const layoutVersion = layoutStore.layoutVersion
      19       136908 :   const cached = renderOrderCache.get(graph)
      20       136908 :   if (
      21              :     cached &&
      22              :     cached.graphVersion === graph._version &&
      23              :     cached.layoutVersion === layoutVersion
      24              :   )
      25       124959 :     return cached.nodes
      26              : 
      27        11949 :   const rootGraphId = graph.rootGraph.id
      28        11949 :   const nodes = graph._nodes
      29              :     .map((node) => ({
      30              :       node,
      31              :       zIndex: layoutStore.getNodeLayout(rootGraphId, node.id)?.zIndex ?? 0
      32              :     }))
      33              :     .sort((a, b) => a.zIndex - b.zIndex || compareNodeIds(a.node.id, b.node.id))
      34              :     .map(({ node }) => node)
      35        11949 :   renderOrderCache.set(graph, {
      36              :     graphVersion: graph._version,
      37              :     layoutVersion,
      38              :     nodes
      39              :   })
      40        11949 :   return nodes
      41              : }
      42              : 
      43              : /**
      44              :  * `drawConnections` normally arranges slots, but Vue-mode `drawNode` clears
      45              :  * `_widgetSlotsDirty`, so that pass is skipped after switching to legacy mode.
      46              :  * Vue DOM measurements also differ slightly from legacy slot positions.
      47              :  *
      48              :  * Delete when `getSlotPosition` is consistent across both renderers.
      49              :  */
      50           29 : export function arrangeForLegacyRender(graph: LGraph): void {
      51           29 :   for (const node of graph._nodes) {
      52          158 :     if (node.flags.collapsed) continue
      53          158 :     try {
      54          158 :       node.arrange()
      55              :     } catch (error) {
      56            0 :       logger.warn('Skipping node that could not be arranged:', node.id, error)
      57              :     }
      58              :   }
      59              : }
        

Generated by: LCOV version 2.0-1