From 63e6d852e3930f3211eb6ca8bf3a5f298de9b10e Mon Sep 17 00:00:00 2001 From: Jeff Charles Date: Tue, 26 Nov 2024 11:26:16 -0500 Subject: [PATCH] `experimental-event-loop` -> `event-loop` --- crates/cli/tests/integration_test.rs | 9 +++------ crates/plugin-api/src/config.rs | 10 +++++----- crates/plugin-api/src/lib.rs | 6 +++--- crates/plugin/src/shared_config/mod.rs | 8 ++++---- crates/runner/src/lib.rs | 27 ++++++++++++-------------- wpt/package.json | 2 +- 6 files changed, 28 insertions(+), 34 deletions(-) diff --git a/crates/cli/tests/integration_test.rs b/crates/cli/tests/integration_test.rs index 3cc7ed40..f8667181 100644 --- a/crates/cli/tests/integration_test.rs +++ b/crates/cli/tests/integration_test.rs @@ -183,10 +183,7 @@ fn test_readme_script(builder: &mut Builder) -> Result<()> { #[javy_cli_test(commands(not(Compile)))] fn test_promises_with_event_loop(builder: &mut Builder) -> Result<()> { - let mut runner = builder - .input("promise.js") - .experimental_event_loop(true) - .build()?; + let mut runner = builder.input("promise.js").event_loop(true).build()?; let (output, _, _) = run(&mut runner, &[]); assert_eq!("\"foo\"\"bar\"".as_bytes(), output); @@ -209,7 +206,7 @@ fn test_promises_without_event_loop(builder: &mut Builder) -> Result<()> { fn test_promise_top_level_await(builder: &mut Builder) -> Result<()> { let mut runner = builder .input("top-level-await.js") - .experimental_event_loop(true) + .event_loop(true) .build()?; let (out, _, _) = run(&mut runner, &[]); @@ -238,7 +235,7 @@ fn test_exported_promises(builder: &mut Builder) -> Result<()> { .input("exported-promise-fn.js") .wit("exported-promise-fn.wit") .world("exported-promise-fn") - .experimental_event_loop(true) + .event_loop(true) .build()?; let (_, logs, _) = run_fn(&mut runner, "foo", &[]); assert_eq!("Top-level\ninside foo\n", logs); diff --git a/crates/plugin-api/src/config.rs b/crates/plugin-api/src/config.rs index 36b1831c..b06e1e68 100644 --- a/crates/plugin-api/src/config.rs +++ b/crates/plugin-api/src/config.rs @@ -5,14 +5,14 @@ use std::ops::{Deref, DerefMut}; pub struct Config { /// The runtime config. pub(crate) runtime_config: javy::Config, - /// Whether to enable the experimental event loop. - pub(crate) experimental_event_loop: bool, + /// Whether to enable the event loop. + pub(crate) event_loop: bool, } impl Config { - /// Whether to enable the experimental event loop. - pub fn experimental_event_loop(&mut self, enabled: bool) -> &mut Self { - self.experimental_event_loop = enabled; + /// Whether to enable the event loop. + pub fn event_loop(&mut self, enabled: bool) -> &mut Self { + self.event_loop = enabled; self } } diff --git a/crates/plugin-api/src/lib.rs b/crates/plugin-api/src/lib.rs index f473a377..b9f72264 100644 --- a/crates/plugin-api/src/lib.rs +++ b/crates/plugin-api/src/lib.rs @@ -55,7 +55,7 @@ static mut EVENT_LOOP_ENABLED: bool = false; static EVENT_LOOP_ERR: &str = r#" Pending jobs in the event queue. Scheduling events is not supported when the - experimental_event_loop cargo feature is disabled. + event-loop runtime config is not enabled. "#; /// Initializes the Javy runtime. @@ -74,7 +74,7 @@ where // implement `Debug`. .map_err(|_| anyhow!("Could not pre-initialize javy::Runtime")) .unwrap(); - EVENT_LOOP_ENABLED = config.experimental_event_loop; + EVENT_LOOP_ENABLED = config.event_loop; }; Ok(()) } @@ -185,7 +185,7 @@ fn handle_maybe_promise(this: Ctx, value: Value) -> quickjs::Result<()> { match value.as_promise() { Some(promise) => { if unsafe { EVENT_LOOP_ENABLED } { - // If the experimental event loop is enabled, trigger it. + // If the event loop is enabled, trigger it. let resolved = promise.finish::(); // `Promise::finish` returns Err(Wouldblock) when the all // pending jobs have been handled. diff --git a/crates/plugin/src/shared_config/mod.rs b/crates/plugin/src/shared_config/mod.rs index c9e6c53b..3c06d76a 100644 --- a/crates/plugin/src/shared_config/mod.rs +++ b/crates/plugin/src/shared_config/mod.rs @@ -26,8 +26,8 @@ runtime_config! { /// Whether to enable support for the `TextEncoder` and `TextDecoder` /// APIs. text_encoding: Option, - /// Whether to enable the experimental event loop. - experimental_event_loop: Option, + /// Whether to enable the event loop. + event_loop: Option, } } @@ -52,8 +52,8 @@ impl SharedConfig { if let Some(enable) = self.text_encoding { config.text_encoding(enable); } - if let Some(enable) = self.experimental_event_loop { - config.experimental_event_loop(enable); + if let Some(enable) = self.event_loop { + config.event_loop(enable); } } } diff --git a/crates/runner/src/lib.rs b/crates/runner/src/lib.rs index 0f344ba4..3175a165 100644 --- a/crates/runner/src/lib.rs +++ b/crates/runner/src/lib.rs @@ -83,8 +83,8 @@ pub struct Builder { simd_json_builtins: Option, /// Whether to enable the `TextEncoder` and `TextDecoder` APIs. text_encoding: Option, - /// Whether to enable the experimental event loop. - experimental_event_loop: Option, + /// Whether to enable the event loop. + event_loop: Option, built: bool, /// Preload the module at path, using the given instance name. preload: Option<(String, PathBuf)>, @@ -111,7 +111,7 @@ impl Default for Builder { javy_json: None, simd_json_builtins: None, text_encoding: None, - experimental_event_loop: None, + event_loop: None, plugin: Plugin::Default, } } @@ -173,8 +173,8 @@ impl Builder { self } - pub fn experimental_event_loop(&mut self, enabled: bool) -> &mut Self { - self.experimental_event_loop = Some(enabled); + pub fn event_loop(&mut self, enabled: bool) -> &mut Self { + self.event_loop = Some(enabled); self } @@ -210,7 +210,7 @@ impl Builder { javy_stream_io, simd_json_builtins, text_encoding, - experimental_event_loop, + event_loop, built: _, preload, command, @@ -238,7 +238,7 @@ impl Builder { javy_stream_io, simd_json_builtins, text_encoding, - experimental_event_loop, + event_loop, preload, plugin, ), @@ -315,7 +315,7 @@ impl Runner { javy_stream_io: Option, override_json_parse_and_stringify: Option, text_encoding: Option, - experimental_event_loop: Option, + event_loop: Option, preload: Option<(String, PathBuf)>, plugin: Plugin, ) -> Result { @@ -337,7 +337,7 @@ impl Runner { &javy_stream_io, &override_json_parse_and_stringify, &text_encoding, - &experimental_event_loop, + &event_loop, &plugin, ); @@ -566,7 +566,7 @@ impl Runner { javy_stream_io: &Option, simd_json_builtins: &Option, text_encoding: &Option, - experimental_event_loop: &Option, + event_loop: &Option, plugin: &Plugin, ) -> Vec { let mut args = vec![ @@ -622,12 +622,9 @@ impl Runner { args.push(format!("text-encoding={}", if enabled { "y" } else { "n" })); } - if let Some(enabled) = *experimental_event_loop { + if let Some(enabled) = *event_loop { args.push("-J".to_string()); - args.push(format!( - "experimental-event-loop={}", - if enabled { "y" } else { "n" } - )); + args.push(format!("event-loop={}", if enabled { "y" } else { "n" })); } if matches!(plugin, Plugin::User | Plugin::DefaultAsUser) { diff --git a/wpt/package.json b/wpt/package.json index f1848609..c260e36f 100644 --- a/wpt/package.json +++ b/wpt/package.json @@ -5,7 +5,7 @@ "type": "module", "scripts": { "bundle": "rollup -c rollup.config.js runner.js", - "javy": "../target/release/javy build -J experimental-event-loop -o bundle.wasm bundle.js", + "javy": "../target/release/javy build -J event-loop -o bundle.wasm bundle.js", "wasmtime": "wasmtime bundle.wasm", "test": "npm run bundle && npm run javy && npm run wasmtime" },