From b663f86c9ebda47c77c663ec698f3c709c860e8a Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Mon, 4 Nov 2024 14:08:09 -0500 Subject: [PATCH] Serialize to node pos/size to plain array (#273) --- src/LGraphNode.ts | 4 ++-- test/LGraphNode.test.ts | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/LGraphNode.ts b/src/LGraphNode.ts index 6bbc94abd..61a21ce50 100644 --- a/src/LGraphNode.ts +++ b/src/LGraphNode.ts @@ -426,8 +426,8 @@ export class LGraphNode implements Positionable { const o: ISerialisedNode = { id: this.id, type: this.type, - pos: this.pos, - size: this.size, + pos: [this.pos[0], this.pos[1]], + size: [this.size[0], this.size[1]], flags: LiteGraph.cloneObject(this.flags), order: this.order, mode: this.mode, diff --git a/test/LGraphNode.test.ts b/test/LGraphNode.test.ts index a846dc637..481642ee1 100644 --- a/test/LGraphNode.test.ts +++ b/test/LGraphNode.test.ts @@ -3,11 +3,14 @@ import { } from "../src/litegraph" describe("LGraphNode", () => { - it("should serialize position correctly", () => { + it("should serialize position/size correctly", () => { const node = new LGraphNode("TestNode") node.pos = [10, 10] expect(node.pos).toEqual(new Float32Array([10, 10])) - expect(node.serialize().pos).toEqual(new Float32Array([10, 10])) - }) + expect(node.serialize().pos).toEqual([10, 10]) + node.size = [100, 100] + expect(node.size).toEqual(new Float32Array([100, 100])) + expect(node.serialize().size).toEqual([100, 100]) + }) }) \ No newline at end of file