   {:color 0
    :angle 0})
 
-(defn update [state]
+(defn update-state [state]
   (let [{:keys [color angle]} state]
     {:color (mod (+ color 0.7) 255)
      :angle (mod (+ angle 0.1) q/TWO-PI)}))
 
-(defn draw [state]
+(defn draw-state [state]
   (q/background 240)
   (q/fill (:color state) 255 255)
   (let [angle (:angle state)

  :host \"my\"
  :size [500 500]
  :setup setup
  :update update
  :draw draw
  :middleware [m/fun-mode])")

(defn extract-size [sketch-source]
  (letfn [(read-all [text]
            (try
              (let [reader (string-push-back-reader text)
                    endof (gensym)]
                (binding [reader/*read-eval* false
                          reader/*data-readers* tags/*cljs-data-readers*]
                  (->> #(reader/read reader false endof)
                       (repeatedly)
                       (take-while #(not= % endof))
                       (doall))))
              (catch Exception e
                (println e)
                '())))
          (defsketch? [form]
            (and (list? form)
                 (symbol? (first form))
                 (= "defsketch" (name (first form)))))

                 (filter #(= :size (first %)))
                 (map second)
                 first))]
    (let [size (-> sketch find-defsketch get-size)]
      (if (and (or (list? size) (vector? size))
               (every? number? size))
        (vec (take 2 size))
        nil))))

(defn compile-cljs [cljs-forms]
  (binding [cljs.analyzer/*cljs-file* "something.cljs"]
    (cljs-env/with-compiler-env (cljs-env/default-compiler-env)
      (cljs/-compile cljs-forms {}))))

(def id (atom 0))
(def sketches (atom (cache/lru-cache-factory {} :threshold 128)))
