LCOV - code coverage report
Current view: top level - packages/object-info-parser/src/classifiers - nodeSource.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 89.5 % 38 34
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1         2356 : export const BLUEPRINT_CATEGORY = 'Subgraph Blueprints'
       2              : 
       3         2356 : export enum NodeSourceType {
       4         2356 :   Core = 'core',
       5         2356 :   CustomNodes = 'custom_nodes',
       6         2356 :   Blueprint = 'blueprint',
       7         2356 :   Essentials = 'essentials',
       8         2356 :   Unknown = 'unknown'
       9              : }
      10         2356 : export const CORE_NODE_MODULES = ['nodes', 'comfy_extras', 'comfy_api_nodes']
      11              : 
      12              : export type NodeSource = {
      13              :   type: NodeSourceType
      14              :   className: string
      15              :   displayText: string
      16              :   badgeText: string
      17              : }
      18              : 
      19         2356 : const UNKNOWN_NODE_SOURCE: NodeSource = {
      20              :   type: NodeSourceType.Unknown,
      21              :   className: 'comfy-unknown',
      22              :   displayText: 'Unknown',
      23              :   badgeText: '?'
      24              : }
      25              : 
      26       506448 : function shortenNodeName(name: string) {
      27       506448 :   return name
      28              :     .replace(/^(ComfyUI-|ComfyUI_|Comfy-|Comfy_)/, '')
      29              :     .replace(/(-ComfyUI|_ComfyUI|-Comfy|_Comfy)$/, '')
      30              : }
      31              : 
      32      5154435 : export function getNodeSource(
      33              :   python_module?: string,
      34              :   essentials_category?: string
      35              : ): NodeSource {
      36      5154435 :   if (!python_module) {
      37            0 :     return UNKNOWN_NODE_SOURCE
      38              :   }
      39      5154435 :   const modules = python_module.split('.')
      40      5154435 :   if (essentials_category) {
      41              :     const moduleName = modules[1] ?? modules[0]
      42       302914 :     const displayName = shortenNodeName(moduleName.split('@')[0])
      43       302914 :     return {
      44              :       type: NodeSourceType.Essentials,
      45              :       className: 'comfy-essentials',
      46              :       displayText: displayName,
      47              :       badgeText: displayName
      48              :     }
      49      4851521 :   } else if (CORE_NODE_MODULES.includes(modules[0])) {
      50      4385080 :     return {
      51              :       type: NodeSourceType.Core,
      52              :       className: 'comfy-core',
      53              :       displayText: 'Comfy Core',
      54              :       badgeText: '🦊'
      55              :     }
      56       466441 :   } else if (modules[0] === 'blueprint') {
      57       262883 :     return {
      58              :       type: NodeSourceType.Blueprint,
      59              :       className: 'blueprint',
      60              :       displayText: 'Blueprint',
      61              :       badgeText: 'bp'
      62              :     }
      63       203558 :   } else if (modules[0] === 'custom_nodes') {
      64       203534 :     const moduleName = modules[1]
      65       203534 :     if (!moduleName) {
      66            0 :       return UNKNOWN_NODE_SOURCE
      67              :     }
      68       203534 :     const customNodeName = moduleName.split('@')[0]
      69       203534 :     const displayName = shortenNodeName(customNodeName)
      70       203534 :     return {
      71              :       type: NodeSourceType.CustomNodes,
      72              :       className: 'comfy-custom-nodes',
      73              :       displayText: displayName,
      74              :       badgeText: displayName
      75              :     }
      76              :   } else {
      77           24 :     return UNKNOWN_NODE_SOURCE
      78              :   }
      79              : }
      80              : 
      81              : interface NodeDefLike {
      82              :   nodeSource: NodeSource
      83              : }
      84              : 
      85            0 : export function isEssentialNode(node: NodeDefLike): boolean {
      86            0 :   return node.nodeSource.type === NodeSourceType.Essentials
      87              : }
      88              : 
      89      3312490 : export function isCustomNode(node: NodeDefLike): boolean {
      90      3312490 :   return node.nodeSource.type === NodeSourceType.CustomNodes
      91              : }
      92              : 
      93         2356 : export enum NodeBadgeMode {
      94         2356 :   None = 'None',
      95         2356 :   ShowAll = 'Show all',
      96         2356 :   HideBuiltIn = 'Hide built-in'
      97              : }
        

Generated by: LCOV version 2.0-1