Skip to content

Commit

Permalink
Rename ComfyWorkflow to ComfyWorkflowJSON (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
huchenlei authored Jul 6, 2024
1 parent d6b2d5f commit 84c939c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/scripts/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ComfyWorkflow } from "types/comfyWorkflow";
import { ComfyWorkflowJSON } from "types/comfyWorkflow";
import {
HistoryTaskItem,
PendingTaskItem,
Expand All @@ -13,7 +13,7 @@ interface QueuePromptRequestBody {
prompt: Record<number, any>;
extra_data: {
extra_pnginfo: {
workflow: ComfyWorkflow;
workflow: ComfyWorkflowJSON;
};
};
front?: boolean;
Expand Down
9 changes: 6 additions & 3 deletions src/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/defaultGraph.ts
Original file line number Diff line number Diff line change
@@ -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: [
Expand Down
6 changes: 4 additions & 2 deletions src/types/comfyWorkflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ export type NodeInput = z.infer<typeof zNodeInput>;
export type NodeOutput = z.infer<typeof zNodeOutput>;
export type ComfyLink = z.infer<typeof zComfyLink>;
export type ComfyNode = z.infer<typeof zComfyNode>;
export type ComfyWorkflow = z.infer<typeof zComfyWorkflow>;
export type ComfyWorkflowJSON = z.infer<typeof zComfyWorkflow>;

export async function parseComfyWorkflow(data: string): Promise<ComfyWorkflow> {
export async function parseComfyWorkflow(
data: string
): Promise<ComfyWorkflowJSON> {
// Validate
const result = await zComfyWorkflow.safeParseAsync(JSON.parse(data));
if (!result.success) {
Expand Down

0 comments on commit 84c939c

Please sign in to comment.