3 ms·
>Would you be up for explaining a bit? The way this system runs is it installs a simple filesystem using IndexedDB (with a serviceworker so that files can have
by Lerc 2mo ago
>Would you be up for explaining a bit?
The way this system runs is it installs a simple filesystem using IndexedDB (with a serviceworker so that files can have urls if necessary) then the JavaScript executable are run by launching a worker. The worker asks the host page for an API and gets sent a list of function calls it can use. It uses a MessagePort to the host to perform actions, so it is a little analogous to a process doing syscalls. All of the calls are passed though to the host (with theoretical auditng by the host (in practice nothing is prevented at the moment)). So when you do a chain of piped commands from the command line, it is actually launching a worker for each and passing the output along to the next (nothing fancy, could be a lot faster). The stdin and stdout that the commands use actually have multiple channels, with html, json, and raw output possible. Commands can provide different output to each channel or just one. The contents are auto downgraded to whatever the reader can handle. So a program can actually output an <img> tag but if it is piped to something that can't handle html input it will receive it as text of the html source. The sender has the option of providing text as well so it could just send the altText on the text channel if it wanted to not be displayed as html source.
>Would it be another way to run programs in addition to the JS utils?
That's what I was thinking. While it's reasonable to re-implement a lot of basic commands, once you get to large pre-existing software, having a way to run them from the same environment is what's needed.
The main integration point start wold be that my environment would need to have a way to point at some data filename/url and identify that it is a thing that can be run by Kandelo. Then it would pass it to Kandelo, If it had hooks for allowing the host environment to manage operations for some file descriptors then my environment would be able to assemble something that looked like stdin and stdout to the running process.
There's obviously a lot more going on for things that do graphics. Something that hid KMS stuff inside an iframe doesn't seem like it would be impossible though.
- brandonpayton 1mo agoSorry for the slow response. I was resting after some travel. > The stdin and stdout that the commands use actually have multiple channels, with html, json, and raw output possible. Commands can provide different output to each channel or just one. This is pretty interesting! > The contents are auto downgraded to whatever the reader can handle. So a program can actually output an <img> tag but if it is piped to something that can't handle html input it will receive it as text of the html source. Like a stream of typed entities? This is a neat idea and one I'll need to digest. What kinds of ways do you use it? > If it had hooks for allowing the host environment to manage operations for some file descriptors then my environment would be able to assemble something that looked like stdin and stdout to the running process. I think there should be a protocol for custom mount types and made a Kandelo issue for it [1]. > There's obviously a lot more going on for things that do graphics. Something that hid KMS stuff inside an iframe doesn't seem like it would be impossible though. We have Linux-style framebuffer support and exploratory devices for direct rendering. IIRC, all target a <canvas> context from a worker, so it seems like there should be a path to rendering to one embedded in an iframe. [1] https://github.com/Automattic/kandelo/issues/1315 https://github.com/Automattic/kandelo/issues/1315