retejs / rete

JavaScript framework for visual programming
https://retejs.org
MIT License
9.86k stars 647 forks source link

Feature: export to code #104

Closed CheweyZ closed 5 years ago

CheweyZ commented 6 years ago

I'm not sure what this would mean at your end depending on how you have it setup but would it be possible to have a feature that exports your current setup of blocks into JS given the logic that it runs is already in the blocks?

Note if not intending to add would you have any standout features of what I should do to implement it my self? as currently having issues figuring out the call stack of passing info between nodes in terms of code almost calling functions

Ni55aN commented 6 years ago

You can try to write lines of code inside the workers into a common string/file. I can not exactly guarantee the success of this method, since I have not yet tested

Ni55aN commented 6 years ago

Everything works well for simple example: https://jsfiddle.net/Ni55aN/hp4gcqum/

Ni55aN commented 6 years ago

This functionality can be implemented in the form of a plugin in v1.0.0 https://github.com/retejs/rete/issues/80

Clasen00 commented 5 years ago

@Ni55aN can you please explain a little how can I use source code of my node in 1.0.8 alpha version of Rete? Because in 1.0.2 I could use something like this worker(node, inputs, outputs, sourceCode) {} so sourceCode var was the exactly source code. But in the current version this variable returning 'undefined' value. What can I do with this? Where I can find source code of specific node to append some js to it?

Clasen00 commented 5 years ago

@Ni55aN to be more clear there is an example of what I want to do: https://codepen.io/hatead/pen/mjPmxV?editors=0010

Ni55aN commented 5 years ago

The major difference between alpha.2 and alpha.8 is inputs/outputs indexes #146

https://rete.readthedocs.io/en/latest/Components/

Clasen00 commented 5 years ago

@Ni55aN so there is no any examples about how i can append some js to the specific node?

Ni55aN commented 5 years ago

@Clasen00 do you mean a visual elements or logic ?

Clasen00 commented 5 years ago

@Ni55aN i mean how to add some custom elements to the specific node :) Like in that example https://codepen.io/hatead/pen/mjPmxV?editors=0010 there is "+" and "-" buttons, i need this in my project)

Ni55aN commented 5 years ago

@Clasen00 ok, let's start again from beginning

But in the current version this variable returning 'undefined' value.

Did you pass the sourceCode variable to engine.process() ?

there is "+" and "-" buttons, i need this in my project)

You need a ButtonControl from the example, but this component rendered with a rete-alight-render-plugin. Currently rete-vue-render-plugin is more preferable. In any case, you can use alight-render together with vue-render - just add this.render = 'alight'; to constructor of exist ButtonControl and node.addControl(new ButtonControl(this.editor, 'btn', "+" )) inside builder()

Clasen00 commented 5 years ago

@Ni55aN thank you! I will try!

Ni55aN commented 5 years ago

A codegenaration is a quite complex, so I need any help of those who have experience with it.

Currently code-plugin can only create a very simple code constructiona