Fork me on GitHub
#clojurescript
<
2018-02-11
>
quang00:02:04

Yeah looks like it... if I can use both amplify and cljs, it'll be 🙌

derpocious00:02:52

what is amplify...?

Yehonathan Sharvit06:02:19

A question related to :npm-deps: How do we refer the namespace as a whole For instance, I’d lile to use regl in my cljs project (http://regl.party/examples) The js code looks like:

const regl = require('regl')()

// This clears the color buffer to black and the depth buffer to 1
regl.clear({
  color: [0, 0, 0, 1],
  depth: 1
})

Yehonathan Sharvit08:02:19

How would you rewrite this js code in cljs?

thheller08:02:56

@viebel (:require ["regl" :as regl]) in ns, then (def regl-instance (regl)), (.. regl-instance (clear #js { ... }))

burke11:02:27

I use some cljsjs packages in my leiningen cljs project. I want to use the css files of some packages, is there a leiningen equivalent to the boot sift command?

mac12:02:11

@sekao I am considering using paren-soup to permit users to edit a embedded cljs dsl in the browser. How would I best control/restrict namespaces and is accessing the 'textContent' of the editor div the best way to access the code in such a scenario?

Yehonathan Sharvit14:02:41

@thheller I tried your code but I get an error. The code:

(ns regl.core
    (:require ["regl" :refer [regl]]))

(enable-console-print!)

(println "Hello")
(regl)
The error:
Uncaught TypeError: module$Users$viebel$tutorials$regl$node_modules$regl$dist$regl.regl is not a function

mfikes14:02:35

@viebel I'm curious if you can replace (regl) with ((js/require "regl"))

mfikes14:02:41

Like (def regl ((js/require "regl")))

Yehonathan Sharvit14:02:18

@mfikes I get this error

Uncaught ReferenceError: require is not defined

mfikes14:02:13

Ahh, right, your code is not executing in Node.js

mfikes14:02:47

Doing (module$Users$viebel$tutorials$regl$node_modules$regl$dist$regl) would be a fragile hack

jrbrodie7715:02:36

I’m looking for a repl for use with figwheel that gives me command history, autocomplete etc. (I’m also using cursive fwiw). Is Dirac my best bet?

joelsanchez15:02:35

you mention you're using Cursive...are command history and autocomplete not working for you? they work for me

bhauman15:02:22

@jrbrodie77 figwheel is going to have this by the end of the the coming week

bhauman15:02:42

in the terminal repl

bhauman16:02:32

I just deployed [lein-figwheel "0.5.15-SNAPSHOT"] with added rebel-readline support. Be sure to launch figwheel with lein trampoline figwheel and ditch rlwrap!

bhauman16:02:56

@jrbrodie77 so actually you can start having the features you asked for right now

thheller17:02:59

@viebel (:require ["regl" :as regl]) not :refer

robert-stuttaford17:02:03

i’m looking forward to the day that clj runs rebel-readline instead of rlwrap, @bhauman 🙂 this is amazing work!

Yehonathan Sharvit18:02:30

@thheller thx Still doesn’t work BTW, I’m in the browser and I’m using leiningen with lein-cljsbuild. My cljs code is:

(ns regl.core
    (:require [regl :as regl]))

(enable-console-print!)

(println "Hello")
(def rrr (regl))
is transpiled to:
File Edit Options Buffers Tools Javascript Help
// Compiled by ClojureScript 1.9.946 {}
goog.provide('regl.core');
goog.require('cljs.core');
goog.require('module$Users$viebel$tutorials$regl$node_modules$regl$dist$regl');
cljs.core.enable_console_print_BANG_.call(null);
cljs.core.println.call(null,"Hello");
regl.core.rrr = module$Users$viebel$tutorials$regl$node_modules$regl$dist$regl();

//# sourceMappingURL=core.js.map

mfikes18:02:26

@viebel So now with that, you can't do this?

(.clear rrr #js {:color #js [0 0 0 1] :depth 1})

Yehonathan Sharvit18:02:34

@mfikes No. I’m having this error in the browser

Uncaught TypeError: module$Users$viebel$tutorials$regl$node_modules$regl$dist$regl is not a function

noisesmith18:02:15

what if you leave out the :as part?

mfikes18:02:45

I would try evaluating module$Users$viebel$tutorials$regl$node_modules$regl$dist$regl in a REPL to see what it is 🙂

Yehonathan Sharvit18:02:44

module$Users$viebel$tutorials$regl$node_modules$regl$dist$regl is an empty js object

noisesmith18:02:16

my hunch is that :as pointing to the same symbol as the thing itself is somehow shadowing

noisesmith18:02:37

which is a bug in the ns macro implementation in clojurescript if so

mfikes18:02:54

Another hunch: The regl loading code (which requires you to evaluate it as a function) makes for something that Closure can't grok.

Yehonathan Sharvit18:02:10

@noisesmith same error with

(ns regl.core
    (:require [regl :as koo]))

rauh18:02:02

@viebel Is js/createREGL available?

rauh18:02:40

So then that case kicked in. Check the first few lines of the regl.js file

Yehonathan Sharvit18:02:28

Something interesting: I’ve switche from :optimization :none to :optimization :whitespace and now I see a closure related error during compilation

SEVERE: /Users/viebel/tutorials/regl_tuto/resources/public/js/compiled/out/node_modules/regl/dist/regl.js:52: ERROR - Parse error. identifier is a reserved word
"[object Uint32Array]":5125,"[object Float32Array]":5126,"[object Float64Array]":5121,"[object ArrayBuffer]":5121};var int8=5120;var int16=5122;var int32=5124;var uint8=5121;var uint16=5123;var uint32=5125;var float=5126;var float32=5126;var glTypes={int8:int8,int16:int16,int32:int32,uint8:uint8,uint16:uint16,uint32:uint32,"float":float,float32:float32};var dynamic$1=35048;var stream=35040;var usageTypes={dynamic:dynamic$1,stream:stream,"static":35044};var arrayFlatten=flattenUtils.flatten;var arrayShape=
                                                                                                                                                                                                                 

thheller22:02:18

since :npm-deps is pretty unreliable you may want to try shadow-cljs. made a quick regl demo https://github.com/thheller/regl-example

Yehonathan Sharvit18:02:44

@mfikes doen’t mean that your guess was accurate?

mfikes18:02:44

Hmm. Dunno what that means.

sekao20:02:09

@mac yes you read textContent to get the code from paren-soup. if you are using the instarepl feature you can pass a :compiler-fn option which runs every time the user edits something

mac20:02:41

@sekao Cool, thanks.

jrbrodie7720:02:42

@Bhauman thanks! I’ll try it out. Thanks for the tools, this stuff is super important. In my day job I work in jupyter/ipython and have seen it go from toy to very productive environment, so great to see cljs moving along too.

jrbrodie7720:02:45

@joelsanchez when I run figwheel in cursive I don’t get a history and autocomplete

joelsanchez21:02:49

i start a lein repl from cursive and then execute "cljs-repl" (from the figwheel api)

joelsanchez21:02:58

that works flawlessly

jrbrodie7722:02:15

I’ll try that. I’ve been doing lein figwheel in cursive.