clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
zackteo 2021-05-12T02:32:11.343500Z

Does anyone know where is the github repo for the re-com site - https://re-com.day8.com.au/#/layout? I saw some unbalanced brackets in the doc

gregg 2021-05-12T02:33:43.343800Z

https://github.com/day8/re-com

zackteo 2021-05-12T03:43:29.344200Z

Whoops. Thank you! I overlooked the fact that the site was in the same repo

p-himik 2021-05-12T08:07:26.344500Z

Also, if you click on any specific component, the top of the page will have two links - one for the component source code, and the other for the page source code.

πŸ‘ 1
hindol 2021-05-12T08:17:50.345Z

Is there an equivalent of ClojureDocs for ClojureScript?

niwinz 2021-05-12T08:59:34.345100Z

I don't know if it is equivalent, but I'm always using https://cljs.github.io/api/

πŸ‘ 1
πŸ™ 1
hindol 2021-05-12T09:04:18.345400Z

Yes, this one I know of. The main strength of ClojureDocs (to me) is the community provided recipes. I find them super useful. So I was just wondering if there is a similar site for CLJS.

hindol 2021-05-12T09:05:57.345600Z

I am comfortable with Clojure. Which book would you suggest for ClojureScript?

solf 2021-05-12T09:21:56.345800Z

Most of clojuredocs is valable for clojurescript too though

solf 2021-05-12T09:22:25.346Z

I wish clojuredocs integration in cider would work for clojurescript

hindol 2021-05-12T09:29:41.346200Z

Nice. Did not know about the ClojureDocs integration in CIDER. Just tried it out. Strangely, it does not have documentation for loop. Is it using an older snapshot?

solf 2021-05-12T09:34:25.346500Z

Hmm don’t know, it should work

solf 2021-05-12T09:34:30.346700Z

oliver 2021-05-12T11:29:53.348200Z

Hola. I'm using shadow-cljs and the generated source-map appears to map all output line columns to 1, so the mapping doesn't work. For instance, the output of decode-source-map:

{:version 3,
 :sources ["zprint/finish.cljc"],
 :mappings {:537 ["1 => zprint/finish.cljc 336:1 p__41998"
                  "1 => zprint/finish.cljc 336:1 cljs.core.nth"
                  "1 => zprint/finish.cljc 336:1 vec__42000"
                  "1 => zprint/finish.cljc 336:1 vec__42000"
                  "1 => zprint/finish.cljc 336:1 vec__42000"
                  "1 => zprint/finish.cljc 340:19 focus-begin"],
            :238 [""],
            :419 ["1 => zprint/finish.cljc 285:1 s"
                  "1 => zprint/finish.cljc 290:3 s"
                  "1 => zprint/finish.cljc 290:9 nl-split"
                  "1 => zprint/finish.cljc 290:18 nl-split"
                  "1 => zprint/finish.cljc 290:18 nl-split"
                  "1 => zprint/finish.cljc 290:19 clojure.string.split"
                  "1 => zprint/finish.cljc 290:40 clojure.string.split"
                  "1 => zprint/finish.cljc 290:40 clojure.string.split"
                  "1 => zprint/finish.cljc 290:45 s"],
...

oliver 2021-05-12T11:33:30.348300Z

Anyone got an idea what the problem might be? In the browser I can't jump to the right line, and I suspect it is due to this. I've compared the source-map with one generated by boot, there it is fine. The compiler option :source-map true is the same for both.

p-himik 2021-05-12T11:35:53.348500Z

Given that boot works, this might be worth asking in #shadow-cljs

oliver 2021-05-12T11:37:43.348700Z

Ah, thanks. I didn't see there was a more specific channel. πŸ™‚

thheller 2021-05-12T11:39:45.348900Z

There are clearly several entries that aren't column 1? so "all output" doesn't seem accurate?

thheller 2021-05-12T11:40:44.349100Z

are you looking at the wrong "column"? the one that references the sources index? that'll always be 1 since there is only one file?

oliver 2021-05-12T11:41:20.349400Z

Those are the line numbers of the output file, if I understand it correctly. And then inside those value lists you see all of them start with "1 => ...", those should be the columns.

oliver 2021-05-12T11:42:33.349600Z

I'll generate a working one. And I think I just found a shadow-cljs version where it worked. Perhaps I can manually bisect my way to where it changed.

thheller 2021-05-12T11:46:51.349800Z

feel free to set up a reproducible repo. As far as I can tell source maps work perfectly fine

oliver 2021-05-12T11:47:43.350Z

Yeah, I can't reproduce what I think I just saw. Same behaviour now with the older shadow-cljs version. I'll dig a bit deeper and post again in the other channel.

flowthing 2021-05-12T14:51:14.352300Z

Any thoughts on why this:

Ξ» clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "RELEASE"}}}' -M -m cljs.main --repl
Downloading: org/clojure/clojurescript/maven-metadata.xml from central
ClojureScript 1.10.844
cljs.user=> (ns foo.bar)
Either hangs indefinitely or throws this:
Execution error (InternalError) at (<cljs repl>:1).
too much recursion

p-himik 2021-05-13T10:09:11.406300Z

I can reproduce it now as well, but only when the initial page was left there an the REPL session has been recreated. It seems that the problem is due to clojure.browser.repl/bootstrap being called multiple times. And goog.require ends up calling itself.

flowthing 2021-05-13T10:10:59.406500Z

Great to hear someone else was able to reproduce it as well. Thanks for trying it out! I also filed an http://ask.clojure.org question about this issue, in case you feel like weighing in there: https://ask.clojure.org/index.php/10602/evaluating-an-ns-form-clojurescript-repl-throws-rangeerror

dpsutton 2021-05-12T15:02:43.353Z

weird. cannot reproduce

oliver 2021-05-12T15:04:10.353100Z

I can't reproduce this either.

flowthing 2021-05-12T15:06:20.353600Z

I'm on Zulu JDK 16, FWIW.

flowthing 2021-05-12T15:07:43.353800Z

I can reproduce it with OpenJDK 11, too, though. πŸ˜•

p-himik 2021-05-12T15:09:14.354Z

When it throws, does *e in the REPL produce anything?

flowthing 2021-05-12T15:09:36.354200Z

No.

flowthing 2021-05-12T15:09:46.354400Z

Unfortunately.

il-tmfv 2021-05-12T15:54:52.357300Z

Hi I’m on 1.10.844 and I have an issue with <http://goog.net|goog.net>.cookies.set Looks like it is complied from https://github.com/google/closure-library/blob/ff84fa63944b428da36006ec940b3b349a8d66d3/closure/goog/net/cookies.js#L167 to

hba.set = function(n, t, h) {
    var e = !1;
    if ("object" == typeof h) {
        var l = h.Lh;
        e = h.Mh || !1;
        var r = h.domain || void 0
          , b = h.path || void 0
          , u = h.Lg
    }
    if (/[;=\s]/.test(n))
        throw Error('Invalid cookie name "' + n + '"');
    if (/[;\r\n]/.test(t))
        throw Error('Invalid cookie value "' + t + '"');
    void 0 === u &amp;&amp; (u = -1),
    this.Oc.cookie = n + "=" + t + (r ? ";domain=" + r : "") + (b ? ";path=" + b : "") + (0 &gt; u ? "" : 0 == u ? ";expires=" + new Date(1970,1,1).toUTCString() : ";expires=" + new Date(Date.now() + 1e3 * u).toUTCString()) + (e ? ";secure" : "") + (null != l ? ";samesite=" + l : "")
}
As you can see some params are renamed (see argument h) like h.Lh Is it expected?

dpsutton 2021-05-12T15:56:14.358400Z

it is expected. is this causing issues for you?

il-tmfv 2021-05-12T15:57:05.359200Z

Yes, basically I cannot pass maxAge param b/c it becomes something like Lh

il-tmfv 2021-05-12T15:57:42.359800Z

BTW, path and domain are left untouched

dpsutton 2021-05-12T15:58:59.360100Z

are you calling this from javascript or clojurescript?

dpsutton 2021-05-12T16:00:34.361500Z

oh i'm following you now. It's not the arguments to the function but the properties on an options object that are being renamed

il-tmfv 2021-05-12T16:00:54.361800Z

from cljs, a pass it as #js {:maxAge 999 :path "/"} I’ve also tried to construct <http://goog.net|goog.net>.Cookies.SetOptions but it didn’t help

p-himik 2021-05-12T16:12:21.362900Z

Looks like it warrants an issue on their GitHub.

p-himik 2021-05-12T16:12:41.363200Z

I don't think any of the keys allowed in options should be renamed.

p-himik 2021-05-12T16:13:21.363400Z

I think you can hot-fix it in your own code with

(defn ^:export f [^js x]
  (.-maxAge x))

p-himik 2021-05-12T16:14:03.363600Z

You don't have to use it - it should simply create an extern for maxAge thus preventing it from being renamed. But I haven't tested this approach.

il-tmfv 2021-05-12T16:15:49.363800Z

Thanks! Maybe it is better to write externs manually then? For <http://goog.net|goog.net>.Cookies.SetOptions Not a fan of this idea though

dnolen 2021-05-12T16:16:23.364300Z

passing #js is not right

dnolen 2021-05-12T16:16:31.364600Z

nor is externs

dnolen 2021-05-12T16:16:46.365Z

SetOptions should work and it should be determined why it isn't

dnolen 2021-05-12T16:17:08.365600Z

the Closure type annotations tell you that SetOptions is required as 3rd parameter

dnolen 2021-05-12T16:18:14.366300Z

@il.tmfv you absolutely cannot call set directly from non-compiled code

p-himik 2021-05-12T16:18:21.366600Z

I wouldn't do that myself. I would simply use that workaround above and create an issue on Closure's GitHub that you linked.

dnolen 2021-05-12T16:18:32.366900Z

if that's what you're doing then it's still trivial to fix

dnolen 2021-05-12T16:18:50.367300Z

you can write an fn that takes the unmunged parameters and then constructs SetOptions

p-himik 2021-05-12T16:19:50.367900Z

Is it true for Closure API in general? If not, how to tell the difference?

dnolen 2021-05-12T16:20:35.368900Z

@p-himik there's nothing to see here

πŸ‘ 1
dnolen 2021-05-12T16:20:44.369300Z

it's exactly the same for all Closure compiled stuff

il-tmfv 2021-05-12T16:20:56.369700Z

How to properly construct it? I’ve tried this, but it feels wrong:

(let [cookie-options (SetOptions.)
        _ (gobj/set cookie-options "maxAge" (* 60 60))
        _ (gobj/set cookie-options "path" "/")]
    (.set goog.net.cookies
          "checkout-data"
          "xxx"
          cookie-options))

p-himik 2021-05-12T16:21:52.370Z

You can use doto to make it more concise and get rid of let.

dnolen 2021-05-12T16:22:12.370400Z

@il.tmfv won't work

p-himik 2021-05-12T16:22:20.370800Z

And I think you can't use gobj/set here because it has to be munged. Just (set! ...).

dnolen 2021-05-12T16:22:35.371300Z

these are the docs, you must supply a type w/ those properties not JSON stuff

dnolen 2021-05-12T16:23:07.371800Z

(deftype Options [domain maxAge path sameSite secure])

dnolen 2021-05-12T16:23:46.372500Z

or write some Closure JS and import that etc. this is relatively well supported - how transit-js -> transit-cljs works

il-tmfv 2021-05-12T16:24:39.373400Z

Thanks! will try and report

p-himik 2021-05-12T16:25:04.373800Z

But <http://goog.net|goog.net>.Cookies.SetOptions is a type, no? Why wouldn't using

(doto (SetOptions.)
  (set! -maxAge 3600)
  (set! -path "/"))
work?

il-tmfv 2021-05-12T16:39:07.374500Z

@dnolen thanks again! deftype helped

dnolen 2021-05-12T16:43:13.374700Z

@p-himik interface

flowthing 2021-05-12T16:44:12.375Z

I can also reproduce it on a different machine that's running a different OS, Java version, and even CPU architecture. Really weird.

p-himik 2021-05-12T16:44:26.375600Z

But this works just fine on my end, in :advanced:

(ns app.core
  (:require [goog.net.Cookies :refer [SetOptions]])
  (:import (<http://goog.net|goog.net> cookies)))

(.set cookies "checkout-data" "xxx"
              (doto (SetOptions.)
                (set! -maxAge 31536000)
                (set! -path "/")))

dnolen 2021-05-12T16:44:51.375800Z

@il.tmfv or rather you're right that will work too, but the important thing is

dnolen 2021-05-12T16:45:22.376800Z

Cookies.SetOptions is defined as an interface here - so you can supply anything that matches

dnolen 2021-05-12T16:45:43.377300Z

but yes using SetOptions works instead of creating deftype

dnolen 2021-05-12T16:46:00.377800Z

but the takeaway just to drive the point home

dnolen 2021-05-12T16:46:12.378800Z

1. For Closure stuff externs is never the right answer

dnolen 2021-05-12T16:46:28.379400Z

2. Do not pass runtime stuff to compiled code if you have not established an adapter

p-himik 2021-05-12T16:46:41.379500Z

But here https://google.github.io/closure-library/api/goog.net.Cookies.SetOptions.html it says record and not interface. Not sure if Closure treats the terms as interchangeable or there's a discrepancy in documentation.

dnolen 2021-05-12T16:46:56.379700Z

pretty sure it can be both?

p-himik 2021-05-12T16:52:38.380400Z

In this case - seems like it. And I can find neither documentation nor usage examples on how @record and @interface are different for GCC.

flowthing 2021-05-12T17:03:24.380500Z

OK, this is browser-related, maybe a browser extension messing with something. I can reproduce the issue with Firefox, but not with Safari.

flowthing 2021-05-12T17:24:57.380800Z

...or not. It sometimes hangs with Safari, too. Oh well.

p-himik 2021-05-12T17:30:26.381Z

When it hangs, you should be able to pause JS execution and see the current stack trace.

p-himik 2021-05-12T17:30:35.381200Z

Via the browser's DevTools.

flowthing 2021-05-12T17:31:45.381400Z

Oh, yes, good tip, will try that. :thumbsup::skin-tone-2: ...except my browser crashed when I tried doing that. :P

p-himik 2021-05-12T17:34:34.381600Z

Time to try all the browsers. :)

flowthing 2021-05-12T17:35:43.381800Z

Heh, I guess so. πŸ™‚

dnolen 2021-05-12T20:21:25.382200Z

pretty interesting news - https://workspaceupdates.googleblog.com/2021/05/Google-Docs-Canvas-Based-Rendering-Update.html

πŸ‘€ 1
dnolen 2021-05-12T20:23:55.383Z

would nice if there were more engineering / technical details

p-himik 2021-05-12T20:26:58.383300Z

Hmm, their demo combines canvas with svg.

phronmophobic 2021-05-12T20:34:32.383900Z

I wonder if that just means they're going to use flutter. I think flutter was already canvas based.