LCOV - code coverage report
Current view: top level - src/renderer/extensions/vueNodes/utils - linkedCoreMediaUtils.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 100.0 % 25 25
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
       2              : import type { NodeExecutionOutput } from '@comfyorg/api-client/executionTypes'
       3              : import { isInputPreviewOutput } from '@/utils/nodeOutputUtil'
       4              : 
       5         2355 : const LINKED_CORE_MEDIA_LOADERS = {
       6              :   LoadAudio: { selectorName: 'audio', showsInputPreview: false },
       7              :   LoadImage: { selectorName: 'image', showsInputPreview: true },
       8              :   LoadImageMask: { selectorName: 'image', showsInputPreview: true },
       9              :   LoadImageOutput: { selectorName: 'image', showsInputPreview: true },
      10              :   LoadVideo: { selectorName: 'file', showsInputPreview: true }
      11              : } as const
      12              : 
      13              : type LinkedCoreMediaLoaderClass = keyof typeof LINKED_CORE_MEDIA_LOADERS
      14              : 
      15        13114 : function isLinkedCoreMediaLoaderClass(
      16              :   value: string
      17              : ): value is LinkedCoreMediaLoaderClass {
      18        13114 :   return Object.hasOwn(LINKED_CORE_MEDIA_LOADERS, value)
      19              : }
      20              : 
      21        13758 : function getCoreMediaLoaderClass(
      22              :   node: LGraphNode
      23              : ): LinkedCoreMediaLoaderClass | undefined {
      24        13758 :   const nodeData = node.constructor.nodeData
      25        13758 :   const nodeClass = node.constructor.comfyClass
      26        13758 :   if (
      27              :     !nodeData ||
      28              :     !('isCoreNode' in nodeData) ||
      29              :     nodeData.isCoreNode !== true ||
      30              :     nodeClass === undefined ||
      31              :     !isLinkedCoreMediaLoaderClass(nodeClass)
      32              :   )
      33        12921 :     return undefined
      34              : 
      35          837 :   return nodeClass
      36              : }
      37              : 
      38          837 : function isMediaLoaderSelectorLinked(
      39              :   node: LGraphNode,
      40              :   nodeClass: LinkedCoreMediaLoaderClass
      41              : ): boolean {
      42          837 :   const { selectorName } = LINKED_CORE_MEDIA_LOADERS[nodeClass]
      43          837 :   const selectorSlotIndex = node.inputs.findIndex(
      44              :     (input) =>
      45              :       input.widget?.name === selectorName || input.name === selectorName
      46              :   )
      47          837 :   return selectorSlotIndex >= 0 && node.isInputConnected(selectorSlotIndex)
      48              : }
      49              : 
      50        13758 : function getLinkedCoreMediaLoaderClass(
      51              :   node: LGraphNode
      52              : ): LinkedCoreMediaLoaderClass | undefined {
      53        13758 :   const nodeClass = getCoreMediaLoaderClass(node)
      54        13758 :   if (!nodeClass || !isMediaLoaderSelectorLinked(node, nodeClass))
      55        13676 :     return undefined
      56              : 
      57           82 :   return nodeClass
      58              : }
      59              : 
      60         5487 : export function shouldHideLinkedCoreMediaInputActions(
      61              :   node: LGraphNode
      62              : ): boolean {
      63         5487 :   const nodeClass = getLinkedCoreMediaLoaderClass(node)
      64         5487 :   return (
      65              :     nodeClass !== undefined &&
      66              :     LINKED_CORE_MEDIA_LOADERS[nodeClass].showsInputPreview
      67              :   )
      68              : }
      69              : 
      70         2895 : export function shouldHideLinkedCoreMediaInputPreview(
      71              :   node: LGraphNode,
      72              :   output: Pick<NodeExecutionOutput, 'images'> | undefined
      73              : ): boolean {
      74         2895 :   return (
      75              :     shouldHideLinkedCoreMediaInputActions(node) && isInputPreviewOutput(output)
      76              :   )
      77              : }
      78              : 
      79         8271 : export function shouldHideLinkedCoreLoadAudioPlayer(node: LGraphNode): boolean {
      80         8271 :   return getLinkedCoreMediaLoaderClass(node) === 'LoadAudio'
      81              : }
        

Generated by: LCOV version 2.0-1