Files
ComfyUI_frontend/src/renderer/extensions/vueNodes/execution/useExecutionStateProvider.ts
2025-09-13 23:44:15 -07:00

36 lines
1.0 KiB
TypeScript

import { computed, provide } from 'vue'
import {
ExecutingNodeIdsKey,
NodeProgressStatesKey
} from '@/renderer/core/canvas/injectionKeys'
import { useExecutionStore } from '@/stores/executionStore'
/**
* Composable for providing execution state to Vue node children
*
* This composable sets up the execution state providers that can be injected
* by child Vue nodes using useNodeExecutionState.
*
* Should be used in the parent component that manages Vue nodes (e.g., GraphCanvas).
*/
export const useExecutionStateProvider = () => {
const executionStore = useExecutionStore()
// Convert execution store data to the format expected by Vue nodes
const executingNodeIds = computed(
() => new Set(executionStore.executingNodeIds.map(String))
)
const nodeProgressStates = computed(() => executionStore.nodeProgressStates)
// Provide the execution state to all child Vue nodes
provide(ExecutingNodeIdsKey, executingNodeIds)
provide(NodeProgressStatesKey, nodeProgressStates)
return {
executingNodeIds,
nodeProgressStates
}
}