Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] How to clear all previously defined nodes? #479

Open
pyramation opened this issue May 28, 2024 · 2 comments
Open

[question] How to clear all previously defined nodes? #479

pyramation opened this issue May 28, 2024 · 2 comments

Comments

@pyramation
Copy link

pyramation commented May 28, 2024

Hello! You're library is AWESOME

I used to work for sidefx.com and have been in FBP my whole life, and want to build a large amount of tooling around litegraph

however, I'd like to define, if possible, only nodes I'm building and delete the current nodes available to keep the menu and folder structure clean. Is this possible?

I tried using

const registered = Object.keys(LiteGraph.registered_node_types);
registered.forEach(node=>{
      LiteGraph.unregisterNodeType(node);
});

Server Error
Error: node type not found: basic/time

@atlasan
Copy link
Contributor

atlasan commented May 29, 2024

Hi there! Better to wait Javi's answer but here's an advice:
I would include only the litegraph.js file from the src folder, or customize the inclusions in the example editor index.html

Your code actually works from the console here:
https://tamats.com/projects/litegraph/editor/
(but fails to remove some formulas that uses a shared node)

The building and packing probably needs some revision, if you're using the npm or the minified version, that it could be a reason.

Nice to have a sidefx dev here ^_^
Because LiteGraph is so cool and thanks to finally have got some big project using it (ComfyUI), a large amount of users actually touches it daily. It's than even more important to try to help and let it grow how it deserve.
If you are going to build many tooling around, that would be awesome, and please share some of you works. Let's contribute and join forces for a better quality of life and nodes.

@zhzLuke96
Copy link

zhzLuke96 commented May 29, 2024

To address your requirement, the correct approach would be to use clearRegisteredTypes instead of unregisterNodeType.

clearRegisteredTypes: function() {
this.registered_node_types = {};
this.node_types_by_file_extension = {};
this.Nodes = {};
this.searchbox_extras = {};
},

The clearRegisteredTypes method will handle multiple internal objects to thoroughly clear out nodes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants