Skip to content

HiRoFa/GreenCopperRuntime

Repository files navigation

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:

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

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

  • HTML Dom (Work in progress)
  • crypto
    • crypto.randomUUID()
    • crypto.subtle
  • JWT (Work in progress)
  • db
    • mysql (Work in progress)
      • single query (named and positional params)
      • execute (batch)
      • 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
    • gpio (Work in progress)
    • fs (Work in progress)
  • libloading
  • utilities
    • caching
      • 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