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
111 downloads per month
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?
- Webkit oppose File System Access API.
- Unable to preopen system folder.
- You can not customize your own interface with high-performance communication mechanisms.
- 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.
wvwasi.wasiSnapshotPreview1.fd_advise()
wvwasi.wasiSnapshotPreview1.fd_allocate()
wvwasi.wasiSnapshotPreview1.fd_close()
wvwasi.wasiSnapshotPreview1.fd_datasync()
wvwasi.wasiSnapshotPreview1.fd_fdstat_get()
wvwasi.wasiSnapshotPreview1.fd_fdstat_set_flags()
wvwasi.wasiSnapshotPreview1.fd_fdstat_set_rights()
wvwasi.wasiSnapshotPreview1.fd_filestat_get()
wvwasi.wasiSnapshotPreview1.fd_filestat_set_size()
wvwasi.wasiSnapshotPreview1.fd_filestat_set_times()
wvwasi.wasiSnapshotPreview1.fd_pread()
wvwasi.wasiSnapshotPreview1.fd_prestat_get()
wvwasi.wasiSnapshotPreview1.fd_prestat_dir_name()
wvwasi.wasiSnapshotPreview1.fd_pwrite()
wvwasi.wasiSnapshotPreview1.fd_read()
wvwasi.wasiSnapshotPreview1.fd_readdir()
wvwasi.wasiSnapshotPreview1.fd_renumber()
wvwasi.wasiSnapshotPreview1.fd_seek()
wvwasi.wasiSnapshotPreview1.fd_sync()
wvwasi.wasiSnapshotPreview1.fd_tell()
wvwasi.wasiSnapshotPreview1.fd_write()
wvwasi.wasiSnapshotPreview1.path_create_directory()
wvwasi.wasiSnapshotPreview1.path_filestat_get()
wvwasi.wasiSnapshotPreview1.path_filestat_set_times()
wvwasi.wasiSnapshotPreview1.path_link()
wvwasi.wasiSnapshotPreview1.path_open()
wvwasi.wasiSnapshotPreview1.path_readlink()
wvwasi.wasiSnapshotPreview1.path_remove_directory()
wvwasi.wasiSnapshotPreview1.path_rename()
wvwasi.wasiSnapshotPreview1.path_symlink()
wvwasi.wasiSnapshotPreview1.path_unlink_file()
wvwasi.wasiSnapshotPreview1.poll_oneoff()
wvwasi.wasiSnapshotPreview1.proc_exit()
wvwasi.wasiSnapshotPreview1.proc_raise()
wvwasi.wasiSnapshotPreview1.sched_yield()
wvwasi.wasiSnapshotPreview1.random_get()
wvwasi.wasiSnapshotPreview1.sock_accept()
wvwasi.wasiSnapshotPreview1.sock_recv()
wvwasi.wasiSnapshotPreview1.sock_send()
wvwasi.wasiSnapshotPreview1.sock_shutdown()
Dependencies
~201MB
~3M SLoC