mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-03 22:59:14 +00:00
[Cleanup] Remove ComfyApp.serializeGraph (#3383)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user