LCOV - code coverage report
Current view: top level - src/renderer/extensions/maskEditor/stores - maskEditorDataStore.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 95.0 % 20 19
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { defineStore } from 'pinia'
       2              : import { computed, ref, shallowRef } from 'vue'
       3              : import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
       4              : import type { NodeId } from '@comfyorg/graph-model/nodeId'
       5              : import type {
       6              :   CanvasBlobLayer,
       7              :   ImageOutput
       8              : } from '@comfyorg/mask-editor/imageOutput'
       9              : 
      10              : export interface ImageRef {
      11              :   filename: string
      12              :   subfolder?: string
      13              :   type?: string
      14              : }
      15              : 
      16              : export interface LoadedImageLayer {
      17              :   image: HTMLImageElement
      18              :   url: string
      19              : }
      20              : 
      21              : interface EditorInputData {
      22              :   baseLayer: LoadedImageLayer
      23              :   maskLayer: LoadedImageLayer
      24              :   paintLayer?: LoadedImageLayer
      25              :   sourceRef: ImageRef
      26              :   nodeId: NodeId
      27              : }
      28              : 
      29              : export interface EditorOutputLayer extends CanvasBlobLayer {
      30              :   ref: ImageRef
      31              : }
      32              : 
      33              : export type EditorOutputData = {
      34              :   [K in keyof ImageOutput]: ImageOutput[K] & { ref: ImageRef }
      35              : }
      36              : 
      37           30 : export const useMaskEditorDataStore = defineStore('maskEditorData', () => {
      38           30 :   const inputData = ref<EditorInputData | null>(null)
      39           30 :   const outputData = ref<EditorOutputData | null>(null)
      40           30 :   const sourceNode = shallowRef<LGraphNode | null>(null)
      41              : 
      42           30 :   const isLoading = ref(false)
      43           30 :   const loadError = ref<string | null>(null)
      44              : 
      45           30 :   const hasValidInput = computed(() => inputData.value !== null)
      46              : 
      47           30 :   const hasValidOutput = computed(() => outputData.value !== null)
      48              : 
      49           30 :   const isReady = computed(() => hasValidInput.value && !isLoading.value)
      50              : 
      51           30 :   const reset = () => {
      52            7 :     inputData.value = null
      53            7 :     outputData.value = null
      54            7 :     sourceNode.value = null
      55            7 :     isLoading.value = false
      56            7 :     loadError.value = null
      57              :   }
      58              : 
      59           30 :   const setLoading = (loading: boolean, error?: string) => {
      60           59 :     isLoading.value = loading
      61           59 :     if (error) {
      62            0 :       loadError.value = error
      63              :     }
      64              :   }
      65              : 
      66           30 :   return {
      67              :     inputData,
      68              :     outputData,
      69              :     sourceNode,
      70              :     isLoading,
      71              :     loadError,
      72              : 
      73              :     hasValidInput,
      74              :     hasValidOutput,
      75              :     isReady,
      76              : 
      77              :     reset,
      78              :     setLoading
      79              :   }
      80              : })
        

Generated by: LCOV version 2.0-1