Move app serialize into ComfyApp class

This commit is contained in:
space-nuko
2023-05-03 23:30:26 -05:00
parent 35d4761fa9
commit fd417c6759
4 changed files with 75 additions and 49 deletions

View File

@@ -18,6 +18,8 @@ import queueState from "$lib/stores/queueState";
import GraphSync from "$lib/GraphSync";
import type { SvelteComponentDev } from "svelte/internal";
import type IComfyInputSlot from "$lib/IComfyInputSlot";
import type { SerializedLayoutState } from "$lib/stores/layoutState";
import layoutState from "$lib/stores/layoutState";
LiteGraph.catch_exceptions = false;
@@ -28,15 +30,11 @@ if (typeof window !== "undefined") {
type QueueItem = { num: number, batchCount: number }
export type SerializedPanes = {
panels: { nodeId: number }[][]
}
export type SerializedAppState = {
createdBy: "ComfyBox",
version: number,
panes: SerializedPanes,
workflow: SerializedLGraph
workflow: SerializedLGraph,
layout: SerializedLayoutState
}
type ComfyAppEvents = {
@@ -307,6 +305,20 @@ export default class ComfyApp {
// await this.#invokeExtensionsAsync("registerCustomNodes");
}
serialize(): SerializedAppState {
const graph = this.lGraph;
const serializedGraph = graph.serialize()
const serializedLayout = layoutState.serialize()
return {
createdBy: "ComfyBox",
version: 1,
workflow: serializedGraph,
layout: serializedLayout
}
}
private showDropZone() {
if (this.dropZone)
this.dropZone.style.display = "block";