#wasi #webview #system-interface #system-api #rust

wvwasi

A WebView with WASI may be the best JS/WASM runtime, and wvwasi is it

4 releases

0.2.0 Mar 17, 2024
0.1.2 Jul 10, 2023
0.1.1 Jul 4, 2023
0.1.0 Jul 4, 2023

#403 in WebAssembly

Download history 11/week @ 2024-09-19 9/week @ 2024-09-26 2/week @ 2024-10-03

111 downloads per month

MIT license

94KB
2K SLoC

wvwasi

A WebView with WebAssembly System Interface (WASI) may be the best Javascript/WebAssembly runtime, and wvwasi is it.

                              |
Javascript/WebAssembly code   |  Javascript/WebAssembly application code
                              |                 |
                              |                 v
                              | WASI syscalls (inserted by compiler toolchain)
                              |                 |
------------------------------+                 |
                              |                 v
Javascript/WebAssembly runtime|    wvwasi (implementation WASI in webview)
(WebView)                     |                 |
                              |                 v
                              |        platform-specific calls
                              |

(Hence wvwasi isn't for making programs execute on WASI runtimes. That would either be a wasm32-wasi target complied by rust, or done through POSIX emulation by the Emscripten or wasi-sdk toolchains.)

WARNING: This is a alpha. Work in progress.

Example Usage

Currently only the Windows platform is implemented, other platforms are on the way.

cargo run --example hello_world --target x86_64-pc-windows-msvc

How does it achieve high performance?

No magic, just IPC and sharedbuffer.

Why not implement WASI using Web APIs?

  1. Webkit oppose File System Access API.
  2. Unable to preopen system folder.
  3. You can not customize your own interface with high-performance communication mechanisms.
  4. You can use native system capabilities, such as sockets at the transport layer, without being limited to websockets at the application layer.

API

The WASI API is versioned. This documentation is based on the WASI preview 1 snapshot. wvwasi implements the WASI system call API with the following additions/modifications:

System Calls

This section has been adapted from the official WASI API documentation.

Dependencies

~201MB
~3M SLoC