MCPcopy Index your code
hub / github.com/DelSkayn/rquickjs

github.com/DelSkayn/rquickjs @v0.12.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.12.0 ↗ · + Follow
1,935 symbols 5,053 edges 144 files 457 documented · 24%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

rquickjs

github crates docs status

This library is a high level bindings of the QuickJS-NG JavaScript engine, a fork of the QuickJS Javascript engine. Its goal is to be an easy to use, and safe wrapper similar to the rlua library.

QuickJS is a small and embeddable JavaScript engine. It supports the ES2020 specification including modules, asynchronous generators, proxies and BigInt. It optionally supports mathematical extensions such as big decimal floating point numbers (BigDecimal), big binary floating point numbers (BigFloat) and operator overloading.

Main features of QuickJS

  • Small and easily embeddable: just a few C files, no external dependency, 210 KiB of x86 code for a simple hello world program.
  • Fast interpreter with very low startup time: runs the 75000 tests of the ECMAScript Test Suite in about 100 seconds on a single core of a desktop PC. The complete life cycle of a runtime instance completes in less than 300 microseconds.
  • Almost complete ES2020 support including modules, asynchronous generators and full Annex B support (legacy web compatibility).
  • Passes nearly 100% of the ECMAScript Test Suite tests when selecting the ES2020 features. A summary is available at Test262 Report.
  • Can compile JavaScript sources to executables with no external dependency.
  • Garbage collection using reference counting (to reduce memory usage and have deterministic behavior) with cycle removal.
  • Mathematical extensions: BigDecimal, BigFloat, operator overloading, bigint mode, math mode.
  • Command line interpreter with contextual colorization implemented in JavaScript.
  • Small built-in standard library with C library wrappers.

Features provided by this crate

  • Full integration with async Rust
  • The ES6 Promises can be handled as Rust futures and vice versa
  • Easy integration with almost any async runtime or executor
  • Flexible data conversion between Rust and JS
  • Many widely used Rust types can be converted to JS and vice versa
  • Support for user-defined allocators
  • The Runtime can be created using custom allocator
  • Using Rust's global allocator is also fully supported
  • Support for user-defined module resolvers and loaders which also can be combined to get more flexible solution for concrete case
  • Support for bundling JS modules as a bytecode using embed macro
  • Support for deferred calling of JS functions
  • Full support of ES6 classes
  • Rust data types can be represented as JS classes
  • Data fields can be accessed via object properties
  • Both static and instance members is also supported
  • The properties can be defined with getters and setters
  • Support for constant static properties
  • Support for holding references to JS objects (Data type which holds refs should implement Trace trait to get garbage collector works properly)
  • Support for extending defined classes by JS

Community development

This crate doesn't aim to provide system and web APIs. The QuickJS library is close to V8 in that regard. If you need APIs from WinterGC or Node, then you can take a look at the follow community projects:

  • AWS LLRT Modules: Collection of modules that micmic some of the Node APIs in pure Rust
  • Rquickjs Extra: Collection of modules that complement AWS LLRT Modules in pure Rust

The community has also built various utilities which might be relevant to you:

  • Rquickjs Serde: Serde serializer and deserializer for rquickjs Value

Development status

This bindings is feature complete, mostly stable and ready to use. The error handling is only thing which may change in the future. Some experimental features like parallel may not works as expected. Use it for your own risk.

Supported platforms

Rquickjs needs to compile a C-library which has it's own limitation on supported platforms, furthermore it needs to generate bindings for that platform. As a result rquickjs might not compile on all platforms which rust supports. In general you can allways try to compile rquickjs with the bindgen feature, this should work for most platforms. Rquickjs ships bindings for a limited set of platforms, for these platforms you don't have to enable the bindgen feature. See below for a list of supported platforms.

platform shipped bindings tested supported by quickjs
x86_64-unknown-linux-gnu
i686-unknown-linux-gnu
aarch64-unknown-linux-gnu
loongarch64-unknown-linux-gnu
x86_64-unknown-linux-musl
aarch64-unknown-linux-musl
loongarch64-unknown-linux-musl
x86_64-pc-windows-gnu
i686-pc-windows-gnu
x86_64-pc-windows-msvc ❌ experimental!
aarch64-pc-windows-msvc ❌ experimental!
x86_64-apple-darwin
aarch64-apple-darwin
wasm32-wasip1
wasm32-wasip2
other Unknown

License

This library is licensed under the MIT License

Extension points exported contracts — how you extend this code

JsLifetime (Interface)
The trait which signifies a type using the rquickjs `'js` lifetime trick for maintaining safety around Javascript values [15 …
core/src/js_lifetime.rs
JsClass (Interface)
The trait which allows Rust types to be used from JavaScript. [10 implementers]
core/src/class.rs
Trace (Interface)
A trait for classes for tracing references to QuickJS objects. QuickJS uses reference counting with tracing to break cy [21 …
core/src/class/trace.rs
FromJs (Interface)
For converting JavaScript values to Rust values This trait automatically converts any value which can be represented as [25 …
core/src/value/convert.rs
IntoJs (Interface)
For converting Rust values to JavaScript values [39 implementers]
core/src/value/convert.rs

Core symbols most depended-on inside this repo

clone
called by 179
core/src/value/atom.rs
as_ptr
called by 108
core/src/value/module.rs
set
called by 108
core/src/value/array.rs
eval
called by 96
core/src/value/module.rs
clone
called by 91
core/src/value.rs
globals
called by 83
core/src/context/ctx.rs
iter
called by 82
core/src/value/array.rs
as_ptr
called by 76
core/src/context/ctx.rs

Shape

Method 904
Class 592
Function 362
Interface 41
Enum 36

Languages

Rust100%
TypeScript1%

Modules by API surface

core/src/class.rs64 symbols
core/src/value.rs57 symbols
core/src/value/array_buffer.rs50 symbols
core/src/value/function.rs48 symbols
core/src/context/ctx.rs48 symbols
core/src/value/object.rs45 symbols
core/src/value/module.rs45 symbols
core/src/value/typed_array.rs37 symbols
core/src/value/iterable.rs35 symbols
core/src/result.rs34 symbols
macro/src/class.rs30 symbols
core/src/value/promise.rs30 symbols

For agents

$ claude mcp add rquickjs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page