Files
ComfyUI_frontend/src/composables/nodePack/useNodePacks.ts
snomiao 7d28bb6919 [refactor] Add type imports across codebase for verbatim module syntax
- Update all Vue components to use type imports
- Update all TypeScript files to use type imports
- Update test files to use type imports
- Ensure compliance with TypeScript verbatim module syntax

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-13 14:12:33 +00:00

44 lines
950 B
TypeScript

import { get, useAsyncState } from '@vueuse/core'
import { type Ref } from 'vue'
import { useComfyRegistryStore } from '@/stores/comfyRegistryStore'
import { type UseNodePacksOptions } from '@/types/comfyManagerTypes'
/**
* Handles fetching node packs from the registry given a list of node pack IDs
*/
export const useNodePacks = (
packsIds: string[] | Ref<string[]>,
options: UseNodePacksOptions = {}
) => {
const { immediate = false } = options
const { getPacksByIds } = useComfyRegistryStore()
const fetchPacks = () => getPacksByIds.call(get(packsIds).filter(Boolean))
const {
isReady,
isLoading,
error,
execute,
state: nodePacks
} = useAsyncState(fetchPacks, [], {
immediate
})
const cleanup = () => {
getPacksByIds.cancel()
isReady.value = false
isLoading.value = false
}
return {
error,
isLoading,
isReady,
nodePacks,
startFetch: execute,
cleanup
}
}