diff --git a/Cargo.lock b/Cargo.lock index f27ca95b5..dd25f6ccd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -540,9 +540,9 @@ dependencies = [ [[package]] name = "convert_case" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "affbf0190ed2caf063e3def54ff444b449371d55c58e513a95ab98eca50adb49" +checksum = "1af709f1f33454bf52eadfc8c78b3b9ef9cb26fb54d16dc9cd9a7299f899fd1b" dependencies = [ "unicode-segmentation", ] @@ -1585,12 +1585,6 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - [[package]] name = "idna" version = "1.1.0" @@ -1755,7 +1749,7 @@ dependencies = [ [[package]] name = "javy" -version = "8.1.1-alpha.1" +version = "9.0.0-alpha.1" dependencies = [ "anyhow", "bitflags", @@ -1838,7 +1832,7 @@ dependencies = [ [[package]] name = "javy-plugin-api" -version = "7.1.1-alpha.1" +version = "8.0.0-alpha.1" dependencies = [ "anyhow", "javy", @@ -2673,9 +2667,9 @@ checksum = "88f8660c1ff60292143c98d08fc6e2f654d722db50410e3f3797d40baaf9d8f3" [[package]] name = "rquickjs" -version = "0.12.2" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e04e4eedfb060b503b5f0a2644abb890b0b3620d3fb674f9455f230014964e4" +checksum = "a0a22bf72f515cc4189dd7c63d016f6de92a11eee98ddf7dd64794198f6eb34e" dependencies = [ "rquickjs-core", "rquickjs-macro", @@ -2683,9 +2677,9 @@ dependencies = [ [[package]] name = "rquickjs-core" -version = "0.12.2" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16e4f499ac5b943d97ee6dbc44f23c2c10426f420f7d2f1793d6318911b6608c" +checksum = "6657979a24d543e5fc66f32cef2f47ca82ce8eb55cec5f7d59a12b7b570bbf24" dependencies = [ "hashbrown 0.17.0", "relative-path", @@ -2694,26 +2688,24 @@ dependencies = [ [[package]] name = "rquickjs-macro" -version = "0.12.2" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cbcc8219b70ee2faa08d5339f47f15741cba2ce0cb9640e8495f2ab51293f50" +checksum = "0a2ea9adb03b669c933482ff740b683cd36be7cef23891657a8ccb850401d286" dependencies = [ - "convert_case 0.11.0", - "fnv", - "ident_case", + "convert_case 0.12.0", "indexmap", "proc-macro-crate", "proc-macro2", "quote", "rquickjs-core", - "syn 2.0.119", + "syn 3.0.6", ] [[package]] name = "rquickjs-serde" -version = "0.6.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cf0aa631f8d0c5051db35f9f59899c34074d7b6be280c03fd4ce6165d0ed35" +checksum = "976f3350570a1d8611442e491a617c5373f9b9d24ae98c735345f7d3eb8f03bd" dependencies = [ "rquickjs", "serde", @@ -2721,9 +2713,9 @@ dependencies = [ [[package]] name = "rquickjs-sys" -version = "0.12.2" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a13ac243b86a74120814ef7e9e30ad5a2c1199b7b9963b1cf7c84e4cdc1cad99" +checksum = "cee271d0eeba64f0915b846cb7ae02e16faf3dfdffdca91731101d9d30fe3423" dependencies = [ "bindgen", "cc", diff --git a/Cargo.toml b/Cargo.toml index 4f8b4ea14..a7f3d4e62 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ wasmtime-wasi = "49.0.2" wasmtime-wizer = "49.0.2" wasm-opt = "0.116.1" anyhow = "1.0" -javy = { path = "crates/javy", version = "8.1.1-alpha.1" } +javy = { path = "crates/javy", version = "9.0.0-alpha.1" } tempfile = "3.27.0" tokio = "1" uuid = { version = "1.23", features = ["v4"] } diff --git a/crates/cli/tests/dylib_test.rs b/crates/cli/tests/dylib_test.rs index 3f9fd5f53..b1d599547 100644 --- a/crates/cli/tests/dylib_test.rs +++ b/crates/cli/tests/dylib_test.rs @@ -24,7 +24,7 @@ fn test_dylib_with_error() -> Result<()> { assert!(res.is_err()); let e = res.err().unwrap(); - let expected_log_output = "Error: foo error\n at foo (function.mjs:1:27)\n at (function.mjs:1:49)\n\n"; + let expected_log_output = "Error: foo error\n at foo (function.mjs:1:28)\n at (function.mjs:1:49)\n\n"; assert_eq!( expected_log_output, e.downcast_ref::().unwrap().stderr diff --git a/crates/cli/tests/integration_test.rs b/crates/cli/tests/integration_test.rs index 4893eb64c..024d6ee1f 100644 --- a/crates/cli/tests/integration_test.rs +++ b/crates/cli/tests/integration_test.rs @@ -11,7 +11,7 @@ fn test_empty(builder: &mut Builder) -> Result<()> { let mut runner = builder.input("empty.js").build()?; let (_, _, fuel_consumed) = run(&mut runner, vec![]); - assert_fuel_consumed_within_threshold(18_909, fuel_consumed); + assert_fuel_consumed_within_threshold(16_943, fuel_consumed); Ok(()) } @@ -31,7 +31,7 @@ fn test_fib(builder: &mut Builder) -> Result<()> { let (output, _, fuel_consumed) = run_with_u8s(&mut runner, 5); assert_eq!(8, output); - assert_fuel_consumed_within_threshold(64_557, fuel_consumed); + assert_fuel_consumed_within_threshold(61_850, fuel_consumed); Ok(()) } @@ -81,7 +81,7 @@ fn test_console_log(builder: &mut Builder) -> Result<()> { let (output, logs, fuel_consumed) = run(&mut runner, vec![]); assert_eq!(b"hello world from console.log\n".to_vec(), output); assert_eq!("hello world from console.error\n", logs.as_str()); - assert_fuel_consumed_within_threshold(30_652, fuel_consumed); + assert_fuel_consumed_within_threshold(29_037, fuel_consumed); Ok(()) } @@ -337,7 +337,7 @@ fn test_exported_default_arrow_fn(builder: &mut Builder) -> Result<()> { let (_, logs, fuel_consumed) = run_fn(&mut runner, "default", vec![]); assert_eq!(logs, "42\n"); - assert_fuel_consumed_within_threshold(33_889, fuel_consumed); + assert_fuel_consumed_within_threshold(31_151, fuel_consumed); Ok(()) } @@ -350,7 +350,7 @@ fn test_exported_default_fn(builder: &mut Builder) -> Result<()> { .build()?; let (_, logs, fuel_consumed) = run_fn(&mut runner, "default", vec![]); assert_eq!(logs, "42\n"); - assert_fuel_consumed_within_threshold(35_195, fuel_consumed); + assert_fuel_consumed_within_threshold(32_857, fuel_consumed); Ok(()) } diff --git a/crates/codegen/tests/snapshots/integration_test__default_dynamic.snap b/crates/codegen/tests/snapshots/integration_test__default_dynamic.snap index a34bb6ff2..94ff8c1f1 100644 --- a/crates/codegen/tests/snapshots/integration_test__default_dynamic.snap +++ b/crates/codegen/tests/snapshots/integration_test__default_dynamic.snap @@ -6,9 +6,9 @@ expression: wat (type (;0;) (func)) (type (;1;) (func (param i32 i32 i32 i32) (result i32))) (type (;2;) (func (param i32 i32 i32 i32 i32))) - (import "javy-default-plugin-v4" "cabi_realloc" (func (;0;) (type 1) (param i32 i32 i32 i32) (result i32))) - (import "javy-default-plugin-v4" "invoke" (func (;1;) (type 2) (param i32 i32 i32 i32 i32))) - (import "javy-default-plugin-v4" "memory" (memory (;0;) 0)) + (import "javy-default-plugin-v5" "cabi_realloc" (func (;0;) (type 1) (param i32 i32 i32 i32) (result i32))) + (import "javy-default-plugin-v5" "invoke" (func (;1;) (type 2) (param i32 i32 i32 i32 i32))) + (import "javy-default-plugin-v5" "memory" (memory (;0;) 0)) (export "_start" (func 4)) (export "log" (func 2)) (export "log2" (func 3)) @@ -88,7 +88,7 @@ expression: wat i32.const 0 call 1 ) - (data (;0;) "\1a\c7\14e}\07\01\18function.mjs\01\06log\01\08log2\01\0econsole\01(Hello from function!\01*Hello from function2!\014Hello from top-level scope\0d\e4\03\00\02\00\00\e6\03\00\01\e8\03\00\00\00\0c \0a\01\a8\01\00\00\00\03\00\02\02\1f\00\e6\03\00\06\e8\03\01\06\0cC\0a\01\e6\03\00\00\00\03\00\00\00\13\008\f5\00\00\00A\f3\00\00\00\04\f6\00\00\00$\01\00)\e4\03\01\07\04\03\034\10\00\0cC\0a\01\e8\03\00\00\00\03\00\00\00\13\008\f5\00\00\00A\f3\00\00\00\04\f7\00\00\00$\01\00)\e4\03\05\08\04\03\054\10\00\08\f0\08\c5\00\e7\c5\01\e8)8\f5\00\00\00A\f3\00\00\00\04\f8\00\00\00$\01\00\0e\06/\e4\03\01\01\06\00\0a\10\004\10\00") + (data (;0;) "\1c\c7\14e}\07\01\18function.mjs\01\06log\01\08log2\01\0econsole\01(Hello from function!\01*Hello from function2!\014Hello from top-level scope\0d\e4\03\00\02\00\00\e6\03\00\01\e8\03\00\00\00\0c \0a\01\a8\01\00\00\00\03\00\02\02\1f\00\e6\03\00\06\e8\03\01\06\0cC\0a\01\e6\03\00\00\00\03\00\00\00\13\008\f5\00\00\00A\f3\00\00\00\04\f6\00\00\00$\01\00)\e4\03\01\07\04\03\034\10\00\0cC\0a\01\e8\03\00\00\00\03\00\00\00\13\008\f5\00\00\00A\f3\00\00\00\04\f7\00\00\00$\01\00)\e4\03\05\08\04\03\054\10\00\08\f0\08\c5\00\e7\c5\01\e8)8\f5\00\00\00A\f3\00\00\00\04\f8\00\00\00$\01\00\0e\06/\e4\03\01\01\06\00\0a\10\004\10\00") (data (;1;) "log") (data (;2;) "log2") (@producers diff --git a/crates/javy/CHANGELOG.md b/crates/javy/CHANGELOG.md index cb31d12c2..a815c8e7d 100644 --- a/crates/javy/CHANGELOG.md +++ b/crates/javy/CHANGELOG.md @@ -8,6 +8,10 @@ Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased +### Changed + +- Bumped rquickjs to 0.14.0. The bytecode format has changed in a breaking way. + ## [8.1.0] - 2026-07-30 ### Added diff --git a/crates/javy/Cargo.toml b/crates/javy/Cargo.toml index 476a52194..24c614bec 100644 --- a/crates/javy/Cargo.toml +++ b/crates/javy/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "javy" -version = "8.1.1-alpha.1" +version = "9.0.0-alpha.1" authors.workspace = true edition.workspace = true license.workspace = true @@ -14,12 +14,12 @@ targets = ["wasip1", "wasip2"] [dependencies] anyhow = { workspace = true } -rquickjs = { version = "0.12.0", features = [ +rquickjs = { version = "0.14.0", features = [ "array-buffer", "bindgen", "disable-assertions", ] } -rquickjs-serde = { version = "0.6.1", optional = true } +rquickjs-serde = { version = "0.8.0", optional = true } serde = { workspace = true, default-features = true, features = ["derive"] } serde_json = { workspace = true, optional = true } serde-transcode = { version = "1.1", optional = true } diff --git a/crates/javy/src/apis/stream_io/mod.rs b/crates/javy/src/apis/stream_io/mod.rs index 3b74b3cf9..272c928a8 100644 --- a/crates/javy/src/apis/stream_io/mod.rs +++ b/crates/javy/src/apis/stream_io/mod.rs @@ -83,9 +83,11 @@ fn write(args: Args<'_>) -> Result> { .as_object() .ok_or_else(|| anyhow!("Data must be an Object"))? .as_array_buffer() - .ok_or_else(|| anyhow!("Data must be an ArrayBuffer"))? - .as_bytes() - .ok_or_else(|| anyhow!("Could not represent data as &[u8]"))?; + .ok_or_else(|| anyhow!("Data must be an ArrayBuffer"))?; + // SAFETY: No JavaScript runs while the slice is alive; it is only read by + // the synchronous stdout/stderr write below. + let data = + unsafe { data.as_bytes() }.ok_or_else(|| anyhow!("Could not represent data as &[u8]"))?; let offset = offset .as_number() diff --git a/crates/javy/src/apis/text_encoding/mod.rs b/crates/javy/src/apis/text_encoding/mod.rs index 1359131db..d4242bdec 100644 --- a/crates/javy/src/apis/text_encoding/mod.rs +++ b/crates/javy/src/apis/text_encoding/mod.rs @@ -47,8 +47,10 @@ fn decode(args: Args<'_>) -> Result> { .as_object() .ok_or_else(|| anyhow!("buffer must be an object"))? .as_array_buffer() - .ok_or_else(|| anyhow!("buffer must be an ArrayBuffer"))? - .as_bytes() + .ok_or_else(|| anyhow!("buffer must be an ArrayBuffer"))?; + // SAFETY: No JavaScript runs while the slice is alive; it is only read + // during UTF-8 decoding below. + let buffer = unsafe { buffer.as_bytes() } .ok_or_else(|| anyhow!("Couldn't retrive &[u8] from buffer"))?; let byte_offset = args[1] diff --git a/crates/plugin-api/CHANGELOG.md b/crates/plugin-api/CHANGELOG.md index 4232186b8..475eaacc0 100644 --- a/crates/plugin-api/CHANGELOG.md +++ b/crates/plugin-api/CHANGELOG.md @@ -8,6 +8,12 @@ Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased +### Changed + +- Updated `javy` to 9.0.0-alpha.1, which bumps rquickjs to 0.14.0. If you are + using a plugin for dynamic linking, you are strongly encouraged to change + the import namespace. + ## [7.1.0] - 2026-06-30 ### Added diff --git a/crates/plugin-api/Cargo.toml b/crates/plugin-api/Cargo.toml index 23cb7f2ba..795c04be6 100644 --- a/crates/plugin-api/Cargo.toml +++ b/crates/plugin-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "javy-plugin-api" -version = "7.1.1-alpha.1" +version = "8.0.0-alpha.1" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/crates/plugin/src/lib.rs b/crates/plugin/src/lib.rs index 58eb51339..871078ca7 100644 --- a/crates/plugin/src/lib.rs +++ b/crates/plugin/src/lib.rs @@ -7,7 +7,7 @@ use crate::shared_config::SharedConfig; mod shared_config; -import_namespace!("javy-default-plugin-v4"); +import_namespace!("javy-default-plugin-v5"); fn config() -> Config { // Read shared config JSON in from stdin. diff --git a/crates/runner/src/lib.rs b/crates/runner/src/lib.rs index 2039f2d3d..03f63185f 100644 --- a/crates/runner/src/lib.rs +++ b/crates/runner/src/lib.rs @@ -34,7 +34,7 @@ impl Plugin { Self::InvalidUser => "invalid-plugin", // Could try and derive this but not going to for now since tests // will break if it changes. - Self::Default | Self::DefaultAsUser => "javy-default-plugin-v4", + Self::Default | Self::DefaultAsUser => "javy-default-plugin-v5", Self::UserWasiP1 { .. } => "test-plugin-wasip1", Self::UserWasiP2 { .. } => "test-plugin-wasip2", } diff --git a/docs/docs-using-dynamic-linking.md b/docs/docs-using-dynamic-linking.md index dff92591f..1e4937bcc 100644 --- a/docs/docs-using-dynamic-linking.md +++ b/docs/docs-using-dynamic-linking.md @@ -41,6 +41,6 @@ Run: $ echo 'console.log("hello world!");' > my_code.js $ javy emit-plugin -o plugin.wasm $ javy build -C dynamic -C plugin=plugin.wasm -o my_code.wasm my_code.js -$ wasmtime run --preload javy-default-plugin-v4=plugin.wasm my_code.wasm +$ wasmtime run --preload javy-default-plugin-v5=plugin.wasm my_code.wasm hello world! ``` diff --git a/docs/docs-using-nodejs.md b/docs/docs-using-nodejs.md index e3275025e..59b8ecb84 100644 --- a/docs/docs-using-nodejs.md +++ b/docs/docs-using-nodejs.md @@ -158,7 +158,7 @@ async function runJavy(pluginModule, embeddedModule, input) { wasi.getImportObject(), ); const instance = await WebAssembly.instantiate(embeddedModule, { - "javy-default-plugin-v4": pluginInstance.exports, + "javy-default-plugin-v5": pluginInstance.exports, }); // Javy plugin is a WASI reactor see https://github.com/WebAssembly/WASI/blob/main/legacy/application-abi.md?plain=1