Created
September 17, 2012 19:06
-
-
Save neotyk/3739151 to your computer and use it in GitHub Desktop.
WebSocket based browser-connected REPL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Connecting browser to REPL server | |
(ns browser-start | |
(:require [haha.clojure.repl.ws-browser :as repl])) | |
(repl/connect "ws://localhost:8108/repl-socket") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where are the
haha.*
namespaces available? Are they on clojars?