0.0.22 • Published 11 days ago

@comfy-creator/graph-editor v0.0.22

Weekly downloads
-
License
-
Repository
-
Last release
11 days ago

Comfy-Graph-Editor

This is a rewrite of ComfyUI. We changed the following:

  • We replaced LiteGraph.js with React Flow; this is a more modern library with many more features and a better dev-experience.
  • We redesigned graph-logic to allow for loops and conditional branching. This will be used to create Agentic Systems in the future, similar to LangGraph.
  • We redesigned the frontend to make it visually similar to Unreal Engine Blueprints.
  • We store every graph as a Yjs doc, which enables multiple-users to collaboratively edit the same graph, and allows for efficiently streaming the results of real-time media generation.
  • We redesigned server <-> client communication to be standardized and less ad-hoc.
  • We replaced the problematic GPL-3 license with our own proprietary license. You can now use a ComfyUI interface as a dependency without being forced to change your software's license to GPL-3 as well; we simply ask for a licensing fee for commercial usage, and bar using it for managed services that compete with our own serverless offering at comfycreator.com.

Usage:

  • Run yarn dev to start the development server; this is served by Vite directly along with hot-reload.
  • Run yarn build to build the library that is published to NPM.

Dev Notes:

State Management:

First we create a yDoc, like const ydoc = new Doc(); this is stored outside of React, in client-memory. Then, we create a YJS provider, which establishes a websocket connection to our Yjs server; we will (1) send diffs that are applied to our local yDoc to this server, and (2) receive diffs from this server, and apply them to our local yDoc. This syncronizes state remotely.

In Zustand, we obtain a reference to this yDoc, like nodesMap = ydoc.getMap<Node>('nodes'). First, we subscribe to the Yjs Provider; when a state, such as nodesMap, changes, we apply this directly to our nodes, like setNodes(Array.from(nodesMap.values()). This updates our Zustand state nodes, which will propagate throughtout the rest of the app.

Next, we create a wrapper, around setNodes(), which will be used by ReactFlow. When any logic in our app calls setNodes(), we will also apply these changes to our yDoc. We also modify our onNodesChanges to similarly take changes that ReactFlow is proposing and apply them to our yDoc as well.

ReactFlow uses (1) nodes as the source of truth for state, (2) it uses onNodesChange as a handler called when it wants to apply state-changes to the graph. This allows us to implement our own custom logic to the state-changes. ReactFlow does not use setNodes directly to change state; it expects us to do that in reseponse to its events.

This is how state is propagated throughtout our app.

0.0.20

11 days ago

0.0.21

11 days ago

0.0.22

11 days ago

0.0.17

11 days ago

0.0.18

11 days ago

0.0.19

11 days ago

0.0.10

13 days ago

0.0.11

13 days ago

0.0.12

13 days ago

0.0.1

13 days ago

0.0.3

13 days ago

0.0.2

13 days ago

0.0.15

13 days ago

0.0.9

13 days ago

0.0.16

13 days ago

0.0.8

13 days ago

0.0.5

13 days ago

0.2.3

18 days ago

0.0.4

13 days ago

0.2.2

18 days ago

0.0.7

13 days ago

0.0.6

13 days ago

0.2.1

19 days ago

0.2.0

19 days ago