mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-02 19:49:58 +00:00
Fix copy paste of widget value (#284)
* Fix copy paste of widget value * Fix ui tests * Allow undefined group font size * Update test expectations [skip ci] * nit --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
@@ -74,7 +74,7 @@ const zGroup = z
|
||||
title: z.string(),
|
||||
bounding: z.tuple([z.number(), z.number(), z.number(), z.number()]),
|
||||
color: z.string(),
|
||||
font_size: z.number(),
|
||||
font_size: z.number().optional(),
|
||||
locked: z.boolean().optional()
|
||||
})
|
||||
.passthrough()
|
||||
@@ -131,16 +131,15 @@ export type ComfyLink = z.infer<typeof zComfyLink>
|
||||
export type ComfyNode = z.infer<typeof zComfyNode>
|
||||
export type ComfyWorkflowJSON = z.infer<typeof zComfyWorkflow>
|
||||
|
||||
export async function parseComfyWorkflow(
|
||||
data: string
|
||||
): Promise<ComfyWorkflowJSON> {
|
||||
// Validate
|
||||
const result = await zComfyWorkflow.safeParseAsync(JSON.parse(data))
|
||||
export async function validateComfyWorkflow(
|
||||
data: any,
|
||||
onError: (error: string) => void = console.warn
|
||||
): Promise<ComfyWorkflowJSON | null> {
|
||||
const result = await zComfyWorkflow.safeParseAsync(data)
|
||||
if (!result.success) {
|
||||
// TODO: Pretty print the error on UI modal.
|
||||
const error = fromZodError(result.error)
|
||||
alert(`Invalid workflow against zod schema:\n${error}`)
|
||||
throw error
|
||||
onError(`Invalid workflow against zod schema:\n${error}`)
|
||||
return null
|
||||
}
|
||||
return result.data
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user