awto/effectfuljs

User space debugger

awto opened this issue · 3 comments

awto commented

Since effectful.js can capture a delimited execution context along with its variables, this unlocks a lot of possibilities for diagnostics.

For example, we can trace the variable's data with ES Proxies and store current continuation along the trace. This continuation can be restored after and thus we get time traveling. Hot reloading also can restore closure captured variables. Remote requests memoized and during replay older value is returned. And so on.

As I see possible API

it should be something like deep iteration over source code tree with calling some callback on each step.
This callback should receive all the possible meta info, like line number, character position, call/closure stack with all the available variable to watch and possibly to modify
If the callback returns false - then stop the execution, if true - do next step.
It's the lowest level. Like eachDeep

Some higher order component will handle all the debugging meta with (conditional)breakpoints, implement debugger commands like a step into/step over/run/pause/stop.
Like filterDeep which is implemented over eachDeep.

So it will be really exposed debugger API.

Each async portion of some execution will be like a separate tree walking,
in case of parallel debugging sessions spawned by some async reason, we need some session id to keep some session-related stuff, so it will be able to for example remember starting point of 'step over' and correctly pause the execution on exit from deeper execution branch.

And UI should render all this

awto commented

Packed an initial version of the transpiler into @effectful/debugger, there is no yet runtime, but it will be tiny as well.

Here is sample output in jest snapshot which should give some clues about how it is supposed to work. It was generated from code.js random file.

Both transpiler and runtime a simple and small so it is easy to implement any API using them.

awto commented

This is in the VSCode marketplace now:

effectful.debugger