0.2.0 • Published 5 years ago

rete-code-plugin v0.2.0

Weekly downloads
6
License
MIT
Repository
github
Last release
5 years ago

Code

Rete.js plugin

import CodePlugin from 'rete-code-plugin';

class NumComponent extends Rete.Component {
    // ...

    code(node, inputs, add) { // 'node' param is similar to worker's "node"
        // "inputs" contains variables name
        add('console.log("hello!")') // add code line
        add('num', node.data.num); // add variable with value "node.data.num"
    }
}

const sourceCode = await CodePlugin.generate(engine, editor.toJSON());

For example, the scheme with such nodes

Number 6
        \ Add 11 -- Add 16
        /         /
Number 5 ---------

will generate the next sourceCode

console.log("hello!");
const number1num = 5;
console.log("hello!");
const number3num = 6;
const add4num = number3num + number1num;
const add2num = add4num + number1num;
0.2.0

5 years ago

0.1.1

6 years ago

0.1.0

6 years ago