MCPcopy Create free account
hub / github.com/Comfy-Org/litegraph.js / serialize

Method serialize

src/LGraph.ts:1599–1626  ·  view source on GitHub ↗

* 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 })

Source from the content-addressed store, hash-verified

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 {

Callers 3

checkNodeTypesMethod · 0.45
convertToSubgraphMethod · 0.45
asSerialisableMethod · 0.45

Calls 1

asSerialisableMethod · 0.95

Tested by

no test coverage detected