tractordev / wanix

Experimental, local-first, web-native, Unix-like development environment
https://wanix.sh
MIT License
206 stars 11 forks source link

Stream support to and fro webassembly and javascript (with pipes and special file handles) #77

Closed r-o-b-b-y closed 5 months ago

r-o-b-b-y commented 5 months ago

Would like to be able to stream within wanix to and fro native browser streaming apis, to accomplish things like media encoding or encryption (go std lib for encryption is awesome, browser encryption apis are currently very sad) Could this come in the shape of a pipe from a special file handle? Imagine cat /sys/dev/instream | go run encode.go > /sys/dev/outstream

progrium commented 5 months ago

Yea this is interesting. First, this covers piping in the shell, which would be an issue on its own to track and relatively straightforward. Second is using files as streams, which is possible and I want to explore, but is also its own issue. I think having a more straightforward first use case for that would help, like working with tty or just named pipes or something.

Connecting with browser APIs is very interesting but to explore that we'd need to have more specific use cases and examples. So the more you can say about that and envision specific code on the JS side the better.

r-o-b-b-y commented 5 months ago

More specific use cases:

This one is a bit out on a limb, but imagine leveraging streaming encryption ciphers inside go wanix along with Browser FileReader Api. The UI for encrypting files on the browser side could be as simple as a drag and drop from the host computer. All the encryption'ing would happen inside go inside wanix. Since we are processing large files you could simultaneously download the encrypted result as your file is being uploaded. Here is a semi tangential stack overflow doing something similar

Or how about Web Audio API? Imagine signal processing audio with a simple a /sys/dev/audio - Simple demos which come to mind are pitch changes, EQ, delay, reverb

JS could more or less accomplish these two use cases on its own, but using wanix as a common familiar posix-like runtime along with type safe multi-platform capable compiled languages; go now (rust c++ etc later?) I think the concept could be very powerful versus javascript's wonky web apis. Streaming could very powerful in that it would allow media streaming interaction, as well as interacting with very very large files.

Maybe pipes wouldn't be the answer, but I see them as again, a common posix primitive that developers are used to interacting with. Also existing libraries, programs, and run-times all deal with stdout and stdin quite well. This is the immediate use case I see that is so great about wanix. To me, web-assembly is otherwise mysterious and difficult to work with, we have entirely new apis and primitives, but does it have to be that way? Maybe wanix could help bridge that gap?

progrium commented 5 months ago

I like the way you think. I'm going to move this to discussions for now to let these ideas develop until we or someone decides to run with them.