hara.runtime.js-playground
Browser playground runtime backed by a WebSocket connection.
Unlike the runtimes in hara.runtime.basic, which target generic JS evaluation environments, this runtime is purpose-built for the browser. It starts an http-kit server, serves a generated HTML page with a split-screen React UI, and evaluates Clojure forms sent over /ws live in the browser.
invoke-ptr-js-playground
added in 4.0
(invoke-ptr-js-playground rt ptr args)invoke for js playground runtime
page-html
added in 4.0
(page-html {:keys [title head body tabs]})renders the js playground page using std.html
Accepts :title, :head, :body and :tabs. Tabs are maps of {:id … :label …} exposed to the client through window.PLAYGROUND_CONFIG.
play-file
added in 4.0
(play-file {:keys [root]} & paths)gets the file path in the js playground runtime’s served root
play-page
added in 4.0
(play-page rt m & [as-script])creates a page asset in the js playground runtime’s served root
play-script
added in 4.0
(play-script rt forms & [as-script layout])emits Clojure forms to JavaScript and writes the script into the served root.
With as-script (truthy), returns the raw JS string instead of the filename.
play-url
added in 4.0
(play-url {:keys [host port]})gets the js playground url for a runtime instance
The returned URL is reachable on the local network so a browser can load the page and connect back over the WebSocket.
playground-client-script
added in 4.0
(playground-client-script)emits the browser-side React playground app as JS via hara.lang.
The client lives in hara.runtime.js-playground.client and is compiled to a single ES module with js.react for the UI and xt.lang.common-lib/return-eval for safe eval.
raw-eval-js-playground
added in 4.0
(raw-eval-js-playground {:keys [channel return process], :as rt} body)raw eval for js playground runtime
Sends the emitted JS body to the connected browser and returns the parsed result, or a status map when disconnected or timed out.
rt-js-playground
added in 4.0
(rt-js-playground {:keys [id lang runtime process], :as m})creates and starts a js playground runtime
rt-js-playground-string
added in 4.0
(rt-js-playground-string {:keys [id lang port host]})string representation of the js playground runtime
rt-js-playground:create
added in 4.0
(rt-js-playground:create {:keys [id lang runtime process], :as m, :or {runtime :playground}})creates a js playground runtime
start-js-playground
added in 4.0
(start-js-playground {:keys [id port host title tabs], :as rt})starts the js playground server and returns the runtime with state attached
stop-js-playground
added in 4.0
(stop-js-playground {:keys [channel stop], :as rt})stops the js playground server