All Projects → binaryage → dirac-sample

binaryage / dirac-sample

Licence: other
An example integration of Dirac DevTools

Programming Languages

clojure
4091 projects
HTML
75241 projects
shell
77523 projects
CSS
56736 projects

Projects that are alternatives of or similar to dirac-sample

replbot
Slack/Discord bot for running interactive REPLs and shells from a chat.
Stars: ✭ 169 (+894.12%)
Mutual labels:  repl
hotelier
Tray App for Hotel Process Manager
Stars: ✭ 46 (+170.59%)
Mutual labels:  devtools
stackOverflow focus
Remove all unnecessary clutter when looking for help on StackOverflow through a Chrome plugin.
Stars: ✭ 58 (+241.18%)
Mutual labels:  devtools
ws-repl
MIGRATED TO https://vcs.rowanthorpe.com/rowan/ws-repl - THIS IS AN ARCHIVED VERSION... Arbitrary REPL in a web-page using websocketd
Stars: ✭ 38 (+123.53%)
Mutual labels:  repl
nim-noise
Nim implementation of linenoise command line editor
Stars: ✭ 45 (+164.71%)
Mutual labels:  repl
clockwork-firefox
Clockwork - php dev tools integrated to your browser - Firefox add-on
Stars: ✭ 22 (+29.41%)
Mutual labels:  devtools
gitcount
A command-line tool to estimate the time spent on a git project, based on a very simple heuristic
Stars: ✭ 25 (+47.06%)
Mutual labels:  devtools
devtools-tips
A collection of useful cross-browser DevTools tips
Stars: ✭ 81 (+376.47%)
Mutual labels:  devtools
huginn
Programming language with no quirks, so simple every child can master it.
Stars: ✭ 41 (+141.18%)
Mutual labels:  repl
ocamline
👨🏻‍💻 Command line interface for user input
Stars: ✭ 32 (+88.24%)
Mutual labels:  repl
rx-devtools
DevTools for RxJS
Stars: ✭ 30 (+76.47%)
Mutual labels:  devtools
svelte-toy
A toy for svelte data stores
Stars: ✭ 73 (+329.41%)
Mutual labels:  devtools
Replay.jl
Replay your REPL instructions
Stars: ✭ 24 (+41.18%)
Mutual labels:  repl
lambda
lambda calculus interpreter
Stars: ✭ 23 (+35.29%)
Mutual labels:  repl
Clojure-Sublimed
Clojure support for Sublime Text 4
Stars: ✭ 268 (+1476.47%)
Mutual labels:  repl
devtools
A simple set of tools for teams building live Carbon pages.
Stars: ✭ 31 (+82.35%)
Mutual labels:  devtools
vue-code-view
A Vue 2 component like Vue SFC REPL `@vue/repl` : u can edit, run and preview the code effect display in real time on the web page.
Stars: ✭ 67 (+294.12%)
Mutual labels:  repl
ShenScript
Shen for JavaScript
Stars: ✭ 40 (+135.29%)
Mutual labels:  repl
flip
Simple, lightweight, virtual IP management utility for moving IPs around nodes in response to cluster events.
Stars: ✭ 23 (+35.29%)
Mutual labels:  devtools
python-ls
Think about Python's dir builtin with recursive search capabilities
Stars: ✭ 44 (+158.82%)
Mutual labels:  devtools

This project is deprecated since Dirac v1.4.0

Please use Dirac integration examples in

https://github.com/binaryage/dirac/tree/master/examples




dirac-sample GitHub license

This project is an example of integration of Dirac DevTools into a Leiningen-based ClojureScript project.

Local setup

git clone https://github.com/binaryage/dirac-sample.git
cd dirac-sample

Demo time!

Installation

Launch latest Chrome Canary from command-line. I recommend to run it with a dedicated user profile, because you will install there a helper Chrome Extension. Also you have to run it with remote debugging enabled on port 9222 (better make an alias of this command):

/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary \
  --remote-debugging-port=9222 \
  --no-first-run \
  --user-data-dir=.test-dirac-chrome-profile

Now you can install the Dirac DevTools Chrome extension.

After installation, should see a new extension icon next to your address bar .

Now you can launch the demo project from terminal:

lein demo

At this point you should have a demo website running at http://localhost:9977.

Please navigate there, do not open internal DevTools and click Dirac icon while on the http://localhost:9977/demo.html page. It should open you a new window with Dirac DevTools app. It will look almost the same as internal DevTools, but you can tell the difference at first glance: active tab highlight will be green instead of blue (see the screenshots above).

Ok, now you can switch to Javascript Console in Dirac DevTools. Focus prompt field and press CTRL+, or CTRL+.. This will cycle between Javascript to ClojureScript REPL prompts.

You should see a red message on a green background: Dirac Agent is not listening at ws://localhost:8231 (need help?).

That's correct. Dirac REPL uses nREPL protocol so we have to provide it with some nREPL server. Luckily enough leiningen offers nREPL server by simply running (in a new terminal session):

lein repl

The terminal should print something similar to this:

Compiling ClojureScript...
nREPL server started on port 8230 on host 127.0.0.1 - nrepl://127.0.0.1:8230
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.8.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_60-b27
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=>
Dirac Agent v0.5.0
Connected to nREPL server at nrepl://localhost:8230.
Agent is accepting connections at ws://localhost:8231.

Last three lines ensure you that Dirac Agent was launched alongside your nREPL server. It connected to it and is accepting DevTools connections on the websocket port 8231.

After your Dirac Agent is up your Dirac DevTools should eventually reconnect.

Connected? The red message should go away and you should see cljs.user indicating your current namespace. REPL is ready for your input at this point. You can try:

(+ 1 2)
js/window
(doc filter)
(filter odd? (range 42))

If you see something very similar to the first screenshot at the top, you have Dirac running properly.

Congratulations!

Hello, World!

Let's try to call hello! function from our namespace dirac-sample.demo.

(dirac-sample.demo/hello! "World")

It worked "Hello, World!" was logged into the console (white background means that the logging output originated in Javascript land).

As you probably know you should first require (or eval) namespace in the REPL context to make it aware of namespace content.

(require 'dirac-sample.demo)

But still you have to type fully qualified name because currently you are in cljs.user namespace. To switch you can use in-ns special function.

Let's try it:

(in-ns)

You get an error java.lang.IllegalArgumentException: Argument to in-ns must be a symbol.. This is a Java exception from nREPL side. Execute (doc in-ns) to see the documentation for this special REPL function. It expects namespace name as the first argument.

(in-ns 'dirac-sample.demo)
(hello! "Dirac")

Should log Hello, Dirac! into the console without warnings.

Breakpoints

You can also test evaluation of ClojureScript in the context of selected stack frame when paused on a breakpoint:

  1. click the "demo a breakpoint" button on the page
  2. debugger should pause on the (js-debugger) line in the breakpoint-demo function

Custom formatters should be presented as inlined values in the source code. Also property names in the scope panel are sorted and displayed in a more friendly way.

Now hit ESC to bring up console drawer. Make sure you are switched to Dirac REPL and then enter:

numbers

You should see actual value (0 1 2) of the numbers variable from local scope (formatted by custom formatters from cljs-devtools). Same way as you would expect when evaluating a Javascript command in a breakpoint context. Actually you can try it. Hit CTRL+. to switch to Javascript console prompt (white background) and enter:

numbers

This should return the same output.

And now return back to Dirac REPL by pressing CTRL+. again and enter:

(str (map inc numbers))

You should get back a string "(1 2 3)".

This is a proof that Dirac REPL can execute arbitrary ClojureScript code in the context of a selected stack frame.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].