From 84c939cf71eb26f2d97cde88b4eade8e9334dedb Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Fri, 5 Jul 2024 21:04:32 -0400 Subject: [PATCH] Rename ComfyWorkflow to ComfyWorkflowJSON (#91) --- src/scripts/api.ts | 4 ++-- src/scripts/app.ts | 9 ++++++--- src/scripts/defaultGraph.ts | 4 ++-- src/types/comfyWorkflow.ts | 6 ++++-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/scripts/api.ts b/src/scripts/api.ts index fd96f9a56..a97b49174 100644 --- a/src/scripts/api.ts +++ b/src/scripts/api.ts @@ -1,4 +1,4 @@ -import { ComfyWorkflow } from "types/comfyWorkflow"; +import { ComfyWorkflowJSON } from "types/comfyWorkflow"; import { HistoryTaskItem, PendingTaskItem, @@ -13,7 +13,7 @@ interface QueuePromptRequestBody { prompt: Record; extra_data: { extra_pnginfo: { - workflow: ComfyWorkflow; + workflow: ComfyWorkflowJSON; }; }; front?: boolean; diff --git a/src/scripts/app.ts b/src/scripts/app.ts index 14567dcee..fb1b4220d 100644 --- a/src/scripts/app.ts +++ b/src/scripts/app.ts @@ -15,7 +15,10 @@ import { createImageHost, calculateImageGrid } from "./ui/imagePreview"; import { DraggableList } from "./ui/draggableList"; import { applyTextReplacements, addStylesheet } from "./utils"; import type { ComfyExtension } from "/types/comfy"; -import { type ComfyWorkflow, parseComfyWorkflow } from "../types/comfyWorkflow"; +import { + type ComfyWorkflowJSON, + parseComfyWorkflow, +} from "../types/comfyWorkflow"; import { ComfyNodeDef } from "/types/apiTypes"; import { ComfyAppMenu } from "./ui/menu/index.js"; import { getStorageValue, setStorageValue } from "./utils.js"; @@ -1094,7 +1097,7 @@ export class ComfyApp { // No image found. Look for node data data = data.getData("text/plain"); - let workflow: ComfyWorkflow; + let workflow: ComfyWorkflowJSON; try { data = data.slice(data.indexOf("{")); workflow = await parseComfyWorkflow(data); @@ -2182,7 +2185,7 @@ export class ComfyApp { * @param { boolean } clean If the graph state, e.g. images, should be cleared */ async loadGraphData( - graphData?: ComfyWorkflow, + graphData?: ComfyWorkflowJSON, clean: boolean = true, restore_view: boolean = true, workflow: string | null = null diff --git a/src/scripts/defaultGraph.ts b/src/scripts/defaultGraph.ts index d3bb0e8b2..2b54dc7a7 100644 --- a/src/scripts/defaultGraph.ts +++ b/src/scripts/defaultGraph.ts @@ -1,6 +1,6 @@ -import type { ComfyWorkflow } from "/types/comfyWorkflow"; +import type { ComfyWorkflowJSON } from "/types/comfyWorkflow"; -export const defaultGraph: ComfyWorkflow = { +export const defaultGraph: ComfyWorkflowJSON = { last_node_id: 9, last_link_id: 9, nodes: [ diff --git a/src/types/comfyWorkflow.ts b/src/types/comfyWorkflow.ts index 62baa107b..2e8954858 100644 --- a/src/types/comfyWorkflow.ts +++ b/src/types/comfyWorkflow.ts @@ -127,9 +127,11 @@ export type NodeInput = z.infer; export type NodeOutput = z.infer; export type ComfyLink = z.infer; export type ComfyNode = z.infer; -export type ComfyWorkflow = z.infer; +export type ComfyWorkflowJSON = z.infer; -export async function parseComfyWorkflow(data: string): Promise { +export async function parseComfyWorkflow( + data: string +): Promise { // Validate const result = await zComfyWorkflow.safeParseAsync(JSON.parse(data)); if (!result.success) {