The Node class is the primary building block of a Rete.js graph. You can define a node by providing a label and then adding Input, Output, and Control instances to it.
Key methods:
addInput(key, input): Adds an input port.addOutput(key, output): Adds an output port.addControl(key, control): Adds a control (like a text or number input) to the node.removeInput(key), removeOutput(key), removeControl(key): Removes the specified element.hasInput(key), hasOutput(key), hasControl(key): Checks for existence.
import { Node, Input, Output, Socket, Control, InputControl } from 'rete';
const socket = new Socket('socket');
const node = new Node('Math Node');
// Add an input
node.addInput('a', new Input(socket, 'Number A'));
// Add an output
node.addOutput('res', new Output(socket, 'Result'));
// Add a control (e.g., a text input)
node.addControl('name', new InputControl('text', {
initial: 'Default Name',
change: (val) => console.log('Changed to:', val)
}));