{"id":26105296,"url":"https://github.com/hirofa/quickjs_es_runtime","last_synced_at":"2025-05-16T10:06:23.657Z","repository":{"id":43573130,"uuid":"289654949","full_name":"HiRoFa/quickjs_es_runtime","owner":"HiRoFa","description":"this is a wrapper library for the javascript runtime quickjs written in rust which works with typescript, modules, promises, async, await and much more","archived":false,"fork":false,"pushed_at":"2025-05-16T08:25:45.000Z","size":52254,"stargazers_count":109,"open_issues_count":6,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-16T10:05:53.364Z","etag":null,"topics":["async","ecmascript","es6","javascript","modules","promises","quickjs","rust","typescript"],"latest_commit_sha":null,"homepage":"https://github.com/HiRoFa/quickjs_es_runtime","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HiRoFa.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-08-23T09:30:17.000Z","updated_at":"2025-05-16T08:23:22.000Z","dependencies_parsed_at":"2024-02-07T09:31:29.476Z","dependency_job_id":"5bf86b3c-1714-4d05-b00e-05d3168d9362","html_url":"https://github.com/HiRoFa/quickjs_es_runtime","commit_stats":{"total_commits":542,"total_committers":4,"mean_commits":135.5,"dds":0.09963099630996308,"last_synced_commit":"5ecc00c81b10e4cb1aeed8442169051bb69eeef8"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HiRoFa%2Fquickjs_es_runtime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HiRoFa%2Fquickjs_es_runtime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HiRoFa%2Fquickjs_es_runtime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HiRoFa%2Fquickjs_es_runtime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HiRoFa","download_url":"https://codeload.github.com/HiRoFa/quickjs_es_runtime/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254509475,"owners_count":22082891,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","ecmascript","es6","javascript","modules","promises","quickjs","rust","typescript"],"created_at":"2025-03-09T21:04:20.272Z","updated_at":"2025-05-16T10:06:23.652Z","avatar_url":"https://github.com/HiRoFa.png","language":"Rust","readme":"# quickjs_runtime\n\nQuickjs_runtime is a library for quickly getting started with embedding a javascript engine in your rust project.\n\nRelies on [hirofa-quickjs-sys](https://github.com/HiRoFa/quickjs-sys) to support quickjs-ng as well as the original\nquickjs\n\nQuickjs_runtime runs all javascript action in a single thread using an EventLoop. This means you can call javascript\nsafely from several threads by adding tasks to the EventLoop.\n\n# quickjs or quickjs-ng\n\nQuickjs_runtime supports both the original quickjs and the quickjs-ng project.\n\nYou can try out quickjs-ng by adding the dep to quickjs_runtime like this (use at your own risk as I have not\nextensively tested it yet):\n\n```toml\nquickjs_runtime = { version = \"0.15\", features = [\"console\", \"setimmediate\", \"setinterval\", \"settimeout\", \"typescript\", \"quickjs-ng\"], default-features = false }\n```\n\n# Usage and Features\n\nAn example on how to embed a script engine in rust using this lib can be found\nhere: [github.com/andrieshiemstra/ScriptExtensionLayerExample](https://github.com/andrieshiemstra/ScriptExtensionLayerExample).\nIt was published in TWIR as a walkthrough.\n\nQuickjs_runtime focuses on making [quickjs](https://bellard.org/quickjs/) easy to use and does not add any additional\nfeatures, that's where these projects come in:\n\n* A more feature-rich (e.g. fetch api support, http based module loader and much more)\n  runtime: [GreenCopperRuntime](https://github.com/HiRoFa/GreenCopperRuntime).\n* The commandline client: [GreenCopperCmd](https://github.com/HiRoFa/GreenCopperCmd).\n\nPlease see the [DOCS](https://hirofa.github.io/quickjs_es_runtime/quickjs_runtime/index.html) for all inner workings\n\n# This lib serves two main goals:\n\n## 1. Provide simple utils for working with quickjs (these are located in the quickjs_utils mod)\n\n* The QuickJsRuntime struct, this is to be used from a single thread\n* E.g. objects::set_property(), functions::invoke_func()\n* Wrap JSValue to provide reference counting (+1 on init, -1 on\n  drop) ([QuickJsValueAdapter](https://hirofa.github.io/quickjs_es_runtime/quickjs_runtime/quickjsvalueadapter/struct.QuickJsValueAdapter.html))\n* Pass a module loader\n\n## 2. Wrap quickjs for use as a ready to go JavaScript Runtime\n\n* Start at the QuickjsRuntimeFacade, it provides an EventQueue which has a thread_local QuickJsRuntimeAdapter\n* All values are copied or abstracted in a JsValueFacades\n* So no need to worry about Garbage collection\n* Evaluate script and invoke functions while waiting for results blocking or with async/await\n* Get Promise result blocking or with async/await\n\n# What works?\n\n## Script and Modules\n\n* Typescript (via SWC)\n* Console (\n  .log/info/debug/trace/error) ([docs](https://hirofa.github.io/quickjs_es_runtime/quickjs_runtime/features/console/index.html))\n* Eval\n  script ([docs](https://hirofa.github.io/quickjs_es_runtime/quickjs_runtime/facades/struct.QuickJsRuntimeFacade.html#method.eval))\n* Create promises in JavaScript which execute async\n* Eval\n  modules ([docs](https://hirofa.github.io/quickjs_es_runtime/quickjs_runtime/facades/struct.QuickJsRuntimeFacade.html#method.eval_module))\n* Load modules (dynamic and\n  static) ([docs](https://hirofa.github.io/quickjs_es_runtime/quickjs_runtime/builder/struct.QuickJsRuntimeBuilder.html#method.script_module_loader))\n* Fetch api (impl in [GreenCopperRuntime](https://github.com/HiRoFa/GreenCopperRuntime))\n* setImmediate\n* setTimeout/Interval (and clear)\n* Script preprocessing (impls for ifdef/macro's/typescript can be found\n  in [GreenCopperRuntime](https://github.com/HiRoFa/GreenCopperRuntime))\n\n## Rust-Script interoperability\n\n* Return Promises from rust functions and resolve them from\n  rust ([docs](https://hirofa.github.io/quickjs_es_runtime/quickjs_runtime/jsutils/promises/fn.new_resolving_promise.html))\n* Add functions from\n  rust ([docs](https://hirofa.github.io/quickjs_es_runtime/quickjs_runtime/quickjsrealmadapter/struct.QuickJsRealmAdapter.html#method.install_function))\n* Invoke JS functions from\n  rust ([docs](https://hirofa.github.io/quickjs_es_runtime/quickjs_runtime/facades/struct.QuickJsRuntimeFacade.html#method.invoke_function))\n* Pass primitives, objects and arrays from and to\n  rust ([docs](https://hirofa.github.io/quickjs_es_runtime/quickjs_runtime/quickjs_utils/primitives/index.html))\n* Create Classes from\n  rust ([docs](https://hirofa.github.io/quickjs_es_runtime/quickjs_runtime/reflection/struct.Proxy.html))\n* Async/await support on eval/call_function/promise\n  resolution ([docs](https://hirofa.github.io/quickjs_es_runtime/quickjs_runtime/values/struct.CachedJsPromiseRef.html#method.get_promise_result))\n* Import native Modules (e.g. dynamic loading of rust functions or Proxy\n  classes) ([docs](https://hirofa.github.io/quickjs_es_runtime/quickjs_runtime/builder/struct.QuickJsRuntimeBuilder.html#method.native_module_loader))\n\n# Goals\n\nEmbedding a script engine in a rust project seems a very tedious job which involves learning a lot about the inner\nworkings of that engine.\n\nThe main goal of this project is to make that job easy!\n\nThe manner in which this is achieved is primarily focused on abstracting the workings of the engine from the\nimplementor, therefore some functionality may not be the fastest way of getting things done.\n\nSo a second goal is to make implementing a fast and efficient integration doable for the uninitiated, the most common\ntasks you do with the engine should be doable with the utils in this package and working examples should be provided in\nthe test modules.\n\nThe reason I chose QuickJS as the engine is that I've been dealing with less modern engines in my java projects and not\nbeing able to use the latest and greatest ECMA-script features becomes quite disappointing at times.\n\nThe fun stuff about QuickJS:\n\n* small footprint\n* fast compilation / startup\n* great JS compatibility\n\n# examples\n\nCargo.toml\n\n```toml\n[dependencies]\nquickjs_runtime = \"0.15\"\n```\n\nHere are some quickstarts:\n\n* start by reading the [DOCS](https://hirofa.github.io/quickjs_es_runtime/quickjs_runtime/index.html)\n* [eval a script](https://hirofa.github.io/quickjs_es_runtime/quickjs_runtime/facades/struct.QuickJsRuntimeFacade.html#method.eval)\n\nThe quickjs Api utils:\n\n* [quickjs_utils](https://hirofa.github.io/quickjs_es_runtime/quickjs_runtime/quickjs_utils/index.html)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhirofa%2Fquickjs_es_runtime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhirofa%2Fquickjs_es_runtime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhirofa%2Fquickjs_es_runtime/lists"}