Comfy-Org / litegraph.js

A graph node engine and editor written in Javascript similar to PD or UDK Blueprints, comes with its own editor in HTML5 Canvas2D. The engine can run client side or server side using Node. It allows to export graphs as JSONs to be included in applications independently.
MIT License
27 stars 6 forks source link

Rewrite the whole lib with TypeScript & ES6 Class instead of Function prototype for easier to maintain and expand #20

Open cnwangjie opened 1 month ago

cnwangjie commented 1 month ago

Description

This issue proposes a significant refactor of the library, transitioning from the current function prototype-based approach to a modern TypeScript and ES6 class-based architecture. The primary motivation behind this change is to improve the library's maintainability, scalability, and overall developer experience.

Current Problems

Inherent Limitations of Prototypal Inheritance: The current function prototype inheritance model can become complex and cumbersome, especially as the codebase grows and new features are added. It often leads to deeply nested object structures and a less intuitive understanding of the code. Lack of Static Typing (JavaScript): Without static typing, we rely on runtime checks to catch errors, which can lead to unexpected issues in production. TypeScript's static type system would help prevent these problems at compile time. Readability and Maintainability Concerns: The prototype-based code can be less readable and harder to reason about than the structured class approach, potentially hindering future development and maintenance efforts.

Proposed Solution

cnwangjie commented 1 month ago

I am working on creating some products around ComfyUI. I have already implemented many parts of it in my code using TypeScript. I'd like to contribute to this project. If no other one is working or has a plan to do this.

DrJKL commented 1 month ago

@cnwangjie There's a parallel effort to do just this.

jagenjo commented 1 month ago

I second this (and Im the culprit of most of it).