mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-10 10:00:08 +00:00
Allow dynamic widgets values (#162)
This commit is contained in:
@@ -49,14 +49,7 @@ const zVector2 = z.union([
|
||||
z.tuple([z.number(), z.number()]),
|
||||
]);
|
||||
|
||||
const zWidgetValues = z.union([
|
||||
z.array(z.any()),
|
||||
z.record(z.any()).transform((v) =>
|
||||
Object.keys(v)
|
||||
.sort((a, b) => Number(a) - Number(b))
|
||||
.map((key) => v[key])
|
||||
),
|
||||
]);
|
||||
const zWidgetValues = z.union([z.array(z.any()), z.record(z.any())]);
|
||||
|
||||
const zComfyNode = z
|
||||
.object({
|
||||
|
||||
@@ -82,9 +82,10 @@ describe("parseComfyWorkflow", () => {
|
||||
workflow.nodes[0].widgets_values = undefined;
|
||||
await expect(parseComfyWorkflow(JSON.stringify(workflow))).resolves.not.toThrow();
|
||||
|
||||
// Should automatically transform the legacy format object to array.
|
||||
workflow.nodes[0].widgets_values = {0: "foo", 1: "bar"};
|
||||
// The object format of widgets_values is used by VHS nodes to perform
|
||||
// dynamic widgets display.
|
||||
workflow.nodes[0].widgets_values = {"foo": "bar"};
|
||||
const parsedWorkflow = await parseComfyWorkflow(JSON.stringify(workflow));
|
||||
expect(parsedWorkflow.nodes[0].widgets_values).toEqual(["foo", "bar"]);
|
||||
expect(parsedWorkflow.nodes[0].widgets_values).toEqual({"foo": "bar"});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user