* Creates a Object containing all the info about this graph, it can be serialized * @deprecated Use asSerialisable, which returns the newer schema version. * @returns value of the node
(option?: { sortNodes: boolean })
| 1597 | * @returns value of the node |
| 1598 | */ |
| 1599 | serialize(option?: { sortNodes: boolean }): ISerialisedGraph { |
| 1600 | const { config, state, groups, nodes, reroutes, extra, floatingLinks, definitions } = this.asSerialisable(option) |
| 1601 | const linkArray = [...this._links.values()] |
| 1602 | const links = linkArray.map(x => x.serialize()) |
| 1603 | |
| 1604 | if (reroutes?.length) { |
| 1605 | // Link parent IDs cannot go in 0.4 schema arrays |
| 1606 | extra.linkExtensions = linkArray |
| 1607 | .filter(x => x.parentId !== undefined) |
| 1608 | .map(x => ({ id: x.id, parentId: x.parentId })) |
| 1609 | } |
| 1610 | |
| 1611 | extra.reroutes = reroutes?.length ? reroutes : undefined |
| 1612 | return { |
| 1613 | id: this.id, |
| 1614 | revision: this.revision, |
| 1615 | last_node_id: state.lastNodeId, |
| 1616 | last_link_id: state.lastLinkId, |
| 1617 | nodes, |
| 1618 | links, |
| 1619 | floatingLinks, |
| 1620 | groups, |
| 1621 | definitions, |
| 1622 | config, |
| 1623 | extra, |
| 1624 | version: LiteGraph.VERSION, |
| 1625 | } |
| 1626 | } |
| 1627 | |
| 1628 | /** @returns The drag and scale state of the first attached canvas, otherwise `undefined`. */ |
| 1629 | #getDragAndScale(): DragAndScaleState | undefined { |
no test coverage detected