dirac
dirac copied to clipboard
Add electron support
Hello! I'm playing around with shadow-cljs + electron (which seems to work really nice!). dirac seems like it would benefit me greatly, so I tried adding it using electrons BrowserWindow.addDevToolsExtension(path)
(api docs here).
Sadly I get this error, and I'm unable to figure out what's going wrong:
Uncaught Exception:
TypeError [ERR_INVALID_ARG_TYPE] [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
at validateString (internal/validators.js:105:11)
at Object.join (path.js:1037:7)
at startBackgroundPages (/Users/<omitted>/examples/electron/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/browser/chrome-extension.js:80:33)
at loadExtension (/Users/<omitted>/examples/electron/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/browser/chrome-extension.js:288:3)
at Function.BrowserWindow.addExtension (/Users/<omitted>/examples/electron/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/browser/chrome-extension.js:378:7)
at Function.BrowserWindow.addDevToolsExtension (/Users/<omitted>/examples/electron/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/browser/chrome-extension.js:408:40)
at Object.example$main$create_window [as create_window] (/Users/<omitted>/examples/electron/.shadow-cljs/builds/main/dev/out/cljs-runtime/example.main.js:30:46)
at App.example$main$maybe_create_window (/Users/<omitted>/examples/electron/.shadow-cljs/builds/main/dev/out/cljs-runtime/example/main.cljs:51:3)
at App.emit (events.js:194:13)
I've successfully used the react dev tools extension, so I don't think I'm doing anything wrong on my end.
Any help or suggestions is very appreciated. :)
Hi, I very much doubt it could work this way. According to my past experience the browser engine shipped with Electron is usually several months older than current Chrome Canary. This is definitely a deal breaker: https://github.com/binaryage/dirac/blob/master/docs/faq.md#why-should-i-use-recent-chrome-canary-with-dirac-devtools.
In theory you could be able to find past Dirac version which would match browser engine in your particular Electron version. But still I think there could be other issues.
I'm personally not going to add Electron support to Dirac. If someone would add it and commit to supporting it, I would consider merging a PR.
Have started to investigate this in the context of getting something to work for developing VSCode extensions in Clojurescript.
I got as far as obtaining a Chromium / dirac pair, but encountered difficulty in running the dirac-sample during its lein repl step. Below is a summary:
- Try to identify relevant version of Electron. I looked at:
https://code.visualstudio.com/updates/v1_36
and noted:
Electron 4.0 update and Electron 6.0 exploration
In this milestone, we finished the exploration of bundling Electron 4 into VS Code, making it the first time this Electron version ships with stable.
So it seemed that Electron 4.0 might be relevant.
- Try to identify relevant version of Chromium. I looked at:
https://github.com/Kilian/electron-to-chromium/blob/master/versions.js
and noted:
module.exports = {
"6.0": "76",
"5.0": "72",
"4.2": "69",
"4.1": "69",
"4.0": "69",
So it seemed like some Chromium 69 might be relevant.
- Try to identify which dirac version to try. I looked at:
https://github.com/binaryage/dirac/releases/tag/v1.2.36
and noted:
Should work best with Chrome ~69.0.3485.1.
Also picked up a zip file of the dirac extension for later manual installation.
- Try to obtain specific Chromium. I looked at the section titled "Downloading old builds of Chrome / Chromium" at:
https://www.chromium.org/getting-involved/download-chromium
and adapted its instructions to first look at:
https://omahaproxy.appspot.com/
entering "69.0.3485.1" in the Version field within the "Version Information" box. This yielded:
Branch Base Position 573176
Then visiting:
https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html
I navigated to "Mac", and entered 573176 in the Filter field and (after some wait) received the URL:
https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Mac/573176/
Visiting it, was able to find a link to chrome-mac.zip, which I downloaded.
- Try to run dirac-sample demo. I cloned the dirac-sample, checked its git log to identify the commit that corresponds to 1.2.36. This looked to be:
22b01be8f8de14054f057fe0ea341ef378f3828f
After a git checkout of this commit, attempted to follow the steps for running the demo. Started the obtained Chromium using the remote debugger port and specifying a custom profile. I manually installed the matching dirac Chrome extension (obtained in step 3 and unzipped) via chrome://extensions/ (enabling dev mode first, etc.) I ran lein demo from a terminal and waited for it to execute the dev-server.sh (web server) step. Then I ran lein repl from another terminal and got:
[WARNING] No nREPL middleware descriptor in metadata of #'dirac.nrepl/middleware, see nrepl.middleware/set-descriptor!
nREPL server started on port 8230 on host 127.0.0.1 - nrepl://127.0.0.1:8230
ERROR: Unhandled REPL handler exception processing message {:id 9b94bd2f-743d-425e-b308-446962134c3a, :op describe}
java.lang.NullPointerException
at clojure.core$swap_BANG_.invokeStatic(core.clj:2346)
at clojure.core$swap_BANG_.invoke(core.clj:2337)
at dirac.nrepl.state$register_last_seen_nrepl_message_BANG_.invokeStatic(state.clj:52)
at dirac.nrepl.state$register_last_seen_nrepl_message_BANG_.invoke(state.clj:49)
at dirac.nrepl.state$register_last_seen_nrepl_message_BANG_.invokeStatic(state.clj:50)
at dirac.nrepl.state$register_last_seen_nrepl_message_BANG_.invoke(state.clj:49)
at dirac.nrepl.piggieback$handler_job_BANG_.invokeStatic(piggieback.clj:93)
at dirac.nrepl.piggieback$handler_job_BANG_.invoke(piggieback.clj:92)
at dirac.nrepl.piggieback$dirac_nrepl_middleware_handler.invokeStatic(piggieback.clj:104)
at dirac.nrepl.piggieback$dirac_nrepl_middleware_handler.invoke(piggieback.clj:100)
at clojure.core$partial$fn__5561.invoke(core.clj:2616)
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__2135.invoke(middleware.clj:22)
at nrepl.server$handle_STAR_.invokeStatic(server.clj:18)
at nrepl.server$handle_STAR_.invoke(server.clj:15)
at nrepl.server$handle$fn__1101.invoke(server.clj:27)
at clojure.core$binding_conveyor_fn$fn__5476.invoke(core.clj:2022)
at clojure.lang.AFn.call(AFn.java:18)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Any hints as to things I might have done wrong or suggestions?
I can also try under Windows (though I think I need to create an appropriate dev-server.bat there at least) and some Linux distribution, but IIUC the primary development platform for dirac is macos.