diff --git a/CHANGELOG.md b/CHANGELOG.md index c8687af840c..97a7ae39192 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.13.0 + +* support quickjs-ng (v 0.3.0) as feature, it compiles, some test cases fail (bigint) but should be a nice first step + # 0.12.1 * bugfix: console.log("a:%s", undefined); would fail diff --git a/Cargo.toml b/Cargo.toml index 8778acfd464..e6663609036 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "quickjs_runtime" -version = "0.12.1" +version = "0.13.0" authors = ["Andries Hiemstra "] edition = "2021" description = "Wrapper API and utils for the QuickJS JavaScript engine with support for Promise, Modules, Async/await" @@ -30,9 +30,9 @@ hirofa_utils = "0.7" #hirofa_utils = {git="https://github.com/HiRoFa/utils"} backtrace = "0.3.67" -libquickjs-sys = {package="hirofa-quickjs-sys", git='https://github.com/HiRoFa/quickjs-sys'} +#libquickjs-sys = {package="hirofa-quickjs-sys", git='https://github.com/HiRoFa/quickjs-sys'} #libquickjs-sys = {package="hirofa-quickjs-sys", path='../quickjs-sys'} -#libquickjs-sys = {package="hirofa-quickjs-sys", version="0.2.0", features=["bellard"]} +libquickjs-sys = {package="hirofa-quickjs-sys", version="0.3.0", default-features=false} lazy_static = "1.4.0" log = "0.4" num_cpus = "1" @@ -43,6 +43,7 @@ tokio = {version = "1", features = ["rt-multi-thread", "rt", "bytes", "fs", "io- serde_json = "1.0" serde = {version="1.0", features=["derive"]} string_cache = "0.8" +flume = {version="0.10", features=["async"]} #swc # like the good people at denoland said diff --git a/src/typescript/mod.rs b/src/typescript/mod.rs index 1d15af2d246..d16f096a140 100644 --- a/src/typescript/mod.rs +++ b/src/typescript/mod.rs @@ -382,7 +382,6 @@ pub fn fix_stack_trace(stack_trace: &str, maps: &HashMap) -> Str #[cfg(test)] pub mod tests { - use crate::builder::QuickJsRuntimeBuilder; use crate::facades::tests::init_test_rt; use crate::jsutils::{JsValueType, Script}; use crate::typescript::{parse_stack_trace, serialize_stack}; @@ -457,7 +456,7 @@ pub mod tests { assert_eq!( serialize_stack(&a).as_str(), - r#" at func (file.ts:88) + r#" at func (file.ts:88:12) at doWriteTransactioned (gcsproject:///gcs_objectstore/ObjectStore.ts:170) "# ); diff --git a/src/values.rs b/src/values.rs index 4ac47f11e80..3c696e54aac 100644 --- a/src/values.rs +++ b/src/values.rs @@ -6,7 +6,6 @@ use crate::reflection::JsProxyInstanceId; use futures::executor::block_on; use futures::Future; use hirofa_utils::debug_mutex::DebugMutex; -use hirofa_utils::resolvable_future::ResolvableFuture; use serde::Serialize; use serde_json::Value; use std::collections::HashMap; @@ -210,11 +209,10 @@ impl CachedJsPromiseRef { pub async fn get_promise_result( &self, ) -> Result, JsError> { - let fut: ResolvableFuture, JsError>> = - ResolvableFuture::new(); - let resolver = fut.get_resolver(); - let resolver1 = resolver.clone(); - let resolver2 = resolver.clone(); + let (tx, rx) = flume::bounded(1); + + let tx1 = tx.clone(); + let tx2 = tx.clone(); self.cached_object.with_obj_void(move |realm, obj| { let res = || { @@ -224,8 +222,8 @@ impl CachedJsPromiseRef { // let resolution = &args[0]; let send_res = match realm.to_js_value_facade(resolution) { - Ok(vf) => resolver1.resolve(Ok(Ok(vf))), - Err(conv_err) => resolver1.resolve(Err(conv_err)), + Ok(vf) => tx1.send(Ok(Ok(vf))), + Err(conv_err) => tx1.send(Err(conv_err)), }; send_res .map_err(|e| JsError::new_string(format!("could not send: {e}")))?; @@ -239,8 +237,8 @@ impl CachedJsPromiseRef { // let rejection = &args[0]; let send_res = match realm.to_js_value_facade(rejection) { - Ok(vf) => resolver2.resolve(Ok(Err(vf))), - Err(conv_err) => resolver2.resolve(Err(conv_err)), + Ok(vf) => tx2.send(Ok(Err(vf))), + Err(conv_err) => tx2.send(Err(conv_err)), }; send_res .map_err(|e| JsError::new_string(format!("could not send: {e}")))?; @@ -254,16 +252,21 @@ impl CachedJsPromiseRef { }; match res() { Ok(_) => {} - Err(e) => match resolver.resolve(Err(e)) { - Ok(_) => {} - Err(e) => { - log::error!("failed to resolve 47643: {}", e); + Err(e) => { + log::error!("failed to add promise reactions {}", e); + match tx.send(Err(e)) { + Ok(_) => {} + Err(e) => { + log::error!("failed to resolve 47643: {}", e); + } } - }, + } } }); - fut.await + rx.recv_async() + .await + .map_err(|e| JsError::new_string(format!("{e}")))? } }