Just to get thing clear straight away, this is a very much work in progress project, nothing is definitive, it might never become definitive
GreenCopperRuntime is a library which adds additional features to a QuickJs JavaScript runtime.
GreenCopperRuntime is based on quickjs_runtime
GreenCopperCmd is a commandline utility which you can use to run js/ts files with GreenCopper
GreenCopperRuntime provides implementations for abstract features of the Runtimes like:
- FileSystemModuleLoader
- HTTPModuleLoader
- HTTPFetch (http capable implementation of fetch api)
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
- mysql (Work in progress)
- 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
- libloading
- libc
- java
- npm
- utilities
- caching
- cache (WiP)
- caching
// wip
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"}
// 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
- QuickJsRuntimeFacade (represents a Runtime)
- JsValueFacade (represents a Value)
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:
- QuickJsRuntimeAdapter (represents a Runtime)
- QuickJsRealmAdapter (represents a Context or Realm)
- QuickJsValueAdapter (represents a Value)
// todo
// wip
// wip
// wip
// wip