Okay, my advice would be to handle all of the stream stuff before GlkOte gets involved, as GlkOte as it is now doesn’t know about streams, not really. So you’d open up a js stream, send text to it, and close it with glk_stream_close, which can then just append the code to the GlkOte update data.
Things to do:
- Add a new stream type around line 2760 of glkapi.js
- Make a new glk_stream_open_javascript function based on one of the existing stream functions, glk_stream_open_memory is probably simplest
- Edit the gli_put_* functions to handle accepting text on the js stream
- Edit glk_stream_close to handle closing the javascript stream
Doing this is quite involved sorry, but I think it’s the best way to do JS handling. Up to you if you think it’s worth it. Vorple does it a somewhat simpler way, through hacking the file system.
I want to do this myself one day, but I’m not there yet.