()
| 859 | |
| 860 | /* Creates a clone of this node */ |
| 861 | clone(): LGraphNode | null { |
| 862 | if (this.type == null) return null |
| 863 | const node = LiteGraph.createNode(this.type) |
| 864 | if (!node) return null |
| 865 | |
| 866 | // we clone it because serialize returns shared containers |
| 867 | const data = LiteGraph.cloneObject(this.serialize()) |
| 868 | const { inputs, outputs } = data |
| 869 | |
| 870 | // remove links |
| 871 | if (inputs) { |
| 872 | for (const input of inputs) { |
| 873 | input.link = null |
| 874 | } |
| 875 | } |
| 876 | |
| 877 | if (outputs) { |
| 878 | for (const { links } of outputs) { |
| 879 | if (links) links.length = 0 |
| 880 | } |
| 881 | } |
| 882 | |
| 883 | // @ts-expect-error Exceptional case: id is removed so that the graph can assign a new one on add. |
| 884 | delete data.id |
| 885 | |
| 886 | if (LiteGraph.use_uuids) data.id = LiteGraph.uuidv4() |
| 887 | |
| 888 | node.configure(data) |
| 889 | |
| 890 | return node |
| 891 | } |
| 892 | |
| 893 | /** |
| 894 | * serialize and stringify |
no test coverage detected