An open API service indexing awesome lists of open source software.

https://github.com/alexzhirkevich/keight

JavaScript runtime for Kotlin Multiplatform. Written entirely in Kotlin. Works on every Kotlin target.
https://github.com/alexzhirkevich/keight

javascript js js-engine js-runtime kmp kotlin kotlin-multiplatform multiplatform

Last synced: 5 months ago
JSON representation

JavaScript runtime for Kotlin Multiplatform. Written entirely in Kotlin. Works on every Kotlin target.

Awesome Lists containing this project

README

          

# Keight

JavaScript runtime for Kotlin Multiplatform. Written entirely in Kotlin. Works on every Kotlin target.

Powers After Effects expressions in [Compottie](https://github.com/alexzhirkevich/compottie) library.

> [!WARNING]
> Project is experimental and WIP.

> The runtime is not currently ES-compliant.

> No support guarantees.

> Use only for evaluation purposes or on your own risk

# Installation

```toml
[versions]
keight=""

[libraries]
keight = { module = "io.github.alexzhirkevich:keight", version.ref = "keight" }
```

# Usage

## Basic

```kotlin

val engine = JSEngine(JSRuntime(coroutineContext))
val code = "const js = 'JS'; 'Hello, ' + js"

val script = engine.compile(code)
val result = script.invoke()?.toKotlin(engine.runtime)
println(result)

// or

val result = engine.evaluate(code)
println(result)

```