mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-24 16:29:45 +00:00
Support associated socket for widgets (#3326)
Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
@@ -10,23 +10,21 @@ import { ComfyWidgetConstructor, ComfyWidgets } from '@/scripts/widgets'
|
||||
|
||||
export const useWidgetStore = defineStore('widget', () => {
|
||||
const coreWidgets = ComfyWidgets
|
||||
const customWidgets = ref<Record<string, ComfyWidgetConstructor>>({})
|
||||
const widgets = computed(() => ({
|
||||
...customWidgets.value,
|
||||
...coreWidgets
|
||||
}))
|
||||
const customWidgets = ref<Map<string, ComfyWidgetConstructor>>(new Map())
|
||||
const widgets = computed<Map<string, ComfyWidgetConstructor>>(
|
||||
() => new Map([...customWidgets.value, ...Object.entries(coreWidgets)])
|
||||
)
|
||||
|
||||
function inputIsWidget(spec: InputSpecV2 | InputSpecV1) {
|
||||
const type = Array.isArray(spec) ? getInputSpecType(spec) : spec.type
|
||||
return type in widgets.value
|
||||
return widgets.value.has(type)
|
||||
}
|
||||
|
||||
function registerCustomWidgets(
|
||||
newWidgets: Record<string, ComfyWidgetConstructor>
|
||||
) {
|
||||
customWidgets.value = {
|
||||
...customWidgets.value,
|
||||
...newWidgets
|
||||
for (const [type, widget] of Object.entries(newWidgets)) {
|
||||
customWidgets.value.set(type, widget)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user