Coder Social home page Coder Social logo

icemic / quickjspp-rs Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 4.0 1.49 MB

A rusty QuickJS (QuickJS-NG) Javascript engine wrapper, and more.

Home Page: https://docs.rs/quickjs-rusty

License: MIT License

Rust 7.32% Makefile 0.34% C 87.10% C++ 5.19% Nix 0.01% Just 0.05%
game javascript javascript-engine quickjs quickjs-runtime rust scripting-language serde quickjspp

quickjspp-rs's Introduction

quickjs-rusty

Crates.io docs.rs

QuickJS is a small and embeddable Javascript engine by Fabrice Bellard and Charlie Gordon. It supports the ES2023 specification including modules, asynchronous generators, proxies and BigInt.
Quickjs-NG is one of the most active forks of QuickJS, and it is maintained by the community focused on reigniting the project.

This crate allows you to easily access and use all the features of QuickJS from Rust. It also provides robust Rust-JS type conversion and interoperability capabilities.

Quickstart

[dependencies]
quickjs-rusty = "0.6.0"
use quickjs_rusty::{Context, JsValue};

let context = Context::new().unwrap();

// Eval.

let value = context.eval("1 + 2").unwrap();
assert_eq!(value, JsValue::Int(3));

let value = context.eval_as::<String>(" var x = 100 + 250; x.toString() ").unwrap();
assert_eq!(&value, "350");

// Callbacks.

context.add_callback("myCallback", |a: i32, b: i32| a + b).unwrap();

context.eval(r#"
    // x will equal 30
    var x = myCallback(10, 20);
"#).unwrap();

Note: This project is derived from quickjs-rs, but it has undergone significant restructuring. It features a completely different code structure and functional design compared to the original project.

Optional Features

The crate supports the following features:

  • serde: (default enabled). enable serde method from_js and to_js to transform between Rust types and js value in quickjs context. It should compatible with serde_json but not tested yet. See more on the example.
  • chrono: (default enabled). chrono integration
    • adds a JsValue::Date variant that can be (de)serialized to/from a JS Date
  • bigint: (default enabled). arbitrary precision integer support via num-bigint

Installation

By default, quickjs is bundled with the libquickjs-sys crate and automatically compiled, assuming you have the appropriate dependencies.

Windows Support

quickjspp-rs can be used under target x86_64-pc-windows-msvc,

System installation

To use the system installation, without the bundled feature, first install the required dependencies, and then compile and install quickjspp.

You then need to disable the bundled feature in the libquickjs-sys crate to force using the system version.

quickjspp-rs's People

Contributors

a-rodin avatar andrieshiemstra avatar chayleaf avatar coolreader18 avatar errord avatar graham avatar icemic avatar kusstar avatar llgoer avatar mrmaxmeier avatar rail-ka avatar theduke avatar xu-cheng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

quickjspp-rs's Issues

Catch up the latest quickjs, or quickjs-ng?

Currently, we're utilizing a forked version of QuickJS, aka quickjspp, as opposed to the original QuickJS. The original version has received numerous updates that significantly enhance its compatibility with ES2023 recently.

Our choice to use quickjspp is primarily due to its support for MSVC compilation. However, there's a concern that if quickjspp doesn't keep up with the latest updates from the original repository, we might fall behind as well. It raises the question of whether it's time to consider other options.

To be frank, the current ecosystem is somewhat perplexing, with multiple versions of quickjs in existence, including Bellard's original and several forks:

It seems that quickjs-ng is the one we shall choose and txiki.js has chosen it. This fork version came up just before Bellard committed the recent updates, so now, it seems a little awkward.
I can not figure out the future of quickjs-ng or quickjs, will they merge together or develop separately?

The most important, both of them have not supported MSVC yet, though there are some discussion on quickjs-ng

I will keep monitoring their progress and update accordingly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.