#quick-js #wasm-build #bindings #serialization #high-level #api-bindings #javy

deprecated quickjs-wasm-rs

High-level bindings and serializers for a Wasm build of QuickJS

10 releases (5 stable)

3.1.0 May 7, 2024
3.0.0 Jan 31, 2024
2.0.1 Sep 11, 2023
1.0.0 May 17, 2023
0.1.0 Mar 14, 2022

#4 in #quick-js

Download history 246/week @ 2024-02-26 25/week @ 2024-03-04 20/week @ 2024-03-11 9/week @ 2024-03-18 9/week @ 2024-03-25 73/week @ 2024-04-01 14/week @ 2024-04-08 17/week @ 2024-04-15 18/week @ 2024-04-22 16/week @ 2024-04-29 135/week @ 2024-05-06 16/week @ 2024-05-13 52/week @ 2024-05-20 134/week @ 2024-05-27 105/week @ 2024-06-03 27/week @ 2024-06-10

321 downloads per month
Used in javy

Apache-2.0 WITH LLVM-exception

3MB
90K SLoC

C 79K SLoC // 0.0% comments JavaScript 7.5K SLoC // 0.0% comments Rust 3.5K SLoC // 0.0% comments Bitbake 499 SLoC // 0.1% comments Shell 111 SLoC // 0.1% comments

This crate is deprecated.

crates.io

The motivation for this change is explained in detail in https://github.com/bytecodealliance/javy/pull/618

We recommend using rquickjs as the high-level bindings for QuickJS.

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 provides quickjs_wasm_rs::messagepack for msgpack, using rmp_serde.
  • json provides quickjs_wasm_rs::json for JSON, using serde_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