Comments (4)
shadow-remote-msg
is just an envelope and it expects an encoded field, as long as you send this its fine.
;; valid
{:op "shadow-remote-msg"
:data "{:op :request-clients :notify true :query [:eq :type :runtime]}"}
;; NOT valid
{:op "shadow-remote-msg"
:data {:op :request-clients :notify true :query [:eq :type :runtime]}}
from shadow-cljs.
Most is probably already available. Just a tad different than you are proposing here. I opened #990 for this but nobody showed any interest, so I closed it after a year. As described in that issue shadow.remote
powers all remote interactions that shadow-cljs has. The entire UI runs over it, as does the nREPL implementation.
For example over nrepl send the following:
{:op "shadow-remote-init" :data-type "edn"}
That just sets up the connection, required to send this once before anything else.
Then you can send (no clue how you'd do an actual pr-str
in cider)
{:op "shadow-remote-msg"
:data (pr-str {:op :request-clients
:notify true
:query [:eq :type :runtime]})}
;; so this, not a literal (pr-str ...)
{:op "shadow-remote-msg"
:data "{:op :request-clients :notify true :query [:eq :type :runtime]}"}
:request-clients
will cause the relay to send you all clients it knows about.:notify
controls whether you want to be notified about changes (disconnect/connects):query
is a very simplistic edn based query language
This example you only get clients that identify as a :runtime
(aka CLJ(S) runtimes), otherwise you also get yourself and the UI connections and so on. Which is fine but probably not something you are interested in. You can also limit it to specific builds, but the client info will also contain the build-id so sending this once is probably better than sending it per build.
On the receiving end you'll get {:op "shadow-remote-msg" :data "edn-encoded-string"}
messages, that should be self explanatory. There will be a :op :welcome
message, and the result for :request-clients
is just :op :clients
and :op :notify
for updates.
I don't know what the state of EDN encoding/decoding is in cider, another available option is :data-type "transit"
. shadow.remote
only understands EDN type data, so JSON/bencode or others are not supported and I'm not really interested in adding support for them, since shadow.remote
needs actual EDN data (eg. keywords).
I can list some more common :op
(e.g. eval, getting build infos, etc) if this is something that would work for your usecase. Since shadow-cljs uses this extensively itself pretty much everything is available, although often optimized for what the UI needs.
from shadow-cljs.
You could also just skip nrepl and directly connect to the websocket if cider/emacs supports that, nREPL
really doesn't bring much to the table in this regard. The messages you'll exchange are the same though, so doesn't matter too much.
from shadow-cljs.
#990 sounds fully workable to me.
I'm not sure about the need for pr-str
. As far as I know, you can attach arbitrary data over an nREPL message, at least for Clojure's basic data types. 'Bencoding' would take care of the rest.
But pr-str is certainly OK. You can send edn-encoded strings, and we would decode it CIDER side with https://github.com/clojure-emacs/parseedn which is a trusted solution.
You could also just skip nrepl and directly connect to the websocket if cider/emacs supports that
Emacs being such a quirky piece of software, I'd prefer it we sticked to nREPL so that we can reuse all our tech and knowledge.
Thanks!
-V
from shadow-cljs.
Related Issues (20)
- Warnings on using decprecated-fn in a deprecated-fn HOT 3
- CLJS build failure HOT 2
- class shadow.undertow$fn$reify__11358 cannot be cast to class clojure.lang.Var$Frame HOT 3
- Requiring a namespace with an underscore instead of dash gets par-compile stuck
- :js-provider :external should support :modules
- Mention that build report only works for :browser target HOT 9
- Issue with CORS in dev HTTP server since 2.25.10 release HOT 2
- :module-hash-names doesn't work with :web-worker true
- Build report for :node-library builds needlessly requires :output-dir
- Preloads with a top-level namespace don't load macros HOT 3
- 2.26.5 incorrectly tagging @dagrejs/dagre npm module js file as es3 HOT 2
- date-fns v3.3.1 and shadow-cljs 2.26.5 to 2.26.6 triggers ICE HOT 2
- Compiling squint-cljs (via @nextjournal/clojure-mode) on 2.27.1 throws ICE HOT 14
- npm-module exports vars in random order with large namespaces HOT 2
- Check namespaced keywords for build ids
- More readable error log with pre-line for browser-test HOT 3
- Srting handling different to clj HOT 1
- `Caused by: java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.tools.analyzer.utils/update-vals` when trying to import a dependency via git HOT 9
- #shadow/env not working in ~/.config/shadow-cljs/config.edn? HOT 7
- How to debug the par-compiler for :cache-level :all HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shadow-cljs.