Line data Source code
1 : import type { LGraphNode } from '@/lib/litegraph/src/litegraph'
2 : import type { IGalleriaWidget } from '@comfyorg/graph-model/widgets'
3 : import { isGalleriaInputSpec } from '@comfyorg/object-info-parser/schemas/nodeDefSchemaV2'
4 : import type {
5 : GalleriaInputSpec,
6 : InputSpec as InputSpecV2
7 : } from '@comfyorg/object-info-parser/schemas/nodeDefSchemaV2'
8 : import type { ComfyWidgetConstructorV2 } from '@/types/widgetConstructor'
9 :
10 2356 : export const useGalleriaWidget = (): ComfyWidgetConstructorV2 => {
11 2356 : return (node: LGraphNode, inputSpec: InputSpecV2): IGalleriaWidget => {
12 0 : if (!isGalleriaInputSpec(inputSpec)) {
13 0 : console.error('Invalid input spec for galleria widget')
14 : }
15 :
16 0 : const galleriaSpec = inputSpec as GalleriaInputSpec
17 0 : const { name } = galleriaSpec
18 0 : const images = galleriaSpec.images ?? galleriaSpec.options?.images ?? []
19 :
20 : const widget = node.addWidget('galleria', name, images, () => {}, {
21 : serialize: true
22 : }) as IGalleriaWidget
23 :
24 0 : return widget
25 : }
26 : }
|