Fork me on GitHub
#clojurescript
<
2019-04-14
>
ackerleytng04:04:23

how would i configure lein to copy the static assets (imgs, css, etc) to the output directory of cljsbuild?

henrik10:04:09

Does anyone know what Google means by "2D array" in this? https://google.github.io/closure-library/api/goog.fx.dom.Scroll.html

henrik10:04:08

start	(Array<number>|null)
2D array for start scroll left and top.

henrik10:04:41

Looks decidedly one dimensional to me, but it fails silently, so I'm guessing I have something wrong.

victorb10:04:42

guessing it's a array with two coordinates, x y which would be the pixels from the left and the pixels from the top (but, this is a guess)

victorb10:04:54

should be used something like this: goog.fx.dom.Scroll(document, [0,0], [0,100], 200);

victorb10:04:42

well, (new goog.fx.dom.Scroll(document, [0,0], [0,100], 200)).play() I guess would be the full usage actually

henrik10:04:43

This is what I have:

(let [el (get-element "the-element")
      scroller (Scroll. el
                       (clj->js [0 800])
                       (clj->js [0 (.-offsetTop el)])
                       200)]
   (.play scroller))
I'm guessing the problem is somewhere else then. Alright, thanks!

henrik12:04:11

I gave up on Closure and just used .scrollIntoView.

Tangible Dream23:04:13

I’m working through Ch7 of living clojure and I think I’m getting tangled up in version dependencies The book is written circa 2015 pardon the length of this output cljsbuild barfout my cheshire-cat.core file core.cljs

(ns cheshire-cat.core
  (:require-macros [cljs.core.async.macros :refer [go]])
  (:require [clojure.browser.repl :as repl]
            [cljs-http.client :as http]
            [cljs.core.async :refer [<!]]
            [enfocus.core :as ef]))

(defn ^:export init []
  (repl/connect "")
  (go (let [response (<! (http/get "/cheshire-cat"))
            body (:body response)]
        (ef/at "#cat-name" (ef/content (:name body)))
        (ef/at "#status" (ef/content (:status body))))))
my project version dance
(defproject cheshire-cat "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :min-lein-version "2.0.0"
  :dependencies [[org.clojure/clojure "1.10.0"]
                 [compojure "1.6.1"]
                 [ring/ring-defaults "0.3.2"]
                 [ring/ring-json "0.5.0-beta1"]
                 [org.clojure/clojurescript "1.10.520"]
                 [cljs-http "0.1.46"]
                 [org.clojure/core.async "0.4.490"]
                 [enfocus "2.1.1"]]
  :plugins [[lein-ring "0.12.5"]
            [lein-cljsbuild "1.1.7"]]
  :ring {:handler cheshire-cat.handler/app}
  :profiles
  {:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
                        [ring/ring-mock "0.3.2"]]}}
  :cljsbuild {
      :builds [{
          :source-paths ["src-cljs"]
          :compiler {
            :output-to "resources/public/main.js"
            :optimizations :whitespace
            :pretty-print true}}]})

zane05:04:11

Hey @UHVRM4S64, did you get yourself sorted here?

zane06:04:29

The issue I believe you're running into is that since that book was written the ns macro became more strict about its arguments.

zane06:04:28

In particular inside a ns form (:import [package.Class]) used to work, even though it's malformed (import lists expect a space between the package name and the class name(s) (:import [package Class])).

zane06:04:28

One of the packages you're using, enfocus, has a namespace (`enfocus.macros`) that uses that malformed syntax: https://github.com/ckirkendall/enfocus/blob/master/src/clj/enfocus/macros.clj#L5).

zane06:04:19

One thing you could try is downgrading your Clojure version to when the ns macro was less strict. 1.9.0, say.

zane06:04:58

I filed an issue for the malformed ns form in enfocus.macros here: https://github.com/ckirkendall/enfocus/issues/111

Tangible Dream13:04:34

I was thinking of downgrading. I’ll try it

Tangible Dream13:04:07

Here is what I get with 1.9.36

Tangible Dream13:04:50

GR-030078mbp:cheshire-cat rhicks$ lein cljsbuild auto
Watching for changes before compiling ClojureScript...
Retrieving org/clojure/tools.reader/1.0.0-beta4/tools.reader-1.0.0-beta4.jar from central
Could not find artifact org.clojure:clojurescript:jar:1.9.0 in central ()
Could not find artifact org.clojure:clojurescript:jar:1.9.0 in clojars ()
This could be due to a typo in :dependencies, file system permissions, or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.
GR-030078mbp:cheshire-cat rhicks$ lein cljsbuild auto
Watching for changes before compiling ClojureScript...
Retrieving org/clojure/clojurescript/1.9.36/clojurescript-1.9.36.pom from central
Retrieving com/google/javascript/closure-compiler/v20160315/closure-compiler-v20160315.pom from central
Retrieving com/google/javascript/closure-compiler-main/v20160315/closure-compiler-main-v20160315.pom from central
Retrieving com/google/javascript/closure-compiler-parent/v20160315/closure-compiler-parent-v20160315.pom from central
Retrieving com/google/javascript/closure-compiler-externs/v20160315/closure-compiler-externs-v20160315.pom from central
Retrieving com/google/guava/guava/19.0/guava-19.0.pom from central
Retrieving com/google/guava/guava-parent/19.0/guava-parent-19.0.pom from central
Retrieving org/clojure/tools.reader/1.0.0-beta1/tools.reader-1.0.0-beta1.pom from central
Retrieving com/google/javascript/closure-compiler/v20160315/closure-compiler-v20160315.jar from central
Retrieving com/google/code/gson/gson/2.2.4/gson-2.2.4.jar from central
Retrieving com/google/javascript/closure-compiler-externs/v20160315/closure-compiler-externs-v20160315.jar from central
Retrieving com/google/guava/guava/19.0/guava-19.0.jar from central
Retrieving org/clojure/tools.reader/1.0.0-beta1/tools.reader-1.0.0-beta1.jar from central
Retrieving org/clojure/clojurescript/1.9.36/clojurescript-1.9.36.jar from central
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: cljs.util, being replaced by: #'cljs.util/boolean?
Exception in thread "main" Syntax error macroexpanding clojure.core/ns at (cljs/source_map/base64_vlq.clj:1:1).
Call to clojure.core/ns did not conform to spec.
	at clojure.lang.Compiler.checkSpecs(Compiler.java:6971)
	at clojure.lang.Compiler.macroexpand1(Compiler.java:6987)
	at clojure.lang.Compiler.macroexpand(Compiler.java:7074)
	at clojure.lang.Compiler.eval(Compiler.java:7160)
	at clojure.lang.Compiler.load(Compiler.java:7635)
	at clojure.lang.RT.loadResourceScript(RT.java:381)
	at clojure.lang.RT.loadResourceScript(RT.java:372)
	at clojure.lang.RT.load(RT.java:463)
	at clojure.lang.RT.load(RT.java:428)
	at clojure.core$load$fn__6824.invoke(core.clj:6126)
	at clojure.core$load.invokeStatic(core.clj:6125)
	at clojure.core$load.doInvoke(core.clj:6109)
	at clojure.lang.RestFn.invoke(RestFn.java:408)
	at clojure.core$load_one.invokeStatic(core.clj:5908)
	at clojure.core$load_one.invoke(core.clj:5903)
	at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
	at clojure.core$load_lib.invokeStatic(core.clj:5947)
	at clojure.core$load_lib.doInvoke(core.clj:5928)
	at clojure.lang.RestFn.applyTo(RestFn.java:142)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$load_libs.invokeStatic(core.clj:5985)
	at clojure.core$load_libs.doInvoke(core.clj:5969)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at clojure.core$apply.invokeStatic(core.clj:667)
	at clojure.core$require.invokeStatic(core.clj:6007)
	at clojure.core$require.doInvoke(core.clj:6007)
	at clojure.lang.RestFn.invoke(RestFn.java:482)
	at cljs.source_map$eval2537$loading__6706__auto____2538.invoke(source_map.clj:1)
	at cljs.source_map$eval2537.invokeStatic(source_map.clj:1)
	at cljs.source_map$eval2537.invoke(source_map.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:7176)

Tangible Dream13:04:50

at clojure.lang.Compiler.eval(Compiler.java:7165)
	at clojure.lang.Compiler.load(Compiler.java:7635)

zane20:04:59

@UHVRM4S64 The relevant bit there is this part:

Call to clojure.core/ns did not conform to spec.
Try going back farther.

Tangible Dream20:04:20

Actually, the writer of enfocus is going to get his code up to current versions

zane20:04:56

Oh, great!