GraalRuntime

The GraalJS execution engine — the "real JavaScript" path. A JIM module's TypeScript is first transpiled to JavaScript by swc4j (here used as a plain TS→JS transpiler, not its bytecode compiler) and then evaluated as an ES module on a GraalJS Context. Scripts get full ECMAScript: real arrays with .map/.filter, closures over reassigned lets, objects, JSON, etc. — none of the bytecode path's "half-Java" workarounds (Store/Num/Args).

The JIM API objects (Jim, Event, ChatLib, ...) are bound as JS globals, so the familiar import { Jim, Event } from 'ratph6.jim.api' line is simply stripped before evaluation (the names resolve to the globals instead).

Single-threaded by construction: the Context is created on, and only ever touched from, the JS thread — which is also where module loading, dispatch and timers run. This matches GraalJS's single-thread-at-a-time contract; no locking needed.

Security: host access is broad on the bound objects, but allowHostClassLookup is left off, so guest code cannot reach Runtime/ProcessBuilder/etc. — only the bound API surface and whatever it returns. Mirrors the intent of JimCompiler's import ban.

Functions

Link copied to clipboard
fun evalSnippet(code: String): Value

Transpile + run a one-off snippet as a script (for /jim eval). JIM + Minecraft names need no import.

Link copied to clipboard
fun loadModule(manifest: JimManifest, dir: Path, source: String): GraalModule

Transpile + evaluate a module's TypeScript as an ES module. Top-level code runs immediately (so top-level Jim.register(...) calls register against module); the returned namespace holds any exported functions (for the main/init entry and trigger-name conventions).

Link copied to clipboard
fun reset()

Dispose the context so a reload starts from clean JS global state. Next load rebuilds it.

Link copied to clipboard
fun transpileTs(source: String, fileName: String): String

Transpile TypeScript (or JS) source to plain ES-module JavaScript.