Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Rust-JSC
Rust-JSC is a Rust library that provides a low-level binding for the JavaScriptCore engine. It allows you to interact with JavaScript code from your Rust applications.
Features
- Low-level binding to the JavaScriptCore engine
- Extended API to interact with JavaScriptCore
- Support for esmodules
Installation
Add the following line to your Cargo.toml file:
[]
= { = "0.1.2" }
Usage
Evaluate Script
use JSContext;
let ctx = new;
let result = ctx.evaluate_script;
assert!;
Evaluate Module
use JSContext;
let filename = "/path/filename.js";
let ctx = new;
let result = ctx.evaluate_module;
assert!;
Typed Arrays
use crate::;
Array
use ;
let ctx = new;
let array = new_array.unwrap;
assert_eq!;
Callbacks
use ;
let ctx = new;
let global_object = ctx.global_object;
let object = new;
let attributes = new
.writable
.configurable
.enumerable
.build;
let function = callback;
object
.set_property
.unwrap;
global_object
.set_property
.unwrap;
let result = ctx.evaluate_script;
assert!;
Supported Platforms
Table below shows the supported platforms:
| Platform | Arch | Supported |
|---|---|---|
| macOS | x86_64 | Coming soon.. |
| macOS | aarch64 | ✅ |
| Linux | x86_64 | ✅ |
| Linux | aarch64 | Coming soon.. |
| Windows | x86_64 | ❌ |
| Windows | aarch64 | ❌ |
FAQ
How do I build the static libraries?
By default, this library will try to download the static libraries from the GitHub mirror. If you want to build the static libraries yourself, you can clone the rust-jsc repo and build the Docker image from the Dockerfile. It will build the static libraries for you and copy them to the provided path.
DOCKER_BUILDKIT=1
This command will only work on Linux. For macOS, you should build the JavaScriptCore static libraries by running the following command from the Makefile:
Then set the RUST_JSC_CUSTOM_BUILD_PATH environment variable to the path of the static libraries.
:warning: Keep in mind this lib use a custom version of WebKit to generate the bindings. this version of WebKit is a fork of the original WebKit with some patches to support esmodules and other features.
How do I troubleshoot linking problems?
If you encounter any problems linking the static libraries, try setting the following environment variables:
# For macOS
# Example path to the JavaScriptCore static libraries
DYLD_LIBRARY_PATH=/Users//Documents/Projects/WebKit/WebKitBuild/JSCOnly/Release/lib:
# For Linux
# Example path to the JavaScriptCore static libraries
LD_LIBRARY_PATH=/Users//Documents/Projects/WebKit/WebKitBuild/JSCOnly/Release/lib:
License
This project is licensed under the MIT License - see the LICENSE file for details.