mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-01 11:10:00 +00:00
Make node id serialization optional (#76)
This commit is contained in:
2
public/litegraph.d.ts
vendored
2
public/litegraph.d.ts
vendored
@@ -584,7 +584,7 @@ export declare class LGraph {
|
||||
/** Destroys a link */
|
||||
removeLink(link_id: number): void;
|
||||
/** Creates a Object containing all the info about this graph, it can be serialized */
|
||||
serialize<T extends serializedLGraph>(): T;
|
||||
serialize<T extends serializedLGraph>(option?: { sortNodes: boolean }): T;
|
||||
/**
|
||||
* Configure a graph from a JSON string
|
||||
* @param data configure a graph from a JSON string
|
||||
|
||||
@@ -2042,9 +2042,13 @@ const globalExport = {};
|
||||
* @method serialize
|
||||
* @return {Object} value of the node
|
||||
*/
|
||||
serialize() {
|
||||
serialize(option = { sortNodes: false }) {
|
||||
var nodes_info = [];
|
||||
nodes_info = [...this._nodes].sort((a, b) => a.id - b.id).map(node => node.serialize());
|
||||
nodes_info = (
|
||||
option?.sortNodes ?
|
||||
[...this._nodes].sort((a, b) => a.id - b.id) :
|
||||
this._nodes
|
||||
).map(node => node.serialize());
|
||||
|
||||
//pack link info into a non-verbose format
|
||||
var links = [];
|
||||
|
||||
Reference in New Issue
Block a user