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

            Line data    Source code
       1              : import { computed, onMounted, watch } from 'vue'
       2              : 
       3              : import { useNodePricing } from '@/composables/node/useNodePricing'
       4              : import { useSettingStore } from '@/platform/settings/settingStore'
       5              : import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
       6              : import { app } from '@/scripts/app'
       7              : import { useExtensionStore } from '@/platform/extensions/stores/extensionStore'
       8              : import { installNodeBadges } from '@/systems/badgeSystem'
       9              : 
      10              : /**
      11              :  * Bootstraps badge derivation: installs it as the legacy canvas's row
      12              :  * source and keeps the legacy canvas redrawing when badge sources change.
      13              :  */
      14         2355 : export const useNodeBadge = () => {
      15         2355 :   const settingStore = useSettingStore()
      16         2355 :   const extensionStore = useExtensionStore()
      17         2355 :   const canvasStore = useCanvasStore()
      18              : 
      19         2355 :   const showApiPricingBadge = computed(() =>
      20              :     settingStore.get('Comfy.NodeBadge.ShowApiPricing')
      21              :   )
      22              : 
      23         2355 :   watch(
      24              :     [
      25              :       () => settingStore.get('Comfy.NodeBadge.NodeSourceBadgeMode'),
      26              :       () => settingStore.get('Comfy.NodeBadge.NodeIdBadgeMode'),
      27              :       () => settingStore.get('Comfy.NodeBadge.NodeLifeCycleBadgeMode'),
      28              :       showApiPricingBadge
      29              :     ],
      30              :     () => {
      31         2376 :       canvasStore.canvas?.setDirty(true, true)
      32              :     }
      33              :   )
      34              : 
      35         2355 :   onMounted(() => {
      36         2355 :     if (extensionStore.isExtensionInstalled('Comfy.NodeBadge')) return
      37              : 
      38         2355 :     const nodePricing = useNodePricing()
      39              : 
      40         2355 :     watch(
      41              :       () => nodePricing.pricingRevision.value,
      42              :       () => {
      43           32 :         if (!showApiPricingBadge.value) return
      44           32 :         canvasStore.canvas?.setDirty(true, true)
      45              :       }
      46              :     )
      47              : 
      48         2355 :     extensionStore.registerExtension({
      49              :       name: 'Comfy.NodeBadge',
      50              :       init() {
      51         2355 :         installNodeBadges()
      52         2355 :         app.canvas.canvas.addEventListener<'litegraph:set-graph'>(
      53              :           'litegraph:set-graph',
      54              :           () => {
      55          216 :             canvasStore.canvas?.setDirty(true, true)
      56              :           }
      57              :         )
      58              :       }
      59              :     })
      60              :   })
      61              : }
        

Generated by: LCOV version 2.0-1