10 ms·
G'day! It's a bit hard to understand what this is, because there's a lot of other stuff in the space. What I've written here is a WASI runner for the browser. I
by benno128 4y ago
G'day! It's a bit hard to understand what this is, because there's a lot of other stuff in the space. What I've written here is a WASI runner for the browser. I've also hooked up a terminal and virtual FS to it. WASI (WebAssembly System Interface) is a standard aimed at writing portable WebAssembly binaries that can run on servers, embedded devices, or locally on your computer. It's not really aimed at the browser. I went through and implemented the whole standard in TypeScript - then built this interface around that implementation so I could play with it.
One really neat thing here is how easy it is to write Rust that targets WASI. If you're into Rust, I'd recommend looking at the source of the demos and then trying out your own WASI binaries.
Here to answer questions if anyone has any!
- rektide 4y agoScore another point for memfs, the in-memory node.js fe impl (which if Im reading this right underpins your wasi fs impl). https://github.com/streamich/memfs https://github.com/streamich/memfs Edit: apologies... your reply says you have you own impl! Damn, awesome! Apologies, I'd seen memfs in a dependencies here: https://github.com/taybenlor/runno/blob/main/packages/runtime/package.json#L65 https://github.com/taybenlor/runno/blob/main/packages/runtim... WHATWG recently took up File System Access spec as their FS spec. It both looks semi promising, but they seem to only care about & are only building specs for specifically emscripten wasm users. Only sync apis, only usable from dedicated workers... there's some hopes for more latter but feels super weird to see the web finally get fs access & have it be fast... but for it to be extremely odd shaped hand tailored to a very narrow class of use. https://fs.spec.whatwg.org/ https://fs.spec.whatwg.org/
- benno128 4y agomemfs is very cool, but the WASI runner in this demo doesn't use it. I implemented my own virtual filesystem (see: https://github.com/taybenlor/runno/blob/main/packages/wasi-motor/lib/wasi/wasi-drive.ts https://github.com/taybenlor/runno/blob/main/packages/wasi-m...). Will look at the FS spec. I would hope that it would be shaped in a way that makes sense for WASI (brief look seems like it is). I'd also love it to be something that makes sense from the JavaScript side as well.
- benno128 4y agoI've also put up an article with a walkthrough of how to use the playground to run FFmpeg: https://runno.dev/articles/ffmpeg https://runno.dev/articles/ffmpeg
- tomashubelbauer 4y agoDo you think you could make ffmpeg one of the demos like you did with quickjs?
- benno128 4y agoGood idea! It's a bit harder, but totally doable.
- williamstein 4y agoUPDATE: I found it; here's the very nice core of his new WASI implementation -- https://github.com/taybenlor/runno/blob/main/packages/wasi-motor/lib/wasi/wasi.ts https://github.com/taybenlor/runno/blob/main/packages/wasi-m... Original comment below: > " I went through and implemented the whole standard in TypeScript" Isn't this file in your code a big part of the implementing the WASI standard? [1] https://github.com/taybenlor/runno/blob/main/packages/wasi/src/index.ts https://github.com/taybenlor/runno/blob/main/packages/wasi/s... I ask because you didn't write that. I was excited that you said " I went through and implemented the whole standard in TypeScript" since I have been working on that same code [1] as the core of this npm package https://www.npmjs.com/package/wasi-js https://www.npmjs.com/package/wasi-js and I've found some subtle bugs in it. I was excited to find another implementation to compare, so maybe you also did something else? Thanks! This is a very exciting space and I greatly appreciate your work.
- benno128 4y agoGood spotto! That's an old WASI runtime from wasmerjs (https://github.com/wasmerio/wasmer-js https://github.com/wasmerio/wasmer-js). That's not the WASI runtime being used in this playground. The one in this playground is @runno/wasi-motor (https://github.com/taybenlor/runno/tree/main/packages/wasi-motor https://github.com/taybenlor/runno/tree/main/packages/wasi-m...). I haven't released it as an NPM package, but it's all MIT so feel free to copy it.
- Existenceblinks 4y agoThere is the .wit in "component model" proposal that is actively developing. Could you explain how it's going to make different between your work here without the .wit and with the .wit files?
- benno128 4y agoI don't really know much about the component model, sorry!