dirac

Dirac v1.7.2 is out: https://github.com/binaryage/dirac/releases/tag/v1.7.2
ksmithbaylor 2017-05-04T14:59:58.771607Z

I'm having some trouble using dirac with my figwheel project. Does anyone have time to help me out?

2017-05-04T15:00:21.785820Z

sorry, not right now, maybe in 2hrs

2017-05-04T15:00:33.792681Z

did you follow dirac-sample project?

2017-05-04T15:00:37.794655Z

does it work for you?

ksmithbaylor 2017-05-04T15:02:43.863565Z

Thanks! I've tried to incorporate the config from that project, but I'm fairly new to Clojure/ClojureScript and some of it is going over my head.

ksmithbaylor 2017-05-04T15:03:28.887669Z

I've got a :repl profile with the config from the sample project.

2017-05-04T15:05:27.949453Z

maybe you could simply share it on github, I would clone it and test on my machine, and help to fix it

ksmithbaylor 2017-05-04T15:05:33.952564Z

running lein repl successfully starts the dirac agent, but I'm not sure where figwheel comes in. Do I still run lein figwheel?

ksmithbaylor 2017-05-04T15:06:51.992543Z

Sure! that would be awesome if you've got some time. It's an electron project, originally forked from https://github.com/Gonzih/cljs-electron

ksmithbaylor 2017-05-04T15:08:07.031504Z

I replaced the Procfile with an npm start command. I'll add some notes to my readme about how to start up the project

ksmithbaylor 2017-05-04T15:08:20.038082Z

My project is here: https://github.com/ksmithbaylor/ynab-reports-cljs

2017-05-04T15:08:34.045358Z

to answer your question, yes, you still run lein figwheel, but figwheel should be configure just to hot-reloading, you don’t want figwheel’s REPL

ksmithbaylor 2017-05-04T15:09:00.058928Z

Yeah, I set :repl false in the figwheel config.

2017-05-04T15:10:35.107357Z

but I’m not sure about figwheel in electron context

ksmithbaylor 2017-05-04T15:10:35.107573Z

I just pushed up a dirac branch to my project with my initial attempts

ksmithbaylor 2017-05-04T15:11:44.142083Z

Yeah, it's a bit weird. if you have yarn (https://yarnpkg.com/en/docs/install) installed, you can start figwheel along with a process that starts/stops electron with yarn start

ksmithbaylor 2017-05-04T15:12:14.157632Z

after doing lein deps and yarn install at the project root

2017-05-04T15:12:20.161014Z

ok, looking at it, don’t have run-p, ah, ok

ksmithbaylor 2017-05-04T15:12:51.176844Z

I'm coming from the JS world, so yarn was the most natural way for me to set up the dev processes

2017-05-04T15:13:08.185926Z

ok, no prob, I’ve heard good things about it

ksmithbaylor 2017-05-04T15:13:14.188332Z

yeah 🙂

ksmithbaylor 2017-05-04T15:13:22.192575Z

thanks for taking the time, by the way!

2017-05-04T15:13:35.198732Z

sure, np

ksmithbaylor 2017-05-04T15:14:38.230374Z

So the electron process code is under electron_src, and the frontend code is under ui_src.

ksmithbaylor 2017-05-04T15:15:29.257028Z

There's also dev_src, which I haven't touched from the boilerplate. I'm not quite sure what its role is, but it starts figwheel/watch-and-reload so I suspect that may be what I'm missing.

2017-05-04T15:16:27.287245Z

well you have to start electron’s V8 with debugger port enabled, I don’t see it in the yarn start output

2017-05-04T15:16:41.293591Z

and then use normal chrome canary + dirac devtools extension to connect to it

ksmithbaylor 2017-05-04T15:17:23.313545Z

oh, ok! I'm adding flags to electron's V8 here: https://github.com/ksmithbaylor/ynab-reports-cljs/blob/master/electron_src/electron/core.cljs#L22

ksmithbaylor 2017-05-04T15:17:30.317104Z

I'll add the remote debugging flag

2017-05-04T15:17:59.331082Z

should be something like --remote-debugging-port=9222

ksmithbaylor 2017-05-04T15:18:38.352275Z

yep, I just added it. let's see....

ksmithbaylor 2017-05-04T15:19:12.369617Z

No luck after refreshing the dirac instance I have running from canary

2017-05-04T15:20:54.421059Z

that flag didn’t work, if it worked, this should be reachable: http://localhost:9222/json

ksmithbaylor 2017-05-04T15:21:24.436421Z

I actually do get a response from that url:

[ {
   "description": "",
   "faviconUrl": "<https://www.google.com/favicon.ico>",
   "id": "1d1cce81-40d3-4809-b1dd-9f63ffc6b32b",
   "title": "New Tab",
   "type": "page",
   "url": "<chrome://newtab/>"
}, {
   "description": "",
   "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:9222/devtools/page/d5d08ac7-2968-4426-bccb-4c4d8b4cf46b",
   "id": "d5d08ac7-2968-4426-bccb-4c4d8b4cf46b",
   "title": "#",
   "type": "page",
   "url": "<chrome-extension://kbkdngfljkchidcjpnfcgcokkbhlkogi/devtools/front_end/inspector.html?devtools_id=1&amp;dirac_flags=111111111&amp;ws=localhost%3A9222%2Fdevtools%2Fpage%2F1d1cce81-40d3-4809-b1dd-9f63ffc6b32b&amp;backend_api=1&amp;backend_css=1>",
   "webSocketDebuggerUrl": "<ws://localhost:9222/devtools/page/d5d08ac7-2968-4426-bccb-4c4d8b4cf46b>"
}, {
   "description": "",
   "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:9222/devtools/page/2d33482d-4781-40d2-887c-30f3547cf252",
   "id": "2d33482d-4781-40d2-887c-30f3547cf252",
   "title": "Dirac DevTools",
   "type": "background_page",
   "url": "<chrome-extension://kbkdngfljkchidcjpnfcgcokkbhlkogi/background.html>",
   "webSocketDebuggerUrl": "<ws://localhost:9222/devtools/page/2d33482d-4781-40d2-887c-30f3547cf252>"
}, {
   "description": "",
   "id": "1bbec51e-5363-4601-bec0-d83e7ef362c5",
   "title": "Worker pid:21621",
   "type": "service_worker",
   "url": "<https://www.google.com/_/chrome/newtab-serviceworker.js>"
}, {
   "description": "",
   "id": "ac371b30-1c12-4c5d-ab87-5ff531c65d3f",
   "title": "Worker pid:21621",
   "type": "service_worker",
   "url": "<https://www.google.com/_/chrome/newtab-serviceworker.js>"
} ]

2017-05-04T15:21:38.443111Z

ok, good, so I did, something wrong

ksmithbaylor 2017-05-04T15:22:03.455540Z

Although canary is also running with remote debugging enabled. Should I turn that off?

2017-05-04T15:22:03.455831Z

push your changes pls

2017-05-04T15:22:08.458363Z

no

ksmithbaylor 2017-05-04T15:22:15.461876Z

Okay, I'll push it up

2017-05-04T15:22:22.465625Z

you want dirac to connect to electron’s V8

ksmithbaylor 2017-05-04T15:22:36.472482Z

pushed

ksmithbaylor 2017-05-04T15:23:51.509682Z

So I just quit chrome canary, and the localhost:9222/json no longer returns a response. So it doesn't seem like Electron has remote debugging enabled after all

2017-05-04T15:24:09.518379Z

aha, so it was your canary

2017-05-04T15:24:12.520244Z

not electron

ksmithbaylor 2017-05-04T15:24:16.522242Z

Oh, I did the switch wrong

ksmithbaylor 2017-05-04T15:24:18.523178Z

hang on

2017-05-04T15:24:36.531772Z

ok, no problem, I really have to run (literally)

2017-05-04T15:24:41.534392Z

will be back in 1,5 hrs

ksmithbaylor 2017-05-04T15:24:56.542665Z

there we go! Sorry to keep you. I'll play with it some, I think you've got me going in the right direction

2017-05-04T15:24:58.543535Z

you have to make electrong expose remote debugging protocol at port 9222

ksmithbaylor 2017-05-04T15:25:05.547296Z

That's working now 🙂

2017-05-04T15:25:06.547451Z

and then dirac will attempt to connect to it

2017-05-04T15:29:31.683355Z

good luck, in troubles try to look here as well: https://github.com/binaryage/dirac/blob/master/docs/node.md and in the FAQ

2017-05-04T15:30:00.698206Z

internal devtools console of Dirac window could also give you some more info

ksmithbaylor 2017-05-04T15:44:15.132628Z

So by opening http://localhost:3449/index.html in canary, dirac is able to connect (with some obvious errors like require is not defined since it's no longer in electron). So that's good news! Just need to figure out how to bridge over to my other V8 instance.

ksmithbaylor 2017-05-04T15:44:40.144502Z

This is so cool 😄

richiardiandrea 2017-05-04T16:52:35.074858Z

is there something around for build clojurescript projects using npm or yarn already?

ksmithbaylor 2017-05-04T16:59:57.279458Z

@richiardiandrea not that I know of. I am still using leiningen, and just scripting it with yarn. But I know there's a lot of activity around tools like lumo that should theoretically provide a completely jvm-less build process for cljs

richiardiandrea 2017-05-04T17:00:25.294554Z

@ksmithbaylor thanks for confirming!

ksmithbaylor 2017-05-04T17:01:36.328196Z

@darwin so, quick update. I was able to connect to my electron process by going to http://localhost:9222 directly from canary (in a new tab). So remote debugging is definitely on and listening on the correct port. But Dirac still does not connect to it. I hovered over the tooltip (which had a red !), and saw the following error message:

ksmithbaylor 2017-05-04T17:02:41.358643Z

I confirmed that the debugger id (e5d4a406...) was the same one that showed up in the URL when I opened it in a new tab.

ksmithbaylor 2017-05-04T17:08:23.512721Z

Even though http://localhost:9222/json does in fact return json

2017-05-04T17:09:34.543576Z

I’m back

ksmithbaylor 2017-05-04T17:09:55.552692Z

Hey!

ksmithbaylor 2017-05-04T17:10:16.562541Z

My context list from that endpoint looks like:

[ {
   "description": "",
   "id": "e5d4a406-fcc3-4a7e-8859-1494c3daeee3",
   "title": "YNAB Helper",
   "type": "page",
   "url": "file:///Users/kevin/main/code/ynab-reports-cljs/resources/public/index.html"
} ]

ksmithbaylor 2017-05-04T17:10:28.567616Z

Is the fact that it's a file:// url messing it up?

2017-05-04T17:12:23.618296Z

I don’t know, but you are correct that the code you pointed out is responsible from selecting correct backend-url from the JSON

2017-05-04T17:12:51.630922Z

recently I have added a support for node situation, but I’ve never tested it with electron

2017-05-04T17:13:25.645530Z

but we can select it manually as well, let me look it up[

ksmithbaylor 2017-05-04T17:16:16.720545Z

Seems like if another condition were added to that or to account for this case, it might help

2017-05-04T17:16:57.737948Z

yes, currently dirac looks at your “app’s web page url” and tries to find a record in that JSON which matches it

2017-05-04T17:17:24.750590Z

the problem with node was that the record had file-system path instead of url, if I recall correctly

2017-05-04T17:17:33.754359Z

and with electron it is I guess something similar

2017-05-04T17:17:44.759453Z

it does not match perfectly according to dirac rules

ksmithbaylor 2017-05-04T17:18:23.777785Z

The html page is served from the filesystem, but loading that url (file:///Users/kevin/main/code/ynab-reports-cljs/resources/public/index.html) in a new tab does load the page

ksmithbaylor 2017-05-04T17:19:49.815512Z

Strange, it does match that URL exactly

2017-05-04T17:19:50.816142Z

that does not work in this case, :url of your electron’s context is file:///Users/darwin/farm/ynab-reports-cljs/resources/public/index.html

2017-05-04T17:20:22.830084Z

so it falls back to node-js resolution, as you correctly figured out

2017-05-04T17:21:08.850732Z

and node-js resolution, takes only :type “node” contexts for consideration: https://github.com/binaryage/dirac/blob/master/src/background/dirac/background/debugging.cljs#L64

2017-05-04T17:21:13.852767Z

so it also fails

2017-05-04T17:21:30.860462Z

so we need to add special case there, or make the main resolution more flexible

ksmithbaylor 2017-05-04T17:21:36.862522Z

oh, got it.

2017-05-04T17:22:02.874129Z

but I can give you a work around for now

2017-05-04T17:23:02.901100Z

<chrome-extension://kbkdngfljkchidcjpnfcgcokkbhlkogi/devtools/front_end/inspector.html?devtools_id=1&amp;dirac_flags=111111111&amp;ws=localhost%3A9222%2Fdevtools%2Fpage%2Ffe0a4e3e-78dd-462b-b140-e2a83a4a24e9&amp;backend_api=1&amp;backend_css=1>

2017-05-04T17:23:16.906967Z

open it in your canary in a blank window as normal url

2017-05-04T17:23:42.918571Z

replace extension id with your dirac extension id, and ws parameter with ws parameter you can see in the JSON

2017-05-04T17:24:26.937995Z

this should start it, but then you will probably have another problem - V8 in electron is probably quite old (several months) but devtools code in dirac is bleeding edge

2017-05-04T17:24:47.947589Z

you might need to downgrade dirac extension to similar version of your debugger protocol

2017-05-04T17:24:53.950259Z

see the FAQ

2017-05-04T17:25:01.953635Z

have to go, will be back in 30mins

ksmithbaylor 2017-05-04T17:25:17.961361Z

Okay, thanks again!

2017-05-04T18:05:43.072128Z

I’m back again, did it work?

2017-05-04T18:11:39.230178Z

this url somewhat works for me <chrome-extension://kbkdngfljkchidcjpnfcgcokkbhlkogi/devtools/front_end/inspector.html?devtools_id=1&amp;dirac_flags=111111111&amp;ws=localhost:9222/devtools/page/df847fdd-c60e-4781-9281-0f8038df9835>

ksmithbaylor 2017-05-04T18:12:01.240541Z

I had to step away, and I'm having trouble spinning everything up again.

2017-05-04T18:12:07.243036Z

it still spits some compatibility errors

ksmithbaylor 2017-05-04T18:12:12.245589Z

Do I need to start figwheel first, or lein repl?

2017-05-04T18:12:23.249910Z

important point is to close Electron’s app devtools

2017-05-04T18:12:38.255869Z

only one debugger protocol client can be connected

ksmithbaylor 2017-05-04T18:13:32.279564Z

I had to start canary with a different remote debugger port (I chose 9223) in order for my electron context to show up as inspectable from localhost:9222

2017-05-04T18:14:01.292498Z

you don’t need to open debugger port on canary (in your scenario)

2017-05-04T18:14:36.307567Z

that’s needed only in normal scenario where you are connecting back to the same canary to debug pages in

ksmithbaylor 2017-05-04T18:14:53.315522Z

There we go! I think I'm seeing the same thing you are now. Some compatibility issues, but mostly working!

2017-05-04T18:15:11.323894Z

I see: Request Overlay.enable failed

2017-05-04T18:15:19.327497Z

and: Request Overlay.setShowViewportSizeOnResize failed

ksmithbaylor 2017-05-04T18:15:20.327882Z

I think downgrading dirac to match the V8 in electron should resolve that, right?

ksmithbaylor 2017-05-04T18:15:25.330178Z

yep, I'm seeing those two as well

2017-05-04T18:15:48.339890Z

yes, depends how old it is, devtools support node.js since january

2017-05-04T18:16:01.346058Z

if it is older than that, you are probably out of luck

ksmithbaylor 2017-05-04T18:16:18.353516Z

I'll check

2017-05-04T18:16:35.360680Z

also you have to run lein repl with dirac agent installed inside your nrepl server

2017-05-04T18:16:54.369436Z

and that does not seem to be the case in current code

2017-05-04T18:17:34.386742Z

wait, I will run it on the side

ksmithbaylor 2017-05-04T18:17:37.388063Z

hmm. I thought that's what my :repl settings did

ksmithbaylor 2017-05-04T18:17:59.398284Z

Is there a way to avoid needing to run lein figwheel and lein repl separately?

2017-05-04T18:18:49.420835Z

ok, repl works, I just thought you have it inside your yarn start

2017-05-04T18:19:11.430779Z

I mean Dirac’s REPL was able to connect to lein repl+dirac-agent

2017-05-04T18:20:11.457594Z

it has some problem with source maps as well….

ksmithbaylor 2017-05-04T18:20:23.464520Z

right. I'll add it to my yarn start to automate it. Any difference as far as which one needs to run first? (figwheel vs repl)

2017-05-04T18:20:23.464641Z

I got tons of errors

ksmithbaylor 2017-05-04T18:20:27.466570Z

Yeah, same here 😕

ksmithbaylor 2017-05-04T18:20:38.473333Z

I may not have source maps configured in my project

2017-05-04T18:20:51.482560Z

there should be no difference

2017-05-04T18:21:19.497400Z

figwheel is your compiler, so it should finish its job before you load the page, repl is independent

ksmithbaylor 2017-05-04T18:21:49.510707Z

I see

2017-05-04T18:23:13.549007Z

to fix the source-maps issue, you would need to somehow tell electron to put there relative urls instead of full file-system paths

2017-05-04T18:23:44.563112Z

or maybe cljs compier

ksmithbaylor 2017-05-04T18:23:54.567553Z

Would it work to make them inline source maps?

2017-05-04T18:24:21.580132Z

to inline source-maps you would have use my patch CLJS-1902

2017-05-04T18:25:15.604226Z

it is doable

ksmithbaylor 2017-05-04T18:25:31.611097Z

I'll try the separate sourcemap server approach

2017-05-04T18:26:22.636530Z

node.js had the same issue

ksmithbaylor 2017-05-04T18:31:46.787003Z

Figwheel doesn't like :source-map-asset-path:

2017-05-04T18:32:22.803492Z

hm, that’s figwheel’s problem, it should be just a warning

ksmithbaylor 2017-05-04T18:34:50.871504Z

Seems like it's changed to :source-map-path recently

2017-05-04T18:35:01.876507Z

I doubt

2017-05-04T18:35:40.894620Z

those are different options

ksmithbaylor 2017-05-04T18:35:53.899951Z

oops

2017-05-04T18:36:27.916622Z

it is not used very often, for me this was the first case I needed it

ksmithbaylor 2017-05-04T18:39:23.994197Z

PR made: https://github.com/bhauman/lein-figwheel/pull/550

👍 1
2017-05-04T18:48:12.229560Z

looks like upgrade to chrome 58 is a work in progress: https://github.com/electron/electron/tree/chrome58

2017-05-04T18:48:22.233946Z

which would be 58.0.3029.96

ksmithbaylor 2017-05-04T18:48:46.244907Z

cool!

2017-05-04T18:48:58.250307Z

that would roughly match https://github.com/binaryage/dirac/releases/tag/v1.2.0

2017-05-04T18:49:24.262238Z

but they are not there yet, so right now you should try to go with some earlier versions

ksmithbaylor 2017-05-04T18:50:00.278214Z

Yeah. Well I think I'm in good shape for now, sans a few minor issues. Thank you so much for taking the time to help me out!

2017-05-04T18:50:53.302620Z

I’m glad I could help, I was curious myself, unfortunately I’ve never tried dirac + electron, and probably nobody else

ksmithbaylor 2017-05-04T18:51:00.305725Z

lol yeah

ksmithbaylor 2017-05-04T18:51:09.309689Z

it's a subset of a subset of a small community

2017-05-04T18:51:37.322110Z

so you are exploring wild area here 🙂 and give that you just started with cljs and whole tooling around it, well played 🙂

ksmithbaylor 2017-05-04T18:51:44.325686Z

haha thanks

2017-05-04T18:52:14.338756Z

also electron, devtools and chrome are all in constant flux, that does not add to robustness 🙂

2017-05-04T18:52:49.354741Z

so expect breakages along the way, the most important is to keep versions relatively close together, here you must follow electron

ksmithbaylor 2017-05-04T18:54:27.399223Z

So out of curiosity, do you know of any other ways I could get a nicer cljs repl than the built-in terminal one? I'm mostly fine with the normal cljs devtools, and was mostly looking to dirac to get a nicer gui experience for my repl

ksmithbaylor 2017-05-04T18:55:04.416026Z

Since this is sort of unknown territory, I may stick with the normal cljs devtools and (now that I have nrepl working) explore other options for a repl

2017-05-04T18:55:06.416975Z

maybe in this case I would stick with Figwheel’s Terminal REPL

2017-05-04T18:55:14.420464Z

and use embedded electron’s devtools

ksmithbaylor 2017-05-04T18:55:18.422466Z

yeah

2017-05-04T18:55:24.424838Z

you will avoid a lot of headaches

ksmithbaylor 2017-05-04T18:55:41.432338Z

yes.

2017-05-04T18:56:03.442627Z

btw. I just checked navigator.userAgent in that electron app: “Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) ynab-helper/0.1.0 Chrome/56.0.2924.87 Electron/1.6.7 Safari/537.36”

2017-05-04T18:56:14.447469Z

Chrome/56.0.2924.87 is damn old

ksmithbaylor 2017-05-04T18:56:19.450016Z

lol yeah

ksmithbaylor 2017-05-04T18:56:24.451995Z

in internet years at least 😛

2017-05-04T18:57:20.477453Z

that would match https://github.com/binaryage/dirac/releases/tag/v0.8.4 from November

2017-05-04T18:58:53.518714Z

one last recommendation: you definitely want to use https://github.com/binaryage/cljs-devtools

ksmithbaylor 2017-05-04T19:01:04.579785Z

yep! I'm already using that, and it's awesome! The "What's next?" at the bottom is what lead me to dirac

✅ 1
piotr-yuxuan 2017-05-04T20:51:05.301967Z

Hey @darwin, I’ve put my current tooling in a gist. Would you mind gaze on it and tell me what you think about this current setup? It’s rather scarse so a reader with no prior context would find it uneasy to grasp but I think you’ll understand this better than I ^^

2017-05-04T20:51:49.319775Z

ok

👍 1
piotr-yuxuan 2017-05-04T20:56:51.443126Z

(ha yeah, a link would be helpful ^^)

2017-05-04T21:00:30.536465Z

doesn’t re-frisk support preloads? that would be useful for :advanced builds

2017-05-04T21:08:10.714709Z

@piotr2b it looks good to me, I haven’t had chance to use re-frisk yet, also reloaded.repl is a new thing to me, will look into that

piotr-yuxuan 2017-05-04T21:38:44.358080Z

Indeed, you’re right about preloads for re-frisk. I opened an issue to ask them about it.

piotr-yuxuan 2017-05-04T21:42:32.431652Z

thanks for your review 🙂

2017-05-04T21:43:06.442254Z

np, good luck and keep us updated about cool tools you find