KiteJs
An engine and the global scope that goes with it. One instance belongs to the thread that opened it: use it and close it there.
KiteJs(Rhino).use { js ->
js.global.function("shout") { args -> args.first().asString().uppercase() }
println(js.evaluate("shout('hi')").asString()) // HI
}Every outermost call from the host into the engine, evaluate, running a JsScript, calling a JsFunction or a method, runs the Promise reactions it queued before it returns. Work queued later, from a host callback, waits for the next such call or for runMicrotasks.
An exception a host function throws is not a JavaScript exception: no catch in the script sees it, and it comes out of the call that started the script as itself when it is a JsException, or inside a JsEngineError otherwise.
Properties
Whether evaluatePausing really pauses here. Only QuickJS on a browser or Node with WebAssembly stack switching (JSPI) can; everywhere else it runs like evaluate.
Functions
A script from bytecode that JsScript.bytecode wrote in an engine of the same kind and version, ready to run here without a parse. The engine runs bytecode without checking it, so load only bytecode the host wrote itself, never bytes from a document or the network. Throws a JsEngineError on an engine that has no bytecode, and for bytes it cannot read.
A host constructor: new makes a plain object and hands it to build to fill in.
A host function named name. body gets this and the arguments, and its answer goes back through Converters.
A promise the host settles later.
Runs whatever the promise callbacks have queued. Evaluating already drains the queue at the end of the call, so this is only for work queued from a host callback afterwards.
Whether obj has a callable then, read once, as a host call.
A Kotlin value as the engine sees it, collections and all. See Converters.