Skip to content

Commit db64188

Browse files
update sys to 0.10.0
1 parent 3f91d6e commit db64188

File tree

15 files changed

+360
-137
lines changed

15 files changed

+360
-137
lines changed

CHANGELOG.md

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 0.15.0
2+
3+
* quickjs-ng 0.10.0
4+
* quickjs 2025-04-26
5+
* some minor but api breaking changes
6+
17
# 0.14.9
28

39
* TypeScript::TRANSPILER no longer uses external_helpers by default
@@ -57,15 +63,16 @@
5763

5864
# 0.13.0
5965

60-
* support quickjs-ng (v 0.3.0) as feature, it compiles, some test cases fail (bigint) but should be a nice first step
66+
* support quickjs-ng (v 0.3.0) as feature, it compiles, some test cases fail (bigint) but should be a nice first step
6167

6268
# 0.12.1
6369

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

6672
# 0.12.0
6773

68-
* uses hirofa-quickjs-sys 0.2.0 and ['bellard'] feature and thus the 2024-01-13 version of the original quickjs by Fabrice Bellard
74+
* uses hirofa-quickjs-sys 0.2.0 and ['bellard'] feature and thus the 2024-01-13 version of the original quickjs by
75+
Fabrice Bellard
6976
* added get_proxy_instance_id for getting instance id without looking up the proxy
7077
* console functions output source filename
7178

@@ -156,18 +163,19 @@
156163

157164
# 0.7
158165

159-
## 0.7.2
166+
## 0.7.2
160167

161168
* fix for #62 (nested callback creation/drop fails)
162169

163-
## 0.7.1
170+
## 0.7.1
164171

165172
* fn to calc memory usage
166173
* implemented static event handlers for proxies
167174

168175
## 0.7.0
169176

170-
* implemented js_proxy_new_instance_with_id from utils which allows you to create an instance of a proxy with a predefined id
177+
* implemented js_proxy_new_instance_with_id from utils which allows you to create an instance of a proxy with a
178+
predefined id
171179
* implemented set_prop / has_prop functions in proxies
172180
* implemented CompiledModuleLoader
173181
* implemented jsValueAdapter.js_to_str()
@@ -186,7 +194,8 @@
186194
* renamed EsRuntime to QuickJsRuntimeFacade, and others to follow same conventions
187195
* removed fetch api (moved to greencopperruntime)
188196
* removed all panics when async promise resolution fails because of the realm being invalid
189-
* implemented a lot of js_utils abstractions, please note that js_utils::JsValueFacade will someday deprecate quickjs_runtime::EsValueFacade
197+
* implemented a lot of js_utils abstractions, please note that js_utils::JsValueFacade will someday deprecate
198+
quickjs_runtime::EsValueFacade
190199

191200
# 0.5
192201

@@ -200,9 +209,11 @@
200209
* replaced EsScript with js_utils::Script
201210
* replaced ScriptPreProcessor with js_utils::ScriptPreProcessor
202211
* replaced EsError with js_utils::JsError
203-
* implemented utils::js_utils (generic adapters and facades, see [the green copper plan](https://github.com/HiRoFa/GreenCopperRuntime/blob/main/README.md#roadmap--the-plan) for what's this all about)
212+
* implemented utils::js_utils (generic adapters and facades,
213+
see [the green copper plan](https://github.com/HiRoFa/GreenCopperRuntime/blob/main/README.md#roadmap--the-plan) for
214+
what's this all about)
204215
* changes to function definitions
205-
* fixed interrupt handler
216+
* fixed interrupt handler
206217

207218
# 0.4
208219

@@ -211,11 +222,11 @@
211222
* moved reflection code to reflection/mod.rs (should not affect api)
212223
* toPrimitive for Proxy classes (do stuff like console.log('got: ' + MyProxyInstanceOrClass))
213224
* removed droppablevalue, replaced with JSPropertyEnumRef
214-
* added is_enumerable(index) fn to JSPropertyEnumRef
225+
* added is_enumerable(index) fn to JSPropertyEnumRef
215226
* added get_name(index) fn to JSPropertyEnumRef
216227
* added interrupt_handler
217228

218-
## 0.4.1
229+
## 0.4.1
219230

220231
* altered tokio dep, full is now optional (prevents valgrind errors)
221232
* altered utils dep to 0.1
@@ -227,8 +238,8 @@
227238

228239
* use EventLoop from hirofa_utils, cleaner code, much less Mutexes
229240
* Renamed a lot of public methods
230-
* e.g. rt.add_to_es_event_queue_sync -> rt.exe_rt_task_in_event_loop()
231-
* e.g. rt.add_to_es_event_queue -> rt.add_rt_task_to_event_loop()
241+
* e.g. rt.add_to_es_event_queue_sync -> rt.exe_rt_task_in_event_loop()
242+
* e.g. rt.add_to_es_event_queue -> rt.add_rt_task_to_event_loop()
232243
* Removed EsRuntime.inner Arc, was a duplicate solution to the same problem
233244
* mit lic
234245
* script preprocessors
@@ -242,19 +253,23 @@
242253

243254
# 0.2
244255

245-
## 0.2.3
256+
## 0.2.3
246257

247-
* added a runtime_init_hook(hook) method to the EsRuntimeBuilder so we can add vars to the runtime when the builder is built
258+
* added a runtime_init_hook(hook) method to the EsRuntimeBuilder so we can add vars to the runtime when the builder is
259+
built
248260
* added EsPromise::new_async which can be used to instantiate a Promise with an async resolver
249-
* Big thanks to [SreeniIO](https://github.com/SreeniIO) for helping out!
250-
* refactored the module loaders in qjsrt so we can differentiate between script and native... I need that for CommonJS and probably later for transpiling and such
261+
* Big thanks to [SreeniIO](https://github.com/SreeniIO) for helping out!
262+
* refactored the module loaders in qjsrt so we can differentiate between script and native... I need that for CommonJS
263+
and probably later for transpiling and such
251264
* added quickjs_utils::get_script_or_module_name to get the current scripts filename or module name
252265
* Proxy supports multiple finalizers
253-
* Proxy as EventTarget first working code. needs to mature, but the goal for now is minimal support for dispatching events from rust to JavaScript
266+
* Proxy as EventTarget first working code. needs to mature, but the goal for now is minimal support for dispatching
267+
events from rust to JavaScript
254268

255269
## 0.2.2
256270

257-
* added _void variants for adding jobs to the event queue, this prevents Futures being dropped before being resolved resulting in errors in the logs
271+
* added _void variants for adding jobs to the event queue, this prevents Futures being dropped before being resolved
272+
resulting in errors in the logs
258273
* setTimeout / setInterval now correctly run pending jobs (fixes resolving promises with timeout and such)
259274
* removed logging from console.rs so we can set custom loglevel to that package
260275
* fixed deadlocks in esvalue promise resolution
@@ -273,22 +288,29 @@
273288
## 0.1.1
274289

275290
* more precise timing for setTimeout and setInterval
276-
* quickjs_utils::maps utils for handling [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) instances from rust
277-
* quickjs_utils::sets utils for handling [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) instances from rust
278-
* Proxy.event_target and Proxy.static_event_target to allow a Proxy to be used as [EventTarget](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget)
291+
* quickjs_utils::maps utils for
292+
handling [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) instances from
293+
rust
294+
* quickjs_utils::sets utils for
295+
handling [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) instances from
296+
rust
297+
* Proxy.event_target and Proxy.static_event_target to allow a Proxy to be used
298+
as [EventTarget](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget)
279299
* objects::construct_object util to create a new instance of a constructor
280300
* iterators util to handle iterators
281301
* EventQueue.async_task will be a starting point for being able to use async/await with javascript
282302
* made async functions in EsRuntime (eval, eval_module, call_function, gc)
283303
* made invoke_function in EsValueFacade async
284-
* added async [get_promise_result](https://hirofa.github.io/quickjs_es_runtime/quickjs_runtime/esvalue/struct.EsValueFacade.html#method.get_promise_result) to EsValueFacade so the result of a promise may be awaited async
304+
* added
305+
async [get_promise_result](https://hirofa.github.io/quickjs_es_runtime/quickjs_runtime/esvalue/struct.EsValueFacade.html#method.get_promise_result)
306+
to EsValueFacade so the result of a promise may be awaited async
285307
* added quickjs_utils::modules::detect_module() method to detect if a script source is a module
286308
* added ```es_args![]``` macro so you can use
287-
309+
288310
```let args = es_args![1, 2, true, "sdf".to_string()]```
289-
311+
290312
instead of
291-
313+
292314
```let args = vec![1.to_es_value_facade(), 2.to_es_value_facade(), true.to_es_value_facade(), "sdf".to_string().to_es_value_facade()]```
293315
* added quickjs_utils::modules::new_module/add_module_export/set_module_export
294316
* added NativeModuleLoader to QuickJSRuntime to enable implementors to load native modules on-demand

Cargo.toml

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "quickjs_runtime"
3-
version = "0.14.9"
3+
version = "0.15.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,62 +30,62 @@ hirofa_utils = "0.7"
3030
backtrace = "0.3"
3131

3232
#libquickjs-sys = {package="hirofa-quickjs-sys", git='https://github.com/HiRoFa/quickjs-sys'}
33-
#libquickjs-sys = {package="hirofa-quickjs-sys", path='../quickjs-sys', default-features=false}
34-
libquickjs-sys = {package="hirofa-quickjs-sys", version="0.9.0", default-features=false}
33+
#libquickjs-sys = { package = "hirofa-quickjs-sys", path = '../quickjs-sys', default-features = false }
34+
libquickjs-sys = { package = "hirofa-quickjs-sys", version = "0.10.0", default-features = false }
3535
lazy_static = "1.5.0"
3636
log = "0.4"
3737
num_cpus = "1"
3838
rand = "0.8"
3939
thread-id = "5"
4040
futures = "0.3"
41-
tokio = {version = "1", features=["rt", "rt-multi-thread"]}
41+
tokio = { version = "1", features = ["rt", "rt-multi-thread"] }
4242
serde_json = "1.0"
43-
serde = {version="1.0", features=["derive"]}
43+
serde = { version = "1.0", features = ["derive"] }
4444
string_cache = "0.8"
45-
flume = {version="0.11", features=["async"]}
45+
flume = { version = "0.11", features = ["async"] }
4646

4747
#swc
4848
# like the good people at denoland said:
4949
# "swc's version bumping is very buggy and there will often be patch versions
5050
# published that break our build, so we pin all swc versions to prevent
5151
# pulling in new versions of swc crates"
5252
# see https://github.com/denoland/deno_ast/blob/main/Cargo.toml
53-
swc = {version="=16.1.1", optional=true}
54-
swc_atoms = {version="=5.0.0", optional=true}
55-
swc_cached = {version="=2.0.0", optional=true}
56-
swc_common = {version="=8.0.1", optional=true, features = ["tty-emitter"]}
57-
swc_macros_common = {version="=1.0.0", optional=true}
58-
swc_eq_ignore_macros = {version="=1.0.0", optional=true}
59-
swc_visit = {version="=2.0.0", optional=true}
60-
swc_visit_macros = {version="=0.5.13", optional=true}
61-
swc_config = {version="=2.0.0", optional=true}
62-
swc_config_macro = {version="=1.0.0", optional=true}
63-
swc_ecma_codegen = {version="=8.0.2", optional=true}
64-
swc_ecma_ast = {version="=8.1.0", optional=true}
65-
swc_ecma_codegen_macros = {version="=1.0.1", optional=true}
66-
swc_ecma_ext_transforms = {version="=11.0.0", optional=true}
67-
swc_ecma_utils = {version="=11.0.0", optional=true}
68-
swc_ecma_visit = {version="=8.0.0", optional=true}
69-
swc_ecma_lints = {version="=11.0.1", optional=true}
70-
swc_ecma_loader = {version="=8.0.0", optional=true}
71-
swc_ecma_minifier = {version="=12.4.0", optional=true}
72-
swc_ecma_parser = {version="=10.0.2", optional=true}
73-
swc_error_reporters = {version="=9.1.1", optional=true}
74-
swc_fast_graph = {version="=9.0.0", optional=true}
75-
swc_ecma_usage_analyzer = {version="=12.0.2", optional=true}
76-
swc_timer = {version="=1.0.0", optional=true}
77-
swc_ecma_preset_env = {version="=14.0.0", optional=true}
78-
swc_ecma_transforms = {version="=14.0.0", optional=true}
79-
swc_ecma_transforms_base = {version="=11.2.0", optional=true}
80-
swc_ecma_transforms_compat = {version="=12.0.0", optional=true}
81-
swc_ecma_transforms_classes = {version="=11.0.0", optional=true}
82-
swc_ecma_transforms_module = {version="=12.1.0", optional=true}
83-
swc_ecma_transforms_optimization = {version="=11.1.0", optional=true}
84-
swc_ecma_transforms_proposal = {version="=11.0.2", optional=true}
85-
swc_ecma_transforms_macros = {version="=1.0.0", optional=true}
86-
swc_ecma_transforms_react = {version="=12.0.1", optional=true}
87-
swc_ecma_transforms_typescript = {version="=12.0.1", optional=true}
88-
swc_node_comments = {version="=8.0.0", optional=true}
53+
swc = { version = "=16.1.1", optional = true }
54+
swc_atoms = { version = "=5.0.0", optional = true }
55+
swc_cached = { version = "=2.0.0", optional = true }
56+
swc_common = { version = "=8.0.1", optional = true, features = ["tty-emitter"] }
57+
swc_macros_common = { version = "=1.0.0", optional = true }
58+
swc_eq_ignore_macros = { version = "=1.0.0", optional = true }
59+
swc_visit = { version = "=2.0.0", optional = true }
60+
swc_visit_macros = { version = "=0.5.13", optional = true }
61+
swc_config = { version = "=2.0.0", optional = true }
62+
swc_config_macro = { version = "=1.0.0", optional = true }
63+
swc_ecma_codegen = { version = "=8.0.2", optional = true }
64+
swc_ecma_ast = { version = "=8.1.0", optional = true }
65+
swc_ecma_codegen_macros = { version = "=1.0.1", optional = true }
66+
swc_ecma_ext_transforms = { version = "=11.0.0", optional = true }
67+
swc_ecma_utils = { version = "=11.0.0", optional = true }
68+
swc_ecma_visit = { version = "=8.0.0", optional = true }
69+
swc_ecma_lints = { version = "=11.0.1", optional = true }
70+
swc_ecma_loader = { version = "=8.0.0", optional = true }
71+
swc_ecma_minifier = { version = "=12.4.0", optional = true }
72+
swc_ecma_parser = { version = "=10.0.2", optional = true }
73+
swc_error_reporters = { version = "=9.1.1", optional = true }
74+
swc_fast_graph = { version = "=9.0.0", optional = true }
75+
swc_ecma_usage_analyzer = { version = "=12.0.2", optional = true }
76+
swc_timer = { version = "=1.0.0", optional = true }
77+
swc_ecma_preset_env = { version = "=14.0.0", optional = true }
78+
swc_ecma_transforms = { version = "=14.0.0", optional = true }
79+
swc_ecma_transforms_base = { version = "=11.2.0", optional = true }
80+
swc_ecma_transforms_compat = { version = "=12.0.0", optional = true }
81+
swc_ecma_transforms_classes = { version = "=11.0.0", optional = true }
82+
swc_ecma_transforms_module = { version = "=12.1.0", optional = true }
83+
swc_ecma_transforms_optimization = { version = "=11.1.0", optional = true }
84+
swc_ecma_transforms_proposal = { version = "=11.0.2", optional = true }
85+
swc_ecma_transforms_macros = { version = "=1.0.0", optional = true }
86+
swc_ecma_transforms_react = { version = "=12.0.1", optional = true }
87+
swc_ecma_transforms_typescript = { version = "=12.0.1", optional = true }
88+
swc_node_comments = { version = "=8.0.0", optional = true }
8989
#swc_trace_macro = {version="=2.0.0", optional=true}
9090

9191

@@ -101,8 +101,8 @@ tracing = "0.1"
101101
tracing-log = "0.1"
102102
tracing-gelf = "0.7"
103103
simple-logging = "2.0.2"
104-
tokio = {version = "1", features=["macros"]}
105-
anyhow="1"
104+
tokio = { version = "1", features = ["macros"] }
105+
anyhow = "1"
106106

107107
[dev-dependencies.cargo-husky]
108108
version = "1.5.0"

src/quickjs_utils/bigints.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use crate::quickjs_utils;
33
use crate::quickjs_utils::{functions, primitives};
44
use crate::quickjsrealmadapter::QuickJsRealmAdapter;
55
use crate::quickjsvalueadapter::QuickJsValueAdapter;
6+
#[cfg(feature = "bellard")]
7+
use crate::quickjsvalueadapter::TAG_BIG_INT;
68
use libquickjs_sys as q;
79

810
pub fn new_bigint_i64_q(
@@ -30,7 +32,12 @@ pub unsafe fn new_bigint_i64(
3032
let ret = QuickJsValueAdapter::new(context, res_val, false, true, "new_bigint_i64");
3133

3234
#[cfg(feature = "bellard")]
33-
assert_eq!(ret.get_ref_count(), 1);
35+
{
36+
#[cfg(debug_assertions)]
37+
if ret.get_tag() == TAG_BIG_INT {
38+
assert_eq!(ret.get_ref_count(), 1);
39+
}
40+
}
3441
Ok(ret)
3542
}
3643

@@ -45,7 +52,12 @@ pub unsafe fn new_bigint_u64(
4552
let ret = QuickJsValueAdapter::new(context, res_val, false, true, "new_bigint_u64");
4653

4754
#[cfg(feature = "bellard")]
48-
assert_eq!(ret.get_ref_count(), 1);
55+
{
56+
#[cfg(debug_assertions)]
57+
if ret.get_tag() == TAG_BIG_INT {
58+
assert_eq!(ret.get_ref_count(), 1);
59+
}
60+
}
4961
Ok(ret)
5062
}
5163

src/quickjs_utils/class_ids.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src/quickjs_utils/dates.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
33
use crate::jsutils::JsError;
44
use crate::quickjs_utils;
5+
#[cfg(feature = "bellard")]
6+
use crate::quickjs_utils::class_ids::JS_CLASS_DATE;
57
use crate::quickjs_utils::{functions, primitives};
68
use crate::quickjsrealmadapter::QuickJsRealmAdapter;
79
use crate::quickjsvalueadapter::QuickJsValueAdapter;
810
use libquickjs_sys as q;
9-
#[cfg(feature = "quickjs-ng")]
10-
use libquickjs_sys::{JS_IsDate};
1111
#[cfg(feature = "bellard")]
12-
use crate::quickjs_utils::objects::is_instance_of_by_name;
12+
use libquickjs_sys::JS_GetClassID;
13+
#[cfg(feature = "quickjs-ng")]
14+
use libquickjs_sys::JS_IsDate;
1315

1416
/// create a new instance of a Date object
1517
pub fn new_date_q(context: &QuickJsRealmAdapter) -> Result<QuickJsValueAdapter, JsError> {
@@ -37,7 +39,7 @@ pub fn is_date_q(context: &QuickJsRealmAdapter, obj_ref: &QuickJsValueAdapter) -
3739
pub unsafe fn is_date(ctx: *mut q::JSContext, obj: &QuickJsValueAdapter) -> bool {
3840
#[cfg(feature = "bellard")]
3941
{
40-
is_instance_of_by_name(ctx, obj, "Date").unwrap_or(false)
42+
JS_GetClassID(*obj.borrow_value()) == JS_CLASS_DATE
4143
}
4244
#[cfg(feature = "quickjs-ng")]
4345
{
@@ -87,14 +89,18 @@ pub unsafe fn get_time(
8789
let time_ref = functions::invoke_member_function(context, date_ref, "getTime", &[])?;
8890
if time_ref.is_f64() {
8991
primitives::to_f64(&time_ref)
90-
} else {
92+
} else if time_ref.is_i32() {
9193
primitives::to_i32(&time_ref).map(|i| i as f64)
94+
} else {
95+
Err(JsError::new_string(format!(
96+
"could not get time, val was a {}",
97+
time_ref.get_js_type()
98+
)))
9299
}
93100
}
94101

95102
#[cfg(test)]
96103
pub mod tests {
97-
98104
use crate::facades::tests::init_test_rt;
99105
use crate::quickjs_utils::dates;
100106
use crate::quickjs_utils::dates::{get_time_q, is_date_q, set_time_q};
@@ -107,11 +113,15 @@ pub mod tests {
107113
let date_ref = dates::new_date_q(q_ctx).expect("new_date failed");
108114
assert!(is_date_q(q_ctx, &date_ref));
109115

110-
set_time_q(q_ctx, &date_ref, 2147483648f64).expect("could not set time");
116+
set_time_q(q_ctx, &date_ref, 1746776901898f64).expect("could not set time");
117+
log::info!(
118+
"date_str={}",
119+
date_ref.to_string().expect("could not get date_ref string")
120+
);
111121
let gt_res = get_time_q(q_ctx, &date_ref);
112122
match gt_res {
113123
Ok(t) => {
114-
assert_eq!(t, 2147483648f64);
124+
assert_eq!(t, 1746776901898f64);
115125
}
116126
Err(e) => {
117127
panic!("get time failed: {}", e);

0 commit comments

Comments
 (0)