You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 11, 2022. It is now read-only.
The JavaScript Engine library (jse) provides an Actor based abstraction so that JavaScript code can be
executed in a browser-less fashion. In-jvm support is provided in the form of Trireme,
a Node API for Rhino. Standalone Rhino is also supported with a RhinoShell environment.
Native JavaScript performance is provided by using
Common Node,
node.js and
PhantomJS (these latter 3 are required to be installed separately).
While multiple engines are provided, plugin authors are encouraged to target the Node API. Doing so means that the
engine options generally come down to Trireme and Node, depending on whether in-JVM or native support is required. Trireme
is therefore provided as a default as there should be no JS coding differences between Trireme and Node, and Trireme
requires no manual installation.
Sample usage can be obtained by inspecting the js-engine-tester sub-project. There's a main class that
illustrates essential interactions. Here is a snippet of it:
val engine = system.actorOf(Node.props(), "engine")
val f = new File(Main.getClass.getResource("test.js").toURI)
for (
result <- (engine ? Engine.ExecuteJs(f, Seq("999"))).mapTo[JsExecutionResult]
) yield {
println(new String(result.output.toArray, "UTF-8"))
...
An additional sbt-js-engine sub-project is provided that declares a base for sbt plugins that use the engine.
This sub-project has a separate release cycle to jse itself and could be spun off into its own repo at a later
point in time e.g. if/when Maven/Gradle support is required. The main point here is that the core JavaScript engine
library is not related to sbt at all and should be usable from other build tools.