GreenCopperRuntime icon indicating copy to clipboard operation
GreenCopperRuntime copied to clipboard

Javascript runtime library built in rust which can be used with quickjs

GreenCopperRuntime

Just to get thing clear straight away, this is a very much work in progress project, nothing is definitive, it might never become definitive

Roadmap / The plan

GreenCopperRuntime is a library which adds additional features to a QuickJs JavaScript runtime.

GreenCopperRuntime is based on quickjs_runtime

Other GreenCopper projects

GreenCopperCmd is a commandline utility which you can use to run js/ts files with GreenCopper

Default implementations

GreenCopperRuntime provides implementations for abstract features of the Runtimes like:

Preprocessing

GreenCopperRuntime provides script pre-processing for:

  • [x] cpp style preprocessing (e.g. use #ifdef $GRECO_DEBUG in code) (DOCS)
  • [ ] macros which generate script before eval
  • [x] Typescript support is implemented as a separate optional project typescript_utils

The following features are optionally added by specifying them in your Cargo.toml

  • [x] HTML Dom (Work in progress)
  • [ ] crypto
    • [x] crypto.randomUUID()
    • [ ] crypto.subtle
  • [x] JWT (Work in progress)
  • [ ] db
    • [x] mysql (Work in progress)
      • [x] single query (named and positional params)
      • [x] execute (batch)
      • [x] transactions
    • [ ] cassandra
    • [ ] redis
  • [ ] com
    • [ ] http (Work in progress, was deleted due to fetch being done first. will review this func later for advanced things like client certs)
    • [ ] sockets
  • [ ] io
    • [x] gpio (Work in progress)
    • [x] fs (Work in progress)
  • [ ] libloading
    • [ ] libc
    • [ ] java
    • [ ] npm
  • [ ] utilities
    • [ ] caching
      • [x] cache (WiP)

Getting started

// wip

Cargo.toml

In your cargo.toml you can add the green_copper dependency and specify the runtimes you want to use (as features)

green_copper_runtime =  { git = 'https://github.com/HiRoFa/GreenCopperRuntime', branch="main", features = ["engine_quickjs"]}
quickjs_runtime = {git = 'https://github.com/HiRoFa/quickjs_es_runtime', branch="main"}

Main api concepts

// wip

GreenCopper based runtimes all split the API into two distinct halves, first of all there are your outer thread-safe API's which do not directly call the underlying runtime, These are the

All of these work (with some exeptions) by adding a job to an EventLoop (a member of the JsRuntimeFacade) and getting the result async (the API returns a Future).

These jobs run in a single thread per runtime and provide access to the Adapters which DO interact with the actual Runtime/Context/Value directly, these are:

Example

// todo

Adding features

// wip

Functions

// wip

Proxy classes

// wip

Modules

// wip