This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-29
Channels
- # announcements (2)
- # babashka (18)
- # beginners (42)
- # calva (56)
- # chlorine-clover (35)
- # clara (9)
- # clj-http (1)
- # clj-kondo (19)
- # cljs-dev (8)
- # clojure (14)
- # clojure-europe (23)
- # clojure-france (7)
- # clojure-norway (6)
- # clojure-uk (3)
- # clojurescript (37)
- # community-development (3)
- # cursive (29)
- # datomic (3)
- # emacs (10)
- # events (2)
- # fulcro (77)
- # hyperfiddle (2)
- # introduce-yourself (4)
- # joker (1)
- # lsp (40)
- # malli (52)
- # meander (7)
- # missionary (16)
- # off-topic (3)
- # pedestal (1)
- # re-frame (5)
- # reitit (38)
- # releases (1)
- # shadow-cljs (4)
- # tools-build (18)
- # tools-deps (1)
- # xtdb (8)
Is there an easy way to convert a javascript regex pattern to a pattern that will work in clojurescript source? Or do I just have to escape characters individually?
keep running in circles with interop trying to turn this: data = event.dataTransfer.getData("text")
into this (event is %) (let [data (. % .-dataTransfer -getData "text")])
and various other combinations with different errors each time
(let [data (.getData (.-dataTransfer %) "text")] ...)
I think you want ..
if you want to "thread" things: (.. % -dataTransfer (getData "text"))
off the top of my head.
Q re: Windows/WSL -- is anyone doing cljs development on Windows with the ClojureScript processes running on WSL2? When I run this command on WSL2, I get a Google Chrome instance running, displaying the cljs welcome page, but I never get an actual REPL prompt:
clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "RELEASE"}}}' -M -m cljs.main -r
If I then close the browser, the version and REPL prompt appears but of course errors out due to losing the connection to the browser:
ClojureScript 1.11.4
cljs.user=> Execution error (SocketException) at sun.nio.ch.NioSocketImpl/implWrite (NioSocketImpl.java:420).
Broken pipe
Full report at:
/tmp/clojure-11840304026226495887.edn
That EDN file starts with
{:clojure.main/message
"Execution error (SocketException) at sun.nio.ch.NioSocketImpl/implWrite (NioSocketImpl.java:420).\nBroken pipe\n",
:clojure.main/triage
{:clojure.error/class java.net.SocketException,
:clojure.error/line 420,
:clojure.error/cause "Broken pipe",
:clojure.error/symbol sun.nio.ch.NioSocketImpl/implWrite,
:clojure.error/source "NioSocketImpl.java",
:clojure.error/phase :execution},
:clojure.main/trace
{:via
[{:type clojure.lang.ExceptionInfo,
:message "Unexpected error during REPL initialization",
:data {:cljs.repl/error :init-failed},
:at [cljs.repl$repl_STAR_ invokeStatic "repl.cljc" 1220]}
{:type java.net.SocketException,
:message "Broken pipe",
:at
[sun.nio.ch.NioSocketImpl implWrite "NioSocketImpl.java" 420]}],
:trace
[[sun.nio.ch.NioSocketImpl implWrite "NioSocketImpl.java" 420]
[sun.nio.ch.NioSocketImpl write "NioSocketImpl.java" 440]
[sun.nio.ch.NioSocketImpl$2 write "NioSocketImpl.java" 826]
[java.net.Socket$SocketOutputStream write "Socket.java" 1035]
[jdk.internal.reflect.GeneratedMethodAccessor10 invoke nil -1]
[jdk.internal.reflect.DelegatingMethodAccessorImpl
invoke
"DelegatingMethodAccessorImpl.java"
43]
[java.lang.reflect.Method invoke "Method.java" 568]
[clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 167]
[clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 102]
[cljs.repl.server$send_and_close invokeStatic "server.clj" 168]
Maybe an idea to sidestep the problem could be to install chrome on the wsl2 itself? :thinking_face: https://docs.microsoft.com/en-us/windows/wsl/tutorials/gui-apps#install-google-chrome-for-linux
i've been doing dev on wsl2 for quite awhile now, i use shadow-cljs though and i'm able to connect to a repl just fine using any browser on windows side
"Start the REPL using the pattern described above, but with the browser as the evaluation environment.
(require '[cljs.repl :as repl])
(require '[cljs.repl.browser :as browser]) ;; require the browser implementation of IJavaScriptEnv
(def env (browser/repl-env)) ;; create a new environment
(repl/repl env) ;; start the REPL
Once the REPL has started, you will see the message "Starting server on port 9000". At this point, open the html page by going to http://localhost:9000 to complete the connection. Once the page is open and the connection is made, the REPL prompt will be displayed."
[Edit] Um, so what does it mean "but with the browser as the evaluation environment"? I'm afraid I had assumed this was the process to create a browser cljs repl from say clj (this is what I thought cljs meant in the namespace), but this may be code to create ANOTHER browser repl from a browser repl.
Before seeing Sean's post I was going to take a couple of weeks to read some source code behind this problem after having queried pez on #calva. I still have to take the time to read it, but I wanted to put my two cents in before then.Forgot to press "shift enter" again. I will complete what I was going to write shortly. The above is from https://clojurescript.org/reference/repl . It will fail at (repl/repl env) in WSL2 because of a socket not being released prior to an attempt to make a connection (I think). I am going to collect screenshots. I believe it is a Linux thing in general and not a WSL2 thing in particular, because https://clojurescript.org/guides/quick-start says: "If you are running Linux and the REPL does not start, try disabling browser auto-launch and opening `http://localhost:9000` manually:" The article does not say WHY some Linux setups won't work properly, but I believe it is the same issue.
The purpose of this next screenshot is to show the browser window opened, although I have just said that already. I hesitate highlight the ?rel=1640775390178 part, because it is undoubtedly not relevant, but does anyone know what it means?
"Fire up the Clojurescript Quick Browser REPL" in Calva and the same thing happens. The browser repl opens in a browser window, but it is inaccessible to the editor. Incidentally, I have until yesterday thought the browser REPL was a process or sub-process within the browser instance. It may still be, but something I read yesterday talked in terms of the browser being a separate process serving a/the browser REPL. Anyway, Calva presents us with the following screen. It says "Connecting cljs repl:", but it never does; it gets stuck here just like repl/repl got stuck in the clj repl above. I understand a cljs prompt is meant to appear after this, but I have never seen one on my system.
When I close the browser window, Calva prints out additional lines 22-27: A SocketException; Write failed because of a broken pipe. Calva then evaluates core.cljs (in package hello_world), but in nrepl, not the browser repl that we want.
I will refer to this screenshot next, as the Slack appears to always present the graphics at the end of each comment in the thread.
The above nREPL log does not record an error (though nrepl does reply with a repl type of clj when I would expect cljs), but cider.piggieback/cljs-repl returns the following error when repeated in the editor (because, I presume the http server is holding onto a broken pipe making its socket unavailable): Execution error (BindException) at http://java.net.PlainSocketImpl/socketBind (PlainSocketImpl.java:-2). Address already in use (Bind failed)
This was the magic piece I had missed:
> "If you are running Linux and the REPL does not start, try disabling browser auto-launch and opening http://localhost:9000 manually:"
Thanks @brendnz!
If I start the basic REPL with --repl-opts '{:launch-browser false}'
and then visit http://localhost:9000 in either Google Chrome on Linux or Edge on Windows, it all works as expected.
Hi guys. I am new to Clojure and clojurescript. What is the best way to use npm packages in clojurescript? I was searching for how to do a wrapper around an npm package, but I didn't find a very useful resource for that. I found many packages under the cljsjs link https://cljsjs.github.io/, but I also want to be able to build my own wrapper. I appreciate your help.
You can try using shadow-cljs
. You can then require most of the npm libraries you have installed in your project doing something like (:require ["react" :as react])
Thanks Arthur. Does that have a downside on the performance?
What do you guys recommend to use for clojure/script time with time zone support? I can see juxt tick as being a good candidate, any other recommendations?
This was the magic piece I had missed:
> "If you are running Linux and the REPL does not start, try disabling browser auto-launch and opening http://localhost:9000 manually:"
Thanks @brendnz!
If I start the basic REPL with --repl-opts '{:launch-browser false}'
and then visit http://localhost:9000 in either Google Chrome on Linux or Edge on Windows, it all works as expected.
If I want to extend a protocol to the types for which the predicates map?, set? and sequential? are true, which types would they be in cljs?
According to a cljs REPL, map?
is satisfies? IMap
, set?
is ISet
, and sequential?
is ISequential
. (based on calling source
on each of these)
(so you'll need to extend those protocols to whatever your new thing is)
It's for a walking protocol, so I won't need to extend them, but every type which implements them 😞
I suspected as much. Sorry.
ahaha @UK0810AQ2 looks like we're on the exact same page this morning https://clojurians.slack.com/archives/C07UQ678E/p1640797627283600
This is killing me:
Use of undeclared Var cljs.core.async.interop/p->c
Anybody seen this before?to answer my own question, <p!
needs to be in :require
not :require-macros