Convert Figma logo to code with AI

retejs logorete

JavaScript framework for visual programming

9,978
651
9,978
6

Top Related Projects

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.

a super simple, no-nonsense diagramming library written in react that just works

Simple flow library 🖥️🖱️

5,633

🚀 JavaScript diagramming library that uses SVG and HTML for rendering.

7,735

Visual connectivity for webapps

4,593

Directed graph layout for JavaScript

Quick Overview

Rete.js is a modular framework for visual programming. It allows developers to create node-based editors in the browser, enabling users to build logic flows and data processing pipelines through a visual interface. Rete.js is highly customizable and can be used for various applications, from simple flow charts to complex visual programming environments.

Pros

  • Highly modular and extensible architecture
  • Rich ecosystem with numerous plugins and extensions
  • Supports both 2D and 3D rendering
  • Active community and regular updates

Cons

  • Steep learning curve for beginners
  • Documentation can be overwhelming due to the number of modules and options
  • Performance may degrade with very large and complex node graphs
  • Some advanced features require additional plugins or custom development

Code Examples

  1. Creating a basic Rete.js editor:
import Rete from "rete";
import ReactRenderPlugin from "rete-react-render-plugin";

const numComponent = new Rete.Component("Number");
numComponent.builder = (node) => {
  const out = new Rete.Output("num", "Number", numSocket);
  node.addOutput(out);
};

const editor = new Rete.NodeEditor("demo@0.1.0", container);
editor.use(ReactRenderPlugin);

editor.register(numComponent);
editor.fromJSON(data).then(() => editor.view.resize());
AreaPlugin.zoomAt(editor);
editor.trigger("process");
  1. Adding a custom node:
class AddComponent extends Rete.Component {
  constructor() {
    super("Add");
  }

  builder(node) {
    const inp1 = new Rete.Input("num1", "Number", numSocket);
    const inp2 = new Rete.Input("num2", "Number", numSocket);
    const out = new Rete.Output("sum", "Number", numSocket);

    return node
      .addInput(inp1)
      .addInput(inp2)
      .addOutput(out);
  }

  worker(node, inputs, outputs) {
    const n1 = inputs["num1"].length ? inputs["num1"][0] : 0;
    const n2 = inputs["num2"].length ? inputs["num2"][0] : 0;
    outputs["sum"] = n1 + n2;
  }
}
  1. Implementing a custom control:
import { Control } from "rete";

class NumControl extends Control {
  constructor(emitter, key, readonly) {
    super(key);
    this.emitter = emitter;
    this.key = key;
    this.readonly = readonly;
  }

  setValue(val) {
    this.value = val;
    this.emitter.trigger("process");
    this._alight();
  }

  render() {
    return (
      <input
        type="number"
        value={this.value}
        readOnly={this.readonly}
        onChange={(e) => this.setValue(+e.target.value)}
      />
    );
  }
}

Getting Started

To get started with Rete.js, follow these steps:

  1. Install Rete.js and its core plugins:

    npm install rete rete-connection-plugin rete-vue-render-plugin
    
  2. Create a new Rete.js editor in your project:

    import Rete from "rete";
    import ConnectionPlugin from "rete-connection-plugin";
    import VueRenderPlugin from "rete-vue-render-plugin";
    
    const container = document.querySelector("#rete");
    const editor = new Rete.NodeEditor("demo@0.1.0", container);
    editor.use(ConnectionPlugin);
    editor.use(VueRenderPlugin);
    
    // Register components and build your editor
    // ...
    
    editor.view.resize();
    AreaPlugin.zoomAt(editor);
    editor.trigger("process");
    
  3. Customize and extend the editor with additional components and plugins as needed.

Competitor Comparisons

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.

Pros of litegraph.js

  • Lightweight and fast, with a smaller footprint
  • Supports WebGL rendering for improved performance
  • More flexible node customization options

Cons of litegraph.js

  • Less active development and community support
  • Fewer built-in features and integrations
  • Limited documentation and examples

Code Comparison

litegraph.js:

var node = LiteGraph.createNode("basic/const");
node.pos = [100,100];
graph.add(node);

Rete:

const node = new Rete.Node('Add');
node.addInput(new Rete.Input('num1', 'Number', numSocket));
node.addOutput(new Rete.Output('result', 'Number', numSocket));

Both libraries allow for creating and adding nodes to a graph, but Rete provides a more structured approach with explicit input and output definitions. litegraph.js offers a simpler syntax for basic node creation, while Rete's approach may be more suitable for complex node structures.

litegraph.js is generally more lightweight and performant, making it a good choice for simpler projects or those requiring WebGL rendering. Rete, on the other hand, offers a more robust ecosystem with better documentation and community support, making it more suitable for larger, more complex applications.

a super simple, no-nonsense diagramming library written in react that just works

Pros of react-diagrams

  • Built specifically for React, offering seamless integration with React applications
  • Extensive documentation and examples, making it easier for developers to get started
  • Strong typing support with TypeScript, enhancing code reliability and maintainability

Cons of react-diagrams

  • Limited flexibility for non-React projects or custom rendering engines
  • Steeper learning curve for developers not familiar with React ecosystem
  • Less performant with large, complex diagrams compared to Rete

Code Comparison

react-diagrams:

import { DiagramEngine, DiagramModel, DefaultNodeModel } from '@projectstorm/react-diagrams';

const engine = new DiagramEngine();
const model = new DiagramModel();
const node1 = new DefaultNodeModel('Node 1', 'rgb(0,192,255)');
model.addNode(node1);
engine.setModel(model);

Rete:

import Rete from 'rete';

const numComponent = new Rete.Component('Number');
numComponent.builder = (node) => {
    const out1 = new Rete.Output('Number', 'Number');
    return node.addOutput(out1);
};

Both libraries offer powerful diagramming capabilities, but react-diagrams is more tightly integrated with React, while Rete provides greater flexibility for various frameworks and custom rendering engines. The choice between them depends on the specific project requirements and the development team's expertise.

Simple flow library 🖥️🖱️

Pros of Drawflow

  • Simpler and more lightweight, making it easier to integrate and use for basic flow diagrams
  • Built-in support for mobile devices and touch interactions
  • More straightforward API with less complexity for basic use cases

Cons of Drawflow

  • Less flexible and extensible compared to Rete's modular architecture
  • Fewer built-in features and node types, requiring more custom development for complex scenarios
  • Smaller community and ecosystem, potentially leading to fewer resources and third-party integrations

Code Comparison

Drawflow:

const drawflow = new Drawflow(document.getElementById('drawflow'));
drawflow.addNode('hello', 1, 1, 150, 100, 'hello', {}, 'Hello World!');

Rete:

const editor = new Rete.NodeEditor('demo@0.1.0', container);
const numComponent = new NumComponent();
editor.register(numComponent);
await editor.fromJSON(data);

Both libraries allow for creating and managing node-based editors, but Rete offers a more modular and extensible approach with components, while Drawflow provides a simpler API for basic flow diagrams. Rete is better suited for complex, customizable node editors, while Drawflow excels in simplicity and ease of use for straightforward flow charts.

5,633

🚀 JavaScript diagramming library that uses SVG and HTML for rendering.

Pros of X6

  • More comprehensive documentation and examples
  • Wider range of graph types and customization options
  • Larger and more active community support

Cons of X6

  • Steeper learning curve due to more complex API
  • Heavier bundle size, potentially impacting performance

Code Comparison

X6:

import { Graph } from '@antv/x6';

const graph = new Graph({
  container: document.getElementById('container'),
  width: 800,
  height: 600,
});

graph.addNode({
  x: 100,
  y: 100,
  width: 80,
  height: 40,
  label: 'Hello',
});

Rete:

import { Engine } from 'rete';

const engine = new Engine('demo@0.1.0');

const node = new Rete.Node('Add');
node.addInput(new Rete.Input('num1', 'Number'));
node.addInput(new Rete.Input('num2', 'Number'));
node.addOutput(new Rete.Output('result', 'Number'));

Both libraries offer powerful graph and node editing capabilities, but X6 provides a more extensive set of features and customization options at the cost of increased complexity. Rete, on the other hand, offers a simpler API that may be easier to get started with for basic node-based applications.

7,735

Visual connectivity for webapps

Pros of jsPlumb

  • More mature and established project with a larger community
  • Extensive documentation and examples
  • Supports multiple rendering modes (SVG, Canvas, VML)

Cons of jsPlumb

  • Steeper learning curve for complex implementations
  • Less flexible for custom node types and behaviors
  • Heavier library size compared to Rete.js

Code Comparison

jsPlumb:

jsPlumb.ready(function() {
  var instance = jsPlumb.getInstance();
  instance.connect({
    source: "element1",
    target: "element2",
    anchor: ["Top", "Bottom"]
  });
});

Rete.js:

const node1 = new Rete.Node('node1');
const node2 = new Rete.Node('node2');
const connection = new Rete.Connection(node1, node2);
editor.addNode(node1);
editor.addNode(node2);

Summary

jsPlumb is a more established library with extensive documentation and multiple rendering options, making it suitable for complex diagramming needs. However, it has a steeper learning curve and is less flexible for custom node types.

Rete.js, on the other hand, offers a more lightweight and flexible approach, allowing for easier customization of nodes and behaviors. It's particularly well-suited for building node-based editors and visual programming interfaces.

The choice between the two depends on the specific requirements of your project, such as the level of customization needed, the complexity of the diagrams, and the desired learning curve for implementation.

4,593

Directed graph layout for JavaScript

Pros of dagre

  • Specialized in graph layout algorithms, offering more advanced and customizable layout options
  • Lightweight and focused, making it easier to integrate into existing projects
  • Better performance for large graphs due to its optimized algorithms

Cons of dagre

  • Limited to graph layout functionality, lacking built-in node editing and interaction features
  • Requires more custom code to create interactive node-based editors
  • Less active development and community support compared to Rete

Code comparison

Rete:

const editor = new Rete.NodeEditor('demo@0.1.0', container);
const component = new MyComponent();
editor.register(component);
const node = await component.createNode({});
editor.addNode(node);

dagre:

const g = new dagre.graphlib.Graph();
g.setGraph({});
g.setDefaultEdgeLabel(() => ({}));
g.setNode('a', { width: 30, height: 30 });
dagre.layout(g);

Summary

Dagre is a specialized graph layout library, offering advanced layout algorithms and better performance for large graphs. However, it lacks built-in editing features and requires more custom code for interactive editors. Rete provides a more comprehensive solution for node-based editors but may be less flexible for complex graph layouts.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Rete.js

Made in Ukraine Discord

JavaScript framework for visual programming

rete logo

#StandWithUkraine 💙💛

#RussiaInvadedUkraine on 24 of February 2022, at 5.00 AM the armed forces of the Russian Federation attacked Ukraine. Please, Stand with Ukraine, stay tuned for updates on Ukraine’s official sources and channels in English and support Ukraine in its fight for freedom and democracy in Europe.

Help to defend Ukraine — donate to Ukraine’s main charity fund

Help to defend Ukraine — donate to the fund of the National Bank of Ukraine

Introduction 🎥

Rete.js is a framework for creating visual interfaces and workflows. It provides out-of-the-box solutions for visualization using various libraries and frameworks, as well as solutions for processing graphs based on dataflow and control flow approaches.

Getting started

Use Rete Kit to quickly set up a Rete.js application. It lets you select a stack (React.js, Vue.js or Angular, Svelte) and the set of features

npx rete-kit app

Alternatively, you can follow the complete guide

Documentation

Sponsors

Thank you to all our sponsors! Become a sponsor

Backers

Thank you to all our backers! Become a backer

Contributors

This project exists thanks to all the people who contribute. Contribute.

License

MIT

NPM DownloadsLast 30 Days