Added virtually the whole of the Scittle distribution, as it proves to be

virtually necessary to do development.
This commit is contained in:
Simon Brooke 2025-09-01 12:49:14 +01:00
parent fcb023ecc5
commit 0a200aca94
741 changed files with 174111 additions and 11 deletions

77
bb.edn Normal file
View file

@ -0,0 +1,77 @@
{:deps {io.github.babashka/sci.nrepl
#_{:local/root "../sci.nrepl"}
{:git/sha "2f8a9ed2d39a1b09d2b4d34d95494b56468f4a23"}
io.github.babashka/http-server
{:git/tag "v0.1.14"
:git/sha "4af3c76"}
io.github.scittle/build
{:local/root "build"}}
:tasks
{:requires ([scittle.build :as build]
[babashka.fs :as fs]
[cheshire.core :as json]
[babashka.process :as p :refer [process]])
clean {:doc "Start from clean slate."
:task (do (fs/delete-tree (fs/file "resources" "public" "js"))
(fs/delete-tree ".cpcache")
(fs/delete-tree ".shadow-cljs"))}
shadow:watch {:doc "Development build. Starts webserver and watches for changes."
:task (build/build {:action "watch"
:args *command-line-args*})}
http-server {:doc "Starts http server for serving static files"
:requires ([babashka.http-server :as http])
:task (do (http/serve {:port 1341 :dir "resources/public"})
(println "Serving static assets at http://localhost:1341"))}
browser-nrepl {:doc "Start browser nREPL"
:requires ([sci.nrepl.browser-server :as bp])
:task (bp/start! {})}
-dev {:depends [shadow:watch browser-nrepl http-server]}
dev {:doc "Development build. Starts webserver and watches for changes."
:task (do (run '-dev {:parallel true})
(deref (promise)))}
prod {:doc "Builds production artifacts."
:task (build/build {})
:depends [clean]}
dist {:doc "Prepare dist folder for npm package"
:depends [prod]
:task (do
(fs/delete-tree "dist")
(fs/create-dirs "dist/dev")
(run! (fn [f] (fs/copy f "dist" {:replace-existing true}))
(fs/glob "resources/public/js" "*.{js,js.map}"))
(run! (fn [f] (fs/copy f "dist/dev" {:replace-existing true}))
(fs/glob "resources/public/js/dev" "*.{js,js.map}")))}
bump-version {:doc "Bumps package.json and pushes new git tag"
:task (do (shell "npm version patch")
(shell "git push --atomic origin main"
(str "v" (:version (json/parse-string (slurp "package.json") true)))))}
npm-publish {:doc "Updates NPM ibrary"
:task (do (run 'dist)
(run 'bump-version)
(shell "npm publish"))}
replace-version {:doc "Ported from bash one-liners. Expects two versions.
TODO: port to Clojure.
TODO: skip changelog.md
"
:task
(let [[prev next] *command-line-args*]
(-> (process ["bash" "-c"
(format "rg %s --files-with-matches -g '!/CHANGELOG.md' | xargs sed -i '' 's/%s/%s/g'"
prev prev next)]
{:inherit true})
p/check))}
gh-pages {:doc "Updates Github pages with new release build."
:task (shell "script/release.clj")}}}

1
build/deps.edn Normal file
View file

@ -0,0 +1 @@
{}

View file

@ -0,0 +1,83 @@
(ns scittle.build
"Provides bb tasks for building and releasing scittle"
(:require
[babashka.classpath :as classpath]
[babashka.fs :as fs]
[babashka.tasks :refer [clojure]]
[clojure.edn :as edn]
[clojure.string :as str]))
(defn- feature-files
[]
(filter fs/exists?
(map (fn [d]
(fs/file d "scittle_plugin.edn"))
(classpath/split-classpath (classpath/get-classpath)))))
(defn- read-configs
[files]
(->> files
(mapcat (comp edn/read-string slurp str))))
(defn- build-cmd [cmd scittle-dir]
(let [files (feature-files)
feature-configs (read-configs files)
;; Each ./src/scittle_plugin.edn has a ./deps.edn
feature-dirs (map (comp fs/parent fs/parent) files)
cmd' (if (seq files)
(format "-Sdeps '%s' %s"
{:deps
(merge (into {}
(map (fn [dir]
[(symbol (str (fs/file-name dir) "/deps"))
{:local/root (str dir)}])
feature-dirs))
{'scittle/deps {:local/root scittle-dir}})}
cmd)
cmd)]
(when (seq feature-configs)
(println "Building features:" (str/join ", " (map :name feature-configs)) "..."))
(if (seq feature-configs)
(apply str cmd'
(map (fn [m] (format " --config-merge '%s'" (pr-str (:shadow-config m))))
feature-configs))
cmd')))
(defn- build*
[cmd]
(let [building-outside-scittle? (not (fs/exists? "shadow-cljs.edn"))
scittle-dir (when building-outside-scittle?
(->> (classpath/get-classpath)
classpath/split-classpath
;; Pull out scittle from local/root or git/url
(some #(when (re-find #"(scittle/[0-9a-f]+|scittle)/src" %) %))
fs/parent))]
(when building-outside-scittle?
(fs/copy (fs/file scittle-dir "shadow-cljs.edn") "shadow-cljs.edn"))
(let [cmd (build-cmd cmd (str scittle-dir))]
(println "> clojure" cmd)
(clojure {:extra-env {"SCI_ELIDE_VARS" "true"}} cmd))
(when building-outside-scittle?
(fs/delete "shadow-cljs.edn"))))
(defn build
"Build scittle shadow builds using clojure cmd and commandline args. Features on
classpath are automatically added.
Options:
* :action - compile action, defaults to release, but may also be compile or watch"
[{:keys [action
args] :or {action "release"}}]
(build* (format "-M -m shadow.cljs.devtools.cli --force-spawn %s main %s" action (str/join " " args)))
(when (= "release" action)
(println "Also building dev release build")
(build* (format "-M -m shadow.cljs.devtools.cli --force-spawn %s main %s %s"
action
"--config-merge '{:compiler-options {:optimizations :simple
:pretty-print true
:pseudo-names true}
:output-dir \"resources/public/js/dev\"
:modules {:scittle.cljs-devtools {:entries [scittle.cljs-devtools]
:depends-on #{:scittle}}}}'"
(str/join " " args)))))

30
deps.edn Normal file
View file

@ -0,0 +1,30 @@
{:paths ["src" "resources"]
:deps
{org.clojure/clojure {:mvn/version "1.11.1"}
thheller/shadow-cljs {:mvn/version "3.1.8"}
org.babashka/sci {:git/url "https://github.com/babashka/sci"
:git/sha "756376056b32198d96dd5b272cee8fc483db60df"}
#_{:local/root "../babashka/sci"}
reagent/reagent {:mvn/version "1.1.1"}
no.cjohansen/replicant {:mvn/version "2025.03.27"}
re-frame/re-frame {:mvn/version "1.3.0"}
cljsjs/react {:mvn/version "18.2.0-1"}
cljsjs/react-dom {:mvn/version "18.2.0-1"}
cljsjs/react-dom-server {:mvn/version "18.2.0-1"}
cljs-ajax/cljs-ajax {:mvn/version "0.8.4"}
applied-science/js-interop {:mvn/version "0.4.2"}
funcool/promesa {:mvn/version "11.0.678"}
io.github.babashka/sci.nrepl
#_{:local/root "../sci.nrepl"}
{:git/url "https://github.com/babashka/sci.nrepl"
:git/sha "75f379c685bbd58c3e23f531339eb144e104937d"}
io.github.babashka/sci.configs
#_{:local/root "/Users/borkdude/dev/sci.configs"}
{:git/url "https://github.com/babashka/sci.configs"
:git/sha "aa84a1b4f1fe45735e5b748769309fc842f737c1"
:exclusions [org.babashka/sci]}
binaryage/devtools {:mvn/version "1.0.7"}}
:aliases
{:dev
{:extra-paths ["dev"]
:extra-deps {}}}}

11
package.json Normal file
View file

@ -0,0 +1,11 @@
{
"name": "scittle",
"version": "0.7.27",
"files": [
"dist"
],
"devDependencies": {
"react": "17.0.1",
"react-dom": "17.0.1"
}
}

View file

@ -0,0 +1,4 @@
{:deps
{datascript/datascript {:mvn/version "1.3.12"}
io.github.babashka/sci.configs {:git/sha "aa84a1b4f1fe45735e5b748769309fc842f737c1"
:exclusions [org.babashka/sci]}}}

View file

@ -0,0 +1,9 @@
(ns scittle.datascript
{:no-doc true}
(:require [sci.configs.tonsky.datascript :refer [config]]
[scittle.core :as scittle]))
(defn init []
(scittle/register-plugin!
::datascript
config))

View file

@ -0,0 +1,12 @@
[{:name scittle/datascript
:namespaces [datascript.core datascript.db]
:js "./scittle.datascript.js"
:shadow-config
{:compiler-options {:externs ["datascript/externs.js"]}
:modules
{:scittle.datascript
{:init-fn scittle.datascript/init
;; From https://github.com/tonsky/datascript/issues/298#issuecomment-813790783
:prepend "globalThis.datascript = {};"
:depends-on #{:scittle}
:entries [datascript.core]}}}}]

View file

@ -0,0 +1,8 @@
{:deps
{no.cjohansen/dataspex {:git/url "https://github.com/cjohansen/dataspex"
:git/sha "02112200651c2bd932907bb69fba1ff50b881741"
:exclusions [ring/ring-core
ring/ring-jetty-adapter
com.cognitect/transit-clj]}
io.github.babashka/sci.configs {:git/sha "aa84a1b4f1fe45735e5b748769309fc842f737c1"
:exclusions [org.babashka/sci]}}}

View file

@ -0,0 +1,9 @@
(ns scittle.dataspex
{:no-doc true}
(:require [sci.configs.cjohansen.dataspex :refer [config]]
[scittle.core :as scittle]))
(defn init []
(scittle/register-plugin!
::dataspex
config))

View file

@ -0,0 +1,8 @@
[{:name scittle/dataspex
:namespaces [dataspex.core]
:js "./scittle.dataspex.js"
:shadow-config
{:modules
{:scittle.dataspex {:init-fn scittle.dataspex/init
:depends-on #{:scittle :scittle.datascript}
:entries [dataspex.core]}}}}]

29
plugins/demo/README.md Normal file
View file

@ -0,0 +1,29 @@
# Demo
A demo project of a custom scittle build.
This demo project uses the `scittle.javelin` and `scittle.hoplon` plugins which aren't part of the normal scittle distribution.
To produce release `.js` files, run: `bb release`.
See:
- `bb.edn` with
- `:deps` which includes:
- a dependency on the `scittle.build` project to build scittle + custom features
- zero or more plugin dependencies
- helpers like static file server
- development `:tasks`. Run `bb dev` for development and `bb release` to produce release artifacts.
- `deps.edn`: this only contains a dependency on scittle itself
Available plugins are in the `plugins` directory inside the top level directory of this repo.
Writing a plugin involves writing
- SCI configuration (this can be shared via the [sci.configs](https://github.com/babashka/sci.configs) project too)
- Adding a `scittle_plugin.edn` file on the plugin's classpath (e.g. in the `src` directory). This EDN file contains:
- `:name`, name of the plugin
- `:namespaces`: the namespaces exposed to SCI
- `:js`: the name of the produced `.js` module file
- `:shadow-config`: the shadow-cljs configuration specific to this plugin
- A `.cljs` file with an `init` function which calls `scittle/register-plugin!`.

22
plugins/demo/bb.edn Normal file
View file

@ -0,0 +1,22 @@
{:deps {io.github.babashka/scittle.build {:local/root "../../build"}
;; datascript plugin
; io.github.babashka/scittle.datascript {:local/root "../../plugins/datascript"}
io.github.babashka/scittle.dataspex {:local/root "../../plugins/dataspex"}
io.github.babashka/scittle.javelin {:local/root "../../plugins/javelin"}
io.github.babashka/scittle.hoplon {:local/root "../../plugins/hoplon"}
io.github.babashka/http-server
{:git/sha "b38c1f16ad2c618adae2c3b102a5520c261a7dd3"}}
:tasks
{:requires ([scittle.build :as build])
watch {:doc "Watch build"
:task (build/build {:action "watch"})}
serve {:doc "Starts http server for serving static files"
:requires ([babashka.http-server :as http])
:task (do (http/serve {:port 1341 :dir "resources/public"})
(println "Serving static assets at http://localhost:1341"))}
-dev {:depends [watch serve]}
dev {:doc "Run compilation in watch mode and start http server"
:task (do (run '-dev {:parallel true})
(deref (promise)))}
release {:doc "Release build (advanced compiled JS)"
:task (build/build {})}}}

1
plugins/demo/deps.edn Normal file
View file

@ -0,0 +1 @@
{:deps {io.github.babashka/scittle {:local/root "../.."}}}

View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<!-- <link rel="stylesheet" href="/css/style.css"> -->
<script src="/js/scittle.js" type="application/javascript"></script>
<script src="/js/scittle.javelin.js" type="application/javascript"></script>
<script src="/js/scittle.hoplon.js" type="application/javascript"></script>
<script type="application/x-scittle">
(require '[hoplon.core :as h])
(require '[javelin.core :as j])
(j/defc title "From Hoplon")
(h/body
(h/h1 (h/text "~{title}")))
</script>
</head>
<body>
<h1>Hello Hoplon!</h1>
</body>
</html>

View file

@ -0,0 +1,32 @@
{:deps
{:aliases [:dev]}
:dev-http
{8000 "classpath:public"}
:builds
{:main
{:target :browser
:js-options
{:resolve {"react" {:target :global
:global "React"}
"react-dom" {:target :global
:global "ReactDOM"}}}
:modules
{:scittle {:entries [scittle.core]}
:scittle.nrepl {:entries [scittle.nrepl]
:depends-on #{:scittle}}
:scittle.promesa {:entries [scittle.promesa]
:depends-on #{:scittle}}
:scittle.pprint {:entries [scittle.pprint]
:depends-on #{:scittle}}
:scittle.reagent {:entries [scittle.reagent]
:depends-on #{:scittle}}
:scittle.re-frame {:entries [scittle.re-frame]
:depends-on #{:scittle.reagent
:scittle}}
:scittle.cljs-ajax {:entries [scittle.cljs-ajax]
:depends-on #{:scittle}}}
:build-hooks [(shadow.cljs.build-report/hook)]
:output-dir "resources/public/js"
:devtools {:repl-pprint true}}}}

4
plugins/hoplon/deps.edn Normal file
View file

@ -0,0 +1,4 @@
{:deps
{hoplon/hoplon {:mvn/version "7.5.0"}
io.github.babashka/sci.configs {:git/sha "aa84a1b4f1fe45735e5b748769309fc842f737c1"
:exclusions [org.babashka/sci]}}}

View file

@ -0,0 +1,9 @@
(ns scittle.hoplon
{:no-doc true}
(:require [sci.configs.hoplon.hoplon :refer [config]]
[scittle.core :as scittle]))
(defn init []
(scittle/register-plugin!
::hoplon
config))

View file

@ -0,0 +1,9 @@
(ns scittle.javelin
{:no-doc true}
(:require [sci.configs.hoplon.javelin :refer [config]]
[scittle.core :as scittle]))
(defn init []
(scittle/register-plugin!
::javelin
config))

View file

@ -0,0 +1,13 @@
[{:name scittle/hoplon
:namespaces [javelin.core
hoplon.core
hoplon.dom]
:js "./scittle.hoplon.js"
:shadow-config
{:modules
{:scittle.hoplon {:init-fn scittle.hoplon/init
:depends-on #{:scittle :scittle.javelin}
:entries [hoplon.core hoplon.dom]}
:scittle.javelin {:init-fn scittle.javelin/init
:depends-on #{:scittle}
:entries [javelin.core]}}}}]

4
plugins/javelin/deps.edn Normal file
View file

@ -0,0 +1,4 @@
{:deps
{hoplon/javelin {:mvn/version "3.9.3"}
io.github.babashka/sci.configs {:git/sha "aa84a1b4f1fe45735e5b748769309fc842f737c1"
:exclusions [org.babashka/sci]}}}

View file

@ -0,0 +1,9 @@
(ns scittle.javelin
{:no-doc true}
(:require [sci.configs.hoplon.javelin :refer [config]]
[scittle.core :as scittle]))
(defn init []
(scittle/register-plugin!
::javelin
config))

View file

@ -0,0 +1,8 @@
[{:name scittle/javelin
:namespaces [javelin.core]
:js "./scittle.javelin.js"
:shadow-config
{:modules
{:scittle.javelin {:init-fn scittle.javelin/init
:depends-on #{:scittle}
:entries [javelin.core]}}}}]

View file

@ -0,0 +1,140 @@
(ns bookmarklet
(:require [reagent.core :as r]
[reagent.dom :as rdom]))
(defn append-tag [tag {:keys [body onload onerror] :as attributes}]
(str "var s=document.createElement('" (name tag) "');"
(clojure.string/join ";" (map (fn [[k v]] (str "s.setAttribute('" (name k) "','" (name v) "')")) (dissoc attributes :body :onload :onerror)))
(when body
(str ";s.innerText=" body))
(when onload
(str ";s.onload=" onload))
(when onerror
(str ";s.onerror=" onerror))
";document.body.appendChild(s);"))
(defn pr-code [code-str]
(pr-str (str "#_CODE_" code-str "#_CODE_")))
(defn read-code [code-str]
(when-let [raw-code (second (re-find #"#_CODE_(.+)#_CODE_" code-str))]
;; Use read-string to undo escaping of characters by pr-str (e.g. newlines)
(read-string (str "\"" raw-code "\""))))
(defn load-gist [gist callback]
(let [set-content (fn [progress-event]
(callback (.. progress-event -srcElement -responseText)))
oreq (js/XMLHttpRequest.)]
(.addEventListener oreq "load" set-content)
(.open oreq "GET" (str "https://gist.githubusercontent.com/" gist "/raw"))
(.send oreq)))
(defn bookmarklet-href [code-str]
(str "javascript:(function(){"
"var runCode = function() {
try {
scittle.core.eval_string(" (pr-code code-str) ")
} catch (error) {
console.log('Error in code', error);
alert('Error running code, see console')
}
};"
"if(typeof scittle === 'undefined'){"
(append-tag :script {:src "https://babashka.github.io/scittle/js/scittle.js"
:onerror "function(){alert('Error loading ' + this.src)}"
:onload "runCode"})
"} else {
runCode() }"
"})();"))
(defn query-params []
(let [query-str (.substring js/window.location.search 1)]
(into {}
(map (fn [pair]
(let [[k v] (.split pair "=" 2)]
[(keyword (js/decodeURIComponent k))
(js/decodeURIComponent v)])))
(.split query-str "&"))))
(def *initial-name (r/atom nil))
(def *initial-code (r/atom nil))
;; Initialize code
(let [{:keys [gist code name]} (query-params)]
(cond gist
(do
(reset! *initial-name "---")
(reset! *initial-code ";; loading from gist")
(load-gist gist (fn [content]
(let [[code meta-str] (reverse (clojure.string/split content #";;---+\n"))
{bookmark-name :name} (when meta-str
(read-string meta-str))]
(when bookmark-name
(reset! *initial-name bookmark-name))
(reset! *initial-code code)))))
code
(do
(reset! *initial-name (or name "My first bookmarklet"))
(reset! *initial-code code))
:else
(do
(reset! *initial-name "My first bookmarklet")
(reset! *initial-code (str "; This is the code of your bookmarklet\n"
(pr-str '(js/alert "Hello")))))))
(defn bookmark-name-field [initial-name *bookmark-name]
(let [*name (r/atom initial-name)]
[(fn []
[:input {:type "text"
:placeholder "The name of the Bookmarklet"
:value @*name
:on-change (fn [e]
(let [v (.. e -target -value)]
(reset! *name v)
(reset! *bookmark-name
(if (clojure.string/blank? v)
(str "Bookmarklet " (rand-int 1000))
v))))}])]))
(defn editor [*code]
[:textarea
{:rows 10 :cols 80
:value @*code
:on-drop (fn [e]
(let [bookmarklet (js/decodeURIComponent (.. e -dataTransfer (getData "text")))
cljs-snippet (read-code bookmarklet)
new-code (if cljs-snippet
(str "; Extracted snippet\n" cljs-snippet)
(str "; Failed to extract snippet\n" bookmarklet))]
(js/console.log "Dropped" bookmarklet)
(set! (.. e -target -value) new-code)
(reset! *code new-code)
(.preventDefault e)))
:on-change (fn [e] (reset! *code (.. e -target -value)))}])
(defn workspace []
(let [value @*initial-code
*code (r/atom value)
bookmark-name @*initial-name
*bookmark-name (r/atom bookmark-name)]
[:div
[bookmark-name-field bookmark-name *bookmark-name]
[:br]
[editor *code]
[:br]
[:br]
"Click the following link or drag it to the bookmarks bar: "
[(fn []
[(fn [] [:a {:href (bookmarklet-href @*code)} @*bookmark-name])])
*code]
[:br]
[(fn []
[:a {:href (str "?name=" (js/encodeURIComponent @*bookmark-name)
"&code=" (js/encodeURIComponent @*code)
"%20")} "Copy this link to share ⤴️"])]]))
(rdom/render [workspace] (.getElementById js/document "app"))

View file

@ -0,0 +1,56 @@
(require '[clojure.string :as str])
(declare cm)
(defn eval-me []
(js/scittle.core.eval_string (-> cm .-state .-doc .toString)))
(def extension
(.of js/cv.keymap
(clj->js [{:key "Mod-Enter"
:run (fn []
(eval-me))}
#_{:key (str modifier "-Enter")
:shift (partial eval-top-level on-result)
:run (partial eval-at-cursor on-result)}])))
(def cm
(let [doc (str/trim "
(require '[reagent.core :as r]
'[reagent.dom :as rdom]
'[re-frame.core :as rf])
(rf/reg-event-fx ::click (fn [{:keys [db]} _] {:db (update db :clicks (fnil inc 0))}))
(rf/reg-sub ::clicks (fn [db] (:clicks db)))
(defn my-component []
(let [clicks (rf/subscribe [::clicks])]
[:div
[:p \"Clicks: \" @clicks]
[:p [:button {:on-click #(rf/dispatch [::click])}
\"Click me!\"]]]))
(rdom/render [my-component] (.getElementById js/document \"reagent\"))
")]
(js/cm.EditorView. #js {:doc doc
:extensions #js [js/cm.basicSetup, (js/lc.clojure), (.highest js/cs.Prec extension)]
:parent (js/document.querySelector "#app")
#_#_:dispatch (fn [tr] (-> cm (.update #js [tr])) (eval-me))
})))
(set! (.-eval_me js/globalThis) eval-me)
(set! (.-cm_instance js/globalThis) cm)
(defn linux? []
(some? (re-find #"(Linux)|(X11)" js/navigator.userAgent)))
(defn mac? []
(and (not (linux?))
(some? (re-find #"(Mac)|(iPhone)|(iPad)|(iPod)" js/navigator.platform))))
(let [elt (js/document.getElementById "evalMe")
txt (.-innerText elt)
mod-symbol (if (mac?)
"⌘"
"⌃")
txt (str txt " " mod-symbol"-⏎")]
(set! (.-innerHTML elt) txt))
(eval-me)

View file

@ -0,0 +1,15 @@
(ns nrepl-playground)
(+ 1 2 3)
(->
(js/document.getElementsByTagName "body")
first
(.append
(doto (js/document.createElement "p")
(.append
(js/document.createTextNode "there")))))
(defn foo [])
(js/alert "Isn't this cool? :)")

View file

@ -0,0 +1,33 @@
;; COPIED FROM https://github.com/cjohansen/replicant-tic-tac-toe/blob/7a33fb12f0cd6658b2f555ff673dee031d4aa921/src/tic_tac_toe/core.cljs
(ns replicant-tictactoe.core
(:require [replicant.dom :as r]
[replicant-tictactoe.game :as game]
[replicant-tictactoe.ui :as ui]))
(defn start-new-game [store]
(reset! store (game/create-game {:size 3})))
(defn main []
;; Set up the atom
(let [store (atom nil)
el (js/document.getElementById "app")]
;; Globally handle DOM events
(r/set-dispatch!
(fn [_ [action & args]]
(case action
:tic (apply swap! store game/tic args)
:reset (start-new-game store))))
;; Render on every change
(add-watch store ::render
(fn [_ _ _ game]
(->> (ui/game->ui-data game)
ui/render-game
(r/render el))))
;; Trigger the first render by initializing the game.
(start-new-game store)))
(main)

View file

@ -0,0 +1,41 @@
;; COPIED FROM https://github.com/cjohansen/replicant-tic-tac-toe/blob/7a33fb12f0cd6658b2f555ff673dee031d4aa921/src/tic_tac_toe/game.cljs
(ns replicant-tictactoe.game)
(defn create-game [{:keys [size]}]
{:next-player :x
:size size})
(def next-player {:x :o, :o :x})
(defn winner? [tics path]
(when (= 1 (count (set (map tics path))))
path))
(defn get-winning-path [{:keys [size tics]} y x]
(or (winner? tics (mapv #(vector y %) (range 0 size)))
(winner? tics (mapv #(vector % x) (range 0 size)))
(when (= y x)
(winner? tics (mapv #(vector % %) (range 0 size))))))
(defn maybe-conclude [game y x]
(if-let [path (get-winning-path game y x)]
(-> (dissoc game :next-player)
(assoc :over? true
:victory {:player (get-in game [:tics [y x]])
:path path}))
(let [tie? (= (count (:tics game)) (* (:size game) (:size game)))]
(cond-> game
tie? (dissoc :next-player)
tie? (assoc :over? true)))))
(defn tic [game y x]
(let [player (:next-player game)]
(if (or (get-in game [:tics [y x]])
(<= (:size game) x)
(<= (:size game) y))
game
(-> game
(assoc-in [:tics [y x]] player)
(assoc :next-player (next-player player))
(maybe-conclude y x)))))

View file

@ -0,0 +1,50 @@
/* COPIED from https://github.com/cjohansen/replicant-tic-tac-toe/blob/7a33fb12f0cd6658b2f555ff673dee031d4aa921/resources/public/styles.css */
.cell {
aspect-ratio: 1 / 1;
background: rgba(255, 255, 255, 0.8);
border-radius: 6%;
border: none;
display: block;
flex: 1 1 0%;
outline: none;
position: relative;
width: 100%;
}
.cell-content {
opacity: 1;
transition: opacity 0.25s;
}
.transparent {
opacity: 0;
}
.cell-dim {
background: rgba(249, 249, 240, 0.3);
}
.cell-highlight {
background: #fcfcf3;
}
.clickable {
cursor: pointer;
}
.board {
--gap: 0.75rem;
background: #833ab4;
background: linear-gradient(90deg, #833ab4 0%, #fd1d1d 50%, #fcb045 100%);
display: flex;
flex-direction: column;
gap: var(--gap);
padding: var(--gap);
max-width: 80vh;
}
.row {
display: flex;
flex-direction: row;
gap: var(--gap);
}

View file

@ -0,0 +1,75 @@
;; COPIED FROM https://github.com/cjohansen/replicant-tic-tac-toe/blob/7a33fb12f0cd6658b2f555ff673dee031d4aa921/src/tic_tac_toe/ui.cljs
(ns replicant-tictactoe.ui)
(def mark-x
[:svg {:xmlns "http://www.w3.org/2000/svg"
:viewBox "0 -10 108 100"}
[:path
{:fill "currentColor"
:d "m1.753 69.19.36-1.08q.35-1.09 1.92-2.97 1.58-1.87 3.85-3.84 2.29-1.97 4.6-3.54 2.31-1.57 4.93-3.24 2.62-1.66 4.65-2.9 2.04-1.23 3.91-2.27 1.87-1.05 3.98-2.31 2.11-1.27 4.12-2.5 2.01-1.24 4.33-2.51l4.6-2.52q2.27-1.25 4.84-2.86 2.56-1.62 5.03-3.09 2.47-1.47 4.5-2.88 2.03-1.4 3.82-2.82t3.81-3.47q2.01-2.06 3.7-3.51 1.69-1.46 3.47-3.03 1.77-1.57 4.01-3.69 2.24-2.11 4.13-3.7 1.89-1.58 3.93-2.97 2.04-1.39 4.05-2.49 2.01-1.11 5.26-2.54 3.24-1.44 4.48-1.46 1.24-.01 2.42.37 1.18.37 2.18 1.11 1 .74 1.71 1.75.71 1.02 1.06 2.21.34 1.19.3 2.43-.05 1.24-.5 2.39-.44 1.16-1.23 2.12-.79.95-1.84 1.61-1.05.65-2.26.94-1.21.28-2.44.16-1.23-.11-2.37-.62-1.13-.5-2.04-1.34-.91-.84-1.51-1.93-.6-1.08-.81-2.3-.22-1.22-.04-2.45.18-1.23.75-2.33.56-1.1 1.45-1.97.89-.86 2.01-1.4 1.11-.54 2.35-.69 1.23-.15 2.44.1t2.29.87q1.07.63 1.88 1.56.82.93 1.29 2.08.48 1.14.56 2.38.09 1.24-.23 2.44-.31 1.19-.99 2.23-.68 1.04-1.66 1.8-.98.76-2.15 1.18l-1.16.41-2.28 1.17q-2.28 1.18-4.38 2.7-2.1 1.51-4.2 3.44-2.1 1.92-4.18 3.7-2.08 1.77-3.9 3.44-1.81 1.68-3.41 3.13-1.6 1.46-3.38 3.09-1.79 1.62-3.44 2.97-1.66 1.34-3.53 2.4-1.88 1.06-4.17 2.65-2.3 1.6-4.79 2.74-2.48 1.14-4.98 2.71-2.5 1.57-4.51 2.47-2.01.9-3.99 1.87-1.98.97-3.88 2.02-1.91 1.05-4.38 2.34-2.46 1.28-4.94 2.53-2.47 1.25-4.48 2.38-2 1.12-3.96 2.14-1.95 1.01-3.83 1.99-1.89.98-4.37 2.05-2.48 1.06-2.96 2.01-.48.96-.78 1.49-.3.53-.71.97-.41.44-.92.77-.51.34-1.09.54-.57.2-1.17.25-.6.06-1.2-.03t-1.16-.32q-.56-.23-1.05-.59-.49-.35-.89-.82-.39-.46-.65-1.01-.27-.54-.4-1.14-.13-.59-.12-1.19.02-.6.18-1.19l.16-.59Z"}]
[:path
{:fill "currentColor"
:d "m28.099 4.991 2.69 1.97q2.69 1.96 4.5 3.22 1.8 1.28 4.54 3.46 2.74 2.18 4.57 3.89t3.38 3.72q1.54 2.02 2.88 4.3 1.34 2.28 2.83 4.46 1.48 2.18 2.63 4.14 1.15 1.96 2.74 4.07 1.59 2.1 3.59 4.19 1.99 2.08 4.23 4.48 2.24 2.4 3.7 4.04 1.47 1.64 2.91 3.23 1.44 1.59 3.08 3.58 1.64 1.99 3.51 4.08 1.87 2.09 3.55 3.77 1.69 1.68 4.1 3.51 2.42 1.83 3.9 2.58 1.48.74 2.14 1.34.66.6 1.15 1.33.5.74.8 1.57.31.84.4 1.72.1.88-.02 1.76-.12.88-.44 1.71-.33.82-.84 1.55-.51.72-1.19 1.3-.67.58-1.46.98-.79.41-1.65.61-.87.2-1.76.19-.88-.01-1.74-.24-.86-.22-1.64-.64-.78-.42-2.27-2.72-1.48-2.3-1.52-3.49-.03-1.19.31-2.33.35-1.14 1.04-2.11.69-.97 1.66-1.67.96-.7 2.1-1.05 1.14-.35 2.33-.32 1.19.02 2.31.43t2.05 1.15q.93.75 1.58 1.75.64 1 .93 2.15.29 1.16.2 2.35-.09 1.18-.56 2.28-.47 1.1-1.26 1.99-.79.88-1.83 1.47t-2.2.82q-1.17.23-2.35.07-1.19-.16-2.25-.68-1.07-.53-1.92-1.37-.84-.84-1.37-1.9-.54-1.07-.7-2.25-.17-1.18.06-2.35.22-1.17.8-2.21.58-1.04 1.47-1.84.88-.79 1.98-1.27 1.09-.47 2.28-.57 1.18-.1 2.34.18 1.16.29 2.16.93 1.01.63 1.76 1.56.74.93-.33-.26-1.07-1.18-.41-.58.66.59 1.15 1.33.5.74.8 1.57.31.83.4 1.72.1.88-.02 1.76-.12.88-.44 1.7-.33.83-.84 1.55-.51.73-1.19 1.31-.67.58-1.46.98-.79.41-1.65.61-.87.2-1.75.19-.89-.01-1.75-.24-.86-.22-1.64-.64-.78-.42-2.73-1.57-1.95-1.14-4.26-2.95-2.31-1.8-3.87-3.43-1.57-1.62-3.17-3.29-1.6-1.66-3.55-4.05-1.95-2.39-3.33-4.15-1.39-1.76-2.77-3.4-1.38-1.64-3.07-3.56-1.7-1.91-3.91-4.13-2.2-2.22-3.74-4.1-1.54-1.88-2.79-3.75-1.24-1.87-2.4-4.33t-2.39-4.46q-1.23-2.01-2.4-4.59-1.17-2.59-2.53-5.01-1.36-2.43-3.35-4.44-1.99-2.02-4.52-4.27-2.54-2.25-5.33-4.04-2.81-1.79-3.28-2.21-.47-.41-.83-.92-.35-.51-.58-1.1-.22-.58-.3-1.2-.08-.62-.01-1.23.08-.62.29-1.21.22-.58.58-1.1.35-.51.81-.93.47-.42 1.02-.71t1.16-.45q.61-.15 1.23-.15t1.22.14q.61.15 1.17.44l.55.28Z"}]])
(def mark-o
[:svg {:xmlns "http://www.w3.org/2000/svg"
:viewBox "0 0 114 114"}
[:path
{:fill "none"
:stroke "currentColor"
:stroke-linecap "round"
:stroke-width "6"
:d "M74.616 8.935c7.73 2.38 15.96 9.34 21.58 16.04 5.63 6.69 10.57 15.46 12.18 24.11 1.6 8.65.74 19.67-2.53 27.77-3.27 8.11-10.12 15.37-17.09 20.88-6.98 5.51-16.07 10.81-24.76 12.17-8.7 1.35-19.32-.76-27.42-4.06-8.1-3.29-15.73-8.93-21.21-15.73-5.48-6.81-10.32-16.5-11.67-25.09-1.35-8.6.19-18.39 3.57-26.51 3.38-8.11 9.99-16.6 16.71-22.19 6.72-5.59 13.95-10.52 23.63-11.36 9.68-.84 28.04 4.34 34.45 6.32 6.42 1.97 4.37 4.6 4.04 5.55m-48.33-9.69c7.65-3.32 19.78-3.63 28.63-2.01 8.86 1.63 17.85 5.89 24.49 11.76 6.64 5.87 12.7 15.08 15.37 23.48 2.67 8.41 2.5 18.4.65 26.95-1.85 8.54-5.98 17.59-11.77 24.34-5.78 6.74-14.56 13.05-22.93 16.11-8.37 3.06-18.75 4.19-27.29 2.25-8.54-1.93-17.37-7.89-23.96-13.87-6.59-5.97-12.89-13.58-15.57-21.96-2.69-8.39-2.31-19.94-.56-28.34 1.75-8.4 5.21-15.74 11.06-22.09 5.85-6.35 19.92-13.32 24.04-16.01 4.12-2.7.37-1.1.67-.16"}]])
(defn render-cell [{:keys [content on-click dim? highlight? clickable?]}]
[:button.cell
{:on {:click on-click}
:class (cond-> []
dim? (conj "cell-dim")
highlight? (conj "cell-highlight")
clickable? (conj "clickable"))}
(when content
[:div.cell-content
{:replicant/mounting {:class "transparent"}
:replicant/unmounting {:class "transparent"}}
content])])
(defn render-board [{:keys [rows]}]
[:div.board
(for [row rows]
[:div.row
(for [cell row]
(render-cell cell))])])
(defn render-game [{:keys [board button]}]
[:div
(render-board board)
(when button
[:button {:on {:click (:on-click button)}
:style {:margin-top 20
:font-size 20}}
(:text button)])])
(def player->mark
{:x mark-x
:o mark-o})
(defn game->ui-data [{:keys [size tics victory over?]}]
(let [highlight? (set (:path victory))]
{:button (when over?
{:text "Start over"
:on-click [:reset]})
:board
{:rows
(for [y (range size)]
(for [x (range size)]
(if-let [player (get tics [y x])]
(let [victorious? (highlight? [y x])]
(cond-> {:content (player->mark player)}
victorious? (assoc :highlight? true)
(and over? (not victorious?)) (assoc :dim? true)))
(if over?
{:dim? true}
{:clickable? true
:on-click [:tic y x]}))))}}))

View file

@ -0,0 +1,2 @@
(defn my-alert2 []
(js/alert "My alert 2!"))

View file

@ -0,0 +1,85 @@
(ns tictactoe
"Ported from https://github.com/borkdude/tictactoe-cljs"
(:require [reagent.core :as r]
[reagent.dom :as rdom]))
(def empty-board [[\- \- \-]
[\- \- \-]
[\- \- \-]])
(def state (r/atom {:board empty-board :player \X}))
(defn get-board-cell
([board row col]
(get-in board [row col])))
(defn get-player [app-state]
(-> app-state :game-state :player))
(defn other-player [player]
(if (= player \X) \O \X))
(defn winner-in-rows? [board player]
(boolean (some (fn [row] (every? (fn [c] (= c player)) row)) board)))
(defn transposed-board [board]
(vec (apply map vector board)))
(defn winner-in-cols? [board player]
(winner-in-rows? (transposed-board board) player))
(defn winner-in-diagonals? [board player]
(let [diag-coords [[[0 0] [1 1] [2 2]]
[[0 2] [1 1] [2 0]]]]
(boolean (some (fn [coords]
(every? (fn [coord]
(= player (apply get-board-cell board coord)))
coords))
diag-coords))))
(defn winner?
"checks if there is a winner. when called with no args, checks for player X and player O.
returns the character for the winning player, nil if there is no winner"
([board]
(boolean (or (winner? board \X)
(winner? board \O))))
([board player]
(when (or (winner-in-rows? board player)
(winner-in-cols? board player)
(winner-in-diagonals? board player))
player)))
(defn full-board?
[board]
(let [all-cells (apply concat board)]
(not-any? #(= % \-) all-cells)))
(defn new-state [old-state row col]
(if (and (= (get-board-cell (:board old-state) row col) \-)
(not (winner? (:board old-state))))
{:board (assoc-in (:board old-state) [row col] (:player old-state))
:player (other-player (:player old-state))}
old-state))
(defn tictactoe []
[:div
(if (winner? (:board @state))
(str "The winner is " (other-player (:player @state)))
(if (full-board? (:board @state))
"It's a draw"
(str "Your turn, player " (:player @state))))
(let [board (-> @state :board)]
[:table
[:tbody
(map-indexed
(fn [i row]
^{:key i}
[:tr
(map-indexed (fn [j elt]
^{:key j}
[:td {:on-click (fn []
(swap! state new-state i j))}elt])
row)])
board)]])])
(rdom/render [tictactoe] (.getElementById js/document "app"))

View file

@ -0,0 +1,23 @@
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.js" type="application/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.cljs-ajax.js" type="application/javascript"></script>
<script type="application/x-scittle">
(require '[ajax.core :refer [GET]])
(defn handler [response]
(js/alert (str response)))
(defn make-request []
(GET "html/cljs-ajax.html" {:handler handler}))
;; export function to use from JavaScript:
(set! (.-make_request js/window) make-request)
</script>
</head>
<body>
<button onclick="make_request()">
Click me!
</button>
</body>
</html>

View file

@ -0,0 +1,16 @@
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.js" type="application/javascript"></script>
<script type="application/x-scittle">
(defn my-alert []
(js/alert "You clicked!"))
;; export function to use from JavaScript:
(set! (.-my_alert js/window) my-alert)
</script>
</head>
<body>
<button onclick="my_alert()">
Click me!
</button>
</body>
</html>

View file

@ -0,0 +1,15 @@
<html>
<head>
<script src="../js/scittle.js" type="application/javascript"></script>
<script crossorigin src="https://cdn.jsdelivr.net/npm/react@18/umd/react.production.min.js"></script>
<script crossorigin src="https://cdn.jsdelivr.net/npm/react-dom@18/umd/react-dom.production.min.js"></script>
<script src="../js/scittle.reagent.js" type="application/javascript"></script>
<script type="application/x-scittle">
(defn f [x]
(inc n))
</script>
</head>
<body>
<div id="app"></div>
</body>
</html>

View file

@ -0,0 +1,25 @@
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.js" type="application/javascript"></script>
<script crossorigin src="https://cdn.jsdelivr.net/npm/react@18/umd/react.production.min.js"></script>
<script crossorigin src="https://cdn.jsdelivr.net/npm/react-dom@18/umd/react-dom.production.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/scittle@0.7.27/dist/scittle.reagent.js" type="application/javascript"></script>
<script type="application/x-scittle">
(require '[reagent.core :as r]
'[reagent.dom :as rdom])
(def state (r/atom {:clicks 0}))
(defn my-component []
[:div
[:p "Clicks: " (:clicks @state)]
[:p [:button {:on-click #(swap! state update :clicks inc)}
"Click me!"]]])
(rdom/render [my-component] (.getElementById js/document "app"))
</script>
</head>
<body>
<div id="app"></div>
</body>
</html>

View file

@ -7,13 +7,13 @@
<style>
@font-face {
font-family: Bulara;
src: url(resources/fonts/bulara_5.ttf);
src: url(fonts/bulara_5.ttf);
font-weight: normal;
}
@font-face {
font-family: 'Noto Sans Gurmukhi';
src: url(resources/fonts/NotoSansGurmukhi-Medium.ttf);
src: url(fonts/NotoSansGurmukhi-Medium.ttf);
font-weight: normal;
}
@ -77,8 +77,8 @@
</style>
<meta charset="UTF-8">
<meta Content-Language="pa, en-GB">
<script src="resources/scripts/scittle.js" type="text/javascript"></script>
<script src="resources/scripts/jquery-3.7.1.slim.min.js" type="text/javascript">
<script src="scripts/scittle.js" type="text/javascript"></script>
<script src="scripts/jquery-3.7.1.slim.min.js" type="text/javascript">
</script>
<!-- Have to pull react and react-dom from CDN during development because of obnoxious
@ -86,7 +86,7 @@
at all, since we don't use them much! -->
<script crossorigin src="https://cdn.jsdelivr.net/npm/react@18/umd/react.production.min.js"></script>
<script crossorigin src="https://cdn.jsdelivr.net/npm/react-dom@18/umd/react-dom.production.min.js"></script>
<script src="resources/scripts/scittle.reagent.js" type="text/javascript"></script>
<script src="scripts/scittle.reagent.js" type="text/javascript"></script>
</script>
@ -1723,7 +1723,7 @@
(def student-recordings (atom (apply vector (repeat (count data) nil))))
(defn enable-play-button [phrase-no])
(defn enable-play-button! [phrase-no])
(defn record-student-sound!
[phrase-no]
@ -1732,10 +1732,10 @@
(try
(.then (.getUserMedia (.mediaDevices js/navigator) {:audio true})
(fn [arg]
(let [media-recorder (MediaRecorder. arg)
(let [media-recorder (js/MediaRecorder. arg)
audio-chunks (atom [])]
(.start media-recorder)
(set! media-recorder onerror
(set! (.-onerror media-recorder)
(fn [s]
(.log js/console (str "Error while recording sound: " s))))
(.addEventListener media-recorder "dataavailable"
@ -1747,7 +1747,7 @@
(js/console.log "data available after MediaRecorder.stop() called.")
(if (> (count @audio-chunks) 0)
(do
;; Store the blob in the student-sounds data structure
;; Store the blob in the student-recordings data structure
(swap! student-recordings assoc phrase-no
(js/Blob. (clj->js @audio-chunks)))
(enable-play-button! phrase-no))))))))
@ -1801,7 +1801,7 @@
(defn play-student!
[phrase-no]
(.play (js/Audio. (.createObjectURL js/URL (@student-sounds phrase-no)))))
(.play (js/Audio. (.createObjectURL js/URL (@student-recordings phrase-no)))))
(defn animate-progress-bar!
[id duration]
@ -1900,7 +1900,7 @@
<p>Select words to hear them. Select the bullet • to hear the whole line. Select three dots ... to record your own
voice.</p>
<audio id="japji-bindranwale" controls src="resources/audio/japji_bindranwale.mp3"></audio>
<audio id="japji-bindranwale" controls src="audio/japji_bindranwale.mp3"></audio>
<div id="content"><span class="gurmukhi" lang="pa">ਕ੍ਰਿਪਾ ਕਰਕੇ ਉਡੀਕ ਕਰੋ...</span></div>
<footer>

View file

@ -0,0 +1,456 @@
goog.provide('ajax.core');
ajax.core.to_interceptor = ajax.interceptors.to_interceptor;
/**
* Call this on the result of `ajax-request` to cancel the request.
*/
ajax.core.abort = (function ajax$core$abort(this$){
return ajax.protocols._abort(this$);
});
ajax.core.json_request_format = ajax.json.json_request_format;
ajax.core.json_response_format = ajax.json.json_response_format;
ajax.core.transit_request_format = ajax.transit.transit_request_format;
ajax.core.transit_response_format = ajax.transit.transit_response_format;
ajax.core.ring_response_format = ajax.ring.ring_response_format;
ajax.core.url_request_format = ajax.url.url_request_format;
ajax.core.text_request_format = ajax.formats.text_request_format;
ajax.core.text_response_format = ajax.formats.text_response_format;
ajax.core.raw_response_format = ajax.formats.raw_response_format;
ajax.core.success_QMARK_ = ajax.util.success_QMARK_;
ajax.core.default_interceptors = ajax.simple.default_interceptors;
ajax.core.ajax_request = ajax.simple.ajax_request;
ajax.core.default_formats = ajax.easy.default_formats;
ajax.core.detect_response_format = ajax.easy.detect_response_format;
/**
* accepts the URI and an optional map of options, options include:
* :handler - the handler function for successful operation
* should accept a single parameter which is the
* deserialized response
* :progress-handler - the handler function for progress events.
* this handler is only available when using the goog.net.XhrIo API
* :error-handler - the handler function for errors, should accept a
* map with keys :status and :status-text
* :format - the format for the request
* :response-format - the format for the response
* :params - a map of parameters that will be sent with the request
*/
ajax.core.GET = (function ajax$core$GET(var_args){
var args__5755__auto__ = [];
var len__5749__auto___47456 = arguments.length;
var i__5750__auto___47457 = (0);
while(true){
if((i__5750__auto___47457 < len__5749__auto___47456)){
args__5755__auto__.push((arguments[i__5750__auto___47457]));
var G__47460 = (i__5750__auto___47457 + (1));
i__5750__auto___47457 = G__47460;
continue;
} else {
}
break;
}
var argseq__5756__auto__ = ((((1) < args__5755__auto__.length))?(new cljs.core.IndexedSeq(args__5755__auto__.slice((1)),(0),null)):null);
return ajax.core.GET.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__5756__auto__);
});
(ajax.core.GET.cljs$core$IFn$_invoke$arity$variadic = (function (uri,opts){
var f__46799__auto__ = cljs.core.first(opts);
return ajax.easy.easy_ajax_request(uri,"GET",(((f__46799__auto__ instanceof cljs.core.Keyword))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,opts):f__46799__auto__));
}));
(ajax.core.GET.cljs$lang$maxFixedArity = (1));
/** @this {Function} */
(ajax.core.GET.cljs$lang$applyTo = (function (seq47294){
var G__47295 = cljs.core.first(seq47294);
var seq47294__$1 = cljs.core.next(seq47294);
var self__5734__auto__ = this;
return self__5734__auto__.cljs$core$IFn$_invoke$arity$variadic(G__47295,seq47294__$1);
}));
/**
* accepts the URI and an optional map of options, options include:
* :handler - the handler function for successful operation
* should accept a single parameter which is the
* deserialized response
* :progress-handler - the handler function for progress events.
* this handler is only available when using the goog.net.XhrIo API
* :error-handler - the handler function for errors, should accept a
* map with keys :status and :status-text
* :format - the format for the request
* :response-format - the format for the response
* :params - a map of parameters that will be sent with the request
*/
ajax.core.HEAD = (function ajax$core$HEAD(var_args){
var args__5755__auto__ = [];
var len__5749__auto___47475 = arguments.length;
var i__5750__auto___47476 = (0);
while(true){
if((i__5750__auto___47476 < len__5749__auto___47475)){
args__5755__auto__.push((arguments[i__5750__auto___47476]));
var G__47477 = (i__5750__auto___47476 + (1));
i__5750__auto___47476 = G__47477;
continue;
} else {
}
break;
}
var argseq__5756__auto__ = ((((1) < args__5755__auto__.length))?(new cljs.core.IndexedSeq(args__5755__auto__.slice((1)),(0),null)):null);
return ajax.core.HEAD.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__5756__auto__);
});
(ajax.core.HEAD.cljs$core$IFn$_invoke$arity$variadic = (function (uri,opts){
var f__46799__auto__ = cljs.core.first(opts);
return ajax.easy.easy_ajax_request(uri,"HEAD",(((f__46799__auto__ instanceof cljs.core.Keyword))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,opts):f__46799__auto__));
}));
(ajax.core.HEAD.cljs$lang$maxFixedArity = (1));
/** @this {Function} */
(ajax.core.HEAD.cljs$lang$applyTo = (function (seq47306){
var G__47307 = cljs.core.first(seq47306);
var seq47306__$1 = cljs.core.next(seq47306);
var self__5734__auto__ = this;
return self__5734__auto__.cljs$core$IFn$_invoke$arity$variadic(G__47307,seq47306__$1);
}));
/**
* accepts the URI and an optional map of options, options include:
* :handler - the handler function for successful operation
* should accept a single parameter which is the
* deserialized response
* :progress-handler - the handler function for progress events.
* this handler is only available when using the goog.net.XhrIo API
* :error-handler - the handler function for errors, should accept a
* map with keys :status and :status-text
* :format - the format for the request
* :response-format - the format for the response
* :params - a map of parameters that will be sent with the request
*/
ajax.core.POST = (function ajax$core$POST(var_args){
var args__5755__auto__ = [];
var len__5749__auto___47490 = arguments.length;
var i__5750__auto___47496 = (0);
while(true){
if((i__5750__auto___47496 < len__5749__auto___47490)){
args__5755__auto__.push((arguments[i__5750__auto___47496]));
var G__47497 = (i__5750__auto___47496 + (1));
i__5750__auto___47496 = G__47497;
continue;
} else {
}
break;
}
var argseq__5756__auto__ = ((((1) < args__5755__auto__.length))?(new cljs.core.IndexedSeq(args__5755__auto__.slice((1)),(0),null)):null);
return ajax.core.POST.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__5756__auto__);
});
(ajax.core.POST.cljs$core$IFn$_invoke$arity$variadic = (function (uri,opts){
var f__46799__auto__ = cljs.core.first(opts);
return ajax.easy.easy_ajax_request(uri,"POST",(((f__46799__auto__ instanceof cljs.core.Keyword))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,opts):f__46799__auto__));
}));
(ajax.core.POST.cljs$lang$maxFixedArity = (1));
/** @this {Function} */
(ajax.core.POST.cljs$lang$applyTo = (function (seq47320){
var G__47321 = cljs.core.first(seq47320);
var seq47320__$1 = cljs.core.next(seq47320);
var self__5734__auto__ = this;
return self__5734__auto__.cljs$core$IFn$_invoke$arity$variadic(G__47321,seq47320__$1);
}));
/**
* accepts the URI and an optional map of options, options include:
* :handler - the handler function for successful operation
* should accept a single parameter which is the
* deserialized response
* :progress-handler - the handler function for progress events.
* this handler is only available when using the goog.net.XhrIo API
* :error-handler - the handler function for errors, should accept a
* map with keys :status and :status-text
* :format - the format for the request
* :response-format - the format for the response
* :params - a map of parameters that will be sent with the request
*/
ajax.core.PUT = (function ajax$core$PUT(var_args){
var args__5755__auto__ = [];
var len__5749__auto___47502 = arguments.length;
var i__5750__auto___47503 = (0);
while(true){
if((i__5750__auto___47503 < len__5749__auto___47502)){
args__5755__auto__.push((arguments[i__5750__auto___47503]));
var G__47504 = (i__5750__auto___47503 + (1));
i__5750__auto___47503 = G__47504;
continue;
} else {
}
break;
}
var argseq__5756__auto__ = ((((1) < args__5755__auto__.length))?(new cljs.core.IndexedSeq(args__5755__auto__.slice((1)),(0),null)):null);
return ajax.core.PUT.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__5756__auto__);
});
(ajax.core.PUT.cljs$core$IFn$_invoke$arity$variadic = (function (uri,opts){
var f__46799__auto__ = cljs.core.first(opts);
return ajax.easy.easy_ajax_request(uri,"PUT",(((f__46799__auto__ instanceof cljs.core.Keyword))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,opts):f__46799__auto__));
}));
(ajax.core.PUT.cljs$lang$maxFixedArity = (1));
/** @this {Function} */
(ajax.core.PUT.cljs$lang$applyTo = (function (seq47334){
var G__47335 = cljs.core.first(seq47334);
var seq47334__$1 = cljs.core.next(seq47334);
var self__5734__auto__ = this;
return self__5734__auto__.cljs$core$IFn$_invoke$arity$variadic(G__47335,seq47334__$1);
}));
/**
* accepts the URI and an optional map of options, options include:
* :handler - the handler function for successful operation
* should accept a single parameter which is the
* deserialized response
* :progress-handler - the handler function for progress events.
* this handler is only available when using the goog.net.XhrIo API
* :error-handler - the handler function for errors, should accept a
* map with keys :status and :status-text
* :format - the format for the request
* :response-format - the format for the response
* :params - a map of parameters that will be sent with the request
*/
ajax.core.DELETE = (function ajax$core$DELETE(var_args){
var args__5755__auto__ = [];
var len__5749__auto___47521 = arguments.length;
var i__5750__auto___47522 = (0);
while(true){
if((i__5750__auto___47522 < len__5749__auto___47521)){
args__5755__auto__.push((arguments[i__5750__auto___47522]));
var G__47523 = (i__5750__auto___47522 + (1));
i__5750__auto___47522 = G__47523;
continue;
} else {
}
break;
}
var argseq__5756__auto__ = ((((1) < args__5755__auto__.length))?(new cljs.core.IndexedSeq(args__5755__auto__.slice((1)),(0),null)):null);
return ajax.core.DELETE.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__5756__auto__);
});
(ajax.core.DELETE.cljs$core$IFn$_invoke$arity$variadic = (function (uri,opts){
var f__46799__auto__ = cljs.core.first(opts);
return ajax.easy.easy_ajax_request(uri,"DELETE",(((f__46799__auto__ instanceof cljs.core.Keyword))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,opts):f__46799__auto__));
}));
(ajax.core.DELETE.cljs$lang$maxFixedArity = (1));
/** @this {Function} */
(ajax.core.DELETE.cljs$lang$applyTo = (function (seq47345){
var G__47346 = cljs.core.first(seq47345);
var seq47345__$1 = cljs.core.next(seq47345);
var self__5734__auto__ = this;
return self__5734__auto__.cljs$core$IFn$_invoke$arity$variadic(G__47346,seq47345__$1);
}));
/**
* accepts the URI and an optional map of options, options include:
* :handler - the handler function for successful operation
* should accept a single parameter which is the
* deserialized response
* :progress-handler - the handler function for progress events.
* this handler is only available when using the goog.net.XhrIo API
* :error-handler - the handler function for errors, should accept a
* map with keys :status and :status-text
* :format - the format for the request
* :response-format - the format for the response
* :params - a map of parameters that will be sent with the request
*/
ajax.core.OPTIONS = (function ajax$core$OPTIONS(var_args){
var args__5755__auto__ = [];
var len__5749__auto___47528 = arguments.length;
var i__5750__auto___47530 = (0);
while(true){
if((i__5750__auto___47530 < len__5749__auto___47528)){
args__5755__auto__.push((arguments[i__5750__auto___47530]));
var G__47531 = (i__5750__auto___47530 + (1));
i__5750__auto___47530 = G__47531;
continue;
} else {
}
break;
}
var argseq__5756__auto__ = ((((1) < args__5755__auto__.length))?(new cljs.core.IndexedSeq(args__5755__auto__.slice((1)),(0),null)):null);
return ajax.core.OPTIONS.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__5756__auto__);
});
(ajax.core.OPTIONS.cljs$core$IFn$_invoke$arity$variadic = (function (uri,opts){
var f__46799__auto__ = cljs.core.first(opts);
return ajax.easy.easy_ajax_request(uri,"OPTIONS",(((f__46799__auto__ instanceof cljs.core.Keyword))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,opts):f__46799__auto__));
}));
(ajax.core.OPTIONS.cljs$lang$maxFixedArity = (1));
/** @this {Function} */
(ajax.core.OPTIONS.cljs$lang$applyTo = (function (seq47351){
var G__47352 = cljs.core.first(seq47351);
var seq47351__$1 = cljs.core.next(seq47351);
var self__5734__auto__ = this;
return self__5734__auto__.cljs$core$IFn$_invoke$arity$variadic(G__47352,seq47351__$1);
}));
/**
* accepts the URI and an optional map of options, options include:
* :handler - the handler function for successful operation
* should accept a single parameter which is the
* deserialized response
* :progress-handler - the handler function for progress events.
* this handler is only available when using the goog.net.XhrIo API
* :error-handler - the handler function for errors, should accept a
* map with keys :status and :status-text
* :format - the format for the request
* :response-format - the format for the response
* :params - a map of parameters that will be sent with the request
*/
ajax.core.TRACE = (function ajax$core$TRACE(var_args){
var args__5755__auto__ = [];
var len__5749__auto___47551 = arguments.length;
var i__5750__auto___47552 = (0);
while(true){
if((i__5750__auto___47552 < len__5749__auto___47551)){
args__5755__auto__.push((arguments[i__5750__auto___47552]));
var G__47553 = (i__5750__auto___47552 + (1));
i__5750__auto___47552 = G__47553;
continue;
} else {
}
break;
}
var argseq__5756__auto__ = ((((1) < args__5755__auto__.length))?(new cljs.core.IndexedSeq(args__5755__auto__.slice((1)),(0),null)):null);
return ajax.core.TRACE.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__5756__auto__);
});
(ajax.core.TRACE.cljs$core$IFn$_invoke$arity$variadic = (function (uri,opts){
var f__46799__auto__ = cljs.core.first(opts);
return ajax.easy.easy_ajax_request(uri,"TRACE",(((f__46799__auto__ instanceof cljs.core.Keyword))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,opts):f__46799__auto__));
}));
(ajax.core.TRACE.cljs$lang$maxFixedArity = (1));
/** @this {Function} */
(ajax.core.TRACE.cljs$lang$applyTo = (function (seq47362){
var G__47363 = cljs.core.first(seq47362);
var seq47362__$1 = cljs.core.next(seq47362);
var self__5734__auto__ = this;
return self__5734__auto__.cljs$core$IFn$_invoke$arity$variadic(G__47363,seq47362__$1);
}));
/**
* accepts the URI and an optional map of options, options include:
* :handler - the handler function for successful operation
* should accept a single parameter which is the
* deserialized response
* :progress-handler - the handler function for progress events.
* this handler is only available when using the goog.net.XhrIo API
* :error-handler - the handler function for errors, should accept a
* map with keys :status and :status-text
* :format - the format for the request
* :response-format - the format for the response
* :params - a map of parameters that will be sent with the request
*/
ajax.core.PATCH = (function ajax$core$PATCH(var_args){
var args__5755__auto__ = [];
var len__5749__auto___47570 = arguments.length;
var i__5750__auto___47571 = (0);
while(true){
if((i__5750__auto___47571 < len__5749__auto___47570)){
args__5755__auto__.push((arguments[i__5750__auto___47571]));
var G__47572 = (i__5750__auto___47571 + (1));
i__5750__auto___47571 = G__47572;
continue;
} else {
}
break;
}
var argseq__5756__auto__ = ((((1) < args__5755__auto__.length))?(new cljs.core.IndexedSeq(args__5755__auto__.slice((1)),(0),null)):null);
return ajax.core.PATCH.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__5756__auto__);
});
(ajax.core.PATCH.cljs$core$IFn$_invoke$arity$variadic = (function (uri,opts){
var f__46799__auto__ = cljs.core.first(opts);
return ajax.easy.easy_ajax_request(uri,"PATCH",(((f__46799__auto__ instanceof cljs.core.Keyword))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,opts):f__46799__auto__));
}));
(ajax.core.PATCH.cljs$lang$maxFixedArity = (1));
/** @this {Function} */
(ajax.core.PATCH.cljs$lang$applyTo = (function (seq47387){
var G__47388 = cljs.core.first(seq47387);
var seq47387__$1 = cljs.core.next(seq47387);
var self__5734__auto__ = this;
return self__5734__auto__.cljs$core$IFn$_invoke$arity$variadic(G__47388,seq47387__$1);
}));
/**
* accepts the URI and an optional map of options, options include:
* :handler - the handler function for successful operation
* should accept a single parameter which is the
* deserialized response
* :progress-handler - the handler function for progress events.
* this handler is only available when using the goog.net.XhrIo API
* :error-handler - the handler function for errors, should accept a
* map with keys :status and :status-text
* :format - the format for the request
* :response-format - the format for the response
* :params - a map of parameters that will be sent with the request
*/
ajax.core.PURGE = (function ajax$core$PURGE(var_args){
var args__5755__auto__ = [];
var len__5749__auto___47575 = arguments.length;
var i__5750__auto___47576 = (0);
while(true){
if((i__5750__auto___47576 < len__5749__auto___47575)){
args__5755__auto__.push((arguments[i__5750__auto___47576]));
var G__47577 = (i__5750__auto___47576 + (1));
i__5750__auto___47576 = G__47577;
continue;
} else {
}
break;
}
var argseq__5756__auto__ = ((((1) < args__5755__auto__.length))?(new cljs.core.IndexedSeq(args__5755__auto__.slice((1)),(0),null)):null);
return ajax.core.PURGE.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__5756__auto__);
});
(ajax.core.PURGE.cljs$core$IFn$_invoke$arity$variadic = (function (uri,opts){
var f__46799__auto__ = cljs.core.first(opts);
return ajax.easy.easy_ajax_request(uri,"PURGE",(((f__46799__auto__ instanceof cljs.core.Keyword))?cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.hash_map,opts):f__46799__auto__));
}));
(ajax.core.PURGE.cljs$lang$maxFixedArity = (1));
/** @this {Function} */
(ajax.core.PURGE.cljs$lang$applyTo = (function (seq47412){
var G__47413 = cljs.core.first(seq47412);
var seq47412__$1 = cljs.core.next(seq47412);
var self__5734__auto__ = this;
return self__5734__auto__.cljs$core$IFn$_invoke$arity$variadic(G__47413,seq47412__$1);
}));
//# sourceMappingURL=ajax.core.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,237 @@
goog.provide('ajax.easy');
ajax.easy.default_formats = cljs.core.atom.cljs$core$IFn$_invoke$arity$1(new cljs.core.PersistentVector(null, 6, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, ["application/transit+json",ajax.transit.transit_response_format], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, ["application/transit+transit",ajax.transit.transit_response_format], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, ["application/json",ajax.json.json_response_format], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, ["text/plain",ajax.formats.text_response_format], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, ["text/html",ajax.formats.text_response_format], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, ["*/*",ajax.formats.raw_response_format], null)], null));
ajax.easy.detect_response_format = (function ajax$easy$detect_response_format(var_args){
var G__47193 = arguments.length;
switch (G__47193) {
case 0:
return ajax.easy.detect_response_format.cljs$core$IFn$_invoke$arity$0();
break;
case 1:
return ajax.easy.detect_response_format.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(ajax.easy.detect_response_format.cljs$core$IFn$_invoke$arity$0 = (function (){
return ajax.formats.detect_response_format(new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"response-format","response-format",1664465322),cljs.core.deref(ajax.easy.default_formats)], null));
}));
(ajax.easy.detect_response_format.cljs$core$IFn$_invoke$arity$1 = (function (opts){
return ajax.formats.detect_response_format(opts);
}));
(ajax.easy.detect_response_format.cljs$lang$maxFixedArity = 1);
/**
* Converts an easy API request format specifier to an `ajax-request`
* request format specifier.
*/
ajax.easy.keyword_request_format = (function ajax$easy$keyword_request_format(format,format_params){
if(cljs.core.map_QMARK_(format)){
return format;
} else {
if(cljs.core.fn_QMARK_(format)){
return new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"write","write",-1857649168),format], null);
} else {
if((format == null)){
return ajax.transit.transit_request_format.cljs$core$IFn$_invoke$arity$1(format_params);
} else {
var G__47195 = format;
var G__47195__$1 = (((G__47195 instanceof cljs.core.Keyword))?G__47195.fqn:null);
switch (G__47195__$1) {
case "transit":
return ajax.transit.transit_request_format.cljs$core$IFn$_invoke$arity$1(format_params);
break;
case "json":
return ajax.json.json_request_format();
break;
case "text":
return ajax.formats.text_request_format();
break;
case "raw":
return ajax.url.url_request_format.cljs$core$IFn$_invoke$arity$1(format_params);
break;
case "url":
return ajax.url.url_request_format.cljs$core$IFn$_invoke$arity$1(format_params);
break;
default:
return null;
}
}
}
}
});
ajax.easy.keyword_response_format_element = (function ajax$easy$keyword_response_format_element(format,format_params){
if(cljs.core.vector_QMARK_(format)){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.first(format),(function (){var G__47201 = cljs.core.second(format);
var G__47202 = format_params;
return (ajax.easy.keyword_response_format_element.cljs$core$IFn$_invoke$arity$2 ? ajax.easy.keyword_response_format_element.cljs$core$IFn$_invoke$arity$2(G__47201,G__47202) : ajax.easy.keyword_response_format_element.call(null,G__47201,G__47202));
})()], null);
} else {
if(cljs.core.map_QMARK_(format)){
return format;
} else {
if(cljs.core.fn_QMARK_(format)){
return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"read","read",1140058661),format,new cljs.core.Keyword(null,"description","description",-1428560544),"custom"], null);
} else {
if((format == null)){
return ajax.easy.detect_response_format.cljs$core$IFn$_invoke$arity$0();
} else {
var G__47218 = format;
var G__47218__$1 = (((G__47218 instanceof cljs.core.Keyword))?G__47218.fqn:null);
switch (G__47218__$1) {
case "transit":
return ajax.transit.transit_response_format.cljs$core$IFn$_invoke$arity$1(format_params);
break;
case "json":
return ajax.json.json_response_format(format_params);
break;
case "text":
return (ajax.formats.text_response_format.cljs$core$IFn$_invoke$arity$0 ? ajax.formats.text_response_format.cljs$core$IFn$_invoke$arity$0() : ajax.formats.text_response_format.call(null));
break;
case "ring":
return ajax.ring.ring_response_format.cljs$core$IFn$_invoke$arity$0();
break;
case "raw":
return ajax.formats.raw_response_format.cljs$core$IFn$_invoke$arity$0();
break;
case "detect":
return ajax.easy.detect_response_format.cljs$core$IFn$_invoke$arity$0();
break;
default:
return null;
}
}
}
}
}
});
/**
* Converts an easy API format specifier to an `ajax-request`
* format specifier. Mostly this is just a case of replacing `:json`
* with `json-response-format`. However, it gets complex when you
* specify a detection format such as `[["application/madeup" :json]]`.
*/
ajax.easy.keyword_response_format = (function ajax$easy$keyword_response_format(format,format_params){
if(cljs.core.vector_QMARK_(format)){
return cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.vector,cljs.core.map.cljs$core$IFn$_invoke$arity$2((function (p1__47236_SHARP_){
return ajax.easy.keyword_response_format_element(p1__47236_SHARP_,format_params);
}),format));
} else {
return ajax.easy.keyword_response_format_element(format,format_params);
}
});
ajax.easy.print_response = (function ajax$easy$print_response(response){
return cljs.core.println.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["CLJS-AJAX response:",response], 0));
});
/**
* This gets called if you forget to attach a handler to an easy
* API function.
*/
ajax.easy.default_handler = cljs.core.atom.cljs$core$IFn$_invoke$arity$1(ajax.easy.print_response);
ajax.easy.print_error_response = (function ajax$easy$print_error_response(response){
if((typeof console !== 'undefined')){
return console.error(response);
} else {
if((typeof window !== 'undefined')){
return window.alert(cljs.core.str.cljs$core$IFn$_invoke$arity$1(response));
} else {
return cljs.core.println.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["CLJS-AJAX ERROR:",response], 0));
}
}
});
/**
* This will be called when errors occur if you don't supply
* an error handler to the easy API functions. If you don't
* want it writing errors to the console (or worse, flashing up
* alerts), make sure you always handle errors.
*/
ajax.easy.default_error_handler = cljs.core.atom.cljs$core$IFn$_invoke$arity$1(ajax.easy.print_error_response);
/**
* Converts easy API handlers to a `ajax-request` handler
*/
ajax.easy.transform_handler = (function ajax$easy$transform_handler(p__47240){
var map__47244 = p__47240;
var map__47244__$1 = cljs.core.__destructure_map(map__47244);
var handler = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47244__$1,new cljs.core.Keyword(null,"handler","handler",-195596612));
var error_handler = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47244__$1,new cljs.core.Keyword(null,"error-handler","error-handler",-484945776));
var finally$ = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47244__$1,new cljs.core.Keyword(null,"finally","finally",1589088705));
var h = (function (){var or__5025__auto__ = handler;
if(cljs.core.truth_(or__5025__auto__)){
return or__5025__auto__;
} else {
return cljs.core.deref(ajax.easy.default_handler);
}
})();
var e = (function (){var or__5025__auto__ = error_handler;
if(cljs.core.truth_(or__5025__auto__)){
return or__5025__auto__;
} else {
return cljs.core.deref(ajax.easy.default_error_handler);
}
})();
return (function ajax$easy$transform_handler_$_easy_handler(p__47245){
var vec__47246 = p__47245;
var ok = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__47246,(0),null);
var result = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__47246,(1),null);
var fexpr__47249_47278 = (cljs.core.truth_(ok)?h:e);
(fexpr__47249_47278.cljs$core$IFn$_invoke$arity$1 ? fexpr__47249_47278.cljs$core$IFn$_invoke$arity$1(result) : fexpr__47249_47278.call(null,result));
if(cljs.core.fn_QMARK_(finally$)){
return (finally$.cljs$core$IFn$_invoke$arity$0 ? finally$.cljs$core$IFn$_invoke$arity$0() : finally$.call(null));
} else {
return null;
}
});
});
/**
* Note that if you call GET, POST et al, this function gets
* called and will include Transit code in your JS.
* If you don't want this to happen, use ajax-request directly
* (and use advanced optimisation).
*/
ajax.easy.transform_opts = (function ajax$easy$transform_opts(p__47250){
var map__47251 = p__47250;
var map__47251__$1 = cljs.core.__destructure_map(map__47251);
var opts = map__47251__$1;
var method = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47251__$1,new cljs.core.Keyword(null,"method","method",55703592));
var format = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47251__$1,new cljs.core.Keyword(null,"format","format",-1306924766));
var response_format = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47251__$1,new cljs.core.Keyword(null,"response-format","response-format",1664465322));
var params = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47251__$1,new cljs.core.Keyword(null,"params","params",710516235));
var body = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47251__$1,new cljs.core.Keyword(null,"body","body",-2049205669));
var needs_format = (((body == null)) && (cljs.core.not_EQ_.cljs$core$IFn$_invoke$arity$2(method,"GET")));
var rf = (cljs.core.truth_((function (){var or__5025__auto__ = format;
if(cljs.core.truth_(or__5025__auto__)){
return or__5025__auto__;
} else {
return needs_format;
}
})())?ajax.easy.keyword_request_format(format,opts):null);
return cljs.core.assoc.cljs$core$IFn$_invoke$arity$variadic(opts,new cljs.core.Keyword(null,"handler","handler",-195596612),ajax.easy.transform_handler(opts),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new cljs.core.Keyword(null,"format","format",-1306924766),rf,new cljs.core.Keyword(null,"response-format","response-format",1664465322),ajax.easy.keyword_response_format(response_format,opts)], 0));
});
ajax.easy.easy_ajax_request = (function ajax$easy$easy_ajax_request(uri,method,opts){
return ajax.simple.ajax_request(ajax.easy.transform_opts(cljs.core.assoc.cljs$core$IFn$_invoke$arity$variadic(opts,new cljs.core.Keyword(null,"uri","uri",-774711847),uri,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new cljs.core.Keyword(null,"method","method",55703592),method], 0))));
});
//# sourceMappingURL=ajax.easy.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,122 @@
goog.provide('ajax.formats');
/**
* This will literally return whatever the underlying implementation
* considers has been sent. Obviously, this is highly implementation
* dependent, gives different results depending on your platform but
* is nonetheless really rather useful.
*/
ajax.formats.raw_response_format = (function ajax$formats$raw_response_format(var_args){
var G__47089 = arguments.length;
switch (G__47089) {
case 0:
return ajax.formats.raw_response_format.cljs$core$IFn$_invoke$arity$0();
break;
case 1:
return ajax.formats.raw_response_format.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(ajax.formats.raw_response_format.cljs$core$IFn$_invoke$arity$0 = (function (){
return ajax.interceptors.map__GT_ResponseFormat(new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"read","read",1140058661),ajax.protocols._body,new cljs.core.Keyword(null,"description","description",-1428560544),"raw text",new cljs.core.Keyword(null,"content-type","content-type",-508222634),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, ["*/*"], null)], null));
}));
(ajax.formats.raw_response_format.cljs$core$IFn$_invoke$arity$1 = (function (_){
return ajax.formats.raw_response_format.cljs$core$IFn$_invoke$arity$0();
}));
(ajax.formats.raw_response_format.cljs$lang$maxFixedArity = 1);
ajax.formats.text_request_format = (function ajax$formats$text_request_format(){
return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"write","write",-1857649168),ajax.util.to_utf8_writer(cljs.core.identity),new cljs.core.Keyword(null,"content-type","content-type",-508222634),"text/plain; charset=utf-8"], null);
});
ajax.formats.text_response_format = ajax.formats.raw_response_format;
/**
* Converts one of a number of types to a response format.
* Note that it processes `[text format]` the same as `format`,
* which makes it easier to work with detection vectors such as
* `default-formats`.
*
* It also supports providing formats as raw functions. I don't
* know if anyone has ever used this.
*/
ajax.formats.get_format = (function ajax$formats$get_format(request,format_entry){
if((((format_entry == null)) || (cljs.core.map_QMARK_(format_entry)))){
return format_entry;
} else {
if(cljs.core.vector_QMARK_(format_entry)){
var G__47097 = request;
var G__47098 = cljs.core.second(format_entry);
return (ajax.formats.get_format.cljs$core$IFn$_invoke$arity$2 ? ajax.formats.get_format.cljs$core$IFn$_invoke$arity$2(G__47097,G__47098) : ajax.formats.get_format.call(null,G__47097,G__47098));
} else {
return (format_entry.cljs$core$IFn$_invoke$arity$1 ? format_entry.cljs$core$IFn$_invoke$arity$1(request) : format_entry.call(null,request));
}
}
});
ajax.formats.get_accept_entries = (function ajax$formats$get_accept_entries(request,format_entry){
var fe = ((cljs.core.vector_QMARK_(format_entry))?cljs.core.first(format_entry):new cljs.core.Keyword(null,"content-type","content-type",-508222634).cljs$core$IFn$_invoke$arity$1(ajax.formats.get_format(request,format_entry)));
if((fe == null)){
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, ["*/*"], null);
} else {
if(typeof fe === 'string'){
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [fe], null);
} else {
return fe;
}
}
});
ajax.formats.content_type_matches = (function ajax$formats$content_type_matches(content_type,accept){
return ((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(accept,"*/*")) || ((content_type.indexOf(accept) >= (0))));
});
ajax.formats.detect_content_type = (function ajax$formats$detect_content_type(content_type,request,format_entry){
var accept = ajax.formats.get_accept_entries(request,format_entry);
return cljs.core.some((function (p1__47110_SHARP_){
return ajax.formats.content_type_matches(content_type,p1__47110_SHARP_);
}),accept);
});
ajax.formats.get_default_format = (function ajax$formats$get_default_format(response,p__47111){
var map__47112 = p__47111;
var map__47112__$1 = cljs.core.__destructure_map(map__47112);
var request = map__47112__$1;
var response_format = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47112__$1,new cljs.core.Keyword(null,"response-format","response-format",1664465322));
var content_type = ajax.util.get_content_type(response);
var accepted_format_QMARK_ = (function ajax$formats$get_default_format_$_accepted_format_QMARK_(format_entry){
return ajax.formats.detect_content_type(content_type,request,format_entry);
});
return ajax.formats.get_format(request,cljs.core.first(cljs.core.filter.cljs$core$IFn$_invoke$arity$2(accepted_format_QMARK_,response_format)));
});
ajax.formats.detect_response_format_read = (function ajax$formats$detect_response_format_read(request){
return (function ajax$formats$detect_response_format_read_$_detect_response_format(response){
var format = ajax.formats.get_default_format(response,request);
var fexpr__47118 = new cljs.core.Keyword(null,"read","read",1140058661).cljs$core$IFn$_invoke$arity$1(format);
return (fexpr__47118.cljs$core$IFn$_invoke$arity$1 ? fexpr__47118.cljs$core$IFn$_invoke$arity$1(response) : fexpr__47118.call(null,response));
});
});
ajax.formats.accept_header = (function ajax$formats$accept_header(p__47120){
var map__47121 = p__47120;
var map__47121__$1 = cljs.core.__destructure_map(map__47121);
var request = map__47121__$1;
var response_format = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47121__$1,new cljs.core.Keyword(null,"response-format","response-format",1664465322));
var formats = ((cljs.core.vector_QMARK_(response_format))?response_format:new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [response_format], null));
return cljs.core.mapcat.cljs$core$IFn$_invoke$arity$variadic((function (p1__47119_SHARP_){
return ajax.formats.get_accept_entries(request,p1__47119_SHARP_);
}),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([formats], 0));
});
/**
* NB This version of the response format doesn't have a zero
* arity version. This is because it would involve pulling
* in every dependency. Instead, core.cljc adds it in.
*/
ajax.formats.detect_response_format = (function ajax$formats$detect_response_format(opts){
var accept = ajax.formats.accept_header(opts);
return ajax.interceptors.map__GT_ResponseFormat(new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"read","read",1140058661),ajax.formats.detect_response_format_read(opts),new cljs.core.Keyword(null,"format","format",-1306924766),["(from ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(accept),")"].join(''),new cljs.core.Keyword(null,"content-type","content-type",-508222634),accept], null));
});
//# sourceMappingURL=ajax.formats.js.map

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,93 @@
goog.provide('ajax.json');
ajax.json.write_json_native = (function ajax$json$write_json_native(data){
return JSON.stringify(cljs.core.clj__GT_js(data));
});
ajax.json.read_json_native = (function ajax$json$read_json_native(raw,keywords_QMARK_,text){
var result_raw = JSON.parse(text);
if(cljs.core.truth_(raw)){
return result_raw;
} else {
return cljs.core.js__GT_clj.cljs$core$IFn$_invoke$arity$variadic(result_raw,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new cljs.core.Keyword(null,"keywordize-keys","keywordize-keys",1310784252),keywords_QMARK_], 0));
}
});
ajax.json.read_json_transit = (function ajax$json$read_json_transit(raw,keywords_QMARK_,text){
if(cljs.core.truth_(raw)){
return JSON.parse(text);
} else {
var edn = cognitect.transit.read(cognitect.transit.reader.cljs$core$IFn$_invoke$arity$1(new cljs.core.Keyword(null,"json","json",1279968570)),text);
if(cljs.core.truth_(keywords_QMARK_)){
return clojure.walk.keywordize_keys(edn);
} else {
return edn;
}
}
});
ajax.json.make_json_request_format = (function ajax$json$make_json_request_format(write_json){
return (function ajax$json$make_json_request_format_$_json_request_format(){
return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"write","write",-1857649168),write_json,new cljs.core.Keyword(null,"content-type","content-type",-508222634),"application/json"], null);
});
});
ajax.json.strip_prefix = (function ajax$json$strip_prefix(prefix,text){
if(cljs.core.truth_((function (){var and__5023__auto__ = prefix;
if(cljs.core.truth_(and__5023__auto__)){
return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2((0),text.indexOf(prefix));
} else {
return and__5023__auto__;
}
})())){
return text.substring(prefix.length);
} else {
return text;
}
});
/**
* Create a json request format given `read-json` function.
*/
ajax.json.make_json_response_format = (function ajax$json$make_json_response_format(read_json){
return (function() {
var ajax$json$make_json_response_format_$_json_response_format = null;
var ajax$json$make_json_response_format_$_json_response_format__0 = (function (){
return ajax$json$make_json_response_format_$_json_response_format.cljs$core$IFn$_invoke$arity$1(cljs.core.PersistentArrayMap.EMPTY);
});
var ajax$json$make_json_response_format_$_json_response_format__1 = (function (p__47101){
var map__47102 = p__47101;
var map__47102__$1 = cljs.core.__destructure_map(map__47102);
var prefix = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47102__$1,new cljs.core.Keyword(null,"prefix","prefix",-265908465));
var keywords_QMARK_ = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47102__$1,new cljs.core.Keyword(null,"keywords?","keywords?",764949733));
var raw = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47102__$1,new cljs.core.Keyword(null,"raw","raw",1604651272));
return ajax.interceptors.map__GT_ResponseFormat(new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"read","read",1140058661),(function ajax$json$make_json_response_format_$_json_response_format_$_json_read_response_format(xhrio){
var G__47104 = raw;
var G__47105 = keywords_QMARK_;
var G__47106 = ajax.json.strip_prefix(prefix,ajax.protocols._body(xhrio));
return (read_json.cljs$core$IFn$_invoke$arity$3 ? read_json.cljs$core$IFn$_invoke$arity$3(G__47104,G__47105,G__47106) : read_json.call(null,G__47104,G__47105,G__47106));
}),new cljs.core.Keyword(null,"description","description",-1428560544),["JSON",(cljs.core.truth_(prefix)?[" prefix '",cljs.core.str.cljs$core$IFn$_invoke$arity$1(prefix),"'"].join(''):null),(cljs.core.truth_(keywords_QMARK_)?" keywordize":null)].join(''),new cljs.core.Keyword(null,"content-type","content-type",-508222634),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, ["application/json"], null)], null));
});
ajax$json$make_json_response_format_$_json_response_format = function(p__47101){
switch(arguments.length){
case 0:
return ajax$json$make_json_response_format_$_json_response_format__0.call(this);
case 1:
return ajax$json$make_json_response_format_$_json_response_format__1.call(this,p__47101);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
ajax$json$make_json_response_format_$_json_response_format.cljs$core$IFn$_invoke$arity$0 = ajax$json$make_json_response_format_$_json_response_format__0;
ajax$json$make_json_response_format_$_json_response_format.cljs$core$IFn$_invoke$arity$1 = ajax$json$make_json_response_format_$_json_response_format__1;
return ajax$json$make_json_response_format_$_json_response_format;
})()
});
/**
* Returns a JSON response format using the native JSON
* implementation. Options include
* :keywords? Returns the keys as keywords
* :prefix A prefix that needs to be stripped off. This is to
* combat JSON hijacking. If you're using JSON with GET request,
* you should think about using this.
* http://stackoverflow.com/questions/2669690/why-does-google-prepend-while1-to-their-json-responses
* http://haacked.com/archive/2009/06/24/json-hijacking.aspx
*/
ajax.json.json_response_format = ajax.json.make_json_response_format(ajax.json.read_json_native);
ajax.json.json_request_format = ajax.json.make_json_request_format(ajax.json.write_json_native);
ajax.json.safe_json_request_format = ajax.json.make_json_response_format(ajax.json.read_json_transit);
//# sourceMappingURL=ajax.json.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,572 @@
goog.provide('ajax.protocols');
/**
* An abstraction for a javascript class that implements
* Ajax calls.
* @interface
*/
ajax.protocols.AjaxImpl = function(){};
var ajax$protocols$AjaxImpl$_js_ajax_request$dyn_45329 = (function (this$,request,handler){
var x__5373__auto__ = (((this$ == null))?null:this$);
var m__5374__auto__ = (ajax.protocols._js_ajax_request[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$3 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$3(this$,request,handler) : m__5374__auto__.call(null,this$,request,handler));
} else {
var m__5372__auto__ = (ajax.protocols._js_ajax_request["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$3 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$3(this$,request,handler) : m__5372__auto__.call(null,this$,request,handler));
} else {
throw cljs.core.missing_protocol("AjaxImpl.-js-ajax-request",this$);
}
}
});
/**
* Makes an actual ajax request. All parameters except opts
* are in JS format. Should return an AjaxRequest.
*/
ajax.protocols._js_ajax_request = (function ajax$protocols$_js_ajax_request(this$,request,handler){
if((((!((this$ == null)))) && ((!((this$.ajax$protocols$AjaxImpl$_js_ajax_request$arity$3 == null)))))){
return this$.ajax$protocols$AjaxImpl$_js_ajax_request$arity$3(this$,request,handler);
} else {
return ajax$protocols$AjaxImpl$_js_ajax_request$dyn_45329(this$,request,handler);
}
});
/**
* An abstraction for a running ajax request.
* @interface
*/
ajax.protocols.AjaxRequest = function(){};
var ajax$protocols$AjaxRequest$_abort$dyn_45330 = (function (this$){
var x__5373__auto__ = (((this$ == null))?null:this$);
var m__5374__auto__ = (ajax.protocols._abort[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$1(this$) : m__5374__auto__.call(null,this$));
} else {
var m__5372__auto__ = (ajax.protocols._abort["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$1(this$) : m__5372__auto__.call(null,this$));
} else {
throw cljs.core.missing_protocol("AjaxRequest.-abort",this$);
}
}
});
/**
* Aborts a running ajax request, if possible.
*/
ajax.protocols._abort = (function ajax$protocols$_abort(this$){
if((((!((this$ == null)))) && ((!((this$.ajax$protocols$AjaxRequest$_abort$arity$1 == null)))))){
return this$.ajax$protocols$AjaxRequest$_abort$arity$1(this$);
} else {
return ajax$protocols$AjaxRequest$_abort$dyn_45330(this$);
}
});
/**
* An abstraction for an ajax response.
* @interface
*/
ajax.protocols.AjaxResponse = function(){};
var ajax$protocols$AjaxResponse$_status$dyn_45335 = (function (this$){
var x__5373__auto__ = (((this$ == null))?null:this$);
var m__5374__auto__ = (ajax.protocols._status[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$1(this$) : m__5374__auto__.call(null,this$));
} else {
var m__5372__auto__ = (ajax.protocols._status["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$1(this$) : m__5372__auto__.call(null,this$));
} else {
throw cljs.core.missing_protocol("AjaxResponse.-status",this$);
}
}
});
/**
* Returns the HTTP Status of the response as an integer.
*/
ajax.protocols._status = (function ajax$protocols$_status(this$){
if((((!((this$ == null)))) && ((!((this$.ajax$protocols$AjaxResponse$_status$arity$1 == null)))))){
return this$.ajax$protocols$AjaxResponse$_status$arity$1(this$);
} else {
return ajax$protocols$AjaxResponse$_status$dyn_45335(this$);
}
});
var ajax$protocols$AjaxResponse$_status_text$dyn_45336 = (function (this$){
var x__5373__auto__ = (((this$ == null))?null:this$);
var m__5374__auto__ = (ajax.protocols._status_text[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$1(this$) : m__5374__auto__.call(null,this$));
} else {
var m__5372__auto__ = (ajax.protocols._status_text["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$1(this$) : m__5372__auto__.call(null,this$));
} else {
throw cljs.core.missing_protocol("AjaxResponse.-status-text",this$);
}
}
});
/**
* Returns the HTTP Status Text of the response as a string.
*/
ajax.protocols._status_text = (function ajax$protocols$_status_text(this$){
if((((!((this$ == null)))) && ((!((this$.ajax$protocols$AjaxResponse$_status_text$arity$1 == null)))))){
return this$.ajax$protocols$AjaxResponse$_status_text$arity$1(this$);
} else {
return ajax$protocols$AjaxResponse$_status_text$dyn_45336(this$);
}
});
var ajax$protocols$AjaxResponse$_get_all_headers$dyn_45337 = (function (this$){
var x__5373__auto__ = (((this$ == null))?null:this$);
var m__5374__auto__ = (ajax.protocols._get_all_headers[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$1(this$) : m__5374__auto__.call(null,this$));
} else {
var m__5372__auto__ = (ajax.protocols._get_all_headers["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$1(this$) : m__5372__auto__.call(null,this$));
} else {
throw cljs.core.missing_protocol("AjaxResponse.-get-all-headers",this$);
}
}
});
/**
* Returns all headers as a map.
*/
ajax.protocols._get_all_headers = (function ajax$protocols$_get_all_headers(this$){
if((((!((this$ == null)))) && ((!((this$.ajax$protocols$AjaxResponse$_get_all_headers$arity$1 == null)))))){
return this$.ajax$protocols$AjaxResponse$_get_all_headers$arity$1(this$);
} else {
return ajax$protocols$AjaxResponse$_get_all_headers$dyn_45337(this$);
}
});
var ajax$protocols$AjaxResponse$_body$dyn_45338 = (function (this$){
var x__5373__auto__ = (((this$ == null))?null:this$);
var m__5374__auto__ = (ajax.protocols._body[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$1(this$) : m__5374__auto__.call(null,this$));
} else {
var m__5372__auto__ = (ajax.protocols._body["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$1(this$) : m__5372__auto__.call(null,this$));
} else {
throw cljs.core.missing_protocol("AjaxResponse.-body",this$);
}
}
});
/**
* Returns the response body as a string or as type specified in response-format such as a blob or arraybuffer.
*/
ajax.protocols._body = (function ajax$protocols$_body(this$){
if((((!((this$ == null)))) && ((!((this$.ajax$protocols$AjaxResponse$_body$arity$1 == null)))))){
return this$.ajax$protocols$AjaxResponse$_body$arity$1(this$);
} else {
return ajax$protocols$AjaxResponse$_body$dyn_45338(this$);
}
});
var ajax$protocols$AjaxResponse$_get_response_header$dyn_45339 = (function (this$,header){
var x__5373__auto__ = (((this$ == null))?null:this$);
var m__5374__auto__ = (ajax.protocols._get_response_header[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$2 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$2(this$,header) : m__5374__auto__.call(null,this$,header));
} else {
var m__5372__auto__ = (ajax.protocols._get_response_header["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$2 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$2(this$,header) : m__5372__auto__.call(null,this$,header));
} else {
throw cljs.core.missing_protocol("AjaxResponse.-get-response-header",this$);
}
}
});
/**
* Gets the specified response header (specified by a string) as a string.
*/
ajax.protocols._get_response_header = (function ajax$protocols$_get_response_header(this$,header){
if((((!((this$ == null)))) && ((!((this$.ajax$protocols$AjaxResponse$_get_response_header$arity$2 == null)))))){
return this$.ajax$protocols$AjaxResponse$_get_response_header$arity$2(this$,header);
} else {
return ajax$protocols$AjaxResponse$_get_response_header$dyn_45339(this$,header);
}
});
var ajax$protocols$AjaxResponse$_was_aborted$dyn_45343 = (function (this$){
var x__5373__auto__ = (((this$ == null))?null:this$);
var m__5374__auto__ = (ajax.protocols._was_aborted[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$1(this$) : m__5374__auto__.call(null,this$));
} else {
var m__5372__auto__ = (ajax.protocols._was_aborted["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$1(this$) : m__5372__auto__.call(null,this$));
} else {
throw cljs.core.missing_protocol("AjaxResponse.-was-aborted",this$);
}
}
});
/**
* Was the response aborted.
*/
ajax.protocols._was_aborted = (function ajax$protocols$_was_aborted(this$){
if((((!((this$ == null)))) && ((!((this$.ajax$protocols$AjaxResponse$_was_aborted$arity$1 == null)))))){
return this$.ajax$protocols$AjaxResponse$_was_aborted$arity$1(this$);
} else {
return ajax$protocols$AjaxResponse$_was_aborted$dyn_45343(this$);
}
});
/**
* An abstraction for something that processes requests and responses.
* @interface
*/
ajax.protocols.Interceptor = function(){};
var ajax$protocols$Interceptor$_process_request$dyn_45345 = (function (this$,request){
var x__5373__auto__ = (((this$ == null))?null:this$);
var m__5374__auto__ = (ajax.protocols._process_request[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$2 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$2(this$,request) : m__5374__auto__.call(null,this$,request));
} else {
var m__5372__auto__ = (ajax.protocols._process_request["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$2 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$2(this$,request) : m__5372__auto__.call(null,this$,request));
} else {
throw cljs.core.missing_protocol("Interceptor.-process-request",this$);
}
}
});
/**
* Transforms the opts
*/
ajax.protocols._process_request = (function ajax$protocols$_process_request(this$,request){
if((((!((this$ == null)))) && ((!((this$.ajax$protocols$Interceptor$_process_request$arity$2 == null)))))){
return this$.ajax$protocols$Interceptor$_process_request$arity$2(this$,request);
} else {
return ajax$protocols$Interceptor$_process_request$dyn_45345(this$,request);
}
});
var ajax$protocols$Interceptor$_process_response$dyn_45346 = (function (this$,response){
var x__5373__auto__ = (((this$ == null))?null:this$);
var m__5374__auto__ = (ajax.protocols._process_response[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$2 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$2(this$,response) : m__5374__auto__.call(null,this$,response));
} else {
var m__5372__auto__ = (ajax.protocols._process_response["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$2 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$2(this$,response) : m__5372__auto__.call(null,this$,response));
} else {
throw cljs.core.missing_protocol("Interceptor.-process-response",this$);
}
}
});
/**
* Transforms the raw response (an implementation of AjaxResponse)
*/
ajax.protocols._process_response = (function ajax$protocols$_process_response(this$,response){
if((((!((this$ == null)))) && ((!((this$.ajax$protocols$Interceptor$_process_response$arity$2 == null)))))){
return this$.ajax$protocols$Interceptor$_process_response$arity$2(this$,response);
} else {
return ajax$protocols$Interceptor$_process_response$dyn_45346(this$,response);
}
});
/**
* @constructor
* @implements {cljs.core.IRecord}
* @implements {cljs.core.IKVReduce}
* @implements {cljs.core.IEquiv}
* @implements {cljs.core.IHash}
* @implements {cljs.core.ICollection}
* @implements {cljs.core.ICounted}
* @implements {ajax.protocols.AjaxResponse}
* @implements {cljs.core.ISeqable}
* @implements {cljs.core.IMeta}
* @implements {cljs.core.ICloneable}
* @implements {cljs.core.IPrintWithWriter}
* @implements {cljs.core.IIterable}
* @implements {cljs.core.IWithMeta}
* @implements {cljs.core.IAssociative}
* @implements {cljs.core.IMap}
* @implements {cljs.core.ILookup}
*/
ajax.protocols.Response = (function (status,body,status_text,headers,was_aborted,__meta,__extmap,__hash){
this.status = status;
this.body = body;
this.status_text = status_text;
this.headers = headers;
this.was_aborted = was_aborted;
this.__meta = __meta;
this.__extmap = __extmap;
this.__hash = __hash;
this.cljs$lang$protocol_mask$partition0$ = 2230716170;
this.cljs$lang$protocol_mask$partition1$ = 139264;
});
(ajax.protocols.Response.prototype.cljs$core$ILookup$_lookup$arity$2 = (function (this__5323__auto__,k__5324__auto__){
var self__ = this;
var this__5323__auto____$1 = this;
return this__5323__auto____$1.cljs$core$ILookup$_lookup$arity$3(null,k__5324__auto__,null);
}));
(ajax.protocols.Response.prototype.cljs$core$ILookup$_lookup$arity$3 = (function (this__5325__auto__,k45091,else__5326__auto__){
var self__ = this;
var this__5325__auto____$1 = this;
var G__45096 = k45091;
var G__45096__$1 = (((G__45096 instanceof cljs.core.Keyword))?G__45096.fqn:null);
switch (G__45096__$1) {
case "status":
return self__.status;
break;
case "body":
return self__.body;
break;
case "status-text":
return self__.status_text;
break;
case "headers":
return self__.headers;
break;
case "was-aborted":
return self__.was_aborted;
break;
default:
return cljs.core.get.cljs$core$IFn$_invoke$arity$3(self__.__extmap,k45091,else__5326__auto__);
}
}));
(ajax.protocols.Response.prototype.cljs$core$IKVReduce$_kv_reduce$arity$3 = (function (this__5343__auto__,f__5344__auto__,init__5345__auto__){
var self__ = this;
var this__5343__auto____$1 = this;
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (ret__5346__auto__,p__45098){
var vec__45099 = p__45098;
var k__5347__auto__ = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__45099,(0),null);
var v__5348__auto__ = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__45099,(1),null);
return (f__5344__auto__.cljs$core$IFn$_invoke$arity$3 ? f__5344__auto__.cljs$core$IFn$_invoke$arity$3(ret__5346__auto__,k__5347__auto__,v__5348__auto__) : f__5344__auto__.call(null,ret__5346__auto__,k__5347__auto__,v__5348__auto__));
}),init__5345__auto__,this__5343__auto____$1);
}));
(ajax.protocols.Response.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (this__5338__auto__,writer__5339__auto__,opts__5340__auto__){
var self__ = this;
var this__5338__auto____$1 = this;
var pr_pair__5341__auto__ = (function (keyval__5342__auto__){
return cljs.core.pr_sequential_writer(writer__5339__auto__,cljs.core.pr_writer,""," ","",opts__5340__auto__,keyval__5342__auto__);
});
return cljs.core.pr_sequential_writer(writer__5339__auto__,pr_pair__5341__auto__,"#ajax.protocols.Response{",", ","}",opts__5340__auto__,cljs.core.concat.cljs$core$IFn$_invoke$arity$2(new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"status","status",-1997798413),self__.status],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"body","body",-2049205669),self__.body],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"status-text","status-text",-1834235478),self__.status_text],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"headers","headers",-835030129),self__.headers],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"was-aborted","was-aborted",-2120084828),self__.was_aborted],null))], null),self__.__extmap));
}));
(ajax.protocols.Response.prototype.cljs$core$IIterable$_iterator$arity$1 = (function (G__45090){
var self__ = this;
var G__45090__$1 = this;
return (new cljs.core.RecordIter((0),G__45090__$1,5,new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"status","status",-1997798413),new cljs.core.Keyword(null,"body","body",-2049205669),new cljs.core.Keyword(null,"status-text","status-text",-1834235478),new cljs.core.Keyword(null,"headers","headers",-835030129),new cljs.core.Keyword(null,"was-aborted","was-aborted",-2120084828)], null),(cljs.core.truth_(self__.__extmap)?cljs.core._iterator(self__.__extmap):cljs.core.nil_iter())));
}));
(ajax.protocols.Response.prototype.cljs$core$IMeta$_meta$arity$1 = (function (this__5321__auto__){
var self__ = this;
var this__5321__auto____$1 = this;
return self__.__meta;
}));
(ajax.protocols.Response.prototype.cljs$core$ICloneable$_clone$arity$1 = (function (this__5318__auto__){
var self__ = this;
var this__5318__auto____$1 = this;
return (new ajax.protocols.Response(self__.status,self__.body,self__.status_text,self__.headers,self__.was_aborted,self__.__meta,self__.__extmap,self__.__hash));
}));
(ajax.protocols.Response.prototype.cljs$core$ICounted$_count$arity$1 = (function (this__5327__auto__){
var self__ = this;
var this__5327__auto____$1 = this;
return (5 + cljs.core.count(self__.__extmap));
}));
(ajax.protocols.Response.prototype.cljs$core$IHash$_hash$arity$1 = (function (this__5319__auto__){
var self__ = this;
var this__5319__auto____$1 = this;
var h__5134__auto__ = self__.__hash;
if((!((h__5134__auto__ == null)))){
return h__5134__auto__;
} else {
var h__5134__auto____$1 = (function (coll__5320__auto__){
return (-473222333 ^ cljs.core.hash_unordered_coll(coll__5320__auto__));
})(this__5319__auto____$1);
(self__.__hash = h__5134__auto____$1);
return h__5134__auto____$1;
}
}));
(ajax.protocols.Response.prototype.cljs$core$IEquiv$_equiv$arity$2 = (function (this45092,other45093){
var self__ = this;
var this45092__$1 = this;
return (((!((other45093 == null)))) && ((((this45092__$1.constructor === other45093.constructor)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this45092__$1.status,other45093.status)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this45092__$1.body,other45093.body)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this45092__$1.status_text,other45093.status_text)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this45092__$1.headers,other45093.headers)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this45092__$1.was_aborted,other45093.was_aborted)) && (cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this45092__$1.__extmap,other45093.__extmap)))))))))))))));
}));
(ajax.protocols.Response.prototype.ajax$protocols$AjaxResponse$ = cljs.core.PROTOCOL_SENTINEL);
(ajax.protocols.Response.prototype.ajax$protocols$AjaxResponse$_body$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return new cljs.core.Keyword(null,"body","body",-2049205669).cljs$core$IFn$_invoke$arity$1(this$__$1);
}));
(ajax.protocols.Response.prototype.ajax$protocols$AjaxResponse$_status$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return new cljs.core.Keyword(null,"status","status",-1997798413).cljs$core$IFn$_invoke$arity$1(this$__$1);
}));
(ajax.protocols.Response.prototype.ajax$protocols$AjaxResponse$_status_text$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return new cljs.core.Keyword(null,"status-text","status-text",-1834235478).cljs$core$IFn$_invoke$arity$1(this$__$1);
}));
(ajax.protocols.Response.prototype.ajax$protocols$AjaxResponse$_get_all_headers$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return new cljs.core.Keyword(null,"headers","headers",-835030129).cljs$core$IFn$_invoke$arity$1(this$__$1);
}));
(ajax.protocols.Response.prototype.ajax$protocols$AjaxResponse$_get_response_header$arity$2 = (function (this$,header){
var self__ = this;
var this$__$1 = this;
return cljs.core.get.cljs$core$IFn$_invoke$arity$2(new cljs.core.Keyword(null,"headers","headers",-835030129).cljs$core$IFn$_invoke$arity$1(this$__$1),header);
}));
(ajax.protocols.Response.prototype.ajax$protocols$AjaxResponse$_was_aborted$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return new cljs.core.Keyword(null,"was-aborted","was-aborted",-2120084828).cljs$core$IFn$_invoke$arity$1(this$__$1);
}));
(ajax.protocols.Response.prototype.cljs$core$IMap$_dissoc$arity$2 = (function (this__5333__auto__,k__5334__auto__){
var self__ = this;
var this__5333__auto____$1 = this;
if(cljs.core.contains_QMARK_(new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 5, [new cljs.core.Keyword(null,"was-aborted","was-aborted",-2120084828),null,new cljs.core.Keyword(null,"status-text","status-text",-1834235478),null,new cljs.core.Keyword(null,"headers","headers",-835030129),null,new cljs.core.Keyword(null,"status","status",-1997798413),null,new cljs.core.Keyword(null,"body","body",-2049205669),null], null), null),k__5334__auto__)){
return cljs.core.dissoc.cljs$core$IFn$_invoke$arity$2(cljs.core._with_meta(cljs.core.into.cljs$core$IFn$_invoke$arity$2(cljs.core.PersistentArrayMap.EMPTY,this__5333__auto____$1),self__.__meta),k__5334__auto__);
} else {
return (new ajax.protocols.Response(self__.status,self__.body,self__.status_text,self__.headers,self__.was_aborted,self__.__meta,cljs.core.not_empty(cljs.core.dissoc.cljs$core$IFn$_invoke$arity$2(self__.__extmap,k__5334__auto__)),null));
}
}));
(ajax.protocols.Response.prototype.cljs$core$IAssociative$_contains_key_QMARK_$arity$2 = (function (this__5330__auto__,k45091){
var self__ = this;
var this__5330__auto____$1 = this;
var G__45317 = k45091;
var G__45317__$1 = (((G__45317 instanceof cljs.core.Keyword))?G__45317.fqn:null);
switch (G__45317__$1) {
case "status":
case "body":
case "status-text":
case "headers":
case "was-aborted":
return true;
break;
default:
return cljs.core.contains_QMARK_(self__.__extmap,k45091);
}
}));
(ajax.protocols.Response.prototype.cljs$core$IAssociative$_assoc$arity$3 = (function (this__5331__auto__,k__5332__auto__,G__45090){
var self__ = this;
var this__5331__auto____$1 = this;
var pred__45318 = cljs.core.keyword_identical_QMARK_;
var expr__45319 = k__5332__auto__;
if(cljs.core.truth_((pred__45318.cljs$core$IFn$_invoke$arity$2 ? pred__45318.cljs$core$IFn$_invoke$arity$2(new cljs.core.Keyword(null,"status","status",-1997798413),expr__45319) : pred__45318.call(null,new cljs.core.Keyword(null,"status","status",-1997798413),expr__45319)))){
return (new ajax.protocols.Response(G__45090,self__.body,self__.status_text,self__.headers,self__.was_aborted,self__.__meta,self__.__extmap,null));
} else {
if(cljs.core.truth_((pred__45318.cljs$core$IFn$_invoke$arity$2 ? pred__45318.cljs$core$IFn$_invoke$arity$2(new cljs.core.Keyword(null,"body","body",-2049205669),expr__45319) : pred__45318.call(null,new cljs.core.Keyword(null,"body","body",-2049205669),expr__45319)))){
return (new ajax.protocols.Response(self__.status,G__45090,self__.status_text,self__.headers,self__.was_aborted,self__.__meta,self__.__extmap,null));
} else {
if(cljs.core.truth_((pred__45318.cljs$core$IFn$_invoke$arity$2 ? pred__45318.cljs$core$IFn$_invoke$arity$2(new cljs.core.Keyword(null,"status-text","status-text",-1834235478),expr__45319) : pred__45318.call(null,new cljs.core.Keyword(null,"status-text","status-text",-1834235478),expr__45319)))){
return (new ajax.protocols.Response(self__.status,self__.body,G__45090,self__.headers,self__.was_aborted,self__.__meta,self__.__extmap,null));
} else {
if(cljs.core.truth_((pred__45318.cljs$core$IFn$_invoke$arity$2 ? pred__45318.cljs$core$IFn$_invoke$arity$2(new cljs.core.Keyword(null,"headers","headers",-835030129),expr__45319) : pred__45318.call(null,new cljs.core.Keyword(null,"headers","headers",-835030129),expr__45319)))){
return (new ajax.protocols.Response(self__.status,self__.body,self__.status_text,G__45090,self__.was_aborted,self__.__meta,self__.__extmap,null));
} else {
if(cljs.core.truth_((pred__45318.cljs$core$IFn$_invoke$arity$2 ? pred__45318.cljs$core$IFn$_invoke$arity$2(new cljs.core.Keyword(null,"was-aborted","was-aborted",-2120084828),expr__45319) : pred__45318.call(null,new cljs.core.Keyword(null,"was-aborted","was-aborted",-2120084828),expr__45319)))){
return (new ajax.protocols.Response(self__.status,self__.body,self__.status_text,self__.headers,G__45090,self__.__meta,self__.__extmap,null));
} else {
return (new ajax.protocols.Response(self__.status,self__.body,self__.status_text,self__.headers,self__.was_aborted,self__.__meta,cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(self__.__extmap,k__5332__auto__,G__45090),null));
}
}
}
}
}
}));
(ajax.protocols.Response.prototype.cljs$core$ISeqable$_seq$arity$1 = (function (this__5336__auto__){
var self__ = this;
var this__5336__auto____$1 = this;
return cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2(new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [(new cljs.core.MapEntry(new cljs.core.Keyword(null,"status","status",-1997798413),self__.status,null)),(new cljs.core.MapEntry(new cljs.core.Keyword(null,"body","body",-2049205669),self__.body,null)),(new cljs.core.MapEntry(new cljs.core.Keyword(null,"status-text","status-text",-1834235478),self__.status_text,null)),(new cljs.core.MapEntry(new cljs.core.Keyword(null,"headers","headers",-835030129),self__.headers,null)),(new cljs.core.MapEntry(new cljs.core.Keyword(null,"was-aborted","was-aborted",-2120084828),self__.was_aborted,null))], null),self__.__extmap));
}));
(ajax.protocols.Response.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (this__5322__auto__,G__45090){
var self__ = this;
var this__5322__auto____$1 = this;
return (new ajax.protocols.Response(self__.status,self__.body,self__.status_text,self__.headers,self__.was_aborted,G__45090,self__.__extmap,self__.__hash));
}));
(ajax.protocols.Response.prototype.cljs$core$ICollection$_conj$arity$2 = (function (this__5328__auto__,entry__5329__auto__){
var self__ = this;
var this__5328__auto____$1 = this;
if(cljs.core.vector_QMARK_(entry__5329__auto__)){
return this__5328__auto____$1.cljs$core$IAssociative$_assoc$arity$3(null,cljs.core._nth(entry__5329__auto__,(0)),cljs.core._nth(entry__5329__auto__,(1)));
} else {
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(cljs.core._conj,this__5328__auto____$1,entry__5329__auto__);
}
}));
(ajax.protocols.Response.getBasis = (function (){
return new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"status","status",-357266886,null),new cljs.core.Symbol(null,"body","body",-408674142,null),new cljs.core.Symbol(null,"status-text","status-text",-193703951,null),new cljs.core.Symbol(null,"headers","headers",805501398,null),new cljs.core.Symbol(null,"was-aborted","was-aborted",-479553301,null)], null);
}));
(ajax.protocols.Response.cljs$lang$type = true);
(ajax.protocols.Response.cljs$lang$ctorPrSeq = (function (this__5369__auto__){
return (new cljs.core.List(null,"ajax.protocols/Response",null,(1),null));
}));
(ajax.protocols.Response.cljs$lang$ctorPrWriter = (function (this__5369__auto__,writer__5370__auto__){
return cljs.core._write(writer__5370__auto__,"ajax.protocols/Response");
}));
/**
* Positional factory function for ajax.protocols/Response.
*/
ajax.protocols.__GT_Response = (function ajax$protocols$__GT_Response(status,body,status_text,headers,was_aborted){
return (new ajax.protocols.Response(status,body,status_text,headers,was_aborted,null,null,null));
});
/**
* Factory function for ajax.protocols/Response, taking a map of keywords to field values.
*/
ajax.protocols.map__GT_Response = (function ajax$protocols$map__GT_Response(G__45094){
var extmap__5365__auto__ = (function (){var G__45324 = cljs.core.dissoc.cljs$core$IFn$_invoke$arity$variadic(G__45094,new cljs.core.Keyword(null,"status","status",-1997798413),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new cljs.core.Keyword(null,"body","body",-2049205669),new cljs.core.Keyword(null,"status-text","status-text",-1834235478),new cljs.core.Keyword(null,"headers","headers",-835030129),new cljs.core.Keyword(null,"was-aborted","was-aborted",-2120084828)], 0));
if(cljs.core.record_QMARK_(G__45094)){
return cljs.core.into.cljs$core$IFn$_invoke$arity$2(cljs.core.PersistentArrayMap.EMPTY,G__45324);
} else {
return G__45324;
}
})();
return (new ajax.protocols.Response(new cljs.core.Keyword(null,"status","status",-1997798413).cljs$core$IFn$_invoke$arity$1(G__45094),new cljs.core.Keyword(null,"body","body",-2049205669).cljs$core$IFn$_invoke$arity$1(G__45094),new cljs.core.Keyword(null,"status-text","status-text",-1834235478).cljs$core$IFn$_invoke$arity$1(G__45094),new cljs.core.Keyword(null,"headers","headers",-835030129).cljs$core$IFn$_invoke$arity$1(G__45094),new cljs.core.Keyword(null,"was-aborted","was-aborted",-2120084828).cljs$core$IFn$_invoke$arity$1(G__45094),null,cljs.core.not_empty(extmap__5365__auto__),null));
});
//# sourceMappingURL=ajax.protocols.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,50 @@
goog.provide('ajax.ring');
ajax.ring.make_ring_read = (function ajax$ring$make_ring_read(body_read){
return (function ajax$ring$make_ring_read_$_ring_read(response){
return new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"status","status",-1997798413),ajax.protocols._status(response),new cljs.core.Keyword(null,"headers","headers",-835030129),ajax.protocols._get_all_headers(response),new cljs.core.Keyword(null,"body","body",-2049205669),(body_read.cljs$core$IFn$_invoke$arity$1 ? body_read.cljs$core$IFn$_invoke$arity$1(response) : body_read.call(null,response))], null);
});
});
/**
* Returns a Ring-compatible response map.
*
* Optionally can be passed a :format option. This should be another
* response-format map. If format is provided it will be used to
* specify the content-type, and the read method will be used to
* populate the :body key in the response map.
*/
ajax.ring.ring_response_format = (function ajax$ring$ring_response_format(var_args){
var G__47143 = arguments.length;
switch (G__47143) {
case 0:
return ajax.ring.ring_response_format.cljs$core$IFn$_invoke$arity$0();
break;
case 1:
return ajax.ring.ring_response_format.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(ajax.ring.ring_response_format.cljs$core$IFn$_invoke$arity$0 = (function (){
return ajax.ring.ring_response_format.cljs$core$IFn$_invoke$arity$1(new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"format","format",-1306924766),ajax.formats.raw_response_format.cljs$core$IFn$_invoke$arity$0()], null));
}));
(ajax.ring.ring_response_format.cljs$core$IFn$_invoke$arity$1 = (function (p__47144){
var map__47145 = p__47144;
var map__47145__$1 = cljs.core.__destructure_map(map__47145);
var map__47146 = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47145__$1,new cljs.core.Keyword(null,"format","format",-1306924766));
var map__47146__$1 = cljs.core.__destructure_map(map__47146);
var read = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47146__$1,new cljs.core.Keyword(null,"read","read",1140058661));
var description = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47146__$1,new cljs.core.Keyword(null,"description","description",-1428560544));
var content_type = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47146__$1,new cljs.core.Keyword(null,"content-type","content-type",-508222634));
return ajax.interceptors.map__GT_ResponseFormat(new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"read","read",1140058661),ajax.ring.make_ring_read(read),new cljs.core.Keyword(null,"description","description",-1428560544),["ring/",cljs.core.str.cljs$core$IFn$_invoke$arity$1(description)].join(''),new cljs.core.Keyword(null,"content-type","content-type",-508222634),content_type], null));
}));
(ajax.ring.ring_response_format.cljs$lang$maxFixedArity = 1);
//# sourceMappingURL=ajax.ring.js.map

View file

@ -0,0 +1 @@
{"version":3,"sources":["ajax/ring.cljc"],"mappings":";AAKA,2BAAA,3BAAMA,8DAAgBC;AAAtB,AACE,sDAAeC;AAAf,AAAA,kDAAA,2FAAA,qGAAA,tIACW,AAACC,uBAAQD,qEACR,AAACE,gCAAiBF,gEACrB,CAACD,0CAAAA,oDAAAA,ZAAUC,gCAAAA;;;AAEtB,AAAA;;;;;;;;iCAAA,yCAAAG,1EAAME;AAAN,AAAA,IAAAD,WAAA,AAAA;AAAA,AAAA,QAAAA;KAAA;AAAA,OAAAC;;;KAAA;AAAA,OAAAA,6DAAA,CAAA,UAAA;;;;AAAA,MAAA,KAAAC,MAAA,CAAA,8DAAA,AAAA;;;;;AAAA,CAAA,+DAAA,/DAAMD;AAAN,AAOM,oEAAA,2CAAA,xGAACO,kKAA8B,AAACC;;;AAPtC,CAAA,+DAAA,WAAAN,1EAAMF;AAAN,AAAA,IAAAG,aAAAD;IAAAC,iBAAA,AAAAC,4BAAAD;IAAAE,aAAA,AAAAC,4CAAAH,eAAA;IAAAE,iBAAA,AAAAD,4BAAAC;WAAA,AAAAC,4CAAAD,eAAA,lEAQaI;kBARb,AAAAH,4CAAAD,eAAA,zEAQkBK;mBARlB,AAAAJ,4CAAAD,eAAA,1EAQ8BM;AAR9B,AASG,gDAAA,2CAAA,oFAAA,gJAAA,xTAACC,yIAA2B,AAACnB,yBAAegB,0EACT,CAAA,oDAAaC,4FACZC;;;AAXvC,CAAA,yDAAA,zDAAMX;;AAAN","names":["ajax.ring/make-ring-read","body-read","response","ajax.protocols/-status","ajax.protocols/-get-all-headers","var_args","G__47143","ajax.ring/ring-response-format","js/Error","p__47144","map__47145","cljs.core/--destructure-map","map__47146","cljs.core.get","ajax.ring.ring_response_format","ajax.formats.raw_response_format","read","description","content-type","ajax.interceptors/map->ResponseFormat"],"sourcesContent":["(ns ajax.ring\n (:require [ajax.interceptors :refer [map->ResponseFormat]]\n [ajax.protocols :refer [-status -get-all-headers -body]]\n [ajax.formats :as f]))\n\n(defn make-ring-read [body-read]\n (fn ring-read [response]\n {:status (-status response)\n :headers (-get-all-headers response)\n :body (body-read response)}))\n\n(defn ring-response-format\n \"Returns a Ring-compatible response map.\n\n Optionally can be passed a :format option. This should be another\n response-format map. If format is provided it will be used to\n specify the content-type, and the read method will be used to\n populate the :body key in the response map.\"\n ([] (ring-response-format {:format (f/raw-response-format)}))\n ([{{:keys [read description content-type]} :format}]\n (map->ResponseFormat {:read (make-ring-read read)\n :description (str \"ring/\" description)\n :content-type content-type})))\n"],"x_google_ignoreList":[0]}

View file

@ -0,0 +1,73 @@
goog.provide('ajax.simple');
ajax.simple.normalize_method = (function ajax$simple$normalize_method(method){
if((method instanceof cljs.core.Keyword)){
return clojure.string.upper_case(cljs.core.name(method));
} else {
return method;
}
});
ajax.simple.process_response = (function ajax$simple$process_response(response,interceptor){
return ajax.protocols._process_response(interceptor,response);
});
ajax.simple.make_js_handler = (function ajax$simple$make_js_handler(handler,interceptors){
return (function ajax$simple$make_js_handler_$_js_handler(response){
var processed = cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(ajax.simple.process_response,response,interceptors);
return (handler.cljs$core$IFn$_invoke$arity$1 ? handler.cljs$core$IFn$_invoke$arity$1(processed) : handler.call(null,processed));
});
});
ajax.simple.base_handler = (function ajax$simple$base_handler(interceptors,p__47150){
var map__47151 = p__47150;
var map__47151__$1 = cljs.core.__destructure_map(map__47151);
var handler = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47151__$1,new cljs.core.Keyword(null,"handler","handler",-195596612));
if(cljs.core.truth_(handler)){
return ajax.simple.make_js_handler(handler,interceptors);
} else {
return ajax.util.throw_error("No ajax handler provided.");
}
});
ajax.simple.default_interceptors = cljs.core.atom.cljs$core$IFn$_invoke$arity$1(cljs.core.PersistentVector.EMPTY);
ajax.simple.normalize_request = (function ajax$simple$normalize_request(request){
var response_format = ajax.interceptors.get_response_format(ajax.formats.detect_response_format,request);
return cljs.core.update.cljs$core$IFn$_invoke$arity$3(cljs.core.update.cljs$core$IFn$_invoke$arity$3(request,new cljs.core.Keyword(null,"method","method",55703592),ajax.simple.normalize_method),new cljs.core.Keyword(null,"interceptors","interceptors",-1546782951),(function (p1__47152_SHARP_){
return cljs.core.concat.cljs$core$IFn$_invoke$arity$variadic(new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [response_format], null),(function (){var or__5025__auto__ = p1__47152_SHARP_;
if(cljs.core.truth_(or__5025__auto__)){
return or__5025__auto__;
} else {
return cljs.core.deref(ajax.simple.default_interceptors);
}
})(),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([ajax.interceptors.request_interceptors], 0));
}));
});
ajax.simple.new_default_api = (function ajax$simple$new_default_api(){
return (new goog.net.XhrIo());
});
/**
* -process-request with the arguments flipped for use in reduce
*/
ajax.simple.process_request = (function ajax$simple$process_request(request,interceptor){
return ajax.protocols._process_request(interceptor,request);
});
/**
* The main request function.
*/
ajax.simple.raw_ajax_request = (function ajax$simple$raw_ajax_request(p__47153){
var map__47154 = p__47153;
var map__47154__$1 = cljs.core.__destructure_map(map__47154);
var request = map__47154__$1;
var interceptors = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47154__$1,new cljs.core.Keyword(null,"interceptors","interceptors",-1546782951));
var request__$1 = cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(ajax.simple.process_request,request,interceptors);
var handler = ajax.simple.base_handler(cljs.core.reverse(interceptors),request__$1);
var api = (function (){var or__5025__auto__ = new cljs.core.Keyword(null,"api","api",-899839580).cljs$core$IFn$_invoke$arity$1(request__$1);
if(cljs.core.truth_(or__5025__auto__)){
return or__5025__auto__;
} else {
return ajax.simple.new_default_api();
}
})();
return ajax.protocols._js_ajax_request(api,request__$1,handler);
});
ajax.simple.ajax_request = (function ajax$simple$ajax_request(request){
return ajax.simple.raw_ajax_request(ajax.simple.normalize_request(request));
});
//# sourceMappingURL=ajax.simple.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,118 @@
goog.provide('ajax.transit');
ajax.transit.transit_type = (function ajax$transit$transit_type(p__47086){
var map__47088 = p__47086;
var map__47088__$1 = cljs.core.__destructure_map(map__47088);
var type = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47088__$1,new cljs.core.Keyword(null,"type","type",1174270348));
var or__5025__auto__ = type;
if(cljs.core.truth_(or__5025__auto__)){
return or__5025__auto__;
} else {
return new cljs.core.Keyword(null,"json","json",1279968570);
}
});
ajax.transit.transit_write_fn = (function ajax$transit$transit_write_fn(type,opts){
var writer = (function (){var or__5025__auto__ = new cljs.core.Keyword(null,"writer","writer",-277568236).cljs$core$IFn$_invoke$arity$1(opts);
if(cljs.core.truth_(or__5025__auto__)){
return or__5025__auto__;
} else {
return cognitect.transit.writer.cljs$core$IFn$_invoke$arity$2(type,opts);
}
})();
return (function ajax$transit$transit_write_fn_$_transit_write_params(params){
return cognitect.transit.write(writer,params);
});
});
/**
* Returns a Transit request format.
*
* Options include:
* :writer Explicit Transit writer. If not supplied one will be created using the other options.
* The default type is :json for ClojureScript and :msgpack for Clojure.
* :type Override the default transit type with value :json, :json-verbose or :msgpack
* :handlers Custom Transit handlers (refer to Transit documentation)
*/
ajax.transit.transit_request_format = (function ajax$transit$transit_request_format(var_args){
var G__47096 = arguments.length;
switch (G__47096) {
case 0:
return ajax.transit.transit_request_format.cljs$core$IFn$_invoke$arity$0();
break;
case 1:
return ajax.transit.transit_request_format.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(ajax.transit.transit_request_format.cljs$core$IFn$_invoke$arity$0 = (function (){
return ajax.transit.transit_request_format.cljs$core$IFn$_invoke$arity$1(cljs.core.PersistentArrayMap.EMPTY);
}));
(ajax.transit.transit_request_format.cljs$core$IFn$_invoke$arity$1 = (function (opts){
var type = ajax.transit.transit_type(opts);
var mime_type = ((((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(type,new cljs.core.Keyword(null,"json","json",1279968570))) || (cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(type,new cljs.core.Keyword(null,"json-verbose","json-verbose",-542533531)))))?"json":"msgpack");
return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"write","write",-1857649168),ajax.transit.transit_write_fn(type,opts),new cljs.core.Keyword(null,"content-type","content-type",-508222634),["application/transit+",mime_type].join('')], null);
}));
(ajax.transit.transit_request_format.cljs$lang$maxFixedArity = 1);
ajax.transit.transit_read_fn = (function ajax$transit$transit_read_fn(opts){
var reader = (function (){var or__5025__auto__ = new cljs.core.Keyword(null,"reader","reader",169660853).cljs$core$IFn$_invoke$arity$1(opts);
if(cljs.core.truth_(or__5025__auto__)){
return or__5025__auto__;
} else {
return cognitect.transit.reader.cljs$core$IFn$_invoke$arity$2(new cljs.core.Keyword(null,"json","json",1279968570),opts);
}
})();
return (function ajax$transit$transit_read_fn_$_transit_read_response(response){
return cognitect.transit.read(reader,ajax.protocols._body(response));
});
});
/**
* Returns a Transit response format.
*
* Options include:
* :reader (CLJS only) Explicit Transit reader. If not supplied one will be created using the other options.
* :handlers Custom Transit handlers (refer to Transit documentation)
*/
ajax.transit.transit_response_format = (function ajax$transit$transit_response_format(var_args){
var G__47108 = arguments.length;
switch (G__47108) {
case 0:
return ajax.transit.transit_response_format.cljs$core$IFn$_invoke$arity$0();
break;
case 1:
return ajax.transit.transit_response_format.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
case 2:
return ajax.transit.transit_response_format.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(ajax.transit.transit_response_format.cljs$core$IFn$_invoke$arity$0 = (function (){
return ajax.transit.transit_response_format.cljs$core$IFn$_invoke$arity$1(cljs.core.PersistentArrayMap.EMPTY);
}));
(ajax.transit.transit_response_format.cljs$core$IFn$_invoke$arity$1 = (function (opts){
return ajax.transit.transit_response_format.cljs$core$IFn$_invoke$arity$2(ajax.transit.transit_type(opts),opts);
}));
(ajax.transit.transit_response_format.cljs$core$IFn$_invoke$arity$2 = (function (type,opts){
return ajax.interceptors.map__GT_ResponseFormat(new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"read","read",1140058661),ajax.transit.transit_read_fn(opts),new cljs.core.Keyword(null,"description","description",-1428560544),"Transit",new cljs.core.Keyword(null,"content-type","content-type",-508222634),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, ["application/transit+json"], null)], null));
}));
(ajax.transit.transit_response_format.cljs$lang$maxFixedArity = 2);
//# sourceMappingURL=ajax.transit.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,137 @@
goog.provide('ajax.url');
ajax.url.key_encode = (function ajax$url$key_encode(key){
if(cljs.core.qualified_keyword_QMARK_(key)){
return clojure.string.join.cljs$core$IFn$_invoke$arity$2("/",cljs.core.juxt.cljs$core$IFn$_invoke$arity$2(cljs.core.namespace,cljs.core.name)(key));
} else {
if((key instanceof cljs.core.Keyword)){
return cljs.core.name(key);
} else {
return key;
}
}
});
ajax.url.value_encode = encodeURIComponent;
ajax.url.key_value_pair_to_str = (function ajax$url$key_value_pair_to_str(p__45373){
var vec__45374 = p__45373;
var k = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__45374,(0),null);
var v = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__45374,(1),null);
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(ajax.url.key_encode(k)),"=",cljs.core.str.cljs$core$IFn$_invoke$arity$1((ajax.url.value_encode.cljs$core$IFn$_invoke$arity$1 ? ajax.url.value_encode.cljs$core$IFn$_invoke$arity$1(v) : ajax.url.value_encode.call(null,v)))].join('');
});
ajax.url.vec_key_transform_fn = (function ajax$url$vec_key_transform_fn(vec_key_encode,k,v){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(vec_key_encode.cljs$core$IFn$_invoke$arity$1 ? vec_key_encode.cljs$core$IFn$_invoke$arity$1(k) : vec_key_encode.call(null,k)),v], null);
});
ajax.url.to_vec_key_transform = (function ajax$url$to_vec_key_transform(vec_strategy){
var vec_key_encode = (function (){var G__45377 = (function (){var or__5025__auto__ = vec_strategy;
if(cljs.core.truth_(or__5025__auto__)){
return or__5025__auto__;
} else {
return new cljs.core.Keyword(null,"java","java",1958249105);
}
})();
var G__45377__$1 = (((G__45377 instanceof cljs.core.Keyword))?G__45377.fqn:null);
switch (G__45377__$1) {
case "java":
return (function (k){
return null;
});
break;
case "rails":
return (function (k){
return "";
});
break;
case "indexed":
return cljs.core.identity;
break;
default:
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__45377__$1)].join('')));
}
})();
return cljs.core.partial.cljs$core$IFn$_invoke$arity$2(ajax.url.vec_key_transform_fn,vec_key_encode);
});
/**
* Takes a parameter and turns it into a sequence of key-value pairs suitable
* for passing to `key-value-pair-to-str`. Since we can have nested maps and
* vectors, we need a vec-key-transform function and the current query key
* prefix as well as the key and value to be analysed. Ultimately, this
* function walks the structure and flattens it.
*/
ajax.url.param_to_key_value_pairs = (function ajax$url$param_to_key_value_pairs(vec_key_transform,prefix,p__45384){
var vec__45385 = p__45384;
var key = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__45385,(0),null);
var value = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__45385,(1),null);
var k1 = ajax.url.key_encode(key);
var new_key = (cljs.core.truth_(prefix)?(cljs.core.truth_(key)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(prefix),"[",cljs.core.str.cljs$core$IFn$_invoke$arity$1(k1),"]"].join(''):prefix):k1);
var recurse = cljs.core.partial.cljs$core$IFn$_invoke$arity$3(ajax.url.param_to_key_value_pairs,vec_key_transform,new_key);
if(typeof value === 'string'){
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new_key,value], null)], null);
} else {
if(cljs.core.qualified_keyword_QMARK_(value)){
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new_key,clojure.string.join.cljs$core$IFn$_invoke$arity$2("/",cljs.core.juxt.cljs$core$IFn$_invoke$arity$2(cljs.core.namespace,cljs.core.name)(value))], null)], null);
} else {
if((value instanceof cljs.core.Keyword)){
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new_key,cljs.core.name(value)], null)], null);
} else {
if(cljs.core.map_QMARK_(value)){
return cljs.core.mapcat.cljs$core$IFn$_invoke$arity$variadic(recurse,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.seq(value)], 0));
} else {
if(((cljs.core.sequential_QMARK_(value)) || (cljs.core.set_QMARK_(value)))){
return cljs.core.mapcat.cljs$core$IFn$_invoke$arity$variadic(recurse,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.map_indexed.cljs$core$IFn$_invoke$arity$2(vec_key_transform,cljs.core.seq(value))], 0));
} else {
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new_key,value], null)], null);
}
}
}
}
}
});
/**
* vec-strategy is one of :rails (a[]=3&a[]=4)
* :java (a=3&a=4) (this is the correct behaviour and the default)
* :indexed (a[3]=1&a[4]=1)
* params is an arbitrary clojure map
*/
ajax.url.params_to_str = (function ajax$url$params_to_str(vec_strategy,params){
return clojure.string.join.cljs$core$IFn$_invoke$arity$2("&",cljs.core.map.cljs$core$IFn$_invoke$arity$2(ajax.url.key_value_pair_to_str,ajax.url.param_to_key_value_pairs(ajax.url.to_vec_key_transform(vec_strategy),null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,params], null))));
});
/**
* The request format for simple POST and GET.
*/
ajax.url.url_request_format = (function ajax$url$url_request_format(var_args){
var G__45392 = arguments.length;
switch (G__45392) {
case 0:
return ajax.url.url_request_format.cljs$core$IFn$_invoke$arity$0();
break;
case 1:
return ajax.url.url_request_format.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(ajax.url.url_request_format.cljs$core$IFn$_invoke$arity$0 = (function (){
return ajax.url.url_request_format.cljs$core$IFn$_invoke$arity$1(cljs.core.PersistentArrayMap.EMPTY);
}));
(ajax.url.url_request_format.cljs$core$IFn$_invoke$arity$1 = (function (p__45394){
var map__45395 = p__45394;
var map__45395__$1 = cljs.core.__destructure_map(map__45395);
var vec_strategy = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__45395__$1,new cljs.core.Keyword(null,"vec-strategy","vec-strategy",1843221372));
return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"write","write",-1857649168),ajax.util.to_utf8_writer(cljs.core.partial.cljs$core$IFn$_invoke$arity$2(ajax.url.params_to_str,vec_strategy)),new cljs.core.Keyword(null,"content-type","content-type",-508222634),"application/x-www-form-urlencoded; charset=utf-8"], null);
}));
(ajax.url.url_request_format.cljs$lang$maxFixedArity = 1);
//# sourceMappingURL=ajax.url.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,37 @@
goog.provide('ajax.util');
/**
* Throws an error.
*/
ajax.util.throw_error = (function ajax$util$throw_error(args){
throw (new Error(cljs.core.str.cljs$core$IFn$_invoke$arity$1(args)));
});
ajax.util.get_content_type = (function ajax$util$get_content_type(response){
var or__5025__auto__ = ajax.protocols._get_response_header(response,"Content-Type");
if(cljs.core.truth_(or__5025__auto__)){
return or__5025__auto__;
} else {
return "";
}
});
/**
* Takes a function that converts to a string and transforms it
* into a function that converts to an object that will write
* UTF-8 to the wire. Note that this is the identity function
* for JavaScript because the underlying implementations take
* a string.
*/
ajax.util.to_utf8_writer = (function ajax$util$to_utf8_writer(to_str){
return to_str;
});
/**
* A set of successful response types derived from `goog.net.HttpStatus.isSuccess`.
*/
ajax.util.successful_response_codes_set = new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 7, [(206),null,(204),null,(304),null,(1223),null,(201),null,(202),null,(200),null], null), null);
/**
* Indicates whether an HTTP status code is considered successful.
*/
ajax.util.success_QMARK_ = (function ajax$util$success_QMARK_(status){
return cljs.core.contains_QMARK_(ajax.util.successful_response_codes_set,status);
});
//# sourceMappingURL=ajax.util.js.map

View file

@ -0,0 +1 @@
{"version":3,"sources":["ajax/util.cljc"],"mappings":";AAQA;;;wBAAA,xBAAMA,wDAEHC;AAFH,AAGE,MAAO,KAAAC,MACE,4CAAKD;;AAEhB,6BAAA,7BAAME,kEAA0BC;AAAhC,AACE,IAAAC,mBAAI,6CAAA,7CAACC,oCAAwBF;AAA7B,AAAA,oBAAAC;AAAAA;;AAAA;;;AAEF;;;;;;;2BAAA,3BAAME,8DAMHC;AANH,AAOYA;;AAMZ;;;0CAAA,iFAAA,WAAA,WAAA,WAAA,YAAA,WAAA,WAAA,9LAAKC;AAaL;;;2BAAA,3BAAMC,8DAEHC;AAFH,AAGE,OAACC,0BAAUH,wCACAE","names":["ajax.util/throw-error","args","js/Error","ajax.util/get-content-type","response","or__5025__auto__","ajax.protocols/-get-response-header","ajax.util/to-utf8-writer","to-str","ajax.util/successful-response-codes-set","ajax.util/success?","status","cljs.core/contains?"],"sourcesContent":["(ns ajax.util\n \"Short utility functions. A lot of these only exist because the \n cross platform implementation is annoying.\"\n (:require [ajax.protocols :as pr])\n #? (:clj\n (:import [java.io OutputStreamWriter]\n [java.lang String])))\n\n(defn throw-error \n \"Throws an error.\"\n [args]\n (throw (#?(:clj Exception. :cljs js/Error.)\n (str args))))\n\n(defn get-content-type ^String [response]\n (or (pr/-get-response-header response \"Content-Type\") \"\"))\n\n(defn to-utf8-writer \n \"Takes a function that converts to a string and transforms it\n into a function that converts to an object that will write\n UTF-8 to the wire. Note that this is the identity function\n for JavaScript because the underlying implementations take\n a string.\"\n [to-str]\n #? (:cljs to-str\n :clj (fn write-utf8 [stream params]\n (doto (OutputStreamWriter. stream)\n (.write ^String (to-str params))\n (.flush)))))\n\n(def successful-response-codes-set\n \"A set of successful response types derived from `goog.net.HttpStatus.isSuccess`.\"\n ;; Factoid: Closure considers some 2XX status codes to *not* be successful, namely\n ;; 205 Reset Content, 207 Multi Status & the unspecified 208+ range\n #{200 ;; Ok\n 201 ;; Created\n 202 ;; Accepted\n 204 ;; No Content\n 206 ;; Partial Content\n 304 ;; Not Modified\n ;; See https://github.com/google/closure-library/blob/f999480c4005641d284b86d82d0d5d0f05f3ffc8/closure/goog/net/httpstatus.js#L89-L94\n 1223}) ;; QUIRK_IE_NO_CONTENT\n\n(defn success? \n \"Indicates whether an HTTP status code is considered successful.\"\n [status]\n (contains? successful-response-codes-set\n status))\n"],"x_google_ignoreList":[0]}

View file

@ -0,0 +1,107 @@
goog.provide('ajax.xhrio');
(goog.net.XhrIo.prototype.ajax$protocols$AjaxImpl$ = cljs.core.PROTOCOL_SENTINEL);
(goog.net.XhrIo.prototype.ajax$protocols$AjaxImpl$_js_ajax_request$arity$3 = (function (this$,p__47157,handler){
var map__47158 = p__47157;
var map__47158__$1 = cljs.core.__destructure_map(map__47158);
var uri = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47158__$1,new cljs.core.Keyword(null,"uri","uri",-774711847));
var method = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47158__$1,new cljs.core.Keyword(null,"method","method",55703592));
var body = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47158__$1,new cljs.core.Keyword(null,"body","body",-2049205669));
var headers = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47158__$1,new cljs.core.Keyword(null,"headers","headers",-835030129));
var timeout = cljs.core.get.cljs$core$IFn$_invoke$arity$3(map__47158__$1,new cljs.core.Keyword(null,"timeout","timeout",-318625318),(0));
var with_credentials = cljs.core.get.cljs$core$IFn$_invoke$arity$3(map__47158__$1,new cljs.core.Keyword(null,"with-credentials","with-credentials",-1163127235),false);
var response_format = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47158__$1,new cljs.core.Keyword(null,"response-format","response-format",1664465322));
var progress_handler = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47158__$1,new cljs.core.Keyword(null,"progress-handler","progress-handler",333585589));
var this$__$1 = this;
var temp__5804__auto___47186 = new cljs.core.Keyword(null,"type","type",1174270348).cljs$core$IFn$_invoke$arity$1(response_format);
if(cljs.core.truth_(temp__5804__auto___47186)){
var response_type_47191 = temp__5804__auto___47186;
this$__$1.setResponseType(cljs.core.name(response_type_47191));
} else {
}
if(cljs.core.fn_QMARK_(progress_handler)){
var G__47164_47192 = this$__$1;
G__47164_47192.setProgressEventsEnabled(true);
goog.events.listen(G__47164_47192,goog.net.EventType.UPLOAD_PROGRESS,progress_handler);
} else {
}
var G__47165 = this$__$1;
goog.events.listen(G__47165,goog.net.EventType.COMPLETE,(function (p1__47155_SHARP_){
var G__47166 = p1__47155_SHARP_.target;
return (handler.cljs$core$IFn$_invoke$arity$1 ? handler.cljs$core$IFn$_invoke$arity$1(G__47166) : handler.call(null,G__47166));
}));
G__47165.setTimeoutInterval(timeout);
G__47165.setWithCredentials(with_credentials);
G__47165.send(uri,method,body,cljs.core.clj__GT_js(headers));
return G__47165;
}));
(goog.net.XhrIo.prototype.ajax$protocols$AjaxRequest$ = cljs.core.PROTOCOL_SENTINEL);
(goog.net.XhrIo.prototype.ajax$protocols$AjaxRequest$_abort$arity$1 = (function (this$){
var this$__$1 = this;
return this$__$1.abort(goog.net.ErrorCode.ABORT);
}));
(goog.net.XhrIo.prototype.ajax$protocols$AjaxResponse$ = cljs.core.PROTOCOL_SENTINEL);
(goog.net.XhrIo.prototype.ajax$protocols$AjaxResponse$_body$arity$1 = (function (this$){
var this$__$1 = this;
return this$__$1.getResponse();
}));
(goog.net.XhrIo.prototype.ajax$protocols$AjaxResponse$_status$arity$1 = (function (this$){
var this$__$1 = this;
return this$__$1.getStatus();
}));
(goog.net.XhrIo.prototype.ajax$protocols$AjaxResponse$_status_text$arity$1 = (function (this$){
var this$__$1 = this;
return this$__$1.getStatusText();
}));
(goog.net.XhrIo.prototype.ajax$protocols$AjaxResponse$_get_all_headers$arity$1 = (function (this$){
var this$__$1 = this;
return cljs.core.js__GT_clj.cljs$core$IFn$_invoke$arity$1(this$__$1.getResponseHeaders());
}));
(goog.net.XhrIo.prototype.ajax$protocols$AjaxResponse$_get_response_header$arity$2 = (function (this$,header){
var this$__$1 = this;
return this$__$1.getResponseHeader(header);
}));
(goog.net.XhrIo.prototype.ajax$protocols$AjaxResponse$_was_aborted$arity$1 = (function (this$){
var this$__$1 = this;
return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this$__$1.getLastErrorCode(),goog.net.ErrorCode.ABORT);
}));
(goog.net.XhrManager.prototype.ajax$protocols$AjaxImpl$ = cljs.core.PROTOCOL_SENTINEL);
(goog.net.XhrManager.prototype.ajax$protocols$AjaxImpl$_js_ajax_request$arity$3 = (function (this$,p__47174,handler){
var map__47178 = p__47174;
var map__47178__$1 = cljs.core.__destructure_map(map__47178);
var uri = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47178__$1,new cljs.core.Keyword(null,"uri","uri",-774711847));
var method = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47178__$1,new cljs.core.Keyword(null,"method","method",55703592));
var body = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47178__$1,new cljs.core.Keyword(null,"body","body",-2049205669));
var headers = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47178__$1,new cljs.core.Keyword(null,"headers","headers",-835030129));
var id = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47178__$1,new cljs.core.Keyword(null,"id","id",-1388402092));
var timeout = cljs.core.get.cljs$core$IFn$_invoke$arity$3(map__47178__$1,new cljs.core.Keyword(null,"timeout","timeout",-318625318),(0));
var priority = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47178__$1,new cljs.core.Keyword(null,"priority","priority",1431093715));
var max_retries = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47178__$1,new cljs.core.Keyword(null,"max-retries","max-retries",-1933762121));
var this$__$1 = this;
var G__47179 = this$__$1;
G__47179.setTimeoutInterval(timeout);
G__47179.send(id,uri,method,body,cljs.core.clj__GT_js(headers),priority,handler,max_retries);
return G__47179;
}));
//# sourceMappingURL=ajax.xhrio.js.map

View file

@ -0,0 +1 @@
{"version":3,"sources":["ajax/xhrio.cljs"],"mappings":";AAWA,AAAA,CAAA,AAAA,oDAAAA,pDAAaC;;AAAb,CAAA,AAAA,AAAaA,4EAEX,iBAAAC,NACGI,eAKAS;AANH,AAAA,IAAAZ,aAAAD;IAAAC,iBAAA,AAAAC,4BAAAD;UAAA,AAAAE,4CAAAF,eAAA,jEAEWI;aAFX,AAAAF,4CAAAF,eAAA,pEAEeK;WAFf,AAAAH,4CAAAF,eAAA,lEAEsBM;cAFtB,AAAAJ,4CAAAF,eAAA,rEAE2BO;cAF3B,AAAAL,4CAAAF,eAAA,2DAAA,hIAEmCQ;uBAFnC,AAAAN,4CAAAF,eAAA,8EAAA,5JAE2CS;sBAF3C,AAAAP,4CAAAF,eAAA,7EAGWU;uBAHX,AAAAR,4CAAAF,eAAA,9EAG2BW;AAH3B,AAAA,gBAAA,ZACGR;AADH,AAOE,IAAAU,2BAAyB,AAAA,mFAAOH;AAAhC,AAAA,oBAAAG;AAAA,AAAA,0BAAAA,tBAAWC;AAAX,AACE,AAAkBX,0BAAK,AAACY,eAAKD;;AAD/B;;AAEA,GAAM,AAACE,oBAAIL;AAAX,AACE,IAAAM,iBAAMd;AAAN,AAAA,AAAAc,wCAAA;;AAAA,mBAAAA,nBAEGC,kCAAcC,mCAAmCR;;AAFpDM;AADF;;AAIA,IAAAG,WAAMjB;AAAN,AAAA,mBAAAiB,qCAAA,WAAAC,nEACGH,4BAAcI;AADjB,AAEkB,IAAAC,WAAS,AAAAF;AAAT,AAAA,sFAAAE,8BAAAA,5GAACX,wCAAAA,kDAAAA;;;AAFnB,AAAAQ,4BAGuBZ;;AAHvB,AAAAY,4BAIuBX;;AAJvB,AAAAW,cAKShB,IAAIC,OAAOC,KAAK,AAACkB,qBAAQjB;;AALlCa;;;AAfJ,CAAA,AAAA,uDAAAvB,vDAAaC;;AAAb,CAAA,AAAA,AAAaA,qEAsBX,WAASK;AAAT,AAAA,gBAAA,ZAASA;AAAT,AAAe,OAAQA,gBAAKsB;;;AAtB9B,CAAA,AAAA,wDAAA5B,xDAAaC;;AAAb,CAAA,AAAA,AAAaA,qEAwBX,WAAQK;AAAR,AAAA,gBAAA,ZAAQA;AAAR,AAAc,OAAcA;;;AAxB9B,CAAA,AAAA,AAAaL,uEAyBX,WAAUK;AAAV,AAAA,gBAAA,ZAAUA;AAAV,AAAgB,OAAYA;;;AAzB9B,CAAA,AAAA,AAAaL,4EA0BX,WAAeK;AAAf,AAAA,gBAAA,ZAAeA;AAAf,AAAqB,OAAgBA;;;AA1BvC,CAAA,AAAA,AAAaL,gFA2BX,WAAmBK;AAAnB,AAAA,gBAAA,ZAAmBA;AAAnB,AACE,OAACuB,mDAAQ,AAAqBvB;;;AA5BlC,CAAA,AAAA,AAAaL,oFA6BX,WAAuBK,MAAKwB;AAA5B,AAAA,gBAAA,ZAAuBxB;AAAvB,AACE,OAAoBA,4BAAKwB;;;AA9B7B,CAAA,AAAA,AAAa7B,4EA+BX,WAAeK;AAAf,AAAA,gBAAA,ZAAeA;AAAf,AACE,OAACyB,6CAAE,AAAmBzB,6BAAMsB;;AAEhC,AAAA,CAAA,AAAA,yDAAA5B,zDAAagC;;AAAb,CAAA,AAAA,AAAaA,iFAEX,iBAAAC,NACG3B,eAGAS;AAJH,AAAA,IAAAmB,aAAAD;IAAAC,iBAAA,AAAA9B,4BAAA8B;UAAA,AAAA7B,4CAAA6B,eAAA,jEACgB3B;aADhB,AAAAF,4CAAA6B,eAAA,pEACoB1B;WADpB,AAAAH,4CAAA6B,eAAA,lEAC2BzB;cAD3B,AAAAJ,4CAAA6B,eAAA,rEACgCxB;SADhC,AAAAL,4CAAA6B,eAAA,hEAEgBC;cAFhB,AAAA9B,4CAAA6B,eAAA,2DAAA,hIAEmBvB;eAFnB,AAAAN,4CAAA6B,eAAA,tEAE2BE;kBAF3B,AAAA/B,4CAAA6B,eAAA,zEAEoCG;AAFpC,AAAA,gBAAA,ZACG/B;AADH,AAKE,IAAAgC,WAAMhC;AAAN,AAAA,AAAAgC,4BACuB3B;;AADvB,AAAA2B,cAESH,GAAG5B,IAAIC,OAAOC,KAAK,AAACkB,qBAAQjB,SAC5B0B,SAASrB,QAAQsB;;AAH1BC","names":["cljs.core/PROTOCOL_SENTINEL","js/goog.net.XhrIo","p__47157","map__47158","cljs.core/--destructure-map","cljs.core.get","this","uri","method","body","headers","timeout","with-credentials","response-format","progress-handler","handler","temp__5804__auto__","response-type","cljs.core/name","cljs.core/fn?","G__47164","goog.events/listen","js/goog.net.EventType.UPLOAD_PROGRESS","G__47165","p1__47155#","goog.net.EventType/COMPLETE","G__47166","cljs.core/clj->js","goog.net.ErrorCode/ABORT","cljs.core.js__GT_clj","header","cljs.core._EQ_","js/goog.net.XhrManager","p__47174","map__47178","id","priority","max-retries","G__47179"],"sourcesContent":["(ns ajax.xhrio\n (:require goog.net.EventType\n goog.net.ErrorCode\n [goog.net.XhrIo :as xhr]\n [goog.net.XhrManager :as xhrm]\n [goog.Uri :as uri]\n [goog.json :as goog-json]\n [goog.events :as events]\n [ajax.protocols :refer [AjaxImpl AjaxRequest\n AjaxResponse Interceptor]]))\n\n(extend-type goog.net.XhrIo\n AjaxImpl\n (-js-ajax-request\n [this\n {:keys [uri method body headers timeout with-credentials\n response-format progress-handler]\n :or {with-credentials false\n timeout 0}}\n handler]\n (when-let [response-type (:type response-format)]\n (.setResponseType this (name response-type)))\n (when (fn? progress-handler)\n (doto this\n (.setProgressEventsEnabled true)\n (events/listen goog.net.EventType.UPLOAD_PROGRESS progress-handler)))\n (doto this\n (events/listen goog.net.EventType/COMPLETE\n #(handler (.-target %)))\n (.setTimeoutInterval timeout)\n (.setWithCredentials with-credentials)\n (.send uri method body (clj->js headers))))\n AjaxRequest\n (-abort [this] (.abort this goog.net.ErrorCode/ABORT))\n AjaxResponse\n (-body [this] (.getResponse this))\n (-status [this] (.getStatus this))\n (-status-text [this] (.getStatusText this))\n (-get-all-headers [this]\n (js->clj (.getResponseHeaders this)))\n (-get-response-header [this header]\n (.getResponseHeader this header))\n (-was-aborted [this]\n (= (.getLastErrorCode this) goog.net.ErrorCode/ABORT)))\n\n(extend-type goog.net.XhrManager\n AjaxImpl\n (-js-ajax-request\n [this {:keys [uri method body headers\n id timeout priority max-retries]\n :or {timeout 0}}\n handler]\n (doto this\n (.setTimeoutInterval timeout)\n (.send id uri method body (clj->js headers)\n priority handler max-retries))))\n"],"x_google_ignoreList":[0]}

View file

@ -0,0 +1,174 @@
goog.provide('ajax.xml_http_request');
ajax.xml_http_request.ready_state = (function ajax$xml_http_request$ready_state(e){
var G__47160 = e.target.readyState;
var fexpr__47159 = new cljs.core.PersistentArrayMap(null, 5, [(0),new cljs.core.Keyword(null,"not-initialized","not-initialized",-1937378906),(1),new cljs.core.Keyword(null,"connection-established","connection-established",-1403749733),(2),new cljs.core.Keyword(null,"request-received","request-received",2110590540),(3),new cljs.core.Keyword(null,"processing-request","processing-request",-264947221),(4),new cljs.core.Keyword(null,"response-ready","response-ready",245208276)], null);
return (fexpr__47159.cljs$core$IFn$_invoke$arity$1 ? fexpr__47159.cljs$core$IFn$_invoke$arity$1(G__47160) : fexpr__47159.call(null,G__47160));
});
ajax.xml_http_request.append = (function ajax$xml_http_request$append(current,next){
if(cljs.core.truth_(current)){
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(current),", ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(next)].join('');
} else {
return next;
}
});
ajax.xml_http_request.process_headers = (function ajax$xml_http_request$process_headers(header_str){
if(cljs.core.truth_(header_str)){
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (headers,header_line){
if(cljs.core.truth_(goog.string.isEmptyOrWhitespace(header_line))){
return headers;
} else {
var key_value = goog.string.splitLimit(header_line,": ",(2));
return cljs.core.update.cljs$core$IFn$_invoke$arity$4(headers,(key_value[(0)]),ajax.xml_http_request.append,(key_value[(1)]));
}
}),cljs.core.PersistentArrayMap.EMPTY,header_str.split("\r\n"));
} else {
return cljs.core.PersistentArrayMap.EMPTY;
}
});
ajax.xml_http_request.xmlhttprequest = (((typeof goog !== 'undefined') && (typeof goog.global !== 'undefined') && (typeof goog.global.XMLHttpRequest !== 'undefined'))?goog.global.XMLHttpRequest:(((typeof require !== 'undefined'))?(function (){var req = require;
return (req.cljs$core$IFn$_invoke$arity$1 ? req.cljs$core$IFn$_invoke$arity$1("xmlhttprequest") : req.call(null,"xmlhttprequest")).XMLHttpRequest;
})():null));
(ajax.xml_http_request.xmlhttprequest.prototype.ajax$protocols$AjaxImpl$ = cljs.core.PROTOCOL_SENTINEL);
(ajax.xml_http_request.xmlhttprequest.prototype.ajax$protocols$AjaxImpl$_js_ajax_request$arity$3 = (function (this$,p__47168,handler){
var map__47169 = p__47168;
var map__47169__$1 = cljs.core.__destructure_map(map__47169);
var uri = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47169__$1,new cljs.core.Keyword(null,"uri","uri",-774711847));
var method = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47169__$1,new cljs.core.Keyword(null,"method","method",55703592));
var body = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47169__$1,new cljs.core.Keyword(null,"body","body",-2049205669));
var headers = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47169__$1,new cljs.core.Keyword(null,"headers","headers",-835030129));
var timeout = cljs.core.get.cljs$core$IFn$_invoke$arity$3(map__47169__$1,new cljs.core.Keyword(null,"timeout","timeout",-318625318),(0));
var with_credentials = cljs.core.get.cljs$core$IFn$_invoke$arity$3(map__47169__$1,new cljs.core.Keyword(null,"with-credentials","with-credentials",-1163127235),false);
var response_format = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__47169__$1,new cljs.core.Keyword(null,"response-format","response-format",1664465322));
var this$__$1 = this;
(this$__$1.withCredentials = with_credentials);
(this$__$1.onreadystatechange = (function (p1__47167_SHARP_){
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(new cljs.core.Keyword(null,"response-ready","response-ready",245208276),ajax.xml_http_request.ready_state(p1__47167_SHARP_))){
return (handler.cljs$core$IFn$_invoke$arity$1 ? handler.cljs$core$IFn$_invoke$arity$1(this$__$1) : handler.call(null,this$__$1));
} else {
return null;
}
}));
this$__$1.open(method,uri,true);
(this$__$1.timeout = timeout);
var temp__5804__auto___47205 = new cljs.core.Keyword(null,"type","type",1174270348).cljs$core$IFn$_invoke$arity$1(response_format);
if(cljs.core.truth_(temp__5804__auto___47205)){
var response_type_47206 = temp__5804__auto___47205;
(this$__$1.responseType = cljs.core.name(response_type_47206));
} else {
}
var seq__47170_47207 = cljs.core.seq(headers);
var chunk__47171_47208 = null;
var count__47172_47209 = (0);
var i__47173_47210 = (0);
while(true){
if((i__47173_47210 < count__47172_47209)){
var vec__47183_47211 = chunk__47171_47208.cljs$core$IIndexed$_nth$arity$2(null,i__47173_47210);
var k_47212 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__47183_47211,(0),null);
var v_47213 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__47183_47211,(1),null);
this$__$1.setRequestHeader(k_47212,v_47213);
var G__47214 = seq__47170_47207;
var G__47215 = chunk__47171_47208;
var G__47216 = count__47172_47209;
var G__47217 = (i__47173_47210 + (1));
seq__47170_47207 = G__47214;
chunk__47171_47208 = G__47215;
count__47172_47209 = G__47216;
i__47173_47210 = G__47217;
continue;
} else {
var temp__5804__auto___47219 = cljs.core.seq(seq__47170_47207);
if(temp__5804__auto___47219){
var seq__47170_47220__$1 = temp__5804__auto___47219;
if(cljs.core.chunked_seq_QMARK_(seq__47170_47220__$1)){
var c__5548__auto___47221 = cljs.core.chunk_first(seq__47170_47220__$1);
var G__47222 = cljs.core.chunk_rest(seq__47170_47220__$1);
var G__47223 = c__5548__auto___47221;
var G__47224 = cljs.core.count(c__5548__auto___47221);
var G__47225 = (0);
seq__47170_47207 = G__47222;
chunk__47171_47208 = G__47223;
count__47172_47209 = G__47224;
i__47173_47210 = G__47225;
continue;
} else {
var vec__47188_47226 = cljs.core.first(seq__47170_47220__$1);
var k_47227 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__47188_47226,(0),null);
var v_47228 = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__47188_47226,(1),null);
this$__$1.setRequestHeader(k_47227,v_47228);
var G__47229 = cljs.core.next(seq__47170_47220__$1);
var G__47230 = null;
var G__47231 = (0);
var G__47232 = (0);
seq__47170_47207 = G__47229;
chunk__47171_47208 = G__47230;
count__47172_47209 = G__47231;
i__47173_47210 = G__47232;
continue;
}
} else {
}
}
break;
}
this$__$1.send((function (){var or__5025__auto__ = body;
if(cljs.core.truth_(or__5025__auto__)){
return or__5025__auto__;
} else {
return "";
}
})());
return this$__$1;
}));
(ajax.xml_http_request.xmlhttprequest.prototype.ajax$protocols$AjaxRequest$ = cljs.core.PROTOCOL_SENTINEL);
(ajax.xml_http_request.xmlhttprequest.prototype.ajax$protocols$AjaxRequest$_abort$arity$1 = (function (this$){
var this$__$1 = this;
return this$__$1.abort();
}));
(ajax.xml_http_request.xmlhttprequest.prototype.ajax$protocols$AjaxResponse$ = cljs.core.PROTOCOL_SENTINEL);
(ajax.xml_http_request.xmlhttprequest.prototype.ajax$protocols$AjaxResponse$_body$arity$1 = (function (this$){
var this$__$1 = this;
return this$__$1.response;
}));
(ajax.xml_http_request.xmlhttprequest.prototype.ajax$protocols$AjaxResponse$_status$arity$1 = (function (this$){
var this$__$1 = this;
return this$__$1.status;
}));
(ajax.xml_http_request.xmlhttprequest.prototype.ajax$protocols$AjaxResponse$_status_text$arity$1 = (function (this$){
var this$__$1 = this;
return this$__$1.statusText;
}));
(ajax.xml_http_request.xmlhttprequest.prototype.ajax$protocols$AjaxResponse$_get_all_headers$arity$1 = (function (this$){
var this$__$1 = this;
return ajax.xml_http_request.process_headers(this$__$1.getAllResponseHeaders());
}));
(ajax.xml_http_request.xmlhttprequest.prototype.ajax$protocols$AjaxResponse$_get_response_header$arity$2 = (function (this$,header){
var this$__$1 = this;
return this$__$1.getResponseHeader(header);
}));
(ajax.xml_http_request.xmlhttprequest.prototype.ajax$protocols$AjaxResponse$_was_aborted$arity$1 = (function (this$){
var this$__$1 = this;
return cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2((0),this$__$1.readyState);
}));
//# sourceMappingURL=ajax.xml_http_request.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,128 @@
goog.provide('applied_science.js_interop.impl');
/**
* Returns `k` or, if it is a keyword, its name.
*/
applied_science.js_interop.impl.wrap_key = (function applied_science$js_interop$impl$wrap_key(k){
var G__53886 = k;
if((k instanceof cljs.core.Keyword)){
return cljs.core.name(G__53886);
} else {
return G__53886;
}
});
applied_science.js_interop.impl.in_QMARK__STAR_ = (function applied_science$js_interop$impl$in_QMARK__STAR_(k_STAR_,obj){
return k_STAR_ in obj;
});
applied_science.js_interop.impl.contains_QMARK__STAR_ = (function applied_science$js_interop$impl$contains_QMARK__STAR_(obj,k_STAR_){
return (((!((obj == null)))) && (applied_science.js_interop.impl.in_QMARK__STAR_(k_STAR_,obj)));
});
applied_science.js_interop.impl.get_PLUS__BANG_ = (function applied_science$js_interop$impl$get_PLUS__BANG_(o,k_STAR_){
var temp__5806__auto__ = (o[k_STAR_]);
if((temp__5806__auto__ == null)){
return (o[k_STAR_] = ({}));
} else {
var child_obj = temp__5806__auto__;
return child_obj;
}
});
/**
* Look up `ks` in `obj`, stopping at any nil
*/
applied_science.js_interop.impl.get_value_by_keys = (function applied_science$js_interop$impl$get_value_by_keys(obj,ks_STAR_){
if(cljs.core.truth_(obj)){
var end = cljs.core.count(ks_STAR_);
var i = (0);
var obj__$1 = obj;
while(true){
if(((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(i,end)) || ((obj__$1 == null)))){
return obj__$1;
} else {
var G__53930 = (i + (1));
var G__53931 = (obj__$1[cljs.core.nth.cljs$core$IFn$_invoke$arity$2(ks_STAR_,i)]);
i = G__53930;
obj__$1 = G__53931;
continue;
}
break;
}
} else {
return null;
}
});
applied_science.js_interop.impl.get_in_STAR_ = (function applied_science$js_interop$impl$get_in_STAR_(var_args){
var G__53898 = arguments.length;
switch (G__53898) {
case 2:
return applied_science.js_interop.impl.get_in_STAR_.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
case 3:
return applied_science.js_interop.impl.get_in_STAR_.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(applied_science.js_interop.impl.get_in_STAR_.cljs$core$IFn$_invoke$arity$2 = (function (obj,ks_STAR_){
return applied_science.js_interop.impl.get_value_by_keys(obj,ks_STAR_);
}));
(applied_science.js_interop.impl.get_in_STAR_.cljs$core$IFn$_invoke$arity$3 = (function (obj,ks_STAR_,not_found){
var temp__5806__auto__ = applied_science.js_interop.impl.get_value_by_keys(obj,cljs.core.butlast(ks_STAR_));
if((temp__5806__auto__ == null)){
return not_found;
} else {
var last_obj = temp__5806__auto__;
var k = cljs.core.peek(ks_STAR_);
if(cljs.core.truth_(k in last_obj)){
return (last_obj[applied_science.js_interop.impl.wrap_key(k)]);
} else {
return not_found;
}
}
}));
(applied_science.js_interop.impl.get_in_STAR_.cljs$lang$maxFixedArity = 3);
/**
* Returns an object containing only those entries in `o` whose key is in `ks`
*/
applied_science.js_interop.impl.select_keys_STAR_ = (function applied_science$js_interop$impl$select_keys_STAR_(obj,ks_STAR_){
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (m,k){
var G__53912 = m;
if(applied_science.js_interop.impl.contains_QMARK__STAR_(obj,k)){
var G__53913 = G__53912;
(G__53913[k] = (obj[k]));
return G__53913;
} else {
return G__53912;
}
}),({}),ks_STAR_);
});
applied_science.js_interop.impl.assoc_in_STAR_ = (function applied_science$js_interop$impl$assoc_in_STAR_(obj,ks_STAR_,v){
var obj__$1 = (((!((obj == null))))?obj:({}));
var inner_obj = cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(applied_science.js_interop.impl.get_PLUS__BANG_,obj__$1,cljs.core.butlast(ks_STAR_));
(inner_obj[cljs.core.peek(ks_STAR_)] = v);
return obj__$1;
});
applied_science.js_interop.impl.update_in_STAR_ = (function applied_science$js_interop$impl$update_in_STAR_(obj,ks_STAR_,f,args){
var obj__$1 = (((!((obj == null))))?obj:({}));
var last_k_STAR_ = cljs.core.peek(ks_STAR_);
var inner_obj = cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(applied_science.js_interop.impl.get_PLUS__BANG_,obj__$1,cljs.core.butlast(ks_STAR_));
var old_val = (inner_obj[last_k_STAR_]);
(inner_obj[last_k_STAR_] = cljs.core.apply.cljs$core$IFn$_invoke$arity$3(f,old_val,args));
return obj__$1;
});
applied_science.js_interop.impl.apply_in_STAR_ = (function applied_science$js_interop$impl$apply_in_STAR_(obj,ks_STAR_,arg_array){
var parent = applied_science.js_interop.impl.get_in_STAR_.cljs$core$IFn$_invoke$arity$2(obj,cljs.core.pop(ks_STAR_));
var f = (parent[cljs.core.peek(ks_STAR_)]);
return f.apply(parent,arg_array);
});
//# sourceMappingURL=applied_science.js_interop.impl.js.map

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,462 @@
goog.provide('cljs.core.async.impl.buffers');
cljs.core.async.impl.buffers.acopy = (function cljs$core$async$impl$buffers$acopy(src,src_start,dest,dest_start,len){
var cnt = (0);
while(true){
if((cnt < len)){
(dest[(dest_start + cnt)] = (src[(src_start + cnt)]));
var G__32109 = (cnt + (1));
cnt = G__32109;
continue;
} else {
return null;
}
break;
}
});
/**
* @constructor
*/
cljs.core.async.impl.buffers.RingBuffer = (function (head,tail,length,arr){
this.head = head;
this.tail = tail;
this.length = length;
this.arr = arr;
});
(cljs.core.async.impl.buffers.RingBuffer.prototype.pop = (function (){
var self__ = this;
var _ = this;
if((self__.length === (0))){
return null;
} else {
var x = (self__.arr[self__.tail]);
(self__.arr[self__.tail] = null);
(self__.tail = ((self__.tail + (1)) % self__.arr.length));
(self__.length = (self__.length - (1)));
return x;
}
}));
(cljs.core.async.impl.buffers.RingBuffer.prototype.unshift = (function (x){
var self__ = this;
var _ = this;
(self__.arr[self__.head] = x);
(self__.head = ((self__.head + (1)) % self__.arr.length));
(self__.length = (self__.length + (1)));
return null;
}));
(cljs.core.async.impl.buffers.RingBuffer.prototype.unbounded_unshift = (function (x){
var self__ = this;
var this$ = this;
if(((self__.length + (1)) === self__.arr.length)){
this$.resize();
} else {
}
return this$.unshift(x);
}));
(cljs.core.async.impl.buffers.RingBuffer.prototype.resize = (function (){
var self__ = this;
var _ = this;
var new_arr_size = (self__.arr.length * (2));
var new_arr = (new Array(new_arr_size));
if((self__.tail < self__.head)){
cljs.core.async.impl.buffers.acopy(self__.arr,self__.tail,new_arr,(0),self__.length);
(self__.tail = (0));
(self__.head = self__.length);
return (self__.arr = new_arr);
} else {
if((self__.tail > self__.head)){
cljs.core.async.impl.buffers.acopy(self__.arr,self__.tail,new_arr,(0),(self__.arr.length - self__.tail));
cljs.core.async.impl.buffers.acopy(self__.arr,(0),new_arr,(self__.arr.length - self__.tail),self__.head);
(self__.tail = (0));
(self__.head = self__.length);
return (self__.arr = new_arr);
} else {
if((self__.tail === self__.head)){
(self__.tail = (0));
(self__.head = (0));
return (self__.arr = new_arr);
} else {
return null;
}
}
}
}));
(cljs.core.async.impl.buffers.RingBuffer.prototype.cleanup = (function (keep_QMARK_){
var self__ = this;
var this$ = this;
var n__5616__auto__ = self__.length;
var x = (0);
while(true){
if((x < n__5616__auto__)){
var v_32110 = this$.pop();
if((keep_QMARK_.cljs$core$IFn$_invoke$arity$1 ? keep_QMARK_.cljs$core$IFn$_invoke$arity$1(v_32110) : keep_QMARK_.call(null,v_32110))){
this$.unshift(v_32110);
} else {
}
var G__32111 = (x + (1));
x = G__32111;
continue;
} else {
return null;
}
break;
}
}));
(cljs.core.async.impl.buffers.RingBuffer.getBasis = (function (){
return new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(new cljs.core.Symbol(null,"head","head",869147608,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"tail","tail",494507963,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"length","length",-2065447907,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"arr","arr",2115492975,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null))], null);
}));
(cljs.core.async.impl.buffers.RingBuffer.cljs$lang$type = true);
(cljs.core.async.impl.buffers.RingBuffer.cljs$lang$ctorStr = "cljs.core.async.impl.buffers/RingBuffer");
(cljs.core.async.impl.buffers.RingBuffer.cljs$lang$ctorPrWriter = (function (this__5310__auto__,writer__5311__auto__,opt__5312__auto__){
return cljs.core._write(writer__5311__auto__,"cljs.core.async.impl.buffers/RingBuffer");
}));
/**
* Positional factory function for cljs.core.async.impl.buffers/RingBuffer.
*/
cljs.core.async.impl.buffers.__GT_RingBuffer = (function cljs$core$async$impl$buffers$__GT_RingBuffer(head,tail,length,arr){
return (new cljs.core.async.impl.buffers.RingBuffer(head,tail,length,arr));
});
cljs.core.async.impl.buffers.ring_buffer = (function cljs$core$async$impl$buffers$ring_buffer(n){
if((n > (0))){
} else {
throw (new Error(["Assert failed: ","Can't create a ring buffer of size 0","\n","(> n 0)"].join('')));
}
return (new cljs.core.async.impl.buffers.RingBuffer((0),(0),(0),(new Array(n))));
});
/**
* @constructor
* @implements {cljs.core.ICounted}
* @implements {cljs.core.async.impl.protocols.Buffer}
*/
cljs.core.async.impl.buffers.FixedBuffer = (function (buf,n){
this.buf = buf;
this.n = n;
this.cljs$lang$protocol_mask$partition0$ = 2;
this.cljs$lang$protocol_mask$partition1$ = 0;
});
(cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$async$impl$protocols$Buffer$ = cljs.core.PROTOCOL_SENTINEL);
(cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return (self__.buf.length >= self__.n);
}));
(cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return self__.buf.pop();
}));
(cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2 = (function (this$,itm){
var self__ = this;
var this$__$1 = this;
self__.buf.unbounded_unshift(itm);
return this$__$1;
}));
(cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return null;
}));
(cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$ICounted$_count$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return self__.buf.length;
}));
(cljs.core.async.impl.buffers.FixedBuffer.getBasis = (function (){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"buf","buf",1426618187,null),new cljs.core.Symbol(null,"n","n",-2092305744,null)], null);
}));
(cljs.core.async.impl.buffers.FixedBuffer.cljs$lang$type = true);
(cljs.core.async.impl.buffers.FixedBuffer.cljs$lang$ctorStr = "cljs.core.async.impl.buffers/FixedBuffer");
(cljs.core.async.impl.buffers.FixedBuffer.cljs$lang$ctorPrWriter = (function (this__5310__auto__,writer__5311__auto__,opt__5312__auto__){
return cljs.core._write(writer__5311__auto__,"cljs.core.async.impl.buffers/FixedBuffer");
}));
/**
* Positional factory function for cljs.core.async.impl.buffers/FixedBuffer.
*/
cljs.core.async.impl.buffers.__GT_FixedBuffer = (function cljs$core$async$impl$buffers$__GT_FixedBuffer(buf,n){
return (new cljs.core.async.impl.buffers.FixedBuffer(buf,n));
});
cljs.core.async.impl.buffers.fixed_buffer = (function cljs$core$async$impl$buffers$fixed_buffer(n){
return (new cljs.core.async.impl.buffers.FixedBuffer(cljs.core.async.impl.buffers.ring_buffer(n),n));
});
/**
* @constructor
* @implements {cljs.core.ICounted}
* @implements {cljs.core.async.impl.protocols.UnblockingBuffer}
* @implements {cljs.core.async.impl.protocols.Buffer}
*/
cljs.core.async.impl.buffers.DroppingBuffer = (function (buf,n){
this.buf = buf;
this.n = n;
this.cljs$lang$protocol_mask$partition0$ = 2;
this.cljs$lang$protocol_mask$partition1$ = 0;
});
(cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$UnblockingBuffer$ = cljs.core.PROTOCOL_SENTINEL);
(cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$ = cljs.core.PROTOCOL_SENTINEL);
(cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return false;
}));
(cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return self__.buf.pop();
}));
(cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2 = (function (this$,itm){
var self__ = this;
var this$__$1 = this;
if((self__.buf.length === self__.n)){
} else {
self__.buf.unshift(itm);
}
return this$__$1;
}));
(cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return null;
}));
(cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$ICounted$_count$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return self__.buf.length;
}));
(cljs.core.async.impl.buffers.DroppingBuffer.getBasis = (function (){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"buf","buf",1426618187,null),new cljs.core.Symbol(null,"n","n",-2092305744,null)], null);
}));
(cljs.core.async.impl.buffers.DroppingBuffer.cljs$lang$type = true);
(cljs.core.async.impl.buffers.DroppingBuffer.cljs$lang$ctorStr = "cljs.core.async.impl.buffers/DroppingBuffer");
(cljs.core.async.impl.buffers.DroppingBuffer.cljs$lang$ctorPrWriter = (function (this__5310__auto__,writer__5311__auto__,opt__5312__auto__){
return cljs.core._write(writer__5311__auto__,"cljs.core.async.impl.buffers/DroppingBuffer");
}));
/**
* Positional factory function for cljs.core.async.impl.buffers/DroppingBuffer.
*/
cljs.core.async.impl.buffers.__GT_DroppingBuffer = (function cljs$core$async$impl$buffers$__GT_DroppingBuffer(buf,n){
return (new cljs.core.async.impl.buffers.DroppingBuffer(buf,n));
});
cljs.core.async.impl.buffers.dropping_buffer = (function cljs$core$async$impl$buffers$dropping_buffer(n){
return (new cljs.core.async.impl.buffers.DroppingBuffer(cljs.core.async.impl.buffers.ring_buffer(n),n));
});
/**
* @constructor
* @implements {cljs.core.ICounted}
* @implements {cljs.core.async.impl.protocols.UnblockingBuffer}
* @implements {cljs.core.async.impl.protocols.Buffer}
*/
cljs.core.async.impl.buffers.SlidingBuffer = (function (buf,n){
this.buf = buf;
this.n = n;
this.cljs$lang$protocol_mask$partition0$ = 2;
this.cljs$lang$protocol_mask$partition1$ = 0;
});
(cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$UnblockingBuffer$ = cljs.core.PROTOCOL_SENTINEL);
(cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$ = cljs.core.PROTOCOL_SENTINEL);
(cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return false;
}));
(cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return self__.buf.pop();
}));
(cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2 = (function (this$,itm){
var self__ = this;
var this$__$1 = this;
if((self__.buf.length === self__.n)){
this$__$1.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1(null);
} else {
}
self__.buf.unshift(itm);
return this$__$1;
}));
(cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return null;
}));
(cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$ICounted$_count$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return self__.buf.length;
}));
(cljs.core.async.impl.buffers.SlidingBuffer.getBasis = (function (){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"buf","buf",1426618187,null),new cljs.core.Symbol(null,"n","n",-2092305744,null)], null);
}));
(cljs.core.async.impl.buffers.SlidingBuffer.cljs$lang$type = true);
(cljs.core.async.impl.buffers.SlidingBuffer.cljs$lang$ctorStr = "cljs.core.async.impl.buffers/SlidingBuffer");
(cljs.core.async.impl.buffers.SlidingBuffer.cljs$lang$ctorPrWriter = (function (this__5310__auto__,writer__5311__auto__,opt__5312__auto__){
return cljs.core._write(writer__5311__auto__,"cljs.core.async.impl.buffers/SlidingBuffer");
}));
/**
* Positional factory function for cljs.core.async.impl.buffers/SlidingBuffer.
*/
cljs.core.async.impl.buffers.__GT_SlidingBuffer = (function cljs$core$async$impl$buffers$__GT_SlidingBuffer(buf,n){
return (new cljs.core.async.impl.buffers.SlidingBuffer(buf,n));
});
cljs.core.async.impl.buffers.sliding_buffer = (function cljs$core$async$impl$buffers$sliding_buffer(n){
return (new cljs.core.async.impl.buffers.SlidingBuffer(cljs.core.async.impl.buffers.ring_buffer(n),n));
});
if((typeof cljs !== 'undefined') && (typeof cljs.core !== 'undefined') && (typeof cljs.core.async !== 'undefined') && (typeof cljs.core.async.impl !== 'undefined') && (typeof cljs.core.async.impl.buffers !== 'undefined') && (typeof cljs.core.async.impl.buffers.NO_VAL !== 'undefined')){
} else {
cljs.core.async.impl.buffers.NO_VAL = (new Object());
}
cljs.core.async.impl.buffers.undelivered_QMARK_ = (function cljs$core$async$impl$buffers$undelivered_QMARK_(val){
return (cljs.core.async.impl.buffers.NO_VAL === val);
});
/**
* @constructor
* @implements {cljs.core.ICounted}
* @implements {cljs.core.async.impl.protocols.UnblockingBuffer}
* @implements {cljs.core.async.impl.protocols.Buffer}
*/
cljs.core.async.impl.buffers.PromiseBuffer = (function (val){
this.val = val;
this.cljs$lang$protocol_mask$partition0$ = 2;
this.cljs$lang$protocol_mask$partition1$ = 0;
});
(cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$UnblockingBuffer$ = cljs.core.PROTOCOL_SENTINEL);
(cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$Buffer$ = cljs.core.PROTOCOL_SENTINEL);
(cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1 = (function (_){
var self__ = this;
var ___$1 = this;
return false;
}));
(cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1 = (function (_){
var self__ = this;
var ___$1 = this;
return self__.val;
}));
(cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2 = (function (this$,itm){
var self__ = this;
var this$__$1 = this;
if(cljs.core.async.impl.buffers.undelivered_QMARK_(self__.val)){
(self__.val = itm);
} else {
}
return this$__$1;
}));
(cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1 = (function (_){
var self__ = this;
var ___$1 = this;
if(cljs.core.async.impl.buffers.undelivered_QMARK_(self__.val)){
return (self__.val = null);
} else {
return null;
}
}));
(cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$ICounted$_count$arity$1 = (function (_){
var self__ = this;
var ___$1 = this;
if(cljs.core.async.impl.buffers.undelivered_QMARK_(self__.val)){
return (0);
} else {
return (1);
}
}));
(cljs.core.async.impl.buffers.PromiseBuffer.getBasis = (function (){
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(new cljs.core.Symbol(null,"val","val",1769233139,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null))], null);
}));
(cljs.core.async.impl.buffers.PromiseBuffer.cljs$lang$type = true);
(cljs.core.async.impl.buffers.PromiseBuffer.cljs$lang$ctorStr = "cljs.core.async.impl.buffers/PromiseBuffer");
(cljs.core.async.impl.buffers.PromiseBuffer.cljs$lang$ctorPrWriter = (function (this__5310__auto__,writer__5311__auto__,opt__5312__auto__){
return cljs.core._write(writer__5311__auto__,"cljs.core.async.impl.buffers/PromiseBuffer");
}));
/**
* Positional factory function for cljs.core.async.impl.buffers/PromiseBuffer.
*/
cljs.core.async.impl.buffers.__GT_PromiseBuffer = (function cljs$core$async$impl$buffers$__GT_PromiseBuffer(val){
return (new cljs.core.async.impl.buffers.PromiseBuffer(val));
});
cljs.core.async.impl.buffers.promise_buffer = (function cljs$core$async$impl$buffers$promise_buffer(){
return (new cljs.core.async.impl.buffers.PromiseBuffer(cljs.core.async.impl.buffers.NO_VAL));
});
//# sourceMappingURL=cljs.core.async.impl.buffers.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,682 @@
goog.provide('cljs.core.async.impl.channels');
/**
* @constructor
* @implements {cljs.core.IMeta}
* @implements {cljs.core.IDeref}
* @implements {cljs.core.IWithMeta}
*/
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels32242 = (function (val,meta32243){
this.val = val;
this.meta32243 = meta32243;
this.cljs$lang$protocol_mask$partition0$ = 425984;
this.cljs$lang$protocol_mask$partition1$ = 0;
});
(cljs.core.async.impl.channels.t_cljs$core$async$impl$channels32242.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (_32244,meta32243__$1){
var self__ = this;
var _32244__$1 = this;
return (new cljs.core.async.impl.channels.t_cljs$core$async$impl$channels32242(self__.val,meta32243__$1));
}));
(cljs.core.async.impl.channels.t_cljs$core$async$impl$channels32242.prototype.cljs$core$IMeta$_meta$arity$1 = (function (_32244){
var self__ = this;
var _32244__$1 = this;
return self__.meta32243;
}));
(cljs.core.async.impl.channels.t_cljs$core$async$impl$channels32242.prototype.cljs$core$IDeref$_deref$arity$1 = (function (_){
var self__ = this;
var ___$1 = this;
return self__.val;
}));
(cljs.core.async.impl.channels.t_cljs$core$async$impl$channels32242.getBasis = (function (){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"val","val",1769233139,null),new cljs.core.Symbol(null,"meta32243","meta32243",-303455196,null)], null);
}));
(cljs.core.async.impl.channels.t_cljs$core$async$impl$channels32242.cljs$lang$type = true);
(cljs.core.async.impl.channels.t_cljs$core$async$impl$channels32242.cljs$lang$ctorStr = "cljs.core.async.impl.channels/t_cljs$core$async$impl$channels32242");
(cljs.core.async.impl.channels.t_cljs$core$async$impl$channels32242.cljs$lang$ctorPrWriter = (function (this__5310__auto__,writer__5311__auto__,opt__5312__auto__){
return cljs.core._write(writer__5311__auto__,"cljs.core.async.impl.channels/t_cljs$core$async$impl$channels32242");
}));
/**
* Positional factory function for cljs.core.async.impl.channels/t_cljs$core$async$impl$channels32242.
*/
cljs.core.async.impl.channels.__GT_t_cljs$core$async$impl$channels32242 = (function cljs$core$async$impl$channels$__GT_t_cljs$core$async$impl$channels32242(val,meta32243){
return (new cljs.core.async.impl.channels.t_cljs$core$async$impl$channels32242(val,meta32243));
});
cljs.core.async.impl.channels.box = (function cljs$core$async$impl$channels$box(val){
return (new cljs.core.async.impl.channels.t_cljs$core$async$impl$channels32242(val,cljs.core.PersistentArrayMap.EMPTY));
});
/**
* @constructor
*/
cljs.core.async.impl.channels.PutBox = (function (handler,val){
this.handler = handler;
this.val = val;
});
(cljs.core.async.impl.channels.PutBox.getBasis = (function (){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"handler","handler",1444934915,null),new cljs.core.Symbol(null,"val","val",1769233139,null)], null);
}));
(cljs.core.async.impl.channels.PutBox.cljs$lang$type = true);
(cljs.core.async.impl.channels.PutBox.cljs$lang$ctorStr = "cljs.core.async.impl.channels/PutBox");
(cljs.core.async.impl.channels.PutBox.cljs$lang$ctorPrWriter = (function (this__5310__auto__,writer__5311__auto__,opt__5312__auto__){
return cljs.core._write(writer__5311__auto__,"cljs.core.async.impl.channels/PutBox");
}));
/**
* Positional factory function for cljs.core.async.impl.channels/PutBox.
*/
cljs.core.async.impl.channels.__GT_PutBox = (function cljs$core$async$impl$channels$__GT_PutBox(handler,val){
return (new cljs.core.async.impl.channels.PutBox(handler,val));
});
cljs.core.async.impl.channels.put_active_QMARK_ = (function cljs$core$async$impl$channels$put_active_QMARK_(box){
return cljs.core.async.impl.protocols.active_QMARK_(box.handler);
});
cljs.core.async.impl.channels.MAX_DIRTY = (64);
/**
* @interface
*/
cljs.core.async.impl.channels.MMC = function(){};
var cljs$core$async$impl$channels$MMC$abort$dyn_32534 = (function (this$){
var x__5373__auto__ = (((this$ == null))?null:this$);
var m__5374__auto__ = (cljs.core.async.impl.channels.abort[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$1(this$) : m__5374__auto__.call(null,this$));
} else {
var m__5372__auto__ = (cljs.core.async.impl.channels.abort["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$1(this$) : m__5372__auto__.call(null,this$));
} else {
throw cljs.core.missing_protocol("MMC.abort",this$);
}
}
});
cljs.core.async.impl.channels.abort = (function cljs$core$async$impl$channels$abort(this$){
if((((!((this$ == null)))) && ((!((this$.cljs$core$async$impl$channels$MMC$abort$arity$1 == null)))))){
return this$.cljs$core$async$impl$channels$MMC$abort$arity$1(this$);
} else {
return cljs$core$async$impl$channels$MMC$abort$dyn_32534(this$);
}
});
/**
* @constructor
* @implements {cljs.core.async.impl.channels.MMC}
* @implements {cljs.core.async.impl.protocols.Channel}
* @implements {cljs.core.async.impl.protocols.WritePort}
* @implements {cljs.core.async.impl.protocols.ReadPort}
*/
cljs.core.async.impl.channels.ManyToManyChannel = (function (takes,dirty_takes,puts,dirty_puts,buf,closed,add_BANG_){
this.takes = takes;
this.dirty_takes = dirty_takes;
this.puts = puts;
this.dirty_puts = dirty_puts;
this.buf = buf;
this.closed = closed;
this.add_BANG_ = add_BANG_;
});
(cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$channels$MMC$ = cljs.core.PROTOCOL_SENTINEL);
(cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$channels$MMC$abort$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
while(true){
var putter_32541 = self__.puts.pop();
if((putter_32541 == null)){
} else {
var put_handler_32542 = putter_32541.handler;
var val_32543 = putter_32541.val;
if(put_handler_32542.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1(null)){
var put_cb_32549 = put_handler_32542.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
cljs.core.async.impl.dispatch.run(((function (put_cb_32549,put_handler_32542,val_32543,putter_32541,this$__$1){
return (function (){
return (put_cb_32549.cljs$core$IFn$_invoke$arity$1 ? put_cb_32549.cljs$core$IFn$_invoke$arity$1(true) : put_cb_32549.call(null,true));
});})(put_cb_32549,put_handler_32542,val_32543,putter_32541,this$__$1))
);
} else {
continue;
}
}
break;
}
self__.puts.cleanup(cljs.core.constantly(false));
return this$__$1.cljs$core$async$impl$protocols$Channel$close_BANG_$arity$1(null);
}));
(cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$WritePort$ = cljs.core.PROTOCOL_SENTINEL);
(cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$WritePort$put_BANG_$arity$3 = (function (this$,val,handler){
var self__ = this;
var this$__$1 = this;
if((!((val == null)))){
} else {
throw (new Error(["Assert failed: ","Can't put nil on a channel","\n","(not (nil? val))"].join('')));
}
var closed__$1 = self__.closed;
if((!(handler.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1(null)))){
return cljs.core.async.impl.channels.box((!(closed__$1)));
} else {
if(closed__$1){
handler.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
return cljs.core.async.impl.channels.box(false);
} else {
if(cljs.core.truth_((function (){var and__5023__auto__ = self__.buf;
if(cljs.core.truth_(and__5023__auto__)){
return cljs.core.not(self__.buf.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1(null));
} else {
return and__5023__auto__;
}
})())){
handler.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
var done_QMARK_ = cljs.core.reduced_QMARK_((self__.add_BANG_.cljs$core$IFn$_invoke$arity$2 ? self__.add_BANG_.cljs$core$IFn$_invoke$arity$2(self__.buf,val) : self__.add_BANG_.call(null,self__.buf,val)));
var take_cbs = (function (){var takers = cljs.core.PersistentVector.EMPTY;
while(true){
if((((self__.takes.length > (0))) && ((cljs.core.count(self__.buf) > (0))))){
var taker = self__.takes.pop();
if(taker.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1(null)){
var ret = taker.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
var val__$1 = self__.buf.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1(null);
var G__32561 = cljs.core.conj.cljs$core$IFn$_invoke$arity$2(takers,((function (takers,ret,val__$1,taker,done_QMARK_,closed__$1,this$__$1){
return (function (){
return (ret.cljs$core$IFn$_invoke$arity$1 ? ret.cljs$core$IFn$_invoke$arity$1(val__$1) : ret.call(null,val__$1));
});})(takers,ret,val__$1,taker,done_QMARK_,closed__$1,this$__$1))
);
takers = G__32561;
continue;
} else {
var G__32565 = takers;
takers = G__32565;
continue;
}
} else {
return takers;
}
break;
}
})();
if(done_QMARK_){
this$__$1.cljs$core$async$impl$channels$MMC$abort$arity$1(null);
} else {
}
if(cljs.core.seq(take_cbs)){
var seq__32335_32569 = cljs.core.seq(take_cbs);
var chunk__32336_32570 = null;
var count__32337_32571 = (0);
var i__32338_32572 = (0);
while(true){
if((i__32338_32572 < count__32337_32571)){
var f_32574 = chunk__32336_32570.cljs$core$IIndexed$_nth$arity$2(null,i__32338_32572);
cljs.core.async.impl.dispatch.run(f_32574);
var G__32575 = seq__32335_32569;
var G__32576 = chunk__32336_32570;
var G__32577 = count__32337_32571;
var G__32578 = (i__32338_32572 + (1));
seq__32335_32569 = G__32575;
chunk__32336_32570 = G__32576;
count__32337_32571 = G__32577;
i__32338_32572 = G__32578;
continue;
} else {
var temp__5804__auto___32581 = cljs.core.seq(seq__32335_32569);
if(temp__5804__auto___32581){
var seq__32335_32583__$1 = temp__5804__auto___32581;
if(cljs.core.chunked_seq_QMARK_(seq__32335_32583__$1)){
var c__5548__auto___32585 = cljs.core.chunk_first(seq__32335_32583__$1);
var G__32586 = cljs.core.chunk_rest(seq__32335_32583__$1);
var G__32587 = c__5548__auto___32585;
var G__32588 = cljs.core.count(c__5548__auto___32585);
var G__32589 = (0);
seq__32335_32569 = G__32586;
chunk__32336_32570 = G__32587;
count__32337_32571 = G__32588;
i__32338_32572 = G__32589;
continue;
} else {
var f_32592 = cljs.core.first(seq__32335_32583__$1);
cljs.core.async.impl.dispatch.run(f_32592);
var G__32593 = cljs.core.next(seq__32335_32583__$1);
var G__32594 = null;
var G__32595 = (0);
var G__32596 = (0);
seq__32335_32569 = G__32593;
chunk__32336_32570 = G__32594;
count__32337_32571 = G__32595;
i__32338_32572 = G__32596;
continue;
}
} else {
}
}
break;
}
} else {
}
return cljs.core.async.impl.channels.box(true);
} else {
var taker = (function (){while(true){
var taker = self__.takes.pop();
if(cljs.core.truth_(taker)){
if(cljs.core.truth_(taker.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1(null))){
return taker;
} else {
continue;
}
} else {
return null;
}
break;
}
})();
if(cljs.core.truth_(taker)){
var take_cb = taker.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
handler.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
cljs.core.async.impl.dispatch.run((function (){
return (take_cb.cljs$core$IFn$_invoke$arity$1 ? take_cb.cljs$core$IFn$_invoke$arity$1(val) : take_cb.call(null,val));
}));
return cljs.core.async.impl.channels.box(true);
} else {
if((self__.dirty_puts > (64))){
(self__.dirty_puts = (0));
self__.puts.cleanup(cljs.core.async.impl.channels.put_active_QMARK_);
} else {
(self__.dirty_puts = (self__.dirty_puts + (1)));
}
if(cljs.core.truth_(handler.cljs$core$async$impl$protocols$Handler$blockable_QMARK_$arity$1(null))){
if((self__.puts.length < (1024))){
} else {
throw (new Error(["Assert failed: ",["No more than ",cljs.core.str.cljs$core$IFn$_invoke$arity$1((1024))," pending puts are allowed on a single channel."," Consider using a windowed buffer."].join(''),"\n","(< (.-length puts) impl/MAX-QUEUE-SIZE)"].join('')));
}
self__.puts.unbounded_unshift((new cljs.core.async.impl.channels.PutBox(handler,val)));
} else {
}
return null;
}
}
}
}
}));
(cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$ReadPort$ = cljs.core.PROTOCOL_SENTINEL);
(cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$ReadPort$take_BANG_$arity$2 = (function (this$,handler){
var self__ = this;
var this$__$1 = this;
if((!(handler.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1(null)))){
return null;
} else {
if((((!((self__.buf == null)))) && ((cljs.core.count(self__.buf) > (0))))){
var temp__5802__auto__ = handler.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
if(cljs.core.truth_(temp__5802__auto__)){
var take_cb = temp__5802__auto__;
var val = self__.buf.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1(null);
var vec__32350 = ((((cljs.core.not(self__.buf.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1(null))) && ((self__.puts.length > (0)))))?(function (){var cbs = cljs.core.PersistentVector.EMPTY;
while(true){
var putter = self__.puts.pop();
var put_handler = putter.handler;
var val__$1 = putter.val;
var cb = (function (){var and__5023__auto__ = put_handler.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1(null);
if(and__5023__auto__){
return put_handler.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
} else {
return and__5023__auto__;
}
})();
var cbs__$1 = (cljs.core.truth_(cb)?cljs.core.conj.cljs$core$IFn$_invoke$arity$2(cbs,cb):cbs);
var done_QMARK_ = (cljs.core.truth_(cb)?cljs.core.reduced_QMARK_((self__.add_BANG_.cljs$core$IFn$_invoke$arity$2 ? self__.add_BANG_.cljs$core$IFn$_invoke$arity$2(self__.buf,val__$1) : self__.add_BANG_.call(null,self__.buf,val__$1))):null);
if(((cljs.core.not(done_QMARK_)) && (((cljs.core.not(self__.buf.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1(null))) && ((self__.puts.length > (0))))))){
var G__32619 = cbs__$1;
cbs = G__32619;
continue;
} else {
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [done_QMARK_,cbs__$1], null);
}
break;
}
})():null);
var done_QMARK_ = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__32350,(0),null);
var cbs = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__32350,(1),null);
if(cljs.core.truth_(done_QMARK_)){
this$__$1.cljs$core$async$impl$channels$MMC$abort$arity$1(null);
} else {
}
var seq__32364_32624 = cljs.core.seq(cbs);
var chunk__32365_32625 = null;
var count__32366_32626 = (0);
var i__32367_32627 = (0);
while(true){
if((i__32367_32627 < count__32366_32626)){
var cb_32628 = chunk__32365_32625.cljs$core$IIndexed$_nth$arity$2(null,i__32367_32627);
cljs.core.async.impl.dispatch.run(((function (seq__32364_32624,chunk__32365_32625,count__32366_32626,i__32367_32627,cb_32628,val,vec__32350,done_QMARK_,cbs,take_cb,temp__5802__auto__,this$__$1){
return (function (){
return (cb_32628.cljs$core$IFn$_invoke$arity$1 ? cb_32628.cljs$core$IFn$_invoke$arity$1(true) : cb_32628.call(null,true));
});})(seq__32364_32624,chunk__32365_32625,count__32366_32626,i__32367_32627,cb_32628,val,vec__32350,done_QMARK_,cbs,take_cb,temp__5802__auto__,this$__$1))
);
var G__32629 = seq__32364_32624;
var G__32630 = chunk__32365_32625;
var G__32631 = count__32366_32626;
var G__32632 = (i__32367_32627 + (1));
seq__32364_32624 = G__32629;
chunk__32365_32625 = G__32630;
count__32366_32626 = G__32631;
i__32367_32627 = G__32632;
continue;
} else {
var temp__5804__auto___32633 = cljs.core.seq(seq__32364_32624);
if(temp__5804__auto___32633){
var seq__32364_32634__$1 = temp__5804__auto___32633;
if(cljs.core.chunked_seq_QMARK_(seq__32364_32634__$1)){
var c__5548__auto___32637 = cljs.core.chunk_first(seq__32364_32634__$1);
var G__32639 = cljs.core.chunk_rest(seq__32364_32634__$1);
var G__32640 = c__5548__auto___32637;
var G__32641 = cljs.core.count(c__5548__auto___32637);
var G__32642 = (0);
seq__32364_32624 = G__32639;
chunk__32365_32625 = G__32640;
count__32366_32626 = G__32641;
i__32367_32627 = G__32642;
continue;
} else {
var cb_32643 = cljs.core.first(seq__32364_32634__$1);
cljs.core.async.impl.dispatch.run(((function (seq__32364_32624,chunk__32365_32625,count__32366_32626,i__32367_32627,cb_32643,seq__32364_32634__$1,temp__5804__auto___32633,val,vec__32350,done_QMARK_,cbs,take_cb,temp__5802__auto__,this$__$1){
return (function (){
return (cb_32643.cljs$core$IFn$_invoke$arity$1 ? cb_32643.cljs$core$IFn$_invoke$arity$1(true) : cb_32643.call(null,true));
});})(seq__32364_32624,chunk__32365_32625,count__32366_32626,i__32367_32627,cb_32643,seq__32364_32634__$1,temp__5804__auto___32633,val,vec__32350,done_QMARK_,cbs,take_cb,temp__5802__auto__,this$__$1))
);
var G__32649 = cljs.core.next(seq__32364_32634__$1);
var G__32650 = null;
var G__32651 = (0);
var G__32652 = (0);
seq__32364_32624 = G__32649;
chunk__32365_32625 = G__32650;
count__32366_32626 = G__32651;
i__32367_32627 = G__32652;
continue;
}
} else {
}
}
break;
}
return cljs.core.async.impl.channels.box(val);
} else {
return null;
}
} else {
var putter = (function (){while(true){
var putter = self__.puts.pop();
if(cljs.core.truth_(putter)){
if(cljs.core.async.impl.protocols.active_QMARK_(putter.handler)){
return putter;
} else {
continue;
}
} else {
return null;
}
break;
}
})();
if(cljs.core.truth_(putter)){
var put_cb = cljs.core.async.impl.protocols.commit(putter.handler);
handler.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
cljs.core.async.impl.dispatch.run((function (){
return (put_cb.cljs$core$IFn$_invoke$arity$1 ? put_cb.cljs$core$IFn$_invoke$arity$1(true) : put_cb.call(null,true));
}));
return cljs.core.async.impl.channels.box(putter.val);
} else {
if(cljs.core.truth_(self__.closed)){
if(cljs.core.truth_(self__.buf)){
(self__.add_BANG_.cljs$core$IFn$_invoke$arity$1 ? self__.add_BANG_.cljs$core$IFn$_invoke$arity$1(self__.buf) : self__.add_BANG_.call(null,self__.buf));
} else {
}
if(cljs.core.truth_((function (){var and__5023__auto__ = handler.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1(null);
if(cljs.core.truth_(and__5023__auto__)){
return handler.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
} else {
return and__5023__auto__;
}
})())){
var has_val = (function (){var and__5023__auto__ = self__.buf;
if(cljs.core.truth_(and__5023__auto__)){
return (cljs.core.count(self__.buf) > (0));
} else {
return and__5023__auto__;
}
})();
var val = (cljs.core.truth_(has_val)?self__.buf.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1(null):null);
return cljs.core.async.impl.channels.box(val);
} else {
return null;
}
} else {
if((self__.dirty_takes > (64))){
(self__.dirty_takes = (0));
self__.takes.cleanup(cljs.core.async.impl.protocols.active_QMARK_);
} else {
(self__.dirty_takes = (self__.dirty_takes + (1)));
}
if(cljs.core.truth_(handler.cljs$core$async$impl$protocols$Handler$blockable_QMARK_$arity$1(null))){
if((self__.takes.length < (1024))){
} else {
throw (new Error(["Assert failed: ",["No more than ",cljs.core.str.cljs$core$IFn$_invoke$arity$1((1024))," pending takes are allowed on a single channel."].join(''),"\n","(< (.-length takes) impl/MAX-QUEUE-SIZE)"].join('')));
}
self__.takes.unbounded_unshift(handler);
} else {
}
return null;
}
}
}
}
}));
(cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$Channel$ = cljs.core.PROTOCOL_SENTINEL);
(cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$Channel$closed_QMARK_$arity$1 = (function (_){
var self__ = this;
var ___$1 = this;
return self__.closed;
}));
(cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$Channel$close_BANG_$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
if(self__.closed){
return null;
} else {
(self__.closed = true);
if(cljs.core.truth_((function (){var and__5023__auto__ = self__.buf;
if(cljs.core.truth_(and__5023__auto__)){
return (self__.puts.length === (0));
} else {
return and__5023__auto__;
}
})())){
(self__.add_BANG_.cljs$core$IFn$_invoke$arity$1 ? self__.add_BANG_.cljs$core$IFn$_invoke$arity$1(self__.buf) : self__.add_BANG_.call(null,self__.buf));
} else {
}
while(true){
var taker_32680 = self__.takes.pop();
if((taker_32680 == null)){
} else {
if(taker_32680.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1(null)){
var take_cb_32684 = taker_32680.cljs$core$async$impl$protocols$Handler$commit$arity$1(null);
var val_32686 = (cljs.core.truth_((function (){var and__5023__auto__ = self__.buf;
if(cljs.core.truth_(and__5023__auto__)){
return (cljs.core.count(self__.buf) > (0));
} else {
return and__5023__auto__;
}
})())?self__.buf.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1(null):null);
cljs.core.async.impl.dispatch.run(((function (take_cb_32684,val_32686,taker_32680,this$__$1){
return (function (){
return (take_cb_32684.cljs$core$IFn$_invoke$arity$1 ? take_cb_32684.cljs$core$IFn$_invoke$arity$1(val_32686) : take_cb_32684.call(null,val_32686));
});})(take_cb_32684,val_32686,taker_32680,this$__$1))
);
} else {
}
continue;
}
break;
}
if(cljs.core.truth_(self__.buf)){
self__.buf.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1(null);
} else {
}
return null;
}
}));
(cljs.core.async.impl.channels.ManyToManyChannel.getBasis = (function (){
return new cljs.core.PersistentVector(null, 7, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"takes","takes",298247964,null),cljs.core.with_meta(new cljs.core.Symbol(null,"dirty-takes","dirty-takes",575642138,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),new cljs.core.Symbol(null,"puts","puts",-1883877054,null),cljs.core.with_meta(new cljs.core.Symbol(null,"dirty-puts","dirty-puts",57041148,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"buf","buf",1426618187,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"tag","tag",-1290361223),new cljs.core.Symbol(null,"not-native","not-native",-236392494,null)], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"closed","closed",720856168,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),new cljs.core.Symbol(null,"add!","add!",2046056845,null)], null);
}));
(cljs.core.async.impl.channels.ManyToManyChannel.cljs$lang$type = true);
(cljs.core.async.impl.channels.ManyToManyChannel.cljs$lang$ctorStr = "cljs.core.async.impl.channels/ManyToManyChannel");
(cljs.core.async.impl.channels.ManyToManyChannel.cljs$lang$ctorPrWriter = (function (this__5310__auto__,writer__5311__auto__,opt__5312__auto__){
return cljs.core._write(writer__5311__auto__,"cljs.core.async.impl.channels/ManyToManyChannel");
}));
/**
* Positional factory function for cljs.core.async.impl.channels/ManyToManyChannel.
*/
cljs.core.async.impl.channels.__GT_ManyToManyChannel = (function cljs$core$async$impl$channels$__GT_ManyToManyChannel(takes,dirty_takes,puts,dirty_puts,buf,closed,add_BANG_){
return (new cljs.core.async.impl.channels.ManyToManyChannel(takes,dirty_takes,puts,dirty_puts,buf,closed,add_BANG_));
});
cljs.core.async.impl.channels.ex_handler = (function cljs$core$async$impl$channels$ex_handler(ex){
console.log(ex);
return null;
});
cljs.core.async.impl.channels.handle = (function cljs$core$async$impl$channels$handle(buf,exh,t){
var else$ = (function (){var fexpr__32460 = (function (){var or__5025__auto__ = exh;
if(cljs.core.truth_(or__5025__auto__)){
return or__5025__auto__;
} else {
return cljs.core.async.impl.channels.ex_handler;
}
})();
return (fexpr__32460.cljs$core$IFn$_invoke$arity$1 ? fexpr__32460.cljs$core$IFn$_invoke$arity$1(t) : fexpr__32460.call(null,t));
})();
if((else$ == null)){
return buf;
} else {
return cljs.core.async.impl.protocols.add_BANG_.cljs$core$IFn$_invoke$arity$2(buf,else$);
}
});
cljs.core.async.impl.channels.chan = (function cljs$core$async$impl$channels$chan(var_args){
var G__32473 = arguments.length;
switch (G__32473) {
case 1:
return cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
case 2:
return cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
case 3:
return cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$1 = (function (buf){
return cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$2(buf,null);
}));
(cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$2 = (function (buf,xform){
return cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$3(buf,xform,null);
}));
(cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$3 = (function (buf,xform,exh){
return (new cljs.core.async.impl.channels.ManyToManyChannel(cljs.core.async.impl.buffers.ring_buffer((32)),(0),cljs.core.async.impl.buffers.ring_buffer((32)),(0),buf,false,(function (){var add_BANG_ = (cljs.core.truth_(xform)?(xform.cljs$core$IFn$_invoke$arity$1 ? xform.cljs$core$IFn$_invoke$arity$1(cljs.core.async.impl.protocols.add_BANG_) : xform.call(null,cljs.core.async.impl.protocols.add_BANG_)):cljs.core.async.impl.protocols.add_BANG_);
return (function() {
var G__32727 = null;
var G__32727__1 = (function (buf__$1){
try{return (add_BANG_.cljs$core$IFn$_invoke$arity$1 ? add_BANG_.cljs$core$IFn$_invoke$arity$1(buf__$1) : add_BANG_.call(null,buf__$1));
}catch (e32506){var t = e32506;
return cljs.core.async.impl.channels.handle(buf__$1,exh,t);
}});
var G__32727__2 = (function (buf__$1,val){
try{return (add_BANG_.cljs$core$IFn$_invoke$arity$2 ? add_BANG_.cljs$core$IFn$_invoke$arity$2(buf__$1,val) : add_BANG_.call(null,buf__$1,val));
}catch (e32508){var t = e32508;
return cljs.core.async.impl.channels.handle(buf__$1,exh,t);
}});
G__32727 = function(buf__$1,val){
switch(arguments.length){
case 1:
return G__32727__1.call(this,buf__$1);
case 2:
return G__32727__2.call(this,buf__$1,val);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
G__32727.cljs$core$IFn$_invoke$arity$1 = G__32727__1;
G__32727.cljs$core$IFn$_invoke$arity$2 = G__32727__2;
return G__32727;
})()
})()));
}));
(cljs.core.async.impl.channels.chan.cljs$lang$maxFixedArity = 3);
//# sourceMappingURL=cljs.core.async.impl.channels.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,54 @@
goog.provide('cljs.core.async.impl.dispatch');
cljs.core.async.impl.dispatch.tasks = cljs.core.async.impl.buffers.ring_buffer((32));
cljs.core.async.impl.dispatch.running_QMARK_ = false;
cljs.core.async.impl.dispatch.queued_QMARK_ = false;
cljs.core.async.impl.dispatch.TASK_BATCH_SIZE = (1024);
cljs.core.async.impl.dispatch.process_messages = (function cljs$core$async$impl$dispatch$process_messages(){
(cljs.core.async.impl.dispatch.running_QMARK_ = true);
(cljs.core.async.impl.dispatch.queued_QMARK_ = false);
var count_32145 = (0);
while(true){
var m_32146 = cljs.core.async.impl.dispatch.tasks.pop();
if((m_32146 == null)){
} else {
(m_32146.cljs$core$IFn$_invoke$arity$0 ? m_32146.cljs$core$IFn$_invoke$arity$0() : m_32146.call(null));
if((count_32145 < cljs.core.async.impl.dispatch.TASK_BATCH_SIZE)){
var G__32148 = (count_32145 + (1));
count_32145 = G__32148;
continue;
} else {
}
}
break;
}
(cljs.core.async.impl.dispatch.running_QMARK_ = false);
if((cljs.core.async.impl.dispatch.tasks.length > (0))){
return (cljs.core.async.impl.dispatch.queue_dispatcher.cljs$core$IFn$_invoke$arity$0 ? cljs.core.async.impl.dispatch.queue_dispatcher.cljs$core$IFn$_invoke$arity$0() : cljs.core.async.impl.dispatch.queue_dispatcher.call(null));
} else {
return null;
}
});
cljs.core.async.impl.dispatch.queue_dispatcher = (function cljs$core$async$impl$dispatch$queue_dispatcher(){
if(((cljs.core.async.impl.dispatch.queued_QMARK_) && (cljs.core.async.impl.dispatch.running_QMARK_))){
return null;
} else {
(cljs.core.async.impl.dispatch.queued_QMARK_ = true);
return goog.async.nextTick(cljs.core.async.impl.dispatch.process_messages);
}
});
cljs.core.async.impl.dispatch.run = (function cljs$core$async$impl$dispatch$run(f){
cljs.core.async.impl.dispatch.tasks.unbounded_unshift(f);
return cljs.core.async.impl.dispatch.queue_dispatcher();
});
cljs.core.async.impl.dispatch.queue_delay = (function cljs$core$async$impl$dispatch$queue_delay(f,delay){
return setTimeout(f,delay);
});
//# sourceMappingURL=cljs.core.async.impl.dispatch.js.map

View file

@ -0,0 +1 @@
{"version":3,"sources":["cljs/core/async/impl/dispatch.cljs"],"mappings":";AAYA,AAAKA,sCAAM,yCAAA,zCAACC;AACZ,+CAAA,/CAAKC;AACL,8CAAA,9CAAKC;AAEL,gDAAA,hDAAKC;AAEL,AAAA,AAEA,iDAAA,jDAAMC;AAAN,AACE,gDAAA,/CAAMH;;AACN,+CAAA,9CAAMC;;AACN,kBAAA,dAAOG;;AAAP,AACE,IAAMC,UAAE,AAAMP;AAAd,AACE,GAAU,YAAA,XAAMO;AAAhB;AAAA,AACE,CAACA,wCAAAA,0CAAAA;;AACD,GAAM,CAAGD,cAAMF;AAAf,AACE,eAAO,eAAA,dAAKE;;;;AADd;;;;;AAEN,gDAAA,/CAAMJ;;AACN,GAAM,8CAAA,7CAAG,AAAUF;AAAnB,AACE,QAACQ,+EAAAA,iFAAAA;;AADH;;;AAGF,iDAAA,jDAAMA;AAAN,AACE,GAAU,EAAKL,iDAAQD;AAAvB;;AAAA,AACE,+CAAA,9CAAMC;;AACN,OAACM,oBAAoBJ;;;AAEzB,oCAAA,pCAAMK,gFAAKC;AAAX,AACE,AAAoBX,sDAAMW;;AAC1B,OAACH;;AAEH,4CAAA,5CAAMI,gGAAaD,EAAEE;AAArB,AACE,OAACC,WAAcH,EAAEE","names":["cljs.core.async.impl.dispatch/tasks","cljs.core.async.impl.buffers/ring-buffer","cljs.core.async.impl.dispatch/running?","cljs.core.async.impl.dispatch/queued?","cljs.core.async.impl.dispatch/TASK_BATCH_SIZE","cljs.core.async.impl.dispatch/process-messages","count","m","cljs.core.async.impl.dispatch/queue-dispatcher","js/goog.async.nextTick","cljs.core.async.impl.dispatch/run","f","cljs.core.async.impl.dispatch/queue-delay","delay","js/setTimeout"],"sourcesContent":[";; Copyright (c) Rich Hickey and contributors. All rights reserved.\n;; The use and distribution terms for this software are covered by the\n;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)\n;; which can be found in the file epl-v10.html at the root of this distribution.\n;; By using this software in any fashion, you are agreeing to be bound by\n;; the terms of this license.\n;; You must not remove this notice, or any other, from this software.\n\n(ns cljs.core.async.impl.dispatch\n (:require [cljs.core.async.impl.buffers :as buffers]\n [goog.async.nextTick]))\n\n(def tasks (buffers/ring-buffer 32))\n(def running? false)\n(def queued? false)\n\n(def TASK_BATCH_SIZE 1024)\n\n(declare queue-dispatcher)\n\n(defn process-messages []\n (set! running? true)\n (set! queued? false)\n (loop [count 0]\n (let [m (.pop tasks)]\n (when-not (nil? m)\n (m)\n (when (< count TASK_BATCH_SIZE)\n (recur (inc count))))))\n (set! running? false)\n (when (> (.-length tasks) 0)\n (queue-dispatcher)))\n\n(defn queue-dispatcher []\n (when-not (and queued? running?)\n (set! queued? true)\n (goog.async.nextTick process-messages)))\n\n(defn run [f]\n (.unbounded-unshift tasks f)\n (queue-dispatcher))\n\n(defn queue-delay [f delay]\n (js/setTimeout f delay))\n\n"],"x_google_ignoreList":[0]}

View file

@ -0,0 +1,165 @@
goog.provide('cljs.core.async.impl.ioc_helpers');
cljs.core.async.impl.ioc_helpers.FN_IDX = (0);
cljs.core.async.impl.ioc_helpers.STATE_IDX = (1);
cljs.core.async.impl.ioc_helpers.VALUE_IDX = (2);
cljs.core.async.impl.ioc_helpers.BINDINGS_IDX = (3);
cljs.core.async.impl.ioc_helpers.EXCEPTION_FRAMES = (4);
cljs.core.async.impl.ioc_helpers.CURRENT_EXCEPTION = (5);
cljs.core.async.impl.ioc_helpers.USER_START_IDX = (6);
cljs.core.async.impl.ioc_helpers.aset_object = (function cljs$core$async$impl$ioc_helpers$aset_object(arr,idx,o){
return (arr[idx][o]);
});
cljs.core.async.impl.ioc_helpers.aget_object = (function cljs$core$async$impl$ioc_helpers$aget_object(arr,idx){
return (arr[idx]);
});
/**
* Returns true if the machine is in a finished state
*/
cljs.core.async.impl.ioc_helpers.finished_QMARK_ = (function cljs$core$async$impl$ioc_helpers$finished_QMARK_(state_array){
return cljs.core.keyword_identical_QMARK_((state_array[(1)]),new cljs.core.Keyword(null,"finished","finished",-1018867731));
});
/**
* @constructor
* @implements {cljs.core.async.impl.protocols.Handler}
* @implements {cljs.core.IMeta}
* @implements {cljs.core.IWithMeta}
*/
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers34886 = (function (f,meta34887){
this.f = f;
this.meta34887 = meta34887;
this.cljs$lang$protocol_mask$partition0$ = 393216;
this.cljs$lang$protocol_mask$partition1$ = 0;
});
(cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers34886.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (_34888,meta34887__$1){
var self__ = this;
var _34888__$1 = this;
return (new cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers34886(self__.f,meta34887__$1));
}));
(cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers34886.prototype.cljs$core$IMeta$_meta$arity$1 = (function (_34888){
var self__ = this;
var _34888__$1 = this;
return self__.meta34887;
}));
(cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers34886.prototype.cljs$core$async$impl$protocols$Handler$ = cljs.core.PROTOCOL_SENTINEL);
(cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers34886.prototype.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1 = (function (_){
var self__ = this;
var ___$1 = this;
return true;
}));
(cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers34886.prototype.cljs$core$async$impl$protocols$Handler$blockable_QMARK_$arity$1 = (function (_){
var self__ = this;
var ___$1 = this;
return true;
}));
(cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers34886.prototype.cljs$core$async$impl$protocols$Handler$commit$arity$1 = (function (_){
var self__ = this;
var ___$1 = this;
return self__.f;
}));
(cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers34886.getBasis = (function (){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"f","f",43394975,null),new cljs.core.Symbol(null,"meta34887","meta34887",-176845657,null)], null);
}));
(cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers34886.cljs$lang$type = true);
(cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers34886.cljs$lang$ctorStr = "cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers34886");
(cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers34886.cljs$lang$ctorPrWriter = (function (this__5310__auto__,writer__5311__auto__,opt__5312__auto__){
return cljs.core._write(writer__5311__auto__,"cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers34886");
}));
/**
* Positional factory function for cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers34886.
*/
cljs.core.async.impl.ioc_helpers.__GT_t_cljs$core$async$impl$ioc_helpers34886 = (function cljs$core$async$impl$ioc_helpers$__GT_t_cljs$core$async$impl$ioc_helpers34886(f,meta34887){
return (new cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers34886(f,meta34887));
});
cljs.core.async.impl.ioc_helpers.fn_handler = (function cljs$core$async$impl$ioc_helpers$fn_handler(f){
return (new cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers34886(f,cljs.core.PersistentArrayMap.EMPTY));
});
cljs.core.async.impl.ioc_helpers.run_state_machine = (function cljs$core$async$impl$ioc_helpers$run_state_machine(state){
var fexpr__34925 = cljs.core.async.impl.ioc_helpers.aget_object(state,(0));
return (fexpr__34925.cljs$core$IFn$_invoke$arity$1 ? fexpr__34925.cljs$core$IFn$_invoke$arity$1(state) : fexpr__34925.call(null,state));
});
cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped = (function cljs$core$async$impl$ioc_helpers$run_state_machine_wrapped(state){
try{return cljs.core.async.impl.ioc_helpers.run_state_machine(state);
}catch (e34931){if((e34931 instanceof Object)){
var ex = e34931;
cljs.core.async.impl.ioc_helpers.aget_object(state,(6)).cljs$core$async$impl$protocols$Channel$close_BANG_$arity$1(null);
throw ex;
} else {
throw e34931;
}
}});
cljs.core.async.impl.ioc_helpers.take_BANG_ = (function cljs$core$async$impl$ioc_helpers$take_BANG_(state,blk,c){
var temp__5802__auto__ = c.cljs$core$async$impl$protocols$ReadPort$take_BANG_$arity$2(null,cljs.core.async.impl.ioc_helpers.fn_handler((function (x){
var statearr_34934_34961 = state;
(statearr_34934_34961[(2)] = x);
(statearr_34934_34961[(1)] = blk);
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped(state);
})));
if(cljs.core.truth_(temp__5802__auto__)){
var cb = temp__5802__auto__;
var statearr_34936_34966 = state;
(statearr_34936_34966[(2)] = cljs.core.deref(cb));
(statearr_34936_34966[(1)] = blk);
return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
return null;
}
});
cljs.core.async.impl.ioc_helpers.put_BANG_ = (function cljs$core$async$impl$ioc_helpers$put_BANG_(state,blk,c,val){
var temp__5802__auto__ = c.cljs$core$async$impl$protocols$WritePort$put_BANG_$arity$3(null,val,cljs.core.async.impl.ioc_helpers.fn_handler((function (ret_val){
var statearr_34950_34967 = state;
(statearr_34950_34967[(2)] = ret_val);
(statearr_34950_34967[(1)] = blk);
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped(state);
})));
if(cljs.core.truth_(temp__5802__auto__)){
var cb = temp__5802__auto__;
var statearr_34952_34968 = state;
(statearr_34952_34968[(2)] = cljs.core.deref(cb));
(statearr_34952_34968[(1)] = blk);
return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
return null;
}
});
cljs.core.async.impl.ioc_helpers.return_chan = (function cljs$core$async$impl$ioc_helpers$return_chan(state,value){
var c = (state[(6)]);
if((value == null)){
} else {
c.cljs$core$async$impl$protocols$WritePort$put_BANG_$arity$3(null,value,cljs.core.async.impl.ioc_helpers.fn_handler((function (_){
return null;
})));
}
c.cljs$core$async$impl$protocols$Channel$close_BANG_$arity$1(null);
return c;
});
//# sourceMappingURL=cljs.core.async.impl.ioc_helpers.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,342 @@
goog.provide('cljs.core.async.impl.protocols');
cljs.core.async.impl.protocols.MAX_QUEUE_SIZE = (1024);
/**
* @interface
*/
cljs.core.async.impl.protocols.ReadPort = function(){};
var cljs$core$async$impl$protocols$ReadPort$take_BANG_$dyn_31953 = (function (port,fn1_handler){
var x__5373__auto__ = (((port == null))?null:port);
var m__5374__auto__ = (cljs.core.async.impl.protocols.take_BANG_[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$2 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$2(port,fn1_handler) : m__5374__auto__.call(null,port,fn1_handler));
} else {
var m__5372__auto__ = (cljs.core.async.impl.protocols.take_BANG_["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$2 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$2(port,fn1_handler) : m__5372__auto__.call(null,port,fn1_handler));
} else {
throw cljs.core.missing_protocol("ReadPort.take!",port);
}
}
});
/**
* derefable val if taken, nil if take was enqueued
*/
cljs.core.async.impl.protocols.take_BANG_ = (function cljs$core$async$impl$protocols$take_BANG_(port,fn1_handler){
if((((!((port == null)))) && ((!((port.cljs$core$async$impl$protocols$ReadPort$take_BANG_$arity$2 == null)))))){
return port.cljs$core$async$impl$protocols$ReadPort$take_BANG_$arity$2(port,fn1_handler);
} else {
return cljs$core$async$impl$protocols$ReadPort$take_BANG_$dyn_31953(port,fn1_handler);
}
});
/**
* @interface
*/
cljs.core.async.impl.protocols.WritePort = function(){};
var cljs$core$async$impl$protocols$WritePort$put_BANG_$dyn_31965 = (function (port,val,fn1_handler){
var x__5373__auto__ = (((port == null))?null:port);
var m__5374__auto__ = (cljs.core.async.impl.protocols.put_BANG_[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$3 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$3(port,val,fn1_handler) : m__5374__auto__.call(null,port,val,fn1_handler));
} else {
var m__5372__auto__ = (cljs.core.async.impl.protocols.put_BANG_["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$3 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$3(port,val,fn1_handler) : m__5372__auto__.call(null,port,val,fn1_handler));
} else {
throw cljs.core.missing_protocol("WritePort.put!",port);
}
}
});
/**
* derefable boolean (false if already closed) if handled, nil if put was enqueued.
* Must throw on nil val.
*/
cljs.core.async.impl.protocols.put_BANG_ = (function cljs$core$async$impl$protocols$put_BANG_(port,val,fn1_handler){
if((((!((port == null)))) && ((!((port.cljs$core$async$impl$protocols$WritePort$put_BANG_$arity$3 == null)))))){
return port.cljs$core$async$impl$protocols$WritePort$put_BANG_$arity$3(port,val,fn1_handler);
} else {
return cljs$core$async$impl$protocols$WritePort$put_BANG_$dyn_31965(port,val,fn1_handler);
}
});
/**
* @interface
*/
cljs.core.async.impl.protocols.Channel = function(){};
var cljs$core$async$impl$protocols$Channel$close_BANG_$dyn_31972 = (function (chan){
var x__5373__auto__ = (((chan == null))?null:chan);
var m__5374__auto__ = (cljs.core.async.impl.protocols.close_BANG_[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$1(chan) : m__5374__auto__.call(null,chan));
} else {
var m__5372__auto__ = (cljs.core.async.impl.protocols.close_BANG_["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$1(chan) : m__5372__auto__.call(null,chan));
} else {
throw cljs.core.missing_protocol("Channel.close!",chan);
}
}
});
cljs.core.async.impl.protocols.close_BANG_ = (function cljs$core$async$impl$protocols$close_BANG_(chan){
if((((!((chan == null)))) && ((!((chan.cljs$core$async$impl$protocols$Channel$close_BANG_$arity$1 == null)))))){
return chan.cljs$core$async$impl$protocols$Channel$close_BANG_$arity$1(chan);
} else {
return cljs$core$async$impl$protocols$Channel$close_BANG_$dyn_31972(chan);
}
});
var cljs$core$async$impl$protocols$Channel$closed_QMARK_$dyn_31976 = (function (chan){
var x__5373__auto__ = (((chan == null))?null:chan);
var m__5374__auto__ = (cljs.core.async.impl.protocols.closed_QMARK_[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$1(chan) : m__5374__auto__.call(null,chan));
} else {
var m__5372__auto__ = (cljs.core.async.impl.protocols.closed_QMARK_["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$1(chan) : m__5372__auto__.call(null,chan));
} else {
throw cljs.core.missing_protocol("Channel.closed?",chan);
}
}
});
cljs.core.async.impl.protocols.closed_QMARK_ = (function cljs$core$async$impl$protocols$closed_QMARK_(chan){
if((((!((chan == null)))) && ((!((chan.cljs$core$async$impl$protocols$Channel$closed_QMARK_$arity$1 == null)))))){
return chan.cljs$core$async$impl$protocols$Channel$closed_QMARK_$arity$1(chan);
} else {
return cljs$core$async$impl$protocols$Channel$closed_QMARK_$dyn_31976(chan);
}
});
/**
* @interface
*/
cljs.core.async.impl.protocols.Handler = function(){};
var cljs$core$async$impl$protocols$Handler$active_QMARK_$dyn_31979 = (function (h){
var x__5373__auto__ = (((h == null))?null:h);
var m__5374__auto__ = (cljs.core.async.impl.protocols.active_QMARK_[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$1(h) : m__5374__auto__.call(null,h));
} else {
var m__5372__auto__ = (cljs.core.async.impl.protocols.active_QMARK_["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$1(h) : m__5372__auto__.call(null,h));
} else {
throw cljs.core.missing_protocol("Handler.active?",h);
}
}
});
/**
* returns true if has callback. Must work w/o lock
*/
cljs.core.async.impl.protocols.active_QMARK_ = (function cljs$core$async$impl$protocols$active_QMARK_(h){
if((((!((h == null)))) && ((!((h.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1 == null)))))){
return h.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1(h);
} else {
return cljs$core$async$impl$protocols$Handler$active_QMARK_$dyn_31979(h);
}
});
var cljs$core$async$impl$protocols$Handler$blockable_QMARK_$dyn_31980 = (function (h){
var x__5373__auto__ = (((h == null))?null:h);
var m__5374__auto__ = (cljs.core.async.impl.protocols.blockable_QMARK_[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$1(h) : m__5374__auto__.call(null,h));
} else {
var m__5372__auto__ = (cljs.core.async.impl.protocols.blockable_QMARK_["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$1(h) : m__5372__auto__.call(null,h));
} else {
throw cljs.core.missing_protocol("Handler.blockable?",h);
}
}
});
/**
* returns true if this handler may be blocked, otherwise it must not block
*/
cljs.core.async.impl.protocols.blockable_QMARK_ = (function cljs$core$async$impl$protocols$blockable_QMARK_(h){
if((((!((h == null)))) && ((!((h.cljs$core$async$impl$protocols$Handler$blockable_QMARK_$arity$1 == null)))))){
return h.cljs$core$async$impl$protocols$Handler$blockable_QMARK_$arity$1(h);
} else {
return cljs$core$async$impl$protocols$Handler$blockable_QMARK_$dyn_31980(h);
}
});
var cljs$core$async$impl$protocols$Handler$commit$dyn_31988 = (function (h){
var x__5373__auto__ = (((h == null))?null:h);
var m__5374__auto__ = (cljs.core.async.impl.protocols.commit[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$1(h) : m__5374__auto__.call(null,h));
} else {
var m__5372__auto__ = (cljs.core.async.impl.protocols.commit["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$1(h) : m__5372__auto__.call(null,h));
} else {
throw cljs.core.missing_protocol("Handler.commit",h);
}
}
});
/**
* commit to fulfilling its end of the transfer, returns cb. Must be called within lock
*/
cljs.core.async.impl.protocols.commit = (function cljs$core$async$impl$protocols$commit(h){
if((((!((h == null)))) && ((!((h.cljs$core$async$impl$protocols$Handler$commit$arity$1 == null)))))){
return h.cljs$core$async$impl$protocols$Handler$commit$arity$1(h);
} else {
return cljs$core$async$impl$protocols$Handler$commit$dyn_31988(h);
}
});
/**
* @interface
*/
cljs.core.async.impl.protocols.Buffer = function(){};
var cljs$core$async$impl$protocols$Buffer$full_QMARK_$dyn_31992 = (function (b){
var x__5373__auto__ = (((b == null))?null:b);
var m__5374__auto__ = (cljs.core.async.impl.protocols.full_QMARK_[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$1(b) : m__5374__auto__.call(null,b));
} else {
var m__5372__auto__ = (cljs.core.async.impl.protocols.full_QMARK_["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$1(b) : m__5372__auto__.call(null,b));
} else {
throw cljs.core.missing_protocol("Buffer.full?",b);
}
}
});
/**
* returns true if buffer cannot accept put
*/
cljs.core.async.impl.protocols.full_QMARK_ = (function cljs$core$async$impl$protocols$full_QMARK_(b){
if((((!((b == null)))) && ((!((b.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1 == null)))))){
return b.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1(b);
} else {
return cljs$core$async$impl$protocols$Buffer$full_QMARK_$dyn_31992(b);
}
});
var cljs$core$async$impl$protocols$Buffer$remove_BANG_$dyn_31993 = (function (b){
var x__5373__auto__ = (((b == null))?null:b);
var m__5374__auto__ = (cljs.core.async.impl.protocols.remove_BANG_[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$1(b) : m__5374__auto__.call(null,b));
} else {
var m__5372__auto__ = (cljs.core.async.impl.protocols.remove_BANG_["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$1(b) : m__5372__auto__.call(null,b));
} else {
throw cljs.core.missing_protocol("Buffer.remove!",b);
}
}
});
/**
* remove and return next item from buffer, called under chan mutex
*/
cljs.core.async.impl.protocols.remove_BANG_ = (function cljs$core$async$impl$protocols$remove_BANG_(b){
if((((!((b == null)))) && ((!((b.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1 == null)))))){
return b.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1(b);
} else {
return cljs$core$async$impl$protocols$Buffer$remove_BANG_$dyn_31993(b);
}
});
var cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$dyn_32000 = (function (b,itm){
var x__5373__auto__ = (((b == null))?null:b);
var m__5374__auto__ = (cljs.core.async.impl.protocols.add_BANG__STAR_[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$2 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$2(b,itm) : m__5374__auto__.call(null,b,itm));
} else {
var m__5372__auto__ = (cljs.core.async.impl.protocols.add_BANG__STAR_["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$2 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$2(b,itm) : m__5372__auto__.call(null,b,itm));
} else {
throw cljs.core.missing_protocol("Buffer.add!*",b);
}
}
});
/**
* if room, add item to the buffer, returns b, called under chan mutex
*/
cljs.core.async.impl.protocols.add_BANG__STAR_ = (function cljs$core$async$impl$protocols$add_BANG__STAR_(b,itm){
if((((!((b == null)))) && ((!((b.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2 == null)))))){
return b.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2(b,itm);
} else {
return cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$dyn_32000(b,itm);
}
});
var cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$dyn_32002 = (function (b){
var x__5373__auto__ = (((b == null))?null:b);
var m__5374__auto__ = (cljs.core.async.impl.protocols.close_buf_BANG_[goog.typeOf(x__5373__auto__)]);
if((!((m__5374__auto__ == null)))){
return (m__5374__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5374__auto__.cljs$core$IFn$_invoke$arity$1(b) : m__5374__auto__.call(null,b));
} else {
var m__5372__auto__ = (cljs.core.async.impl.protocols.close_buf_BANG_["_"]);
if((!((m__5372__auto__ == null)))){
return (m__5372__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5372__auto__.cljs$core$IFn$_invoke$arity$1(b) : m__5372__auto__.call(null,b));
} else {
throw cljs.core.missing_protocol("Buffer.close-buf!",b);
}
}
});
/**
* called on chan closed under chan mutex, return ignored
*/
cljs.core.async.impl.protocols.close_buf_BANG_ = (function cljs$core$async$impl$protocols$close_buf_BANG_(b){
if((((!((b == null)))) && ((!((b.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1 == null)))))){
return b.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1(b);
} else {
return cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$dyn_32002(b);
}
});
cljs.core.async.impl.protocols.add_BANG_ = (function cljs$core$async$impl$protocols$add_BANG_(var_args){
var G__31934 = arguments.length;
switch (G__31934) {
case 1:
return cljs.core.async.impl.protocols.add_BANG_.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
case 2:
return cljs.core.async.impl.protocols.add_BANG_.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(cljs.core.async.impl.protocols.add_BANG_.cljs$core$IFn$_invoke$arity$1 = (function (b){
return b;
}));
(cljs.core.async.impl.protocols.add_BANG_.cljs$core$IFn$_invoke$arity$2 = (function (b,itm){
if((!((itm == null)))){
} else {
throw (new Error("Assert failed: (not (nil? itm))"));
}
return cljs.core.async.impl.protocols.add_BANG__STAR_(b,itm);
}));
(cljs.core.async.impl.protocols.add_BANG_.cljs$lang$maxFixedArity = 2);
/**
* @interface
*/
cljs.core.async.impl.protocols.UnblockingBuffer = function(){};
//# sourceMappingURL=cljs.core.async.impl.protocols.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,481 @@
goog.provide('cljs.core.async.impl.timers');
cljs.core.async.impl.timers.MAX_LEVEL = (15);
cljs.core.async.impl.timers.P = ((1) / (2));
cljs.core.async.impl.timers.random_level = (function cljs$core$async$impl$timers$random_level(var_args){
var G__34935 = arguments.length;
switch (G__34935) {
case 0:
return cljs.core.async.impl.timers.random_level.cljs$core$IFn$_invoke$arity$0();
break;
case 1:
return cljs.core.async.impl.timers.random_level.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(cljs.core.async.impl.timers.random_level.cljs$core$IFn$_invoke$arity$0 = (function (){
return cljs.core.async.impl.timers.random_level.cljs$core$IFn$_invoke$arity$1((0));
}));
(cljs.core.async.impl.timers.random_level.cljs$core$IFn$_invoke$arity$1 = (function (level){
while(true){
if((((Math.random() < cljs.core.async.impl.timers.P)) && ((level < cljs.core.async.impl.timers.MAX_LEVEL)))){
var G__35025 = (level + (1));
level = G__35025;
continue;
} else {
return level;
}
break;
}
}));
(cljs.core.async.impl.timers.random_level.cljs$lang$maxFixedArity = 1);
/**
* @constructor
* @implements {cljs.core.ISeqable}
* @implements {cljs.core.IPrintWithWriter}
*/
cljs.core.async.impl.timers.SkipListNode = (function (key,val,forward){
this.key = key;
this.val = val;
this.forward = forward;
this.cljs$lang$protocol_mask$partition0$ = 2155872256;
this.cljs$lang$protocol_mask$partition1$ = 0;
});
(cljs.core.async.impl.timers.SkipListNode.prototype.cljs$core$ISeqable$_seq$arity$1 = (function (coll){
var self__ = this;
var coll__$1 = this;
return (new cljs.core.List(null,self__.key,(new cljs.core.List(null,self__.val,null,(1),null)),(2),null));
}));
(cljs.core.async.impl.timers.SkipListNode.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (coll,writer,opts){
var self__ = this;
var coll__$1 = this;
return cljs.core.pr_sequential_writer(writer,cljs.core.pr_writer,"["," ","]",opts,coll__$1);
}));
(cljs.core.async.impl.timers.SkipListNode.getBasis = (function (){
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"key","key",124488940,null),cljs.core.with_meta(new cljs.core.Symbol(null,"val","val",1769233139,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),new cljs.core.Symbol(null,"forward","forward",1083186224,null)], null);
}));
(cljs.core.async.impl.timers.SkipListNode.cljs$lang$type = true);
(cljs.core.async.impl.timers.SkipListNode.cljs$lang$ctorStr = "cljs.core.async.impl.timers/SkipListNode");
(cljs.core.async.impl.timers.SkipListNode.cljs$lang$ctorPrWriter = (function (this__5310__auto__,writer__5311__auto__,opt__5312__auto__){
return cljs.core._write(writer__5311__auto__,"cljs.core.async.impl.timers/SkipListNode");
}));
/**
* Positional factory function for cljs.core.async.impl.timers/SkipListNode.
*/
cljs.core.async.impl.timers.__GT_SkipListNode = (function cljs$core$async$impl$timers$__GT_SkipListNode(key,val,forward){
return (new cljs.core.async.impl.timers.SkipListNode(key,val,forward));
});
cljs.core.async.impl.timers.skip_list_node = (function cljs$core$async$impl$timers$skip_list_node(var_args){
var G__34960 = arguments.length;
switch (G__34960) {
case 1:
return cljs.core.async.impl.timers.skip_list_node.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
case 3:
return cljs.core.async.impl.timers.skip_list_node.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(cljs.core.async.impl.timers.skip_list_node.cljs$core$IFn$_invoke$arity$1 = (function (level){
return cljs.core.async.impl.timers.skip_list_node.cljs$core$IFn$_invoke$arity$3(null,null,level);
}));
(cljs.core.async.impl.timers.skip_list_node.cljs$core$IFn$_invoke$arity$3 = (function (k,v,level){
var arr = (new Array((level + (1))));
var i_35037 = (0);
while(true){
if((i_35037 < arr.length)){
(arr[i_35037] = null);
var G__35038 = (i_35037 + (1));
i_35037 = G__35038;
continue;
} else {
}
break;
}
return (new cljs.core.async.impl.timers.SkipListNode(k,v,arr));
}));
(cljs.core.async.impl.timers.skip_list_node.cljs$lang$maxFixedArity = 3);
cljs.core.async.impl.timers.least_greater_node = (function cljs$core$async$impl$timers$least_greater_node(var_args){
var G__34977 = arguments.length;
switch (G__34977) {
case 3:
return cljs.core.async.impl.timers.least_greater_node.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
case 4:
return cljs.core.async.impl.timers.least_greater_node.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(cljs.core.async.impl.timers.least_greater_node.cljs$core$IFn$_invoke$arity$3 = (function (x,k,level){
return cljs.core.async.impl.timers.least_greater_node.cljs$core$IFn$_invoke$arity$4(x,k,level,null);
}));
(cljs.core.async.impl.timers.least_greater_node.cljs$core$IFn$_invoke$arity$4 = (function (x,k,level,update){
while(true){
if((!((level < (0))))){
var x__$1 = (function (){var x__$1 = x;
while(true){
var temp__5802__auto__ = (((level < x__$1.forward.length))?(x__$1.forward[level]):null);
if(cljs.core.truth_(temp__5802__auto__)){
var x_SINGLEQUOTE_ = temp__5802__auto__;
if((x_SINGLEQUOTE_.key < k)){
var G__35043 = x_SINGLEQUOTE_;
x__$1 = G__35043;
continue;
} else {
return x__$1;
}
} else {
return x__$1;
}
break;
}
})();
if((update == null)){
} else {
(update[level] = x__$1);
}
var G__35044 = x__$1;
var G__35045 = k;
var G__35046 = (level - (1));
var G__35047 = update;
x = G__35044;
k = G__35045;
level = G__35046;
update = G__35047;
continue;
} else {
return x;
}
break;
}
}));
(cljs.core.async.impl.timers.least_greater_node.cljs$lang$maxFixedArity = 4);
/**
* @constructor
* @implements {cljs.core.ISeqable}
* @implements {cljs.core.IPrintWithWriter}
*/
cljs.core.async.impl.timers.SkipList = (function (header,level){
this.header = header;
this.level = level;
this.cljs$lang$protocol_mask$partition0$ = 2155872256;
this.cljs$lang$protocol_mask$partition1$ = 0;
});
(cljs.core.async.impl.timers.SkipList.prototype.put = (function (k,v){
var self__ = this;
var coll = this;
var update = (new Array(cljs.core.async.impl.timers.MAX_LEVEL));
var x = cljs.core.async.impl.timers.least_greater_node.cljs$core$IFn$_invoke$arity$4(self__.header,k,self__.level,update);
var x__$1 = (x.forward[(0)]);
if((((!((x__$1 == null)))) && ((x__$1.key === k)))){
return (x__$1.val = v);
} else {
var new_level = cljs.core.async.impl.timers.random_level.cljs$core$IFn$_invoke$arity$0();
if((new_level > self__.level)){
var i_35053 = (self__.level + (1));
while(true){
if((i_35053 <= (new_level + (1)))){
(update[i_35053] = self__.header);
var G__35055 = (i_35053 + (1));
i_35053 = G__35055;
continue;
} else {
}
break;
}
(self__.level = new_level);
} else {
}
var x__$2 = cljs.core.async.impl.timers.skip_list_node.cljs$core$IFn$_invoke$arity$3(k,v,(new Array(new_level)));
var i = (0);
while(true){
if((i <= self__.level)){
var links_35056 = (update[i]).forward;
if((i < x__$2.forward.length)){
(x__$2.forward[i] = (links_35056[i]));
} else {
x__$2.forward.push((((i < links_35056.length))?(links_35056[i]):null));
}
if((i < links_35056.length)){
(links_35056[i] = x__$2);
} else {
links_35056.push(x__$2);
}
var G__35062 = (i + (1));
i = G__35062;
continue;
} else {
return null;
}
break;
}
}
}));
(cljs.core.async.impl.timers.SkipList.prototype.remove = (function (k){
var self__ = this;
var coll = this;
var update = (new Array(cljs.core.async.impl.timers.MAX_LEVEL));
var x = cljs.core.async.impl.timers.least_greater_node.cljs$core$IFn$_invoke$arity$4(self__.header,k,self__.level,update);
var x__$1 = (((x.forward.length === (0)))?null:(x.forward[(0)]));
if((((!((x__$1 == null)))) && ((x__$1.key === k)))){
var i_35064 = (0);
while(true){
if((i_35064 <= self__.level)){
var links_35065 = (update[i_35064]).forward;
if((x__$1 === (((i_35064 < links_35065.length))?(links_35065[i_35064]):null))){
(links_35065[i_35064] = (x__$1.forward[i_35064]));
var G__35067 = (i_35064 + (1));
i_35064 = G__35067;
continue;
} else {
var G__35068 = (i_35064 + (1));
i_35064 = G__35068;
continue;
}
} else {
}
break;
}
while(true){
if(((((((0) < self__.level)) && ((self__.level < self__.header.forward.length)))) && (((self__.header.forward[self__.level]) == null)))){
(self__.level = (self__.level - (1)));
continue;
} else {
return null;
}
break;
}
} else {
return null;
}
}));
(cljs.core.async.impl.timers.SkipList.prototype.ceilingEntry = (function (k){
var self__ = this;
var coll = this;
var x = self__.header;
var level__$1 = self__.level;
while(true){
if((!((level__$1 < (0))))){
var nx = (function (){var x__$1 = x;
while(true){
var x_SINGLEQUOTE_ = (((level__$1 < x__$1.forward.length))?(x__$1.forward[level__$1]):null);
if((!((x_SINGLEQUOTE_ == null)))){
if((x_SINGLEQUOTE_.key > k)){
return x__$1;
} else {
var G__35073 = x_SINGLEQUOTE_;
x__$1 = G__35073;
continue;
}
} else {
if((level__$1 === (0))){
return x__$1;
} else {
return null;
}
}
break;
}
})();
if(cljs.core.truth_(nx)){
var G__35075 = nx;
var G__35076 = (level__$1 - (1));
x = G__35075;
level__$1 = G__35076;
continue;
} else {
var G__35077 = x;
var G__35078 = (level__$1 - (1));
x = G__35077;
level__$1 = G__35078;
continue;
}
} else {
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(x.key,k)){
return x;
} else {
return (x.forward[(0)]);
}
}
break;
}
}));
(cljs.core.async.impl.timers.SkipList.prototype.floorEntry = (function (k){
var self__ = this;
var coll = this;
var x = self__.header;
var level__$1 = self__.level;
while(true){
if((!((level__$1 < (0))))){
var nx = (function (){var x__$1 = x;
while(true){
var x_SINGLEQUOTE_ = (((level__$1 < x__$1.forward.length))?(x__$1.forward[level__$1]):null);
if((!((x_SINGLEQUOTE_ == null)))){
if((x_SINGLEQUOTE_.key > k)){
return x__$1;
} else {
var G__35082 = x_SINGLEQUOTE_;
x__$1 = G__35082;
continue;
}
} else {
if((level__$1 === (0))){
return x__$1;
} else {
return null;
}
}
break;
}
})();
if(cljs.core.truth_(nx)){
var G__35084 = nx;
var G__35085 = (level__$1 - (1));
x = G__35084;
level__$1 = G__35085;
continue;
} else {
var G__35086 = x;
var G__35087 = (level__$1 - (1));
x = G__35086;
level__$1 = G__35087;
continue;
}
} else {
if((x === self__.header)){
return null;
} else {
return x;
}
}
break;
}
}));
(cljs.core.async.impl.timers.SkipList.prototype.cljs$core$ISeqable$_seq$arity$1 = (function (coll){
var self__ = this;
var coll__$1 = this;
var iter = (function cljs$core$async$impl$timers$iter(node){
return (new cljs.core.LazySeq(null,(function (){
if((node == null)){
return null;
} else {
return cljs.core.cons(new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [node.key,node.val], null),cljs$core$async$impl$timers$iter((node.forward[(0)])));
}
}),null,null));
});
return iter((self__.header.forward[(0)]));
}));
(cljs.core.async.impl.timers.SkipList.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (coll,writer,opts){
var self__ = this;
var coll__$1 = this;
var pr_pair = (function (keyval){
return cljs.core.pr_sequential_writer(writer,cljs.core.pr_writer,""," ","",opts,keyval);
});
return cljs.core.pr_sequential_writer(writer,pr_pair,"{",", ","}",opts,coll__$1);
}));
(cljs.core.async.impl.timers.SkipList.getBasis = (function (){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"header","header",1759972661,null),cljs.core.with_meta(new cljs.core.Symbol(null,"level","level",-1363938217,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null))], null);
}));
(cljs.core.async.impl.timers.SkipList.cljs$lang$type = true);
(cljs.core.async.impl.timers.SkipList.cljs$lang$ctorStr = "cljs.core.async.impl.timers/SkipList");
(cljs.core.async.impl.timers.SkipList.cljs$lang$ctorPrWriter = (function (this__5310__auto__,writer__5311__auto__,opt__5312__auto__){
return cljs.core._write(writer__5311__auto__,"cljs.core.async.impl.timers/SkipList");
}));
/**
* Positional factory function for cljs.core.async.impl.timers/SkipList.
*/
cljs.core.async.impl.timers.__GT_SkipList = (function cljs$core$async$impl$timers$__GT_SkipList(header,level){
return (new cljs.core.async.impl.timers.SkipList(header,level));
});
cljs.core.async.impl.timers.skip_list = (function cljs$core$async$impl$timers$skip_list(){
return (new cljs.core.async.impl.timers.SkipList(cljs.core.async.impl.timers.skip_list_node.cljs$core$IFn$_invoke$arity$1((0)),(0)));
});
cljs.core.async.impl.timers.timeouts_map = cljs.core.async.impl.timers.skip_list();
cljs.core.async.impl.timers.TIMEOUT_RESOLUTION_MS = (10);
/**
* returns a channel that will close after msecs
*/
cljs.core.async.impl.timers.timeout = (function cljs$core$async$impl$timers$timeout(msecs){
var timeout = ((new Date()).valueOf() + msecs);
var me = cljs.core.async.impl.timers.timeouts_map.ceilingEntry(timeout);
var or__5025__auto__ = (cljs.core.truth_((function (){var and__5023__auto__ = me;
if(cljs.core.truth_(and__5023__auto__)){
return (me.key < (timeout + cljs.core.async.impl.timers.TIMEOUT_RESOLUTION_MS));
} else {
return and__5023__auto__;
}
})())?me.val:null);
if(cljs.core.truth_(or__5025__auto__)){
return or__5025__auto__;
} else {
var timeout_channel = cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$1(null);
cljs.core.async.impl.timers.timeouts_map.put(timeout,timeout_channel);
cljs.core.async.impl.dispatch.queue_delay((function (){
cljs.core.async.impl.timers.timeouts_map.remove(timeout);
return cljs.core.async.impl.protocols.close_BANG_(timeout_channel);
}),msecs);
return timeout_channel;
}
});
//# sourceMappingURL=cljs.core.async.impl.timers.js.map

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

File diff suppressed because it is too large Load diff

Some files were not shown because too many files have changed in this diff Show more