Added compiled JavaScript to repository for GitHub pages

This feels like a mistake...
This commit is contained in:
Simon Brooke 2020-10-20 14:44:11 +01:00
parent 3d5a2fb322
commit dc226b1f25
468 changed files with 212152 additions and 2 deletions

View file

@ -0,0 +1,515 @@
(ns figwheel.client
(:require
[goog.Uri :as guri]
[goog.userAgent.product :as product]
[goog.object :as gobj]
[cljs.reader :refer [read-string]]
[cljs.core.async :refer [put! chan <! map< close! timeout alts!] :as async]
[figwheel.client.socket :as socket]
[figwheel.client.utils :as utils]
[figwheel.client.heads-up :as heads-up]
[figwheel.client.file-reloading :as reloading]
[clojure.string :as string]
;; to support repl doc
[cljs.repl])
(:require-macros
[cljs.core.async.macros :refer [go go-loop]])
(:import [goog]))
(def _figwheel-version_ "0.5.9")
;; exception formatting
(defn figwheel-repl-print
([stream args]
(socket/send! {:figwheel-event "callback"
:callback-name "figwheel-repl-print"
:content {:stream stream
:args args}})
nil)
([args]
(figwheel-repl-print :out args)))
(defn console-out-print [args]
(.apply (.-log js/console) js/console (into-array args)))
(defn console-err-print [args]
(.apply (.-error js/console) js/console (into-array args)))
(defn repl-out-print-fn [& args]
(console-out-print args)
(figwheel-repl-print :out args)
nil)
(defn repl-err-print-fn [& args]
(console-err-print args)
(figwheel-repl-print :err args)
nil)
(defn enable-repl-print! []
(set! *print-newline* false)
(set-print-fn! repl-out-print-fn)
(set-print-err-fn! repl-err-print-fn)
nil)
(defn autoload? []
(utils/persistent-config-get :figwheel-autoload true))
(defn ^:export toggle-autoload []
(let [res (utils/persistent-config-set! :figwheel-autoload (not (autoload?)))]
(utils/log :info
(str "Toggle autoload deprecated! Use (figwheel.client/set-autoload! false)"))
(utils/log :info
(str "Figwheel autoloading " (if (autoload?) "ON" "OFF")))
res))
(defn ^:export set-autoload
"Figwheel by default loads code changes as you work. Sometimes you
just want to work on your code without the ramifications of
autoloading and simply load your code piecemeal in the REPL. You can
turn autoloading on and of with this method.
(figwheel.client/set-autoload false)
NOTE: This is a persistent setting, meaning that it will persist
through browser reloads."
[b]
(assert (or (true? b) (false? b)))
(utils/persistent-config-set! :figwheel-autoload b))
(defn ^:export repl-pprint []
(utils/persistent-config-get :figwheel-repl-pprint true))
(defn ^:export set-repl-pprint
"This method gives you the ability to turn the pretty printing of
the REPL's return value on and off.
(figwheel.client/set-repl-pprint false)
NOTE: This is a persistent setting, meaning that it will persist
through browser reloads."
[b]
(assert (or (true? b) (false? b)))
(utils/persistent-config-set! :figwheel-repl-pprint b))
(defn ^:export repl-result-pr-str [v]
(if (repl-pprint)
(utils/pprint-to-string v)
(pr-str v)))
(defn get-essential-messages [ed]
(when ed
(cons (select-keys ed [:message :class])
(get-essential-messages (:cause ed)))))
(defn error-msg-format [{:keys [message class]}] (str class " : " message))
(def format-messages (comp (partial map error-msg-format) get-essential-messages))
;; more flexible state management
(defn focus-msgs [name-set msg-hist]
(cons (first msg-hist) (filter (comp name-set :msg-name) (rest msg-hist))))
(defn reload-file?* [msg-name opts]
(or (:load-warninged-code opts)
(not= msg-name :compile-warning)))
(defn reload-file-state? [msg-names opts]
(and (= (first msg-names) :files-changed)
(reload-file?* (second msg-names) opts)))
(defn block-reload-file-state? [msg-names opts]
(and (= (first msg-names) :files-changed)
(not (reload-file?* (second msg-names) opts))))
(defn warning-append-state? [msg-names]
(= [:compile-warning :compile-warning] (take 2 msg-names)))
(defn warning-state? [msg-names]
(= :compile-warning (first msg-names)))
(defn rewarning-state? [msg-names]
(= [:compile-warning :files-changed :compile-warning] (take 3 msg-names)))
(defn compile-fail-state? [msg-names]
(= :compile-failed (first msg-names)))
(defn compile-refail-state? [msg-names]
(= [:compile-failed :compile-failed] (take 2 msg-names)))
(defn css-loaded-state? [msg-names]
(= :css-files-changed (first msg-names)))
(defn file-reloader-plugin [opts]
(let [ch (chan)]
(go-loop []
(when-let [msg-hist' (<! ch)]
(let [msg-hist (focus-msgs #{:files-changed :compile-warning} msg-hist')
msg-names (map :msg-name msg-hist)
msg (first msg-hist)]
#_(.log js/console (prn-str msg))
(if (autoload?)
(cond
(reload-file-state? msg-names opts)
(alts! [(reloading/reload-js-files opts msg) (timeout 1000)])
(block-reload-file-state? msg-names opts)
(utils/log :warn (str "Figwheel: Not loading code with warnings - " (-> msg :files first :file))))
(do
(utils/log :warn "Figwheel: code autoloading is OFF")
(utils/log :info (str "Not loading: " (map :file (:files msg))))))
(recur))))
(fn [msg-hist] (put! ch msg-hist) msg-hist)))
#_(defn error-test2 []
js/joe)
#_(defn error-test3 []
(error-test2))
#_(defn error-test []
(error-test3))
(defn truncate-stack-trace [stack-str]
(take-while #(not (re-matches #".*eval_javascript_STAR__STAR_.*" %))
(string/split-lines stack-str)))
(defn get-ua-product []
(cond
(utils/node-env?) :chrome
product/SAFARI :safari
product/CHROME :chrome
product/FIREFOX :firefox
product/IE :ie))
(let [base-path (utils/base-url-path)]
(defn eval-javascript** [code opts result-handler]
(try
(enable-repl-print!)
(let [result-value (utils/eval-helper code opts)]
(result-handler
{:status :success,
:ua-product (get-ua-product)
:value result-value}))
(catch js/Error e
(result-handler
{:status :exception
:value (pr-str e)
:ua-product (get-ua-product)
:stacktrace (string/join "\n" (truncate-stack-trace (.-stack e)))
:base-path base-path }))
(catch :default e
(result-handler
{:status :exception
:ua-product (get-ua-product)
:value (pr-str e)
:stacktrace "No stacktrace available."}))
(finally
;; should we let people shoot themselves in the foot?
;; you can theoretically disable repl printing in the repl
;; but for now I'm going to prevent it
(enable-repl-print!)))))
(defn ensure-cljs-user
"The REPL can disconnect and reconnect lets ensure cljs.user exists at least."
[]
;; this should be included in the REPL
(when-not js/cljs.user
(set! js/cljs.user #js {})))
(defn repl-plugin [{:keys [build-id] :as opts}]
(fn [[{:keys [msg-name] :as msg} & _]]
(when (= :repl-eval msg-name)
(ensure-cljs-user)
(eval-javascript** (:code msg) opts
(fn [res]
(socket/send! {:figwheel-event "callback"
:callback-name (:callback-name msg)
:content res}))))))
(defn css-reloader-plugin [opts]
(fn [[{:keys [msg-name] :as msg} & _]]
(when (= msg-name :css-files-changed)
(reloading/reload-css-files opts msg))))
(defn compile-fail-warning-plugin [{:keys [on-compile-warning on-compile-fail]}]
(fn [[{:keys [msg-name] :as msg} & _]]
(condp = msg-name
:compile-warning (on-compile-warning msg)
:compile-failed (on-compile-fail msg)
nil)))
(defn auto-jump-to-error [opts error]
(when (:auto-jump-to-source-on-error opts)
(heads-up/auto-notify-source-file-line error)))
;; this is seperate for live dev only
(defn heads-up-plugin-msg-handler [opts msg-hist']
(let [msg-hist (focus-msgs #{:files-changed :compile-warning :compile-failed} msg-hist')
msg-names (map :msg-name msg-hist)
msg (first msg-hist)]
(go
(cond
(reload-file-state? msg-names opts)
(if (and (autoload?)
(:autoload opts))
(<! (heads-up/flash-loaded))
(<! (heads-up/clear)))
(compile-refail-state? msg-names)
(do
(<! (heads-up/clear))
(<! (heads-up/display-exception (:exception-data msg)))
(auto-jump-to-error opts (:exception-data msg)))
(compile-fail-state? msg-names)
(do
(<! (heads-up/display-exception (:exception-data msg)))
(auto-jump-to-error opts (:exception-data msg)))
(warning-append-state? msg-names)
(heads-up/append-warning-message (:message msg))
(rewarning-state? msg-names)
(do
(<! (heads-up/clear))
(<! (heads-up/display-warning (:message msg)))
(auto-jump-to-error opts (:message msg)))
(warning-state? msg-names)
(do
(<! (heads-up/display-warning (:message msg)))
(auto-jump-to-error opts (:message msg)))
(css-loaded-state? msg-names)
(<! (heads-up/flash-loaded))))))
(defn heads-up-plugin [opts]
(let [ch (chan)]
(def heads-up-config-options** opts)
(go-loop []
(when-let [msg-hist' (<! ch)]
(<! (heads-up-plugin-msg-handler opts msg-hist'))
(recur)))
(heads-up/ensure-container)
(fn [msg-hist] (put! ch msg-hist) msg-hist)))
(defn enforce-project-plugin [opts]
(fn [msg-hist]
(when (< 1 (count (set (keep :project-id (take 5 msg-hist)))))
(socket/close!)
(.error js/console "Figwheel: message received from different project. Shutting socket down.")
(when (:heads-up-display opts)
(go
(<! (timeout 3000))
(heads-up/display-system-warning
"Connection from different project"
"Shutting connection down!!!!!"))))))
(defn enforce-figwheel-version-plugin [opts]
(fn [msg-hist]
(when-let [figwheel-version (-> msg-hist first :figwheel-version)]
(when (not= figwheel-version _figwheel-version_)
(socket/close!)
(.error js/console "Figwheel: message received from different version of Figwheel.")
(when (:heads-up-display opts)
(go
(<! (timeout 2000))
(heads-up/display-system-warning
"Figwheel Client and Server have different versions!!"
(str "Figwheel Client Version <strong>" _figwheel-version_ "</strong> is not equal to "
"Figwheel Sidecar Version <strong>" figwheel-version "</strong>"
". Shutting down Websocket Connection!"
"<h4>To fix try:</h4>"
"<ol><li>Reload this page and make sure you are not getting a cached version of the client.</li>"
"<li>You may have to clean (delete compiled assets) and rebuild to make sure that the new client code is being used.</li>"
"<li>Also, make sure you have consistent Figwheel dependencies.</li></ol>"))))))))
#_((enforce-figwheel-version-plugin {:heads-up-display true}) [{:figwheel-version "yeah"}])
;; defaults and configuration
;; default callbacks
;; if you don't configure a :jsload-callback or an :on-jsload callback
;; this function will dispatch a browser event
;;
;; you can listen to this event easily like so:
;; document.body.addEventListener("figwheel.js-reload", function (e) { console.log(e.detail);} );
(def default-on-jsload identity)
(defn file-line-column [{:keys [file line column]}]
(cond-> ""
file (str "file " file)
line (str " at line " line)
(and line column) (str ", column " column)))
(defn default-on-compile-fail [{:keys [formatted-exception exception-data cause] :as ed}]
(utils/log :debug "Figwheel: Compile Exception")
(doseq [msg (format-messages exception-data)]
(utils/log :info msg))
(if cause
(utils/log :info (str "Error on " (file-line-column ed))))
ed)
(defn default-on-compile-warning [{:keys [message] :as w}]
(utils/log :warn (str "Figwheel: Compile Warning - " (:message message) " in " (file-line-column message)))
w)
(defn default-before-load [files]
(utils/log :debug "Figwheel: notified of file changes")
files)
(defn default-on-cssload [files]
(utils/log :debug "Figwheel: loaded CSS files")
(utils/log :info (pr-str (map :file files)))
files)
(defonce config-defaults
{:retry-count 100
:websocket-url (str "ws://"
(if (utils/html-env?) js/location.host "localhost:3449")
"/figwheel-ws")
:load-warninged-code false
:auto-jump-to-source-on-error false
;; :on-message identity
:on-jsload default-on-jsload
:before-jsload default-before-load
:on-cssload default-on-cssload
:on-compile-fail #'default-on-compile-fail
:on-compile-warning #'default-on-compile-warning
:reload-dependents true
:autoload true
:debug false
:heads-up-display true
:eval-fn false
})
(defn handle-deprecated-jsload-callback [config]
(if (:jsload-callback config)
(-> config
(assoc :on-jsload (:jsload-callback config))
(dissoc :jsload-callback))
config))
(defn fill-url-template [config]
(if (utils/html-env?)
(update-in config [:websocket-url]
(fn [x]
(-> x
(string/replace "[[client-hostname]]" js/location.hostname)
(string/replace "[[client-port]]" js/location.port))))
config))
(defn base-plugins [system-options]
(let [base {:enforce-project-plugin enforce-project-plugin
:enforce-figwheel-version-plugin enforce-figwheel-version-plugin
:file-reloader-plugin file-reloader-plugin
:comp-fail-warning-plugin compile-fail-warning-plugin
:css-reloader-plugin css-reloader-plugin
:repl-plugin repl-plugin}
base (if (not (utils/html-env?)) ;; we are in an html environment?
(select-keys base [#_:enforce-project-plugin
:file-reloader-plugin
:comp-fail-warning-plugin
:repl-plugin])
base)
base (if (false? (:autoload system-options))
(dissoc base :file-reloader-plugin)
base)]
(if (and (:heads-up-display system-options)
(utils/html-env?))
(assoc base :heads-up-display-plugin heads-up-plugin)
base)))
(defn add-message-watch [key callback]
(add-watch
socket/message-history-atom key
(fn [_ _ _ msg-hist] (callback (first msg-hist)))))
(defn add-plugins [plugins system-options]
(doseq [[k plugin] plugins]
(when plugin
(let [pl (plugin system-options)]
(add-watch socket/message-history-atom k
(fn [_ _ _ msg-hist] (pl msg-hist)))))))
(defn start
([opts]
(when-not (nil? goog/dependencies_)
(defonce __figwheel-start-once__
(js/setTimeout
#(let [plugins' (:plugins opts) ;; plugins replaces all plugins
merge-plugins (:merge-plugins opts) ;; merges plugins
system-options (-> config-defaults
(merge (dissoc opts :plugins :merge-plugins))
handle-deprecated-jsload-callback
fill-url-template)
plugins (if plugins'
plugins'
(merge (base-plugins system-options) merge-plugins))]
(set! utils/*print-debug* (:debug opts))
(enable-repl-print!)
(add-plugins plugins system-options)
(reloading/patch-goog-base)
(doseq [msg (:initial-messages system-options)]
(socket/handle-incoming-message msg))
(socket/open system-options))))))
([] (start {})))
;; legacy interface
(def watch-and-reload-with-opts start)
(defn watch-and-reload [& {:keys [] :as opts}] (start opts))
;; --- Bad Initial Compilation Helper Application ---
;;
;; this is only used to replace a missing compile target
;; when the initial compile fails due an exception
;; this is intended to be compiled seperately
(defn fetch-data-from-env []
(try
(read-string (gobj/get js/window "FIGWHEEL_CLIENT_CONFIGURATION"))
(catch js/Error e
(cljs.core/*print-err-fn*
"Unable to load FIGWHEEL_CLIENT_CONFIGURATION from the environment")
{:autoload false})))
(def console-intro-message
"Figwheel has compiled a temporary helper application to your :output-file.
The code currently in your configured output file does not
represent the code that you are trying to compile.
This temporary application is intended to help you continue to get
feedback from Figwheel until the build you are working on compiles
correctly.
When your ClojureScript source code compiles correctly this helper
application will auto-reload and pick up your freshly compiled
ClojureScript program.")
(defn bad-compile-helper-app []
(enable-console-print!)
(let [config (fetch-data-from-env)]
(println console-intro-message)
(heads-up/bad-compile-screen)
(when-not js/goog.dependencies_
(set! js/goog.dependencies_ true))
(start config)
(add-message-watch
:listen-for-successful-compile
(fn [{:keys [msg-name]}]
(when (= msg-name :files-changed)
(set! js/location.href js/location.href))))))

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,529 @@
(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.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]
[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))
(aget js/goog.dependencies_.nameToPath ns))
(defn provided? [ns]
(aget js/goog.dependencies_.written (name->path ns)))
(defn immutable-ns? [name]
(or (#{"goog"
"cljs.core"
"an.existing.path"
"dup.base"
"far.out"
"ns"
"someprotopackage.TestPackageTypes"
"svgpan.SvgPan"
"testDep.bar"} name)
(some
(partial goog.string/startsWith name)
["goog." "cljs." "clojure." "fake." "proto2."])))
(defn get-requires [ns]
(->> ns
name->path
(aget 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 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]
(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)]
(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 reload-file*
(condp = (utils/host-env?)
:node
(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))))))
:html (fn [request-url callback]
(dev-assert (string? request-url) (not (nil? callback)))
(let [deferred (loader/load (add-cache-buster request-url)
#js { :cleanupWhenDone true })]
(.addCallback deferred #(apply callback [true]))
(.addErrback deferred #(apply callback [false]))))
:worker (fn [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))))
(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))
(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 (<! reload-chan)]
(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] (put! reload-chan url))
(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 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))))))
(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]]
(aset (.-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>" (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,906 @@
// Compiled by ClojureScript 1.9.229 {}
goog.provide('figwheel.client.heads_up');
goog.require('cljs.core');
goog.require('goog.dom');
goog.require('goog.dom.dataset');
goog.require('goog.string');
goog.require('cljs.core.async');
goog.require('goog.object');
goog.require('figwheel.client.socket');
goog.require('cljs.pprint');
goog.require('clojure.string');
goog.require('figwheel.client.utils');
figwheel.client.heads_up.node = (function figwheel$client$heads_up$node(var_args){
var args__26212__auto__ = [];
var len__26205__auto___37789 = arguments.length;
var i__26206__auto___37790 = (0);
while(true){
if((i__26206__auto___37790 < len__26205__auto___37789)){
args__26212__auto__.push((arguments[i__26206__auto___37790]));
var G__37791 = (i__26206__auto___37790 + (1));
i__26206__auto___37790 = G__37791;
continue;
} else {
}
break;
}
var argseq__26213__auto__ = ((((2) < args__26212__auto__.length))?(new cljs.core.IndexedSeq(args__26212__auto__.slice((2)),(0),null)):null);
return figwheel.client.heads_up.node.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__26213__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__37781_37792 = cljs.core.seq.call(null,cljs.core.keys.call(null,attrs));
var chunk__37782_37793 = null;
var count__37783_37794 = (0);
var i__37784_37795 = (0);
while(true){
if((i__37784_37795 < count__37783_37794)){
var k_37796 = cljs.core._nth.call(null,chunk__37782_37793,i__37784_37795);
e.setAttribute(cljs.core.name.call(null,k_37796),cljs.core.get.call(null,attrs,k_37796));
var G__37797 = seq__37781_37792;
var G__37798 = chunk__37782_37793;
var G__37799 = count__37783_37794;
var G__37800 = (i__37784_37795 + (1));
seq__37781_37792 = G__37797;
chunk__37782_37793 = G__37798;
count__37783_37794 = G__37799;
i__37784_37795 = G__37800;
continue;
} else {
var temp__4657__auto___37801 = cljs.core.seq.call(null,seq__37781_37792);
if(temp__4657__auto___37801){
var seq__37781_37802__$1 = temp__4657__auto___37801;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__37781_37802__$1)){
var c__25941__auto___37803 = cljs.core.chunk_first.call(null,seq__37781_37802__$1);
var G__37804 = cljs.core.chunk_rest.call(null,seq__37781_37802__$1);
var G__37805 = c__25941__auto___37803;
var G__37806 = cljs.core.count.call(null,c__25941__auto___37803);
var G__37807 = (0);
seq__37781_37792 = G__37804;
chunk__37782_37793 = G__37805;
count__37783_37794 = G__37806;
i__37784_37795 = G__37807;
continue;
} else {
var k_37808 = cljs.core.first.call(null,seq__37781_37802__$1);
e.setAttribute(cljs.core.name.call(null,k_37808),cljs.core.get.call(null,attrs,k_37808));
var G__37809 = cljs.core.next.call(null,seq__37781_37802__$1);
var G__37810 = null;
var G__37811 = (0);
var G__37812 = (0);
seq__37781_37792 = G__37809;
chunk__37782_37793 = G__37810;
count__37783_37794 = G__37811;
i__37784_37795 = G__37812;
continue;
}
} else {
}
}
break;
}
var seq__37785_37813 = cljs.core.seq.call(null,children);
var chunk__37786_37814 = null;
var count__37787_37815 = (0);
var i__37788_37816 = (0);
while(true){
if((i__37788_37816 < count__37787_37815)){
var ch_37817 = cljs.core._nth.call(null,chunk__37786_37814,i__37788_37816);
e.appendChild(ch_37817);
var G__37818 = seq__37785_37813;
var G__37819 = chunk__37786_37814;
var G__37820 = count__37787_37815;
var G__37821 = (i__37788_37816 + (1));
seq__37785_37813 = G__37818;
chunk__37786_37814 = G__37819;
count__37787_37815 = G__37820;
i__37788_37816 = G__37821;
continue;
} else {
var temp__4657__auto___37822 = cljs.core.seq.call(null,seq__37785_37813);
if(temp__4657__auto___37822){
var seq__37785_37823__$1 = temp__4657__auto___37822;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__37785_37823__$1)){
var c__25941__auto___37824 = cljs.core.chunk_first.call(null,seq__37785_37823__$1);
var G__37825 = cljs.core.chunk_rest.call(null,seq__37785_37823__$1);
var G__37826 = c__25941__auto___37824;
var G__37827 = cljs.core.count.call(null,c__25941__auto___37824);
var G__37828 = (0);
seq__37785_37813 = G__37825;
chunk__37786_37814 = G__37826;
count__37787_37815 = G__37827;
i__37788_37816 = G__37828;
continue;
} else {
var ch_37829 = cljs.core.first.call(null,seq__37785_37823__$1);
e.appendChild(ch_37829);
var G__37830 = cljs.core.next.call(null,seq__37785_37823__$1);
var G__37831 = null;
var G__37832 = (0);
var G__37833 = (0);
seq__37785_37813 = G__37830;
chunk__37786_37814 = G__37831;
count__37787_37815 = G__37832;
i__37788_37816 = G__37833;
continue;
}
} else {
}
}
break;
}
return e;
});
figwheel.client.heads_up.node.cljs$lang$maxFixedArity = (2);
figwheel.client.heads_up.node.cljs$lang$applyTo = (function (seq37778){
var G__37779 = cljs.core.first.call(null,seq37778);
var seq37778__$1 = cljs.core.next.call(null,seq37778);
var G__37780 = cljs.core.first.call(null,seq37778__$1);
var seq37778__$2 = cljs.core.next.call(null,seq37778__$1);
return figwheel.client.heads_up.node.cljs$core$IFn$_invoke$arity$variadic(G__37779,G__37780,seq37778__$2);
});
if(typeof figwheel.client.heads_up.heads_up_event_dispatch !== 'undefined'){
} else {
figwheel.client.heads_up.heads_up_event_dispatch = (function (){var method_table__26055__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var prefer_table__26056__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var method_cache__26057__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var cached_hierarchy__26058__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var hierarchy__26059__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__26055__auto__,prefer_table__26056__auto__,method_cache__26057__auto__,cached_hierarchy__26058__auto__,hierarchy__26059__auto__){
return (function (dataset){
return dataset.figwheelEvent;
});})(method_table__26055__auto__,prefer_table__26056__auto__,method_cache__26057__auto__,cached_hierarchy__26058__auto__,hierarchy__26059__auto__))
,new cljs.core.Keyword(null,"default","default",-1987822328),hierarchy__26059__auto__,method_table__26055__auto__,prefer_table__26056__auto__,method_cache__26057__auto__,cached_hierarchy__26058__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([cljs.core.str("#"),cljs.core.str(cont_id)].join('')))){
var el_37834 = 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),[cljs.core.str("-webkit-transition: all 0.2s ease-in-out;"),cljs.core.str("-moz-transition: all 0.2s ease-in-out;"),cljs.core.str("-o-transition: all 0.2s ease-in-out;"),cljs.core.str("transition: all 0.2s ease-in-out;"),cljs.core.str("font-size: 13px;"),cljs.core.str("border-top: 1px solid #f5f5f5;"),cljs.core.str("box-shadow: 0px 0px 1px #aaaaaa;"),cljs.core.str("line-height: 18px;"),cljs.core.str("color: #333;"),cljs.core.str("font-family: monospace;"),cljs.core.str("padding: 0px 10px 0px 70px;"),cljs.core.str("position: fixed;"),cljs.core.str("bottom: 0px;"),cljs.core.str("left: 0px;"),cljs.core.str("height: 0px;"),cljs.core.str("opacity: 0.0;"),cljs.core.str("box-sizing: border-box;"),cljs.core.str("z-index: 10000;"),cljs.core.str("text-align: left;")].join('')], null));
el_37834.onclick = figwheel.client.heads_up.heads_up_onclick_handler;
el_37834.innerHTML = figwheel.client.heads_up.cljs_logo_svg;
el_37834.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_37834);
} 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__37835,st_map){
var map__37842 = p__37835;
var map__37842__$1 = ((((!((map__37842 == null)))?((((map__37842.cljs$lang$protocol_mask$partition0$ & (64))) || (map__37842.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__37842):map__37842);
var container_el = cljs.core.get.call(null,map__37842__$1,new cljs.core.Keyword(null,"container-el","container-el",109664205));
return cljs.core.mapv.call(null,((function (map__37842,map__37842__$1,container_el){
return (function (p__37844){
var vec__37845 = p__37844;
var k = cljs.core.nth.call(null,vec__37845,(0),null);
var v = cljs.core.nth.call(null,vec__37845,(1),null);
return (container_el.style[cljs.core.name.call(null,k)] = v);
});})(map__37842,map__37842__$1,container_el))
,st_map);
});
figwheel.client.heads_up.set_content_BANG_ = (function figwheel$client$heads_up$set_content_BANG_(p__37848,dom_str){
var map__37851 = p__37848;
var map__37851__$1 = ((((!((map__37851 == null)))?((((map__37851.cljs$lang$protocol_mask$partition0$ & (64))) || (map__37851.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__37851):map__37851);
var c = map__37851__$1;
var content_area_el = cljs.core.get.call(null,map__37851__$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__37853){
var map__37856 = p__37853;
var map__37856__$1 = ((((!((map__37856 == null)))?((((map__37856.cljs$lang$protocol_mask$partition0$ & (64))) || (map__37856.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__37856):map__37856);
var content_area_el = cljs.core.get.call(null,map__37856__$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 [cljs.core.str("<a style=\""),cljs.core.str("float: right;"),cljs.core.str("font-size: 18px;"),cljs.core.str("text-decoration: none;"),cljs.core.str("text-align: right;"),cljs.core.str("width: 30px;"),cljs.core.str("height: 30px;"),cljs.core.str("color: rgba(84,84,84, 0.5);"),cljs.core.str("\" href=\"#\" data-figwheel-event=\"close-heads-up\">"),cljs.core.str("x"),cljs.core.str("</a>")].join('');
});
figwheel.client.heads_up.display_heads_up = (function figwheel$client$heads_up$display_heads_up(style,msg){
var c__28364__auto__ = cljs.core.async.chan.call(null,(1));
cljs.core.async.impl.dispatch.run.call(null,((function (c__28364__auto__){
return (function (){
var f__28365__auto__ = (function (){var switch__28252__auto__ = ((function (c__28364__auto__){
return (function (state_37899){
var state_val_37900 = (state_37899[(1)]);
if((state_val_37900 === (1))){
var inst_37884 = (state_37899[(7)]);
var inst_37884__$1 = figwheel.client.heads_up.ensure_container.call(null);
var inst_37885 = [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_37886 = ["10px","10px","100%","68px","1.0"];
var inst_37887 = cljs.core.PersistentHashMap.fromArrays(inst_37885,inst_37886);
var inst_37888 = cljs.core.merge.call(null,inst_37887,style);
var inst_37889 = figwheel.client.heads_up.set_style_BANG_.call(null,inst_37884__$1,inst_37888);
var inst_37890 = figwheel.client.heads_up.set_content_BANG_.call(null,inst_37884__$1,msg);
var inst_37891 = cljs.core.async.timeout.call(null,(300));
var state_37899__$1 = (function (){var statearr_37901 = state_37899;
(statearr_37901[(8)] = inst_37889);
(statearr_37901[(9)] = inst_37890);
(statearr_37901[(7)] = inst_37884__$1);
return statearr_37901;
})();
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_37899__$1,(2),inst_37891);
} else {
if((state_val_37900 === (2))){
var inst_37884 = (state_37899[(7)]);
var inst_37893 = (state_37899[(2)]);
var inst_37894 = [new cljs.core.Keyword(null,"height","height",1025178622)];
var inst_37895 = ["auto"];
var inst_37896 = cljs.core.PersistentHashMap.fromArrays(inst_37894,inst_37895);
var inst_37897 = figwheel.client.heads_up.set_style_BANG_.call(null,inst_37884,inst_37896);
var state_37899__$1 = (function (){var statearr_37902 = state_37899;
(statearr_37902[(10)] = inst_37893);
return statearr_37902;
})();
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_37899__$1,inst_37897);
} else {
return null;
}
}
});})(c__28364__auto__))
;
return ((function (switch__28252__auto__,c__28364__auto__){
return (function() {
var figwheel$client$heads_up$display_heads_up_$_state_machine__28253__auto__ = null;
var figwheel$client$heads_up$display_heads_up_$_state_machine__28253__auto____0 = (function (){
var statearr_37906 = [null,null,null,null,null,null,null,null,null,null,null];
(statearr_37906[(0)] = figwheel$client$heads_up$display_heads_up_$_state_machine__28253__auto__);
(statearr_37906[(1)] = (1));
return statearr_37906;
});
var figwheel$client$heads_up$display_heads_up_$_state_machine__28253__auto____1 = (function (state_37899){
while(true){
var ret_value__28254__auto__ = (function (){try{while(true){
var result__28255__auto__ = switch__28252__auto__.call(null,state_37899);
if(cljs.core.keyword_identical_QMARK_.call(null,result__28255__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
continue;
} else {
return result__28255__auto__;
}
break;
}
}catch (e37907){if((e37907 instanceof Object)){
var ex__28256__auto__ = e37907;
var statearr_37908_37910 = state_37899;
(statearr_37908_37910[(5)] = ex__28256__auto__);
cljs.core.async.impl.ioc_helpers.process_exception.call(null,state_37899);
return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
throw e37907;
}
}})();
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__28254__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
var G__37911 = state_37899;
state_37899 = G__37911;
continue;
} else {
return ret_value__28254__auto__;
}
break;
}
});
figwheel$client$heads_up$display_heads_up_$_state_machine__28253__auto__ = function(state_37899){
switch(arguments.length){
case 0:
return figwheel$client$heads_up$display_heads_up_$_state_machine__28253__auto____0.call(this);
case 1:
return figwheel$client$heads_up$display_heads_up_$_state_machine__28253__auto____1.call(this,state_37899);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
figwheel$client$heads_up$display_heads_up_$_state_machine__28253__auto__.cljs$core$IFn$_invoke$arity$0 = figwheel$client$heads_up$display_heads_up_$_state_machine__28253__auto____0;
figwheel$client$heads_up$display_heads_up_$_state_machine__28253__auto__.cljs$core$IFn$_invoke$arity$1 = figwheel$client$heads_up$display_heads_up_$_state_machine__28253__auto____1;
return figwheel$client$heads_up$display_heads_up_$_state_machine__28253__auto__;
})()
;})(switch__28252__auto__,c__28364__auto__))
})();
var state__28366__auto__ = (function (){var statearr_37909 = f__28365__auto__.call(null);
(statearr_37909[cljs.core.async.impl.ioc_helpers.USER_START_IDX] = c__28364__auto__);
return statearr_37909;
})();
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__28366__auto__);
});})(c__28364__auto__))
);
return c__28364__auto__;
});
figwheel.client.heads_up.heading = (function figwheel$client$heads_up$heading(var_args){
var args37912 = [];
var len__26205__auto___37915 = arguments.length;
var i__26206__auto___37916 = (0);
while(true){
if((i__26206__auto___37916 < len__26205__auto___37915)){
args37912.push((arguments[i__26206__auto___37916]));
var G__37917 = (i__26206__auto___37916 + (1));
i__26206__auto___37916 = G__37917;
continue;
} else {
}
break;
}
var G__37914 = args37912.length;
switch (G__37914) {
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([cljs.core.str("Invalid arity: "),cljs.core.str(args37912.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 [cljs.core.str("<div style=\""),cljs.core.str("font-size: 26px;"),cljs.core.str("line-height: 26px;"),cljs.core.str("margin-bottom: 2px;"),cljs.core.str("padding-top: 1px;"),cljs.core.str("\">"),cljs.core.str(s),cljs.core.str(" <span style=\""),cljs.core.str("display: inline-block;"),cljs.core.str("font-size: 13px;"),cljs.core.str("\">"),cljs.core.str(sub_head),cljs.core.str("</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 [cljs.core.str("<div style=\"cursor: pointer;\" data-figwheel-event=\"file-selected\" data-file-name=\""),cljs.core.str(file_name),cljs.core.str("\" data-file-line=\""),cljs.core.str(line_number),cljs.core.str("\" data-file-column=\""),cljs.core.str(column_number),cljs.core.str("\">"),cljs.core.str(msg),cljs.core.str("</div>")].join('');
});
figwheel.client.heads_up.format_line = (function figwheel$client$heads_up$format_line(msg,p__37919){
var map__37922 = p__37919;
var map__37922__$1 = ((((!((map__37922 == null)))?((((map__37922.cljs$lang$protocol_mask$partition0$ & (64))) || (map__37922.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__37922):map__37922);
var file = cljs.core.get.call(null,map__37922__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
var line = cljs.core.get.call(null,map__37922__$1,new cljs.core.Keyword(null,"line","line",212345235));
var column = cljs.core.get.call(null,map__37922__$1,new cljs.core.Keyword(null,"column","column",2078222095));
var msg__$1 = goog.string.htmlEscape(msg);
if(cljs.core.truth_((function (){var or__25130__auto__ = file;
if(cljs.core.truth_(or__25130__auto__)){
return or__25130__auto__;
} else {
return line;
}
})())){
return figwheel.client.heads_up.file_selector_div.call(null,file,line,column,msg__$1);
} else {
return [cljs.core.str("<div>"),cljs.core.str(msg__$1),cljs.core.str("</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((((len < n))?cljs.core.apply.call(null,cljs.core.str,cljs.core.repeat.call(null,(n - len)," ")):"")),cljs.core.str(line_number)].join('');
});
figwheel.client.heads_up.inline_error_line = (function figwheel$client$heads_up$inline_error_line(style,line_number,line){
return [cljs.core.str("<span style='"),cljs.core.str(style),cljs.core.str("'>"),cljs.core.str("<span style='color: #757575;'>"),cljs.core.str(line_number),cljs.core.str(" </span>"),cljs.core.str(figwheel.client.heads_up.escape.call(null,line)),cljs.core.str("</span>")].join('');
});
figwheel.client.heads_up.format_inline_error_line = (function figwheel$client$heads_up$format_inline_error_line(p__37924){
var vec__37931 = p__37924;
var typ = cljs.core.nth.call(null,vec__37931,(0),null);
var line_number = cljs.core.nth.call(null,vec__37931,(1),null);
var line = cljs.core.nth.call(null,vec__37931,(2),null);
var pred__37934 = cljs.core._EQ_;
var expr__37935 = typ;
if(cljs.core.truth_(pred__37934.call(null,new cljs.core.Keyword(null,"code-line","code-line",-2138627853),expr__37935))){
return figwheel.client.heads_up.inline_error_line.call(null,"color: #999;",line_number,line);
} else {
if(cljs.core.truth_(pred__37934.call(null,new cljs.core.Keyword(null,"error-in-code","error-in-code",-1661931357),expr__37935))){
return figwheel.client.heads_up.inline_error_line.call(null,"color: #ccc; font-weight: bold;",line_number,line);
} else {
if(cljs.core.truth_(pred__37934.call(null,new cljs.core.Keyword(null,"error-message","error-message",1756021561),expr__37935))){
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.reduce.call(null,cljs.core.max,cljs.core.map.call(null,cljs.core.second,inline_error)))].join(''));
return cljs.core.map.call(null,((function (max_line_number_length){
return (function (p1__37937_SHARP_){
return cljs.core.update_in.call(null,p1__37937_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 [cljs.core.str("<pre style='whitespace:pre; overflow-x: scroll; display:block; font-family:monospace; font-size:0.8em; border-radius: 3px;"),cljs.core.str(" line-height: 1.1em; padding: 10px; background-color: rgb(24,26,38); margin-right: 5px'>"),cljs.core.str(clojure.string.join.call(null,"\n",lines)),cljs.core.str("</pre>")].join('');
});
figwheel.client.heads_up.flatten_exception = (function figwheel$client$heads_up$flatten_exception(p1__37938_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__37938_SHARP_));
});
figwheel.client.heads_up.exception__GT_display_data = (function figwheel$client$heads_up$exception__GT_display_data(p__37941){
var map__37944 = p__37941;
var map__37944__$1 = ((((!((map__37944 == null)))?((((map__37944.cljs$lang$protocol_mask$partition0$ & (64))) || (map__37944.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__37944):map__37944);
var exception = map__37944__$1;
var message = cljs.core.get.call(null,map__37944__$1,new cljs.core.Keyword(null,"message","message",-406056002));
var failed_loading_clj_file = cljs.core.get.call(null,map__37944__$1,new cljs.core.Keyword(null,"failed-loading-clj-file","failed-loading-clj-file",-1682536481));
var reader_exception = cljs.core.get.call(null,map__37944__$1,new cljs.core.Keyword(null,"reader-exception","reader-exception",-1938323098));
var file = cljs.core.get.call(null,map__37944__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
var column = cljs.core.get.call(null,map__37944__$1,new cljs.core.Keyword(null,"column","column",2078222095));
var failed_compiling = cljs.core.get.call(null,map__37944__$1,new cljs.core.Keyword(null,"failed-compiling","failed-compiling",1768639503));
var error_inline = cljs.core.get.call(null,map__37944__$1,new cljs.core.Keyword(null,"error-inline","error-inline",1073987185));
var line = cljs.core.get.call(null,map__37944__$1,new cljs.core.Keyword(null,"line","line",212345235));
var class$ = cljs.core.get.call(null,map__37944__$1,new cljs.core.Keyword(null,"class","class",-2030961996));
var analysis_exception = cljs.core.get.call(null,map__37944__$1,new cljs.core.Keyword(null,"analysis-exception","analysis-exception",591623285));
var display_ex_data = cljs.core.get.call(null,map__37944__$1,new cljs.core.Keyword(null,"display-ex-data","display-ex-data",-1611558730));
var last_message = (cljs.core.truth_((function (){var and__25118__auto__ = file;
if(cljs.core.truth_(and__25118__auto__)){
return line;
} else {
return and__25118__auto__;
}
})())?[cljs.core.str("Please see line "),cljs.core.str(line),cljs.core.str(" of file "),cljs.core.str(file)].join(''):(cljs.core.truth_(file)?[cljs.core.str("Please see "),cljs.core.str(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__37944,map__37944__$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__37939_SHARP_){
return [cljs.core.str("<div>"),cljs.core.str(p1__37939_SHARP_),cljs.core.str("</div>")].join('');
});})(last_message,map__37944,map__37944__$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.str((cljs.core.truth_(class$)?[cljs.core.str(figwheel.client.heads_up.escape.call(null,class$)),cljs.core.str(": ")].join(''):"")),cljs.core.str("<span style=\"font-weight:bold;\">"),cljs.core.str(figwheel.client.heads_up.escape.call(null,message)),cljs.core.str("</span>")].join(''),(cljs.core.truth_(display_ex_data)?[cljs.core.str("<pre>"),cljs.core.str(figwheel.client.utils.pprint_to_string.call(null,display_ex_data)),cljs.core.str("</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__37944,map__37944__$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__37940_SHARP_){
return [cljs.core.str(figwheel.client.heads_up.escape.call(null,new cljs.core.Keyword(null,"class","class",-2030961996).cljs$core$IFn$_invoke$arity$1(p1__37940_SHARP_))),cljs.core.str(": "),cljs.core.str(figwheel.client.heads_up.escape.call(null,new cljs.core.Keyword(null,"message","message",-406056002).cljs$core$IFn$_invoke$arity$1(p1__37940_SHARP_)))].join('');
});})(last_message,map__37944,map__37944__$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, [[cljs.core.str("<div style=\"color: #AD4F4F; padding-top: 3px;\">"),cljs.core.str(figwheel.client.heads_up.escape.call(null,last_message)),cljs.core.str("</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__37946){
var map__37949 = p__37946;
var map__37949__$1 = ((((!((map__37949 == null)))?((((map__37949.cljs$lang$protocol_mask$partition0$ & (64))) || (map__37949.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__37949):map__37949);
var file = cljs.core.get.call(null,map__37949__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
var line = cljs.core.get.call(null,map__37949__$1,new cljs.core.Keyword(null,"line","line",212345235));
var column = cljs.core.get.call(null,map__37949__$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(file)].join(''),new cljs.core.Keyword(null,"file-line","file-line",-1228823138),[cljs.core.str(line)].join(''),new cljs.core.Keyword(null,"file-column","file-column",1543934780),[cljs.core.str(column)].join('')], null));
});
figwheel.client.heads_up.display_exception = (function figwheel$client$heads_up$display_exception(exception_data){
var map__37954 = figwheel.client.heads_up.exception__GT_display_data.call(null,exception_data);
var map__37954__$1 = ((((!((map__37954 == null)))?((((map__37954.cljs$lang$protocol_mask$partition0$ & (64))) || (map__37954.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__37954):map__37954);
var head = cljs.core.get.call(null,map__37954__$1,new cljs.core.Keyword(null,"head","head",-771383919));
var sub_head = cljs.core.get.call(null,map__37954__$1,new cljs.core.Keyword(null,"sub-head","sub-head",1930649117));
var messages = cljs.core.get.call(null,map__37954__$1,new cljs.core.Keyword(null,"messages","messages",345434482));
var last_message = cljs.core.get.call(null,map__37954__$1,new cljs.core.Keyword(null,"last-message","last-message",-2087778135));
var file = cljs.core.get.call(null,map__37954__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
var line = cljs.core.get.call(null,map__37954__$1,new cljs.core.Keyword(null,"line","line",212345235));
var column = cljs.core.get.call(null,map__37954__$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),[cljs.core.str(figwheel.client.heads_up.close_link.call(null)),cljs.core.str(figwheel.client.heads_up.heading.call(null,head,sub_head)),cljs.core.str(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__37957){
var map__37960 = p__37957;
var map__37960__$1 = ((((!((map__37960 == null)))?((((map__37960.cljs$lang$protocol_mask$partition0$ & (64))) || (map__37960.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__37960):map__37960);
var warning_data = map__37960__$1;
var file = cljs.core.get.call(null,map__37960__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
var line = cljs.core.get.call(null,map__37960__$1,new cljs.core.Keyword(null,"line","line",212345235));
var column = cljs.core.get.call(null,map__37960__$1,new cljs.core.Keyword(null,"column","column",2078222095));
var message = cljs.core.get.call(null,map__37960__$1,new cljs.core.Keyword(null,"message","message",-406056002));
var error_inline = cljs.core.get.call(null,map__37960__$1,new cljs.core.Keyword(null,"error-inline","error-inline",1073987185));
var last_message = (cljs.core.truth_((function (){var and__25118__auto__ = file;
if(cljs.core.truth_(and__25118__auto__)){
return line;
} else {
return and__25118__auto__;
}
})())?[cljs.core.str("Please see line "),cljs.core.str(line),cljs.core.str(" of file "),cljs.core.str(file)].join(''):(cljs.core.truth_(file)?[cljs.core.str("Please see "),cljs.core.str(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__37960,map__37960__$1,warning_data,file,line,column,message,error_inline){
return (function (p1__37956_SHARP_){
return [cljs.core.str("<div>"),cljs.core.str(p1__37956_SHARP_),cljs.core.str("</div>")].join('');
});})(last_message,map__37960,map__37960__$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)?[cljs.core.str("<span style=\"font-weight:bold;\">"),cljs.core.str(figwheel.client.heads_up.escape.call(null,message)),cljs.core.str("</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, [[cljs.core.str("<div style=\"color: #AD4F4F; padding-top: 3px; margin-bottom: 10px;\">"),cljs.core.str(figwheel.client.heads_up.escape.call(null,last_message)),cljs.core.str("</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),[cljs.core.str(figwheel.client.heads_up.close_link.call(null)),cljs.core.str(figwheel.client.heads_up.heading.call(null,header)),cljs.core.str("<div>"),cljs.core.str(msg),cljs.core.str("</div>")].join(''));
});
figwheel.client.heads_up.display_warning = (function figwheel$client$heads_up$display_warning(warning_data){
var map__37964 = figwheel.client.heads_up.warning_data__GT_display_data.call(null,warning_data);
var map__37964__$1 = ((((!((map__37964 == null)))?((((map__37964.cljs$lang$protocol_mask$partition0$ & (64))) || (map__37964.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__37964):map__37964);
var head = cljs.core.get.call(null,map__37964__$1,new cljs.core.Keyword(null,"head","head",-771383919));
var sub_head = cljs.core.get.call(null,map__37964__$1,new cljs.core.Keyword(null,"sub-head","sub-head",1930649117));
var messages = cljs.core.get.call(null,map__37964__$1,new cljs.core.Keyword(null,"messages","messages",345434482));
var last_message = cljs.core.get.call(null,map__37964__$1,new cljs.core.Keyword(null,"last-message","last-message",-2087778135));
var file = cljs.core.get.call(null,map__37964__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
var line = cljs.core.get.call(null,map__37964__$1,new cljs.core.Keyword(null,"line","line",212345235));
var column = cljs.core.get.call(null,map__37964__$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),[cljs.core.str(figwheel.client.heads_up.close_link.call(null)),cljs.core.str(figwheel.client.heads_up.heading.call(null,head,sub_head)),cljs.core.str(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__37966){
var map__37970 = p__37966;
var map__37970__$1 = ((((!((map__37970 == null)))?((((map__37970.cljs$lang$protocol_mask$partition0$ & (64))) || (map__37970.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__37970):map__37970);
var warning_data = map__37970__$1;
var message = cljs.core.get.call(null,map__37970__$1,new cljs.core.Keyword(null,"message","message",-406056002));
var file = cljs.core.get.call(null,map__37970__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
var line = cljs.core.get.call(null,map__37970__$1,new cljs.core.Keyword(null,"line","line",212345235));
var column = cljs.core.get.call(null,map__37970__$1,new cljs.core.Keyword(null,"column","column",2078222095));
var G__37972 = message;
var G__37972__$1 = (cljs.core.truth_(line)?[cljs.core.str(G__37972),cljs.core.str(" at line "),cljs.core.str(line)].join(''):G__37972);
var G__37972__$2 = (cljs.core.truth_((function (){var and__25118__auto__ = line;
if(cljs.core.truth_(and__25118__auto__)){
return column;
} else {
return and__25118__auto__;
}
})())?[cljs.core.str(G__37972__$1),cljs.core.str(", column "),cljs.core.str(column)].join(''):G__37972__$1);
if(cljs.core.truth_(file)){
return [cljs.core.str(G__37972__$2),cljs.core.str(" in file "),cljs.core.str(file)].join('');
} else {
return G__37972__$2;
}
});
figwheel.client.heads_up.append_warning_message = (function figwheel$client$heads_up$append_warning_message(p__37973){
var map__37978 = p__37973;
var map__37978__$1 = ((((!((map__37978 == null)))?((((map__37978.cljs$lang$protocol_mask$partition0$ & (64))) || (map__37978.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__37978):map__37978);
var warning_data = map__37978__$1;
var message = cljs.core.get.call(null,map__37978__$1,new cljs.core.Keyword(null,"message","message",-406056002));
var file = cljs.core.get.call(null,map__37978__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
var line = cljs.core.get.call(null,map__37978__$1,new cljs.core.Keyword(null,"line","line",212345235));
var column = cljs.core.get.call(null,map__37978__$1,new cljs.core.Keyword(null,"column","column",2078222095));
if(cljs.core.truth_(message)){
var map__37980 = figwheel.client.heads_up.ensure_container.call(null);
var map__37980__$1 = ((((!((map__37980 == null)))?((((map__37980.cljs$lang$protocol_mask$partition0$ & (64))) || (map__37980.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__37980):map__37980);
var content_area_el = cljs.core.get.call(null,map__37980__$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__4657__auto__ = goog.dom.getLastElementChild(content_area_el);
if(cljs.core.truth_(temp__4657__auto__)){
var last_child = temp__4657__auto__;
var temp__4655__auto__ = goog.dom.dataset.get(last_child,"figwheel_count");
if(cljs.core.truth_(temp__4655__auto__)){
var message_count = temp__4655__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(message_count__$1),cljs.core.str(" 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__28364__auto__ = cljs.core.async.chan.call(null,(1));
cljs.core.async.impl.dispatch.run.call(null,((function (c__28364__auto__){
return (function (){
var f__28365__auto__ = (function (){var switch__28252__auto__ = ((function (c__28364__auto__){
return (function (state_38028){
var state_val_38029 = (state_38028[(1)]);
if((state_val_38029 === (1))){
var inst_38011 = (state_38028[(7)]);
var inst_38011__$1 = figwheel.client.heads_up.ensure_container.call(null);
var inst_38012 = [new cljs.core.Keyword(null,"opacity","opacity",397153780)];
var inst_38013 = ["0.0"];
var inst_38014 = cljs.core.PersistentHashMap.fromArrays(inst_38012,inst_38013);
var inst_38015 = figwheel.client.heads_up.set_style_BANG_.call(null,inst_38011__$1,inst_38014);
var inst_38016 = cljs.core.async.timeout.call(null,(300));
var state_38028__$1 = (function (){var statearr_38030 = state_38028;
(statearr_38030[(8)] = inst_38015);
(statearr_38030[(7)] = inst_38011__$1);
return statearr_38030;
})();
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_38028__$1,(2),inst_38016);
} else {
if((state_val_38029 === (2))){
var inst_38011 = (state_38028[(7)]);
var inst_38018 = (state_38028[(2)]);
var inst_38019 = [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_38020 = ["auto","0px","0px","0px 10px 0px 70px","0px","transparent"];
var inst_38021 = cljs.core.PersistentHashMap.fromArrays(inst_38019,inst_38020);
var inst_38022 = figwheel.client.heads_up.set_style_BANG_.call(null,inst_38011,inst_38021);
var inst_38023 = cljs.core.async.timeout.call(null,(200));
var state_38028__$1 = (function (){var statearr_38031 = state_38028;
(statearr_38031[(9)] = inst_38018);
(statearr_38031[(10)] = inst_38022);
return statearr_38031;
})();
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_38028__$1,(3),inst_38023);
} else {
if((state_val_38029 === (3))){
var inst_38011 = (state_38028[(7)]);
var inst_38025 = (state_38028[(2)]);
var inst_38026 = figwheel.client.heads_up.set_content_BANG_.call(null,inst_38011,"");
var state_38028__$1 = (function (){var statearr_38032 = state_38028;
(statearr_38032[(11)] = inst_38025);
return statearr_38032;
})();
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_38028__$1,inst_38026);
} else {
return null;
}
}
}
});})(c__28364__auto__))
;
return ((function (switch__28252__auto__,c__28364__auto__){
return (function() {
var figwheel$client$heads_up$clear_$_state_machine__28253__auto__ = null;
var figwheel$client$heads_up$clear_$_state_machine__28253__auto____0 = (function (){
var statearr_38036 = [null,null,null,null,null,null,null,null,null,null,null,null];
(statearr_38036[(0)] = figwheel$client$heads_up$clear_$_state_machine__28253__auto__);
(statearr_38036[(1)] = (1));
return statearr_38036;
});
var figwheel$client$heads_up$clear_$_state_machine__28253__auto____1 = (function (state_38028){
while(true){
var ret_value__28254__auto__ = (function (){try{while(true){
var result__28255__auto__ = switch__28252__auto__.call(null,state_38028);
if(cljs.core.keyword_identical_QMARK_.call(null,result__28255__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
continue;
} else {
return result__28255__auto__;
}
break;
}
}catch (e38037){if((e38037 instanceof Object)){
var ex__28256__auto__ = e38037;
var statearr_38038_38040 = state_38028;
(statearr_38038_38040[(5)] = ex__28256__auto__);
cljs.core.async.impl.ioc_helpers.process_exception.call(null,state_38028);
return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
throw e38037;
}
}})();
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__28254__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
var G__38041 = state_38028;
state_38028 = G__38041;
continue;
} else {
return ret_value__28254__auto__;
}
break;
}
});
figwheel$client$heads_up$clear_$_state_machine__28253__auto__ = function(state_38028){
switch(arguments.length){
case 0:
return figwheel$client$heads_up$clear_$_state_machine__28253__auto____0.call(this);
case 1:
return figwheel$client$heads_up$clear_$_state_machine__28253__auto____1.call(this,state_38028);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
figwheel$client$heads_up$clear_$_state_machine__28253__auto__.cljs$core$IFn$_invoke$arity$0 = figwheel$client$heads_up$clear_$_state_machine__28253__auto____0;
figwheel$client$heads_up$clear_$_state_machine__28253__auto__.cljs$core$IFn$_invoke$arity$1 = figwheel$client$heads_up$clear_$_state_machine__28253__auto____1;
return figwheel$client$heads_up$clear_$_state_machine__28253__auto__;
})()
;})(switch__28252__auto__,c__28364__auto__))
})();
var state__28366__auto__ = (function (){var statearr_38039 = f__28365__auto__.call(null);
(statearr_38039[cljs.core.async.impl.ioc_helpers.USER_START_IDX] = c__28364__auto__);
return statearr_38039;
})();
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__28366__auto__);
});})(c__28364__auto__))
);
return c__28364__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__28364__auto__ = cljs.core.async.chan.call(null,(1));
cljs.core.async.impl.dispatch.run.call(null,((function (c__28364__auto__){
return (function (){
var f__28365__auto__ = (function (){var switch__28252__auto__ = ((function (c__28364__auto__){
return (function (state_38073){
var state_val_38074 = (state_38073[(1)]);
if((state_val_38074 === (1))){
var inst_38063 = figwheel.client.heads_up.display_loaded_start.call(null);
var state_38073__$1 = state_38073;
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_38073__$1,(2),inst_38063);
} else {
if((state_val_38074 === (2))){
var inst_38065 = (state_38073[(2)]);
var inst_38066 = cljs.core.async.timeout.call(null,(400));
var state_38073__$1 = (function (){var statearr_38075 = state_38073;
(statearr_38075[(7)] = inst_38065);
return statearr_38075;
})();
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_38073__$1,(3),inst_38066);
} else {
if((state_val_38074 === (3))){
var inst_38068 = (state_38073[(2)]);
var inst_38069 = figwheel.client.heads_up.clear.call(null);
var state_38073__$1 = (function (){var statearr_38076 = state_38073;
(statearr_38076[(8)] = inst_38068);
return statearr_38076;
})();
return cljs.core.async.impl.ioc_helpers.take_BANG_.call(null,state_38073__$1,(4),inst_38069);
} else {
if((state_val_38074 === (4))){
var inst_38071 = (state_38073[(2)]);
var state_38073__$1 = state_38073;
return cljs.core.async.impl.ioc_helpers.return_chan.call(null,state_38073__$1,inst_38071);
} else {
return null;
}
}
}
}
});})(c__28364__auto__))
;
return ((function (switch__28252__auto__,c__28364__auto__){
return (function() {
var figwheel$client$heads_up$flash_loaded_$_state_machine__28253__auto__ = null;
var figwheel$client$heads_up$flash_loaded_$_state_machine__28253__auto____0 = (function (){
var statearr_38080 = [null,null,null,null,null,null,null,null,null];
(statearr_38080[(0)] = figwheel$client$heads_up$flash_loaded_$_state_machine__28253__auto__);
(statearr_38080[(1)] = (1));
return statearr_38080;
});
var figwheel$client$heads_up$flash_loaded_$_state_machine__28253__auto____1 = (function (state_38073){
while(true){
var ret_value__28254__auto__ = (function (){try{while(true){
var result__28255__auto__ = switch__28252__auto__.call(null,state_38073);
if(cljs.core.keyword_identical_QMARK_.call(null,result__28255__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
continue;
} else {
return result__28255__auto__;
}
break;
}
}catch (e38081){if((e38081 instanceof Object)){
var ex__28256__auto__ = e38081;
var statearr_38082_38084 = state_38073;
(statearr_38082_38084[(5)] = ex__28256__auto__);
cljs.core.async.impl.ioc_helpers.process_exception.call(null,state_38073);
return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
throw e38081;
}
}})();
if(cljs.core.keyword_identical_QMARK_.call(null,ret_value__28254__auto__,new cljs.core.Keyword(null,"recur","recur",-437573268))){
var G__38085 = state_38073;
state_38073 = G__38085;
continue;
} else {
return ret_value__28254__auto__;
}
break;
}
});
figwheel$client$heads_up$flash_loaded_$_state_machine__28253__auto__ = function(state_38073){
switch(arguments.length){
case 0:
return figwheel$client$heads_up$flash_loaded_$_state_machine__28253__auto____0.call(this);
case 1:
return figwheel$client$heads_up$flash_loaded_$_state_machine__28253__auto____1.call(this,state_38073);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
figwheel$client$heads_up$flash_loaded_$_state_machine__28253__auto__.cljs$core$IFn$_invoke$arity$0 = figwheel$client$heads_up$flash_loaded_$_state_machine__28253__auto____0;
figwheel$client$heads_up$flash_loaded_$_state_machine__28253__auto__.cljs$core$IFn$_invoke$arity$1 = figwheel$client$heads_up$flash_loaded_$_state_machine__28253__auto____1;
return figwheel$client$heads_up$flash_loaded_$_state_machine__28253__auto__;
})()
;})(switch__28252__auto__,c__28364__auto__))
})();
var state__28366__auto__ = (function (){var statearr_38083 = f__28365__auto__.call(null);
(statearr_38083[cljs.core.async.impl.ioc_helpers.USER_START_IDX] = c__28364__auto__);
return statearr_38083;
})();
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state__28366__auto__);
});})(c__28364__auto__))
);
return c__28364__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__4657__auto__ = document.getElementById("figwheelFailScreen");
if(cljs.core.truth_(temp__4657__auto__)){
var el = temp__4657__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": [cljs.core.str("background-color: rgba(24, 26, 38, 0.95);"),cljs.core.str("position: absolute;"),cljs.core.str("z-index: 9000;"),cljs.core.str("width: 100vw;"),cljs.core.str("height: 100vh;"),cljs.core.str("top: 0px; left: 0px;"),cljs.core.str("font-family: monospace")].join('')}),goog.dom.createDom("div",({"class": "message", "style": [cljs.core.str("color: #FFF5DB;"),cljs.core.str("width: 100vw;"),cljs.core.str("margin: auto;"),cljs.core.str("margin-top: 10px;"),cljs.core.str("text-align: center; "),cljs.core.str("padding: 2px 0px;"),cljs.core.str("font-size: 13px;"),cljs.core.str("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=1603199206271

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,89 @@
(ns figwheel.client.socket
(:require
[figwheel.client.utils :as utils]
[cljs.reader :refer [read-string]]))
(defn get-websocket-imp []
(cond
(utils/html-env?) (aget js/window "WebSocket")
(utils/node-env?) (try (js/require "ws")
(catch js/Error e
nil))
(utils/worker-env?) (aget 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 {}, :use-macros {}, :excludes #{}, :name figwheel.client.socket, :imports nil, :requires {utils figwheel.client.utils, figwheel.client.utils figwheel.client.utils, cljs.reader cljs.reader}, :uses {read-string cljs.reader}, :defs {get-websocket-imp {:protocol-inline nil, :meta {:file "/Users/simon/workspace/swinging-needle-meter/docs/js/compiled/out/figwheel/client/socket.cljs", :line 6, :column 7, :end-line 6, :end-column 24, :arglists (quote ([]))}, :name figwheel.client.socket/get-websocket-imp, :variadic false, :file "docs/js/compiled/out/figwheel/client/socket.cljs", :end-column 24, :method-params ([]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 6, :end-line 6, :max-fixed-arity 0, :fn-var true, :arglists (quote ([]))}, message-history-atom {:name figwheel.client.socket/message-history-atom, :file "docs/js/compiled/out/figwheel/client/socket.cljs", :line 36, :column 1, :end-line 36, :end-column 30, :meta {:file "/Users/simon/workspace/swinging-needle-meter/docs/js/compiled/out/figwheel/client/socket.cljs", :line 36, :column 10, :end-line 36, :end-column 30}}, socket-atom {:name figwheel.client.socket/socket-atom, :file "docs/js/compiled/out/figwheel/client/socket.cljs", :line 38, :column 1, :end-line 38, :end-column 21, :meta {:file "/Users/simon/workspace/swinging-needle-meter/docs/js/compiled/out/figwheel/client/socket.cljs", :line 38, :column 10, :end-line 38, :end-column 21}}, send! {:protocol-inline nil, :meta {:file "/Users/simon/workspace/swinging-needle-meter/docs/js/compiled/out/figwheel/client/socket.cljs", :line 40, :column 7, :end-line 40, :end-column 12, :arglists (quote ([msg])), :doc "Send a end message to the server."}, :name figwheel.client.socket/send!, :variadic false, :file "docs/js/compiled/out/figwheel/client/socket.cljs", :end-column 12, :method-params ([msg]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 40, :end-line 40, :max-fixed-arity 1, :fn-var true, :arglists (quote ([msg])), :doc "Send a end message to the server."}, close! {:protocol-inline nil, :meta {:file "/Users/simon/workspace/swinging-needle-meter/docs/js/compiled/out/figwheel/client/socket.cljs", :line 46, :column 7, :end-line 46, :end-column 13, :arglists (quote ([]))}, :name figwheel.client.socket/close!, :variadic false, :file "docs/js/compiled/out/figwheel/client/socket.cljs", :end-column 13, :method-params ([]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 46, :end-line 46, :max-fixed-arity 0, :fn-var true, :arglists (quote ([]))}, handle-incoming-message {:protocol-inline nil, :meta {:file "/Users/simon/workspace/swinging-needle-meter/docs/js/compiled/out/figwheel/client/socket.cljs", :line 50, :column 7, :end-line 50, :end-column 30, :arglists (quote ([msg]))}, :name figwheel.client.socket/handle-incoming-message, :variadic false, :file "docs/js/compiled/out/figwheel/client/socket.cljs", :end-column 30, :method-params ([msg]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 50, :end-line 50, :max-fixed-arity 1, :fn-var true, :arglists (quote ([msg]))}, open {:protocol-inline nil, :meta {:file "/Users/simon/workspace/swinging-needle-meter/docs/js/compiled/out/figwheel/client/socket.cljs", :line 59, :column 7, :end-line 59, :end-column 11, :arglists (quote ([{:keys [retry-count retried-count websocket-url build-id], :as opts}]))}, :name figwheel.client.socket/open, :variadic false, :file "docs/js/compiled/out/figwheel/client/socket.cljs", :end-column 11, :method-params ([p__37771]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 59, :end-line 59, :max-fixed-arity 1, :fn-var true, :arglists (quote ([{:keys [retry-count retried-count websocket-url build-id], :as opts}]))}}, :require-macros nil, :cljs.analyzer/constants {:seen #{:ping :retried-count :else :ns handle-incoming-message :name figwheel.client.socket/handle-incoming-message :file :end-column :debug :column :build-id :line msg :websocket-url :end-line :msg-name :arglists figwheel.client.socket :doc :retry-count :test}, :order [:else :msg-name :ping :retry-count :retried-count :websocket-url :build-id :debug figwheel.client.socket/handle-incoming-message :ns :name :file :end-column :column :line :end-line :arglists :doc :test figwheel.client.socket handle-incoming-message msg]}, :doc nil}

View file

@ -0,0 +1,150 @@
// Compiled by ClojureScript 1.9.229 {}
goog.provide('figwheel.client.socket');
goog.require('cljs.core');
goog.require('figwheel.client.utils');
goog.require('cljs.reader');
figwheel.client.socket.get_websocket_imp = (function figwheel$client$socket$get_websocket_imp(){
if(cljs.core.truth_(figwheel.client.utils.html_env_QMARK_.call(null))){
return (window["WebSocket"]);
} else {
if(cljs.core.truth_(figwheel.client.utils.node_env_QMARK_.call(null))){
try{return require("ws");
}catch (e37770){if((e37770 instanceof Error)){
var e = e37770;
return null;
} else {
throw e37770;
}
}} else {
if(cljs.core.truth_(figwheel.client.utils.worker_env_QMARK_.call(null))){
return (self["WebSocket"]);
} else {
return null;
}
}
}
});
if(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.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__25118__auto__ = cljs.core.map_QMARK_.call(null,msg);
if(and__25118__auto__){
var and__25118__auto____$1 = new cljs.core.Keyword(null,"msg-name","msg-name",-353709863).cljs$core$IFn$_invoke$arity$1(msg);
if(cljs.core.truth_(and__25118__auto____$1)){
var and__25118__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__25118__auto____$2){
return cljs.core.swap_BANG_.call(null,figwheel.client.socket.message_history_atom,cljs.core.conj,msg);
} else {
return and__25118__auto____$2;
}
} else {
return and__25118__auto____$1;
}
} else {
return and__25118__auto__;
}
});
figwheel.client.socket.open = (function figwheel$client$socket$open(p__37771){
var map__37774 = p__37771;
var map__37774__$1 = ((((!((map__37774 == null)))?((((map__37774.cljs$lang$protocol_mask$partition0$ & (64))) || (map__37774.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__37774):map__37774);
var opts = map__37774__$1;
var retry_count = cljs.core.get.call(null,map__37774__$1,new cljs.core.Keyword(null,"retry-count","retry-count",1936122875));
var retried_count = cljs.core.get.call(null,map__37774__$1,new cljs.core.Keyword(null,"retried-count","retried-count",-2127867357));
var websocket_url = cljs.core.get.call(null,map__37774__$1,new cljs.core.Keyword(null,"websocket-url","websocket-url",-490444938));
var build_id = cljs.core.get.call(null,map__37774__$1,new cljs.core.Keyword(null,"build-id","build-id",1642831089));
var temp__4655__auto__ = figwheel.client.socket.get_websocket_imp.call(null);
if(cljs.core.truth_(temp__4655__auto__)){
var WebSocket = temp__4655__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(websocket_url),cljs.core.str((cljs.core.truth_(build_id)?[cljs.core.str("/"),cljs.core.str(build_id)].join(''):""))].join('');
var socket = (new WebSocket(url));
socket.onmessage = ((function (url,socket,WebSocket,temp__4655__auto__,map__37774,map__37774__$1,opts,retry_count,retried_count,websocket_url,build_id){
return (function (msg_str){
var temp__4657__auto__ = cljs.reader.read_string.call(null,msg_str.data);
if(cljs.core.truth_(temp__4657__auto__)){
var msg = temp__4657__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),"docs/js/compiled/out/figwheel/client/socket.cljs",30,1,50,50,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__4655__auto__,map__37774,map__37774__$1,opts,retry_count,retried_count,websocket_url,build_id))
;
socket.onopen = ((function (url,socket,WebSocket,temp__4655__auto__,map__37774,map__37774__$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(cljs.core.truth_(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__4655__auto__,map__37774,map__37774__$1,opts,retry_count,retried_count,websocket_url,build_id))
;
socket.onclose = ((function (url,socket,WebSocket,temp__4655__auto__,map__37774,map__37774__$1,opts,retry_count,retried_count,websocket_url,build_id){
return (function (x){
var retried_count__$1 = (function (){var or__25130__auto__ = retried_count;
if(cljs.core.truth_(or__25130__auto__)){
return or__25130__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__4655__auto__,map__37774,map__37774__$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__4655__auto__,map__37774,map__37774__$1,opts,retry_count,retried_count,websocket_url,build_id))
,(function (){var x__25468__auto__ = (10000);
var y__25469__auto__ = ((2000) + ((500) * retried_count__$1));
return ((x__25468__auto__ < y__25469__auto__) ? x__25468__auto__ : y__25469__auto__);
})());
} else {
return null;
}
});})(url,socket,WebSocket,temp__4655__auto__,map__37774,map__37774__$1,opts,retry_count,retried_count,websocket_url,build_id))
;
socket.onerror = ((function (url,socket,WebSocket,temp__4655__auto__,map__37774,map__37774__$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__4655__auto__,map__37774,map__37774__$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),(cljs.core.truth_(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=1603199205905

View file

@ -0,0 +1 @@
{"version":3,"file":"\/Users\/simon\/workspace\/swinging-needle-meter\/docs\/js\/compiled\/out\/figwheel\/client\/socket.js","sources":["socket.cljs?rel=1603199205906"],"lineCount":150,"mappings":";AAAA;;;;AAKA,2CAAA,3CAAMA;AAAN,AACE,oBACE,AAACC;AAAiB,eAAA,PAAMC;;AAD1B,oBAEE,AAACC;AAAiB,IAAA,AAAK,eAAA,RAACE;gBAAN,GAAA,CAAAD,kBACYE;AADZ,QAAAF,JACqBG;AADrB,AAAA;;AAAA,AAAA,MAAAH;;;;AAFpB,oBAKE,AAACI;AAAmB,aAAA,LAAMC;;AAL5B,AAAA;;;;;;AA6BF,GAAA,OAASC;AAAT;AAAA,AAAA,AAASA,8CAAqB,AAACC,yBA60E3B,AAAA0C;;AA30EJ,GAAA,OAASzC;AAAT;AAAA,AAAA,AAASA,qCAAY,yBAAA,zBAACD;;AAEtB;;;oCAAA,pCAAME,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,qBAAK,AAACC,+BAAKR;AAAX,AAAA,GAAAO;AAAA,IAAAA,yBACK,AAAA,2FAAWP;AADhB,AAAA,oBAAAO;AAAA,IAAAA,yBAGK,4HAAA,5HAACE,4BAAK,AAAA,2FAAWT;AAHtB,AAAA,GAAAO;AAIK,OAACG,+BAAMd,4CACAe,eAAKX;;AALjBO;;;AAAAA;;;AAAAA;;;AAOF,8BAAA,sCAAAK,pEAAMK;AAAN,AAAA,IAAAJ,aAAAD;IAAAC,iBAAA,EAAA,EAAA,EAAA,CAAAA,cAAA,QAAA,EAAA,CAAA,CAAA,AAAAA,iDAAA,WAAA,AAAAA,6BAAA,KAAA,OAAA,QAAA,AAAAC,0BAAAC,mBAAAF,YAAAA;WAAAA,PAA0ES;kBAA1E,AAAAN,wBAAAH,eAAA,rDAAoBK;oBAApB,AAAAF,wBAAAH,eAAA,vDAAgCM;oBAAhC,AAAAH,wBAAAH,eAAA,vDAA8CO;eAA9C,AAAAJ,wBAAAH,eAAA,lDAA4DQ;AAA5D,AACE,IAAAE,qBAAmB,AAACrC;AAApB,AAAA,oBAAAqC;AAAA,gBAAAA,ZAASC;AAAT,AACE,AACE,oCAAA,wDAAA,5FAACC;;AACD,IAAMC,MAAI,eAAKN,6BAAc,kFAAA,hEAAIC,UAAS,eAAA,mBAASA;IAC7CM,SAAO,KAAAH,UAAYE;AADzB,AAEE,AAAM,AAAaC,mBAAQ;kBAAKC;AAAL,AACE,IAAAC,qBACW,AAACC,kCAAY,AAAQF;AADhC,AAAA,oBAAAC;AAAA,AAAA,UAAAA,NAAW7B;AAAX,AAEE,OAAA,qFAAA,2IAAA,wCAAA,gDAAA,qDAAA,sDAAA,iEAAA,yDAAA,oDAAA,6DAAA,6DAAA,mDAAA,sDAAA,8FAAA,gGAAA,mDAAA,GAAA,EAAA,GAAA,GAAA,eAAA,mFAAA,+DAAA,KAAA,kEAAA,AAAA,8DAAA,9GAAGK,gDAAAA,iFAAwBL;;AAF7B;;;;;AAG7B,AAAM,AAAU2B,gBAAS;kBAAKI;AAAL,AACE,AAACC,gCAAOlC,mCAAY6B;;AACpB,oBAAM,AAACxC;AAAP,AACE,wBAAA,xBAAmBC,uCAAyBe;;AAD9C;;AAEA,2CAAA,wDAAA,5FAACsB;;;;AAC5B,AAAM,AAAWE,iBAAQ;kBAAKI;AAAL,AACE,IAAMZ,oBAAc,iBAAAc,oBAAId;AAAJ,AAAA,oBAAAc;AAAAA;;AAAA;;;AAApB,AACE,0CAAA,1CAAC3B;;AACD,GAAM,CAAGY,cAAYC;AAArB,AACE,OAACe,WACA;;AAAA,AACE,OAACC,sCACA,+BAAA,\/BAACC,0BAAMd,6EAAoB,qBAAA,pBAAKH;;CAEnC,iBAAAkB,mBAAA;IAAAC,mBAAW,CAAA,SAAQ,CAAA,QAAOnB;AAA1B,AAAA,SAAAkB,mBAAAC,oBAAAD,mBAAAC;;;AANH;;;;;AAO7B,AAAM,AAAWX,iBAAQ;kBAAKI;AAAL,AAAQ,iDAAA,1CAACzB;;;;AAClCqB;;AACJ,2CAAA,pCAACF,4FACU,oEAAA,6FAAA,\/IAAI,AAACpC","names":["figwheel.client.socket\/get-websocket-imp","figwheel.client.utils\/html-env?","js\/window","figwheel.client.utils\/node-env?","e37770","js\/require","js\/Error","e","figwheel.client.utils\/worker-env?","js\/self","figwheel.client.socket\/message-history-atom","cljs.core\/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__25118__auto__","cljs.core\/map?","cljs.core\/not=","cljs.core\/swap!","cljs.core\/conj","p__37771","map__37774","cljs.core\/apply","cljs.core\/hash-map","cljs.core\/get","figwheel.client.socket\/open","retry-count","retried-count","websocket-url","build-id","opts","temp__4655__auto__","WebSocket","figwheel.client.utils\/log","url","socket","msg-str","temp__4657__auto__","cljs.reader\/read-string","x","cljs.core\/reset!","or__25130__auto__","js\/setTimeout","open","cljs.core\/assoc","x__25468__auto__","y__25469__auto__","cljs.core\/List"]}

View file

@ -0,0 +1,135 @@
(ns ^:figwheel-no-load figwheel.client.utils
(:require [clojure.string :as string]
[goog.string :as gstring]
[cljs.reader :refer [read-string]]
[cljs.pprint :refer [pprint]]
[goog.userAgent.product :as product])
(:import [goog]
[goog.async Deferred]
[goog.string StringBuffer]))
;; 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 node-env? [] (not (nil? goog/nodeGlobalRequire)))
(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
(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?) (aget 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-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 (exists? js/localStorage)
(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]
(cond
(contains? @local-persistent-config ky)
(get @local-persistent-config ky)
(and (exists? js/localStorage) (.getItem js/localStorage (name ky)))
(let [v (read-string (.getItem js/localStorage (name ky)))]
(persistent-config-set! ky v)
v)
:else not-found))
([ky]
(persistent-config-get ky nil)))

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,302 @@
// Compiled by ClojureScript 1.9.229 {}
goog.provide('figwheel.client.utils');
goog.require('cljs.core');
goog.require('goog.string');
goog.require('goog.userAgent.product');
goog.require('goog.async.Deferred');
goog.require('cljs.pprint');
goog.require('goog.string.StringBuffer');
goog.require('clojure.string');
goog.require('cljs.reader');
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.node_env_QMARK_ = (function figwheel$client$utils$node_env_QMARK_(){
return !((goog.nodeGlobalRequire == null));
});
figwheel.client.utils.worker_env_QMARK_ = (function figwheel$client$utils$worker_env_QMARK_(){
return ((goog.global.document == null)) && (typeof self !== 'undefined') && (typeof self.importScripts !== 'undefined');
});
figwheel.client.utils.host_env_QMARK_ = (function figwheel$client$utils$host_env_QMARK_(){
if(cljs.core.truth_(figwheel.client.utils.node_env_QMARK_.call(null))){
return new cljs.core.Keyword(null,"node","node",581201198);
} else {
if(cljs.core.truth_(figwheel.client.utils.html_env_QMARK_.call(null))){
return new cljs.core.Keyword(null,"html","html",-998796897);
} else {
if(cljs.core.truth_(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 obj35264 = {"detail":data};
return obj35264;
})()));
} 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__25118__auto__ = figwheel.client.utils.html_env_QMARK_.call(null);
if(cljs.core.truth_(and__25118__auto__)){
var and__25118__auto____$1 = (window["CustomEvent"]);
if(cljs.core.truth_(and__25118__auto____$1)){
return typeof document !== 'undefined';
} else {
return and__25118__auto____$1;
}
} else {
return and__25118__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(cljs.core.truth_(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 args35269 = [];
var len__26205__auto___35275 = arguments.length;
var i__26206__auto___35276 = (0);
while(true){
if((i__26206__auto___35276 < len__26205__auto___35275)){
args35269.push((arguments[i__26206__auto___35276]));
var G__35277 = (i__26206__auto___35276 + (1));
i__26206__auto___35276 = G__35277;
continue;
} else {
}
break;
}
var G__35271 = args35269.length;
switch (G__35271) {
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([cljs.core.str("Invalid arity: "),cljs.core.str(args35269.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__35272 = cljs.core._EQ_;
var expr__35273 = (cljs.core.truth_(figwheel.client.utils.html_env_QMARK_.call(null))?level:new cljs.core.Keyword(null,"info","info",-317069002));
if(cljs.core.truth_(pred__35272.call(null,new cljs.core.Keyword(null,"warn","warn",-436710552),expr__35273))){
return ((function (pred__35272,expr__35273){
return (function (p1__35265_SHARP_){
return console.warn(p1__35265_SHARP_);
});
;})(pred__35272,expr__35273))
} else {
if(cljs.core.truth_(pred__35272.call(null,new cljs.core.Keyword(null,"debug","debug",-1608172596),expr__35273))){
return ((function (pred__35272,expr__35273){
return (function (p1__35266_SHARP_){
return console.debug(p1__35266_SHARP_);
});
;})(pred__35272,expr__35273))
} else {
if(cljs.core.truth_(pred__35272.call(null,new cljs.core.Keyword(null,"error","error",-978969032),expr__35273))){
return ((function (pred__35272,expr__35273){
return (function (p1__35267_SHARP_){
return console.error(p1__35267_SHARP_);
});
;})(pred__35272,expr__35273))
} else {
return ((function (pred__35272,expr__35273){
return (function (p1__35268_SHARP_){
return console.log(p1__35268_SHARP_);
});
;})(pred__35272,expr__35273))
}
}
}
})();
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__35279){
var map__35282 = p__35279;
var map__35282__$1 = ((((!((map__35282 == null)))?((((map__35282.cljs$lang$protocol_mask$partition0$ & (64))) || (map__35282.cljs$core$ISeq$))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__35282):map__35282);
var opts = map__35282__$1;
var eval_fn = cljs.core.get.call(null,map__35282__$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(sb)].join(''));
});
/**
* 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__35284_SHARP_){
return new_def.callback(p1__35284_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.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'){
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__35285){
var vec__35286 = p__35285;
var ky = cljs.core.nth.call(null,vec__35286,(0),null);
var v = cljs.core.nth.call(null,vec__35286,(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 args35289 = [];
var len__26205__auto___35292 = arguments.length;
var i__26206__auto___35293 = (0);
while(true){
if((i__26206__auto___35293 < len__26205__auto___35292)){
args35289.push((arguments[i__26206__auto___35293]));
var G__35294 = (i__26206__auto___35293 + (1));
i__26206__auto___35293 = G__35294;
continue;
} else {
}
break;
}
var G__35291 = args35289.length;
switch (G__35291) {
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([cljs.core.str("Invalid arity: "),cljs.core.str(args35289.length)].join('')));
}
});
figwheel.client.utils.persistent_config_get.cljs$core$IFn$_invoke$arity$2 = (function (ky,not_found){
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__25118__auto__ = typeof localStorage !== 'undefined';
if(and__25118__auto__){
return localStorage.getItem(cljs.core.name.call(null,ky));
} else {
return and__25118__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;
}
}
});
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=1603199202496

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,3 @@
(ns figwheel.connect.dev (:require [swinging-needle-meter.core] [figwheel.client] [figwheel.client.utils]))
(figwheel.client/start {:on-jsload (fn [& x] (if js/swinging-needle-meter.core.mount-root (apply js/swinging-needle-meter.core.mount-root x) (figwheel.client.utils/log :debug "Figwheel: :on-jsload hook 'swinging-needle-meter.core/mount-root' is missing"))), :build-id "dev", :websocket-url "ws://localhost:3449/figwheel-ws"})

View file

@ -0,0 +1 @@
{:rename-macros {}, :renames {}, :use-macros {}, :excludes #{}, :name figwheel.connect.dev, :imports nil, :requires {swinging-needle-meter.core swinging-needle-meter.core, figwheel.client figwheel.client, figwheel.client.utils figwheel.client.utils}, :uses nil, :require-macros nil, :cljs.analyzer/constants {:seen #{:on-jsload :debug :build-id :websocket-url}, :order [:on-jsload :build-id :websocket-url :debug]}, :doc nil}

View file

@ -0,0 +1,33 @@
// Compiled by ClojureScript 1.9.229 {}
goog.provide('figwheel.connect.dev');
goog.require('cljs.core');
goog.require('swinging_needle_meter.core');
goog.require('figwheel.client');
goog.require('figwheel.client.utils');
figwheel.client.start.call(null,new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"on-jsload","on-jsload",-395756602),(function() {
var G__27939__delegate = function (x){
if(cljs.core.truth_(swinging_needle_meter.core.mount_root)){
return cljs.core.apply.call(null,swinging_needle_meter.core.mount_root,x);
} else {
return figwheel.client.utils.log.call(null,new cljs.core.Keyword(null,"debug","debug",-1608172596),"Figwheel: :on-jsload hook 'swinging-needle-meter.core/mount-root' is missing");
}
};
var G__27939 = function (var_args){
var x = null;
if (arguments.length > 0) {
var G__27940__i = 0, G__27940__a = new Array(arguments.length - 0);
while (G__27940__i < G__27940__a.length) {G__27940__a[G__27940__i] = arguments[G__27940__i + 0]; ++G__27940__i;}
x = new cljs.core.IndexedSeq(G__27940__a,0);
}
return G__27939__delegate.call(this,x);};
G__27939.cljs$lang$maxFixedArity = 0;
G__27939.cljs$lang$applyTo = (function (arglist__27941){
var x = cljs.core.seq(arglist__27941);
return G__27939__delegate(x);
});
G__27939.cljs$core$IFn$_invoke$arity$variadic = G__27939__delegate;
return G__27939;
})()
,new cljs.core.Keyword(null,"build-id","build-id",1642831089),"dev",new cljs.core.Keyword(null,"websocket-url","websocket-url",-490444938),"ws://localhost:3449/figwheel-ws"], null));
//# sourceMappingURL=dev.js.map?rel=1603200848820

View file

@ -0,0 +1 @@
{"version":3,"file":"\/Users\/simon\/workspace\/swinging-needle-meter\/resources\/public\/js\/compiled\/out\/figwheel\/connect\/dev.js","sources":["dev.cljs?rel=1603200848820"],"lineCount":33,"mappings":";AAAA;;;;;AACA,gCAAA,2CAAA,3EAACA,0IAAkC;mCAAOC;AAAP,AAAU,oBAAIC;AAAyC,OAACC,0BAAMD,sCAAyCD;;AAAG,2CAAA,wDAAA,5FAACG;;;;IAApGH;;;;EAAAA;;oCAAAA;;;IAAAA;0BAAAA;;;;;CAA1C,6DAAA,MAAA,uEAAA","names":["figwheel.client\/start","x","js\/swinging-needle-meter.core.mount-root","cljs.core\/apply","figwheel.client.utils\/log"]}