wasi-js
This is a Javascript library for interacting with WASI Modules in node and in the browser.
Features
wasi-js
uses the same API as the WASI integration in Node.
However, wasi-js
is focused on:
Bringing WASI to an Isomorphic context (Node.js and the Browser)
Make it easy to plug in different filesystems (via wasmfs)
Make code safer using Typescript
Pure JavaScript implementation (no Native bindings needed)
Very small
Easy to plugin support for sleep, blocking read of stdout, and writing to stdout and stderr.
Installation
To install wasi-js
, run this command:
Testing
There is currently no test suite directly in this package. However, that doesn't mean that it doesn't get thorough testing. Indeed, it is tested by the other packages of CoWasm that depend on it, including a large number of tests in the cpython test suite (which helped me find many bugs).
Quick Start
This quick start is for node. It's something like this. See cowasm for a nontrivial application that uses wasi-js both in node and the browser. The usage is something like this:
Set the env variable DEBUG=wasi*
to see a log of all wasi system calls; this uses the debug library.
History
This started long ago as a fork of version 0.12.0 of @wasmer/wasi to keep it alive, since the Wasmer company deleted it entirely (replacing it with a rust rewrite with very different goals), and I would like to use it in CoWasm. I added some functionality to better support blocking IO and other features needed mainly in the browser. I also found and fixed some very subtle bugs while trying to get the cPython test suite to work.
There is no real test suite directly of this package. That said, I have tested it quite a bit indirectly via Python test suites.
As mentioned above, this is based on what the wasmer devs wrote, which itself was based on what Gus Caplan wrote. I have also added hooks for implementing blocking IO.
Here's what the WASMER people wrote:
This is the original MIT license below: