nrepl

https://github.com/nrepl/nrepl || https://nrepl.org
lilactown 2019-04-08T14:36:25.001700Z

I’m considering trying to connect to nREPL from a web app / chrome extension for a project. is there any prior art for something like this?

dominicm 2019-04-08T14:36:42.002200Z

Drawbridge I think

lilactown 2019-04-08T14:36:44.002300Z

I’m looking at drawbridge, which seems like it might be the way to go.

lilactown 2019-04-08T14:36:45.002500Z

yeah

lilactown 2019-04-08T14:37:19.003Z

I’m a bit bummed that it requires a separate dep. the dream would be that I could just connect to any old nREPL server

shen 2019-04-08T14:41:21.004100Z

Think the fundamental limit is that a web app will need to speak http or ws

shen 2019-04-08T14:51:02.006800Z

and I don't think Java standard libraries provide either of those.

lilactown 2019-04-08T14:52:54.008700Z

yeah. I wish there was some way for Chrome to connect to a regular ol’ socket 😭 pulling in an HTTP server for every project using nREPL seems potentially problematic

bozhidar 2019-04-08T14:56:49.009Z

> I’m a bit bummed that it requires a separate dep. the dream would be that I could just connect to any old nREPL server (edited)

bozhidar 2019-04-08T14:57:39.009900Z

That’s hard to do as you need to bundle somehow an HTTP server with the REPL. Leiningen used to ship Drawbridge at some point, but I’m not sure if that’s still the case.

bozhidar 2019-04-08T14:58:43.010700Z

In theory we could have a trivial self-contained http implementation bundled with nREPL, but there never was a lot of demand for this.

lilactown 2019-04-08T15:00:35.011200Z

makes sense.

lilactown 2019-04-08T15:03:45.012700Z

would you take a PR with something like that? I might be able to put something together, but I also understand if it’s just increasing surface area to support for something not many other people need

shen 2019-04-08T15:04:59.013400Z

what's the usecase here, @lilactown?

lilactown 2019-04-08T15:05:26.013800Z

I’m working on some devtooling a la REBL for the browser

lilactown 2019-04-08T15:07:04.014800Z

I previously implemented my own shoddy protocol on top of websockets for Node.js / JVM, but I was thinking i might be able to simplify my life by just connecting directly to a REPL

dominicm 2019-04-08T15:10:12.017200Z

I think the side loading work might be useful here?

dominicm 2019-04-08T15:10:30.017900Z

I guess not actually, as you can't sideload a transport

lilactown 2019-04-08T15:11:11.018400Z

specifically I’m now pivoting to a chrome extension that would connect to a remote session: CLJS in an inspected page, Node.js, and JVM. I previously implemented different “adapters” for each platform, but I know that most projects already have nREPL which would reduce dependencies users would have to install and potentially reduce the differences in implementation

shen 2019-04-08T15:11:51.018700Z

this might be useful?

shen 2019-04-08T15:11:52.018800Z

https://github.com/tomjakubowski/weasel

lilactown 2019-04-08T15:13:21.020100Z

I looked at that as well. it’s still another transport, right? and it didn’t look like it had been updated in awhile, so I wasn’t sure if it supported the latest nREPL

shen 2019-04-08T15:13:44.020600Z

I imagine step one is getting this all to work with drawbridge/your own http transport

shen 2019-04-08T15:14:02.021100Z

and then check if it's worth trying to merge the functionality into nREPL

shen 2019-04-08T15:15:12.022500Z

I've seen some roll-your-own HTTP implementations, and if you are super narrow about the usecase, it can be manageable. But all depends on what it looks like

lilactown 2019-04-08T15:15:56.023200Z

yeah. I’m afraid that it will bloom into “now nREPL has a fully-fledged HTTP server impl” lol

bozhidar 2019-04-08T15:36:00.023400Z

> I looked at that as well. it’s still another transport, right? and it didn’t look like it had been updated in awhile, so I wasn’t sure if it supported the latest nREPL

bozhidar 2019-04-08T15:37:45.024600Z

Not really. It’s just a ClojureScript REPL based on piggieback.

bozhidar 2019-04-08T15:38:02.024900Z

> yeah. I’m afraid that it will bloom into “now nREPL has a fully-fledged HTTP server impl” lol

bozhidar 2019-04-08T15:38:10.025200Z

That’s always a possible outcome. 😄

bozhidar 2019-04-08T15:39:07.025400Z

> I guess not actually, as you can’t sideload a transport

bozhidar 2019-04-08T15:40:21.027Z

@dominicm You won’t need to sideload it, thouhg. You could inject it in the initial payload you’d use to convert a socket repl to nREPL. Once we get there that is. @cgrand already has some branch where the injection works, so I guess that’d be just an extension of this idea.

shen 2019-04-08T15:52:08.027100Z

isn't it a way to speak to piggieback via a websocket?

shen 2019-04-08T15:52:53.027300Z

think it's part of boot's counterpart to lein-figwheel

cgrand 2019-04-08T16:03:11.027900Z

hmm no the injection is not done yet (been busy)

bozhidar 2019-04-08T16:09:54.029300Z

yeah, I know. Just remember that demo you showed me way back in December and that we spoke that the injection could be a good way to provide custom transports seamlessly.

dominicm 2019-04-08T16:13:35.029900Z

@bozhidar I don't think that browsers let you make arbitrary socket calls.

bozhidar 2019-04-08T16:16:25.030600Z

Good point. That approach would work for conventional clients, but not for @lilactown’s use case.

lilactown 2019-04-08T16:18:13.031500Z

I kind of want just a dumb endpoint that I could dump some code into to “inject” stuff, like a heavier HTTP transport if needed

dominicm 2019-04-08T17:35:01.032700Z

An interesting idea would be to have the default transport allow sideloading via a very dumb detection of http request

dominicm 2019-04-08T17:36:20.033900Z

Not sure how much parsing would be needed for the cases we want to support.