Refresh combo boxes button

This commit is contained in:
space-nuko
2023-05-04 20:24:04 -05:00
parent 2ae41e26e6
commit df0a93ecb0
13 changed files with 196 additions and 64 deletions

View File

@@ -1,9 +1,10 @@
import type { ComfyInputConfig } from "$lib/IComfyInputSlot";
import type { SerializedPrompt } from "$lib/components/ComfyApp";
import type ComfyWidget from "$lib/components/widgets/ComfyWidget";
import { LGraph, LGraphNode } from "@litegraph-ts/core";
import { LGraph, LGraphNode, LiteGraph, type SerializedLGraphNode } from "@litegraph-ts/core";
import type { SvelteComponentDev } from "svelte/internal";
import type { ComfyWidgetNode } from "./ComfyWidgetNodes";
import type IComfyInputSlot from "$lib/IComfyInputSlot";
export type DefaultWidgetSpec = {
defaultWidgetNode: new (name?: string) => ComfyWidgetNode,
@@ -21,4 +22,34 @@ export default class ComfyGraphNode extends LGraphNode {
onExecuted?(output: any): void;
defaultWidgets?: DefaultWidgetLayout
override onSerialize(o: SerializedLGraphNode) {
for (let index = 0; index < this.inputs.length; index++) {
const input = this.inputs[index]
const serInput = o.inputs[index]
if ("defaultWidgetNode" in input) {
const comfyInput = input as IComfyInputSlot
const widgetNode = comfyInput.defaultWidgetNode
const ty = Object.values(LiteGraph.registered_node_types)
.find(v => v.class === widgetNode)
if (ty)
(serInput as any).widgetNodeType = ty.type
}
}
}
override onConfigure(o: SerializedLGraphNode) {
for (let index = 0; index < this.inputs.length; index++) {
const input = this.inputs[index]
const serInput = o.inputs[index]
if ("widgetNodeType" in serInput) {
const comfyInput = input as IComfyInputSlot
const ty: string = serInput.widgetNodeType as any
const widgetNode = Object.values(LiteGraph.registered_node_types)
.find(v => v.type === ty)
if (widgetNode)
comfyInput.defaultWidgetNode = widgetNode.class as any
}
}
}
}