Skip to content

Commit 60896f8

Browse files
prep 0.13
1 parent 2d83b88 commit 60896f8

File tree

4 files changed

+28
-21
lines changed

4 files changed

+28
-21
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.13.0
2+
3+
* support quickjs-ng (v 0.3.0) as feature, it compiles, some test cases fail (bigint) but should be a nice first step
4+
15
# 0.12.1
26

37
* bugfix: console.log("a:%s", undefined); would fail

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "quickjs_runtime"
3-
version = "0.12.1"
3+
version = "0.13.0"
44
authors = ["Andries Hiemstra <[email protected]>"]
55
edition = "2021"
66
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"
3030
#hirofa_utils = {git="https://github.com/HiRoFa/utils"}
3131
backtrace = "0.3.67"
3232

33-
libquickjs-sys = {package="hirofa-quickjs-sys", git='https://github.com/HiRoFa/quickjs-sys'}
33+
#libquickjs-sys = {package="hirofa-quickjs-sys", git='https://github.com/HiRoFa/quickjs-sys'}
3434
#libquickjs-sys = {package="hirofa-quickjs-sys", path='../quickjs-sys'}
35-
#libquickjs-sys = {package="hirofa-quickjs-sys", version="0.2.0", features=["bellard"]}
35+
libquickjs-sys = {package="hirofa-quickjs-sys", version="0.3.0", default-features=false}
3636
lazy_static = "1.4.0"
3737
log = "0.4"
3838
num_cpus = "1"
@@ -43,6 +43,7 @@ tokio = {version = "1", features = ["rt-multi-thread", "rt", "bytes", "fs", "io-
4343
serde_json = "1.0"
4444
serde = {version="1.0", features=["derive"]}
4545
string_cache = "0.8"
46+
flume = {version="0.10", features=["async"]}
4647

4748
#swc
4849
# like the good people at denoland said

src/typescript/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ pub fn fix_stack_trace(stack_trace: &str, maps: &HashMap<String, String>) -> Str
382382

383383
#[cfg(test)]
384384
pub mod tests {
385-
use crate::builder::QuickJsRuntimeBuilder;
386385
use crate::facades::tests::init_test_rt;
387386
use crate::jsutils::{JsValueType, Script};
388387
use crate::typescript::{parse_stack_trace, serialize_stack};
@@ -457,7 +456,7 @@ pub mod tests {
457456

458457
assert_eq!(
459458
serialize_stack(&a).as_str(),
460-
r#" at func (file.ts:88)
459+
r#" at func (file.ts:88:12)
461460
at doWriteTransactioned (gcsproject:///gcs_objectstore/ObjectStore.ts:170)
462461
"#
463462
);

src/values.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use crate::reflection::JsProxyInstanceId;
66
use futures::executor::block_on;
77
use futures::Future;
88
use hirofa_utils::debug_mutex::DebugMutex;
9-
use hirofa_utils::resolvable_future::ResolvableFuture;
109
use serde::Serialize;
1110
use serde_json::Value;
1211
use std::collections::HashMap;
@@ -210,11 +209,10 @@ impl CachedJsPromiseRef {
210209
pub async fn get_promise_result(
211210
&self,
212211
) -> Result<Result<JsValueFacade, JsValueFacade>, JsError> {
213-
let fut: ResolvableFuture<Result<Result<JsValueFacade, JsValueFacade>, JsError>> =
214-
ResolvableFuture::new();
215-
let resolver = fut.get_resolver();
216-
let resolver1 = resolver.clone();
217-
let resolver2 = resolver.clone();
212+
let (tx, rx) = flume::bounded(1);
213+
214+
let tx1 = tx.clone();
215+
let tx2 = tx.clone();
218216

219217
self.cached_object.with_obj_void(move |realm, obj| {
220218
let res = || {
@@ -224,8 +222,8 @@ impl CachedJsPromiseRef {
224222
//
225223
let resolution = &args[0];
226224
let send_res = match realm.to_js_value_facade(resolution) {
227-
Ok(vf) => resolver1.resolve(Ok(Ok(vf))),
228-
Err(conv_err) => resolver1.resolve(Err(conv_err)),
225+
Ok(vf) => tx1.send(Ok(Ok(vf))),
226+
Err(conv_err) => tx1.send(Err(conv_err)),
229227
};
230228
send_res
231229
.map_err(|e| JsError::new_string(format!("could not send: {e}")))?;
@@ -239,8 +237,8 @@ impl CachedJsPromiseRef {
239237
//
240238
let rejection = &args[0];
241239
let send_res = match realm.to_js_value_facade(rejection) {
242-
Ok(vf) => resolver2.resolve(Ok(Err(vf))),
243-
Err(conv_err) => resolver2.resolve(Err(conv_err)),
240+
Ok(vf) => tx2.send(Ok(Err(vf))),
241+
Err(conv_err) => tx2.send(Err(conv_err)),
244242
};
245243
send_res
246244
.map_err(|e| JsError::new_string(format!("could not send: {e}")))?;
@@ -254,16 +252,21 @@ impl CachedJsPromiseRef {
254252
};
255253
match res() {
256254
Ok(_) => {}
257-
Err(e) => match resolver.resolve(Err(e)) {
258-
Ok(_) => {}
259-
Err(e) => {
260-
log::error!("failed to resolve 47643: {}", e);
255+
Err(e) => {
256+
log::error!("failed to add promise reactions {}", e);
257+
match tx.send(Err(e)) {
258+
Ok(_) => {}
259+
Err(e) => {
260+
log::error!("failed to resolve 47643: {}", e);
261+
}
261262
}
262-
},
263+
}
263264
}
264265
});
265266

266-
fut.await
267+
rx.recv_async()
268+
.await
269+
.map_err(|e| JsError::new_string(format!("{e}")))?
267270
}
268271
}
269272

0 commit comments

Comments
 (0)