This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-26
Channels
- # aleph (2)
- # aws-lambda (18)
- # beginners (81)
- # boot (3)
- # cider (25)
- # cljs-dev (274)
- # cljsjs (10)
- # clojars (25)
- # clojure (65)
- # clojure-austin (1)
- # clojure-brasil (2)
- # clojure-dev (33)
- # clojure-dusseldorf (6)
- # clojure-gamedev (3)
- # clojure-italy (17)
- # clojure-poland (3)
- # clojure-russia (7)
- # clojure-spec (48)
- # clojure-uk (45)
- # clojured (1)
- # clojurescript (26)
- # core-logic (2)
- # data-science (4)
- # datascript (6)
- # datomic (58)
- # defnpodcast (2)
- # docker (1)
- # duct (14)
- # figwheel (2)
- # fulcro (130)
- # graphql (3)
- # leiningen (1)
- # liberator (15)
- # luminus (5)
- # nrepl (1)
- # numerical-computing (1)
- # off-topic (45)
- # onyx (15)
- # re-frame (9)
- # reagent (3)
- # ring (1)
- # shadow-cljs (91)
- # spacemacs (8)
- # sql (23)
- # unrepl (38)
- # videos (2)
- # vim (12)
I'm working on the REPL based exception that you get when you run that. I suspect it might be the result of the way I replace the script tag completely.
@mfikes @bhauman I added a div with id app
to master, I think it makes what you’re trying to do simpler
I’m lukewarm now on browser REPL working without the compile step, I just can’t see a way to make it work without being messy
the only way I could think to do it cleanly was to add an output-to when compiling the repl client js
https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/repl/browser.clj#L232
@dnolen On a positive note, your app
addition made this work 🙂 https://twitter.com/mfikes/status/967929140430229505
Nothing a little laziness can’t solve I guess https://github.com/clojure/clojurescript/commit/d8e33cd9826cfc6da70e79f8f6984ad8c5caa9bb
clj -m cljs.main -re browser -c chambered.core -r
after adding your dep just worked, open browser with running example
On Linux it would be xdg-open 😉
Nice cross-os summary https://www.dwheeler.com/essays/open-files-urls.html
I’ll take a stab; I have all the OSs available to test with https://dev.clojure.org/jira/browse/CLJS-2555
Yes. I’m actually testing something close to that, but will switch to exactly that instead.
(.browse (Desktop/getDesktop) (URI. (str "http://" (:host repl-env) ":" (:port repl-env))))
Oh… interesting. So that namespace uses clojure.java.shell
instead of the facility in Java. Well, I’ll just use the clojure.java.browse
one, as it lets users re-bind *open-url-script*
Ahh, nice, clojure.java.browse
even falls back to the Desktop
stuff I was just trying. 🙂
Cool. I think it is good to go. It actually opened the browser on Windows as well but failed for an unrelated reason https://gist.github.com/mfikes/b2b137e3c491bf3aaf34eff6b03a686d (I’ll see if I can get a minimal repro for JIRA)
Nice I wasn’t aware of clojure.java.browse
looks like the handiwork of Christophe Grand
Captured a minimal repro for the issue mentioned a couple of messages back https://dev.clojure.org/jira/browse/CLJS-2556
Yeah, this git deps stuff, composing with all this other stuff is definitely new territory. We definitely were not able to sling around code like this previously.
this kind of stuff is exactly what we were hoping to enable - it’s a lot of fun seeing y’all use it :)
the browser repl *could* be the default repl, it starts faster than nashorn and is still the most used CLJS environment
add the clojurescript favicon <link rel="icon" href="https://clojurescript.org/images/cljs-logo-icon-32.png">
to the index.html
note to self: this is getting very close to bare bones figwheel, the client just needs to know what files to require on change
I suppose if you made the browser REPL the default, then people could still run non-browser tests if desired (by specifying -re nashorn
for example)
using V8 (via Project Detroit) in the future as the default would also be very compelling (speed, for one)
Riffing on Bruce's idea of an informative message, for the "compileless" browser REPL, we could slap a logo in there with a little extra code.
(server/send-and-close conn 200
(str "document.write('<script>document.body.setAttribute(\"bgcolor\", \"#000000\");</script>');\n"
"document.write('<script>document.getElementById(\"app\").innerHTML = \"<canvas id=canvas width=1000 height=1000></canvas>\";</script>');\n"
"document.write('<script>ctx = document.getElementById(\"canvas\").getContext(\"2d\");</script>'); ctx.lineWidth = 12;\n"
"document.write('<script>ctx.fillStyle = \"#FFFFFF\"; ctx.beginPath(); ctx.arc(300, 150, 100, 0, 2 * Math.PI); ctx.fill();</script>');\n"
"document.write('<script>ctx.strokeStyle = \"#96CA4B\"; ctx.beginPath(); ctx.arc(300, 150, 86, 1.57, 4.71); ctx.stroke();</script>');\n"
"document.write('<script>ctx.strokeStyle = \"#5F7FBF\"; ctx.beginPath(); ctx.arc(300, 150, 86, 4.71, 1.57); ctx.stroke();</script>');\n"
"document.write('<script>ctx.fillRect(294, 55, 12, 190);</script>');\n"
"document.write('<script src=\"out/goog/base.js\"></script>');\n"
"document.write('<script src=\"out/goog/deps.js\"></script>');\n"
"document.write('<script src=\"out/cljs_deps.js\"></script>');\n"
"document.write('<script>goog.require(\"clojure.browser.repl.preload\");</script>');\n")
"text/javascript"
"UTF-8")
(That's produced by the 7 extra lines inserted above the normal code to load the Closure stuff and the browser REPL preload code.)
@mfikes while it’s nice to use some Canvas, we could probably just drop the logo there 🙂 I think there’s one in SVG floating around right?
Yes, the real one is at https://github.com/cljs/logo
I'll put together a patch that uses the real logo—we can then decide if we actually want it in the end.
Oh yeah we can also AOT compile the browser REPL client JS file - https://dev.clojure.org/jira/browse/CLJS-2561
I don't know if I have access to see the images list in the clojurescript site. That png is https://clojurescript.org/images/cljs-logo-icon-256.png
@mfikes honestly I would just get the SVG from that repo and copy it into the ClojureScript JAR - we can serve it locally, ditto for the favicon
Thinking about how this might work if ClojureScript is a git dep... perhaps it can be a resource...
I can manage the build / deploy side, just put things in the right place for now and tweak the server
I didn't worry too much about styling, but the patch for the logo and copy is now attached. It looks like the following
There is a vexing bug where the logo doesn't appear the first time you start it up. Maybe the solution will come to us if we ponder it a bit.
Yeah, it is strange. The logo is indeed copied and if you get the image address from your browser and then open it in another browser it works. I've tried adding a sleep after the code that copies the files to try to avoid any such race, but that doesn't do it either. Hrm.
@mfikes I cleaned up the svg / png handling a bit, I don’t think there should be races now - I just avoid the filesystem
I'm updating the chambered and bocko-canvas demos to ensure they work with this latest stuff.
@potetm can we get a rebased patch for this https://dev.clojure.org/jira/browse/CLJS-2167? Sorry for the long delay but now’s a good time to spruce up Browser REPL 🙂
also https://dev.clojure.org/jira/browse/CLJS-2168?focusedCommentId=48330#comment-48330
I’m fine w/ disabling :optimizations
that’s only for the client JS there’ no reason for the user to control that
@dnolen for sure! hopefully can get to it this afternoon; tomorrow morning at the lastest.
That would be nice. (If you do that, can you style the whole body from within the app div?)
There’s one more thing about the browser repl that’s on my todo list, I’m curious if someone already got to it: I think I know why the browser “misses” sometimes. IIRC The child-parent connection just uses a setTimeout before establishing a connection. There’s a pattern for send/ack outlined in Closure: The Definitive Guide that might fix that issue.
An consequence of what @bhauman is referring to is that chambered
looks like the following
All chambered
is doing is
(set! (.-innerHTML (.getElementById js/document "app"))
"<canvas id=\"game\" width=\"424\" height=\"240\"></canvas>")
@mfikes actually if you move the style tag inside the app that should work for you I think
@dnolen Cool. I’m hopping on a plane this evening. I should have some time to take a look at it while I travel.
Sweet. chambered
is updated and it behaves properly (you see the expected brief flash of the default page, which gets replaced). chambered
no longer requires -re browser
as well, so simpler to start:
clj -Sdeps '{:deps {github-mfikes/chambered {:git/url "" :sha "3cbb5fef025ac5da39098e06429043216a6e97b9"}}}' -m cljs.main -c chambered.core -r
Oh, wait, I guess you need an explicitly add -re browser
to have it automatically start the browser.
Is the intent with the default REPL being browser that you don't need to specify -re browser
? (Thinking about the fact that we lose auto-browser behavior.)
Working on the shutdown-agents issue https://dev.clojure.org/jira/browse/CLJS-2562
See if omitting -re browser
make it so the browser doesn't open localhost:9000 for you
@mfikes it works over here, but not if you have multiple one’s running because the address won’t bind
I was initially in a directory that had a deps file in it, and it launched a nashorn repl, so that was confusing
Well, clj -m cljs.main
in the ClojureScript directory starts the browser. but in the chambered
example, copied here:
clj -Sdeps '{:deps {github-mfikes/chambered {:git/url "" :sha "3cbb5fef025ac5da39098e06429043216a6e97b9"}}}' -m cljs.main -c chambered.core -r
you seem to need to explicitly add -re browser
Sorted: I had a local deps.edn
overriding my ClojureScript dep and not taking the one from from the project
While we are on the issue of the server, now that CORS is a well supported thing. We could have a simpler repl connection that is supported by simple HTTP polling. No mess no fuss. No iframes, and very robust connection.
depending on when we’re looking to carve a release, I might be up for making the init tweak then swinging back around with a full rewrite
Moving (shutdown-agents)
to the end of cljs.main/-main
fixes things, while not messing with js/setTimeout
calls in flight, but seems like something else might go wrong. Anyway here is the potential patch for https://dev.clojure.org/jira/browse/CLJS-2562
https://github.com/mfikes/clojurescript/commit/a02bf1150fc069723ccd094a5151e2e91f2f3f1d
well these improvements are exciting, I can't pull myself away, I'm more rapt by this than by the Olympics
I wonder @dnolen, Safari seems to exhibit that behavior where it needs a refresh to work, when it is populating a fresh out
directory—perhaps it is similar to the thing you just fixed with the png
and svg
, but for the script files being written to the filesystem and a race with Safari occuring.
It seems pretty deterministic for me. java -jar cljs.jar
fails if out
is not there, but it works if it is already there
Yeah. It really feels like some of the (valid) complaints that people have might be addressed by this release.
but the chambered example failed to connect the repl every time, even after I killed the browser
Ah hah! Here is what the Safari JavaScript console shows if you start up without a populated "out"
@bhauman chambered
connects the 2nd time you execute that command. In other words, when you have a populated "out"
FWIW, Bocko stuff updated and works fine with latest :sha
(https://gist.github.com/mfikes/e00202b2de7cc2352fedcf92b1fe60dc)
yeah chambered goes into a loop and gives little control to the browser, so not a great example of REPL integration
@dnolen To save you some time in case you encounter it: jbake
(the tool for clojurescript site) doesn't seem to work with Java 9; it is fine with Java 8. If you use Java 9 the failure will look like
$ jbake
JBake v2.5.0-SNAPSHOT (2015-11-04 14:58:30PM) []
An unexpected error occurred: null
@mfikes I think I fixed https://dev.clojure.org/jira/browse/CLJS-2556 on master
Hello folks, is this correct with the new REPL namespaces? because it throws for me. I can open an issue of course, just wanted to be sure
clojure -J-Dclojure.server.repl='{:port 5044 :accept cljs.server.node/repl}' -A:cljs-canary
trying the -re
thing now
@richiardiandrea throws how?
a sec, pasting to a file
I connect to it with nc localhost 5555
@richiardiandrea you need Clojure 1.10.0-alpha4
oh, gotcha thanks!
It works! Not for now now, but it would be awesome if a -o
would accept a path to an already present cljsc_opts.edn
file containing compiler options
or a way to use my own compiler options for the repl ... it does not seem to see my npm
deps
@richiardiandrea it’s really not possible to get that much configuration out of this
ok lemme try that
@dnolen is -cf
on master
now? the last commit I see is allow setting browser host/post via cljs.main
yep having options from the command line is awesome, as I was saying earlier, having deps.edn
plues cljsc_opts.edn
in the project is definitely cool...plus I have a serverless-lumo.edn
for lumo
...each conf file is decoupled from the other
thank you folks for the work you put in last week/weekend, I was reading along 😄
@bhauman I just added minimal error handling, it should make the more cryptic cases more clear
nearly all the bad stuff is from falling into the main case, so we check everything there now
I'll attempt to keep the content in the cljs.main
reference PR up to date between now and release https://github.com/clojure/clojurescript-site/pull/173
@potetm I went ahead and fixed the bind address case, it needed a couple of tweaks anyway
ok well, -cf
seems not to complain but the the require
of something from :npm-deps
is not working yet...anyways thanks that is what I was hoping for, will try to dig when I have more time