Rename ComfyWorkflow to ComfyWorkflowJSON (#91)

This commit is contained in:
Chenlei Hu
2024-07-05 21:04:32 -04:00
committed by GitHub
parent d6b2d5fb4f
commit 84c939cf71
4 changed files with 14 additions and 9 deletions

View File

@@ -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<number, any>;
extra_data: {
extra_pnginfo: {
workflow: ComfyWorkflow;
workflow: ComfyWorkflowJSON;
};
};
front?: boolean;

View File

@@ -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

View File

@@ -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: [

View File

@@ -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) {