9 releases (3 major breaking)
3.0.0 | Jan 31, 2024 |
---|---|
2.0.1 | Sep 11, 2023 |
2.0.0 | Aug 17, 2023 |
1.0.0 | May 17, 2023 |
0.1.0 | Mar 14, 2022 |
#1051 in WebAssembly
114 downloads per month
Used in 2 crates
(via javy)
3MB
90K
SLoC
quickjs-wasm-rs
High-level bindings and serializers for a Wasm build of QuickJS.
Bindings
JSContextRef
corresponds to a QuickJS JSContext
and JSValueRef
corresponds to a QuickJS JSValue
.
use quickjs_wasm_rs::JSContextRef;
let mut context = JSContextRef::default();
will create a new context.
Serializers
This crate provides optional transcoding features for converting between
serialization formats and JSValueRef
:
messagepack
providesquickjs_wasm_rs::messagepack
for msgpack, usingrmp_serde
.json
providesquickjs_wasm_rs::json
for JSON, usingserde_json
.
msgpack example:
use quickjs_wasm_rs::{messagepack, JSContextRef, JSValueRef};
let context = JSContextRef::default();
let input_bytes: &[u8] = ...;
let input_value = messagepack::transcode_input(&context, input_bytes).unwrap();
let output_value: JSValueRef = ...;
let output = messagepack::transcode_output(output_value).unwrap();
Publishing to crates.io
To publish this crate to crates.io, run ./publish.sh
.
Using a custom WASI SDK
This crate can be compiled using a custom WASI SDK. When building this crate, set the QUICKJS_WASM_SYS_WASI_SDK_PATH
environment variable to the absolute path where you installed the SDK.
Dependencies
~0.6–5MB
~84K SLoC