Fork me on GitHub
#clojurescript
<
2016-07-14
>
adamw05:07:43

Hi folks, apologies for possibly an obvious question. I'm getting an error as follows trying to write the equivalent of

new PDFJS.DefaultTextLayerFactory()
clojurescript:
(new js/PDFJS.DefaultTextLayerFactory)
error:
memo.cljs:70 Uncaught (in promise) TypeError: PDFJS.DefaultTextLayerFactory is not a constructor(…)

adamw05:07:26

the definition of DefaultTextLayerFactory is a prototype, like so:

adamw05:07:55

What is the correct cljs way to invoke this?

adamw05:07:32

It's exported here

adamw06:07:22

hmm. It seems that it's defined like this in pdf.ext.js in the clsjs package:

"PDFPageView": {
        "setPdfPage": function () {},
        "update": function () {},
        "draw": function () {}
    },
    "DefaultTextLayerFactory": {}
I don't know if that means there is only one object, and if so how I can access its members?

hueyp06:07:49

is there a flag to use non-minified react w/ cljsjs with advanced optimizations?

rohit08:07:48

@adamw: I’m using the pdfjs package from cljsjs and it seems that there is no such thing as PDFJS.DefaultTextLayerFactory

adamw08:07:14

@rohit: but yeah, it

rohit08:07:26

@adamw: I saw that as well.

adamw08:07:28

is just a 'thing'. Not a function or anything useful. So no idea how to work with it

adamw08:07:56

@rohit: also it seems like our version of pdfjs is lagging a -looong- way behind pdf/js current

adamw08:07:44

1.1.3 but github is on like 1.4.20

adamw08:07:16

need to learn how this clsjs packaging thing works; I don't understand what the .ext.js file actually does

rohit08:07:18

@adamw: see my screenshot for what I mean

rohit08:07:37

for me PDFJS.DefaultTextLayerFactory is undefined

rohit08:07:29

For packaging help, please use the #C0E66E1H7 channel. I can help you there.

adamw10:07:20

@rohit: one thing I don't understand. So those definitions in the extern file (PDFPageView/DefaultTextLayerFactory) are from viewer.inc.js, not from pdf.js. This discussion (https://github.com/cljsjs/packages/pull/143) seems to imply that somehow this works, but I would have thought we would need another .extern file for viewer.inc.js, or can we just munge it into one file?

rohit10:07:23

@adamw: lets talk on #C0E66E1H7. Seems to be that the deps.cljs file for it may not be accurate

schmandle10:07:46

Hi. I'm in the process of adding specs to a Clojurescript application, and I am seeing some poor performance. Running through the test suite without instrumentation takes about 15 seconds on my laptop. After adding a call to instrument-all in my test runner it takes about 5 minutes. This is after adding specs to only a couple of namespaces. Is this to be expected, or does it indicate that I am doing something wrong?

schmandle10:07:16

It seems that higher order functions are the main culprit. For example, an invocation of this function:

(defn- alter-active-word
  [words f]
  (mapv (fn [word]
          (if (active-item? word)
            (f word)
            word))
        words))

(s/fdef alter-active-word
        :args (s/cat :words :command-line/words
                     :f     (s/fspec :args (s/cat :w :command-line/wordwrap)
                                     :ret  :command-line/wordwrap))
        :ret  :command-line/words)
runs in 0.20ms when not instrumented and 314.17ms when instrumented.

akiel15:07:11

Hi, is there something like alias in cljs? I like to define an alias for a namespace which doesn’t exist only to be able to use shorter namespaced keywords.

ethangracer16:07:29

anybody know of a way to detect if a PersistentVector is a map entry when using prewalk in cljs?

hueyp16:07:23

@akiel: have you tried ::alias/foo or is that only clojure?

akiel16:07:24

@hueyp: yes that works if I define the alias in :require but than the namespace has to exist - I just don’t have the namespace in cljs - it comes from the server

hueyp16:07:26

gotcha! dunno~

ag17:07:05

does anyone know if it’s possible to use https://github.com/dgrnbrg/spyscope in CLJS?

ag17:07:48

or maybe there’s a way to “inject” stuff with figwheel? then I could use [taoensso.timbre :refer-macros [spy]]?

miguelb18:07:05

posted this in #C0620C0C8 but but thought I would add it here too — has anyone used https://github.com/airbnb/enzyme with clojurescript?

dnolen18:07:18

@schmandle: to be expected, but I know they are still collecting feedback

dnolen18:07:02

@schmandle: at this point probably better to demonstrate what you are doing with clojure.spec and report that on the Clojure mailing list - cljs.spec is more or less a direct port

dnolen18:07:00

@akiel: doesn’t exist yet, but there’s some discussion bubbling around that for Clojure, you should make your desire know there - we’re only going to get it if Clojure gets it

dnolen18:07:22

(we’re not going to do alias but something at the ns form level is what has been thrown around)

akiel18:07:40

@dnolen: thanks did not know about discussions of this at the ns form level