Skip to content

Instantly share code, notes, and snippets.

@neotyk
Created September 17, 2012 19:06
Show Gist options
  • Save neotyk/3739151 to your computer and use it in GitHub Desktop.
Save neotyk/3739151 to your computer and use it in GitHub Desktop.
WebSocket based browser-connected REPL
This ClojureScript REPL is able to work in restrictive environment, like Chrome Extension.
Requirements:
- WebSocket :: to receive JavaScript forms and send results back,
- 'unsafe-eval' :: Content Security Policy needs to allow 'unsafe-eval' for script-src
Security warning: Do *not* use in production!
Tested on Chrome, might work on other HTML5 enabled browsers.
;; Connecting browser to REPL server
(ns browser-start
(:require [haha.clojure.repl.ws-browser :as repl]))
(repl/connect "ws://localhost:8108/repl-socket")
;; Starting REPL server from Clojure
(ns repl-start
(:require [cljs.repl :as repl]
[haha.cljs.repl.ws-browser :as browser]))
(def env (browser/repl-env :port 8108))
(repl/repl env)
;; Connect your browser by running browser_start.cljs in your browser.
;; ClojureScript:> (+ 1 1)
;; 2
@aperiodic
Copy link

Where are the haha.* namespaces available? Are they on clojars?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment