Refresh combo boxes button
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user