Auto transforms bugged node pos (#712)

This commit is contained in:
Chenlei Hu
2024-09-02 14:41:45 -04:00
committed by GitHub
parent 9d69db6db7
commit 51b7467012
2 changed files with 21 additions and 1 deletions

View File

@@ -74,7 +74,10 @@ const zProperties = z
.passthrough()
const zVector2 = z.union([
z.object({ 0: z.number(), 1: z.number() }).transform((v) => [v[0], v[1]]),
z
.object({ 0: z.number(), 1: z.number() })
.passthrough()
.transform((v) => [v[0], v[1]]),
z.tuple([z.number(), z.number()])
])

View File

@@ -69,6 +69,23 @@ describe('parseComfyWorkflow', () => {
workflow.nodes[0].pos = { 0: 3, 1: 4 }
validatedWorkflow = await validateComfyWorkflow(workflow)
expect(validatedWorkflow.nodes[0].pos).toEqual([3, 4])
// Should accept the legacy bugged format object.
// https://github.com/Comfy-Org/ComfyUI_frontend/issues/710
workflow.nodes[0].pos = {
'0': 600,
'1': 340,
'2': 0,
'3': 0,
'4': 0,
'5': 0,
'6': 0,
'7': 0,
'8': 0,
'9': 0
}
validatedWorkflow = await validateComfyWorkflow(workflow)
expect(validatedWorkflow.nodes[0].pos).toEqual([600, 340])
})
it('workflow.nodes.widget_values', async () => {