diff --git a/src/components/toast/RerouteMigrationToast.vue b/src/components/toast/RerouteMigrationToast.vue index cee726321..4264945ee 100644 --- a/src/components/toast/RerouteMigrationToast.vue +++ b/src/components/toast/RerouteMigrationToast.vue @@ -33,7 +33,7 @@ const toast = useToast() const workflowStore = useWorkflowStore() const migrateToLitegraphReroute = () => { - const workflowJSON = app.serializeGraph() as unknown as WorkflowJSON04 + const workflowJSON = app.graph.serialize() as unknown as WorkflowJSON04 const migratedWorkflowJSON = migrateLegacyRerouteNodes(workflowJSON) app.loadGraphData( migratedWorkflowJSON, diff --git a/src/composables/useWorkflowPersistence.ts b/src/composables/useWorkflowPersistence.ts index a2583a66f..e0178a139 100644 --- a/src/composables/useWorkflowPersistence.ts +++ b/src/composables/useWorkflowPersistence.ts @@ -18,7 +18,7 @@ export function useWorkflowPersistence() { const persistCurrentWorkflow = () => { if (!workflowPersistenceEnabled.value) return - const workflow = JSON.stringify(comfyApp.serializeGraph()) + const workflow = JSON.stringify(comfyApp.graph.serialize()) localStorage.setItem('workflow', workflow) if (api.clientId) { sessionStorage.setItem(`workflow:${api.clientId}`, workflow) diff --git a/src/scripts/app.ts b/src/scripts/app.ts index e7308d1a8..d6fd8131e 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -1147,24 +1147,13 @@ export class ComfyApp { ) await useWorkflowService().afterLoadNewGraph( workflow, - // @ts-expect-error zod types issue. Will be fixed after we enable ts-strict - this.graph.serialize() + this.graph.serialize() as unknown as ComfyWorkflowJSON ) requestAnimationFrame(() => { this.graph.setDirtyCanvas(true, true) }) } - /** - * Serializes a graph using preferred user settings. - * @param graph The litegraph to serialize. - * @returns A serialized graph (aka workflow) with preferred user settings. - */ - serializeGraph(graph: LGraph = this.graph) { - const sortNodes = useSettingStore().get('Comfy.Workflow.SortNodeIdOnSave') - return graph.serialize({ sortNodes }) - } - async graphToPrompt(graph = this.graph) { return graphToPrompt(graph, { sortNodes: useSettingStore().get('Comfy.Workflow.SortNodeIdOnSave') @@ -1276,8 +1265,10 @@ export class ComfyApp { // by external callers, and `importA1111` has no access to `app`. useWorkflowService().beforeLoadNewGraph() importA1111(this.graph, pngInfo.parameters) - // @ts-expect-error zod type issue on ComfyWorkflowJSON. Should be resolved after enabling ts-strict globally. - useWorkflowService().afterLoadNewGraph(fileName, this.serializeGraph()) + useWorkflowService().afterLoadNewGraph( + fileName, + this.graph.serialize() as unknown as ComfyWorkflowJSON + ) } else { this.showErrorOnFileLoad(file) } @@ -1479,9 +1470,10 @@ export class ComfyApp { app.graph.arrange() - // @ts-expect-error zod type issue on ComfyWorkflowJSON. ComfyWorkflowJSON - // is stricter than LiteGraph's serialisation schema. - useWorkflowService().afterLoadNewGraph(fileName, this.serializeGraph()) + useWorkflowService().afterLoadNewGraph( + fileName, + this.graph.serialize() as unknown as ComfyWorkflowJSON + ) } /**