DelSkayn / rquickjs

High level bindings to the quickjs javascript engine
MIT License
431 stars 58 forks source link

New util crate #319

Open Sytten opened 1 month ago

Sytten commented 1 month ago

This is a new util crate that is meant as a place for the community to contribute utilities that are not covered by quickjs natively. This first iteration adds:

codecov-commenter commented 1 month ago

Codecov Report

Attention: Patch coverage is 97.29144% with 25 lines in your changes are missing coverage. Please review.

Project coverage is 71.59%. Comparing base (304db5d) to head (bf69953).

Files Patch % Lines
util/src/console/formatter.rs 96.10% 10 Missing :warning:
util/src/console/mod.rs 75.00% 10 Missing :warning:
util/src/url_search_params.rs 99.19% 5 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #319 +/- ## ========================================== + Coverage 68.31% 71.59% +3.27% ========================================== Files 83 87 +4 Lines 12237 13160 +923 ========================================== + Hits 8360 9422 +1062 + Misses 3877 3738 -139 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

ahaoboy commented 1 week ago

Implementing console in rust is very complicated. The best way may be to reuse deno's js code, which will be very simple at the rust and consistent with deno. Here is an example, I hope it will be helpful.

https://github.com/ahaoboy/rqjs/blob/main/rqjs-ext/src/modules/console.rs

Sytten commented 1 week ago

@ahaoboy That sounds like a bad idea considering it is js based and quickjs is really not that fast to run js code. I dont think we need to be 100% there. We have been using this console implementation for about a year.

ahaoboy commented 1 week ago

Nice job~

@ahaoboy That sounds like a bad idea considering it is js based and quickjs is really not that fast to run js code.

I haven't tested the difference in size and speed between the js and rust code, but the two are not in conflict. Users should be able to choose different console implementations based on their scenario. If they need more style and more comprehensive output, they can choose console_deno(maybe this name). If they need more startup speed and size, then the simple rust implementation will be more suitable.

Based on the test of the following simple code, it seems that Promsie is not supported?

console.log([1, '1'])
console.log(1)
console.log('a')

const a = [1]
a[1] = a;
console.log(a)

console.log('Promise:', Promise.resolve(1))
console.log('Proxy:', new Proxy({ a: 1 }, {}))

image

Sytten commented 1 week ago

Yeah still missing some things, thats why I said 80% done