#configurable #run-time #quickjs #javascript #anyhow #bytecode

javy

Configurable JavaScript runtime for WebAssembly

9 stable releases (3 major)

new 4.0.0 Jan 8, 2025
3.1.0 Nov 27, 2024
3.0.1 Sep 18, 2024
3.0.0 Jun 28, 2024
1.0.0 May 17, 2023

#1250 in WebAssembly

Download history 49/week @ 2024-09-20 14/week @ 2024-09-27 7/week @ 2024-10-04 1/week @ 2024-10-11 126/week @ 2024-11-08 81/week @ 2024-11-15 278/week @ 2024-11-22 67/week @ 2024-11-29 48/week @ 2024-12-06 11/week @ 2024-12-13 1/week @ 2024-12-20 1/week @ 2024-12-27 51/week @ 2025-01-03

86 downloads per month
Used in javy-plugin-api

Apache-2.0 WITH LLVM-exception

115KB
2.5K SLoC

Javy

A configurable JavaScript runtime for WebAssembly

Documentation Status crates.io status

Uses QuickJS through the rquickjs crate to evalulate JavaScript source code or QuickJS bytecode.

Refer to the crate level documentation to learn more.

Example usage:

use anyhow::anyhow;
use javy::{Runtime, from_js_error};
let runtime = Runtime::default();
let context = runtime.context();

context.with(|cx| {
    let globals = this.globals();
    globals.set(
        "print_hello",
        Function::new(
            this.clone(),
            MutFn::new(move |_, _| {
                println!("Hello, world!");
            }),
        )?,
    )?;
 });

context.with(|cx| {
    cx.eval_with_options(Default::default(), "print_hello();")
         .map_err(|e| from_js_error(cx.clone(), e))
         .map(|_| ())
});

Publishing to crates.io

To publish this crate to crates.io, run ./publish.sh. You will likely need to run git submodule deinit test262 so the working tree is small enough for the publishing to succeed.

Dependencies

~8–12MB
~286K SLoC