Comments (9)
OK, this thread explains that the problem lies with the Clojurescript repl itself, so not an Austin issue.
http://comments.gmane.org/gmane.comp.java.clojure.user/60605
So what's LightTable secret sauce and how can Austin benefit from it?
Contrary to the official Clojurescript stance that it is not supported, LightTable enables the use case where a html file is opened from disk and successfully establishes a connection with a Clojurescript repl.
from austin.
Preliminary findings indicate that LightTable fires up an internal web server with websockets transport.
Very interesting. Is this outside the scope of Austin? If so, I'll close this issue. Thanks.
BTW, there is a reward for implementing this: https://twitter.com/swannodette/status/365272360896569344
:-)
from austin.
Either way, there's a server, something needs to be available to compile the ClojureScript you're evaluating, etc. Given that, what's the benefit of a websocket server vs. HTTP?
Note that Austin just reuses the stock ClojureScript browser-REPL client-side bits, which uses a CrossPageChannel to talk to the server. Changing that isn't necessarily outside of Austin's scope, but (a) it's not a nontrivial change, and (b) the work would necessitate a compelling benefit.
from austin.
I agee, it doesn't need to be websocket per se.
In this particular instance, I care about the use case, which could be defined like this: "given a client-side project with no server component, start an in-browser Clojurescript repl."
This is currently not possible with Austin, but it is with LightTable.
When I was doing the Om tutorial (https://github.com/swannodette/om/wiki/Basic-Tutorial) which contains instructions for LightTable, I was shocked to see how easy it was.
Austin should probably continue to use the stock ClojureScript browser-REPL as-is, but it could provide the additional tooling LightTable has. Whatever the implementation details are, with or without websockets. It's all public, open source code anyway.
from austin.
There are a couple of things:
- LightTable's approach works because WebSockets are not bound by the same-origin policy. We can modify Austin's embedded server to add the necessary
Access-Control-Allow-Origin: *
header to all responses (or whatever less-permissive one that will allow only localhost and whatever the origin is forfile://
URLs). - This would work with the existing client-side bits, with the exception that the CrossPageChannel (or one of its dependencies) does some questionable URL string-munging in order to (potentially?) check for a
robots.txt
, which ends up yielding an invalid URL (since there's no host in e.g.file:///tmp/start-repl.html
).
I've long wanted Austin to have its own browser-side component to replace cljs.browser.repl
, probably using SSEs instead of the CrossPageChannel (the big advantage of which was that it worked on all browsers, including IE 6, back when CLJS was first released). Combined with the CORS header server-side, this should make austin suitable for this use case.
from austin.
That all makes a lot of sense. And it sounds like a good plan.
If Austin is to become a default go-to REPL for Clojurescript development, it will need to support that use case. I'll be happy to help to the best of ability.
from austin.
An easier approach would be to allow the user to "mount" a local directory as the root of all resources served for a particular REPL session (mock usage here):
user=> (cemerick.austin.repls/mount-static "/app/directory" ...other REPL env config)
Static local site mounted @ http://localhost:51665/3889/
So /app/directory/index.html
would be served via http://localhost:51665/3889/
or http://localhost:51665/3889/index.html
; similarly for the usual sorts of web resources. Further, Austin could use enlive or similar to inject the necessary JavaScript (equivalent to the output of (browser-connected-repl-js)
) at the end of the <head>
or <body>
tag, populated with the corresponding URL for that session, e.g. http://localhost:51665/3889/repl
.
This would be a much less significant change, but achieve the same objectives…while preserving the ability to have multiple concurrent browser-REPL sessions. Patch welcome.
from austin.
I agree. I discovered that somebody already proposed something along those lines.
Adrian Medina posted a lein template (om-cljs) that has all the machinery required in dev/user.clj.
https://github.com/aamedina/cljs/blob/master/src/leiningen/new/om_cljs/dev/user.clj
I tried it myself and it works great. Austin could borrow from it, no?
from austin.
Yes, it looks like the approach I described is exactly what was implemented there. So, "borrow", yes, conceptually.
The user in question hasn't submitted a PR themselves, so any kind of copy/paste wouldn't be appropriate; but even so, they are operating a separate server that happens to coordinate with a running Austin REPL environment to get the necessary connect URL, etc. The "mounting" of a directory as the root of an Austin session's served content can and should be part of cemerick.austin
.
from austin.
Related Issues (20)
- Eliminate use of CrossPageChannel HOT 3
- Fail gracefully on attempts to use REPL env with disposed session
- Austin should not declare its own ClojureScript dependency HOT 5
- Cljs compiler env doesn't correspond to a refreshed browser env, with (disastrous!) consequences HOT 6
- NullPointerException with Clojurescript 0.0-2173 HOT 5
- NPE against org.clojure/clojurescript "0.0-2173" HOT 1
- Incompatibility with cljs 2173 HOT 1
- austin/exec-env fails w/ cljs 0.0-2173 HOT 3
- Hot reloading of HTML files not working in example project HOT 4
- Inexplicable problems with sample project HOT 3
- Can't require namespaces HOT 1
- Initial namespace not setup properly HOT 1
- Add support for adding JS dependencies. HOT 1
- tools.logging aot issue HOT 2
- Austin not compatible with cljs-2356 HOT 4
- clojurescript 0.0-2665 cannot compile austin 0.1.5 HOT 7
- Add production profile to browser-connected-repl-sample
- After loading (cemerick.austin.repls/exec), forms hang at repl prompt HOT 5
- After loading (cemerick.austin.repls/exec), austin fails with "No value supplied for key:" HOT 4
- Can't start repl
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 austin.