Initial commit; does not yet work.

This commit is contained in:
Simon Brooke 2020-02-25 09:45:17 +00:00
commit bca0f8492d
600 changed files with 171999 additions and 0 deletions

View file

@ -0,0 +1,563 @@
(ns figwheel.client.file-reloading
(:require
[figwheel.client.utils :as utils :refer-macros [dev-assert]]
[goog.Uri :as guri]
[goog.string]
[goog.object :as gobj]
[goog.net.jsloader :as loader]
[goog.html.legacyconversions :as conv]
[goog.string :as gstring]
[clojure.string :as string]
[clojure.set :refer [difference]]
[cljs.core.async :refer [put! chan <! map< close! timeout alts!] :as async])
(:require-macros
[cljs.core.async.macros :refer [go go-loop]])
(:import [goog.async Deferred]))
(declare queued-file-reload)
(defonce figwheel-meta-pragmas (atom {}))
;; you can listen to this event easily like so:
;; document.body.addEventListener("figwheel.js-reload", function (e) {console.log(e.detail);} );
(defn on-jsload-custom-event [url]
(utils/dispatch-custom-event "figwheel.js-reload" url))
;; you can listen to this event easily like so:
;; document.body.addEventListener("figwheel.before-js-reload", function (e) { console.log(e.detail);} );
(defn before-jsload-custom-event [files]
(utils/dispatch-custom-event "figwheel.before-js-reload" files))
;; you can listen to this event easily like so:
;; document.body.addEventListener("figwheel.css-reload", function (e) {console.log(e.detail);} );
(defn on-cssload-custom-event [files]
(utils/dispatch-custom-event "figwheel.css-reload" files))
#_(defn all? [pred coll]
(reduce #(and %1 %2) true (map pred coll)))
(defn namespace-file-map? [m]
(or
(and (map? m)
(string? (:namespace m))
(or (nil? (:file m))
(string? (:file m)))
(= (:type m)
:namespace))
(do
(println "Error not namespace-file-map" (pr-str m))
false)))
;; this assumes no query string on url
(defn add-cache-buster [url]
(dev-assert (string? url))
(.makeUnique (guri/parse url)))
(defn name->path [ns]
(dev-assert (string? ns))
(gobj/get js/goog.dependencies_.nameToPath ns))
(defn provided? [ns]
(gobj/get js/goog.dependencies_.written (name->path ns)))
(defn immutable-ns? [name]
(or (#{"goog" "cljs.core" "cljs.nodejs"} name)
(goog.string/startsWith "clojure." name)
(goog.string/startsWith "goog." name)))
(defn get-requires [ns]
(->> ns
name->path
(gobj/get js/goog.dependencies_.requires)
(gobj/getKeys)
(filter #(not (immutable-ns? %)))
set))
(defonce dependency-data (atom {:pathToName {} :dependents {}}))
(defn path-to-name! [path name]
(swap! dependency-data update-in [:pathToName path] (fnil clojure.set/union #{}) #{name}))
(defn setup-path->name!
"Setup a path to name dependencies map.
That goes from path -> #{ ns-names }"
[]
;; we only need this for dependents
(let [nameToPath (gobj/filter js/goog.dependencies_.nameToPath
(fn [v k o] (gstring/startsWith v "../")))]
(gobj/forEach nameToPath (fn [v k o] (path-to-name! v k)))))
(defn path->name
"returns a set of namespaces defined by a path"
[path]
(get-in @dependency-data [:pathToName path]))
(defn name-to-parent! [ns parent-ns]
(swap! dependency-data update-in [:dependents ns] (fnil clojure.set/union #{}) #{parent-ns}))
(defn setup-ns->dependents!
"This reverses the goog.dependencies_.requires for looking up ns-dependents."
[]
(let [requires (gobj/filter js/goog.dependencies_.requires
(fn [v k o] (gstring/startsWith k "../")))]
(gobj/forEach
requires
(fn [v k _]
(gobj/forEach
v
(fn [v' k' _]
(doseq [n (path->name k)]
(name-to-parent! k' n))))))))
(defn ns->dependents [ns]
(get-in @dependency-data [:dependents ns]))
(defn in-upper-level? [topo-state current-depth dep]
(some (fn [[_ v]] (and v (v dep)))
(filter (fn [[k v]] (> k current-depth)) topo-state)))
(defn build-topo-sort [get-deps]
(let [get-deps (memoize get-deps)]
(letfn [(topo-sort-helper* [x depth state]
(let [deps (get-deps x)]
(when-not (empty? deps) (topo-sort* deps depth state))))
(topo-sort*
([deps]
(topo-sort* deps 0 (atom (sorted-map))))
([deps depth state]
(swap! state update-in [depth] (fnil into #{}) deps)
(doseq [dep deps]
(when (and dep (not (in-upper-level? @state depth dep)))
(topo-sort-helper* dep (inc depth) state)))
(when (= depth 0)
(elim-dups* (reverse (vals @state))))))
(elim-dups* [[x & xs]]
(if (nil? x)
(list)
(cons x (elim-dups* (map #(difference % x) xs)))))]
topo-sort*)))
(defn get-all-dependencies [ns]
(let [topo-sort' (build-topo-sort get-requires)]
(apply concat (topo-sort' (set [ns])))))
(defn get-all-dependents [nss]
(let [topo-sort' (build-topo-sort ns->dependents)]
(filter (comp not immutable-ns?)
(reverse (apply concat (topo-sort' (set nss)))))))
#_(prn "dependents" (get-all-dependents [ "example.core" "figwheel.client.file_reloading" "cljs.core"]))
#_(prn "dependencies" (get-all-dependencies "figwheel.client.file_reloading"))
#_(time (get-all-dependents [ "example.core" "figwheel.client.file_reloading" "cljs.core"]))
(defn unprovide! [ns]
(let [path (name->path ns)]
(gobj/remove js/goog.dependencies_.visited path)
(gobj/remove js/goog.dependencies_.written path)
(gobj/remove js/goog.dependencies_.written (str js/goog.basePath path))))
;; this matches goog behavior in url resolution should actually just
;; use that code
(defn resolve-ns [ns] (str goog/basePath (name->path ns)))
(defn addDependency [path provides requires]
(doseq [prov provides]
(path-to-name! path prov)
(doseq [req requires]
(name-to-parent! req prov))))
(defn figwheel-require [src reload]
;; require is going to be called
(set! (.-require js/goog) figwheel-require)
(when (= reload "reload-all")
(doseq [ns (get-all-dependencies src)] (unprovide! ns)))
(when reload (unprovide! src))
(.require_figwheel_backup_ js/goog src))
(defn bootstrap-goog-base
"Reusable browser REPL bootstrapping. Patches the essential functions
in goog.base to support re-loading of namespaces after page load."
[]
;; The biggest problem here is that clojure.browser.repl might have
;; patched this or might patch this afterward
(when-not js/COMPILED
(set! (.-require_figwheel_backup_ js/goog) (or js/goog.require__ js/goog.require))
;; suppress useless Google Closure error about duplicate provides
(set! (.-isProvided_ js/goog) (fn [name] false))
;; provide cljs.user
(setup-path->name!)
(setup-ns->dependents!)
(set! (.-addDependency_figwheel_backup_ js/goog) js/goog.addDependency)
(set! (.-addDependency js/goog)
(fn [& args]
(apply addDependency args)
(apply (.-addDependency_figwheel_backup_ js/goog) args)))
(goog/constructNamespace_ "cljs.user")
;; we must reuse Closure library dev time dependency management, under namespace
;; reload scenarios we simply delete entries from the correct
;; private locations
(set! (.-CLOSURE_IMPORT_SCRIPT goog/global) queued-file-reload)
(set! (.-require js/goog) figwheel-require)))
(defn patch-goog-base []
(defonce bootstrapped-cljs (do (bootstrap-goog-base) true)))
(def gloader
(cond
(exists? loader/safeLoad)
#(loader/safeLoad (conv/trustedResourceUrlFromString (str %1)) %2)
(exists? loader/load) #(loader/load (str %1) %2)
:else (throw (ex-info "No remote script loading function found." {}))))
(defn reload-file-in-html-env
[request-url callback]
(dev-assert (string? request-url) (not (nil? callback)))
(doto (gloader (add-cache-buster request-url) #js {:cleanupWhenDone true})
(.addCallback #(apply callback [true]))
(.addErrback #(apply callback [false]))))
(def ^:export write-script-tag-import reload-file-in-html-env)
(defn ^:export worker-import-script [request-url callback]
(dev-assert (string? request-url) (not (nil? callback)))
(callback (try
(do (.importScripts js/self (add-cache-buster request-url))
true)
(catch js/Error e
(utils/log :error (str "Figwheel: Error loading file " request-url))
(utils/log :error (.-stack e))
false))))
(defn ^:export create-node-script-import-fn []
(let [node-path-lib (js/require "path")
;; just finding a file that is in the cache so we can
;; figure out where we are
util-pattern (str (.-sep node-path-lib)
(.join node-path-lib "goog" "bootstrap" "nodejs.js"))
util-path (gobj/findKey js/require.cache (fn [v k o] (gstring/endsWith k util-pattern)))
parts (-> (string/split util-path #"[/\\]") pop pop)
root-path (string/join (.-sep node-path-lib) parts)]
(fn [request-url callback]
(dev-assert (string? request-url) (not (nil? callback)))
(let [cache-path (.resolve node-path-lib root-path request-url)]
(gobj/remove (.-cache js/require) cache-path)
(callback (try
(js/require cache-path)
(catch js/Error e
(utils/log :error (str "Figwheel: Error loading file " cache-path))
(utils/log :error (.-stack e))
false)))))))
;; TODO
#_(defn async-fetch-import-script [request-url callback]
(let [base-url (or goog.global.FIGWHEEL_RELOAD_BASE_URL "http://localhost:8081")]
(doto (js/fetch (str base-url "/" request-url))
(.then (fn [r] ))
)))
(def reload-file*
(condp = (utils/host-env?)
:node (create-node-script-import-fn)
:html write-script-tag-import
;; TODO react native reloading not supported internally yet
;:react-native
#_(if (utils/worker-env?)
worker-import-script
async-fetch-import-script)
:worker worker-import-script
(fn [a b] (throw "Reload not defined for this platform"))))
(defn reload-file [{:keys [request-url] :as file-msg} callback]
(dev-assert (string? request-url) (not (nil? callback)))
(utils/debug-prn (str "FigWheel: Attempting to load " request-url))
((or (gobj/get goog.global "FIGWHEEL_IMPORT_SCRIPT") reload-file*)
request-url
(fn [success?]
(if success?
(do
(utils/debug-prn (str "FigWheel: Successfully loaded " request-url))
(apply callback [(assoc file-msg :loaded-file true)]))
(do
(utils/log :error (str "Figwheel: Error loading file " request-url))
(apply callback [file-msg]))))))
;; for goog.require consumption
(defonce reload-chan (chan))
(defonce on-load-callbacks (atom {}))
(defonce dependencies-loaded (atom []))
(defn blocking-load [url]
(let [out (chan)]
(reload-file
{:request-url url}
(fn [file-msg]
(put! out file-msg)
(close! out)))
out))
(defonce reloader-loop
(go-loop []
(when-let [[url opt-source-text] (<! reload-chan)]
(cond
opt-source-text
(js/eval opt-source-text)
url
(let [file-msg (<! (blocking-load url))]
(if-let [callback (get @on-load-callbacks url)]
(callback file-msg)
(swap! dependencies-loaded conj file-msg))))
(recur))))
(defn queued-file-reload
([url] (queued-file-reload url nil))
([url opt-source-text] (put! reload-chan [url opt-source-text])))
(defn require-with-callback [{:keys [namespace] :as file-msg} callback]
(let [request-url (resolve-ns namespace)]
(swap! on-load-callbacks assoc request-url
(fn [file-msg']
(swap! on-load-callbacks dissoc request-url)
(apply callback [(merge file-msg (select-keys file-msg' [:loaded-file]))])))
;; we are forcing reload here
(figwheel-require (name namespace) true)))
(defn figwheel-no-load? [{:keys [namespace] :as file-msg}]
(let [meta-pragmas (get @figwheel-meta-pragmas (name namespace))]
(:figwheel-no-load meta-pragmas)))
(defn ns-exists? [namespace]
(some? (reduce (fnil gobj/get #js{})
goog.global (string/split (name namespace) "."))))
(defn reload-file? [{:keys [namespace] :as file-msg}]
(dev-assert (namespace-file-map? file-msg))
(let [meta-pragmas (get @figwheel-meta-pragmas (name namespace))]
(and
(not (figwheel-no-load? file-msg))
(or
(:figwheel-always meta-pragmas)
(:figwheel-load meta-pragmas)
;; might want to use .-visited here
(provided? (name namespace))
(ns-exists? namespace)))))
(defn js-reload [{:keys [request-url namespace] :as file-msg} callback]
(dev-assert (namespace-file-map? file-msg))
(if (reload-file? file-msg)
(require-with-callback file-msg callback)
(do
(utils/debug-prn (str "Figwheel: Not trying to load file " request-url))
(apply callback [file-msg]))))
(defn reload-js-file [file-msg]
(let [out (chan)]
(js-reload
file-msg
(fn [url]
#_(patch-goog-base)
(put! out url)
(close! out)))
out))
(defn load-all-js-files
"Returns a chanel with one collection of loaded filenames on it."
[files]
(let [out (chan)]
(go-loop [[f & fs] files]
(if-not (nil? f)
(do (put! out (<! (reload-js-file f)))
(recur fs))
(close! out)))
(async/into [] out)))
(defn eval-body [{:keys [eval-body file]} opts]
(when (and eval-body (string? eval-body))
(let [code eval-body]
(try
(utils/debug-prn (str "Evaling file " file))
(utils/eval-helper code opts)
(catch :default e
(utils/log :error (str "Unable to evaluate " file)))))))
(defn expand-files [files]
(let [deps (get-all-dependents (map :namespace files))]
(filter (comp not
(partial re-matches #"figwheel\.connect.*")
:namespace)
(map
(fn [n]
(if-let [file-msg (first (filter #(= (:namespace %) n) files))]
file-msg
{:type :namespace :namespace n}))
deps))))
(defn sort-files [files]
(if (<= (count files) 1) ;; no need to sort if only one
files
(let [keep-files (set (keep :namespace files))]
(filter (comp keep-files :namespace) (expand-files files)))))
(defn get-figwheel-always []
(map (fn [[k v]] {:namespace k :type :namespace})
(filter (fn [[k v]]
(:figwheel-always v)) @figwheel-meta-pragmas)))
(defn reload-js-files [{:keys [before-jsload on-jsload reload-dependents] :as opts}
{:keys [files figwheel-meta recompile-dependents] :as msg}]
(when-not (empty? figwheel-meta)
(reset! figwheel-meta-pragmas figwheel-meta))
(go
(before-jsload files)
(before-jsload-custom-event files)
;; evaluate the eval bodies first
;; for now this is only for updating dependencies
;; we are not handling removals
;; TODO handle removals
(let [eval-bodies (filter #(:eval-body %) files)]
(when (not-empty eval-bodies)
(doseq [eval-body-file eval-bodies]
(eval-body eval-body-file opts))))
(reset! dependencies-loaded (list))
(let [all-files (filter #(and (:namespace %)
(not (:eval-body %))
(not (figwheel-no-load? %)))
files)
;; add in figwheel always
all-files (concat all-files (get-figwheel-always))
all-files (if (or reload-dependents recompile-dependents)
(expand-files all-files)
(sort-files all-files))
;_ (prn "expand-files" (expand-files all-files))
;_ (prn "sort-files" (sort-files all-files))
res' (<! (load-all-js-files all-files))
res (filter :loaded-file res')
files-not-loaded (filter #(not (:loaded-file %)) res')
dependencies-that-loaded (filter :loaded-file @dependencies-loaded)]
(when (not-empty dependencies-that-loaded)
(utils/log :debug "Figwheel: loaded these dependencies")
(utils/log (pr-str (map (fn [{:keys [request-url]}]
(string/replace request-url goog/basePath ""))
(reverse dependencies-that-loaded)))))
(when (not-empty res)
(utils/log :debug "Figwheel: loaded these files")
(utils/log (pr-str (map (fn [{:keys [namespace file]}]
(if namespace
(name->path (name namespace))
file)) res)))
(js/setTimeout #(do
(on-jsload-custom-event res)
(apply on-jsload [res])) 10))
(when (not-empty files-not-loaded)
(utils/log :debug "Figwheel: NOT loading these files ")
(let [{:keys [figwheel-no-load not-required]}
(group-by
(fn [{:keys [namespace]}]
(let [meta-data (get @figwheel-meta-pragmas (name namespace))]
(cond
(nil? meta-data) :not-required
(meta-data :figwheel-no-load) :figwheel-no-load
:else :not-required)))
files-not-loaded)]
(when (not-empty figwheel-no-load)
(utils/log (str "figwheel-no-load meta-data: "
(pr-str (map (comp name->path :namespace) figwheel-no-load)))))
(when (not-empty not-required)
(utils/log (str "not required: " (pr-str (map :file not-required))))))))))
;; CSS reloading
(defn current-links []
(.call (.. js/Array -prototype -slice)
(.getElementsByTagName js/document "link")))
(defn truncate-url [url]
(-> (first (string/split url #"\?"))
(string/replace-first (str (.-protocol js/location) "//") "")
(string/replace-first ".*://" "")
(string/replace-first #"^//" "")
(string/replace-first #"[^\/]*" "")))
(defn matches-file?
[{:keys [file]} link]
(when-let [link-href (.-href link)]
(let [match (string/join "/"
(take-while identity
(map #(if (= %1 %2) %1 false)
(reverse (string/split file "/"))
(reverse (string/split (truncate-url link-href) "/")))))
match-length (count match)
file-name-length (count (last (string/split file "/")))]
(when (>= match-length file-name-length) ;; has to match more than the file name length
{:link link
:link-href link-href
:match-length match-length
:current-url-length (count (truncate-url link-href))}))))
(defn get-correct-link [f-data]
(when-let [res (first
(sort-by
(fn [{:keys [match-length current-url-length]}]
(- current-url-length match-length))
(keep #(matches-file? f-data %)
(current-links))))]
(:link res)))
(defn clone-link [link url]
(let [clone (.createElement js/document "link")]
(set! (.-rel clone) "stylesheet")
(set! (.-media clone) (.-media link))
(set! (.-disabled clone) (.-disabled link))
(set! (.-href clone) (add-cache-buster url))
clone))
(defn create-link [url]
(let [link (.createElement js/document "link")]
(set! (.-rel link) "stylesheet")
(set! (.-href link) (add-cache-buster url))
link))
(defn distinctify [key seqq]
(vals (reduce #(assoc %1 (get %2 key) %2) {} seqq)))
(defn add-link-to-document [orig-link klone finished-fn]
(let [parent (.-parentNode orig-link)]
(if (= orig-link (.-lastChild parent))
(.appendChild parent klone)
(.insertBefore parent klone (.-nextSibling orig-link)))
;; prevent css removal flash
(js/setTimeout #(do
(.removeChild parent orig-link)
(finished-fn))
300)))
(defonce reload-css-deferred-chain (atom (.succeed Deferred)))
(defn reload-css-file [f-data fin]
(if-let [link (get-correct-link f-data)]
(add-link-to-document link (clone-link link (.-href link))
#(fin (assoc f-data :loaded true)))
(fin f-data)))
(defn reload-css-files* [deferred f-datas on-cssload]
(-> deferred
(utils/mapConcatD reload-css-file f-datas)
(utils/liftContD (fn [f-datas' fin]
(let [loaded-f-datas (filter :loaded f-datas')]
(on-cssload-custom-event loaded-f-datas)
(when (fn? on-cssload)
(on-cssload loaded-f-datas)))
(fin)))))
(defn reload-css-files [{:keys [on-cssload]} {:keys [files] :as files-msg}]
(when (utils/html-env?)
(when-let [f-datas (not-empty (distinctify :file files))]
(swap! reload-css-deferred-chain reload-css-files* f-datas on-cssload))))

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,422 @@
(ns figwheel.client.heads-up
(:require
[clojure.string :as string]
[figwheel.client.socket :as socket]
[figwheel.client.utils :as utils]
[cljs.core.async :refer [put! chan <! map< close! timeout alts!] :as async]
[goog.string]
[goog.dom.dataset :as data]
[goog.object :as gobj]
[goog.dom :as dom]
[cljs.pprint :as pp])
(:require-macros
[cljs.core.async.macros :refer [go go-loop]]))
(declare clear cljs-logo-svg)
;; cheap hiccup
(defn node [t attrs & children]
(let [e (.createElement js/document (name t))]
(doseq [k (keys attrs)] (.setAttribute e (name k) (get attrs k)))
(doseq [ch children] (.appendChild e ch)) ;; children
e))
(defmulti heads-up-event-dispatch (fn [dataset] (.-figwheelEvent dataset)))
(defmethod heads-up-event-dispatch :default [_] {})
(defmethod heads-up-event-dispatch "file-selected" [dataset]
(socket/send! {:figwheel-event "file-selected"
:file-name (.-fileName dataset)
:file-line (.-fileLine dataset)
:file-column (.-fileColumn dataset)}))
(defmethod heads-up-event-dispatch "close-heads-up" [dataset] (clear))
(defn ancestor-nodes [el]
(iterate (fn [e] (.-parentNode e)) el))
(defn get-dataset [el]
(first (keep (fn [x] (when (.. x -dataset -figwheelEvent) (.. x -dataset)))
(take 4 (ancestor-nodes el)))))
(defn heads-up-onclick-handler [event]
(let [dataset (get-dataset (.. event -target))]
(.preventDefault event)
(when dataset
(heads-up-event-dispatch dataset))))
(defn ensure-container []
(let [cont-id "figwheel-heads-up-container"
content-id "figwheel-heads-up-content-area"]
(if-not (.querySelector js/document (str "#" cont-id))
(let [el (node :div { :id cont-id
:style
(str "-webkit-transition: all 0.2s ease-in-out;"
"-moz-transition: all 0.2s ease-in-out;"
"-o-transition: all 0.2s ease-in-out;"
"transition: all 0.2s ease-in-out;"
"font-size: 13px;"
"border-top: 1px solid #f5f5f5;"
"box-shadow: 0px 0px 1px #aaaaaa;"
"line-height: 18px;"
"color: #333;"
"font-family: monospace;"
"padding: 0px 10px 0px 70px;"
"position: fixed;"
"bottom: 0px;"
"left: 0px;"
"height: 0px;"
"opacity: 0.0;"
"box-sizing: border-box;"
"z-index: 10000;"
"text-align: left;"
) })]
(set! (.-onclick el) heads-up-onclick-handler)
(set! (.-innerHTML el) cljs-logo-svg)
(.appendChild el (node :div {:id content-id}))
(-> (.-body js/document)
(.appendChild el))))
{ :container-el (.getElementById js/document cont-id)
:content-area-el (.getElementById js/document content-id) }
))
(defn set-style! [{:keys [container-el]} st-map]
(mapv
(fn [[k v]]
(gobj/set (.-style container-el) (name k) v))
st-map))
(defn set-content! [{:keys [content-area-el] :as c} dom-str]
(set! (.-innerHTML content-area-el) dom-str))
(defn get-content [{:keys [content-area-el]}]
(.-innerHTML content-area-el))
(defn close-link []
(str "<a style=\""
"float: right;"
"font-size: 18px;"
"text-decoration: none;"
"text-align: right;"
"width: 30px;"
"height: 30px;"
"color: rgba(84,84,84, 0.5);"
"\" href=\"#\" data-figwheel-event=\"close-heads-up\">"
"x"
"</a>"))
(defn display-heads-up [style msg]
(go
(let [c (ensure-container)]
(set-style! c (merge {
:paddingTop "10px"
:paddingBottom "10px"
:width "100%"
:minHeight "68px"
:opacity "1.0" }
style))
(set-content! c msg)
(<! (timeout 300))
(set-style! c {:height "auto"}))))
(defn heading
([s] (heading s ""))
([s sub-head]
(str "<div style=\""
"font-size: 26px;"
"line-height: 26px;"
"margin-bottom: 2px;"
"padding-top: 1px;"
"\">"
s
" <span style=\""
"display: inline-block;"
"font-size: 13px;"
"\">"
sub-head
"</span></div>")))
(defn file-selector-div [file-name line-number column-number msg]
(str "<div style=\"cursor: pointer;\" data-figwheel-event=\"file-selected\" data-file-name=\""
file-name "\" data-file-line=\"" line-number "\" data-file-column=\"" column-number
"\">" msg "</div>"))
(defn format-line [msg {:keys [file line column]}]
(let [msg (goog.string/htmlEscape msg)]
(if (or file line)
(file-selector-div file line column msg)
(str "<div>" msg "</div>"))))
(defn escape [x]
(goog.string/htmlEscape x))
(defn pad-line-number [n line-number]
(let [len (count ((fnil str "") line-number))]
(-> (if (< len n)
(apply str (repeat (- n len) " "))
"")
(str line-number))))
(defn inline-error-line [style line-number line]
(str "<span style='" style "'>" "<span style='color: #757575;'>" line-number " </span>" (escape line) "</span>"))
(defn format-inline-error-line [[typ line-number line]]
(condp = typ
:code-line (inline-error-line "color: #999;" line-number line)
:error-in-code (inline-error-line "color: #ccc; font-weight: bold;" line-number line)
:error-message (inline-error-line "color: #D07D7D;" line-number line)
(inline-error-line "color: #666;" line-number line)))
(defn pad-line-numbers [inline-error]
(let [max-line-number-length (count (str (reduce max (map second inline-error))))]
(map #(update-in % [1]
(partial pad-line-number max-line-number-length)) inline-error)))
(defn format-inline-error [inline-error]
(let [lines (map format-inline-error-line (pad-line-numbers inline-error))]
(str "<pre style='whitespace:pre; overflow-x: scroll; display:block; font-family:monospace; font-size:0.8em; border-radius: 3px;"
" line-height: 1.1em; padding: 10px; background-color: rgb(24,26,38); margin-right: 5px'>"
(string/join "\n" lines)
"</pre>")))
(def flatten-exception #(take-while some? (iterate :cause %)))
(defn exception->display-data [{:keys [failed-loading-clj-file
failed-compiling
reader-exception
analysis-exception
display-ex-data
class file line column message
error-inline] :as exception}]
(let [last-message (cond
(and file line)
(str "Please see line " line " of file " file )
file (str "Please see " file)
:else nil)]
{:head (cond
failed-loading-clj-file "Couldn't load Clojure file"
analysis-exception "Could not Analyze"
reader-exception "Could not Read"
failed-compiling "Could not Compile"
:else "Compile Exception")
:sub-head file
:messages (concat
(map
#(str "<div>" % "</div>")
(if message
[(str (if class
(str (escape class)
": ") "")
"<span style=\"font-weight:bold;\">" (escape message) "</span>")
(when display-ex-data
(str "<pre style=\"white-space: pre-wrap\">" (utils/pprint-to-string display-ex-data) "</pre>"))
(when (pos? (count error-inline))
(format-inline-error error-inline))]
(map #(str (escape (:class %))
": " (escape (:message %))) (flatten-exception (:exception-data exception)))))
(when last-message [(str "<div style=\"color: #AD4F4F; padding-top: 3px;\">" (escape last-message) "</div>")]))
:file file
:line line
:column column}))
(defn auto-notify-source-file-line [{:keys [file line column]}]
(socket/send! {:figwheel-event "file-selected"
:file-name (str file)
:file-line (str line)
:file-column (str column)}))
(defn display-exception [exception-data]
(let [{:keys [head
sub-head
messages
last-message
file
line
column]}
(-> exception-data
exception->display-data)
msg (apply str messages
#_(map #(str "<div>" (goog.string/htmlEscape %)
"</div>") messages))]
(display-heads-up {:backgroundColor "rgba(255, 161, 161, 0.95)"}
(str (close-link)
(heading head sub-head)
(file-selector-div file line column msg)))))
(defn warning-data->display-data [{:keys [file line column message error-inline] :as warning-data}]
(let [last-message (cond
(and file line)
(str "Please see line " line " of file " file )
file (str "Please see " file)
:else nil)]
{:head "Compile Warning"
:sub-head file
:messages (concat
(map
#(str "<div>" % "</div>")
[(when message
(str "<span style=\"font-weight:bold;\">" (escape message) "</span>"))
(when (pos? (count error-inline))
(format-inline-error error-inline))])
(when last-message
[(str "<div style=\"color: #AD4F4F; padding-top: 3px; margin-bottom: 10px;\">" (escape last-message) "</div>")]))
:file file
:line line
:column column}))
(defn display-system-warning [header msg]
(display-heads-up {:backgroundColor "rgba(255, 220, 110, 0.95)" }
(str (close-link) (heading header)
"<div>" msg "</div>"
#_(format-line msg {}))))
(defn display-warning [warning-data]
(let [{:keys [head
sub-head
messages
last-message
file
line
column]}
(-> warning-data
warning-data->display-data)
msg (apply str messages)]
(display-heads-up {:backgroundColor "rgba(255, 220, 110, 0.95)" }
(str (close-link)
(heading head sub-head)
(file-selector-div file line column msg)))))
(defn format-warning-message [{:keys [message file line column] :as warning-data}]
(cond-> message
line (str " at line " line)
(and line column) (str ", column " column)
file (str " in file " file)) )
(defn append-warning-message [{:keys [message file line column] :as warning-data}]
(when message
(let [{:keys [content-area-el]} (ensure-container)
el (dom/createElement "div")
child-count (.-length (dom/getChildren content-area-el))]
(if (< child-count 6)
(do
(set! (.-innerHTML el)
(format-line (format-warning-message warning-data)
warning-data))
(dom/append content-area-el el))
(when-let [last-child (dom/getLastElementChild content-area-el)]
(if-let [message-count (data/get last-child "figwheel_count")]
(let [message-count (inc (js/parseInt message-count))]
(data/set last-child "figwheel_count" message-count)
(set! (.-innerHTML last-child)
(str message-count " more warnings have not been displayed ...")))
(dom/append
content-area-el
(dom/createDom "div" #js {:data-figwheel_count 1
:style "margin-top: 3px; font-weight: bold"}
"1 more warning that has not been displayed ..."))))))))
(defn clear []
(go
(let [c (ensure-container)]
(set-style! c { :opacity "0.0" })
(<! (timeout 300))
(set-style! c { :width "auto"
:height "0px"
:minHeight "0px"
:padding "0px 10px 0px 70px"
:borderRadius "0px"
:backgroundColor "transparent" })
(<! (timeout 200))
(set-content! c ""))))
(defn display-loaded-start []
(display-heads-up {:backgroundColor "rgba(211,234,172,1.0)"
:width "68px"
:height "68px"
:paddingLeft "0px"
:paddingRight "0px"
:borderRadius "35px" } ""))
(defn flash-loaded []
(go
(<! (display-loaded-start))
(<! (timeout 400))
(<! (clear))))
(def cljs-logo-svg
"<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>
<svg width='49px' height='49px' style='position:absolute; top:9px; left: 10px;' version='1.1'
xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px'
viewBox='0 0 428 428' enable-background='new 0 0 428 428' xml:space='preserve'>
<circle fill='#fff' cx='213' cy='214' r='213' />
<g>
<path fill='#96CA4B' d='M122,266.6c-12.7,0-22.3-3.7-28.9-11.1c-6.6-7.4-9.9-18-9.9-31.8c0-14.1,3.4-24.9,10.3-32.5
s16.8-11.4,29.9-11.4c8.8,0,16.8,1.6,23.8,4.9l-5.4,14.3c-7.5-2.9-13.7-4.4-18.6-4.4c-14.5,0-21.7,9.6-21.7,28.8
c0,9.4,1.8,16.4,5.4,21.2c3.6,4.7,8.9,7.1,15.9,7.1c7.9,0,15.4-2,22.5-5.9v15.5c-3.2,1.9-6.6,3.2-10.2,4
C131.5,266.2,127.1,266.6,122,266.6z'/>
<path fill='#96CA4B' d='M194.4,265.1h-17.8V147.3h17.8V265.1z'/>
<path fill='#5F7FBF' d='M222.9,302.3c-5.3,0-9.8-0.6-13.3-1.9v-14.1c3.4,0.9,6.9,1.4,10.5,1.4c7.6,0,11.4-4.3,11.4-12.9v-93.5h17.8
v94.7c0,8.6-2.3,15.2-6.8,19.6C237.9,300.1,231.4,302.3,222.9,302.3z M230.4,159.2c0-3.2,0.9-5.6,2.6-7.3c1.7-1.7,4.2-2.6,7.5-2.6
c3.1,0,5.6,0.9,7.3,2.6c1.7,1.7,2.6,4.2,2.6,7.3c0,3-0.9,5.4-2.6,7.2c-1.7,1.7-4.2,2.6-7.3,2.6c-3.2,0-5.7-0.9-7.5-2.6
C231.2,164.6,230.4,162.2,230.4,159.2z'/>
<path fill='#5F7FBF' d='M342.5,241.3c0,8.2-3,14.4-8.9,18.8c-6,4.4-14.5,6.5-25.6,6.5c-11.2,0-20.1-1.7-26.9-5.1v-15.4
c9.8,4.5,19,6.8,27.5,6.8c10.9,0,16.4-3.3,16.4-9.9c0-2.1-0.6-3.9-1.8-5.3c-1.2-1.4-3.2-2.9-6-4.4c-2.8-1.5-6.6-3.2-11.6-5.1
c-9.6-3.7-16.2-7.5-19.6-11.2c-3.4-3.7-5.1-8.6-5.1-14.5c0-7.2,2.9-12.7,8.7-16.7c5.8-4,13.6-5.9,23.6-5.9c9.8,0,19.1,2,27.9,6
l-5.8,13.4c-9-3.7-16.6-5.6-22.8-5.6c-9.4,0-14.1,2.7-14.1,8c0,2.6,1.2,4.8,3.7,6.7c2.4,1.8,7.8,4.3,16,7.5
c6.9,2.7,11.9,5.1,15.1,7.3c3.1,2.2,5.4,4.8,7,7.7C341.7,233.7,342.5,237.2,342.5,241.3z'/>
</g>
<path fill='#96CA4B' stroke='#96CA4B' stroke-width='6' stroke-miterlimit='10' d='M197,392.7c-91.2-8.1-163-85-163-178.3
S105.8,44.3,197,36.2V16.1c-102.3,8.2-183,94-183,198.4s80.7,190.2,183,198.4V392.7z'/>
<path fill='#5F7FBF' stroke='#5F7FBF' stroke-width='6' stroke-miterlimit='10' d='M229,16.1v20.1c91.2,8.1,163,85,163,178.3
s-71.8,170.2-163,178.3v20.1c102.3-8.2,183-94,183-198.4S331.3,24.3,229,16.1z'/>
</svg>")
;; ---- bad compile helper ui ----
(defn close-bad-compile-screen []
(when-let [el (js/document.getElementById "figwheelFailScreen")]
(dom/removeNode el)))
(defn bad-compile-screen []
(let [body (-> (dom/getElementsByTagNameAndClass "body")
(aget 0))]
(close-bad-compile-screen)
#_(dom/removeChildren body)
(dom/append body
(dom/createDom
"div"
#js {:id "figwheelFailScreen"
:style (str "background-color: rgba(24, 26, 38, 0.95);"
"position: absolute;"
"z-index: 9000;"
"width: 100vw;"
"height: 100vh;"
"top: 0px; left: 0px;"
"font-family: monospace")}
(dom/createDom
"div"
#js {:class "message"
:style (str
"color: #FFF5DB;"
"width: 100vw;"
"margin: auto;"
"margin-top: 10px;"
"text-align: center; "
"padding: 2px 0px;"
"font-size: 13px;"
"position: relative")}
(dom/createDom
"a"
#js {:onclick (fn [e]
(.preventDefault e)
(close-bad-compile-screen))
:href "javascript:"
:style "position: absolute; right: 10px; top: 10px; color: #666"}
"X")
(dom/createDom "h2" #js {:style "color: #FFF5DB"}
"Figwheel Says: Your code didn't compile.")
(dom/createDom "div" #js {:style "font-size: 12px"}
(dom/createDom "p" #js { :style "color: #D07D7D;"}
"Keep trying. This page will auto-refresh when your code compiles successfully.")
))))))

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,897 @@
// Compiled by ClojureScript 1.10.520 {}
goog.provide('figwheel.client.heads_up');
goog.require('cljs.core');
goog.require('clojure.string');
goog.require('figwheel.client.socket');
goog.require('figwheel.client.utils');
goog.require('cljs.core.async');
goog.require('goog.string');
goog.require('goog.dom.dataset');
goog.require('goog.object');
goog.require('goog.dom');
goog.require('cljs.pprint');
figwheel.client.heads_up.node = (function figwheel$client$heads_up$node(var_args){
var args__4736__auto__ = [];
var len__4730__auto___30179 = arguments.length;
var i__4731__auto___30180 = (0);
while(true){
if((i__4731__auto___30180 < len__4730__auto___30179)){
args__4736__auto__.push((arguments[i__4731__auto___30180]));
var G__30181 = (i__4731__auto___30180 + (1));
i__4731__auto___30180 = G__30181;
continue;
} else {
}
break;
}
var argseq__4737__auto__ = ((((2) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((2)),(0),null)):null);
return figwheel.client.heads_up.node.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__4737__auto__);
});
figwheel.client.heads_up.node.cljs$core$IFn$_invoke$arity$variadic = (function (t,attrs,children){
var e = document.createElement(cljs.core.name.call(null,t));
var seq__30171_30182 = cljs.core.seq.call(null,cljs.core.keys.call(null,attrs));
var chunk__30172_30183 = null;
var count__30173_30184 = (0);
var i__30174_30185 = (0);
while(true){
if((i__30174_30185 < count__30173_30184)){
var k_30186 = cljs.core._nth.call(null,chunk__30172_30183,i__30174_30185);
e.setAttribute(cljs.core.name.call(null,k_30186),cljs.core.get.call(null,attrs,k_30186));
var G__30187 = seq__30171_30182;
var G__30188 = chunk__30172_30183;
var G__30189 = count__30173_30184;
var G__30190 = (i__30174_30185 + (1));
seq__30171_30182 = G__30187;
chunk__30172_30183 = G__30188;
count__30173_30184 = G__30189;
i__30174_30185 = G__30190;
continue;
} else {
var temp__5720__auto___30191 = cljs.core.seq.call(null,seq__30171_30182);
if(temp__5720__auto___30191){
var seq__30171_30192__$1 = temp__5720__auto___30191;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__30171_30192__$1)){
var c__4550__auto___30193 = cljs.core.chunk_first.call(null,seq__30171_30192__$1);
var G__30194 = cljs.core.chunk_rest.call(null,seq__30171_30192__$1);
var G__30195 = c__4550__auto___30193;
var G__30196 = cljs.core.count.call(null,c__4550__auto___30193);
var G__30197 = (0);
seq__30171_30182 = G__30194;
chunk__30172_30183 = G__30195;
count__30173_30184 = G__30196;
i__30174_30185 = G__30197;
continue;
} else {
var k_30198 = cljs.core.first.call(null,seq__30171_30192__$1);
e.setAttribute(cljs.core.name.call(null,k_30198),cljs.core.get.call(null,attrs,k_30198));
var G__30199 = cljs.core.next.call(null,seq__30171_30192__$1);
var G__30200 = null;
var G__30201 = (0);
var G__30202 = (0);
seq__30171_30182 = G__30199;
chunk__30172_30183 = G__30200;
count__30173_30184 = G__30201;
i__30174_30185 = G__30202;
continue;
}
} else {
}
}
break;
}
var seq__30175_30203 = cljs.core.seq.call(null,children);
var chunk__30176_30204 = null;
var count__30177_30205 = (0);
var i__30178_30206 = (0);
while(true){
if((i__30178_30206 < count__30177_30205)){
var ch_30207 = cljs.core._nth.call(null,chunk__30176_30204,i__30178_30206);
e.appendChild(ch_30207);
var G__30208 = seq__30175_30203;
var G__30209 = chunk__30176_30204;
var G__30210 = count__30177_30205;
var G__30211 = (i__30178_30206 + (1));
seq__30175_30203 = G__30208;
chunk__30176_30204 = G__30209;
count__30177_30205 = G__30210;
i__30178_30206 = G__30211;
continue;
} else {
var temp__5720__auto___30212 = cljs.core.seq.call(null,seq__30175_30203);
if(temp__5720__auto___30212){
var seq__30175_30213__$1 = temp__5720__auto___30212;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__30175_30213__$1)){
var c__4550__auto___30214 = cljs.core.chunk_first.call(null,seq__30175_30213__$1);
var G__30215 = cljs.core.chunk_rest.call(null,seq__30175_30213__$1);
var G__30216 = c__4550__auto___30214;
var G__30217 = cljs.core.count.call(null,c__4550__auto___30214);
var G__30218 = (0);
seq__30175_30203 = G__30215;
chunk__30176_30204 = G__30216;
count__30177_30205 = G__30217;
i__30178_30206 = G__30218;
continue;
} else {
var ch_30219 = cljs.core.first.call(null,seq__30175_30213__$1);
e.appendChild(ch_30219);
var G__30220 = cljs.core.next.call(null,seq__30175_30213__$1);
var G__30221 = null;
var G__30222 = (0);
var G__30223 = (0);
seq__30175_30203 = G__30220;
chunk__30176_30204 = G__30221;
count__30177_30205 = G__30222;
i__30178_30206 = G__30223;
continue;
}
} else {
}
}
break;
}
return e;
});
figwheel.client.heads_up.node.cljs$lang$maxFixedArity = (2);
/** @this {Function} */
figwheel.client.heads_up.node.cljs$lang$applyTo = (function (seq30168){
var G__30169 = cljs.core.first.call(null,seq30168);
var seq30168__$1 = cljs.core.next.call(null,seq30168);
var G__30170 = cljs.core.first.call(null,seq30168__$1);
var seq30168__$2 = cljs.core.next.call(null,seq30168__$1);
var self__4717__auto__ = this;
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__30169,G__30170,seq30168__$2);
});
if((typeof figwheel !== 'undefined') && (typeof figwheel.client !== 'undefined') && (typeof figwheel.client.heads_up !== 'undefined') && (typeof figwheel.client.heads_up.heads_up_event_dispatch !== 'undefined')){
} else {
figwheel.client.heads_up.heads_up_event_dispatch = (function (){var method_table__4613__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var prefer_table__4614__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var method_cache__4615__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var cached_hierarchy__4616__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var hierarchy__4617__auto__ = cljs.core.get.call(null,cljs.core.PersistentArrayMap.EMPTY,new cljs.core.Keyword(null,"hierarchy","hierarchy",-1053470341),cljs.core.get_global_hierarchy.call(null));
return (new cljs.core.MultiFn(cljs.core.symbol.call(null,"figwheel.client.heads-up","heads-up-event-dispatch"),((function (method_table__4613__auto__,prefer_table__4614__auto__,method_cache__4615__auto__,cached_hierarchy__4616__auto__,hierarchy__4617__auto__){
return (function (dataset){
return dataset.figwheelEvent;
});})(method_table__4613__auto__,prefer_table__4614__auto__,method_cache__4615__auto__,cached_hierarchy__4616__auto__,hierarchy__4617__auto__))
,new cljs.core.Keyword(null,"default","default",-1987822328),hierarchy__4617__auto__,method_table__4613__auto__,prefer_table__4614__auto__,method_cache__4615__auto__,cached_hierarchy__4616__auto__));
})();
}
cljs.core._add_method.call(null,figwheel.client.heads_up.heads_up_event_dispatch,new cljs.core.Keyword(null,"default","default",-1987822328),(function (_){
return cljs.core.PersistentArrayMap.EMPTY;
}));
cljs.core._add_method.call(null,figwheel.client.heads_up.heads_up_event_dispatch,"file-selected",(function (dataset){
return figwheel.client.socket.send_BANG_.call(null,new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"figwheel-event","figwheel-event",519570592),"file-selected",new cljs.core.Keyword(null,"file-name","file-name",-1654217259),dataset.fileName,new cljs.core.Keyword(null,"file-line","file-line",-1228823138),dataset.fileLine,new cljs.core.Keyword(null,"file-column","file-column",1543934780),dataset.fileColumn], null));
}));
cljs.core._add_method.call(null,figwheel.client.heads_up.heads_up_event_dispatch,"close-heads-up",(function (dataset){
return figwheel.client.heads_up.clear.call(null);
}));
figwheel.client.heads_up.ancestor_nodes = (function figwheel$client$heads_up$ancestor_nodes(el){
return cljs.core.iterate.call(null,(function (e){
return e.parentNode;
}),el);
});
figwheel.client.heads_up.get_dataset = (function figwheel$client$heads_up$get_dataset(el){
return cljs.core.first.call(null,cljs.core.keep.call(null,(function (x){
if(cljs.core.truth_(x.dataset.figwheelEvent)){
return x.dataset;
} else {
return null;
}
}),cljs.core.take.call(null,(4),figwheel.client.heads_up.ancestor_nodes.call(null,el))));
});
figwheel.client.heads_up.heads_up_onclick_handler = (function figwheel$client$heads_up$heads_up_onclick_handler(event){
var dataset = figwheel.client.heads_up.get_dataset.call(null,event.target);
event.preventDefault();
if(cljs.core.truth_(dataset)){
return figwheel.client.heads_up.heads_up_event_dispatch.call(null,dataset);
} else {
return null;
}
});
figwheel.client.heads_up.ensure_container = (function figwheel$client$heads_up$ensure_container(){
var cont_id = "figwheel-heads-up-container";
var content_id = "figwheel-heads-up-content-area";
if(cljs.core.not.call(null,document.querySelector(["#",cont_id].join('')))){
var el_30224 = figwheel.client.heads_up.node.call(null,new cljs.core.Keyword(null,"div","div",1057191632),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"id","id",-1388402092),cont_id,new cljs.core.Keyword(null,"style","style",-496642736),["-webkit-transition: all 0.2s ease-in-out;","-moz-transition: all 0.2s ease-in-out;","-o-transition: all 0.2s ease-in-out;","transition: all 0.2s ease-in-out;","font-size: 13px;","border-top: 1px solid #f5f5f5;","box-shadow: 0px 0px 1px #aaaaaa;","line-height: 18px;","color: #333;","font-family: monospace;","padding: 0px 10px 0px 70px;","position: fixed;","bottom: 0px;","left: 0px;","height: 0px;","opacity: 0.0;","box-sizing: border-box;","z-index: 10000;","text-align: left;"].join('')], null));
el_30224.onclick = figwheel.client.heads_up.heads_up_onclick_handler;
el_30224.innerHTML = figwheel.client.heads_up.cljs_logo_svg;
el_30224.appendChild(figwheel.client.heads_up.node.call(null,new cljs.core.Keyword(null,"div","div",1057191632),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"id","id",-1388402092),content_id], null)));
document.body.appendChild(el_30224);
} else {
}
return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"container-el","container-el",109664205),document.getElementById(cont_id),new cljs.core.Keyword(null,"content-area-el","content-area-el",742757187),document.getElementById(content_id)], null);
});
figwheel.client.heads_up.set_style_BANG_ = (function figwheel$client$heads_up$set_style_BANG_(p__30225,st_map){
var map__30226 = p__30225;
var map__30226__$1 = (((((!((map__30226 == null))))?(((((map__30226.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30226.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30226):map__30226);
var container_el = cljs.core.get.call(null,map__30226__$1,new cljs.core.Keyword(null,"container-el","container-el",109664205));
return cljs.core.mapv.call(null,((function (map__30226,map__30226__$1,container_el){
return (function (p__30228){
var vec__30229 = p__30228;
var k = cljs.core.nth.call(null,vec__30229,(0),null);
var v = cljs.core.nth.call(null,vec__30229,(1),null);
return goog.object.set(container_el.style,cljs.core.name.call(null,k),v);
});})(map__30226,map__30226__$1,container_el))
,st_map);
});
figwheel.client.heads_up.set_content_BANG_ = (function figwheel$client$heads_up$set_content_BANG_(p__30232,dom_str){
var map__30233 = p__30232;
var map__30233__$1 = (((((!((map__30233 == null))))?(((((map__30233.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30233.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30233):map__30233);
var c = map__30233__$1;
var content_area_el = cljs.core.get.call(null,map__30233__$1,new cljs.core.Keyword(null,"content-area-el","content-area-el",742757187));
return content_area_el.innerHTML = dom_str;
});
figwheel.client.heads_up.get_content = (function figwheel$client$heads_up$get_content(p__30235){
var map__30236 = p__30235;
var map__30236__$1 = (((((!((map__30236 == null))))?(((((map__30236.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30236.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30236):map__30236);
var content_area_el = cljs.core.get.call(null,map__30236__$1,new cljs.core.Keyword(null,"content-area-el","content-area-el",742757187));
return content_area_el.innerHTML;
});
figwheel.client.heads_up.close_link = (function figwheel$client$heads_up$close_link(){
return ["<a style=\"","float: right;","font-size: 18px;","text-decoration: none;","text-align: right;","width: 30px;","height: 30px;","color: rgba(84,84,84, 0.5);","\" href=\"#\" data-figwheel-event=\"close-heads-up\">","x","</a>"].join('');
});
figwheel.client.heads_up.display_heads_up = (function figwheel$client$heads_up$display_heads_up(style,msg){
var c__22951__auto__ = cljs.core.async.chan.call(null,(1));
cljs.core.async.impl.dispatch.run.call(null,((function (c__22951__auto__){
return (function (){
var f__22952__auto__ = (function (){var switch__22856__auto__ = ((function (c__22951__auto__){
return (function (state_30253){
var state_val_30254 = (state_30253[(1)]);
if((state_val_30254 === (1))){
var inst_30238 = (state_30253[(7)]);
var inst_30238__$1 = figwheel.client.heads_up.ensure_container.call(null);
var inst_30239 = [new cljs.core.Keyword(null,"paddingTop","paddingTop",-1088692345),new cljs.core.Keyword(null,"paddingBottom","paddingBottom",-916694489),new cljs.core.Keyword(null,"width","width",-384071477),new cljs.core.Keyword(null,"minHeight","minHeight",-1635998980),new cljs.core.Keyword(null,"opacity","opacity",397153780)];
var inst_30240 = ["10px","10px","100%","68px","1.0"];
var inst_30241 = cljs.core.PersistentHashMap.fromArrays(inst_30239,inst_30240);
var inst_30242 = cljs.core.merge.call(null,inst_30241,style);
var inst_30243 = figwheel.client.heads_up.set_style_BANG_.call(null,inst_30238__$1,inst_30242);
var inst_30244 = figwheel.client.heads_up.set_content_BANG_.call(null,inst_30238__$1,msg);
var inst_30245 = cljs.core.async.timeout.call(null,(300));
var state_30253__$1 = (function (){var statearr_30255 = state_30253;
(statearr_30255[(8)] = inst_30243);
(statearr_30255[(7)] = inst_30238__$1);
(statearr_30255[(9)] = inst_30244);
return statearr_30255;
})();
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_30253__$1,(2),inst_30245);
} else {
if((state_val_30254 === (2))){
var inst_30238 = (state_30253[(7)]);
var inst_30247 = (state_30253[(2)]);
var inst_30248 = [new cljs.core.Keyword(null,"height","height",1025178622)];
var inst_30249 = ["auto"];
var inst_30250 = cljs.core.PersistentHashMap.fromArrays(inst_30248,inst_30249);
var inst_30251 = figwheel.client.heads_up.set_style_BANG_.call(null,inst_30238,inst_30250);
var state_30253__$1 = (function (){var statearr_30256 = state_30253;
(statearr_30256[(10)] = inst_30247);
return statearr_30256;
})();
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_30253__$1,inst_30251);
} else {
return null;
}
}
});})(c__22951__auto__))
;
return ((function (switch__22856__auto__,c__22951__auto__){
return (function() {
var figwheel$client$heads_up$display_heads_up_$_state_machine__22857__auto__ = null;
var figwheel$client$heads_up$display_heads_up_$_state_machine__22857__auto____0 = (function (){
var statearr_30257 = [null,null,null,null,null,null,null,null,null,null,null];
(statearr_30257[(0)] = figwheel$client$heads_up$display_heads_up_$_state_machine__22857__auto__);
(statearr_30257[(1)] = (1));
return statearr_30257;
});
var figwheel$client$heads_up$display_heads_up_$_state_machine__22857__auto____1 = (function (state_30253){
while(true){
var ret_value__22858__auto__ = (function (){try{while(true){
var result__22859__auto__ = switch__22856__auto__.call(null,state_30253);
if(cljs.core.keyword_identical_QMARK_.call(null,result__22859__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
continue;
} else {
return result__22859__auto__;
}
break;
}
}catch (e30258){if((e30258 instanceof Object)){
var ex__22860__auto__ = e30258;
var statearr_30259_30261 = state_30253;
(statearr_30259_30261[(5)] = ex__22860__auto__);
cljs.core.async.impl.ioc_helpers.process_exception.call(null,state_30253);
return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
throw e30258;
}
}})();
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__22858__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
var G__30262 = state_30253;
state_30253 = G__30262;
continue;
} else {
return ret_value__22858__auto__;
}
break;
}
});
figwheel$client$heads_up$display_heads_up_$_state_machine__22857__auto__ = function(state_30253){
switch(arguments.length){
case 0:
return figwheel$client$heads_up$display_heads_up_$_state_machine__22857__auto____0.call(this);
case 1:
return figwheel$client$heads_up$display_heads_up_$_state_machine__22857__auto____1.call(this,state_30253);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
figwheel$client$heads_up$display_heads_up_$_state_machine__22857__auto__.cljs$core$IFn$_invoke$arity$0 = figwheel$client$heads_up$display_heads_up_$_state_machine__22857__auto____0;
figwheel$client$heads_up$display_heads_up_$_state_machine__22857__auto__.cljs$core$IFn$_invoke$arity$1 = figwheel$client$heads_up$display_heads_up_$_state_machine__22857__auto____1;
return figwheel$client$heads_up$display_heads_up_$_state_machine__22857__auto__;
})()
;})(switch__22856__auto__,c__22951__auto__))
})();
var state__22953__auto__ = (function (){var statearr_30260 = f__22952__auto__.call(null);
(statearr_30260[(6)] = c__22951__auto__);
return statearr_30260;
})();
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__22953__auto__);
});})(c__22951__auto__))
);
return c__22951__auto__;
});
figwheel.client.heads_up.heading = (function figwheel$client$heads_up$heading(var_args){
var G__30264 = arguments.length;
switch (G__30264) {
case 1:
return figwheel.client.heads_up.heading.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
case 2:
return figwheel.client.heads_up.heading.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
figwheel.client.heads_up.heading.cljs$core$IFn$_invoke$arity$1 = (function (s){
return figwheel.client.heads_up.heading.call(null,s,"");
});
figwheel.client.heads_up.heading.cljs$core$IFn$_invoke$arity$2 = (function (s,sub_head){
return ["<div style=\"","font-size: 26px;","line-height: 26px;","margin-bottom: 2px;","padding-top: 1px;","\">",cljs.core.str.cljs$core$IFn$_invoke$arity$1(s)," <span style=\"","display: inline-block;","font-size: 13px;","\">",cljs.core.str.cljs$core$IFn$_invoke$arity$1(sub_head),"</span></div>"].join('');
});
figwheel.client.heads_up.heading.cljs$lang$maxFixedArity = 2;
figwheel.client.heads_up.file_selector_div = (function figwheel$client$heads_up$file_selector_div(file_name,line_number,column_number,msg){
return ["<div style=\"cursor: pointer;\" data-figwheel-event=\"file-selected\" data-file-name=\"",cljs.core.str.cljs$core$IFn$_invoke$arity$1(file_name),"\" data-file-line=\"",cljs.core.str.cljs$core$IFn$_invoke$arity$1(line_number),"\" data-file-column=\"",cljs.core.str.cljs$core$IFn$_invoke$arity$1(column_number),"\">",cljs.core.str.cljs$core$IFn$_invoke$arity$1(msg),"</div>"].join('');
});
figwheel.client.heads_up.format_line = (function figwheel$client$heads_up$format_line(msg,p__30266){
var map__30267 = p__30266;
var map__30267__$1 = (((((!((map__30267 == null))))?(((((map__30267.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30267.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30267):map__30267);
var file = cljs.core.get.call(null,map__30267__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
var line = cljs.core.get.call(null,map__30267__$1,new cljs.core.Keyword(null,"line","line",212345235));
var column = cljs.core.get.call(null,map__30267__$1,new cljs.core.Keyword(null,"column","column",2078222095));
var msg__$1 = goog.string.htmlEscape(msg);
if(cljs.core.truth_((function (){var or__4131__auto__ = file;
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return line;
}
})())){
return figwheel.client.heads_up.file_selector_div.call(null,file,line,column,msg__$1);
} else {
return ["<div>",cljs.core.str.cljs$core$IFn$_invoke$arity$1(msg__$1),"</div>"].join('');
}
});
figwheel.client.heads_up.escape = (function figwheel$client$heads_up$escape(x){
return goog.string.htmlEscape(x);
});
figwheel.client.heads_up.pad_line_number = (function figwheel$client$heads_up$pad_line_number(n,line_number){
var len = cljs.core.count.call(null,cljs.core.fnil.call(null,cljs.core.str,"").call(null,line_number));
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1((((len < n))?cljs.core.apply.call(null,cljs.core.str,cljs.core.repeat.call(null,(n - len)," ")):"")),cljs.core.str.cljs$core$IFn$_invoke$arity$1(line_number)].join('');
});
figwheel.client.heads_up.inline_error_line = (function figwheel$client$heads_up$inline_error_line(style,line_number,line){
return ["<span style='",cljs.core.str.cljs$core$IFn$_invoke$arity$1(style),"'>","<span style='color: #757575;'>",cljs.core.str.cljs$core$IFn$_invoke$arity$1(line_number)," </span>",cljs.core.str.cljs$core$IFn$_invoke$arity$1(figwheel.client.heads_up.escape.call(null,line)),"</span>"].join('');
});
figwheel.client.heads_up.format_inline_error_line = (function figwheel$client$heads_up$format_inline_error_line(p__30269){
var vec__30270 = p__30269;
var typ = cljs.core.nth.call(null,vec__30270,(0),null);
var line_number = cljs.core.nth.call(null,vec__30270,(1),null);
var line = cljs.core.nth.call(null,vec__30270,(2),null);
var pred__30273 = cljs.core._EQ_;
var expr__30274 = typ;
if(cljs.core.truth_(pred__30273.call(null,new cljs.core.Keyword(null,"code-line","code-line",-2138627853),expr__30274))){
return figwheel.client.heads_up.inline_error_line.call(null,"color: #999;",line_number,line);
} else {
if(cljs.core.truth_(pred__30273.call(null,new cljs.core.Keyword(null,"error-in-code","error-in-code",-1661931357),expr__30274))){
return figwheel.client.heads_up.inline_error_line.call(null,"color: #ccc; font-weight: bold;",line_number,line);
} else {
if(cljs.core.truth_(pred__30273.call(null,new cljs.core.Keyword(null,"error-message","error-message",1756021561),expr__30274))){
return figwheel.client.heads_up.inline_error_line.call(null,"color: #D07D7D;",line_number,line);
} else {
return figwheel.client.heads_up.inline_error_line.call(null,"color: #666;",line_number,line);
}
}
}
});
figwheel.client.heads_up.pad_line_numbers = (function figwheel$client$heads_up$pad_line_numbers(inline_error){
var max_line_number_length = cljs.core.count.call(null,cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.reduce.call(null,cljs.core.max,cljs.core.map.call(null,cljs.core.second,inline_error))));
return cljs.core.map.call(null,((function (max_line_number_length){
return (function (p1__30276_SHARP_){
return cljs.core.update_in.call(null,p1__30276_SHARP_,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [(1)], null),cljs.core.partial.call(null,figwheel.client.heads_up.pad_line_number,max_line_number_length));
});})(max_line_number_length))
,inline_error);
});
figwheel.client.heads_up.format_inline_error = (function figwheel$client$heads_up$format_inline_error(inline_error){
var lines = cljs.core.map.call(null,figwheel.client.heads_up.format_inline_error_line,figwheel.client.heads_up.pad_line_numbers.call(null,inline_error));
return ["<pre style='whitespace:pre; overflow-x: scroll; display:block; font-family:monospace; font-size:0.8em; border-radius: 3px;"," line-height: 1.1em; padding: 10px; background-color: rgb(24,26,38); margin-right: 5px'>",cljs.core.str.cljs$core$IFn$_invoke$arity$1(clojure.string.join.call(null,"\n",lines)),"</pre>"].join('');
});
figwheel.client.heads_up.flatten_exception = (function figwheel$client$heads_up$flatten_exception(p1__30277_SHARP_){
return cljs.core.take_while.call(null,cljs.core.some_QMARK_,cljs.core.iterate.call(null,new cljs.core.Keyword(null,"cause","cause",231901252),p1__30277_SHARP_));
});
figwheel.client.heads_up.exception__GT_display_data = (function figwheel$client$heads_up$exception__GT_display_data(p__30280){
var map__30281 = p__30280;
var map__30281__$1 = (((((!((map__30281 == null))))?(((((map__30281.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30281.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30281):map__30281);
var exception = map__30281__$1;
var message = cljs.core.get.call(null,map__30281__$1,new cljs.core.Keyword(null,"message","message",-406056002));
var failed_loading_clj_file = cljs.core.get.call(null,map__30281__$1,new cljs.core.Keyword(null,"failed-loading-clj-file","failed-loading-clj-file",-1682536481));
var reader_exception = cljs.core.get.call(null,map__30281__$1,new cljs.core.Keyword(null,"reader-exception","reader-exception",-1938323098));
var file = cljs.core.get.call(null,map__30281__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
var column = cljs.core.get.call(null,map__30281__$1,new cljs.core.Keyword(null,"column","column",2078222095));
var failed_compiling = cljs.core.get.call(null,map__30281__$1,new cljs.core.Keyword(null,"failed-compiling","failed-compiling",1768639503));
var error_inline = cljs.core.get.call(null,map__30281__$1,new cljs.core.Keyword(null,"error-inline","error-inline",1073987185));
var line = cljs.core.get.call(null,map__30281__$1,new cljs.core.Keyword(null,"line","line",212345235));
var class$ = cljs.core.get.call(null,map__30281__$1,new cljs.core.Keyword(null,"class","class",-2030961996));
var analysis_exception = cljs.core.get.call(null,map__30281__$1,new cljs.core.Keyword(null,"analysis-exception","analysis-exception",591623285));
var display_ex_data = cljs.core.get.call(null,map__30281__$1,new cljs.core.Keyword(null,"display-ex-data","display-ex-data",-1611558730));
var last_message = (cljs.core.truth_((function (){var and__4120__auto__ = file;
if(cljs.core.truth_(and__4120__auto__)){
return line;
} else {
return and__4120__auto__;
}
})())?["Please see line ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(line)," of file ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(file)].join(''):(cljs.core.truth_(file)?["Please see ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(file)].join(''):null
));
return new cljs.core.PersistentArrayMap(null, 6, [new cljs.core.Keyword(null,"head","head",-771383919),(cljs.core.truth_(failed_loading_clj_file)?"Couldn't load Clojure file":(cljs.core.truth_(analysis_exception)?"Could not Analyze":(cljs.core.truth_(reader_exception)?"Could not Read":(cljs.core.truth_(failed_compiling)?"Could not Compile":"Compile Exception"
)))),new cljs.core.Keyword(null,"sub-head","sub-head",1930649117),file,new cljs.core.Keyword(null,"messages","messages",345434482),cljs.core.concat.call(null,cljs.core.map.call(null,((function (last_message,map__30281,map__30281__$1,exception,message,failed_loading_clj_file,reader_exception,file,column,failed_compiling,error_inline,line,class$,analysis_exception,display_ex_data){
return (function (p1__30278_SHARP_){
return ["<div>",cljs.core.str.cljs$core$IFn$_invoke$arity$1(p1__30278_SHARP_),"</div>"].join('');
});})(last_message,map__30281,map__30281__$1,exception,message,failed_loading_clj_file,reader_exception,file,column,failed_compiling,error_inline,line,class$,analysis_exception,display_ex_data))
,(cljs.core.truth_(message)?new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [[(cljs.core.truth_(class$)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(figwheel.client.heads_up.escape.call(null,class$)),": "].join(''):""),"<span style=\"font-weight:bold;\">",cljs.core.str.cljs$core$IFn$_invoke$arity$1(figwheel.client.heads_up.escape.call(null,message)),"</span>"].join(''),(cljs.core.truth_(display_ex_data)?["<pre style=\"white-space: pre-wrap\">",cljs.core.str.cljs$core$IFn$_invoke$arity$1(figwheel.client.utils.pprint_to_string.call(null,display_ex_data)),"</pre>"].join(''):null),(((cljs.core.count.call(null,error_inline) > (0)))?figwheel.client.heads_up.format_inline_error.call(null,error_inline):null)], null):cljs.core.map.call(null,((function (last_message,map__30281,map__30281__$1,exception,message,failed_loading_clj_file,reader_exception,file,column,failed_compiling,error_inline,line,class$,analysis_exception,display_ex_data){
return (function (p1__30279_SHARP_){
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(figwheel.client.heads_up.escape.call(null,new cljs.core.Keyword(null,"class","class",-2030961996).cljs$core$IFn$_invoke$arity$1(p1__30279_SHARP_))),": ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(figwheel.client.heads_up.escape.call(null,new cljs.core.Keyword(null,"message","message",-406056002).cljs$core$IFn$_invoke$arity$1(p1__30279_SHARP_)))].join('');
});})(last_message,map__30281,map__30281__$1,exception,message,failed_loading_clj_file,reader_exception,file,column,failed_compiling,error_inline,line,class$,analysis_exception,display_ex_data))
,figwheel.client.heads_up.flatten_exception.call(null,new cljs.core.Keyword(null,"exception-data","exception-data",-512474886).cljs$core$IFn$_invoke$arity$1(exception))))),(cljs.core.truth_(last_message)?new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [["<div style=\"color: #AD4F4F; padding-top: 3px;\">",cljs.core.str.cljs$core$IFn$_invoke$arity$1(figwheel.client.heads_up.escape.call(null,last_message)),"</div>"].join('')], null):null)),new cljs.core.Keyword(null,"file","file",-1269645878),file,new cljs.core.Keyword(null,"line","line",212345235),line,new cljs.core.Keyword(null,"column","column",2078222095),column], null);
});
figwheel.client.heads_up.auto_notify_source_file_line = (function figwheel$client$heads_up$auto_notify_source_file_line(p__30283){
var map__30284 = p__30283;
var map__30284__$1 = (((((!((map__30284 == null))))?(((((map__30284.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30284.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30284):map__30284);
var file = cljs.core.get.call(null,map__30284__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
var line = cljs.core.get.call(null,map__30284__$1,new cljs.core.Keyword(null,"line","line",212345235));
var column = cljs.core.get.call(null,map__30284__$1,new cljs.core.Keyword(null,"column","column",2078222095));
return figwheel.client.socket.send_BANG_.call(null,new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"figwheel-event","figwheel-event",519570592),"file-selected",new cljs.core.Keyword(null,"file-name","file-name",-1654217259),cljs.core.str.cljs$core$IFn$_invoke$arity$1(file),new cljs.core.Keyword(null,"file-line","file-line",-1228823138),cljs.core.str.cljs$core$IFn$_invoke$arity$1(line),new cljs.core.Keyword(null,"file-column","file-column",1543934780),cljs.core.str.cljs$core$IFn$_invoke$arity$1(column)], null));
});
figwheel.client.heads_up.display_exception = (function figwheel$client$heads_up$display_exception(exception_data){
var map__30287 = figwheel.client.heads_up.exception__GT_display_data.call(null,exception_data);
var map__30287__$1 = (((((!((map__30287 == null))))?(((((map__30287.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30287.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30287):map__30287);
var head = cljs.core.get.call(null,map__30287__$1,new cljs.core.Keyword(null,"head","head",-771383919));
var sub_head = cljs.core.get.call(null,map__30287__$1,new cljs.core.Keyword(null,"sub-head","sub-head",1930649117));
var messages = cljs.core.get.call(null,map__30287__$1,new cljs.core.Keyword(null,"messages","messages",345434482));
var last_message = cljs.core.get.call(null,map__30287__$1,new cljs.core.Keyword(null,"last-message","last-message",-2087778135));
var file = cljs.core.get.call(null,map__30287__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
var line = cljs.core.get.call(null,map__30287__$1,new cljs.core.Keyword(null,"line","line",212345235));
var column = cljs.core.get.call(null,map__30287__$1,new cljs.core.Keyword(null,"column","column",2078222095));
var msg = cljs.core.apply.call(null,cljs.core.str,messages);
return figwheel.client.heads_up.display_heads_up.call(null,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"backgroundColor","backgroundColor",1738438491),"rgba(255, 161, 161, 0.95)"], null),[figwheel.client.heads_up.close_link.call(null),figwheel.client.heads_up.heading.call(null,head,sub_head),figwheel.client.heads_up.file_selector_div.call(null,file,line,column,msg)].join(''));
});
figwheel.client.heads_up.warning_data__GT_display_data = (function figwheel$client$heads_up$warning_data__GT_display_data(p__30290){
var map__30291 = p__30290;
var map__30291__$1 = (((((!((map__30291 == null))))?(((((map__30291.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30291.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30291):map__30291);
var warning_data = map__30291__$1;
var file = cljs.core.get.call(null,map__30291__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
var line = cljs.core.get.call(null,map__30291__$1,new cljs.core.Keyword(null,"line","line",212345235));
var column = cljs.core.get.call(null,map__30291__$1,new cljs.core.Keyword(null,"column","column",2078222095));
var message = cljs.core.get.call(null,map__30291__$1,new cljs.core.Keyword(null,"message","message",-406056002));
var error_inline = cljs.core.get.call(null,map__30291__$1,new cljs.core.Keyword(null,"error-inline","error-inline",1073987185));
var last_message = (cljs.core.truth_((function (){var and__4120__auto__ = file;
if(cljs.core.truth_(and__4120__auto__)){
return line;
} else {
return and__4120__auto__;
}
})())?["Please see line ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(line)," of file ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(file)].join(''):(cljs.core.truth_(file)?["Please see ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(file)].join(''):null
));
return new cljs.core.PersistentArrayMap(null, 6, [new cljs.core.Keyword(null,"head","head",-771383919),"Compile Warning",new cljs.core.Keyword(null,"sub-head","sub-head",1930649117),file,new cljs.core.Keyword(null,"messages","messages",345434482),cljs.core.concat.call(null,cljs.core.map.call(null,((function (last_message,map__30291,map__30291__$1,warning_data,file,line,column,message,error_inline){
return (function (p1__30289_SHARP_){
return ["<div>",cljs.core.str.cljs$core$IFn$_invoke$arity$1(p1__30289_SHARP_),"</div>"].join('');
});})(last_message,map__30291,map__30291__$1,warning_data,file,line,column,message,error_inline))
,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(cljs.core.truth_(message)?["<span style=\"font-weight:bold;\">",cljs.core.str.cljs$core$IFn$_invoke$arity$1(figwheel.client.heads_up.escape.call(null,message)),"</span>"].join(''):null),(((cljs.core.count.call(null,error_inline) > (0)))?figwheel.client.heads_up.format_inline_error.call(null,error_inline):null)], null)),(cljs.core.truth_(last_message)?new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [["<div style=\"color: #AD4F4F; padding-top: 3px; margin-bottom: 10px;\">",cljs.core.str.cljs$core$IFn$_invoke$arity$1(figwheel.client.heads_up.escape.call(null,last_message)),"</div>"].join('')], null):null)),new cljs.core.Keyword(null,"file","file",-1269645878),file,new cljs.core.Keyword(null,"line","line",212345235),line,new cljs.core.Keyword(null,"column","column",2078222095),column], null);
});
figwheel.client.heads_up.display_system_warning = (function figwheel$client$heads_up$display_system_warning(header,msg){
return figwheel.client.heads_up.display_heads_up.call(null,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"backgroundColor","backgroundColor",1738438491),"rgba(255, 220, 110, 0.95)"], null),[figwheel.client.heads_up.close_link.call(null),cljs.core.str.cljs$core$IFn$_invoke$arity$1(figwheel.client.heads_up.heading.call(null,header)),"<div>",cljs.core.str.cljs$core$IFn$_invoke$arity$1(msg),"</div>"].join(''));
});
figwheel.client.heads_up.display_warning = (function figwheel$client$heads_up$display_warning(warning_data){
var map__30293 = figwheel.client.heads_up.warning_data__GT_display_data.call(null,warning_data);
var map__30293__$1 = (((((!((map__30293 == null))))?(((((map__30293.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30293.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30293):map__30293);
var head = cljs.core.get.call(null,map__30293__$1,new cljs.core.Keyword(null,"head","head",-771383919));
var sub_head = cljs.core.get.call(null,map__30293__$1,new cljs.core.Keyword(null,"sub-head","sub-head",1930649117));
var messages = cljs.core.get.call(null,map__30293__$1,new cljs.core.Keyword(null,"messages","messages",345434482));
var last_message = cljs.core.get.call(null,map__30293__$1,new cljs.core.Keyword(null,"last-message","last-message",-2087778135));
var file = cljs.core.get.call(null,map__30293__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
var line = cljs.core.get.call(null,map__30293__$1,new cljs.core.Keyword(null,"line","line",212345235));
var column = cljs.core.get.call(null,map__30293__$1,new cljs.core.Keyword(null,"column","column",2078222095));
var msg = cljs.core.apply.call(null,cljs.core.str,messages);
return figwheel.client.heads_up.display_heads_up.call(null,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"backgroundColor","backgroundColor",1738438491),"rgba(255, 220, 110, 0.95)"], null),[figwheel.client.heads_up.close_link.call(null),figwheel.client.heads_up.heading.call(null,head,sub_head),figwheel.client.heads_up.file_selector_div.call(null,file,line,column,msg)].join(''));
});
figwheel.client.heads_up.format_warning_message = (function figwheel$client$heads_up$format_warning_message(p__30295){
var map__30296 = p__30295;
var map__30296__$1 = (((((!((map__30296 == null))))?(((((map__30296.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30296.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30296):map__30296);
var warning_data = map__30296__$1;
var message = cljs.core.get.call(null,map__30296__$1,new cljs.core.Keyword(null,"message","message",-406056002));
var file = cljs.core.get.call(null,map__30296__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
var line = cljs.core.get.call(null,map__30296__$1,new cljs.core.Keyword(null,"line","line",212345235));
var column = cljs.core.get.call(null,map__30296__$1,new cljs.core.Keyword(null,"column","column",2078222095));
var G__30298 = message;
var G__30298__$1 = (cljs.core.truth_(line)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__30298)," at line ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(line)].join(''):G__30298);
var G__30298__$2 = (cljs.core.truth_((function (){var and__4120__auto__ = line;
if(cljs.core.truth_(and__4120__auto__)){
return column;
} else {
return and__4120__auto__;
}
})())?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__30298__$1),", column ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(column)].join(''):G__30298__$1);
if(cljs.core.truth_(file)){
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__30298__$2)," in file ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(file)].join('');
} else {
return G__30298__$2;
}
});
figwheel.client.heads_up.append_warning_message = (function figwheel$client$heads_up$append_warning_message(p__30299){
var map__30300 = p__30299;
var map__30300__$1 = (((((!((map__30300 == null))))?(((((map__30300.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30300.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30300):map__30300);
var warning_data = map__30300__$1;
var message = cljs.core.get.call(null,map__30300__$1,new cljs.core.Keyword(null,"message","message",-406056002));
var file = cljs.core.get.call(null,map__30300__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
var line = cljs.core.get.call(null,map__30300__$1,new cljs.core.Keyword(null,"line","line",212345235));
var column = cljs.core.get.call(null,map__30300__$1,new cljs.core.Keyword(null,"column","column",2078222095));
if(cljs.core.truth_(message)){
var map__30302 = figwheel.client.heads_up.ensure_container.call(null);
var map__30302__$1 = (((((!((map__30302 == null))))?(((((map__30302.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30302.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30302):map__30302);
var content_area_el = cljs.core.get.call(null,map__30302__$1,new cljs.core.Keyword(null,"content-area-el","content-area-el",742757187));
var el = goog.dom.createElement("div");
var child_count = goog.dom.getChildren(content_area_el).length;
if((child_count < (6))){
el.innerHTML = figwheel.client.heads_up.format_line.call(null,figwheel.client.heads_up.format_warning_message.call(null,warning_data),warning_data);
return goog.dom.append(content_area_el,el);
} else {
var temp__5720__auto__ = goog.dom.getLastElementChild(content_area_el);
if(cljs.core.truth_(temp__5720__auto__)){
var last_child = temp__5720__auto__;
var temp__5718__auto__ = goog.dom.dataset.get(last_child,"figwheel_count");
if(cljs.core.truth_(temp__5718__auto__)){
var message_count = temp__5718__auto__;
var message_count__$1 = (parseInt(message_count) + (1));
goog.dom.dataset.set(last_child,"figwheel_count",message_count__$1);
return last_child.innerHTML = [cljs.core.str.cljs$core$IFn$_invoke$arity$1(message_count__$1)," more warnings have not been displayed ..."].join('');
} else {
return goog.dom.append(content_area_el,goog.dom.createDom("div",({"data-figwheel_count": (1), "style": "margin-top: 3px; font-weight: bold"}),"1 more warning that has not been displayed ..."));
}
} else {
return null;
}
}
} else {
return null;
}
});
figwheel.client.heads_up.clear = (function figwheel$client$heads_up$clear(){
var c__22951__auto__ = cljs.core.async.chan.call(null,(1));
cljs.core.async.impl.dispatch.run.call(null,((function (c__22951__auto__){
return (function (){
var f__22952__auto__ = (function (){var switch__22856__auto__ = ((function (c__22951__auto__){
return (function (state_30321){
var state_val_30322 = (state_30321[(1)]);
if((state_val_30322 === (1))){
var inst_30304 = (state_30321[(7)]);
var inst_30304__$1 = figwheel.client.heads_up.ensure_container.call(null);
var inst_30305 = [new cljs.core.Keyword(null,"opacity","opacity",397153780)];
var inst_30306 = ["0.0"];
var inst_30307 = cljs.core.PersistentHashMap.fromArrays(inst_30305,inst_30306);
var inst_30308 = figwheel.client.heads_up.set_style_BANG_.call(null,inst_30304__$1,inst_30307);
var inst_30309 = cljs.core.async.timeout.call(null,(300));
var state_30321__$1 = (function (){var statearr_30323 = state_30321;
(statearr_30323[(8)] = inst_30308);
(statearr_30323[(7)] = inst_30304__$1);
return statearr_30323;
})();
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_30321__$1,(2),inst_30309);
} else {
if((state_val_30322 === (2))){
var inst_30304 = (state_30321[(7)]);
var inst_30311 = (state_30321[(2)]);
var inst_30312 = [new cljs.core.Keyword(null,"width","width",-384071477),new cljs.core.Keyword(null,"height","height",1025178622),new cljs.core.Keyword(null,"minHeight","minHeight",-1635998980),new cljs.core.Keyword(null,"padding","padding",1660304693),new cljs.core.Keyword(null,"borderRadius","borderRadius",-1505621083),new cljs.core.Keyword(null,"backgroundColor","backgroundColor",1738438491)];
var inst_30313 = ["auto","0px","0px","0px 10px 0px 70px","0px","transparent"];
var inst_30314 = cljs.core.PersistentHashMap.fromArrays(inst_30312,inst_30313);
var inst_30315 = figwheel.client.heads_up.set_style_BANG_.call(null,inst_30304,inst_30314);
var inst_30316 = cljs.core.async.timeout.call(null,(200));
var state_30321__$1 = (function (){var statearr_30324 = state_30321;
(statearr_30324[(9)] = inst_30311);
(statearr_30324[(10)] = inst_30315);
return statearr_30324;
})();
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_30321__$1,(3),inst_30316);
} else {
if((state_val_30322 === (3))){
var inst_30304 = (state_30321[(7)]);
var inst_30318 = (state_30321[(2)]);
var inst_30319 = figwheel.client.heads_up.set_content_BANG_.call(null,inst_30304,"");
var state_30321__$1 = (function (){var statearr_30325 = state_30321;
(statearr_30325[(11)] = inst_30318);
return statearr_30325;
})();
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_30321__$1,inst_30319);
} else {
return null;
}
}
}
});})(c__22951__auto__))
;
return ((function (switch__22856__auto__,c__22951__auto__){
return (function() {
var figwheel$client$heads_up$clear_$_state_machine__22857__auto__ = null;
var figwheel$client$heads_up$clear_$_state_machine__22857__auto____0 = (function (){
var statearr_30326 = [null,null,null,null,null,null,null,null,null,null,null,null];
(statearr_30326[(0)] = figwheel$client$heads_up$clear_$_state_machine__22857__auto__);
(statearr_30326[(1)] = (1));
return statearr_30326;
});
var figwheel$client$heads_up$clear_$_state_machine__22857__auto____1 = (function (state_30321){
while(true){
var ret_value__22858__auto__ = (function (){try{while(true){
var result__22859__auto__ = switch__22856__auto__.call(null,state_30321);
if(cljs.core.keyword_identical_QMARK_.call(null,result__22859__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
continue;
} else {
return result__22859__auto__;
}
break;
}
}catch (e30327){if((e30327 instanceof Object)){
var ex__22860__auto__ = e30327;
var statearr_30328_30330 = state_30321;
(statearr_30328_30330[(5)] = ex__22860__auto__);
cljs.core.async.impl.ioc_helpers.process_exception.call(null,state_30321);
return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
throw e30327;
}
}})();
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__22858__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
var G__30331 = state_30321;
state_30321 = G__30331;
continue;
} else {
return ret_value__22858__auto__;
}
break;
}
});
figwheel$client$heads_up$clear_$_state_machine__22857__auto__ = function(state_30321){
switch(arguments.length){
case 0:
return figwheel$client$heads_up$clear_$_state_machine__22857__auto____0.call(this);
case 1:
return figwheel$client$heads_up$clear_$_state_machine__22857__auto____1.call(this,state_30321);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
figwheel$client$heads_up$clear_$_state_machine__22857__auto__.cljs$core$IFn$_invoke$arity$0 = figwheel$client$heads_up$clear_$_state_machine__22857__auto____0;
figwheel$client$heads_up$clear_$_state_machine__22857__auto__.cljs$core$IFn$_invoke$arity$1 = figwheel$client$heads_up$clear_$_state_machine__22857__auto____1;
return figwheel$client$heads_up$clear_$_state_machine__22857__auto__;
})()
;})(switch__22856__auto__,c__22951__auto__))
})();
var state__22953__auto__ = (function (){var statearr_30329 = f__22952__auto__.call(null);
(statearr_30329[(6)] = c__22951__auto__);
return statearr_30329;
})();
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__22953__auto__);
});})(c__22951__auto__))
);
return c__22951__auto__;
});
figwheel.client.heads_up.display_loaded_start = (function figwheel$client$heads_up$display_loaded_start(){
return figwheel.client.heads_up.display_heads_up.call(null,new cljs.core.PersistentArrayMap(null, 6, [new cljs.core.Keyword(null,"backgroundColor","backgroundColor",1738438491),"rgba(211,234,172,1.0)",new cljs.core.Keyword(null,"width","width",-384071477),"68px",new cljs.core.Keyword(null,"height","height",1025178622),"68px",new cljs.core.Keyword(null,"paddingLeft","paddingLeft",262720813),"0px",new cljs.core.Keyword(null,"paddingRight","paddingRight",-1642313463),"0px",new cljs.core.Keyword(null,"borderRadius","borderRadius",-1505621083),"35px"], null),"");
});
figwheel.client.heads_up.flash_loaded = (function figwheel$client$heads_up$flash_loaded(){
var c__22951__auto__ = cljs.core.async.chan.call(null,(1));
cljs.core.async.impl.dispatch.run.call(null,((function (c__22951__auto__){
return (function (){
var f__22952__auto__ = (function (){var switch__22856__auto__ = ((function (c__22951__auto__){
return (function (state_30342){
var state_val_30343 = (state_30342[(1)]);
if((state_val_30343 === (1))){
var inst_30332 = figwheel.client.heads_up.display_loaded_start.call(null);
var state_30342__$1 = state_30342;
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_30342__$1,(2),inst_30332);
} else {
if((state_val_30343 === (2))){
var inst_30334 = (state_30342[(2)]);
var inst_30335 = cljs.core.async.timeout.call(null,(400));
var state_30342__$1 = (function (){var statearr_30344 = state_30342;
(statearr_30344[(7)] = inst_30334);
return statearr_30344;
})();
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_30342__$1,(3),inst_30335);
} else {
if((state_val_30343 === (3))){
var inst_30337 = (state_30342[(2)]);
var inst_30338 = figwheel.client.heads_up.clear.call(null);
var state_30342__$1 = (function (){var statearr_30345 = state_30342;
(statearr_30345[(8)] = inst_30337);
return statearr_30345;
})();
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_30342__$1,(4),inst_30338);
} else {
if((state_val_30343 === (4))){
var inst_30340 = (state_30342[(2)]);
var state_30342__$1 = state_30342;
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_30342__$1,inst_30340);
} else {
return null;
}
}
}
}
});})(c__22951__auto__))
;
return ((function (switch__22856__auto__,c__22951__auto__){
return (function() {
var figwheel$client$heads_up$flash_loaded_$_state_machine__22857__auto__ = null;
var figwheel$client$heads_up$flash_loaded_$_state_machine__22857__auto____0 = (function (){
var statearr_30346 = [null,null,null,null,null,null,null,null,null];
(statearr_30346[(0)] = figwheel$client$heads_up$flash_loaded_$_state_machine__22857__auto__);
(statearr_30346[(1)] = (1));
return statearr_30346;
});
var figwheel$client$heads_up$flash_loaded_$_state_machine__22857__auto____1 = (function (state_30342){
while(true){
var ret_value__22858__auto__ = (function (){try{while(true){
var result__22859__auto__ = switch__22856__auto__.call(null,state_30342);
if(cljs.core.keyword_identical_QMARK_.call(null,result__22859__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
continue;
} else {
return result__22859__auto__;
}
break;
}
}catch (e30347){if((e30347 instanceof Object)){
var ex__22860__auto__ = e30347;
var statearr_30348_30350 = state_30342;
(statearr_30348_30350[(5)] = ex__22860__auto__);
cljs.core.async.impl.ioc_helpers.process_exception.call(null,state_30342);
return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
throw e30347;
}
}})();
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__22858__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
var G__30351 = state_30342;
state_30342 = G__30351;
continue;
} else {
return ret_value__22858__auto__;
}
break;
}
});
figwheel$client$heads_up$flash_loaded_$_state_machine__22857__auto__ = function(state_30342){
switch(arguments.length){
case 0:
return figwheel$client$heads_up$flash_loaded_$_state_machine__22857__auto____0.call(this);
case 1:
return figwheel$client$heads_up$flash_loaded_$_state_machine__22857__auto____1.call(this,state_30342);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
figwheel$client$heads_up$flash_loaded_$_state_machine__22857__auto__.cljs$core$IFn$_invoke$arity$0 = figwheel$client$heads_up$flash_loaded_$_state_machine__22857__auto____0;
figwheel$client$heads_up$flash_loaded_$_state_machine__22857__auto__.cljs$core$IFn$_invoke$arity$1 = figwheel$client$heads_up$flash_loaded_$_state_machine__22857__auto____1;
return figwheel$client$heads_up$flash_loaded_$_state_machine__22857__auto__;
})()
;})(switch__22856__auto__,c__22951__auto__))
})();
var state__22953__auto__ = (function (){var statearr_30349 = f__22952__auto__.call(null);
(statearr_30349[(6)] = c__22951__auto__);
return statearr_30349;
})();
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__22953__auto__);
});})(c__22951__auto__))
);
return c__22951__auto__;
});
figwheel.client.heads_up.cljs_logo_svg = "<?xml version='1.0' encoding='utf-8'?>\n<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>\n<svg width='49px' height='49px' style='position:absolute; top:9px; left: 10px;' version='1.1'\n xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px'\n viewBox='0 0 428 428' enable-background='new 0 0 428 428' xml:space='preserve'>\n<circle fill='#fff' cx='213' cy='214' r='213' />\n<g>\n<path fill='#96CA4B' d='M122,266.6c-12.7,0-22.3-3.7-28.9-11.1c-6.6-7.4-9.9-18-9.9-31.8c0-14.1,3.4-24.9,10.3-32.5\n s16.8-11.4,29.9-11.4c8.8,0,16.8,1.6,23.8,4.9l-5.4,14.3c-7.5-2.9-13.7-4.4-18.6-4.4c-14.5,0-21.7,9.6-21.7,28.8\n c0,9.4,1.8,16.4,5.4,21.2c3.6,4.7,8.9,7.1,15.9,7.1c7.9,0,15.4-2,22.5-5.9v15.5c-3.2,1.9-6.6,3.2-10.2,4\n C131.5,266.2,127.1,266.6,122,266.6z'/>\n<path fill='#96CA4B' d='M194.4,265.1h-17.8V147.3h17.8V265.1z'/>\n<path fill='#5F7FBF' d='M222.9,302.3c-5.3,0-9.8-0.6-13.3-1.9v-14.1c3.4,0.9,6.9,1.4,10.5,1.4c7.6,0,11.4-4.3,11.4-12.9v-93.5h17.8\n v94.7c0,8.6-2.3,15.2-6.8,19.6C237.9,300.1,231.4,302.3,222.9,302.3z M230.4,159.2c0-3.2,0.9-5.6,2.6-7.3c1.7-1.7,4.2-2.6,7.5-2.6\n c3.1,0,5.6,0.9,7.3,2.6c1.7,1.7,2.6,4.2,2.6,7.3c0,3-0.9,5.4-2.6,7.2c-1.7,1.7-4.2,2.6-7.3,2.6c-3.2,0-5.7-0.9-7.5-2.6\n C231.2,164.6,230.4,162.2,230.4,159.2z'/>\n<path fill='#5F7FBF' d='M342.5,241.3c0,8.2-3,14.4-8.9,18.8c-6,4.4-14.5,6.5-25.6,6.5c-11.2,0-20.1-1.7-26.9-5.1v-15.4\n c9.8,4.5,19,6.8,27.5,6.8c10.9,0,16.4-3.3,16.4-9.9c0-2.1-0.6-3.9-1.8-5.3c-1.2-1.4-3.2-2.9-6-4.4c-2.8-1.5-6.6-3.2-11.6-5.1\n c-9.6-3.7-16.2-7.5-19.6-11.2c-3.4-3.7-5.1-8.6-5.1-14.5c0-7.2,2.9-12.7,8.7-16.7c5.8-4,13.6-5.9,23.6-5.9c9.8,0,19.1,2,27.9,6\n l-5.8,13.4c-9-3.7-16.6-5.6-22.8-5.6c-9.4,0-14.1,2.7-14.1,8c0,2.6,1.2,4.8,3.7,6.7c2.4,1.8,7.8,4.3,16,7.5\n c6.9,2.7,11.9,5.1,15.1,7.3c3.1,2.2,5.4,4.8,7,7.7C341.7,233.7,342.5,237.2,342.5,241.3z'/>\n</g>\n<path fill='#96CA4B' stroke='#96CA4B' stroke-width='6' stroke-miterlimit='10' d='M197,392.7c-91.2-8.1-163-85-163-178.3\n S105.8,44.3,197,36.2V16.1c-102.3,8.2-183,94-183,198.4s80.7,190.2,183,198.4V392.7z'/>\n<path fill='#5F7FBF' stroke='#5F7FBF' stroke-width='6' stroke-miterlimit='10' d='M229,16.1v20.1c91.2,8.1,163,85,163,178.3\n s-71.8,170.2-163,178.3v20.1c102.3-8.2,183-94,183-198.4S331.3,24.3,229,16.1z'/>\n</svg>";
figwheel.client.heads_up.close_bad_compile_screen = (function figwheel$client$heads_up$close_bad_compile_screen(){
var temp__5720__auto__ = document.getElementById("figwheelFailScreen");
if(cljs.core.truth_(temp__5720__auto__)){
var el = temp__5720__auto__;
return goog.dom.removeNode(el);
} else {
return null;
}
});
figwheel.client.heads_up.bad_compile_screen = (function figwheel$client$heads_up$bad_compile_screen(){
var body = (goog.dom.getElementsByTagNameAndClass("body")[(0)]);
figwheel.client.heads_up.close_bad_compile_screen.call(null);
return goog.dom.append(body,goog.dom.createDom("div",({"id": "figwheelFailScreen", "style": ["background-color: rgba(24, 26, 38, 0.95);","position: absolute;","z-index: 9000;","width: 100vw;","height: 100vh;","top: 0px; left: 0px;","font-family: monospace"].join('')}),goog.dom.createDom("div",({"class": "message", "style": ["color: #FFF5DB;","width: 100vw;","margin: auto;","margin-top: 10px;","text-align: center; ","padding: 2px 0px;","font-size: 13px;","position: relative"].join('')}),goog.dom.createDom("a",({"onclick": ((function (body){
return (function (e){
e.preventDefault();
return figwheel.client.heads_up.close_bad_compile_screen.call(null);
});})(body))
, "href": "javascript:", "style": "position: absolute; right: 10px; top: 10px; color: #666"}),"X"),goog.dom.createDom("h2",({"style": "color: #FFF5DB"}),"Figwheel Says: Your code didn't compile."),goog.dom.createDom("div",({"style": "font-size: 12px"}),goog.dom.createDom("p",({"style": "color: #D07D7D;"}),"Keep trying. This page will auto-refresh when your code compiles successfully.")))));
});
//# sourceMappingURL=heads_up.js.map?rel=1582560151801

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,96 @@
(ns figwheel.client.socket
(:require
[goog.object :as gobj]
[figwheel.client.utils :as utils]
[cljs.reader :refer [read-string]]))
(defn get-websocket-imp []
(or
(gobj/get goog.global "FIGWHEEL_WEBSOCKET_CLASS")
(gobj/get goog.global "WebSocket")
(cond
;; TODO remove
(utils/html-or-react-native-env?) (gobj/get js/window "WebSocket")
(utils/node-env?) (try (js/require "ws")
(catch js/Error e
nil))
;; TODO remove
(utils/worker-env?) (gobj/get js/self "WebSocket")
:else nil)))
;; messages have the following formats
;; files-changed message
;; { :msg-name :files-changed
;; :files [{:file "/js/compiled/out/example/core.js",
;; :type :javascript,
;; :msg-name :file-changed,
;; :namespace "example.core" }] }
;; css-files-changed message
;; there should really only be one file in here at a time
;; { :msg-name :css-files-changed
;; :files [{:file "/css/example.css",
;; :type :css }] }
;; compile-failed message
;; { :msg-name :compile-failed
;; :exception-data {:cause { ... lots of exception info ... } }}
;; the exception data is nested raw info obtained for the compile time
;; exception
(defonce message-history-atom (atom (list)))
(defonce socket-atom (atom false))
(defn send!
"Send a end message to the server."
[msg]
(when @socket-atom
(.send @socket-atom (pr-str msg))))
(defn close! []
(set! (.-onclose @socket-atom) identity)
(.close @socket-atom))
(defn handle-incoming-message [msg]
(utils/debug-prn msg)
(and (map? msg)
(:msg-name msg)
;; don't forward pings
(not= (:msg-name msg) :ping)
(swap! message-history-atom
conj msg)))
(defn open [{:keys [retry-count retried-count websocket-url build-id] :as opts}]
(if-let [WebSocket (get-websocket-imp)]
(do
(utils/log :debug "Figwheel: trying to open cljs reload socket")
(let [url (str websocket-url (if build-id (str "/" build-id) ""))
socket (WebSocket. url)]
(set! (.-onmessage socket) (fn [msg-str]
(when-let [msg
(read-string (.-data msg-str))]
(#'handle-incoming-message msg))))
(set! (.-onopen socket) (fn [x]
(reset! socket-atom socket)
(when (utils/html-env?)
(.addEventListener js/window "beforeunload" close!))
(utils/log :debug "Figwheel: socket connection established")))
(set! (.-onclose socket) (fn [x]
(let [retried-count (or retried-count 0)]
(utils/debug-prn "Figwheel: socket closed or failed to open")
(when (> retry-count retried-count)
(js/setTimeout
(fn []
(open
(assoc opts :retried-count (inc retried-count))))
;; linear back off
(min 10000 (+ 2000 (* 500 retried-count))))))))
(set! (.-onerror socket) (fn [x] (utils/debug-prn "Figwheel: socket error ")))
socket))
(utils/log :debug
(if (utils/node-env?)
"Figwheel: Can't start Figwheel!! Please make sure ws is installed\n do -> 'npm install ws'"
"Figwheel: Can't start Figwheel!! This browser doesn't support WebSockets"))))

View file

@ -0,0 +1 @@
["^ ","~:rename-macros",["^ "],"~:renames",["^ "],"~:externs",["^ ","~$window",["^ ","~$addEventListener",["^ "]],"~$Error",["^ "],"~$require",["^ "],"~$self",["^ "],"~$setTimeout",["^ "]],"~:use-macros",["^ "],"~:excludes",["~#set",[]],"~:name","~$figwheel.client.socket","~:imports",null,"~:requires",["^ ","~$gobj","~$goog.object","^A","^A","~$utils","~$figwheel.client.utils","^C","^C","~$cljs.reader","^D"],"~:cljs.spec/speced-vars",[],"~:uses",["^ ","~$read-string","^D"],"~:defs",["^ ","~$get-websocket-imp",["^ ","~:protocol-inline",null,"~:meta",["^ ","~:file","/home/simon/workspace/geocsv-lite/resources/public/js/compiled/out/figwheel/client/socket.cljs","~:line",7,"~:column",7,"~:end-line",7,"~:end-column",24,"~:arglists",["~#list",["~$quote",["^R",[[]]]]]],"^<","~$figwheel.client.socket/get-websocket-imp","^L","resources/public/js/compiled/out/figwheel/client/socket.cljs","^P",24,"~:method-params",["^R",[[]]],"~:protocol-impl",null,"~:arglists-meta",["^R",[null,null]],"^N",1,"~:variadic?",false,"^M",7,"~:ret-tag",["^;",[null,"~$any","~$clj-nil"]],"^O",7,"~:max-fixed-arity",0,"~:fn-var",true,"^Q",["^R",["^S",["^R",[[]]]]]],"~$message-history-atom",["^ ","^<","~$figwheel.client.socket/message-history-atom","^L","resources/public/js/compiled/out/figwheel/client/socket.cljs","^M",43,"^N",1,"^O",43,"^P",30,"^K",["^ ","^L","/home/simon/workspace/geocsv-lite/resources/public/js/compiled/out/figwheel/client/socket.cljs","^M",43,"^N",10,"^O",43,"^P",30],"~:tag","~$cljs.core/Atom"],"~$socket-atom",["^ ","^<","~$figwheel.client.socket/socket-atom","^L","resources/public/js/compiled/out/figwheel/client/socket.cljs","^M",45,"^N",1,"^O",45,"^P",21,"^K",["^ ","^L","/home/simon/workspace/geocsv-lite/resources/public/js/compiled/out/figwheel/client/socket.cljs","^M",45,"^N",10,"^O",45,"^P",21],"^14","^15"],"~$send!",["^ ","^J",null,"^K",["^ ","^L","/home/simon/workspace/geocsv-lite/resources/public/js/compiled/out/figwheel/client/socket.cljs","^M",47,"^N",7,"^O",47,"^P",12,"^Q",["^R",["^S",["^R",[["~$msg"]]]]],"~:doc","Send a end message to the server."],"^<","~$figwheel.client.socket/send!","^L","resources/public/js/compiled/out/figwheel/client/socket.cljs","^P",12,"^U",["^R",[["^19"]]],"^V",null,"^W",["^R",[null,null]],"^N",1,"^X",false,"^M",47,"^Y",["^;",["^Z","^["]],"^O",47,"^10",1,"^11",true,"^Q",["^R",["^S",["^R",[["^19"]]]]],"^1:","Send a end message to the server."],"~$close!",["^ ","^J",null,"^K",["^ ","^L","/home/simon/workspace/geocsv-lite/resources/public/js/compiled/out/figwheel/client/socket.cljs","^M",53,"^N",7,"^O",53,"^P",13,"^Q",["^R",["^S",["^R",[[]]]]]],"^<","~$figwheel.client.socket/close!","^L","resources/public/js/compiled/out/figwheel/client/socket.cljs","^P",13,"^U",["^R",[[]]],"^V",null,"^W",["^R",[null,null]],"^N",1,"^X",false,"^M",53,"^Y","^Z","^O",53,"^10",0,"^11",true,"^Q",["^R",["^S",["^R",[[]]]]]],"~$handle-incoming-message",["^ ","^J",null,"^K",["^ ","^L","/home/simon/workspace/geocsv-lite/resources/public/js/compiled/out/figwheel/client/socket.cljs","^M",57,"^N",7,"^O",57,"^P",30,"^Q",["^R",["^S",["^R",[["^19"]]]]]],"^<","~$figwheel.client.socket/handle-incoming-message","^L","resources/public/js/compiled/out/figwheel/client/socket.cljs","^P",30,"^U",["^R",[["^19"]]],"^V",null,"^W",["^R",[null,null]],"^N",1,"^X",false,"^M",57,"^Y",["^;",[null,"~$boolean","^Z"]],"^O",57,"^10",1,"^11",true,"^Q",["^R",["^S",["^R",[["^19"]]]]]],"~$open",["^ ","^J",null,"^K",["^ ","^L","/home/simon/workspace/geocsv-lite/resources/public/js/compiled/out/figwheel/client/socket.cljs","^M",66,"^N",7,"^O",66,"^P",11,"^Q",["^R",["^S",["^R",[[["^ ","~:keys",["~$retry-count","~$retried-count","~$websocket-url","~$build-id"],"~:as","~$opts"]]]]]]],"^<","~$figwheel.client.socket/open","^L","resources/public/js/compiled/out/figwheel/client/socket.cljs","^P",11,"^U",["^R",[["~$p__30163"]]],"^V",null,"^W",["^R",[null,null]],"^N",1,"^X",false,"^M",66,"^Y",["^;",["~$WebSocket","^Z"]],"^O",66,"^10",1,"^11",true,"^Q",["^R",["^S",["^R",[[["^ ","^1B",["^1C","^1D","^1E","^1F"],"^1G","^1H"]]]]]]]],"~:cljs.spec/registry-ref",[],"~:require-macros",["^ ","^B","^C","^C","^C","^D","^D"],"~:cljs.analyzer/constants",["^ ","~:seen",["^;",["~:ping","~:retried-count","~:else","~:ns","^1>","^<","^1?","^L","^P","~:debug","^N","~:build-id","^M","^19","~:websocket-url","^O","~:msg-name","^Q","^=","^1:","~:retry-count","~:test"]],"~:order",["^1R","^1W","^1P","^1X","^1Q","^1V","^1U","^1T","^1?","^1S","^<","^L","^P","^N","^M","^O","^Q","^1:","^1Y","^=","^1>","^19"]],"^1:",null]

View file

@ -0,0 +1,161 @@
// Compiled by ClojureScript 1.10.520 {}
goog.provide('figwheel.client.socket');
goog.require('cljs.core');
goog.require('goog.object');
goog.require('figwheel.client.utils');
goog.require('cljs.reader');
figwheel.client.socket.get_websocket_imp = (function figwheel$client$socket$get_websocket_imp(){
var or__4131__auto__ = goog.object.get(goog.global,"FIGWHEEL_WEBSOCKET_CLASS");
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
var or__4131__auto____$1 = goog.object.get(goog.global,"WebSocket");
if(cljs.core.truth_(or__4131__auto____$1)){
return or__4131__auto____$1;
} else {
if(figwheel.client.utils.html_or_react_native_env_QMARK_.call(null)){
return goog.object.get(window,"WebSocket");
} else {
if(figwheel.client.utils.node_env_QMARK_.call(null)){
try{return require("ws");
}catch (e30162){if((e30162 instanceof Error)){
var e = e30162;
return null;
} else {
throw e30162;
}
}} else {
if(figwheel.client.utils.worker_env_QMARK_.call(null)){
return goog.object.get(self,"WebSocket");
} else {
return null;
}
}
}
}
}
});
if((typeof figwheel !== 'undefined') && (typeof figwheel.client !== 'undefined') && (typeof figwheel.client.socket !== 'undefined') && (typeof figwheel.client.socket.message_history_atom !== 'undefined')){
} else {
figwheel.client.socket.message_history_atom = cljs.core.atom.call(null,cljs.core.List.EMPTY);
}
if((typeof figwheel !== 'undefined') && (typeof figwheel.client !== 'undefined') && (typeof figwheel.client.socket !== 'undefined') && (typeof figwheel.client.socket.socket_atom !== 'undefined')){
} else {
figwheel.client.socket.socket_atom = cljs.core.atom.call(null,false);
}
/**
* Send a end message to the server.
*/
figwheel.client.socket.send_BANG_ = (function figwheel$client$socket$send_BANG_(msg){
if(cljs.core.truth_(cljs.core.deref.call(null,figwheel.client.socket.socket_atom))){
return cljs.core.deref.call(null,figwheel.client.socket.socket_atom).send(cljs.core.pr_str.call(null,msg));
} else {
return null;
}
});
figwheel.client.socket.close_BANG_ = (function figwheel$client$socket$close_BANG_(){
cljs.core.deref.call(null,figwheel.client.socket.socket_atom).onclose = cljs.core.identity;
return cljs.core.deref.call(null,figwheel.client.socket.socket_atom).close();
});
figwheel.client.socket.handle_incoming_message = (function figwheel$client$socket$handle_incoming_message(msg){
figwheel.client.utils.debug_prn.call(null,msg);
var and__4120__auto__ = cljs.core.map_QMARK_.call(null,msg);
if(and__4120__auto__){
var and__4120__auto____$1 = new cljs.core.Keyword(null,"msg-name","msg-name",-353709863).cljs$core$IFn$_invoke$arity$1(msg);
if(cljs.core.truth_(and__4120__auto____$1)){
var and__4120__auto____$2 = cljs.core.not_EQ_.call(null,new cljs.core.Keyword(null,"msg-name","msg-name",-353709863).cljs$core$IFn$_invoke$arity$1(msg),new cljs.core.Keyword(null,"ping","ping",-1670114784));
if(and__4120__auto____$2){
return cljs.core.swap_BANG_.call(null,figwheel.client.socket.message_history_atom,cljs.core.conj,msg);
} else {
return and__4120__auto____$2;
}
} else {
return and__4120__auto____$1;
}
} else {
return and__4120__auto__;
}
});
figwheel.client.socket.open = (function figwheel$client$socket$open(p__30163){
var map__30164 = p__30163;
var map__30164__$1 = (((((!((map__30164 == null))))?(((((map__30164.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30164.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30164):map__30164);
var opts = map__30164__$1;
var retry_count = cljs.core.get.call(null,map__30164__$1,new cljs.core.Keyword(null,"retry-count","retry-count",1936122875));
var retried_count = cljs.core.get.call(null,map__30164__$1,new cljs.core.Keyword(null,"retried-count","retried-count",-2127867357));
var websocket_url = cljs.core.get.call(null,map__30164__$1,new cljs.core.Keyword(null,"websocket-url","websocket-url",-490444938));
var build_id = cljs.core.get.call(null,map__30164__$1,new cljs.core.Keyword(null,"build-id","build-id",1642831089));
var temp__5718__auto__ = figwheel.client.socket.get_websocket_imp.call(null);
if(cljs.core.truth_(temp__5718__auto__)){
var WebSocket = temp__5718__auto__;
figwheel.client.utils.log.call(null,new cljs.core.Keyword(null,"debug","debug",-1608172596),"Figwheel: trying to open cljs reload socket");
var url = [cljs.core.str.cljs$core$IFn$_invoke$arity$1(websocket_url),(cljs.core.truth_(build_id)?["/",cljs.core.str.cljs$core$IFn$_invoke$arity$1(build_id)].join(''):"")].join('');
var socket = (new WebSocket(url));
socket.onmessage = ((function (url,socket,WebSocket,temp__5718__auto__,map__30164,map__30164__$1,opts,retry_count,retried_count,websocket_url,build_id){
return (function (msg_str){
var temp__5720__auto__ = cljs.reader.read_string.call(null,msg_str.data);
if(cljs.core.truth_(temp__5720__auto__)){
var msg = temp__5720__auto__;
return new cljs.core.Var(function(){return figwheel.client.socket.handle_incoming_message;},new cljs.core.Symbol("figwheel.client.socket","handle-incoming-message","figwheel.client.socket/handle-incoming-message",-2084786999,null),cljs.core.PersistentHashMap.fromArrays([new cljs.core.Keyword(null,"ns","ns",441598760),new cljs.core.Keyword(null,"name","name",1843675177),new cljs.core.Keyword(null,"file","file",-1269645878),new cljs.core.Keyword(null,"end-column","end-column",1425389514),new cljs.core.Keyword(null,"column","column",2078222095),new cljs.core.Keyword(null,"line","line",212345235),new cljs.core.Keyword(null,"end-line","end-line",1837326455),new cljs.core.Keyword(null,"arglists","arglists",1661989754),new cljs.core.Keyword(null,"doc","doc",1913296891),new cljs.core.Keyword(null,"test","test",577538877)],[new cljs.core.Symbol(null,"figwheel.client.socket","figwheel.client.socket",-1038129509,null),new cljs.core.Symbol(null,"handle-incoming-message","handle-incoming-message",-1068736536,null),"resources/public/js/compiled/out/figwheel/client/socket.cljs",30,1,57,57,cljs.core.list(new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"msg","msg",254428083,null)], null)),null,(cljs.core.truth_(figwheel.client.socket.handle_incoming_message)?figwheel.client.socket.handle_incoming_message.cljs$lang$test:null)])).call(null,msg);
} else {
return null;
}
});})(url,socket,WebSocket,temp__5718__auto__,map__30164,map__30164__$1,opts,retry_count,retried_count,websocket_url,build_id))
;
socket.onopen = ((function (url,socket,WebSocket,temp__5718__auto__,map__30164,map__30164__$1,opts,retry_count,retried_count,websocket_url,build_id){
return (function (x){
cljs.core.reset_BANG_.call(null,figwheel.client.socket.socket_atom,socket);
if(figwheel.client.utils.html_env_QMARK_.call(null)){
window.addEventListener("beforeunload",figwheel.client.socket.close_BANG_);
} else {
}
return figwheel.client.utils.log.call(null,new cljs.core.Keyword(null,"debug","debug",-1608172596),"Figwheel: socket connection established");
});})(url,socket,WebSocket,temp__5718__auto__,map__30164,map__30164__$1,opts,retry_count,retried_count,websocket_url,build_id))
;
socket.onclose = ((function (url,socket,WebSocket,temp__5718__auto__,map__30164,map__30164__$1,opts,retry_count,retried_count,websocket_url,build_id){
return (function (x){
var retried_count__$1 = (function (){var or__4131__auto__ = retried_count;
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return (0);
}
})();
figwheel.client.utils.debug_prn.call(null,"Figwheel: socket closed or failed to open");
if((retry_count > retried_count__$1)){
return setTimeout(((function (retried_count__$1,url,socket,WebSocket,temp__5718__auto__,map__30164,map__30164__$1,opts,retry_count,retried_count,websocket_url,build_id){
return (function (){
return figwheel.client.socket.open.call(null,cljs.core.assoc.call(null,opts,new cljs.core.Keyword(null,"retried-count","retried-count",-2127867357),(retried_count__$1 + (1))));
});})(retried_count__$1,url,socket,WebSocket,temp__5718__auto__,map__30164,map__30164__$1,opts,retry_count,retried_count,websocket_url,build_id))
,(function (){var x__4222__auto__ = (10000);
var y__4223__auto__ = ((2000) + ((500) * retried_count__$1));
return ((x__4222__auto__ < y__4223__auto__) ? x__4222__auto__ : y__4223__auto__);
})());
} else {
return null;
}
});})(url,socket,WebSocket,temp__5718__auto__,map__30164,map__30164__$1,opts,retry_count,retried_count,websocket_url,build_id))
;
socket.onerror = ((function (url,socket,WebSocket,temp__5718__auto__,map__30164,map__30164__$1,opts,retry_count,retried_count,websocket_url,build_id){
return (function (x){
return figwheel.client.utils.debug_prn.call(null,"Figwheel: socket error ");
});})(url,socket,WebSocket,temp__5718__auto__,map__30164,map__30164__$1,opts,retry_count,retried_count,websocket_url,build_id))
;
return socket;
} else {
return figwheel.client.utils.log.call(null,new cljs.core.Keyword(null,"debug","debug",-1608172596),((figwheel.client.utils.node_env_QMARK_.call(null))?"Figwheel: Can't start Figwheel!! Please make sure ws is installed\n do -> 'npm install ws'":"Figwheel: Can't start Figwheel!! This browser doesn't support WebSockets"));
}
});
//# sourceMappingURL=socket.js.map?rel=1582560151718

View file

@ -0,0 +1 @@
{"version":3,"file":"\/home\/simon\/workspace\/geocsv-lite\/resources\/public\/js\/compiled\/out\/figwheel\/client\/socket.js","sources":["socket.cljs?rel=1582560151719"],"lineCount":161,"mappings":";AAAA;;;;;AAMA,2CAAA,3CAAMA;AAAN,AACE,IAAAC,mBACC,4BAAA,5BAACC,gBAASC;AADX,AAAA,oBAAAF;AAAAA;;AAAA,IAAAA,uBAEC,4BAAA,5BAACC,gBAASC;AAFX,AAAA,oBAAAF;AAAAA;;AAGC,GAEE,AAACG;AAAiC,8BAAA,vBAACF,gBAASG;;AAF9C,GAGE,AAACC;AAAiB,IAAA,AAAK,eAAA,RAACE;gBAAN,GAAA,CAAAD,kBACYE;AADZ,QAAAF,JACqBG;AADrB,AAAA;;AAAA,AAAA,MAAAH;;;;AAHpB,GAOE,AAACI;AAAmB,4BAAA,rBAACT,gBAASU;;AAPhC,AAAA;;;;;;;;AAgCH,GAAA,QAAAC,qCAAAC,4CAAAC,mDAAAC;AAAA;AAAA,AAAA,AAASC,8CAAqB,AAACC,yBAg+E3B,AAAA2C;;AA99EJ,GAAA,QAAAhD,qCAAAC,4CAAAC,mDAAAI;AAAA;AAAA,AAAA,AAASC,qCAAY,yBAAA,zBAACF;;AAEtB;;;oCAAA,pCAAMG,gFAEHC;AAFH,AAGE,oBAAA,AAAAC,0BAAOH;AAAP,AACE,OAAA,AAAAG,0BAAQH,yCAAY,AAACI,2BAAOF;;AAD9B;;;AAGF,qCAAA,rCAAMG;AAAN,AACE,AAAM,AAAA,AAAAF,0BAAYH,8CAAaM;;AAC\/B,OAAA,AAAAH,0BAASH;;AAEX,iDAAA,jDAAMO,0GAAyBL;AAA\/B,AACE,AAACM,0CAAgBN;;AACjB,IAAAO,oBAAK,AAACC,+BAAKR;AAAX,AAAA,GAAAO;AAAA,IAAAA,wBACK,AAAA,2FAAWP;AADhB,AAAA,oBAAAO;AAAA,IAAAA,wBAGK,4HAAA,5HAACE,4BAAK,AAAA,2FAAWT;AAHtB,AAAA,GAAAO;AAIK,OAACG,+BAAMf,4CACAgB,eAAKX;;AALjBO;;;AAAAA;;;AAAAA;;;AAOF,8BAAA,sCAAAK,pEAAMM;AAAN,AAAA,IAAAL,aAAAD;IAAAC,iBAAA,EAAA,EAAA,GAAA,CAAAA,cAAA,SAAA,EAAA,EAAA,CAAA,AAAAA,iDAAA,WAAA,CAAAC,gCAAA,AAAAD,+BAAA,KAAA,OAAA,QAAA,AAAAE,0BAAAC,mBAAAH,YAAAA;WAAAA,PAA0EU;kBAA1E,AAAAN,wBAAAJ,eAAA,rDAAoBM;oBAApB,AAAAF,wBAAAJ,eAAA,vDAAgCO;oBAAhC,AAAAH,wBAAAJ,eAAA,vDAA8CQ;eAA9C,AAAAJ,wBAAAJ,eAAA,lDAA4DS;AAA5D,AACE,IAAAE,qBAAmB,AAAC9C;AAApB,AAAA,oBAAA8C;AAAA,gBAAAA,ZAASC;AAAT,AACE,AACE,oCAAA,wDAAA,5FAACC;;AACD,IAAMC,MAAI,6CAAKN,eAAc,iGAAA,\/EAAIC,UAAS,CAAA,gDAASA;IAC7CM,SAAO,KAAAH,UAAYE;AADzB,AAEE,AAAM,AAAaC,mBAAQ;kBAAKC;AAAL,AACE,IAAAC,qBACW,AAACC,kCAAY,AAAQF;AADhC,AAAA,oBAAAC;AAAA,AAAA,UAAAA,NAAW9B;AAAX,AAEE,OAAA,qFAAA,AAAA,2IAAA,wCAAA,gDAAA,qDAAA,sDAAA,iEAAA,yDAAA,oDAAA,6DAAA,6DAAA,mDAAA,sDAAA,AAAA,8FAAA,AAAA,gGAAA,AAAA,+DAAA,AAAA,GAAA,AAAA,EAAA,AAAA,GAAA,AAAA,GAAA,AAAA,iKAAA,AAAA,KAAA,kBAAAK,gDAAA,AAAA,AAAAA,8DAAA,mBAA2BL;;AAF7B;;;;;AAG7B,AAAM,AAAU4B,gBAAS;kBAAKI;AAAL,AACE,AAACC,gCAAOnC,mCAAY8B;;AACpB,GAAM,AAACM;AAAP,AACE,wBAAA,xBAAmBnD,uCAAyBoB;;AAD9C;;AAEA,2CAAA,wDAAA,5FAACuB;;;;AAC5B,AAAM,AAAWE,iBAAQ;kBAAKI;AAAL,AACE,IAAMZ,oBAAc,iBAAAzC,mBAAIyC;AAAJ,AAAA,oBAAAzC;AAAAA;;AAAA;;;AAApB,AACE,0CAAA,1CAAC2B;;AACD,GAAM,CAAGa,cAAYC;AAArB,AACE,OAACe,WACA;;AAAA,AACE,OAACjB,sCACA,+BAAA,\/BAACkB,0BAAMb,6EAAoB,qBAAA,pBAAKH;;CAEnC,iBAAAiB,kBAAA;IAAAC,kBAAW,CAAA,SAAQ,CAAA,QAAOlB;AAA1B,AAAA,SAAAiB,kBAAAC,mBAAAD,kBAAAC;;;AANH;;;;;AAO7B,AAAM,AAAWV,iBAAQ;kBAAKI;AAAL,AAAQ,iDAAA,1CAAC1B;;;;AAClCsB;;AACJ,2CAAA,pCAACF,4FACU,oDAAA,6FAAA,\/IAAI,AAAC1C","names":["figwheel.client.socket\/get-websocket-imp","or__4131__auto__","goog.object\/get","goog\/global","figwheel.client.utils\/html-or-react-native-env?","js\/window","figwheel.client.utils\/node-env?","e30162","js\/require","js\/Error","e","figwheel.client.utils\/worker-env?","js\/self","js\/figwheel","js\/figwheel.client","js\/figwheel.client.socket","js\/figwheel.client.socket.message-history-atom","figwheel.client.socket\/message-history-atom","cljs.core\/atom","js\/figwheel.client.socket.socket-atom","figwheel.client.socket\/socket-atom","figwheel.client.socket\/send!","msg","cljs.core\/deref","cljs.core\/pr-str","figwheel.client.socket\/close!","cljs.core\/identity","figwheel.client.socket\/handle-incoming-message","figwheel.client.utils\/debug-prn","and__4120__auto__","cljs.core\/map?","cljs.core\/not=","cljs.core\/swap!","cljs.core\/conj","p__30163","map__30164","cljs.core\/PROTOCOL_SENTINEL","cljs.core\/apply","cljs.core\/hash-map","cljs.core\/get","figwheel.client.socket\/open","retry-count","retried-count","websocket-url","build-id","opts","temp__5718__auto__","WebSocket","figwheel.client.utils\/log","url","socket","msg-str","temp__5720__auto__","cljs.reader\/read-string","x","cljs.core\/reset!","figwheel.client.utils\/html-env?","js\/setTimeout","cljs.core\/assoc","x__4222__auto__","y__4223__auto__","cljs.core\/List"]}

View file

@ -0,0 +1,146 @@
(ns ^:figwheel-no-load figwheel.client.utils
(:require [clojure.string :as string]
[goog.string :as gstring]
[goog.object :as gobj]
[cljs.reader :refer [read-string]]
[cljs.pprint :refer [pprint]]
[goog.userAgent.product :as product])
(:import [goog.async Deferred]
[goog.string StringBuffer])
(:require-macros [figwheel.client.utils :refer [feature?]]))
;; don't auto reload this file it will mess up the debug printing
(def ^:dynamic *print-debug* false)
(defn html-env? [] (not (nil? goog/global.document)))
(defn react-native-env? [] (and (exists? goog/global.navigator)
(= goog/global.navigator.product "ReactNative")))
(defn node-env? [] (not (nil? goog/nodeGlobalRequire)))
(defn html-or-react-native-env? []
(or (html-env?) (react-native-env?)))
(defn worker-env? [] (and
(nil? goog/global.document)
(exists? js/self)
(exists? (.-importScripts js/self))))
(defn host-env? [] (cond (node-env?) :node
(html-env?) :html
(react-native-env?) :react-native
(worker-env?) :worker))
(defn base-url-path [] (string/replace goog/basePath #"(.*)goog/" "$1"))
;; Custom Event must exist before calling this
(defn create-custom-event [event-name data]
(if-not product/IE
(js/CustomEvent. event-name (js-obj "detail" data))
;; in windows world
;; this will probably not work at some point in
;; newer versions of IE
(let [event (js/document.createEvent "CustomEvent")]
(.. event (initCustomEvent event-name false false data))
event)))
;; actually we should probably lift the event system here off the DOM
;; so that we work well in Node and other environments
(defn dispatch-custom-event [event-name data]
(when (and (html-env?) (gobj/get js/window "CustomEvent") (js* "typeof document !== 'undefined'"))
(.dispatchEvent (.-body js/document)
(create-custom-event event-name data))))
(defn debug-prn [o]
(when *print-debug*
(let [o (if (or (map? o)
(seq? o))
(prn-str o)
o)]
(.log js/console o))))
(defn log
([x] (log :info x))
([level arg]
(let [f (condp = (if (html-or-react-native-env?) level :info)
:warn #(.warn js/console %)
:debug #(.debug js/console %)
:error #(.error js/console %)
#(.log js/console %))]
(f arg))))
(defn eval-helper [code {:keys [eval-fn] :as opts}]
(if eval-fn
(eval-fn code opts)
(js* "eval(~{code})")))
(defn pprint-to-string [x]
(let [sb (StringBuffer.)
sbw (StringBufferWriter. sb)]
(pprint x sbw)
(gstring/trimRight (str sb))))
;; Deferred helpers that focus on guaranteed successful side effects
;; not very monadic but it meets our needs
(defn liftContD
"chains an async action on to a deferred
Must provide a goog.async.Deferred and action function that
takes an initial value and a continuation fn to call with the result"
[deferred f]
(.then deferred (fn [val]
(let [new-def (Deferred.)]
(f val #(.callback new-def %))
new-def))))
(defn mapConcatD
"maps an async action across a collection and chains the results
onto a deferred"
[deferred f coll]
(let [results (atom [])]
(.then
(reduce (fn [defr v]
(liftContD defr
(fn [_ fin]
(f v (fn [v]
(swap! results conj v)
(fin v))))))
deferred coll)
(fn [_] (.succeed Deferred @results)))))
;; persistent storage of configuration keys
(defonce local-persistent-config
(let [a (atom {})]
(when (feature? js/localStorage "setItem")
(add-watch a :sync-local-storage
(fn [_ _ _ n]
(mapv (fn [[ky v]]
(.setItem js/localStorage (name ky) (pr-str v)))
n))))
a))
(defn persistent-config-set!
"Set a local value on a key that in a browser will persist even when
the browser gets reloaded."
[ky v]
(swap! local-persistent-config assoc ky v))
(defn persistent-config-get
([ky not-found]
(try
(cond
(contains? @local-persistent-config ky)
(get @local-persistent-config ky)
(and (feature? js/localStorage "getItem")
(.getItem js/localStorage (name ky)))
(let [v (read-string (.getItem js/localStorage (name ky)))]
(persistent-config-set! ky v)
v)
:else not-found)
(catch js/Error e
not-found)))
([ky]
(persistent-config-get ky nil)))

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,290 @@
// Compiled by ClojureScript 1.10.520 {}
goog.provide('figwheel.client.utils');
goog.require('cljs.core');
goog.require('clojure.string');
goog.require('goog.string');
goog.require('goog.object');
goog.require('cljs.reader');
goog.require('cljs.pprint');
goog.require('goog.userAgent.product');
goog.require('goog.async.Deferred');
goog.require('goog.string.StringBuffer');
figwheel.client.utils._STAR_print_debug_STAR_ = false;
figwheel.client.utils.html_env_QMARK_ = (function figwheel$client$utils$html_env_QMARK_(){
return (!((goog.global.document == null)));
});
figwheel.client.utils.react_native_env_QMARK_ = (function figwheel$client$utils$react_native_env_QMARK_(){
return (((typeof goog !== 'undefined') && (typeof goog.global !== 'undefined') && (typeof goog.global.navigator !== 'undefined')) && (cljs.core._EQ_.call(null,goog.global.navigator.product,"ReactNative")));
});
figwheel.client.utils.node_env_QMARK_ = (function figwheel$client$utils$node_env_QMARK_(){
return (!((goog.nodeGlobalRequire == null)));
});
figwheel.client.utils.html_or_react_native_env_QMARK_ = (function figwheel$client$utils$html_or_react_native_env_QMARK_(){
return ((figwheel.client.utils.html_env_QMARK_.call(null)) || (figwheel.client.utils.react_native_env_QMARK_.call(null)));
});
figwheel.client.utils.worker_env_QMARK_ = (function figwheel$client$utils$worker_env_QMARK_(){
return (((goog.global.document == null)) && ((typeof self !== 'undefined')) && ((!((self.importScripts == null)))));
});
figwheel.client.utils.host_env_QMARK_ = (function figwheel$client$utils$host_env_QMARK_(){
if(figwheel.client.utils.node_env_QMARK_.call(null)){
return new cljs.core.Keyword(null,"node","node",581201198);
} else {
if(figwheel.client.utils.html_env_QMARK_.call(null)){
return new cljs.core.Keyword(null,"html","html",-998796897);
} else {
if(figwheel.client.utils.react_native_env_QMARK_.call(null)){
return new cljs.core.Keyword(null,"react-native","react-native",-1543085138);
} else {
if(figwheel.client.utils.worker_env_QMARK_.call(null)){
return new cljs.core.Keyword(null,"worker","worker",938239996);
} else {
return null;
}
}
}
}
});
figwheel.client.utils.base_url_path = (function figwheel$client$utils$base_url_path(){
return clojure.string.replace.call(null,goog.basePath,/(.*)goog\//,"$1");
});
figwheel.client.utils.create_custom_event = (function figwheel$client$utils$create_custom_event(event_name,data){
if(cljs.core.not.call(null,goog.userAgent.product.IE)){
return (new CustomEvent(event_name,(function (){var obj28450 = ({"detail":data});
return obj28450;
})()));
} else {
var event = document.createEvent("CustomEvent");
event.initCustomEvent(event_name,false,false,data);
return event;
}
});
figwheel.client.utils.dispatch_custom_event = (function figwheel$client$utils$dispatch_custom_event(event_name,data){
if(cljs.core.truth_((function (){var and__4120__auto__ = figwheel.client.utils.html_env_QMARK_.call(null);
if(and__4120__auto__){
var and__4120__auto____$1 = goog.object.get(window,"CustomEvent");
if(cljs.core.truth_(and__4120__auto____$1)){
return typeof document !== 'undefined';
} else {
return and__4120__auto____$1;
}
} else {
return and__4120__auto__;
}
})())){
return document.body.dispatchEvent(figwheel.client.utils.create_custom_event.call(null,event_name,data));
} else {
return null;
}
});
figwheel.client.utils.debug_prn = (function figwheel$client$utils$debug_prn(o){
if(figwheel.client.utils._STAR_print_debug_STAR_){
var o__$1 = ((((cljs.core.map_QMARK_.call(null,o)) || (cljs.core.seq_QMARK_.call(null,o))))?cljs.core.prn_str.call(null,o):o);
return console.log(o__$1);
} else {
return null;
}
});
figwheel.client.utils.log = (function figwheel$client$utils$log(var_args){
var G__28456 = arguments.length;
switch (G__28456) {
case 1:
return figwheel.client.utils.log.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
case 2:
return figwheel.client.utils.log.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
figwheel.client.utils.log.cljs$core$IFn$_invoke$arity$1 = (function (x){
return figwheel.client.utils.log.call(null,new cljs.core.Keyword(null,"info","info",-317069002),x);
});
figwheel.client.utils.log.cljs$core$IFn$_invoke$arity$2 = (function (level,arg){
var f = (function (){var pred__28457 = cljs.core._EQ_;
var expr__28458 = ((figwheel.client.utils.html_or_react_native_env_QMARK_.call(null))?level:new cljs.core.Keyword(null,"info","info",-317069002));
if(cljs.core.truth_(pred__28457.call(null,new cljs.core.Keyword(null,"warn","warn",-436710552),expr__28458))){
return ((function (pred__28457,expr__28458){
return (function (p1__28451_SHARP_){
return console.warn(p1__28451_SHARP_);
});
;})(pred__28457,expr__28458))
} else {
if(cljs.core.truth_(pred__28457.call(null,new cljs.core.Keyword(null,"debug","debug",-1608172596),expr__28458))){
return ((function (pred__28457,expr__28458){
return (function (p1__28452_SHARP_){
return console.debug(p1__28452_SHARP_);
});
;})(pred__28457,expr__28458))
} else {
if(cljs.core.truth_(pred__28457.call(null,new cljs.core.Keyword(null,"error","error",-978969032),expr__28458))){
return ((function (pred__28457,expr__28458){
return (function (p1__28453_SHARP_){
return console.error(p1__28453_SHARP_);
});
;})(pred__28457,expr__28458))
} else {
return ((function (pred__28457,expr__28458){
return (function (p1__28454_SHARP_){
return console.log(p1__28454_SHARP_);
});
;})(pred__28457,expr__28458))
}
}
}
})();
return f.call(null,arg);
});
figwheel.client.utils.log.cljs$lang$maxFixedArity = 2;
figwheel.client.utils.eval_helper = (function figwheel$client$utils$eval_helper(code,p__28461){
var map__28462 = p__28461;
var map__28462__$1 = (((((!((map__28462 == null))))?(((((map__28462.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__28462.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__28462):map__28462);
var opts = map__28462__$1;
var eval_fn = cljs.core.get.call(null,map__28462__$1,new cljs.core.Keyword(null,"eval-fn","eval-fn",-1111644294));
if(cljs.core.truth_(eval_fn)){
return eval_fn.call(null,code,opts);
} else {
return eval(code);
}
});
figwheel.client.utils.pprint_to_string = (function figwheel$client$utils$pprint_to_string(x){
var sb = (new goog.string.StringBuffer());
var sbw = (new cljs.core.StringBufferWriter(sb));
cljs.pprint.pprint.call(null,x,sbw);
return goog.string.trimRight(cljs.core.str.cljs$core$IFn$_invoke$arity$1(sb));
});
/**
* chains an async action on to a deferred
* Must provide a goog.async.Deferred and action function that
* takes an initial value and a continuation fn to call with the result
*/
figwheel.client.utils.liftContD = (function figwheel$client$utils$liftContD(deferred,f){
return deferred.then((function (val){
var new_def = (new goog.async.Deferred());
f.call(null,val,((function (new_def){
return (function (p1__28464_SHARP_){
return new_def.callback(p1__28464_SHARP_);
});})(new_def))
);
return new_def;
}));
});
/**
* maps an async action across a collection and chains the results
* onto a deferred
*/
figwheel.client.utils.mapConcatD = (function figwheel$client$utils$mapConcatD(deferred,f,coll){
var results = cljs.core.atom.call(null,cljs.core.PersistentVector.EMPTY);
return cljs.core.reduce.call(null,((function (results){
return (function (defr,v){
return figwheel.client.utils.liftContD.call(null,defr,((function (results){
return (function (_,fin){
return f.call(null,v,((function (results){
return (function (v__$1){
cljs.core.swap_BANG_.call(null,results,cljs.core.conj,v__$1);
return fin.call(null,v__$1);
});})(results))
);
});})(results))
);
});})(results))
,deferred,coll).then(((function (results){
return (function (_){
return goog.async.Deferred.succeed(cljs.core.deref.call(null,results));
});})(results))
);
});
if((typeof figwheel !== 'undefined') && (typeof figwheel.client !== 'undefined') && (typeof figwheel.client.utils !== 'undefined') && (typeof figwheel.client.utils.local_persistent_config !== 'undefined')){
} else {
figwheel.client.utils.local_persistent_config = (function (){var a = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
if((((typeof localStorage !== 'undefined')) && ((!((goog.object.get(localStorage,"setItem") == null)))))){
cljs.core.add_watch.call(null,a,new cljs.core.Keyword(null,"sync-local-storage","sync-local-storage",-473590105),((function (a){
return (function (_,___$1,___$2,n){
return cljs.core.mapv.call(null,((function (a){
return (function (p__28465){
var vec__28466 = p__28465;
var ky = cljs.core.nth.call(null,vec__28466,(0),null);
var v = cljs.core.nth.call(null,vec__28466,(1),null);
return localStorage.setItem(cljs.core.name.call(null,ky),cljs.core.pr_str.call(null,v));
});})(a))
,n);
});})(a))
);
} else {
}
return a;
})();
}
/**
* Set a local value on a key that in a browser will persist even when
* the browser gets reloaded.
*/
figwheel.client.utils.persistent_config_set_BANG_ = (function figwheel$client$utils$persistent_config_set_BANG_(ky,v){
return cljs.core.swap_BANG_.call(null,figwheel.client.utils.local_persistent_config,cljs.core.assoc,ky,v);
});
figwheel.client.utils.persistent_config_get = (function figwheel$client$utils$persistent_config_get(var_args){
var G__28470 = arguments.length;
switch (G__28470) {
case 2:
return figwheel.client.utils.persistent_config_get.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
case 1:
return figwheel.client.utils.persistent_config_get.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
figwheel.client.utils.persistent_config_get.cljs$core$IFn$_invoke$arity$2 = (function (ky,not_found){
try{if(cljs.core.contains_QMARK_.call(null,cljs.core.deref.call(null,figwheel.client.utils.local_persistent_config),ky)){
return cljs.core.get.call(null,cljs.core.deref.call(null,figwheel.client.utils.local_persistent_config),ky);
} else {
if(cljs.core.truth_((function (){var and__4120__auto__ = (((typeof localStorage !== 'undefined')) && ((!((goog.object.get(localStorage,"getItem") == null)))));
if(and__4120__auto__){
return localStorage.getItem(cljs.core.name.call(null,ky));
} else {
return and__4120__auto__;
}
})())){
var v = cljs.reader.read_string.call(null,localStorage.getItem(cljs.core.name.call(null,ky)));
figwheel.client.utils.persistent_config_set_BANG_.call(null,ky,v);
return v;
} else {
return not_found;
}
}
}catch (e28471){if((e28471 instanceof Error)){
var e = e28471;
return not_found;
} else {
throw e28471;
}
}});
figwheel.client.utils.persistent_config_get.cljs$core$IFn$_invoke$arity$1 = (function (ky){
return figwheel.client.utils.persistent_config_get.call(null,ky,null);
});
figwheel.client.utils.persistent_config_get.cljs$lang$maxFixedArity = 2;
//# sourceMappingURL=utils.js.map?rel=1582560150739

File diff suppressed because one or more lines are too long