Tha gallery widget

This commit is contained in:
space-nuko
2023-04-07 12:13:03 -05:00
parent eed4e29004
commit f40e46d0c2
18 changed files with 246 additions and 40 deletions

View File

@@ -1,5 +1,14 @@
import type ComfyWidget from "$lib/components/widgets/ComfyWidget";
import { LGraphNode } from "@litegraph-ts/core";
export default class ComfyGraphNode extends LGraphNode {
isVirtualNode: boolean = false;
/*
* Widgets that aren't a part of the graph, but are used for rendering
* purposes only.
*/
virtualWidgets: ComfyWidget[] = [];
onExecuted?(output: any): void;
}

View File

@@ -0,0 +1,32 @@
import ComfyGalleryWidget, { type ComfyGalleryEntry } from "$lib/widgets/ComfyGalleryWidget";
import ComfyGraphNode from "./ComfyGraphNode";
export type ComfyImageResult = {
filename: string,
subfolder: string,
type: "output" | "temp"
}
export type ComfyImageExecOutput = {
images: ComfyImageResult[]
}
export default class ComfySaveImageNode extends ComfyGraphNode {
private _imageResults: Array<ComfyImageResult> = [];
private _galleryWidget: ComfyGalleryWidget;
constructor(title?: any) {
super(title)
this._galleryWidget = new ComfyGalleryWidget("Images", this._imageResults, this);
this.virtualWidgets.push(this._galleryWidget)
}
override onExecuted(output: ComfyImageExecOutput) {
this._imageResults = Array.from(output.images); // TODO append?
const galleryItems = this._imageResults.map(r => {
// TODO
let entry: ComfyGalleryEntry = ["http://localhost:8188/" + r.type + "/" + r.filename, null]
return entry
});
this._galleryWidget.setValue(galleryItems)
}
}

View File

@@ -1 +1,2 @@
export { default as ComfyReroute } from "./ComfyReroute"
export { default as ComfySaveImageNode } from "./ComfySaveImageNode"