added github pages support

This commit is contained in:
didier amyot committed 2018-01-27 11:27:33 -05:00
1 parent b14ebdbf63
commit 6ed638a1cc
373 files changed
+185436 -2343

No files matched your search

+349
View File
@@ -0,0 +1,349 @@
(ns reagent.core
(:require-macros [reagent.core])
(:refer-clojure :exclude [partial atom flush])
(:require [reagent.impl.template :as tmpl]
[reagent.impl.component :as comp]
[reagent.impl.util :as util]
[reagent.impl.batching :as batch]
[reagent.ratom :as ratom]
[reagent.debug :as deb :refer-macros [dbg prn
assert-some assert-component
assert-js-object assert-new-state
assert-callable]]
[reagent.interop :refer-macros [$ $!]]
[reagent.dom :as dom]))
(def is-client util/is-client)
(def react util/react)
(defn create-element
"Create a native React element, by calling React.createElement directly.
That means the second argument must be a javascript object (or nil), and
that any Reagent hiccup forms must be processed with as-element. For example
like this:
(r/create-element \"div\" #js{:className \"foo\"}
\"Hi \" (r/as-element [:strong \"world!\"])
which is equivalent to
[:div.foo \"Hi\" [:strong \"world!\"]]"
([type]
(create-element type nil))
([type props]
(assert-js-object props)
($ react createElement type props))
([type props child]
(assert-js-object props)
($ react createElement type props child))
([type props child & children]
(assert-js-object props)
(apply ($ react :createElement) type props child children)))
(defn as-element
"Turns a vector of Hiccup syntax into a React element. Returns form
unchanged if it is not a vector."
[form]
(tmpl/as-element form))
(defn adapt-react-class
"Returns an adapter for a native React class, that may be used
just like a Reagent component function or class in Hiccup forms."
[c]
(assert-some c "Component")
(tmpl/adapt-react-class c))
(defn reactify-component
"Returns an adapter for a Reagent component, that may be used from
React, for example in JSX. A single argument, props, is passed to
the component, converted to a map."
[c]
(assert-some c "Component")
(comp/reactify-component c))
(defn render
"Render a Reagent component into the DOM. The first argument may be
either a vector (using Reagent's Hiccup syntax), or a React element.
The second argument should be a DOM node.
Optionally takes a callback that is called when the component is in place.
Returns the mounted component instance."
([comp container]
(dom/render comp container))
([comp container callback]
(dom/render comp container callback)))
(defn unmount-component-at-node
"Remove a component from the given DOM node."
[container]
(dom/unmount-component-at-node container))
;; For backward compatibility
(def as-component as-element)
(def render-component render)
(defn ^:export force-update-all
"Force re-rendering of all mounted Reagent components. This is
probably only useful in a development environment, when you want to
update components in response to some dynamic changes to code.
Note that force-update-all may not update root components. This
happens if a component 'foo' is mounted with `(render [foo])` (since
functions are passed by value, and not by reference, in
ClojureScript). To get around this you'll have to introduce a layer
of indirection, for example by using `(render [#'foo])` instead."
[]
(ratom/flush!)
(dom/force-update-all)
(batch/flush-after-render))
(defn create-class
"Create a component, React style. Should be called with a map,
looking like this:
{:get-initial-state (fn [this])
:component-will-receive-props (fn [this new-argv])
:should-component-update (fn [this old-argv new-argv])
:component-will-mount (fn [this])
:component-did-mount (fn [this])
:component-will-update (fn [this new-argv])
:component-did-update (fn [this old-argv])
:component-will-unmount (fn [this])
:reagent-render (fn [args....])} ;; or :render (fn [this])
Everything is optional, except either :reagent-render or :render."
[spec]
(comp/create-class spec))
(defn current-component
"Returns the current React component (a.k.a this) in a component
function."
[]
comp/*current-component*)
(defn state-atom
"Returns an atom containing a components state."
[this]
(assert-component this)
(comp/state-atom this))
(defn state
"Returns the state of a component, as set with replace-state or set-state.
Equivalent to (deref (r/state-atom this))"
[this]
(assert-component this)
(deref (state-atom this)))
(defn replace-state
"Set state of a component.
Equivalent to (reset! (state-atom this) new-state)"
[this new-state]
(assert-component this)
(assert-new-state new-state)
(reset! (state-atom this) new-state))
(defn set-state
"Merge component state with new-state.
Equivalent to (swap! (state-atom this) merge new-state)"
[this new-state]
(assert-component this)
(assert-new-state new-state)
(swap! (state-atom this) merge new-state))
(defn force-update
"Force a component to re-render immediately.
If the second argument is true, child components will also be
re-rendered, even is their arguments have not changed."
([this]
(force-update this false))
([this deep]
(ratom/flush!)
(util/force-update this deep)
(batch/flush-after-render)))
(defn props
"Returns the props passed to a component."
[this]
(assert-component this)
(comp/get-props this))
(defn children
"Returns the children passed to a component."
[this]
(assert-component this)
(comp/get-children this))
(defn argv
"Returns the entire Hiccup form passed to the component."
[this]
(assert-component this)
(comp/get-argv this))
(defn dom-node
"Returns the root DOM node of a mounted component."
[this]
(dom/dom-node this))
(defn merge-props
"Utility function that merges two maps, handling :class and :style
specially, like React's transferPropsTo."
[defaults props]
(util/merge-props defaults props))
(defn flush
"Render dirty components immediately to the DOM.
Note that this may not work in event handlers, since React.js does
batching of updates there."
[]
(batch/flush))
;; Ratom
(defn atom
"Like clojure.core/atom, except that it keeps track of derefs.
Reagent components that derefs one of these are automatically
re-rendered."
([x] (ratom/atom x))
([x & rest] (apply ratom/atom x rest)))
(defn track
"Takes a function and optional arguments, and returns a derefable
containing the output of that function. If the function derefs
Reagent atoms (or track, etc), the value will be updated whenever
the atom changes.
In other words, @(track foo bar) will produce the same result
as (foo bar), but foo will only be called again when the atoms it
depends on changes, and will only trigger updates of components when
its result changes.
track is lazy, i.e the function is only evaluated on deref."
[f & args]
{:pre [(ifn? f)]}
(ratom/make-track f args))
(defn track!
"An eager version of track. The function passed is called
immediately, and continues to be called when needed, until stopped
with dispose!."
[f & args]
{:pre [(ifn? f)]}
(ratom/make-track! f args))
(defn dispose!
"Stop the result of track! from updating."
[x]
(ratom/dispose! x))
(defn wrap
"Provide a combination of value and callback, that looks like an atom.
The first argument can be any value, that will be returned when the
result is deref'ed.
The second argument should be a function, that is called with the
optional extra arguments provided to wrap, and the new value of the
resulting 'atom'.
Use for example like this:
(wrap (:foo @state)
swap! state assoc :foo)
Probably useful only for passing to child components."
[value reset-fn & args]
(assert-callable reset-fn)
(ratom/make-wrapper value reset-fn args))
;; RCursor
(defn cursor
"Provide a cursor into a Reagent atom.
Behaves like a Reagent atom but focuses updates and derefs to
the specified path within the wrapped Reagent atom. e.g.,
(let [c (cursor ra [:nested :content])]
... @c ;; equivalent to (get-in @ra [:nested :content])
... (reset! c 42) ;; equivalent to (swap! ra assoc-in [:nested :content] 42)
... (swap! c inc) ;; equivalence to (swap! ra update-in [:nested :content] inc)
)
The first parameter can also be a function, that should look
something like this:
(defn set-get
([k] (get-in @state k))
([k v] (swap! state assoc-in k v)))
The function will be called with one argument – the path passed to
cursor – when the cursor is deref'ed, and two arguments (path and
new value) when the cursor is modified.
Given that set-get function, (and that state is a Reagent atom, or
another cursor) these cursors are equivalent:
(cursor state [:foo]) and (cursor set-get [:foo]).
Note that a cursor is lazy: its value will not change until it is
used. This may be noticed with add-watch."
([src path]
(ratom/cursor src path)))
;; Utilities
(defn rswap!
"Swaps the value of a to be (apply f current-value-of-atom args).
rswap! works like swap!, except that recursive calls to rswap! on
the same atom are allowed – and it always returns nil."
[a f & args]
{:pre [(satisfies? IAtom a)
(ifn? f)]}
(if a.rswapping
(-> (or a.rswapfs (set! a.rswapfs (array)))
(.push #(apply f % args)))
(do (set! a.rswapping true)
(try (swap! a (fn [state]
(loop [s (apply f state args)]
(if-some [sf (some-> a.rswapfs .shift)]
(recur (sf s))
s))))
(finally
(set! a.rswapping false)))))
nil)
(defn next-tick
"Run f using requestAnimationFrame or equivalent.
f will be called just before components are rendered."
[f]
(batch/do-before-flush f))
(defn after-render
"Run f using requestAnimationFrame or equivalent.
f will be called just after any queued renders in the next animation
frame (and even if no renders actually occur)."
[f]
(batch/do-after-render f))
(defn partial
"Works just like clojure.core/partial, but the result can be compared with ="
[f & args]
(util/make-partial-fn f args))
(defn component-path
;; Try to return the path of component c as a string.
;; Maybe useful for debugging and error reporting, but may break
;; with future versions of React (and return nil).
[c]
(comp/component-path c))
+1
View File
@@ -0,0 +1 @@
{:rename-macros {}, :renames {}, :externs {Error {}}, :use-macros {assert-js-object reagent.debug, assert-some reagent.debug, assert-new-state reagent.debug, dbg reagent.debug, $! reagent.interop, prn reagent.debug, assert-component reagent.debug, $ reagent.interop, assert-callable reagent.debug}, :excludes #{atom flush partial}, :name reagent.core, :imports nil, :requires {reagent.impl.util reagent.impl.util, dom reagent.dom, comp reagent.impl.component, reagent.interop reagent.interop, reagent.ratom reagent.ratom, reagent.impl.template reagent.impl.template, reagent.impl.batching reagent.impl.batching, reagent.impl.component reagent.impl.component, util reagent.impl.util, tmpl reagent.impl.template, ratom reagent.ratom, deb reagent.debug, batch reagent.impl.batching, reagent.debug reagent.debug, reagent.dom reagent.dom}, :cljs.spec/speced-vars [], :uses nil, :defs {after-render {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/core.cljs", :line 331, :column 7, :end-line 331, :end-column 19, :arglists (quote ([f])), :doc "Run f using requestAnimationFrame or equivalent.\n\n f will be called just after any queued renders in the next animation\n frame (and even if no renders actually occur)."}, :name reagent.core/after-render, :variadic false, :file "target/cljsbuild/public/js/out/reagent/core.cljs", :end-column 19, :method-params ([f]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 331, :end-line 331, :max-fixed-arity 1, :fn-var true, :arglists (quote ([f])), :doc "Run f using requestAnimationFrame or equivalent.\n\n f will be called just after any queued renders in the next animation\n frame (and even if no renders actually occur)."}, current-component {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/core.cljs", :line 122, :column 7, :end-line 122, :end-column 24, :arglists (quote ([])), :doc "Returns the current React component (a.k.a this) in a component\n function."}, :name reagent.core/current-component, :variadic false, :file "target/cljsbuild/public/js/out/reagent/core.cljs", :end-column 24, :method-params ([]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 122, :end-line 122, :max-fixed-arity 0, :fn-var true, :arglists (quote ([])), :doc "Returns the current React component (a.k.a this) in a component\n function."}, as-component {:name reagent.core/as-component, :file "target/cljsbuild/public/js/out/reagent/core.cljs", :line 85, :column 1, :end-line 85, :end-column 18, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/core.cljs", :line 85, :column 6, :end-line 85, :end-column 18}}, adapt-react-class {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/core.cljs", :line 51, :column 7, :end-line 51, :end-column 24, :arglists (quote ([c])), :doc "Returns an adapter for a native React class, that may be used\n just like a Reagent component function or class in Hiccup forms."}, :name reagent.core/adapt-react-class, :variadic false, :file "target/cljsbuild/public/js/out/reagent/core.cljs", :end-column 24, :method-params ([c]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 51, :end-line 51, :max-fixed-arity 1, :fn-var true, :arglists (quote ([c])), :doc "Returns an adapter for a native React class, that may be used\n just like a Reagent component function or class in Hiccup forms."}, atom {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/core.cljs", :line 210, :column 7, :end-line 210, :end-column 11, :arglists (quote ([x] [x & rest])), :doc "Like clojure.core/atom, except that it keeps track of derefs.\n Reagent components that derefs one of these are automatically\n re-rendered.", :top-fn {:variadic true, :max-fixed-arity 1, :method-params ([x]), :arglists ([x] [x & rest]), :arglists-meta (nil nil)}}, :name reagent.core/atom, :variadic true, :file "target/cljsbuild/public/js/out/reagent/core.cljs", :end-column 11, :top-fn {:variadic true, :max-fixed-arity 1, :method-params ([x]), :arglists ([x] [x & rest]), :arglists-meta (nil nil)}, :method-params ([x]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 210, :end-line 210, :max-fixed-arity 1, :fn-var true, :arglists ([x] [x & rest]), :doc "Like clojure.core/atom, except that it keeps track of derefs.\n Reagent components that derefs one of these are automatically\n re-rendered."}, merge-props {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/core.cljs", :line 192, :column 7, :end-line 192, :end-column 18, :arglists (quote ([defaults props])), :doc "Utility function that merges two maps, handling :class and :style\n specially, like React's transferPropsTo."}, :name reagent.core/merge-props, :variadic false, :file "target/cljsbuild/public/js/out/reagent/core.cljLine truncated
+757
View File
@@ -0,0 +1,757 @@
// Compiled by ClojureScript 1.9.946 {}
goog.provide('reagent.core');
goog.require('cljs.core');
goog.require('reagent.impl.template');
goog.require('reagent.impl.component');
goog.require('reagent.impl.util');
goog.require('reagent.impl.batching');
goog.require('reagent.ratom');
goog.require('reagent.debug');
goog.require('reagent.interop');
goog.require('reagent.dom');
reagent.core.is_client = reagent.impl.util.is_client;
reagent.core.react = reagent.impl.util.react;
/**
* Create a native React element, by calling React.createElement directly.
*
* That means the second argument must be a javascript object (or nil), and
* that any Reagent hiccup forms must be processed with as-element. For example
* like this:
*
* (r/create-element "div" #js{:className "foo"}
* "Hi " (r/as-element [:strong "world!"])
*
* which is equivalent to
*
* [:div.foo "Hi" [:strong "world!"]]
*/
reagent.core.create_element = (function reagent$core$create_element(var_args){
var G__37760 = arguments.length;
switch (G__37760) {
case 1:
return reagent.core.create_element.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
case 2:
return reagent.core.create_element.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
case 3:
return reagent.core.create_element.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
default:
var args_arr__36800__auto__ = [];
var len__36777__auto___37762 = arguments.length;
var i__36778__auto___37763 = (0);
while(true){
if((i__36778__auto___37763 < len__36777__auto___37762)){
args_arr__36800__auto__.push((arguments[i__36778__auto___37763]));
var G__37764 = (i__36778__auto___37763 + (1));
i__36778__auto___37763 = G__37764;
continue;
} else {
}
break;
}
var argseq__36801__auto__ = (new cljs.core.IndexedSeq(args_arr__36800__auto__.slice((3)),(0),null));
return reagent.core.create_element.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),argseq__36801__auto__);
}
});
reagent.core.create_element.cljs$core$IFn$_invoke$arity$1 = (function (type){
return reagent.core.create_element.call(null,type,null);
});
reagent.core.create_element.cljs$core$IFn$_invoke$arity$2 = (function (type,props){
if(!(cljs.core.map_QMARK_.call(null,props))){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a JS object, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.call(null,props))].join('')),"\n","(clojure.core/not (clojure.core/map? props))"].join('')));
}
return (reagent.core.react["createElement"])(type,props);
});
reagent.core.create_element.cljs$core$IFn$_invoke$arity$3 = (function (type,props,child){
if(!(cljs.core.map_QMARK_.call(null,props))){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a JS object, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.call(null,props))].join('')),"\n","(clojure.core/not (clojure.core/map? props))"].join('')));
}
return (reagent.core.react["createElement"])(type,props,child);
});
reagent.core.create_element.cljs$core$IFn$_invoke$arity$variadic = (function (type,props,child,children){
if(!(cljs.core.map_QMARK_.call(null,props))){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a JS object, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.call(null,props))].join('')),"\n","(clojure.core/not (clojure.core/map? props))"].join('')));
}
return cljs.core.apply.call(null,(reagent.core.react["createElement"]),type,props,child,children);
});
reagent.core.create_element.cljs$lang$applyTo = (function (seq37756){
var G__37757 = cljs.core.first.call(null,seq37756);
var seq37756__$1 = cljs.core.next.call(null,seq37756);
var G__37758 = cljs.core.first.call(null,seq37756__$1);
var seq37756__$2 = cljs.core.next.call(null,seq37756__$1);
var G__37759 = cljs.core.first.call(null,seq37756__$2);
var seq37756__$3 = cljs.core.next.call(null,seq37756__$2);
return reagent.core.create_element.cljs$core$IFn$_invoke$arity$variadic(G__37757,G__37758,G__37759,seq37756__$3);
});
reagent.core.create_element.cljs$lang$maxFixedArity = (3);
/**
* Turns a vector of Hiccup syntax into a React element. Returns form
* unchanged if it is not a vector.
*/
reagent.core.as_element = (function reagent$core$as_element(form){
return reagent.impl.template.as_element.call(null,form);
});
/**
* Returns an adapter for a native React class, that may be used
* just like a Reagent component function or class in Hiccup forms.
*/
reagent.core.adapt_react_class = (function reagent$core$adapt_react_class(c){
if(cljs.core.truth_(c)){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Component"," must not be nil"].join('')),"\n","c"].join('')));
}
return reagent.impl.template.adapt_react_class.call(null,c);
});
/**
* Returns an adapter for a Reagent component, that may be used from
* React, for example in JSX. A single argument, props, is passed to
* the component, converted to a map.
*/
reagent.core.reactify_component = (function reagent$core$reactify_component(c){
if(cljs.core.truth_(c)){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Component"," must not be nil"].join('')),"\n","c"].join('')));
}
return reagent.impl.component.reactify_component.call(null,c);
});
/**
* Render a Reagent component into the DOM. The first argument may be
* either a vector (using Reagent's Hiccup syntax), or a React element.
* The second argument should be a DOM node.
*
* Optionally takes a callback that is called when the component is in place.
*
* Returns the mounted component instance.
*/
reagent.core.render = (function reagent$core$render(var_args){
var G__37766 = arguments.length;
switch (G__37766) {
case 2:
return reagent.core.render.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
case 3:
return reagent.core.render.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('')));
}
});
reagent.core.render.cljs$core$IFn$_invoke$arity$2 = (function (comp,container){
return reagent.dom.render.call(null,comp,container);
});
reagent.core.render.cljs$core$IFn$_invoke$arity$3 = (function (comp,container,callback){
return reagent.dom.render.call(null,comp,container,callback);
});
reagent.core.render.cljs$lang$maxFixedArity = 3;
/**
* Remove a component from the given DOM node.
*/
reagent.core.unmount_component_at_node = (function reagent$core$unmount_component_at_node(container){
return reagent.dom.unmount_component_at_node.call(null,container);
});
reagent.core.as_component = reagent.core.as_element;
reagent.core.render_component = reagent.core.render;
/**
* Force re-rendering of all mounted Reagent components. This is
* probably only useful in a development environment, when you want to
* update components in response to some dynamic changes to code.
*
* Note that force-update-all may not update root components. This
* happens if a component 'foo' is mounted with `(render [foo])` (since
* functions are passed by value, and not by reference, in
* ClojureScript). To get around this you'll have to introduce a layer
* of indirection, for example by using `(render [#'foo])` instead.
*/
reagent.core.force_update_all = (function reagent$core$force_update_all(){
reagent.ratom.flush_BANG_.call(null);
reagent.dom.force_update_all.call(null);
return reagent.impl.batching.flush_after_render.call(null);
});
goog.exportSymbol('reagent.core.force_update_all', reagent.core.force_update_all);
/**
* Create a component, React style. Should be called with a map,
* looking like this:
*
* {:get-initial-state (fn [this])
* :component-will-receive-props (fn [this new-argv])
* :should-component-update (fn [this old-argv new-argv])
* :component-will-mount (fn [this])
* :component-did-mount (fn [this])
* :component-will-update (fn [this new-argv])
* :component-did-update (fn [this old-argv])
* :component-will-unmount (fn [this])
* :reagent-render (fn [args....])} ;; or :render (fn [this])
*
* Everything is optional, except either :reagent-render or :render.
*/
reagent.core.create_class = (function reagent$core$create_class(spec){
return reagent.impl.component.create_class.call(null,spec);
});
/**
* Returns the current React component (a.k.a this) in a component
* function.
*/
reagent.core.current_component = (function reagent$core$current_component(){
return reagent.impl.component._STAR_current_component_STAR_;
});
/**
* Returns an atom containing a components state.
*/
reagent.core.state_atom = (function reagent$core$state_atom(this$){
if(reagent.impl.component.reagent_component_QMARK_.call(null,this$)){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a reagent component, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.call(null,this$))].join('')),"\n","(comp/reagent-component? this)"].join('')));
}
return reagent.impl.component.state_atom.call(null,this$);
});
/**
* Returns the state of a component, as set with replace-state or set-state.
* Equivalent to (deref (r/state-atom this))
*/
reagent.core.state = (function reagent$core$state(this$){
if(reagent.impl.component.reagent_component_QMARK_.call(null,this$)){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a reagent component, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.call(null,this$))].join('')),"\n","(comp/reagent-component? this)"].join('')));
}
return cljs.core.deref.call(null,reagent.core.state_atom.call(null,this$));
});
/**
* Set state of a component.
* Equivalent to (reset! (state-atom this) new-state)
*/
reagent.core.replace_state = (function reagent$core$replace_state(this$,new_state){
if(reagent.impl.component.reagent_component_QMARK_.call(null,this$)){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a reagent component, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.call(null,this$))].join('')),"\n","(comp/reagent-component? this)"].join('')));
}
if(((new_state == null)) || (cljs.core.map_QMARK_.call(null,new_state))){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a valid new state, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.call(null,new_state))].join('')),"\n","(clojure.core/or (clojure.core/nil? new-state) (clojure.core/map? new-state))"].join('')));
}
return cljs.core.reset_BANG_.call(null,reagent.core.state_atom.call(null,this$),new_state);
});
/**
* Merge component state with new-state.
* Equivalent to (swap! (state-atom this) merge new-state)
*/
reagent.core.set_state = (function reagent$core$set_state(this$,new_state){
if(reagent.impl.component.reagent_component_QMARK_.call(null,this$)){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a reagent component, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.call(null,this$))].join('')),"\n","(comp/reagent-component? this)"].join('')));
}
if(((new_state == null)) || (cljs.core.map_QMARK_.call(null,new_state))){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a valid new state, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.call(null,new_state))].join('')),"\n","(clojure.core/or (clojure.core/nil? new-state) (clojure.core/map? new-state))"].join('')));
}
return cljs.core.swap_BANG_.call(null,reagent.core.state_atom.call(null,this$),cljs.core.merge,new_state);
});
/**
* Force a component to re-render immediately.
*
* If the second argument is true, child components will also be
* re-rendered, even is their arguments have not changed.
*/
reagent.core.force_update = (function reagent$core$force_update(var_args){
var G__37769 = arguments.length;
switch (G__37769) {
case 1:
return reagent.core.force_update.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
case 2:
return reagent.core.force_update.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('')));
}
});
reagent.core.force_update.cljs$core$IFn$_invoke$arity$1 = (function (this$){
return reagent.core.force_update.call(null,this$,false);
});
reagent.core.force_update.cljs$core$IFn$_invoke$arity$2 = (function (this$,deep){
reagent.ratom.flush_BANG_.call(null);
reagent.impl.util.force_update.call(null,this$,deep);
return reagent.impl.batching.flush_after_render.call(null);
});
reagent.core.force_update.cljs$lang$maxFixedArity = 2;
/**
* Returns the props passed to a component.
*/
reagent.core.props = (function reagent$core$props(this$){
if(reagent.impl.component.reagent_component_QMARK_.call(null,this$)){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a reagent component, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.call(null,this$))].join('')),"\n","(comp/reagent-component? this)"].join('')));
}
return reagent.impl.component.get_props.call(null,this$);
});
/**
* Returns the children passed to a component.
*/
reagent.core.children = (function reagent$core$children(this$){
if(reagent.impl.component.reagent_component_QMARK_.call(null,this$)){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a reagent component, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.call(null,this$))].join('')),"\n","(comp/reagent-component? this)"].join('')));
}
return reagent.impl.component.get_children.call(null,this$);
});
/**
* Returns the entire Hiccup form passed to the component.
*/
reagent.core.argv = (function reagent$core$argv(this$){
if(reagent.impl.component.reagent_component_QMARK_.call(null,this$)){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected a reagent component, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.call(null,this$))].join('')),"\n","(comp/reagent-component? this)"].join('')));
}
return reagent.impl.component.get_argv.call(null,this$);
});
/**
* Returns the root DOM node of a mounted component.
*/
reagent.core.dom_node = (function reagent$core$dom_node(this$){
return reagent.dom.dom_node.call(null,this$);
});
/**
* Utility function that merges two maps, handling :class and :style
* specially, like React's transferPropsTo.
*/
reagent.core.merge_props = (function reagent$core$merge_props(defaults,props){
return reagent.impl.util.merge_props.call(null,defaults,props);
});
/**
* Render dirty components immediately to the DOM.
*
* Note that this may not work in event handlers, since React.js does
* batching of updates there.
*/
reagent.core.flush = (function reagent$core$flush(){
return reagent.impl.batching.flush.call(null);
});
/**
* Like clojure.core/atom, except that it keeps track of derefs.
* Reagent components that derefs one of these are automatically
* re-rendered.
*/
reagent.core.atom = (function reagent$core$atom(var_args){
var G__37774 = arguments.length;
switch (G__37774) {
case 1:
return reagent.core.atom.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
default:
var args_arr__36800__auto__ = [];
var len__36777__auto___37776 = arguments.length;
var i__36778__auto___37777 = (0);
while(true){
if((i__36778__auto___37777 < len__36777__auto___37776)){
args_arr__36800__auto__.push((arguments[i__36778__auto___37777]));
var G__37778 = (i__36778__auto___37777 + (1));
i__36778__auto___37777 = G__37778;
continue;
} else {
}
break;
}
var argseq__36801__auto__ = (new cljs.core.IndexedSeq(args_arr__36800__auto__.slice((1)),(0),null));
return reagent.core.atom.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__36801__auto__);
}
});
reagent.core.atom.cljs$core$IFn$_invoke$arity$1 = (function (x){
return reagent.ratom.atom.call(null,x);
});
reagent.core.atom.cljs$core$IFn$_invoke$arity$variadic = (function (x,rest){
return cljs.core.apply.call(null,reagent.ratom.atom,x,rest);
});
reagent.core.atom.cljs$lang$applyTo = (function (seq37772){
var G__37773 = cljs.core.first.call(null,seq37772);
var seq37772__$1 = cljs.core.next.call(null,seq37772);
return reagent.core.atom.cljs$core$IFn$_invoke$arity$variadic(G__37773,seq37772__$1);
});
reagent.core.atom.cljs$lang$maxFixedArity = (1);
/**
* Takes a function and optional arguments, and returns a derefable
* containing the output of that function. If the function derefs
* Reagent atoms (or track, etc), the value will be updated whenever
* the atom changes.
*
* In other words, @(track foo bar) will produce the same result
* as (foo bar), but foo will only be called again when the atoms it
* depends on changes, and will only trigger updates of components when
* its result changes.
*
* track is lazy, i.e the function is only evaluated on deref.
*/
reagent.core.track = (function reagent$core$track(var_args){
var args__36784__auto__ = [];
var len__36777__auto___37781 = arguments.length;
var i__36778__auto___37782 = (0);
while(true){
if((i__36778__auto___37782 < len__36777__auto___37781)){
args__36784__auto__.push((arguments[i__36778__auto___37782]));
var G__37783 = (i__36778__auto___37782 + (1));
i__36778__auto___37782 = G__37783;
continue;
} else {
}
break;
}
var argseq__36785__auto__ = ((((1) < args__36784__auto__.length))?(new cljs.core.IndexedSeq(args__36784__auto__.slice((1)),(0),null)):null);
return reagent.core.track.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__36785__auto__);
});
reagent.core.track.cljs$core$IFn$_invoke$arity$variadic = (function (f,args){
if(cljs.core.ifn_QMARK_.call(null,f)){
} else {
throw (new Error("Assert failed: (ifn? f)"));
}
return reagent.ratom.make_track.call(null,f,args);
});
reagent.core.track.cljs$lang$maxFixedArity = (1);
reagent.core.track.cljs$lang$applyTo = (function (seq37779){
var G__37780 = cljs.core.first.call(null,seq37779);
var seq37779__$1 = cljs.core.next.call(null,seq37779);
return reagent.core.track.cljs$core$IFn$_invoke$arity$variadic(G__37780,seq37779__$1);
});
/**
* An eager version of track. The function passed is called
* immediately, and continues to be called when needed, until stopped
* with dispose!.
*/
reagent.core.track_BANG_ = (function reagent$core$track_BANG_(var_args){
var args__36784__auto__ = [];
var len__36777__auto___37786 = arguments.length;
var i__36778__auto___37787 = (0);
while(true){
if((i__36778__auto___37787 < len__36777__auto___37786)){
args__36784__auto__.push((arguments[i__36778__auto___37787]));
var G__37788 = (i__36778__auto___37787 + (1));
i__36778__auto___37787 = G__37788;
continue;
} else {
}
break;
}
var argseq__36785__auto__ = ((((1) < args__36784__auto__.length))?(new cljs.core.IndexedSeq(args__36784__auto__.slice((1)),(0),null)):null);
return reagent.core.track_BANG_.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__36785__auto__);
});
reagent.core.track_BANG_.cljs$core$IFn$_invoke$arity$variadic = (function (f,args){
if(cljs.core.ifn_QMARK_.call(null,f)){
} else {
throw (new Error("Assert failed: (ifn? f)"));
}
return reagent.ratom.make_track_BANG_.call(null,f,args);
});
reagent.core.track_BANG_.cljs$lang$maxFixedArity = (1);
reagent.core.track_BANG_.cljs$lang$applyTo = (function (seq37784){
var G__37785 = cljs.core.first.call(null,seq37784);
var seq37784__$1 = cljs.core.next.call(null,seq37784);
return reagent.core.track_BANG_.cljs$core$IFn$_invoke$arity$variadic(G__37785,seq37784__$1);
});
/**
* Stop the result of track! from updating.
*/
reagent.core.dispose_BANG_ = (function reagent$core$dispose_BANG_(x){
return reagent.ratom.dispose_BANG_.call(null,x);
});
/**
* Provide a combination of value and callback, that looks like an atom.
*
* The first argument can be any value, that will be returned when the
* result is deref'ed.
*
* The second argument should be a function, that is called with the
* optional extra arguments provided to wrap, and the new value of the
* resulting 'atom'.
*
* Use for example like this:
*
* (wrap (:foo @state)
* swap! state assoc :foo)
*
* Probably useful only for passing to child components.
*/
reagent.core.wrap = (function reagent$core$wrap(var_args){
var args__36784__auto__ = [];
var len__36777__auto___37792 = arguments.length;
var i__36778__auto___37793 = (0);
while(true){
if((i__36778__auto___37793 < len__36777__auto___37792)){
args__36784__auto__.push((arguments[i__36778__auto___37793]));
var G__37794 = (i__36778__auto___37793 + (1));
i__36778__auto___37793 = G__37794;
continue;
} else {
}
break;
}
var argseq__36785__auto__ = ((((2) < args__36784__auto__.length))?(new cljs.core.IndexedSeq(args__36784__auto__.slice((2)),(0),null)):null);
return reagent.core.wrap.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__36785__auto__);
});
reagent.core.wrap.cljs$core$IFn$_invoke$arity$variadic = (function (value,reset_fn,args){
if(cljs.core.ifn_QMARK_.call(null,reset_fn)){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected something callable, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.call(null,reset_fn))].join('')),"\n","(clojure.core/ifn? reset-fn)"].join('')));
}
return reagent.ratom.make_wrapper.call(null,value,reset_fn,args);
});
reagent.core.wrap.cljs$lang$maxFixedArity = (2);
reagent.core.wrap.cljs$lang$applyTo = (function (seq37789){
var G__37790 = cljs.core.first.call(null,seq37789);
var seq37789__$1 = cljs.core.next.call(null,seq37789);
var G__37791 = cljs.core.first.call(null,seq37789__$1);
var seq37789__$2 = cljs.core.next.call(null,seq37789__$1);
return reagent.core.wrap.cljs$core$IFn$_invoke$arity$variadic(G__37790,G__37791,seq37789__$2);
});
/**
* Provide a cursor into a Reagent atom.
*
* Behaves like a Reagent atom but focuses updates and derefs to
* the specified path within the wrapped Reagent atom. e.g.,
* (let [c (cursor ra [:nested :content])]
* ... @c ;; equivalent to (get-in @ra [:nested :content])
* ... (reset! c 42) ;; equivalent to (swap! ra assoc-in [:nested :content] 42)
* ... (swap! c inc) ;; equivalence to (swap! ra update-in [:nested :content] inc)
* )
*
* The first parameter can also be a function, that should look
* something like this:
*
* (defn set-get
* ([k] (get-in @state k))
* ([k v] (swap! state assoc-in k v)))
*
* The function will be called with one argument – the path passed to
* cursor – when the cursor is deref'ed, and two arguments (path and
* new value) when the cursor is modified.
*
* Given that set-get function, (and that state is a Reagent atom, or
* another cursor) these cursors are equivalent:
* (cursor state [:foo]) and (cursor set-get [:foo]).
*
* Note that a cursor is lazy: its value will not change until it is
* used. This may be noticed with add-watch.
*/
reagent.core.cursor = (function reagent$core$cursor(src,path){
return reagent.ratom.cursor.call(null,src,path);
});
/**
* Swaps the value of a to be (apply f current-value-of-atom args).
*
* rswap! works like swap!, except that recursive calls to rswap! on
* the same atom are allowed – and it always returns nil.
*/
reagent.core.rswap_BANG_ = (function reagent$core$rswap_BANG_(var_args){
var args__36784__auto__ = [];
var len__36777__auto___37801 = arguments.length;
var i__36778__auto___37802 = (0);
while(true){
if((i__36778__auto___37802 < len__36777__auto___37801)){
args__36784__auto__.push((arguments[i__36778__auto___37802]));
var G__37803 = (i__36778__auto___37802 + (1));
i__36778__auto___37802 = G__37803;
continue;
} else {
}
break;
}
var argseq__36785__auto__ = ((((2) < args__36784__auto__.length))?(new cljs.core.IndexedSeq(args__36784__auto__.slice((2)),(0),null)):null);
return reagent.core.rswap_BANG_.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__36785__auto__);
});
reagent.core.rswap_BANG_.cljs$core$IFn$_invoke$arity$variadic = (function (a,f,args){
if(((!((a == null)))?((((a.cljs$lang$protocol_mask$partition1$ & (16384))) || ((cljs.core.PROTOCOL_SENTINEL === a.cljs$core$IAtom$)))?true:(((!a.cljs$lang$protocol_mask$partition1$))?cljs.core.native_satisfies_QMARK_.call(null,cljs.core.IAtom,a):false)):cljs.core.native_satisfies_QMARK_.call(null,cljs.core.IAtom,a))){
} else {
throw (new Error("Assert failed: (satisfies? IAtom a)"));
}
if(cljs.core.ifn_QMARK_.call(null,f)){
} else {
throw (new Error("Assert failed: (ifn? f)"));
}
if(cljs.core.truth_(a.rswapping)){
(function (){var or__35498__auto__ = a.rswapfs;
if(cljs.core.truth_(or__35498__auto__)){
return or__35498__auto__;
} else {
return a.rswapfs = [];
}
})().push((function (p1__37795_SHARP_){
return cljs.core.apply.call(null,f,p1__37795_SHARP_,args);
}));
} else {
a.rswapping = true;
try{cljs.core.swap_BANG_.call(null,a,(function (state){
var s = cljs.core.apply.call(null,f,state,args);
while(true){
var temp__5459__auto__ = (function (){var G__37800 = a.rswapfs;
if((G__37800 == null)){
return null;
} else {
return G__37800.shift();
}
})();
if((temp__5459__auto__ == null)){
return s;
} else {
var sf = temp__5459__auto__;
var G__37804 = sf.call(null,s);
s = G__37804;
continue;
}
break;
}
}));
}finally {a.rswapping = false;
}}
return null;
});
reagent.core.rswap_BANG_.cljs$lang$maxFixedArity = (2);
reagent.core.rswap_BANG_.cljs$lang$applyTo = (function (seq37796){
var G__37797 = cljs.core.first.call(null,seq37796);
var seq37796__$1 = cljs.core.next.call(null,seq37796);
var G__37798 = cljs.core.first.call(null,seq37796__$1);
var seq37796__$2 = cljs.core.next.call(null,seq37796__$1);
return reagent.core.rswap_BANG_.cljs$core$IFn$_invoke$arity$variadic(G__37797,G__37798,seq37796__$2);
});
/**
* Run f using requestAnimationFrame or equivalent.
*
* f will be called just before components are rendered.
*/
reagent.core.next_tick = (function reagent$core$next_tick(f){
return reagent.impl.batching.do_before_flush.call(null,f);
});
/**
* Run f using requestAnimationFrame or equivalent.
*
* f will be called just after any queued renders in the next animation
* frame (and even if no renders actually occur).
*/
reagent.core.after_render = (function reagent$core$after_render(f){
return reagent.impl.batching.do_after_render.call(null,f);
});
/**
* Works just like clojure.core/partial, but the result can be compared with =
*/
reagent.core.partial = (function reagent$core$partial(var_args){
var args__36784__auto__ = [];
var len__36777__auto___37807 = arguments.length;
var i__36778__auto___37808 = (0);
while(true){
if((i__36778__auto___37808 < len__36777__auto___37807)){
args__36784__auto__.push((arguments[i__36778__auto___37808]));
var G__37809 = (i__36778__auto___37808 + (1));
i__36778__auto___37808 = G__37809;
continue;
} else {
}
break;
}
var argseq__36785__auto__ = ((((1) < args__36784__auto__.length))?(new cljs.core.IndexedSeq(args__36784__auto__.slice((1)),(0),null)):null);
return reagent.core.partial.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__36785__auto__);
});
reagent.core.partial.cljs$core$IFn$_invoke$arity$variadic = (function (f,args){
return reagent.impl.util.make_partial_fn.call(null,f,args);
});
reagent.core.partial.cljs$lang$maxFixedArity = (1);
reagent.core.partial.cljs$lang$applyTo = (function (seq37805){
var G__37806 = cljs.core.first.call(null,seq37805);
var seq37805__$1 = cljs.core.next.call(null,seq37805);
return reagent.core.partial.cljs$core$IFn$_invoke$arity$variadic(G__37806,seq37805__$1);
});
reagent.core.component_path = (function reagent$core$component_path(c){
return reagent.impl.component.component_path.call(null,c);
});
//# sourceMappingURL=core.js.map?rel=1517021941368
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"\/home\/didier\/clojupyter\/website\/target\/cljsbuild\/public\/js\/out\/reagent\/core.js","sources":["core.cljs?rel=1517021941370"],"lineCount":757,"mappings":";AAAA;;;;;;;;;;AAeA,AAAKA,yBAAUC;AAEf,AAAKC,qBAAMC;AAEX,AAAA;;;;;;;;;;;;;;8BAAA,sCAAAC,pEAAME;AAAN,AAAA,IAAAD,WAAA,AAAA;AAAA,AAAA,QAAAA;KAAA;AAAA,OAAAC,0DAAA,CAAA,UAAA;;;KAAA;AAAA,OAAAA,0DAAA,CAAA,UAAA,MAAA,CAAA,UAAA;;;KAAA;AAAA,OAAAA,0DAAA,CAAA,UAAA,MAAA,CAAA,UAAA,MAAA,CAAA,UAAA;;;;AAAA,IAAAC,0BAAA;AAAA,AAAA,IAAAC,2BAAA,AAAA;AAAA,AAAA,IAAAC,yBAAA;;AAAA,AAAA,GAAA,CAAAA,yBAAAD;AAAA,AAAA,AAAAD,6BAAA,CAAA,UAAAE;;AAAA,eAAA,CAAAA,yBAAA;;;;AAAA;;;;AAAA,IAAAC,wBAAA,KAAAC,qBAAA,AAAAJ,8BAAA,KAAA,IAAA;AAAA,AAAA,OAAAD,iEAAA,CAAA,UAAA,MAAA,CAAA,UAAA,MAAA,CAAA,UAAA,MAAAI;;;;;AAAA,AAAA,4DAAA,5DAAMJ,uEAaFY;AAbJ,AAcG,kDAAA,3CAACZ,sCAAeY;;;AAdnB,AAAA,4DAAA,5DAAMZ,uEAeFY,KAAKC;AAfT,AAgBG,GAAA,EAAA,AAAAC,+BAAkBD;AAAlB;AAAA,AAA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ug]))
(def ^:const has-console (exists? js/console))
(def ^boolean tracking false)
(defonce warnings (atom nil))
(defonce track-console
(let [o #js{}]
(set! (.-warn o)
(fn [& args]
(swap! warnings update-in [:warn] conj (apply str args))))
(set! (.-error o)
(fn [& args]
(swap! warnings update-in [:error] conj (apply str args))))
o))
(defn track-warnings [f]
(set! tracking true)
(reset! warnings nil)
(f)
(let [warns @warnings]
(reset! warnings nil)
(set! tracking false)
warns))
+1
View File
@@ -0,0 +1 @@
{:rename-macros {}, :renames {}, :externs {console {}}, :use-macros {}, :excludes #{}, :name reagent.debug, :imports nil, :requires nil, :cljs.spec/speced-vars [], :uses nil, :defs {has-console {:name reagent.debug/has-console, :file "target/cljsbuild/public/js/out/reagent/debug.cljs", :line 4, :column 1, :end-line 4, :end-column 25, :const true, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/debug.cljs", :line 4, :column 14, :end-line 4, :end-column 25, :const true}, :tag boolean}, tracking {:name reagent.debug/tracking, :file "target/cljsbuild/public/js/out/reagent/debug.cljs", :line 6, :column 1, :end-line 6, :end-column 23, :tag boolean, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/debug.cljs", :line 6, :column 15, :end-line 6, :end-column 23, :tag boolean}}, warnings {:name reagent.debug/warnings, :file "target/cljsbuild/public/js/out/reagent/debug.cljs", :line 8, :column 1, :end-line 8, :end-column 18, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/debug.cljs", :line 8, :column 10, :end-line 8, :end-column 18}, :tag any}, track-console {:name reagent.debug/track-console, :file "target/cljsbuild/public/js/out/reagent/debug.cljs", :line 10, :column 1, :end-line 10, :end-column 23, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/debug.cljs", :line 10, :column 10, :end-line 10, :end-column 23}, :tag object}, track-warnings {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/debug.cljs", :line 20, :column 7, :end-line 20, :end-column 21, :arglists (quote ([f]))}, :name reagent.debug/track-warnings, :variadic false, :file "target/cljsbuild/public/js/out/reagent/debug.cljs", :end-column 21, :method-params ([f]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 20, :end-line 20, :max-fixed-arity 1, :fn-var true, :arglists (quote ([f]))}}, :cljs.spec/registry-ref [], :require-macros {reagent.debug reagent.debug}, :cljs.analyzer/constants {:seen #{:warn :error}, :order [:warn :error]}, :doc nil}
+79
View File
@@ -0,0 +1,79 @@
// Compiled by ClojureScript 1.9.946 {}
goog.provide('reagent.debug');
goog.require('cljs.core');
reagent.debug.has_console = typeof console !== 'undefined';
reagent.debug.tracking = false;
if(typeof reagent.debug.warnings !== 'undefined'){
} else {
reagent.debug.warnings = cljs.core.atom.call(null,null);
}
if(typeof reagent.debug.track_console !== 'undefined'){
} else {
reagent.debug.track_console = (function (){var o = ({});
o.warn = ((function (o){
return (function() {
var G__37347__delegate = function (args){
return cljs.core.swap_BANG_.call(null,reagent.debug.warnings,cljs.core.update_in,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"warn","warn",-436710552)], null),cljs.core.conj,cljs.core.apply.call(null,cljs.core.str,args));
};
var G__37347 = function (var_args){
var args = null;
if (arguments.length > 0) {
var G__37348__i = 0, G__37348__a = new Array(arguments.length - 0);
while (G__37348__i < G__37348__a.length) {G__37348__a[G__37348__i] = arguments[G__37348__i + 0]; ++G__37348__i;}
args = new cljs.core.IndexedSeq(G__37348__a,0,null);
}
return G__37347__delegate.call(this,args);};
G__37347.cljs$lang$maxFixedArity = 0;
G__37347.cljs$lang$applyTo = (function (arglist__37349){
var args = cljs.core.seq(arglist__37349);
return G__37347__delegate(args);
});
G__37347.cljs$core$IFn$_invoke$arity$variadic = G__37347__delegate;
return G__37347;
})()
;})(o))
;
o.error = ((function (o){
return (function() {
var G__37350__delegate = function (args){
return cljs.core.swap_BANG_.call(null,reagent.debug.warnings,cljs.core.update_in,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"error","error",-978969032)], null),cljs.core.conj,cljs.core.apply.call(null,cljs.core.str,args));
};
var G__37350 = function (var_args){
var args = null;
if (arguments.length > 0) {
var G__37351__i = 0, G__37351__a = new Array(arguments.length - 0);
while (G__37351__i < G__37351__a.length) {G__37351__a[G__37351__i] = arguments[G__37351__i + 0]; ++G__37351__i;}
args = new cljs.core.IndexedSeq(G__37351__a,0,null);
}
return G__37350__delegate.call(this,args);};
G__37350.cljs$lang$maxFixedArity = 0;
G__37350.cljs$lang$applyTo = (function (arglist__37352){
var args = cljs.core.seq(arglist__37352);
return G__37350__delegate(args);
});
G__37350.cljs$core$IFn$_invoke$arity$variadic = G__37350__delegate;
return G__37350;
})()
;})(o))
;
return o;
})();
}
reagent.debug.track_warnings = (function reagent$debug$track_warnings(f){
reagent.debug.tracking = true;
cljs.core.reset_BANG_.call(null,reagent.debug.warnings,null);
f.call(null);
var warns = cljs.core.deref.call(null,reagent.debug.warnings);
cljs.core.reset_BANG_.call(null,reagent.debug.warnings,null);
reagent.debug.tracking = false;
return warns;
});
//# sourceMappingURL=debug.js.map?rel=1517021940345
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"\/home\/didier\/clojupyter\/website\/target\/cljsbuild\/public\/js\/out\/reagent\/debug.js","sources":["debug.cljs?rel=1517021940345"],"lineCount":79,"mappings":";AAAA;;AAGA,AAAaA,4BAAY,OAASC;AAElC,yBAAA,zBAAcC;AAEd,GAAA,OAASC;AAAT;AAAA,AAAA,AAASA,yBAAS,yBAAA,zBAACC;;AAEnB,GAAA,OAASC;AAAT;AAAA,AAAA,AAASA,8BACP,qBAAA,JAAMC;AAAN,AACE,AAAM,AAAQA,SACR;;mCAAOC;AAAP,AACE,iFAAA,mFAAA,7JAACC,+BAAML,uBAASM,oKAAkBC,eAAK,AAACC,0BAAMC,cAAIL;;;IAD7CA;;;;EAAAA;;oCAAAA;;;IAAAA;0BAAAA;;;;;;;;AAEb,AAAM,AAASD,UACT;;mCAAOC;AAAP,AACE,iFAAA,mFAAA,7JAACC,+BAAML,uBAASM,sKAAmBC,eAAK,AAACC,0BAAMC,cAAIL;;;IAD9CA;;;;EAAAA;;oCAAAA;;;IAAAA;0BAAAA;;;;;;;;AAEbD;;;AAEJ,+BAAA,\/BAAMO,sEAAgBC;AAAtB,AACE,yBAAA,zBAAMZ;;AACN,uDAAA,vDAACa,gCAAOZ;;AACR,AAACW;;AACD,YAAA,AAAAE,RAAMC,kCAAOd;AAAb,AACE,uDAAA,vDAACY,gCAAOZ;;AACR,yBAAA,zBAAMD;;AACNe","names":["reagent.debug\/has-console","js\/console","reagent.debug\/tracking","reagent.debug\/warnings","cljs.core\/atom","reagent.debug\/track-console","o","args","cljs.core\/swap!","cljs.core\/update-in","cljs.core\/conj","cljs.core\/apply","cljs.core\/str","reagent.debug\/track-warnings","f","cljs.core\/reset!","cljs.core\/deref","warns"]}
+80
View File
@@ -0,0 +1,80 @@
(ns reagent.dom
(:require [cljsjs.react.dom]
[reagent.impl.util :as util]
[reagent.impl.template :as tmpl]
[reagent.impl.batching :as batch]
[reagent.ratom :as ratom]
[reagent.debug :refer-macros [dbg]]
[reagent.interop :refer-macros [$ $!]]))
(defonce ^:private imported nil)
(defn module []
(cond
(some? imported) imported
(exists? js/ReactDOM) (set! imported js/ReactDOM)
(exists? js/require) (or (set! imported (js/require "react-dom"))
(throw (js/Error. "require('react-dom') failed")))
:else
(throw (js/Error. "js/ReactDOM is missing"))))
(defonce ^:private roots (atom {}))
(defn- unmount-comp [container]
(swap! roots dissoc container)
($ (module) unmountComponentAtNode container))
(defn- render-comp [comp container callback]
(binding [util/*always-update* true]
(->> ($ (module) render (comp) container
(fn []
(binding [util/*always-update* false]
(swap! roots assoc container [comp container])
(batch/flush-after-render)
(if (some? callback)
(callback))))))))
(defn- re-render-component [comp container]
(render-comp comp container nil))
(defn render
"Render a Reagent component into the DOM. The first argument may be
either a vector (using Reagent's Hiccup syntax), or a React element. The second argument should be a DOM node.
Optionally takes a callback that is called when the component is in place.
Returns the mounted component instance."
([comp container]
(render comp container nil))
([comp container callback]
(ratom/flush!)
(let [f (fn []
(tmpl/as-element (if (fn? comp) (comp) comp)))]
(render-comp f container callback))))
(defn unmount-component-at-node [container]
(unmount-comp container))
(defn dom-node
"Returns the root DOM node of a mounted component."
[this]
($ (module) findDOMNode this))
(set! tmpl/find-dom-node dom-node)
(defn force-update-all
"Force re-rendering of all mounted Reagent components. This is
probably only useful in a development environment, when you want to
update components in response to some dynamic changes to code.
Note that force-update-all may not update root components. This
happens if a component 'foo' is mounted with `(render [foo])` (since
functions are passed by value, and not by reference, in
ClojureScript). To get around this you'll have to introduce a layer
of indirection, for example by using `(render [#'foo])` instead."
[]
(ratom/flush!)
(doseq [v (vals @roots)]
(apply re-render-component v))
"Updated")
+1
View File
@@ -0,0 +1 @@
{:rename-macros {}, :renames {}, :externs {ReactDOM {}, require {}, Error {}}, :use-macros {dbg reagent.debug, $! reagent.interop, $ reagent.interop}, :excludes #{}, :name reagent.dom, :imports nil, :requires {reagent.impl.util reagent.impl.util, reagent.interop reagent.interop, reagent.ratom reagent.ratom, reagent.impl.template reagent.impl.template, reagent.impl.batching reagent.impl.batching, cljsjs.react.dom cljsjs.react.dom, util reagent.impl.util, tmpl reagent.impl.template, ratom reagent.ratom, batch reagent.impl.batching, reagent.debug reagent.debug}, :cljs.spec/speced-vars [], :uses nil, :defs {re-render-component {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/dom.cljs", :line 38, :column 8, :end-line 38, :end-column 27, :private true, :arglists (quote ([comp container]))}, :private true, :name reagent.dom/re-render-component, :variadic false, :file "target/cljsbuild/public/js/out/reagent/dom.cljs", :end-column 27, :method-params ([comp container]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 38, :end-line 38, :max-fixed-arity 2, :fn-var true, :arglists (quote ([comp container]))}, force-update-all {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/dom.cljs", :line 66, :column 7, :end-line 66, :end-column 23, :arglists (quote ([])), :doc "Force re-rendering of all mounted Reagent components. This is\n probably only useful in a development environment, when you want to\n update components in response to some dynamic changes to code.\n\n Note that force-update-all may not update root components. This\n happens if a component 'foo' is mounted with `(render [foo])` (since\n functions are passed by value, and not by reference, in\n ClojureScript). To get around this you'll have to introduce a layer\n of indirection, for example by using `(render [#'foo])` instead."}, :name reagent.dom/force-update-all, :variadic false, :file "target/cljsbuild/public/js/out/reagent/dom.cljs", :end-column 23, :method-params ([]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 66, :end-line 66, :max-fixed-arity 0, :fn-var true, :arglists (quote ([])), :doc "Force re-rendering of all mounted Reagent components. This is\n probably only useful in a development environment, when you want to\n update components in response to some dynamic changes to code.\n\n Note that force-update-all may not update root components. This\n happens if a component 'foo' is mounted with `(render [foo])` (since\n functions are passed by value, and not by reference, in\n ClojureScript). To get around this you'll have to introduce a layer\n of indirection, for example by using `(render [#'foo])` instead."}, render-comp {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/dom.cljs", :line 28, :column 8, :end-line 28, :end-column 19, :private true, :arglists (quote ([comp container callback]))}, :private true, :name reagent.dom/render-comp, :variadic false, :file "target/cljsbuild/public/js/out/reagent/dom.cljs", :end-column 19, :method-params ([comp container callback]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 28, :end-line 28, :max-fixed-arity 3, :fn-var true, :arglists (quote ([comp container callback]))}, imported {:name reagent.dom/imported, :file "target/cljsbuild/public/js/out/reagent/dom.cljs", :line 10, :column 1, :end-line 10, :end-column 28, :private true, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/dom.cljs", :line 10, :column 20, :end-line 10, :end-column 28, :private true}, :tag clj-nil}, unmount-component-at-node {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/dom.cljs", :line 56, :column 7, :end-line 56, :end-column 32, :arglists (quote ([container]))}, :name reagent.dom/unmount-component-at-node, :variadic false, :file "target/cljsbuild/public/js/out/reagent/dom.cljs", :end-column 32, :method-params ([container]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 56, :end-line 56, :max-fixed-arity 1, :fn-var true, :arglists (quote ([container]))}, unmount-comp {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/dom.cljs", :line 24, :column 8, :end-line 24, :end-column 20, :private true, :arglists (quote ([container]))}, :private true, :name reagent.dom/unmount-comp, :variadic false, :file "target/cljsbuild/public/js/out/reagent/dom.cljs", :end-column 20, :method-params ([container]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 24, :end-line 24, :max-fixed-arity 1, :fn-var true, :arglists (quote ([container]))}, roots {:name reagent.dom/roots, :file "target/cljsbuild/public/js/out/reagent/dom.cljs", :line 22, :column 1, :end-line 22, :end-column 25, :private true, :meta {:file "/home/didier/clojupyter/websiteLine truncated
+191
View File
@@ -0,0 +1,191 @@
// Compiled by ClojureScript 1.9.946 {}
goog.provide('reagent.dom');
goog.require('cljs.core');
goog.require('cljsjs.react.dom');
goog.require('reagent.impl.util');
goog.require('reagent.impl.template');
goog.require('reagent.impl.batching');
goog.require('reagent.ratom');
goog.require('reagent.debug');
goog.require('reagent.interop');
if(typeof reagent.dom.imported !== 'undefined'){
} else {
reagent.dom.imported = null;
}
reagent.dom.module = (function reagent$dom$module(){
if(!((reagent.dom.imported == null))){
return reagent.dom.imported;
} else {
if(typeof ReactDOM !== 'undefined'){
return reagent.dom.imported = ReactDOM;
} else {
if(typeof require !== 'undefined'){
var or__35498__auto__ = reagent.dom.imported = require("react-dom");
if(cljs.core.truth_(or__35498__auto__)){
return or__35498__auto__;
} else {
throw (new Error("require('react-dom') failed"));
}
} else {
throw (new Error("js/ReactDOM is missing"));
}
}
}
});
if(typeof reagent.dom.roots !== 'undefined'){
} else {
reagent.dom.roots = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
}
reagent.dom.unmount_comp = (function reagent$dom$unmount_comp(container){
cljs.core.swap_BANG_.call(null,reagent.dom.roots,cljs.core.dissoc,container);
return (reagent.dom.module.call(null)["unmountComponentAtNode"])(container);
});
reagent.dom.render_comp = (function reagent$dom$render_comp(comp,container,callback){
var _STAR_always_update_STAR_37708 = reagent.impl.util._STAR_always_update_STAR_;
reagent.impl.util._STAR_always_update_STAR_ = true;
try{return (reagent.dom.module.call(null)["render"])(comp.call(null),container,((function (_STAR_always_update_STAR_37708){
return (function (){
var _STAR_always_update_STAR_37709 = reagent.impl.util._STAR_always_update_STAR_;
reagent.impl.util._STAR_always_update_STAR_ = false;
try{cljs.core.swap_BANG_.call(null,reagent.dom.roots,cljs.core.assoc,container,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [comp,container], null));
reagent.impl.batching.flush_after_render.call(null);
if(!((callback == null))){
return callback.call(null);
} else {
return null;
}
}finally {reagent.impl.util._STAR_always_update_STAR_ = _STAR_always_update_STAR_37709;
}});})(_STAR_always_update_STAR_37708))
);
}finally {reagent.impl.util._STAR_always_update_STAR_ = _STAR_always_update_STAR_37708;
}});
reagent.dom.re_render_component = (function reagent$dom$re_render_component(comp,container){
return reagent.dom.render_comp.call(null,comp,container,null);
});
/**
* Render a Reagent component into the DOM. The first argument may be
* either a vector (using Reagent's Hiccup syntax), or a React element. The second argument should be a DOM node.
*
* Optionally takes a callback that is called when the component is in place.
*
* Returns the mounted component instance.
*/
reagent.dom.render = (function reagent$dom$render(var_args){
var G__37711 = arguments.length;
switch (G__37711) {
case 2:
return reagent.dom.render.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
case 3:
return reagent.dom.render.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('')));
}
});
reagent.dom.render.cljs$core$IFn$_invoke$arity$2 = (function (comp,container){
return reagent.dom.render.call(null,comp,container,null);
});
reagent.dom.render.cljs$core$IFn$_invoke$arity$3 = (function (comp,container,callback){
reagent.ratom.flush_BANG_.call(null);
var f = (function (){
return reagent.impl.template.as_element.call(null,((cljs.core.fn_QMARK_.call(null,comp))?comp.call(null):comp));
});
return reagent.dom.render_comp.call(null,f,container,callback);
});
reagent.dom.render.cljs$lang$maxFixedArity = 3;
reagent.dom.unmount_component_at_node = (function reagent$dom$unmount_component_at_node(container){
return reagent.dom.unmount_comp.call(null,container);
});
/**
* Returns the root DOM node of a mounted component.
*/
reagent.dom.dom_node = (function reagent$dom$dom_node(this$){
return (reagent.dom.module.call(null)["findDOMNode"])(this$);
});
reagent.impl.template.find_dom_node = reagent.dom.dom_node;
/**
* Force re-rendering of all mounted Reagent components. This is
* probably only useful in a development environment, when you want to
* update components in response to some dynamic changes to code.
*
* Note that force-update-all may not update root components. This
* happens if a component 'foo' is mounted with `(render [foo])` (since
* functions are passed by value, and not by reference, in
* ClojureScript). To get around this you'll have to introduce a layer
* of indirection, for example by using `(render [#'foo])` instead.
*/
reagent.dom.force_update_all = (function reagent$dom$force_update_all(){
reagent.ratom.flush_BANG_.call(null);
var seq__37713_37717 = cljs.core.seq.call(null,cljs.core.vals.call(null,cljs.core.deref.call(null,reagent.dom.roots)));
var chunk__37714_37718 = null;
var count__37715_37719 = (0);
var i__37716_37720 = (0);
while(true){
if((i__37716_37720 < count__37715_37719)){
var v_37721 = cljs.core._nth.call(null,chunk__37714_37718,i__37716_37720);
cljs.core.apply.call(null,reagent.dom.re_render_component,v_37721);
var G__37722 = seq__37713_37717;
var G__37723 = chunk__37714_37718;
var G__37724 = count__37715_37719;
var G__37725 = (i__37716_37720 + (1));
seq__37713_37717 = G__37722;
chunk__37714_37718 = G__37723;
count__37715_37719 = G__37724;
i__37716_37720 = G__37725;
continue;
} else {
var temp__5457__auto___37726 = cljs.core.seq.call(null,seq__37713_37717);
if(temp__5457__auto___37726){
var seq__37713_37727__$1 = temp__5457__auto___37726;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__37713_37727__$1)){
var c__36429__auto___37728 = cljs.core.chunk_first.call(null,seq__37713_37727__$1);
var G__37729 = cljs.core.chunk_rest.call(null,seq__37713_37727__$1);
var G__37730 = c__36429__auto___37728;
var G__37731 = cljs.core.count.call(null,c__36429__auto___37728);
var G__37732 = (0);
seq__37713_37717 = G__37729;
chunk__37714_37718 = G__37730;
count__37715_37719 = G__37731;
i__37716_37720 = G__37732;
continue;
} else {
var v_37733 = cljs.core.first.call(null,seq__37713_37727__$1);
cljs.core.apply.call(null,reagent.dom.re_render_component,v_37733);
var G__37734 = cljs.core.next.call(null,seq__37713_37727__$1);
var G__37735 = null;
var G__37736 = (0);
var G__37737 = (0);
seq__37713_37717 = G__37734;
chunk__37714_37718 = G__37735;
count__37715_37719 = G__37736;
i__37716_37720 = G__37737;
continue;
}
} else {
}
}
break;
}
return "Updated";
});
//# sourceMappingURL=dom.js.map?rel=1517021941259
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"\/home\/didier\/clojupyter\/website\/target\/cljsbuild\/public\/js\/out\/reagent\/dom.js","sources":["dom.cljs?rel=1517021941260"],"lineCount":191,"mappings":";AAAA;;;;;;;;;AASA,GAAA,OAAmBA;AAAnB;AAAA,AAAA,uBAAA,vBAAmBA;;AAEnB,qBAAA,rBAAMC;AAAN,AACE,GACE,EAAA,yBAAA,xBAAOD;AAAUA;;AADnB,GAEE,OAASE;AAAa,OAAMF,uBAASE;;AAFvC,GAGE,OAASC;AAAY,IAAAC,oBAAI,AAAMJ,uBAAS,QAAA,RAACG;AAApB,AAAA,oBAAAC;AAAAA;;AACI,MAAO,KAAAC,MAAA;;;AAJlC,AAME,MAAO,KAAAA,MAAA;;;;;;AAGX,GAAA,OAAmBC;AAAnB;AAAA,AAAA,AAAmBA,oBAAM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B,AAAA,6CAAA,7CAAMS;;AAAN,AAeA,wCAAA,xCAAMK,wFAA2BnB;AAAjC,AACE,OAACD,mCAAaC;;AAEhB;;;uBAAA,vBAAMoB,sDAEHC;AAFH,AAGE,OAAA,+BAAA,9BAAG,AAAC7B,8CAAoB6B;;AAE1B,AAAMC,sCAAmBF;AAEzB;;;;;;;;;;;+BAAA,\/BAAMG;AAAN,AAWE,AAACR;;AACD,IAAAS,mBAAA,AAAAC,wBAAU,yBAAA,AAAAc,zBAACC,mDAAM3C;IAAjB6B,qBAAA;IAAAC,qBAAA;IAAAC,iBAAA;;AAAA,AAAA,GAAA,AAAA,CAAAA,iBAAAD;AAAA,cAAA,AAAAE,yBAAAH,mBAAAE,tDAAQU;AAAR,AAAA,AACE,AAACG,0BAAM9B,gCAAoB2B;;AAD7B,eAAAd;eAAAE;eAAAC;eAAA,CAAAC,iBAAA;;;;;;;AAAA,IAAAE,2BAAA,AAAAL,wBAAAD;AAAA,AAAA,GAAAM;AAAA,AAAA,IAAAN,uBAAAM;AAAA,AAAA,GAAA,AAAAC,uCAAAP;AAAA,IAAAQ,yBAAA,AAAAC,gCAAAT;AAAA,AAAA,eAAA,AAAAU,+BAAAV;eAAAQ;eAAA,AAAAG,0BAAAH;eAAA;;;;;;;AAAA,cAAA,AAAAI,0BAAAZ,pCAAQc;AAAR,AAAA,AACE,AAACG,0BAAM9B,gCAAoB2B;;AAD7B,eAAA,AAAAD,yBAAAb;eAAA;eAAA;eAAA;;;;;;;;AAAA;;;;;AAZF","names":["reagent.dom\/imported","reagent.dom\/module","js\/ReactDOM","js\/require","or__35498__auto__","js\/Error","reagent.dom\/roots","cljs.core\/atom","reagent.dom\/unmount-comp","container","cljs.core\/swap!","cljs.core\/dissoc","reagent.dom\/render-comp","comp","callback","*always-update*37708","reagent.impl.util\/*always-update*","*always-update*37709","cljs.core\/assoc","reagent.impl.batching\/flush-after-render","reagent.dom\/re-render-component","var_args","G__37711","reagent.dom\/render","reagent.ratom\/flush!","f","reagent.impl.template\/as-element","cljs.core\/fn?","reagent.dom\/unmount-component-at-node","reagent.dom\/dom-node","this","reagent.impl.template\/find-dom-node","reagent.dom\/force-update-all","seq__37713","cljs.core\/seq","chunk__37714","count__37715","i__37716","cljs.core\/-nth","temp__5457__auto__","cljs.core\/chunked-seq?","c__36429__auto__","cljs.core\/chunk-first","cljs.core\/chunk-rest","cljs.core\/count","cljs.core\/first","cljs.core\/next","v","cljs.core\/deref","cljs.core\/vals","cljs.core\/apply"]}
+113
View File
@@ -0,0 +1,113 @@
(ns reagent.impl.batching
(:refer-clojure :exclude [flush])
(:require [reagent.debug :refer-macros [dbg assert-some]]
[reagent.interop :refer-macros [$ $!]]
[reagent.impl.util :refer [is-client]]
[clojure.string :as string]))
;;; Update batching
(defonce mount-count 0)
(defn next-mount-count []
(set! mount-count (inc mount-count)))
(defn fake-raf [f]
(js/setTimeout f 16))
(def next-tick
(if-not is-client
fake-raf
(let [w js/window]
(or ($ w :requestAnimationFrame)
($ w :webkitRequestAnimationFrame)
($ w :mozRequestAnimationFrame)
($ w :msRequestAnimationFrame)
fake-raf))))
(defn compare-mount-order [c1 c2]
(- ($ c1 :cljsMountOrder)
($ c2 :cljsMountOrder)))
(defn run-queue [a]
;; sort components by mount order, to make sure parents
;; are rendered before children
(.sort a compare-mount-order)
(dotimes [i (alength a)]
(let [c (aget a i)]
(when (true? ($ c :cljsIsDirty))
($ c forceUpdate)))))
;; Set from ratom.cljs
(defonce ratom-flush (fn []))
(deftype RenderQueue [^:mutable ^boolean scheduled?]
Object
(enqueue [this k f]
(assert-some f "Enqueued function")
(when (nil? (aget this k))
(aset this k (array)))
(.push (aget this k) f)
(.schedule this))
(run-funs [this k]
(when-some [fs (aget this k)]
(aset this k nil)
(dotimes [i (alength fs)]
((aget fs i)))))
(schedule [this]
(when-not scheduled?
(set! scheduled? true)
(next-tick #(.run-queues this))))
(queue-render [this c]
(.enqueue this "componentQueue" c))
(add-before-flush [this f]
(.enqueue this "beforeFlush" f))
(add-after-render [this f]
(.enqueue this "afterRender" f))
(run-queues [this]
(set! scheduled? false)
(.flush-queues this))
(flush-after-render [this]
(.run-funs this "afterRender"))
(flush-queues [this]
(.run-funs this "beforeFlush")
(ratom-flush)
(when-some [cs (aget this "componentQueue")]
(aset this "componentQueue" nil)
(run-queue cs))
(.flush-after-render this)))
(defonce render-queue (->RenderQueue false))
(defn flush []
(.flush-queues render-queue))
(defn flush-after-render []
(.flush-after-render render-queue))
(defn queue-render [c]
(when-not ($ c :cljsIsDirty)
($! c :cljsIsDirty true)
(.queue-render render-queue c)))
(defn mark-rendered [c]
($! c :cljsIsDirty false))
(defn do-before-flush [f]
(.add-before-flush render-queue f))
(defn do-after-render [f]
(.add-after-render render-queue f))
(defn schedule []
(when (false? (.-scheduled? render-queue))
(.schedule render-queue)))
@@ -0,0 +1 @@
{:rename-macros {}, :renames {}, :externs {setTimeout {}, window {}, Error {}}, :use-macros {assert-some reagent.debug, dbg reagent.debug, $! reagent.interop, $ reagent.interop}, :excludes #{flush}, :name reagent.impl.batching, :imports nil, :requires {reagent.debug reagent.debug, reagent.interop reagent.interop, reagent.impl.util reagent.impl.util, string clojure.string, clojure.string clojure.string}, :cljs.spec/speced-vars [], :uses {is-client reagent.impl.util}, :defs {fake-raf {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/batching.cljs", :line 15, :column 7, :end-line 15, :end-column 15, :arglists (quote ([f]))}, :name reagent.impl.batching/fake-raf, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/batching.cljs", :end-column 15, :method-params ([f]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 15, :end-line 15, :max-fixed-arity 1, :fn-var true, :arglists (quote ([f]))}, do-before-flush {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/batching.cljs", :line 105, :column 7, :end-line 105, :end-column 22, :arglists (quote ([f]))}, :name reagent.impl.batching/do-before-flush, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/batching.cljs", :end-column 22, :method-params ([f]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 105, :end-line 105, :max-fixed-arity 1, :fn-var true, :arglists (quote ([f]))}, flush-after-render {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/batching.cljs", :line 94, :column 7, :end-line 94, :end-column 25, :arglists (quote ([]))}, :name reagent.impl.batching/flush-after-render, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/batching.cljs", :end-column 25, :method-params ([]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 94, :end-line 94, :max-fixed-arity 0, :fn-var true, :arglists (quote ([]))}, queue-render {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/batching.cljs", :line 97, :column 7, :end-line 97, :end-column 19, :arglists (quote ([c]))}, :name reagent.impl.batching/queue-render, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/batching.cljs", :end-column 19, :method-params ([c]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 97, :end-line 97, :max-fixed-arity 1, :fn-var true, :arglists (quote ([c]))}, next-tick {:name reagent.impl.batching/next-tick, :file "target/cljsbuild/public/js/out/reagent/impl/batching.cljs", :line 18, :column 1, :end-line 18, :end-column 15, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/batching.cljs", :line 18, :column 6, :end-line 18, :end-column 15}, :tag #{nil any}}, flush {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/batching.cljs", :line 91, :column 7, :end-line 91, :end-column 12, :arglists (quote ([]))}, :name reagent.impl.batching/flush, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/batching.cljs", :end-column 12, :method-params ([]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 91, :end-line 91, :max-fixed-arity 0, :fn-var true, :arglists (quote ([]))}, mark-rendered {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/batching.cljs", :line 102, :column 7, :end-line 102, :end-column 20, :arglists (quote ([c]))}, :name reagent.impl.batching/mark-rendered, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/batching.cljs", :end-column 20, :method-params ([c]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 102, :end-line 102, :max-fixed-arity 1, :fn-var true, :arglists (quote ([c]))}, schedule {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/batching.cljs", :line 111, :column 7, :end-line 111, :end-column 15, :arglists (quote ([]))}, :name reagent.impl.batching/schedule, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/batching.cljs", :end-column 15, :method-params ([]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 111, :end-line 111, :max-fixed-arity 0, :fn-var true, :arglists (quote ([]))}, render-queue {:name reagent.impl.batching/render-queue, :file "target/cljsbuild/public/js/out/reagent/impl/batching.cljs", :line 89, :column 1, :end-line 89, :end-column 22, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/batching.cljs", :line 89, :column 10, :end-line 89, :end-column 22}, :tag any}, RenderQueue {:num-fields 1, :protocols #{reagent.impl.batching/Object}, :name reagent.impl.batching/RenderQueue, :file "target/cljsbuild/public/js/out/reagent/impl/batchingLine truncated
+244
View File
@@ -0,0 +1,244 @@
// Compiled by ClojureScript 1.9.946 {}
goog.provide('reagent.impl.batching');
goog.require('cljs.core');
goog.require('reagent.debug');
goog.require('reagent.interop');
goog.require('reagent.impl.util');
goog.require('clojure.string');
if(typeof reagent.impl.batching.mount_count !== 'undefined'){
} else {
reagent.impl.batching.mount_count = (0);
}
reagent.impl.batching.next_mount_count = (function reagent$impl$batching$next_mount_count(){
return reagent.impl.batching.mount_count = (reagent.impl.batching.mount_count + (1));
});
reagent.impl.batching.fake_raf = (function reagent$impl$batching$fake_raf(f){
return setTimeout(f,(16));
});
reagent.impl.batching.next_tick = ((!(reagent.impl.util.is_client))?reagent.impl.batching.fake_raf:(function (){var w = window;
var or__35498__auto__ = (w["requestAnimationFrame"]);
if(cljs.core.truth_(or__35498__auto__)){
return or__35498__auto__;
} else {
var or__35498__auto____$1 = (w["webkitRequestAnimationFrame"]);
if(cljs.core.truth_(or__35498__auto____$1)){
return or__35498__auto____$1;
} else {
var or__35498__auto____$2 = (w["mozRequestAnimationFrame"]);
if(cljs.core.truth_(or__35498__auto____$2)){
return or__35498__auto____$2;
} else {
var or__35498__auto____$3 = (w["msRequestAnimationFrame"]);
if(cljs.core.truth_(or__35498__auto____$3)){
return or__35498__auto____$3;
} else {
return reagent.impl.batching.fake_raf;
}
}
}
}
})());
reagent.impl.batching.compare_mount_order = (function reagent$impl$batching$compare_mount_order(c1,c2){
return ((c1["cljsMountOrder"]) - (c2["cljsMountOrder"]));
});
reagent.impl.batching.run_queue = (function reagent$impl$batching$run_queue(a){
a.sort(reagent.impl.batching.compare_mount_order);
var n__36543__auto__ = a.length;
var i = (0);
while(true){
if((i < n__36543__auto__)){
var c_37398 = (a[i]);
if((c_37398["cljsIsDirty"]) === true){
(c_37398["forceUpdate"])();
} else {
}
var G__37399 = (i + (1));
i = G__37399;
continue;
} else {
return null;
}
break;
}
});
if(typeof reagent.impl.batching.ratom_flush !== 'undefined'){
} else {
reagent.impl.batching.ratom_flush = (function reagent$impl$batching$ratom_flush(){
return null;
});
}
/**
* @constructor
* @implements {reagent.impl.batching.Object}
*/
reagent.impl.batching.RenderQueue = (function (scheduled_QMARK_){
this.scheduled_QMARK_ = scheduled_QMARK_;
});
reagent.impl.batching.RenderQueue.prototype.run_funs = (function (k){
var self__ = this;
var this$ = this;
var temp__5461__auto__ = (this$[k]);
if((temp__5461__auto__ == null)){
return null;
} else {
var fs = temp__5461__auto__;
(this$[k] = null);
var n__36543__auto__ = fs.length;
var i = (0);
while(true){
if((i < n__36543__auto__)){
(fs[i]).call(null);
var G__37400 = (i + (1));
i = G__37400;
continue;
} else {
return null;
}
break;
}
}
});
reagent.impl.batching.RenderQueue.prototype.flush_after_render = (function (){
var self__ = this;
var this$ = this;
return this$.run_funs("afterRender");
});
reagent.impl.batching.RenderQueue.prototype.queue_render = (function (c){
var self__ = this;
var this$ = this;
return this$.enqueue("componentQueue",c);
});
reagent.impl.batching.RenderQueue.prototype.schedule = (function (){
var self__ = this;
var this$ = this;
if(self__.scheduled_QMARK_){
return null;
} else {
self__.scheduled_QMARK_ = true;
return reagent.impl.batching.next_tick.call(null,((function (this$){
return (function (){
return this$.run_queues();
});})(this$))
);
}
});
reagent.impl.batching.RenderQueue.prototype.flush_queues = (function (){
var self__ = this;
var this$ = this;
this$.run_funs("beforeFlush");
reagent.impl.batching.ratom_flush.call(null);
var temp__5461__auto___37401 = (this$["componentQueue"]);
if((temp__5461__auto___37401 == null)){
} else {
var cs_37402 = temp__5461__auto___37401;
(this$["componentQueue"] = null);
reagent.impl.batching.run_queue.call(null,cs_37402);
}
return this$.flush_after_render();
});
reagent.impl.batching.RenderQueue.prototype.run_queues = (function (){
var self__ = this;
var this$ = this;
self__.scheduled_QMARK_ = false;
return this$.flush_queues();
});
reagent.impl.batching.RenderQueue.prototype.enqueue = (function (k,f){
var self__ = this;
var this$ = this;
if(cljs.core.truth_(f)){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Enqueued function"," must not be nil"].join('')),"\n","f"].join('')));
}
if(((this$[k]) == null)){
(this$[k] = []);
} else {
}
(this$[k]).push(f);
return this$.schedule();
});
reagent.impl.batching.RenderQueue.prototype.add_before_flush = (function (f){
var self__ = this;
var this$ = this;
return this$.enqueue("beforeFlush",f);
});
reagent.impl.batching.RenderQueue.prototype.add_after_render = (function (f){
var self__ = this;
var this$ = this;
return this$.enqueue("afterRender",f);
});
reagent.impl.batching.RenderQueue.getBasis = (function (){
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(new cljs.core.Symbol(null,"scheduled?","scheduled?",579986609,null),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"tag","tag",-1290361223),new cljs.core.Symbol(null,"boolean","boolean",-278886877,null),new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null))], null);
});
reagent.impl.batching.RenderQueue.cljs$lang$type = true;
reagent.impl.batching.RenderQueue.cljs$lang$ctorStr = "reagent.impl.batching/RenderQueue";
reagent.impl.batching.RenderQueue.cljs$lang$ctorPrWriter = (function (this__36169__auto__,writer__36170__auto__,opt__36171__auto__){
return cljs.core._write.call(null,writer__36170__auto__,"reagent.impl.batching/RenderQueue");
});
reagent.impl.batching.__GT_RenderQueue = (function reagent$impl$batching$__GT_RenderQueue(scheduled_QMARK_){
return (new reagent.impl.batching.RenderQueue(scheduled_QMARK_));
});
if(typeof reagent.impl.batching.render_queue !== 'undefined'){
} else {
reagent.impl.batching.render_queue = reagent.impl.batching.__GT_RenderQueue.call(null,false);
}
reagent.impl.batching.flush = (function reagent$impl$batching$flush(){
return reagent.impl.batching.render_queue.flush_queues();
});
reagent.impl.batching.flush_after_render = (function reagent$impl$batching$flush_after_render(){
return reagent.impl.batching.render_queue.flush_after_render();
});
reagent.impl.batching.queue_render = (function reagent$impl$batching$queue_render(c){
if(cljs.core.truth_((c["cljsIsDirty"]))){
return null;
} else {
(c["cljsIsDirty"] = true);
return reagent.impl.batching.render_queue.queue_render(c);
}
});
reagent.impl.batching.mark_rendered = (function reagent$impl$batching$mark_rendered(c){
return (c["cljsIsDirty"] = false);
});
reagent.impl.batching.do_before_flush = (function reagent$impl$batching$do_before_flush(f){
return reagent.impl.batching.render_queue.add_before_flush(f);
});
reagent.impl.batching.do_after_render = (function reagent$impl$batching$do_after_render(f){
return reagent.impl.batching.render_queue.add_after_render(f);
});
reagent.impl.batching.schedule = (function reagent$impl$batching$schedule(){
if(reagent.impl.batching.render_queue.scheduled_QMARK_ === false){
return reagent.impl.batching.render_queue.schedule();
} else {
return null;
}
});
//# sourceMappingURL=batching.js.map?rel=1517021940666
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"\/home\/didier\/clojupyter\/website\/target\/cljsbuild\/public\/js\/out\/reagent\/impl\/batching.js","sources":["batching.cljs?rel=1517021940667"],"lineCount":244,"mappings":";AAAA;;;;;;AASA,GAAA,OAASA;AAAT;AAAA,AAAA,oCAAA,pCAASA;;AAET,yCAAA,zCAAMC;AAAN,AACE,OAAMD,oCAAY,qCAAA,pCAAKA;;AAEzB,iCAAA,jCAAME,0EAAUC;AAAhB,AACE,oBAAA,bAACC,WAAcD;;AAEjB,AAAKE,kCACH,EAAA,EAAQC,8BACNJ,+BACA,iBAAMK,IAAEC;AAAR,AACE,IAAAC,oBAAI,GAAA,FAAGF;AAAP,AAAA,oBAAAE;AAAAA;;AAAA,IAAAA,wBACI,GAAA,FAAGF;AADP,AAAA,oBAAAE;AAAAA;;AAAA,IAAAA,wBAEI,GAAA,FAAGF;AAFP,AAAA,oBAAAE;AAAAA;;AAAA,IAAAA,wBAGI,GAAA,FAAGF;AAHP,AAAA,oBAAAE;AAAAA;;AAIIP;;;;;;AAEV,4CAAA,5CAAMQ,gGAAqBC,GAAGC;AAA9B,AACE,QAAG,IAAA,HAAGD,wBACH,IAAA,HAAGC;;AAER,kCAAA,lCAAMC,4EAAWC;AAAjB,AAGE,AAAOA,OAAEJ;;AACT,IAAAK,mBAAY,AAASD;AAArB,AAAA,QAAA,JAAUE;;AAAV,AAAA,GAAA,KAAAD,JAAUC;AAAV,AACE,IAAMC,UAAE,CAAMH,EAAEE;AAAhB,AACE,GAAM,AAAO,SAAA,RAAGC;AAAhB,AACE,AAAA,SAAA,RAAGA;;AADL;;AAFJ,eAAA,KAAA,JAAUD;;;;AAAV;;;;;AAOF,GAAA,OAASE;AAAT;AAAA,AAAA,AAASA,oCAAY;AAAA,AAAA;;;AAErB,AAAA;;;;;;;;AAAA,AAAA,AAAA,AAAA,uDAAA,vDAASK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,AAAQ,AAAcP;AAA5B,AACE,OAAWA;;AADb","names":["reagent.impl.batching\/mount-count","reagent.impl.batching\/next-mount-count","reagent.impl.batching\/fake-raf","f","js\/setTimeout","reagent.impl.batching\/next-tick","reagent.impl.util\/is-client","w","js\/window","or__35498__auto__","reagent.impl.batching\/compare-mount-order","c1","c2","reagent.impl.batching\/run-queue","a","n__36543__auto__","i","c","reagent.impl.batching\/ratom-flush","this__36169__auto__","writer__36170__auto__","opt__36171__auto__","cljs.core\/-write","reagent.impl.batching\/RenderQueue","reagent.impl.batching\/->RenderQueue","scheduled?","this","k","js\/Error","temp__5461__auto__","fs","cs","reagent.impl.batching\/render-queue","reagent.impl.batching\/flush","reagent.impl.batching\/flush-after-render","reagent.impl.batching\/queue-render","reagent.impl.batching\/mark-rendered","reagent.impl.batching\/do-before-flush","reagent.impl.batching\/do-after-render","reagent.impl.batching\/schedule"]}
+316
View File
@@ -0,0 +1,316 @@
(ns reagent.impl.component
(:require [reagent.impl.util :as util]
[reagent.impl.batching :as batch]
[reagent.ratom :as ratom]
[reagent.interop :refer-macros [$ $!]]
[reagent.debug :refer-macros [dbg prn dev? warn error warn-unless
assert-callable]]))
(declare ^:dynamic *current-component*)
;;; Argv access
(defn shallow-obj-to-map [o]
(let [ks (js-keys o)
len (alength ks)]
(loop [m {} i 0]
(if (< i len)
(let [k (aget ks i)]
(recur (assoc m (keyword k) (aget o k)) (inc i)))
m))))
(defn extract-props [v]
(let [p (nth v 1 nil)]
(if (map? p) p)))
(defn extract-children [v]
(let [p (nth v 1 nil)
first-child (if (or (nil? p) (map? p)) 2 1)]
(if (> (count v) first-child)
(subvec v first-child))))
(defn props-argv [c p]
(if-some [a ($ p :argv)]
a
[(.-constructor c) (shallow-obj-to-map p)]))
(defn get-argv [c]
(props-argv c ($ c :props)))
(defn get-props [c]
(let [p ($ c :props)]
(if-some [v ($ p :argv)]
(extract-props v)
(shallow-obj-to-map p))))
(defn get-children [c]
(let [p ($ c :props)]
(if-some [v ($ p :argv)]
(extract-children v)
(->> ($ p :children)
($ util/react Children.toArray)
(into [])))))
(defn ^boolean reagent-class? [c]
(and (fn? c)
(some? (some-> c .-prototype ($ :reagentRender)))))
(defn ^boolean react-class? [c]
(and (fn? c)
(some? (some-> c .-prototype ($ :render)))))
(defn ^boolean reagent-component? [c]
(some? ($ c :reagentRender)))
(defn cached-react-class [c]
($ c :cljsReactClass))
(defn cache-react-class [c constructor]
($! c :cljsReactClass constructor))
;;; State
(defn state-atom [this]
(let [sa ($ this :cljsState)]
(if-not (nil? sa)
sa
($! this :cljsState (ratom/atom nil)))))
;; avoid circular dependency: this gets set from template.cljs
(defonce as-element nil)
;;; Rendering
(defn wrap-render [c]
(let [f ($ c :reagentRender)
_ (assert-callable f)
res (if (true? ($ c :cljsLegacyRender))
(.call f c c)
(let [v (get-argv c)
n (count v)]
(case n
1 (.call f c)
2 (.call f c (nth v 1))
3 (.call f c (nth v 1) (nth v 2))
4 (.call f c (nth v 1) (nth v 2) (nth v 3))
5 (.call f c (nth v 1) (nth v 2) (nth v 3) (nth v 4))
(.apply f c (.slice (into-array v) 1)))))]
(cond
(vector? res) (as-element res)
(ifn? res) (let [f (if (reagent-class? res)
(fn [& args]
(as-element (apply vector res args)))
res)]
($! c :reagentRender f)
(recur c))
:else res)))
(declare comp-name)
(defn do-render [c]
(binding [*current-component* c]
(if (dev?)
;; Log errors, without using try/catch (and mess up call stack)
(let [ok (array false)]
(try
(let [res (wrap-render c)]
(aset ok 0 true)
res)
(finally
(when-not (aget ok 0)
(error (str "Error rendering component"
(comp-name)))))))
(wrap-render c))))
;;; Method wrapping
(def rat-opts {:no-cache true})
(def static-fns
{:render
(fn render []
(this-as c (if util/*non-reactive*
(do-render c)
(let [rat ($ c :cljsRatom)]
(batch/mark-rendered c)
(if (nil? rat)
(ratom/run-in-reaction #(do-render c) c "cljsRatom"
batch/queue-render rat-opts)
(._run rat false))))))})
(defn custom-wrapper [key f]
(case key
:getDefaultProps
(throw (js/Error. "getDefaultProps not supported"))
:getInitialState
(fn getInitialState []
(this-as c (reset! (state-atom c) (.call f c c))))
:componentWillReceiveProps
(fn componentWillReceiveProps [nextprops]
(this-as c (.call f c c (props-argv c nextprops))))
:shouldComponentUpdate
(fn shouldComponentUpdate [nextprops nextstate]
(or util/*always-update*
(this-as c
;; Don't care about nextstate here, we use forceUpdate
;; when only when state has changed anyway.
(let [old-argv ($ c :props.argv)
new-argv ($ nextprops :argv)
noargv (or (nil? old-argv) (nil? new-argv))]
(cond
(nil? f) (or noargv (not= old-argv new-argv))
noargv (.call f c c (get-argv c) (props-argv c nextprops))
:else (.call f c c old-argv new-argv))))))
:componentWillUpdate
(fn componentWillUpdate [nextprops]
(this-as c (.call f c c (props-argv c nextprops))))
:componentDidUpdate
(fn componentDidUpdate [oldprops]
(this-as c (.call f c c (props-argv c oldprops))))
:componentWillMount
(fn componentWillMount []
(this-as c
($! c :cljsMountOrder (batch/next-mount-count))
(when-not (nil? f)
(.call f c c))))
:componentDidMount
(fn componentDidMount []
(this-as c (.call f c c)))
:componentWillUnmount
(fn componentWillUnmount []
(this-as c
(some-> ($ c :cljsRatom)
ratom/dispose!)
(batch/mark-rendered c)
(when-not (nil? f)
(.call f c c))))
nil))
(defn get-wrapper [key f name]
(let [wrap (custom-wrapper key f)]
(when (and wrap f)
(assert-callable f))
(or wrap f)))
(def obligatory {:shouldComponentUpdate nil
:componentWillMount nil
:componentWillUnmount nil})
(def dash-to-camel (util/memoize-1 util/dash-to-camel))
(defn camelify-map-keys [fun-map]
(reduce-kv (fn [m k v]
(assoc m (-> k dash-to-camel keyword) v))
{} fun-map))
(defn add-obligatory [fun-map]
(merge obligatory fun-map))
(defn wrap-funs [fmap]
(when (dev?)
(let [renders (select-keys fmap [:render :reagentRender :componentFunction])
render-fun (-> renders vals first)]
(assert (pos? (count renders)) "Missing reagent-render")
(assert (== 1 (count renders)) "Too many render functions supplied")
(assert-callable render-fun)))
(let [render-fun (or (:reagentRender fmap)
(:componentFunction fmap))
legacy-render (nil? render-fun)
render-fun (or render-fun
(:render fmap))
name (str (or (:displayName fmap)
(util/fun-name render-fun)))
name (case name
"" (str (gensym "reagent"))
name)
fmap (reduce-kv (fn [m k v]
(assoc m k (get-wrapper k v name)))
{} fmap)]
(assoc fmap
:displayName name
:autobind false
:cljsLegacyRender legacy-render
:reagentRender render-fun
:render (:render static-fns))))
(defn map-to-js [m]
(reduce-kv (fn [o k v]
(doto o
(aset (name k) v)))
#js{} m))
(defn cljsify [body]
(-> body
camelify-map-keys
add-obligatory
wrap-funs
map-to-js))
(defn create-class [body]
{:pre [(map? body)]}
(->> body
cljsify
util/create-class))
(defn component-path [c]
(let [elem (some-> (or (some-> c ($ :_reactInternalInstance))
c)
($ :_currentElement))
name (some-> elem
($ :type)
($ :displayName))
path (some-> elem
($ :_owner)
component-path
(str " > "))
res (str path name)]
(when-not (empty? res) res)))
(defn comp-name []
(if (dev?)
(let [c *current-component*
n (or (component-path c)
(some-> c .-constructor util/fun-name))]
(if-not (empty? n)
(str " (in " n ")")
""))
""))
(defn fn-to-class [f]
(assert-callable f)
(warn-unless (not (and (react-class? f)
(not (reagent-class? f))))
"Using native React classes directly in Hiccup forms "
"is not supported. Use create-element or "
"adapt-react-class instead: " (let [n (util/fun-name f)]
(if (empty? n) f n))
(comp-name))
(if (reagent-class? f)
(cache-react-class f f)
(let [spec (meta f)
withrender (assoc spec :reagent-render f)
res (create-class withrender)]
(cache-react-class f res))))
(defn as-class [tag]
(if-some [cached-class (cached-react-class tag)]
cached-class
(fn-to-class tag)))
(defn reactify-component [comp]
(if (react-class? comp)
comp
(as-class comp)))
@@ -0,0 +1 @@
{:rename-macros {}, :renames {}, :externs {Error {}, console {}}, :use-macros {warn-unless reagent.debug, dbg reagent.debug, $! reagent.interop, prn reagent.debug, warn reagent.debug, dev? reagent.debug, $ reagent.interop, assert-callable reagent.debug, error reagent.debug}, :excludes #{}, :name reagent.impl.component, :imports nil, :requires {util reagent.impl.util, reagent.impl.util reagent.impl.util, batch reagent.impl.batching, reagent.impl.batching reagent.impl.batching, ratom reagent.ratom, reagent.ratom reagent.ratom, reagent.interop reagent.interop, reagent.debug reagent.debug}, :cljs.spec/speced-vars [], :uses nil, :defs {get-props {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/component.cljs", :line 41, :column 7, :end-line 41, :end-column 16, :arglists (quote ([c]))}, :name reagent.impl.component/get-props, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/component.cljs", :end-column 16, :method-params ([c]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 41, :end-line 41, :max-fixed-arity 1, :fn-var true, :arglists (quote ([c]))}, get-wrapper {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/component.cljs", :line 202, :column 7, :end-line 202, :end-column 18, :arglists (quote ([key f name]))}, :name reagent.impl.component/get-wrapper, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/component.cljs", :end-column 18, :method-params ([key f name]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 202, :end-line 202, :max-fixed-arity 3, :fn-var true, :arglists (quote ([key f name]))}, get-argv {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/component.cljs", :line 38, :column 7, :end-line 38, :end-column 15, :arglists (quote ([c]))}, :name reagent.impl.component/get-argv, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/component.cljs", :end-column 15, :method-params ([c]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 38, :end-line 38, :max-fixed-arity 1, :fn-var true, :arglists (quote ([c]))}, wrap-render {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/component.cljs", :line 87, :column 7, :end-line 87, :end-column 18, :arglists (quote ([c]))}, :name reagent.impl.component/wrap-render, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/component.cljs", :end-column 18, :method-params ([c]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 87, :end-line 87, :max-fixed-arity 1, :fn-var true, :arglists (quote ([c]))}, rat-opts {:name reagent.impl.component/rat-opts, :file "target/cljsbuild/public/js/out/reagent/impl/component.cljs", :line 131, :column 1, :end-line 131, :end-column 14, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/component.cljs", :line 131, :column 6, :end-line 131, :end-column 14}, :tag cljs.core/IMap}, obligatory {:name reagent.impl.component/obligatory, :file "target/cljsbuild/public/js/out/reagent/impl/component.cljs", :line 208, :column 1, :end-line 208, :end-column 16, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/component.cljs", :line 208, :column 6, :end-line 208, :end-column 16}, :tag cljs.core/IMap}, props-argv {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/component.cljs", :line 33, :column 7, :end-line 33, :end-column 17, :arglists (quote ([c p]))}, :name reagent.impl.component/props-argv, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/component.cljs", :end-column 17, :method-params ([c p]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 33, :end-line 33, :max-fixed-arity 2, :fn-var true, :arglists (quote ([c p]))}, as-element {:name reagent.impl.component/as-element, :file "target/cljsbuild/public/js/out/reagent/impl/component.cljs", :line 82, :column 1, :end-line 82, :end-column 20, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/component.cljs", :line 82, :column 10, :end-line 82, :end-column 20}, :tag clj-nil}, do-render {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/component.cljs", :line 113, :column 7, :end-line 113, :end-column 16, :arglists (quote ([c]))}, :name reagent.impl.component/do-render, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/component.cljs", :end-column 16, :method-params ([c]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 113, :end-line 113, :max-fixed-arity 1, :fn-var true, :arglists (quote ([c]))}, comp-name {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/compoLine truncated
+573
View File
@@ -0,0 +1,573 @@
// Compiled by ClojureScript 1.9.946 {}
goog.provide('reagent.impl.component');
goog.require('cljs.core');
goog.require('reagent.impl.util');
goog.require('reagent.impl.batching');
goog.require('reagent.ratom');
goog.require('reagent.interop');
goog.require('reagent.debug');
reagent.impl.component.shallow_obj_to_map = (function reagent$impl$component$shallow_obj_to_map(o){
var ks = cljs.core.js_keys.call(null,o);
var len = ks.length;
var m = cljs.core.PersistentArrayMap.EMPTY;
var i = (0);
while(true){
if((i < len)){
var k = (ks[i]);
var G__37627 = cljs.core.assoc.call(null,m,cljs.core.keyword.call(null,k),(o[k]));
var G__37628 = (i + (1));
m = G__37627;
i = G__37628;
continue;
} else {
return m;
}
break;
}
});
reagent.impl.component.extract_props = (function reagent$impl$component$extract_props(v){
var p = cljs.core.nth.call(null,v,(1),null);
if(cljs.core.map_QMARK_.call(null,p)){
return p;
} else {
return null;
}
});
reagent.impl.component.extract_children = (function reagent$impl$component$extract_children(v){
var p = cljs.core.nth.call(null,v,(1),null);
var first_child = ((((p == null)) || (cljs.core.map_QMARK_.call(null,p)))?(2):(1));
if((cljs.core.count.call(null,v) > first_child)){
return cljs.core.subvec.call(null,v,first_child);
} else {
return null;
}
});
reagent.impl.component.props_argv = (function reagent$impl$component$props_argv(c,p){
var temp__5459__auto__ = (p["argv"]);
if((temp__5459__auto__ == null)){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [c.constructor,reagent.impl.component.shallow_obj_to_map.call(null,p)], null);
} else {
var a = temp__5459__auto__;
return a;
}
});
reagent.impl.component.get_argv = (function reagent$impl$component$get_argv(c){
return reagent.impl.component.props_argv.call(null,c,(c["props"]));
});
reagent.impl.component.get_props = (function reagent$impl$component$get_props(c){
var p = (c["props"]);
var temp__5459__auto__ = (p["argv"]);
if((temp__5459__auto__ == null)){
return reagent.impl.component.shallow_obj_to_map.call(null,p);
} else {
var v = temp__5459__auto__;
return reagent.impl.component.extract_props.call(null,v);
}
});
reagent.impl.component.get_children = (function reagent$impl$component$get_children(c){
var p = (c["props"]);
var temp__5459__auto__ = (p["argv"]);
if((temp__5459__auto__ == null)){
return cljs.core.into.call(null,cljs.core.PersistentVector.EMPTY,(reagent.impl.util.react["Children"]["toArray"])((p["children"])));
} else {
var v = temp__5459__auto__;
return reagent.impl.component.extract_children.call(null,v);
}
});
reagent.impl.component.reagent_class_QMARK_ = (function reagent$impl$component$reagent_class_QMARK_(c){
return (cljs.core.fn_QMARK_.call(null,c)) && (!(((function (){var G__37630 = c;
var G__37630__$1 = (((G__37630 == null))?null:G__37630.prototype);
if((G__37630__$1 == null)){
return null;
} else {
return (G__37630__$1["reagentRender"]);
}
})() == null)));
});
reagent.impl.component.react_class_QMARK_ = (function reagent$impl$component$react_class_QMARK_(c){
return (cljs.core.fn_QMARK_.call(null,c)) && (!(((function (){var G__37632 = c;
var G__37632__$1 = (((G__37632 == null))?null:G__37632.prototype);
if((G__37632__$1 == null)){
return null;
} else {
return (G__37632__$1["render"]);
}
})() == null)));
});
reagent.impl.component.reagent_component_QMARK_ = (function reagent$impl$component$reagent_component_QMARK_(c){
return !(((c["reagentRender"]) == null));
});
reagent.impl.component.cached_react_class = (function reagent$impl$component$cached_react_class(c){
return (c["cljsReactClass"]);
});
reagent.impl.component.cache_react_class = (function reagent$impl$component$cache_react_class(c,constructor$){
return (c["cljsReactClass"] = constructor$);
});
reagent.impl.component.state_atom = (function reagent$impl$component$state_atom(this$){
var sa = (this$["cljsState"]);
if(!((sa == null))){
return sa;
} else {
return (this$["cljsState"] = reagent.ratom.atom.call(null,null));
}
});
if(typeof reagent.impl.component.as_element !== 'undefined'){
} else {
reagent.impl.component.as_element = null;
}
reagent.impl.component.wrap_render = (function reagent$impl$component$wrap_render(c){
while(true){
var f = (c["reagentRender"]);
var _ = ((cljs.core.ifn_QMARK_.call(null,f))?null:(function(){throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected something callable, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.call(null,f))].join('')),"\n","(clojure.core/ifn? f)"].join('')))})());
var res = (((c["cljsLegacyRender"]) === true)?f.call(c,c):(function (){var v = reagent.impl.component.get_argv.call(null,c);
var n = cljs.core.count.call(null,v);
var G__37633 = n;
switch (G__37633) {
case (1):
return f.call(c);
break;
case (2):
return f.call(c,cljs.core.nth.call(null,v,(1)));
break;
case (3):
return f.call(c,cljs.core.nth.call(null,v,(1)),cljs.core.nth.call(null,v,(2)));
break;
case (4):
return f.call(c,cljs.core.nth.call(null,v,(1)),cljs.core.nth.call(null,v,(2)),cljs.core.nth.call(null,v,(3)));
break;
case (5):
return f.call(c,cljs.core.nth.call(null,v,(1)),cljs.core.nth.call(null,v,(2)),cljs.core.nth.call(null,v,(3)),cljs.core.nth.call(null,v,(4)));
break;
default:
return f.apply(c,cljs.core.into_array.call(null,v).slice((1)));
}
})());
if(cljs.core.vector_QMARK_.call(null,res)){
return reagent.impl.component.as_element.call(null,res);
} else {
if(cljs.core.ifn_QMARK_.call(null,res)){
var f__$1 = ((reagent.impl.component.reagent_class_QMARK_.call(null,res))?((function (c,f,_,res){
return (function() {
var G__37635__delegate = function (args){
return reagent.impl.component.as_element.call(null,cljs.core.apply.call(null,cljs.core.vector,res,args));
};
var G__37635 = function (var_args){
var args = null;
if (arguments.length > 0) {
var G__37636__i = 0, G__37636__a = new Array(arguments.length - 0);
while (G__37636__i < G__37636__a.length) {G__37636__a[G__37636__i] = arguments[G__37636__i + 0]; ++G__37636__i;}
args = new cljs.core.IndexedSeq(G__37636__a,0,null);
}
return G__37635__delegate.call(this,args);};
G__37635.cljs$lang$maxFixedArity = 0;
G__37635.cljs$lang$applyTo = (function (arglist__37637){
var args = cljs.core.seq(arglist__37637);
return G__37635__delegate(args);
});
G__37635.cljs$core$IFn$_invoke$arity$variadic = G__37635__delegate;
return G__37635;
})()
;})(c,f,_,res))
:res);
(c["reagentRender"] = f__$1);
var G__37638 = c;
c = G__37638;
continue;
} else {
return res;
}
}
break;
}
});
reagent.impl.component.do_render = (function reagent$impl$component$do_render(c){
var _STAR_current_component_STAR_37639 = reagent.impl.component._STAR_current_component_STAR_;
reagent.impl.component._STAR_current_component_STAR_ = c;
try{var ok = [false];
try{var res = reagent.impl.component.wrap_render.call(null,c);
(ok[(0)] = true);
return res;
}finally {if(cljs.core.truth_((ok[(0)]))){
} else {
if(cljs.core.truth_(reagent.debug.has_console)){
(cljs.core.truth_(reagent.debug.tracking)?reagent.debug.track_console:console).error([cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Error rendering component",cljs.core.str.cljs$core$IFn$_invoke$arity$1(reagent.impl.component.comp_name.call(null))].join(''))].join(''));
} else {
}
}
}
}finally {reagent.impl.component._STAR_current_component_STAR_ = _STAR_current_component_STAR_37639;
}});
reagent.impl.component.rat_opts = new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"no-cache","no-cache",1588056370),true], null);
reagent.impl.component.static_fns = new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"render","render",-1408033454),(function reagent$impl$component$render(){
var c = this;
if(reagent.impl.util._STAR_non_reactive_STAR_){
return reagent.impl.component.do_render.call(null,c);
} else {
var rat = (c["cljsRatom"]);
reagent.impl.batching.mark_rendered.call(null,c);
if((rat == null)){
return reagent.ratom.run_in_reaction.call(null,((function (rat,c){
return (function (){
return reagent.impl.component.do_render.call(null,c);
});})(rat,c))
,c,"cljsRatom",reagent.impl.batching.queue_render,reagent.impl.component.rat_opts);
} else {
return rat._run(false);
}
}
})], null);
reagent.impl.component.custom_wrapper = (function reagent$impl$component$custom_wrapper(key,f){
var G__37640 = key;
var G__37640__$1 = (((G__37640 instanceof cljs.core.Keyword))?G__37640.fqn:null);
switch (G__37640__$1) {
case "getDefaultProps":
throw (new Error("getDefaultProps not supported"));
break;
case "getInitialState":
return ((function (G__37640,G__37640__$1){
return (function reagent$impl$component$custom_wrapper_$_getInitialState(){
var c = this;
return cljs.core.reset_BANG_.call(null,reagent.impl.component.state_atom.call(null,c),f.call(c,c));
});
;})(G__37640,G__37640__$1))
break;
case "componentWillReceiveProps":
return ((function (G__37640,G__37640__$1){
return (function reagent$impl$component$custom_wrapper_$_componentWillReceiveProps(nextprops){
var c = this;
return f.call(c,c,reagent.impl.component.props_argv.call(null,c,nextprops));
});
;})(G__37640,G__37640__$1))
break;
case "shouldComponentUpdate":
return ((function (G__37640,G__37640__$1){
return (function reagent$impl$component$custom_wrapper_$_shouldComponentUpdate(nextprops,nextstate){
var or__35498__auto__ = reagent.impl.util._STAR_always_update_STAR_;
if(or__35498__auto__){
return or__35498__auto__;
} else {
var c = this;
var old_argv = (c["props"]["argv"]);
var new_argv = (nextprops["argv"]);
var noargv = ((old_argv == null)) || ((new_argv == null));
if((f == null)){
return (noargv) || (cljs.core.not_EQ_.call(null,old_argv,new_argv));
} else {
if(noargv){
return f.call(c,c,reagent.impl.component.get_argv.call(null,c),reagent.impl.component.props_argv.call(null,c,nextprops));
} else {
return f.call(c,c,old_argv,new_argv);
}
}
}
});
;})(G__37640,G__37640__$1))
break;
case "componentWillUpdate":
return ((function (G__37640,G__37640__$1){
return (function reagent$impl$component$custom_wrapper_$_componentWillUpdate(nextprops){
var c = this;
return f.call(c,c,reagent.impl.component.props_argv.call(null,c,nextprops));
});
;})(G__37640,G__37640__$1))
break;
case "componentDidUpdate":
return ((function (G__37640,G__37640__$1){
return (function reagent$impl$component$custom_wrapper_$_componentDidUpdate(oldprops){
var c = this;
return f.call(c,c,reagent.impl.component.props_argv.call(null,c,oldprops));
});
;})(G__37640,G__37640__$1))
break;
case "componentWillMount":
return ((function (G__37640,G__37640__$1){
return (function reagent$impl$component$custom_wrapper_$_componentWillMount(){
var c = this;
(c["cljsMountOrder"] = reagent.impl.batching.next_mount_count.call(null));
if((f == null)){
return null;
} else {
return f.call(c,c);
}
});
;})(G__37640,G__37640__$1))
break;
case "componentDidMount":
return ((function (G__37640,G__37640__$1){
return (function reagent$impl$component$custom_wrapper_$_componentDidMount(){
var c = this;
return f.call(c,c);
});
;})(G__37640,G__37640__$1))
break;
case "componentWillUnmount":
return ((function (G__37640,G__37640__$1){
return (function reagent$impl$component$custom_wrapper_$_componentWillUnmount(){
var c = this;
var G__37641_37643 = (c["cljsRatom"]);
if((G__37641_37643 == null)){
} else {
reagent.ratom.dispose_BANG_.call(null,G__37641_37643);
}
reagent.impl.batching.mark_rendered.call(null,c);
if((f == null)){
return null;
} else {
return f.call(c,c);
}
});
;})(G__37640,G__37640__$1))
break;
default:
return null;
}
});
reagent.impl.component.get_wrapper = (function reagent$impl$component$get_wrapper(key,f,name){
var wrap = reagent.impl.component.custom_wrapper.call(null,key,f);
if(cljs.core.truth_((function (){var and__35486__auto__ = wrap;
if(cljs.core.truth_(and__35486__auto__)){
return f;
} else {
return and__35486__auto__;
}
})())){
if(cljs.core.ifn_QMARK_.call(null,f)){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected something callable, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.call(null,f))].join('')),"\n","(clojure.core/ifn? f)"].join('')));
}
} else {
}
var or__35498__auto__ = wrap;
if(cljs.core.truth_(or__35498__auto__)){
return or__35498__auto__;
} else {
return f;
}
});
reagent.impl.component.obligatory = new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"shouldComponentUpdate","shouldComponentUpdate",1795750960),null,new cljs.core.Keyword(null,"componentWillMount","componentWillMount",-285327619),null,new cljs.core.Keyword(null,"componentWillUnmount","componentWillUnmount",1573788814),null], null);
reagent.impl.component.dash_to_camel = reagent.impl.util.memoize_1.call(null,reagent.impl.util.dash_to_camel);
reagent.impl.component.camelify_map_keys = (function reagent$impl$component$camelify_map_keys(fun_map){
return cljs.core.reduce_kv.call(null,(function (m,k,v){
return cljs.core.assoc.call(null,m,cljs.core.keyword.call(null,reagent.impl.component.dash_to_camel.call(null,k)),v);
}),cljs.core.PersistentArrayMap.EMPTY,fun_map);
});
reagent.impl.component.add_obligatory = (function reagent$impl$component$add_obligatory(fun_map){
return cljs.core.merge.call(null,reagent.impl.component.obligatory,fun_map);
});
reagent.impl.component.wrap_funs = (function reagent$impl$component$wrap_funs(fmap){
var renders_37645 = cljs.core.select_keys.call(null,fmap,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"render","render",-1408033454),new cljs.core.Keyword(null,"reagentRender","reagentRender",-358306383),new cljs.core.Keyword(null,"componentFunction","componentFunction",825866104)], null));
var render_fun_37646 = cljs.core.first.call(null,cljs.core.vals.call(null,renders_37645));
if((cljs.core.count.call(null,renders_37645) > (0))){
} else {
throw (new Error(["Assert failed: ","Missing reagent-render","\n","(pos? (count renders))"].join('')));
}
if(((1) === cljs.core.count.call(null,renders_37645))){
} else {
throw (new Error(["Assert failed: ","Too many render functions supplied","\n","(== 1 (count renders))"].join('')));
}
if(cljs.core.ifn_QMARK_.call(null,render_fun_37646)){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected something callable, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.call(null,render_fun_37646))].join('')),"\n","(clojure.core/ifn? render-fun)"].join('')));
}
var render_fun = (function (){var or__35498__auto__ = new cljs.core.Keyword(null,"reagentRender","reagentRender",-358306383).cljs$core$IFn$_invoke$arity$1(fmap);
if(cljs.core.truth_(or__35498__auto__)){
return or__35498__auto__;
} else {
return new cljs.core.Keyword(null,"componentFunction","componentFunction",825866104).cljs$core$IFn$_invoke$arity$1(fmap);
}
})();
var legacy_render = (render_fun == null);
var render_fun__$1 = (function (){var or__35498__auto__ = render_fun;
if(cljs.core.truth_(or__35498__auto__)){
return or__35498__auto__;
} else {
return new cljs.core.Keyword(null,"render","render",-1408033454).cljs$core$IFn$_invoke$arity$1(fmap);
}
})();
var name = [cljs.core.str.cljs$core$IFn$_invoke$arity$1((function (){var or__35498__auto__ = new cljs.core.Keyword(null,"displayName","displayName",-809144601).cljs$core$IFn$_invoke$arity$1(fmap);
if(cljs.core.truth_(or__35498__auto__)){
return or__35498__auto__;
} else {
return reagent.impl.util.fun_name.call(null,render_fun__$1);
}
})())].join('');
var name__$1 = (function (){var G__37644 = name;
switch (G__37644) {
case "":
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.gensym.call(null,"reagent"))].join('');
break;
default:
return name;
}
})();
var fmap__$1 = cljs.core.reduce_kv.call(null,((function (render_fun,legacy_render,render_fun__$1,name,name__$1){
return (function (m,k,v){
return cljs.core.assoc.call(null,m,k,reagent.impl.component.get_wrapper.call(null,k,v,name__$1));
});})(render_fun,legacy_render,render_fun__$1,name,name__$1))
,cljs.core.PersistentArrayMap.EMPTY,fmap);
return cljs.core.assoc.call(null,fmap__$1,new cljs.core.Keyword(null,"displayName","displayName",-809144601),name__$1,new cljs.core.Keyword(null,"autobind","autobind",-570650245),false,new cljs.core.Keyword(null,"cljsLegacyRender","cljsLegacyRender",-1527295613),legacy_render,new cljs.core.Keyword(null,"reagentRender","reagentRender",-358306383),render_fun__$1,new cljs.core.Keyword(null,"render","render",-1408033454),new cljs.core.Keyword(null,"render","render",-1408033454).cljs$core$IFn$_invoke$arity$1(reagent.impl.component.static_fns));
});
reagent.impl.component.map_to_js = (function reagent$impl$component$map_to_js(m){
return cljs.core.reduce_kv.call(null,(function (o,k,v){
var G__37648 = o;
(G__37648[cljs.core.name.call(null,k)] = v);
return G__37648;
}),({}),m);
});
reagent.impl.component.cljsify = (function reagent$impl$component$cljsify(body){
return reagent.impl.component.map_to_js.call(null,reagent.impl.component.wrap_funs.call(null,reagent.impl.component.add_obligatory.call(null,reagent.impl.component.camelify_map_keys.call(null,body))));
});
reagent.impl.component.create_class = (function reagent$impl$component$create_class(body){
if(cljs.core.map_QMARK_.call(null,body)){
} else {
throw (new Error("Assert failed: (map? body)"));
}
return reagent.impl.util.create_class.call(null,reagent.impl.component.cljsify.call(null,body));
});
reagent.impl.component.component_path = (function reagent$impl$component$component_path(c){
var elem = (function (){var G__37649 = (function (){var or__35498__auto__ = (function (){var G__37651 = c;
if((G__37651 == null)){
return null;
} else {
return (G__37651["_reactInternalInstance"]);
}
})();
if(cljs.core.truth_(or__35498__auto__)){
return or__35498__auto__;
} else {
return c;
}
})();
if((G__37649 == null)){
return null;
} else {
return (G__37649["_currentElement"]);
}
})();
var name = (function (){var G__37652 = elem;
var G__37652__$1 = (((G__37652 == null))?null:(G__37652["type"]));
if((G__37652__$1 == null)){
return null;
} else {
return (G__37652__$1["displayName"]);
}
})();
var path = (function (){var G__37653 = elem;
var G__37653__$1 = (((G__37653 == null))?null:(G__37653["_owner"]));
var G__37653__$2 = (((G__37653__$1 == null))?null:reagent.impl.component.component_path.call(null,G__37653__$1));
if((G__37653__$2 == null)){
return null;
} else {
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__37653__$2)," > "].join('');
}
})();
var res = [cljs.core.str.cljs$core$IFn$_invoke$arity$1(path),cljs.core.str.cljs$core$IFn$_invoke$arity$1(name)].join('');
if(cljs.core.empty_QMARK_.call(null,res)){
return null;
} else {
return res;
}
});
reagent.impl.component.comp_name = (function reagent$impl$component$comp_name(){
var c = reagent.impl.component._STAR_current_component_STAR_;
var n = (function (){var or__35498__auto__ = reagent.impl.component.component_path.call(null,c);
if(cljs.core.truth_(or__35498__auto__)){
return or__35498__auto__;
} else {
var G__37654 = c;
var G__37654__$1 = (((G__37654 == null))?null:G__37654.constructor);
if((G__37654__$1 == null)){
return null;
} else {
return reagent.impl.util.fun_name.call(null,G__37654__$1);
}
}
})();
if(!(cljs.core.empty_QMARK_.call(null,n))){
return [" (in ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(n),")"].join('');
} else {
return "";
}
});
reagent.impl.component.fn_to_class = (function reagent$impl$component$fn_to_class(f){
if(cljs.core.ifn_QMARK_.call(null,f)){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Expected something callable, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.call(null,f))].join('')),"\n","(clojure.core/ifn? f)"].join('')));
}
if(!(!((reagent.impl.component.react_class_QMARK_.call(null,f)) && (!(reagent.impl.component.reagent_class_QMARK_.call(null,f)))))){
if(cljs.core.truth_(reagent.debug.has_console)){
(cljs.core.truth_(reagent.debug.tracking)?reagent.debug.track_console:console).warn(["Warning: ","Using native React classes directly in Hiccup forms ","is not supported. Use create-element or ","adapt-react-class instead: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1((function (){var n = reagent.impl.util.fun_name.call(null,f);
if(cljs.core.empty_QMARK_.call(null,n)){
return f;
} else {
return n;
}
})()),cljs.core.str.cljs$core$IFn$_invoke$arity$1(reagent.impl.component.comp_name.call(null))].join(''));
} else {
}
} else {
}
if(reagent.impl.component.reagent_class_QMARK_.call(null,f)){
return reagent.impl.component.cache_react_class.call(null,f,f);
} else {
var spec = cljs.core.meta.call(null,f);
var withrender = cljs.core.assoc.call(null,spec,new cljs.core.Keyword(null,"reagent-render","reagent-render",-985383853),f);
var res = reagent.impl.component.create_class.call(null,withrender);
return reagent.impl.component.cache_react_class.call(null,f,res);
}
});
reagent.impl.component.as_class = (function reagent$impl$component$as_class(tag){
var temp__5459__auto__ = reagent.impl.component.cached_react_class.call(null,tag);
if((temp__5459__auto__ == null)){
return reagent.impl.component.fn_to_class.call(null,tag);
} else {
var cached_class = temp__5459__auto__;
return cached_class;
}
});
reagent.impl.component.reactify_component = (function reagent$impl$component$reactify_component(comp){
if(reagent.impl.component.react_class_QMARK_.call(null,comp)){
return comp;
} else {
return reagent.impl.component.as_class.call(null,comp);
}
});
//# sourceMappingURL=component.js.map?rel=1517021941100
@@ -0,0 +1 @@
{"version":3,"file":"\/home\/didier\/clojupyter\/website\/target\/cljsbuild\/public\/js\/out\/reagent\/impl\/component.js","sources":["component.cljs?rel=1517021941102"],"lineCount":573,"mappings":";AAAA;;;;;;;AAQA,AAAA,AAKA,4CAAA,5CAAMA,gGAAoBC;AAA1B,AACE,IAAMC,KAAG,AAACC,4BAAQF;IACZG,MAAI,AAASF;AADnB,AAEE,QAAA,JAAOG;QAAP,JAAYC;;AAAZ,AACE,GAAI,CAAGA,IAAEF;AACP,IAAMG,IAAE,CAAML,GAAGI;AAAjB,AACE,eAAO,AAACE,0BAAMH,EAAE,AAACI,4BAAQF,GAAG,CAAMN,EAAEM;eAAI,KAAA,JAAKD;;;;;AAC\/CD;;;;;AAER,uCAAA,vCAAMK,sFAAeC;AAArB,AACE,IAAMC,IAAE,0BAAA,IAAA,9BAACC,wBAAIF;AAAb,AACE,GAAI,AAACG,+BAAKF;AAAGA;;AAAb;;;AAEJ,0CAAA,1CAAMG,4FAAkBJ;AAAxB,AACE,IAAMC,IAAE,0BAAA,IAAA,9BAACC,wBAAIF;IACPK,cAAY,wDAAA,IAAA,1DAAI,CAAI,MAAA,LAAMJ,gBAAG,AAACE,+BAAKF;AADzC,AAEE,GAAI,CAAG,AAACK,0BAAMN,KAAGK;AACf,OAACE,2BAAOP,EAAEK;;AADZ;;;AAGJ,oCAAA,pCAAMG,gFAAYC,EAAER;AAApB,AACE,IAAAS,qBAAY,GAAA,FAAGT;AAAf,AAAA,GAAA,CAAAS,sBAAA;AAAA,0FAEG,AAAeD,cAAG,AAACpB,oDAAmBY;;AAFzC,QAAAS,JAAUC;AAAV,AACEA;;;AAGJ,kCAAA,lCAAMC,4EAAUH;AAAhB,AACE,OAACD,4CAAWC,EAAE,GAAA,FAAGA;;AAEnB,mCAAA,nCAAMI,8EAAWJ;AAAjB,AACE,IAAMR,IAAE,GAAA,FAAGQ;AAAX,AACE,IAAAC,qBAAY,GAAA,FAAGT;AAAf,AAAA,GAAA,CAAAS,sBAAA;AAEE,OAACrB,oDAAmBY;;AAFtB,QA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WAAS,GAAA,SAAA,XAAG7D;IACZ8D,WAAS,WAAA,VAAGL;IACZM,SAAO,CAAI,aAAA,ZAAMF,uBAAU,aAAA,ZAAMC;AAFvC,AAGE,GACE,MAAA,LAAMvC;AAAG,QAAIwC,YAAO,AAACC,4BAAKH,SAASC;;AADrC,GAEEC;AAAO,OAAOxC,OAAEvB,EAAEA,EAAE,AAACG,0CAASH,GAAG,AAACD,4CAAWC,EAAEyD;;AAFjD,AAGS,OAAOlC,OAAEvB,EAAEA,EAAE6D,SAASC;;;;;;;;;KAxBlD;AA2BE;6EAAyBL;AAAzB,AACE,QAAA,JAASzD;AAAT,AAAW,OAAOuB,OAAEvB,EAAEA,EAAE,AAACD,4CAAWC,EAAEyD;;;;;KA5B1C;AA+BE;4EAAwBQ;AAAxB,AACE,QAAA,JAASjE;AAAT,AAAW,OAAOuB,OAAEvB,EAAEA,EAAE,AAACD,4CAAWC,EAAEiE;;;;;KAhC1C;AAmCE;;AAAA,AACE,QAAA,JAASjE;AAAT,AACS,GAAA,FAAIA,sBAAkB,AAACkE;;AACvB,GAAU,MAAA,LAAM3C;AAAhB;;AAAA,AACE,OAAOA,OAAEvB,EAAEA;;;;;;KAvC1B;AA0CE;;AAAA,AACE,QAAA,JAASA;ALine truncated
+405
View File
@@ -0,0 +1,405 @@
(ns reagent.impl.template
(:require [clojure.string :as string]
[clojure.walk :refer [prewalk]]
[reagent.impl.util :as util :refer [is-client]]
[reagent.impl.component :as comp]
[reagent.impl.batching :as batch]
[reagent.ratom :as ratom]
[reagent.interop :refer-macros [$ $!]]
[reagent.debug :refer-macros [dbg prn println log dev?
warn warn-unless]]))
;; From Weavejester's Hiccup, via pump:
(def ^{:doc "Regular expression that parses a CSS-style id and class
from a tag name."}
re-tag #"([^\s\.#]+)(?:#([^\s\.#]+))?(?:\.([^\s#]+))?")
(deftype NativeWrapper [])
;;; Common utilities
(defn ^boolean named? [x]
(or (keyword? x)
(symbol? x)))
(defn ^boolean hiccup-tag? [x]
(or (named? x)
(string? x)))
(defn ^boolean valid-tag? [x]
(or (hiccup-tag? x)
(ifn? x)
(instance? NativeWrapper x)))
;;; Props conversion
(def prop-name-cache #js{:class "className"
:for "htmlFor"
:charset "charSet"})
(defn cache-get [o k]
(when ^boolean (.hasOwnProperty o k)
(aget o k)))
(defn cached-prop-name [k]
(if (named? k)
(if-some [k' (cache-get prop-name-cache (name k))]
k'
(aset prop-name-cache (name k)
(util/dash-to-camel k)))
k))
(defn ^boolean js-val? [x]
(not (identical? "object" (goog/typeOf x))))
(declare convert-prop-value)
(defn kv-conv [o k v]
(doto o
(aset (cached-prop-name k)
(convert-prop-value v))))
(defn convert-prop-value [x]
(cond (js-val? x) x
(named? x) (name x)
(map? x) (reduce-kv kv-conv #js{} x)
(coll? x) (clj->js x)
(ifn? x) (fn [& args]
(apply x args))
:else (clj->js x)))
(defn oset [o k v]
(doto (if (nil? o) #js{} o)
(aset k v)))
(defn oget [o k]
(if (nil? o) nil (aget o k)))
(defn set-id-class [p id-class]
(let [id ($ id-class :id)
p (if (and (some? id)
(nil? (oget p "id")))
(oset p "id" id)
p)]
(if-some [class ($ id-class :className)]
(let [old (oget p "className")]
(oset p "className" (if (nil? old)
class
(str class " " old))))
p)))
(defn convert-props [props id-class]
(-> props
convert-prop-value
(set-id-class id-class)))
;;; Specialization for input components
;; This gets set from reagent.dom
(defonce find-dom-node nil)
;; <input type="??" >
;; The properites 'selectionStart' and 'selectionEnd' only exist on some inputs
;; See: https://html.spec.whatwg.org/multipage/forms.html#do-not-apply
(def these-inputs-have-selection-api #{"text" "textarea" "password" "search"
"tel" "url"})
(defn ^boolean has-selection-api?
[input-type]
(contains? these-inputs-have-selection-api input-type))
(defn input-set-value [this]
(when ($ this :cljsInputLive)
($! this :cljsInputDirty false)
(let [rendered-value ($ this :cljsRenderedValue)
dom-value ($ this :cljsDOMValue)
node (find-dom-node this)]
(when (not= rendered-value dom-value)
(if-not (and (identical? node ($ js/document :activeElement))
(has-selection-api? ($ node :type))
(string? rendered-value)
(string? dom-value))
;; just set the value, no need to worry about a cursor
(do
($! this :cljsDOMValue rendered-value)
($! node :value rendered-value))
;; Setting "value" (below) moves the cursor position to the
;; end which gives the user a jarring experience.
;;
;; But repositioning the cursor within the text, turns out to
;; be quite a challenge because changes in the text can be
;; triggered by various events like:
;; - a validation function rejecting a user inputted char
;; - the user enters a lower case char, but is transformed to
;; upper.
;; - the user selects multiple chars and deletes text
;; - the user pastes in multiple chars, and some of them are
;; rejected by a validator.
;; - the user selects multiple chars and then types in a
;; single new char to repalce them all.
;; Coming up with a sane cursor repositioning strategy hasn't
;; been easy ALTHOUGH in the end, it kinda fell out nicely,
;; and it appears to sanely handle all the cases we could
;; think of.
;; So this is just a warning. The code below is simple
;; enough, but if you are tempted to change it, be aware of
;; all the scenarios you have handle.
(let [node-value ($ node :value)]
(if (not= node-value dom-value)
;; IE has not notified us of the change yet, so check again later
(batch/do-after-render #(input-set-value this))
(let [existing-offset-from-end (- (count node-value)
($ node :selectionStart))
new-cursor-offset (- (count rendered-value)
existing-offset-from-end)]
($! this :cljsDOMValue rendered-value)
($! node :value rendered-value)
($! node :selectionStart new-cursor-offset)
($! node :selectionEnd new-cursor-offset)))))))))
(defn input-handle-change [this on-change e]
($! this :cljsDOMValue (-> e .-target .-value))
;; Make sure the input is re-rendered, in case on-change
;; wants to keep the value unchanged
(when-not ($ this :cljsInputDirty)
($! this :cljsInputDirty true)
(batch/do-after-render #(input-set-value this)))
(on-change e))
(defn input-render-setup [this jsprops]
;; Don't rely on React for updating "controlled inputs", since it
;; doesn't play well with async rendering (misses keystrokes).
(when (and (some? jsprops)
(.hasOwnProperty jsprops "onChange")
(.hasOwnProperty jsprops "value"))
(assert find-dom-node
"reagent.dom needs to be loaded for controlled input to work")
(let [v ($ jsprops :value)
value (if (nil? v) "" v)
on-change ($ jsprops :onChange)]
(when-not ($ this :cljsInputLive)
;; set initial value
($! this :cljsInputLive true)
($! this :cljsDOMValue value))
($! this :cljsRenderedValue value)
(js-delete jsprops "value")
(doto jsprops
($! :defaultValue value)
($! :onChange #(input-handle-change this on-change %))))))
(defn input-unmount [this]
($! this :cljsInputLive nil))
(defn ^boolean input-component? [x]
(case x
("input" "textarea") true
false))
(def reagent-input-class nil)
(declare make-element)
(def input-spec
{:display-name "ReagentInput"
:component-did-update input-set-value
:component-will-unmount input-unmount
:reagent-render
(fn [argv comp jsprops first-child]
(let [this comp/*current-component*]
(input-render-setup this jsprops)
(make-element argv comp jsprops first-child)))})
(defn reagent-input []
(when (nil? reagent-input-class)
(set! reagent-input-class (comp/create-class input-spec)))
reagent-input-class)
;;; Conversion from Hiccup forms
(defn parse-tag [hiccup-tag]
(let [[tag id class] (->> hiccup-tag name (re-matches re-tag) next)
class (when-not (nil? class)
(string/replace class #"\." " "))]
(assert tag (str "Invalid tag: '" hiccup-tag "'"
(comp/comp-name)))
#js{:name tag
:id id
:className class}))
(defn try-get-key [x]
;; try catch to avoid clojurescript peculiarity with
;; sorted-maps with keys that are numbers
(try (get x :key)
(catch :default e)))
(defn get-key [x]
(when (map? x)
(try-get-key x)))
(defn key-from-vec [v]
(if-some [k (-> (meta v) get-key)]
k
(-> v (nth 1 nil) get-key)))
(defn reag-element [tag v]
(let [c (comp/as-class tag)
jsprops #js{:argv v}]
(when-some [key (key-from-vec v)]
($! jsprops :key key))
($ util/react createElement c jsprops)))
(defn adapt-react-class [c]
(doto (->NativeWrapper)
($! :name c)
($! :id nil)
($! :class nil)))
(def tag-name-cache #js{})
(defn cached-parse [x]
(if-some [s (cache-get tag-name-cache x)]
s
(aset tag-name-cache x (parse-tag x))))
(declare as-element)
(defn native-element [parsed argv first]
(let [comp ($ parsed :name)]
(let [props (nth argv first nil)
hasprops (or (nil? props) (map? props))
jsprops (convert-props (if hasprops props) parsed)
first-child (+ first (if hasprops 1 0))]
(if (input-component? comp)
(-> [(reagent-input) argv comp jsprops first-child]
(with-meta (meta argv))
as-element)
(let [key (-> (meta argv) get-key)
p (if (nil? key)
jsprops
(oset jsprops "key" key))]
(make-element argv comp p first-child))))))
(defn str-coll [coll]
(if (dev?)
(str (prewalk (fn [x]
(if (fn? x)
(let [n (util/fun-name x)]
(case n "" x (symbol n)))
x)) coll))
(str coll)))
(defn hiccup-err [v & msg]
(str (apply str msg) ": " (str-coll v) "\n" (comp/comp-name)))
(defn vec-to-elem [v]
(assert (pos? (count v)) (hiccup-err v "Hiccup form should not be empty"))
(let [tag (nth v 0 nil)]
(assert (valid-tag? tag) (hiccup-err v "Invalid Hiccup form"))
(cond
(hiccup-tag? tag)
(let [n (name tag)
pos (.indexOf n ">")]
(case pos
-1 (native-element (cached-parse n) v 1)
0 (let [comp (nth v 1 nil)]
;; Support [:> comp ...]
(assert (= ">" n) (hiccup-err v "Invalid Hiccup tag"))
(assert (or (string? comp) (fn? comp))
(hiccup-err v "Expected React component in"))
(native-element #js{:name comp} v 2))
;; Support extended hiccup syntax, i.e :div.bar>a.foo
(recur [(subs n 0 pos)
(assoc v 0 (subs n (inc pos)))])))
(instance? NativeWrapper tag)
(native-element tag v 1)
:else (reag-element tag v))))
(declare expand-seq)
(declare expand-seq-check)
(defn as-element [x]
(cond (js-val? x) x
(vector? x) (vec-to-elem x)
(seq? x) (if (dev?)
(expand-seq-check x)
(expand-seq x))
(named? x) (name x)
(satisfies? IPrintWithWriter x) (pr-str x)
:else x))
(set! comp/as-element as-element)
(defn expand-seq [s]
(let [a (into-array s)]
(dotimes [i (alength a)]
(aset a i (as-element (aget a i))))
a))
(defn expand-seq-dev [s o]
(let [a (into-array s)]
(dotimes [i (alength a)]
(let [val (aget a i)]
(when (and (vector? val)
(nil? (key-from-vec val)))
($! o :no-key true))
(aset a i (as-element val))))
a))
(defn expand-seq-check [x]
(let [ctx #js{}
[res derefed] (ratom/check-derefs #(expand-seq-dev x ctx))]
(when derefed
(warn (hiccup-err x "Reactive deref not supported in lazy seq, "
"it should be wrapped in doall")))
(when ($ ctx :no-key)
(warn (hiccup-err x "Every element in a seq should have a unique :key")))
res))
;; From https://github.com/babel/babel/commit/1d0e68f5a19d721fe8799b1ea331041d8bf9120e
;; (def react-element-type (or (and (exists? js/Symbol)
;; ($ js/Symbol :for)
;; ($ js/Symbol for "react.element"))
;; 60103))
;; (defn make-element-fast [argv comp jsprops first-child]
;; (let [key (some-> jsprops ($ :key))
;; ref (some-> jsprops ($ :ref))
;; props (if (nil? jsprops) (js-obj) jsprops)]
;; ($! props :children
;; (case (- (count argv) first-child)
;; 0 nil
;; 1 (as-element (nth argv first-child))
;; (reduce-kv (fn [a k v]
;; (when (>= k first-child)
;; (.push a (as-element v)))
;; a)
;; #js[] argv)))
;; (js-obj "key" key
;; "ref" ref
;; "props" props
;; "$$typeof" react-element-type
;; "type" comp
;; ;; "_store" (js-obj)
;; )))
(defn make-element [argv comp jsprops first-child]
(case (- (count argv) first-child)
;; Optimize cases of zero or one child
0 ($ util/react createElement comp jsprops)
1 ($ util/react createElement comp jsprops
(as-element (nth argv first-child nil)))
(.apply ($ util/react :createElement) nil
(reduce-kv (fn [a k v]
(when (>= k first-child)
(.push a (as-element v)))
a)
#js[comp jsprops] argv))))
@@ -0,0 +1 @@
{:rename-macros {}, :renames {}, :externs {document {}, Error {}, console {}}, :use-macros {log reagent.debug, warn-unless reagent.debug, dbg reagent.debug, $! reagent.interop, prn reagent.debug, warn reagent.debug, dev? reagent.debug, prewalk clojure.walk, println reagent.debug, $ reagent.interop}, :excludes #{}, :name reagent.impl.template, :imports nil, :requires {reagent.impl.util reagent.impl.util, comp reagent.impl.component, reagent.interop reagent.interop, reagent.ratom reagent.ratom, reagent.impl.batching reagent.impl.batching, reagent.impl.component reagent.impl.component, util reagent.impl.util, ratom reagent.ratom, string clojure.string, batch reagent.impl.batching, reagent.debug reagent.debug, clojure.string clojure.string, clojure.walk clojure.walk}, :cljs.spec/speced-vars [], :uses {prewalk clojure.walk, is-client reagent.impl.util}, :defs {valid-tag? {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/template.cljs", :line 30, :column 16, :end-line 30, :end-column 26, :tag boolean, :arglists (quote ([x]))}, :name reagent.impl.template/valid-tag?, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/template.cljs", :end-column 26, :method-params ([x]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 30, :ret-tag boolean, :end-line 30, :max-fixed-arity 1, :tag boolean, :fn-var true, :arglists (quote ([x]))}, adapt-react-class {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/template.cljs", :line 256, :column 7, :end-line 256, :end-column 24, :arglists (quote ([c]))}, :name reagent.impl.template/adapt-react-class, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/template.cljs", :end-column 24, :method-params ([c]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 256, :end-line 256, :max-fixed-arity 1, :fn-var true, :arglists (quote ([c]))}, has-selection-api? {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/template.cljs", :line 110, :column 16, :end-line 110, :end-column 34, :tag boolean, :arglists (quote ([input-type]))}, :name reagent.impl.template/has-selection-api?, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/template.cljs", :end-column 34, :method-params ([input-type]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 110, :ret-tag boolean, :end-line 110, :max-fixed-arity 1, :tag boolean, :fn-var true, :arglists (quote ([input-type]))}, str-coll {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/template.cljs", :line 287, :column 7, :end-line 287, :end-column 15, :arglists (quote ([coll]))}, :name reagent.impl.template/str-coll, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/template.cljs", :end-column 15, :method-params ([coll]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 287, :end-line 287, :max-fixed-arity 1, :fn-var true, :arglists (quote ([coll]))}, get-key {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/template.cljs", :line 240, :column 7, :end-line 240, :end-column 14, :arglists (quote ([x]))}, :name reagent.impl.template/get-key, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/template.cljs", :end-column 14, :method-params ([x]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 240, :end-line 240, :max-fixed-arity 1, :fn-var true, :arglists (quote ([x]))}, re-tag {:name reagent.impl.template/re-tag, :file "target/cljsbuild/public/js/out/reagent/impl/template.cljs", :line 13, :column 1, :end-line 15, :end-column 9, :doc "Regular expression that parses a CSS-style id and class\n from a tag name.", :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/template.cljs", :line 15, :column 3, :end-line 15, :end-column 9, :doc "Regular expression that parses a CSS-style id and class\n from a tag name."}, :tag any}, reag-element {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/template.cljs", :line 249, :column 7, :end-line 249, :end-column 19, :arglists (quote ([tag v]))}, :name reagent.impl.template/reag-element, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/template.cljs", :end-column 19, :method-params ([tag v]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 249, :end-line 249, :max-fixed-arity 2, :fn-var true, :arglists (quote ([tag v]))}, as-element {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/template.cljs", :line 327, :column 7, :end-line 327, :end-column 17, :arglists (quote ([x]))}, :name reagent.impl.template/as-element, :variadic false, :file "target/cljsbuild/publicLine truncated
+596
View File
@@ -0,0 +1,596 @@
// Compiled by ClojureScript 1.9.946 {}
goog.provide('reagent.impl.template');
goog.require('cljs.core');
goog.require('clojure.string');
goog.require('clojure.walk');
goog.require('reagent.impl.util');
goog.require('reagent.impl.component');
goog.require('reagent.impl.batching');
goog.require('reagent.ratom');
goog.require('reagent.interop');
goog.require('reagent.debug');
/**
* Regular expression that parses a CSS-style id and class
* from a tag name.
*/
reagent.impl.template.re_tag = /([^\s\.#]+)(?:#([^\s\.#]+))?(?:\.([^\s#]+))?/;
/**
* @constructor
*/
reagent.impl.template.NativeWrapper = (function (){
});
reagent.impl.template.NativeWrapper.getBasis = (function (){
return cljs.core.PersistentVector.EMPTY;
});
reagent.impl.template.NativeWrapper.cljs$lang$type = true;
reagent.impl.template.NativeWrapper.cljs$lang$ctorStr = "reagent.impl.template/NativeWrapper";
reagent.impl.template.NativeWrapper.cljs$lang$ctorPrWriter = (function (this__36169__auto__,writer__36170__auto__,opt__36171__auto__){
return cljs.core._write.call(null,writer__36170__auto__,"reagent.impl.template/NativeWrapper");
});
reagent.impl.template.__GT_NativeWrapper = (function reagent$impl$template$__GT_NativeWrapper(){
return (new reagent.impl.template.NativeWrapper());
});
reagent.impl.template.named_QMARK_ = (function reagent$impl$template$named_QMARK_(x){
return ((x instanceof cljs.core.Keyword)) || ((x instanceof cljs.core.Symbol));
});
reagent.impl.template.hiccup_tag_QMARK_ = (function reagent$impl$template$hiccup_tag_QMARK_(x){
return (reagent.impl.template.named_QMARK_.call(null,x)) || (typeof x === 'string');
});
reagent.impl.template.valid_tag_QMARK_ = (function reagent$impl$template$valid_tag_QMARK_(x){
return (reagent.impl.template.hiccup_tag_QMARK_.call(null,x)) || (cljs.core.ifn_QMARK_.call(null,x)) || ((x instanceof reagent.impl.template.NativeWrapper));
});
reagent.impl.template.prop_name_cache = ({"class": "className", "for": "htmlFor", "charset": "charSet"});
reagent.impl.template.cache_get = (function reagent$impl$template$cache_get(o,k){
if(o.hasOwnProperty(k)){
return (o[k]);
} else {
return null;
}
});
reagent.impl.template.cached_prop_name = (function reagent$impl$template$cached_prop_name(k){
if(reagent.impl.template.named_QMARK_.call(null,k)){
var temp__5459__auto__ = reagent.impl.template.cache_get.call(null,reagent.impl.template.prop_name_cache,cljs.core.name.call(null,k));
if((temp__5459__auto__ == null)){
return (reagent.impl.template.prop_name_cache[cljs.core.name.call(null,k)] = reagent.impl.util.dash_to_camel.call(null,k));
} else {
var k_SINGLEQUOTE_ = temp__5459__auto__;
return k_SINGLEQUOTE_;
}
} else {
return k;
}
});
reagent.impl.template.js_val_QMARK_ = (function reagent$impl$template$js_val_QMARK_(x){
return !(("object" === goog.typeOf(x)));
});
reagent.impl.template.kv_conv = (function reagent$impl$template$kv_conv(o,k,v){
var G__37667 = o;
(G__37667[reagent.impl.template.cached_prop_name.call(null,k)] = reagent.impl.template.convert_prop_value.call(null,v));
return G__37667;
});
reagent.impl.template.convert_prop_value = (function reagent$impl$template$convert_prop_value(x){
if(reagent.impl.template.js_val_QMARK_.call(null,x)){
return x;
} else {
if(reagent.impl.template.named_QMARK_.call(null,x)){
return cljs.core.name.call(null,x);
} else {
if(cljs.core.map_QMARK_.call(null,x)){
return cljs.core.reduce_kv.call(null,reagent.impl.template.kv_conv,({}),x);
} else {
if(cljs.core.coll_QMARK_.call(null,x)){
return cljs.core.clj__GT_js.call(null,x);
} else {
if(cljs.core.ifn_QMARK_.call(null,x)){
return (function() {
var G__37668__delegate = function (args){
return cljs.core.apply.call(null,x,args);
};
var G__37668 = function (var_args){
var args = null;
if (arguments.length > 0) {
var G__37669__i = 0, G__37669__a = new Array(arguments.length - 0);
while (G__37669__i < G__37669__a.length) {G__37669__a[G__37669__i] = arguments[G__37669__i + 0]; ++G__37669__i;}
args = new cljs.core.IndexedSeq(G__37669__a,0,null);
}
return G__37668__delegate.call(this,args);};
G__37668.cljs$lang$maxFixedArity = 0;
G__37668.cljs$lang$applyTo = (function (arglist__37670){
var args = cljs.core.seq(arglist__37670);
return G__37668__delegate(args);
});
G__37668.cljs$core$IFn$_invoke$arity$variadic = G__37668__delegate;
return G__37668;
})()
;
} else {
return cljs.core.clj__GT_js.call(null,x);
}
}
}
}
}
});
reagent.impl.template.oset = (function reagent$impl$template$oset(o,k,v){
var G__37671 = (((o == null))?({}):o);
(G__37671[k] = v);
return G__37671;
});
reagent.impl.template.oget = (function reagent$impl$template$oget(o,k){
if((o == null)){
return null;
} else {
return (o[k]);
}
});
reagent.impl.template.set_id_class = (function reagent$impl$template$set_id_class(p,id_class){
var id = (id_class["id"]);
var p__$1 = (((!((id == null))) && ((reagent.impl.template.oget.call(null,p,"id") == null)))?reagent.impl.template.oset.call(null,p,"id",id):p);
var temp__5459__auto__ = (id_class["className"]);
if((temp__5459__auto__ == null)){
return p__$1;
} else {
var class$ = temp__5459__auto__;
var old = reagent.impl.template.oget.call(null,p__$1,"className");
return reagent.impl.template.oset.call(null,p__$1,"className",(((old == null))?class$:[cljs.core.str.cljs$core$IFn$_invoke$arity$1(class$)," ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(old)].join('')));
}
});
reagent.impl.template.convert_props = (function reagent$impl$template$convert_props(props,id_class){
return reagent.impl.template.set_id_class.call(null,reagent.impl.template.convert_prop_value.call(null,props),id_class);
});
if(typeof reagent.impl.template.find_dom_node !== 'undefined'){
} else {
reagent.impl.template.find_dom_node = null;
}
reagent.impl.template.these_inputs_have_selection_api = new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 6, ["url",null,"tel",null,"text",null,"textarea",null,"password",null,"search",null], null), null);
reagent.impl.template.has_selection_api_QMARK_ = (function reagent$impl$template$has_selection_api_QMARK_(input_type){
return cljs.core.contains_QMARK_.call(null,reagent.impl.template.these_inputs_have_selection_api,input_type);
});
reagent.impl.template.input_set_value = (function reagent$impl$template$input_set_value(this$){
if(cljs.core.truth_((this$["cljsInputLive"]))){
(this$["cljsInputDirty"] = false);
var rendered_value = (this$["cljsRenderedValue"]);
var dom_value = (this$["cljsDOMValue"]);
var node = reagent.impl.template.find_dom_node.call(null,this$);
if(cljs.core.not_EQ_.call(null,rendered_value,dom_value)){
if(!(((node === (document["activeElement"]))) && (reagent.impl.template.has_selection_api_QMARK_.call(null,(node["type"]))) && (typeof rendered_value === 'string') && (typeof dom_value === 'string'))){
(this$["cljsDOMValue"] = rendered_value);
return (node["value"] = rendered_value);
} else {
var node_value = (node["value"]);
if(cljs.core.not_EQ_.call(null,node_value,dom_value)){
return reagent.impl.batching.do_after_render.call(null,((function (node_value,rendered_value,dom_value,node){
return (function (){
return reagent.impl.template.input_set_value.call(null,this$);
});})(node_value,rendered_value,dom_value,node))
);
} else {
var existing_offset_from_end = (cljs.core.count.call(null,node_value) - (node["selectionStart"]));
var new_cursor_offset = (cljs.core.count.call(null,rendered_value) - existing_offset_from_end);
(this$["cljsDOMValue"] = rendered_value);
(node["value"] = rendered_value);
(node["selectionStart"] = new_cursor_offset);
return (node["selectionEnd"] = new_cursor_offset);
}
}
} else {
return null;
}
} else {
return null;
}
});
reagent.impl.template.input_handle_change = (function reagent$impl$template$input_handle_change(this$,on_change,e){
(this$["cljsDOMValue"] = e.target.value);
if(cljs.core.truth_((this$["cljsInputDirty"]))){
} else {
(this$["cljsInputDirty"] = true);
reagent.impl.batching.do_after_render.call(null,(function (){
return reagent.impl.template.input_set_value.call(null,this$);
}));
}
return on_change.call(null,e);
});
reagent.impl.template.input_render_setup = (function reagent$impl$template$input_render_setup(this$,jsprops){
if(cljs.core.truth_((function (){var and__35486__auto__ = !((jsprops == null));
if(and__35486__auto__){
var and__35486__auto____$1 = jsprops.hasOwnProperty("onChange");
if(cljs.core.truth_(and__35486__auto____$1)){
return jsprops.hasOwnProperty("value");
} else {
return and__35486__auto____$1;
}
} else {
return and__35486__auto__;
}
})())){
if(cljs.core.truth_(reagent.impl.template.find_dom_node)){
} else {
throw (new Error(["Assert failed: ","reagent.dom needs to be loaded for controlled input to work","\n","find-dom-node"].join('')));
}
var v = (jsprops["value"]);
var value = (((v == null))?"":v);
var on_change = (jsprops["onChange"]);
if(cljs.core.truth_((this$["cljsInputLive"]))){
} else {
(this$["cljsInputLive"] = true);
(this$["cljsDOMValue"] = value);
}
(this$["cljsRenderedValue"] = value);
delete jsprops["value"];
var G__37673 = jsprops;
(G__37673["defaultValue"] = value);
(G__37673["onChange"] = ((function (G__37673,v,value,on_change){
return (function (p1__37672_SHARP_){
return reagent.impl.template.input_handle_change.call(null,this$,on_change,p1__37672_SHARP_);
});})(G__37673,v,value,on_change))
);
return G__37673;
} else {
return null;
}
});
reagent.impl.template.input_unmount = (function reagent$impl$template$input_unmount(this$){
return (this$["cljsInputLive"] = null);
});
reagent.impl.template.input_component_QMARK_ = (function reagent$impl$template$input_component_QMARK_(x){
var G__37674 = x;
switch (G__37674) {
case "input":
case "textarea":
return true;
break;
default:
return false;
}
});
reagent.impl.template.reagent_input_class = null;
reagent.impl.template.input_spec = new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"display-name","display-name",694513143),"ReagentInput",new cljs.core.Keyword(null,"component-did-update","component-did-update",-1468549173),reagent.impl.template.input_set_value,new cljs.core.Keyword(null,"component-will-unmount","component-will-unmount",-2058314698),reagent.impl.template.input_unmount,new cljs.core.Keyword(null,"reagent-render","reagent-render",-985383853),(function (argv,comp,jsprops,first_child){
var this$ = reagent.impl.component._STAR_current_component_STAR_;
reagent.impl.template.input_render_setup.call(null,this$,jsprops);
return reagent.impl.template.make_element.call(null,argv,comp,jsprops,first_child);
})], null);
reagent.impl.template.reagent_input = (function reagent$impl$template$reagent_input(){
if((reagent.impl.template.reagent_input_class == null)){
reagent.impl.template.reagent_input_class = reagent.impl.component.create_class.call(null,reagent.impl.template.input_spec);
} else {
}
return reagent.impl.template.reagent_input_class;
});
reagent.impl.template.parse_tag = (function reagent$impl$template$parse_tag(hiccup_tag){
var vec__37676 = cljs.core.next.call(null,cljs.core.re_matches.call(null,reagent.impl.template.re_tag,cljs.core.name.call(null,hiccup_tag)));
var tag = cljs.core.nth.call(null,vec__37676,(0),null);
var id = cljs.core.nth.call(null,vec__37676,(1),null);
var class$ = cljs.core.nth.call(null,vec__37676,(2),null);
var class$__$1 = (((class$ == null))?null:clojure.string.replace.call(null,class$,/\./," "));
if(cljs.core.truth_(tag)){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Invalid tag: '",cljs.core.str.cljs$core$IFn$_invoke$arity$1(hiccup_tag),"'",cljs.core.str.cljs$core$IFn$_invoke$arity$1(reagent.impl.component.comp_name.call(null))].join('')),"\n","tag"].join('')));
}
return ({"name": tag, "id": id, "className": class$__$1});
});
reagent.impl.template.try_get_key = (function reagent$impl$template$try_get_key(x){
try{return cljs.core.get.call(null,x,new cljs.core.Keyword(null,"key","key",-1516042587));
}catch (e37679){var e = e37679;
return null;
}});
reagent.impl.template.get_key = (function reagent$impl$template$get_key(x){
if(cljs.core.map_QMARK_.call(null,x)){
return reagent.impl.template.try_get_key.call(null,x);
} else {
return null;
}
});
reagent.impl.template.key_from_vec = (function reagent$impl$template$key_from_vec(v){
var temp__5459__auto__ = reagent.impl.template.get_key.call(null,cljs.core.meta.call(null,v));
if((temp__5459__auto__ == null)){
return reagent.impl.template.get_key.call(null,cljs.core.nth.call(null,v,(1),null));
} else {
var k = temp__5459__auto__;
return k;
}
});
reagent.impl.template.reag_element = (function reagent$impl$template$reag_element(tag,v){
var c = reagent.impl.component.as_class.call(null,tag);
var jsprops = ({"argv": v});
var temp__5461__auto___37680 = reagent.impl.template.key_from_vec.call(null,v);
if((temp__5461__auto___37680 == null)){
} else {
var key_37681 = temp__5461__auto___37680;
(jsprops["key"] = key_37681);
}
return (reagent.impl.util.react["createElement"])(c,jsprops);
});
reagent.impl.template.adapt_react_class = (function reagent$impl$template$adapt_react_class(c){
var G__37682 = reagent.impl.template.__GT_NativeWrapper.call(null);
(G__37682["name"] = c);
(G__37682["id"] = null);
(G__37682["class"] = null);
return G__37682;
});
reagent.impl.template.tag_name_cache = ({});
reagent.impl.template.cached_parse = (function reagent$impl$template$cached_parse(x){
var temp__5459__auto__ = reagent.impl.template.cache_get.call(null,reagent.impl.template.tag_name_cache,x);
if((temp__5459__auto__ == null)){
return (reagent.impl.template.tag_name_cache[x] = reagent.impl.template.parse_tag.call(null,x));
} else {
var s = temp__5459__auto__;
return s;
}
});
reagent.impl.template.native_element = (function reagent$impl$template$native_element(parsed,argv,first){
var comp = (parsed["name"]);
var props = cljs.core.nth.call(null,argv,first,null);
var hasprops = ((props == null)) || (cljs.core.map_QMARK_.call(null,props));
var jsprops = reagent.impl.template.convert_props.call(null,((hasprops)?props:null),parsed);
var first_child = (first + ((hasprops)?(1):(0)));
if(reagent.impl.template.input_component_QMARK_.call(null,comp)){
return reagent.impl.template.as_element.call(null,cljs.core.with_meta.call(null,new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [reagent.impl.template.reagent_input.call(null),argv,comp,jsprops,first_child], null),cljs.core.meta.call(null,argv)));
} else {
var key = reagent.impl.template.get_key.call(null,cljs.core.meta.call(null,argv));
var p = (((key == null))?jsprops:reagent.impl.template.oset.call(null,jsprops,"key",key));
return reagent.impl.template.make_element.call(null,argv,comp,p,first_child);
}
});
reagent.impl.template.str_coll = (function reagent$impl$template$str_coll(coll){
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(clojure.walk.prewalk.call(null,(function (x){
if(cljs.core.fn_QMARK_.call(null,x)){
var n = reagent.impl.util.fun_name.call(null,x);
var G__37683 = n;
switch (G__37683) {
case "":
return x;
break;
default:
return cljs.core.symbol.call(null,n);
}
} else {
return x;
}
}),coll))].join('');
});
reagent.impl.template.hiccup_err = (function reagent$impl$template$hiccup_err(var_args){
var args__36784__auto__ = [];
var len__36777__auto___37687 = arguments.length;
var i__36778__auto___37688 = (0);
while(true){
if((i__36778__auto___37688 < len__36777__auto___37687)){
args__36784__auto__.push((arguments[i__36778__auto___37688]));
var G__37689 = (i__36778__auto___37688 + (1));
i__36778__auto___37688 = G__37689;
continue;
} else {
}
break;
}
var argseq__36785__auto__ = ((((1) < args__36784__auto__.length))?(new cljs.core.IndexedSeq(args__36784__auto__.slice((1)),(0),null)):null);
return reagent.impl.template.hiccup_err.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__36785__auto__);
});
reagent.impl.template.hiccup_err.cljs$core$IFn$_invoke$arity$variadic = (function (v,msg){
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.apply.call(null,cljs.core.str,msg)),": ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(reagent.impl.template.str_coll.call(null,v)),"\n",cljs.core.str.cljs$core$IFn$_invoke$arity$1(reagent.impl.component.comp_name.call(null))].join('');
});
reagent.impl.template.hiccup_err.cljs$lang$maxFixedArity = (1);
reagent.impl.template.hiccup_err.cljs$lang$applyTo = (function (seq37685){
var G__37686 = cljs.core.first.call(null,seq37685);
var seq37685__$1 = cljs.core.next.call(null,seq37685);
return reagent.impl.template.hiccup_err.cljs$core$IFn$_invoke$arity$variadic(G__37686,seq37685__$1);
});
reagent.impl.template.vec_to_elem = (function reagent$impl$template$vec_to_elem(v){
while(true){
if((cljs.core.count.call(null,v) > (0))){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(reagent.impl.template.hiccup_err.call(null,v,"Hiccup form should not be empty")),"\n","(pos? (count v))"].join('')));
}
var tag = cljs.core.nth.call(null,v,(0),null);
if(reagent.impl.template.valid_tag_QMARK_.call(null,tag)){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(reagent.impl.template.hiccup_err.call(null,v,"Invalid Hiccup form")),"\n","(valid-tag? tag)"].join('')));
}
if(reagent.impl.template.hiccup_tag_QMARK_.call(null,tag)){
var n = cljs.core.name.call(null,tag);
var pos = n.indexOf(">");
var G__37690 = pos;
switch (G__37690) {
case (-1):
return reagent.impl.template.native_element.call(null,reagent.impl.template.cached_parse.call(null,n),v,(1));
break;
case (0):
var comp = cljs.core.nth.call(null,v,(1),null);
if(cljs.core._EQ_.call(null,">",n)){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(reagent.impl.template.hiccup_err.call(null,v,"Invalid Hiccup tag")),"\n","(= \">\" n)"].join('')));
}
if((typeof comp === 'string') || (cljs.core.fn_QMARK_.call(null,comp))){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(reagent.impl.template.hiccup_err.call(null,v,"Expected React component in")),"\n","(or (string? comp) (fn? comp))"].join('')));
}
return reagent.impl.template.native_element.call(null,({"name": comp}),v,(2));
break;
default:
var G__37692 = new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.subs.call(null,n,(0),pos),cljs.core.assoc.call(null,v,(0),cljs.core.subs.call(null,n,(pos + (1))))], null);
v = G__37692;
continue;
}
} else {
if((tag instanceof reagent.impl.template.NativeWrapper)){
return reagent.impl.template.native_element.call(null,tag,v,(1));
} else {
return reagent.impl.template.reag_element.call(null,tag,v);
}
}
break;
}
});
reagent.impl.template.as_element = (function reagent$impl$template$as_element(x){
if(reagent.impl.template.js_val_QMARK_.call(null,x)){
return x;
} else {
if(cljs.core.vector_QMARK_.call(null,x)){
return reagent.impl.template.vec_to_elem.call(null,x);
} else {
if(cljs.core.seq_QMARK_.call(null,x)){
return reagent.impl.template.expand_seq_check.call(null,x);
} else {
if(reagent.impl.template.named_QMARK_.call(null,x)){
return cljs.core.name.call(null,x);
} else {
if(((!((x == null)))?((((x.cljs$lang$protocol_mask$partition0$ & (2147483648))) || ((cljs.core.PROTOCOL_SENTINEL === x.cljs$core$IPrintWithWriter$)))?true:(((!x.cljs$lang$protocol_mask$partition0$))?cljs.core.native_satisfies_QMARK_.call(null,cljs.core.IPrintWithWriter,x):false)):cljs.core.native_satisfies_QMARK_.call(null,cljs.core.IPrintWithWriter,x))){
return cljs.core.pr_str.call(null,x);
} else {
return x;
}
}
}
}
}
});
reagent.impl.component.as_element = reagent.impl.template.as_element;
reagent.impl.template.expand_seq = (function reagent$impl$template$expand_seq(s){
var a = cljs.core.into_array.call(null,s);
var n__36543__auto___37694 = a.length;
var i_37695 = (0);
while(true){
if((i_37695 < n__36543__auto___37694)){
(a[i_37695] = reagent.impl.template.as_element.call(null,(a[i_37695])));
var G__37696 = (i_37695 + (1));
i_37695 = G__37696;
continue;
} else {
}
break;
}
return a;
});
reagent.impl.template.expand_seq_dev = (function reagent$impl$template$expand_seq_dev(s,o){
var a = cljs.core.into_array.call(null,s);
var n__36543__auto___37697 = a.length;
var i_37698 = (0);
while(true){
if((i_37698 < n__36543__auto___37697)){
var val_37699 = (a[i_37698]);
if((cljs.core.vector_QMARK_.call(null,val_37699)) && ((reagent.impl.template.key_from_vec.call(null,val_37699) == null))){
(o["no-key"] = true);
} else {
}
(a[i_37698] = reagent.impl.template.as_element.call(null,val_37699));
var G__37700 = (i_37698 + (1));
i_37698 = G__37700;
continue;
} else {
}
break;
}
return a;
});
reagent.impl.template.expand_seq_check = (function reagent$impl$template$expand_seq_check(x){
var ctx = ({});
var vec__37701 = reagent.ratom.check_derefs.call(null,((function (ctx){
return (function (){
return reagent.impl.template.expand_seq_dev.call(null,x,ctx);
});})(ctx))
);
var res = cljs.core.nth.call(null,vec__37701,(0),null);
var derefed = cljs.core.nth.call(null,vec__37701,(1),null);
if(cljs.core.truth_(derefed)){
if(cljs.core.truth_(reagent.debug.has_console)){
(cljs.core.truth_(reagent.debug.tracking)?reagent.debug.track_console:console).warn(["Warning: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(reagent.impl.template.hiccup_err.call(null,x,"Reactive deref not supported in lazy seq, ","it should be wrapped in doall"))].join(''));
} else {
}
} else {
}
if(cljs.core.truth_((ctx["no-key"]))){
if(cljs.core.truth_(reagent.debug.has_console)){
(cljs.core.truth_(reagent.debug.tracking)?reagent.debug.track_console:console).warn(["Warning: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(reagent.impl.template.hiccup_err.call(null,x,"Every element in a seq should have a unique :key"))].join(''));
} else {
}
} else {
}
return res;
});
reagent.impl.template.make_element = (function reagent$impl$template$make_element(argv,comp,jsprops,first_child){
var G__37704 = (cljs.core.count.call(null,argv) - first_child);
switch (G__37704) {
case (0):
return (reagent.impl.util.react["createElement"])(comp,jsprops);
break;
case (1):
return (reagent.impl.util.react["createElement"])(comp,jsprops,reagent.impl.template.as_element.call(null,cljs.core.nth.call(null,argv,first_child,null)));
break;
default:
return (reagent.impl.util.react["createElement"]).apply(null,cljs.core.reduce_kv.call(null,((function (G__37704){
return (function (a,k,v){
if((k >= first_child)){
a.push(reagent.impl.template.as_element.call(null,v));
} else {
}
return a;
});})(G__37704))
,[comp,jsprops],argv));
}
});
//# sourceMappingURL=template.js.map?rel=1517021941217
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"\/home\/didier\/clojupyter\/website\/target\/cljsbuild\/public\/js\/out\/reagent\/impl\/template.js","sources":["template.cljs?rel=1517021941219"],"lineCount":596,"mappings":";AAAA;;;;;;;;;;AAYA;;;;+BAAA,\/BAEEA;AAEF,AAAA;;;;;;AAAA;AAAA,AAAA,+CAAA,\/CAASK;AAAT,AAAA;;;AAAA,AAAA,qDAAA,rDAASA;;AAAT,AAAA,wDAAA,xDAASA;;AAAT,AAAA,6DAAA,WAAAJ,oBAAAC,sBAAAC,lHAASE;AAAT,AAAA,OAAAD,2BAAAF,sBAAA;;;AAAA,2CAAA,3CAASI;AAAT,AAAA,YAAAD;;;AAASA,AAKT,qCAAA,rCAAeE,kFAAQC;AAAvB,AACE,QAAI,cAAAC,bAAUD,qCACV,cAAAE,bAASF;;AAEf,0CAAA,1CAAeG,4FAAaH;AAA5B,AACE,QAAI,AAACD,6CAAOC,QACR,OAASA;;AAEf,yCAAA,zCAAeI,0FAAYJ;AAA3B,AACE,QAAI,AAACG,kDAAYH,QACb,AAACK,+BAAKL,QACN,cAAWH,bAAcG;;AAK\/B,wCAAA,WAAA,oBAAA,sBAAA,7FAAKM;AAIL,kCAAA,lCAAMC,4EAAWC,EAAEC;AAAnB,AACE,GAAM,AAA0BD,iBAAEC;AAAlC,AACE,QAAMD,EAAEC;;AADV;;;AAGF,yCAAA,zCAAMC,0FAAkBD;AAAxB,AACE,GAAI,AAACV,6CAAOU;AACV,IAAAE,qBAAa,AAACJ,0CAAUD,sCAAgB,AAACO,yBAAKJ;AAA9C,AAAA,GAAA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,4CAAA,5CAAKC;AAEL,AAAA,AAEA,mCAAA,2CAAA,oEAAA,eAAA,4HAAA,8HAAA,3ZAAKC,uPAEoB1B,gIACEsB,6GAExB,WAAKK,KAAKC,KAAKZ,QAAQa;AAAvB,AACE,IAAM5B,QAAK6B;AAAX,AACE,AAACf,mDAAmBd,MAAKe;;AACzB,OAACe,6CAAaJ,KAAKC,KAAKZ,QAAQa;;AAEvC,sCAAA,tCAAMG;AAAN,AACE,GAAM,8CAAA,7CAAMP;AAAZ,AACE,AAAMA,4CAAoB,AAACQ,8CAAkBP;;AAD\/C;;AAEAD;;AAKF,kCAAA,lCAAMS,4EAAWC;AAAjB,AACE,IAAAC,aAAqB,8GAAKD,zBAAWjE,5DAAK,4DAAA,5DAACqE,+BAAW1F,xDAAQ2F;UAA9D,AAAAH,wBAAAD,WAAA,IAAA,7CAAOE;SAAP,AAAAD,wBAAAD,WAAA,IAAA,5CAAW9C;aAAX,AAAA+C,wBAAAD,WAAA,IAAA,hDAAc7C;IACRA,aAAM,oBAAA,KAAA,vBAAU,WAAA,VAAMA,sBACd,wCAAA,KAAA,7CAACkD,iCAAelD;AAF9B,AAGE,oBAAQ+C;AAAR;AAAA,AAAA,MAAA,KAAApB,MAAA,CAAA,gPAAA,KAAA,vLAAY,CAAA,yEAAA,ZAAsBiB,4DACjB,AAACO;;;AAJpB,iBAKYJ,WACFhD,iBACOC;;AAEnB,oCAAA,pCAAMoD,gFAAatF;AAAnB,AAGE,IAAA,AAAK,iCAAA,1BAACwF,wBAAIxF;gBAAV,QAAAuF,JACqB9B;AADrB,AAAA;;AAGF,gCAAA,hCAAMgC,wEAASzF;AAAf,AACE,GAAM,AAACqB,+BAAKrB;AAAZ,Line truncated
+155
View File
@@ -0,0 +1,155 @@
(ns reagent.impl.util
(:require [cljsjs.react]
[cljsjs.create-react-class]
[reagent.debug :refer-macros [dbg log warn]]
[reagent.interop :refer-macros [$ $!]]
[clojure.string :as string]))
(defonce react
(cond (exists? js/React) js/React
(exists? js/require) (or (js/require "react")
(throw (js/Error. "require('react') failed")))
:else (throw (js/Error. "js/React is missing"))))
(defonce create-class
(cond (exists? js/createReactClass) js/createReactClass
(exists? js/require) (or (js/require "create-react-class")
(throw (js/Error. "require('create-react-class') failed")))
:else (throw (js/Error. "js/createReactClass is missing"))))
(def is-client (and (exists? js/window)
(-> js/window ($ :document) nil? not)))
(def ^:dynamic ^boolean *non-reactive* false)
;;; Props accessors
;; Misc utilities
(defn memoize-1 [f]
(let [mem (atom {})]
(fn [arg]
(let [v (get @mem arg)]
(if-not (nil? v)
v
(let [ret (f arg)]
(swap! mem assoc arg ret)
ret))))))
(def dont-camel-case #{"aria" "data"})
(defn capitalize [s]
(if (< (count s) 2)
(string/upper-case s)
(str (string/upper-case (subs s 0 1)) (subs s 1))))
(defn dash-to-camel [dashed]
(if (string? dashed)
dashed
(let [name-str (name dashed)
[start & parts] (string/split name-str #"-")]
(if (dont-camel-case start)
name-str
(apply str start (map capitalize parts))))))
(defn fun-name [f]
(let [n (or (and (fn? f)
(or ($ f :displayName)
($ f :name)))
(and (implements? INamed f)
(name f))
(let [m (meta f)]
(if (map? m)
(:name m))))]
(-> n
str
(clojure.string/replace "$" "."))))
(deftype PartialFn [pfn f args]
Fn
IFn
(-invoke [_]
(pfn))
(-invoke [_ a]
(pfn a))
(-invoke [_ a b]
(pfn a b))
(-invoke [_ a b c]
(pfn a b c))
(-invoke [_ a b c d]
(pfn a b c d))
(-invoke [_ a b c d e]
(pfn a b c d e))
(-invoke [_ a b c d e f]
(pfn a b c d e f))
(-invoke [_ a b c d e f g]
(pfn a b c d e f g))
(-invoke [_ a b c d e f g h]
(pfn a b c d e f g h))
(-invoke [_ a b c d e f g h i]
(pfn a b c d e f g h i))
(-invoke [_ a b c d e f g h i j]
(pfn a b c d e f g h i j))
(-invoke [_ a b c d e f g h i j k]
(pfn a b c d e f g h i j k))
(-invoke [_ a b c d e f g h i j k l]
(pfn a b c d e f g h i j k l))
(-invoke [_ a b c d e f g h i j k l m]
(pfn a b c d e f g h i j k l m))
(-invoke [_ a b c d e f g h i j k l m n]
(pfn a b c d e f g h i j k l m n))
(-invoke [_ a b c d e f g h i j k l m n o]
(pfn a b c d e f g h i j k l m n o))
(-invoke [_ a b c d e f g h i j k l m n o p]
(pfn a b c d e f g h i j k l m n o p))
(-invoke [_ a b c d e f g h i j k l m n o p q]
(pfn a b c d e f g h i j k l m n o p q))
(-invoke [_ a b c d e f g h i j k l m n o p q r]
(pfn a b c d e f g h i j k l m n o p q r))
(-invoke [_ a b c d e f g h i j k l m n o p q r s]
(pfn a b c d e f g h i j k l m n o p q r s))
(-invoke [_ a b c d e f g h i j k l m n o p q r s t]
(pfn a b c d e f g h i j k l m n o p q r s t))
(-invoke [_ a b c d e f g h i j k l m n o p q r s t rest]
(apply pfn a b c d e f g h i j k l m n o p q r s t rest))
IEquiv
(-equiv [_ other]
(and (= f (.-f other)) (= args (.-args other))))
IHash
(-hash [_] (hash [f args])))
(defn make-partial-fn [f args]
(->PartialFn (apply partial f args) f args))
(defn- merge-class [p1 p2]
(let [class (when-let [c1 (:class p1)]
(when-let [c2 (:class p2)]
(str c1 " " c2)))]
(if (nil? class)
p2
(assoc p2 :class class))))
(defn- merge-style [p1 p2]
(let [style (when-let [s1 (:style p1)]
(when-let [s2 (:style p2)]
(merge s1 s2)))]
(if (nil? style)
p2
(assoc p2 :style style))))
(defn merge-props [p1 p2]
(if (nil? p1)
p2
(do
(assert (map? p1)
(str "Property must be a map, not " (pr-str p1)))
(merge-style p1 (merge-class p1 (merge p1 p2))))))
(def ^:dynamic *always-update* false)
(defn force-update [comp deep]
(if deep
(binding [*always-update* true]
($ comp forceUpdate))
($ comp forceUpdate)))
@@ -0,0 +1 @@
{:rename-macros {}, :renames {}, :externs {React {}, require {}, Error {}, createReactClass {}, window {}}, :use-macros {log reagent.debug, dbg reagent.debug, $! reagent.interop, warn reagent.debug, $ reagent.interop}, :excludes #{}, :name reagent.impl.util, :imports nil, :requires {cljsjs.react cljsjs.react, cljsjs.create-react-class cljsjs.create-react-class, reagent.debug reagent.debug, reagent.interop reagent.interop, string clojure.string, clojure.string clojure.string}, :cljs.spec/speced-vars [], :uses nil, :defs {->PartialFn {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/util.cljs", :line 68, :column 10, :end-line 68, :end-column 19, :protocols #{cljs.core/IEquiv cljs.core/IHash cljs.core/IFn cljs.core/Fn}, :skip-protocol-flag #{cljs.core/IEquiv cljs.core/IHash cljs.core/IFn}, :factory :positional, :arglists (quote ([pfn f args]))}, :protocols #{cljs.core/IEquiv cljs.core/IHash cljs.core/IFn cljs.core/Fn}, :name reagent.impl.util/->PartialFn, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/util.cljs", :end-column 19, :method-params ([pfn f args]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :factory :positional, :line 68, :end-line 68, :max-fixed-arity 3, :fn-var true, :arglists (quote ([pfn f args])), :skip-protocol-flag #{cljs.core/IEquiv cljs.core/IHash cljs.core/IFn}}, merge-props {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/util.cljs", :line 140, :column 7, :end-line 140, :end-column 18, :arglists (quote ([p1 p2]))}, :name reagent.impl.util/merge-props, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/util.cljs", :end-column 18, :method-params ([p1 p2]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 140, :end-line 140, :max-fixed-arity 2, :fn-var true, :arglists (quote ([p1 p2]))}, capitalize {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/util.cljs", :line 41, :column 7, :end-line 41, :end-column 17, :arglists (quote ([s]))}, :name reagent.impl.util/capitalize, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/util.cljs", :end-column 17, :method-params ([s]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 41, :end-line 41, :max-fixed-arity 1, :fn-var true, :arglists (quote ([s]))}, react {:name reagent.impl.util/react, :file "target/cljsbuild/public/js/out/reagent/impl/util.cljs", :line 8, :column 1, :end-line 8, :end-column 15, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/util.cljs", :line 8, :column 10, :end-line 8, :end-column 15}, :tag js}, PartialFn {:num-fields 3, :protocols #{cljs.core/IEquiv cljs.core/IHash cljs.core/IFn cljs.core/Fn}, :name reagent.impl.util/PartialFn, :file "target/cljsbuild/public/js/out/reagent/impl/util.cljs", :end-column 19, :type true, :column 10, :line 68, :record false, :end-line 68, :skip-protocol-flag #{cljs.core/IEquiv cljs.core/IHash cljs.core/IFn}}, dash-to-camel {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/util.cljs", :line 46, :column 7, :end-line 46, :end-column 20, :arglists (quote ([dashed]))}, :name reagent.impl.util/dash-to-camel, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/util.cljs", :end-column 20, :method-params ([dashed]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 46, :end-line 46, :max-fixed-arity 1, :fn-var true, :arglists (quote ([dashed]))}, dont-camel-case {:name reagent.impl.util/dont-camel-case, :file "target/cljsbuild/public/js/out/reagent/impl/util.cljs", :line 39, :column 1, :end-line 39, :end-column 21, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/util.cljs", :line 39, :column 6, :end-line 39, :end-column 21}, :tag cljs.core/ISet}, merge-style {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/util.cljs", :line 132, :column 8, :end-line 132, :end-column 19, :private true, :arglists (quote ([p1 p2]))}, :private true, :name reagent.impl.util/merge-style, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/util.cljs", :end-column 19, :method-params ([p1 p2]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 132, :end-line 132, :max-fixed-arity 2, :fn-var true, :arglists (quote ([p1 p2]))}, memoize-1 {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/impl/util.cljs", :line 29, :column 7, :end-line 29, :end-column 16, :arglists (quote ([f]))}, :name reagent.impl.util/memoize-1, :variadic false, :file "target/cljsbuild/public/js/out/reagent/impl/util.cljs", :end-column 16, :method-params ([f]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 29, :end-line 29, :max-fixed-arity 1, :fnLine truncated
+574
View File
@@ -0,0 +1,574 @@
// Compiled by ClojureScript 1.9.946 {}
goog.provide('reagent.impl.util');
goog.require('cljs.core');
goog.require('cljsjs.react');
goog.require('cljsjs.create_react_class');
goog.require('reagent.debug');
goog.require('reagent.interop');
goog.require('clojure.string');
if(typeof reagent.impl.util.react !== 'undefined'){
} else {
reagent.impl.util.react = ((typeof React !== 'undefined')?React:((typeof require !== 'undefined')?(function (){var or__35498__auto__ = require("react");
if(cljs.core.truth_(or__35498__auto__)){
return or__35498__auto__;
} else {
throw (new Error("require('react') failed"));
}
})():(function(){throw (new Error("js/React is missing"))})()
));
}
if(typeof reagent.impl.util.create_class !== 'undefined'){
} else {
reagent.impl.util.create_class = ((typeof createReactClass !== 'undefined')?createReactClass:((typeof require !== 'undefined')?(function (){var or__35498__auto__ = require("create-react-class");
if(cljs.core.truth_(or__35498__auto__)){
return or__35498__auto__;
} else {
throw (new Error("require('create-react-class') failed"));
}
})():(function(){throw (new Error("js/createReactClass is missing"))})()
));
}
reagent.impl.util.is_client = (typeof window !== 'undefined') && (!(((window["document"]) == null)));
reagent.impl.util._STAR_non_reactive_STAR_ = false;
reagent.impl.util.memoize_1 = (function reagent$impl$util$memoize_1(f){
var mem = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
return ((function (mem){
return (function (arg){
var v = cljs.core.get.call(null,cljs.core.deref.call(null,mem),arg);
if(!((v == null))){
return v;
} else {
var ret = f.call(null,arg);
cljs.core.swap_BANG_.call(null,mem,cljs.core.assoc,arg,ret);
return ret;
}
});
;})(mem))
});
reagent.impl.util.dont_camel_case = new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 2, ["aria",null,"data",null], null), null);
reagent.impl.util.capitalize = (function reagent$impl$util$capitalize(s){
if((cljs.core.count.call(null,s) < (2))){
return clojure.string.upper_case.call(null,s);
} else {
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(clojure.string.upper_case.call(null,cljs.core.subs.call(null,s,(0),(1)))),cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.subs.call(null,s,(1)))].join('');
}
});
reagent.impl.util.dash_to_camel = (function reagent$impl$util$dash_to_camel(dashed){
if(typeof dashed === 'string'){
return dashed;
} else {
var name_str = cljs.core.name.call(null,dashed);
var vec__37386 = clojure.string.split.call(null,name_str,/-/);
var seq__37387 = cljs.core.seq.call(null,vec__37386);
var first__37388 = cljs.core.first.call(null,seq__37387);
var seq__37387__$1 = cljs.core.next.call(null,seq__37387);
var start = first__37388;
var parts = seq__37387__$1;
if(cljs.core.truth_(reagent.impl.util.dont_camel_case.call(null,start))){
return name_str;
} else {
return cljs.core.apply.call(null,cljs.core.str,start,cljs.core.map.call(null,reagent.impl.util.capitalize,parts));
}
}
});
reagent.impl.util.fun_name = (function reagent$impl$util$fun_name(f){
var n = (function (){var or__35498__auto__ = (function (){var and__35486__auto__ = cljs.core.fn_QMARK_.call(null,f);
if(and__35486__auto__){
var or__35498__auto__ = (f["displayName"]);
if(cljs.core.truth_(or__35498__auto__)){
return or__35498__auto__;
} else {
return (f["name"]);
}
} else {
return and__35486__auto__;
}
})();
if(cljs.core.truth_(or__35498__auto__)){
return or__35498__auto__;
} else {
var or__35498__auto____$1 = (function (){var and__35486__auto__ = ((!((f == null)))?((((f.cljs$lang$protocol_mask$partition1$ & (4096))) || ((cljs.core.PROTOCOL_SENTINEL === f.cljs$core$INamed$)))?true:false):false);
if(and__35486__auto__){
return cljs.core.name.call(null,f);
} else {
return and__35486__auto__;
}
})();
if(cljs.core.truth_(or__35498__auto____$1)){
return or__35498__auto____$1;
} else {
var m = cljs.core.meta.call(null,f);
if(cljs.core.map_QMARK_.call(null,m)){
return new cljs.core.Keyword(null,"name","name",1843675177).cljs$core$IFn$_invoke$arity$1(m);
} else {
return null;
}
}
}
})();
return clojure.string.replace.call(null,[cljs.core.str.cljs$core$IFn$_invoke$arity$1(n)].join(''),"$",".");
});
/**
* @constructor
* @implements {cljs.core.IEquiv}
* @implements {cljs.core.IHash}
* @implements {cljs.core.IFn}
* @implements {cljs.core.Fn}
*/
reagent.impl.util.PartialFn = (function (pfn,f,args){
this.pfn = pfn;
this.f = f;
this.args = args;
this.cljs$lang$protocol_mask$partition0$ = 6291457;
this.cljs$lang$protocol_mask$partition1$ = 0;
});
reagent.impl.util.PartialFn.prototype.cljs$core$Fn$ = cljs.core.PROTOCOL_SENTINEL;
reagent.impl.util.PartialFn.prototype.call = (function() {
var G__37394 = null;
var G__37394__1 = (function (self__){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return self__.pfn.call(null);
});
var G__37394__2 = (function (self__,a){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return self__.pfn.call(null,a);
});
var G__37394__3 = (function (self__,a,b){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return self__.pfn.call(null,a,b);
});
var G__37394__4 = (function (self__,a,b,c){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return self__.pfn.call(null,a,b,c);
});
var G__37394__5 = (function (self__,a,b,c,d){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return self__.pfn.call(null,a,b,c,d);
});
var G__37394__6 = (function (self__,a,b,c,d,e){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return self__.pfn.call(null,a,b,c,d,e);
});
var G__37394__7 = (function (self__,a,b,c,d,e,f__$1){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return self__.pfn.call(null,a,b,c,d,e,f__$1);
});
var G__37394__8 = (function (self__,a,b,c,d,e,f__$1,g){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g);
});
var G__37394__9 = (function (self__,a,b,c,d,e,f__$1,g,h){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h);
});
var G__37394__10 = (function (self__,a,b,c,d,e,f__$1,g,h,i){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i);
});
var G__37394__11 = (function (self__,a,b,c,d,e,f__$1,g,h,i,j){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j);
});
var G__37394__12 = (function (self__,a,b,c,d,e,f__$1,g,h,i,j,k){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j,k);
});
var G__37394__13 = (function (self__,a,b,c,d,e,f__$1,g,h,i,j,k,l){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j,k,l);
});
var G__37394__14 = (function (self__,a,b,c,d,e,f__$1,g,h,i,j,k,l,m){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j,k,l,m);
});
var G__37394__15 = (function (self__,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n);
});
var G__37394__16 = (function (self__,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o);
});
var G__37394__17 = (function (self__,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p);
});
var G__37394__18 = (function (self__,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q);
});
var G__37394__19 = (function (self__,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q,r){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q,r);
});
var G__37394__20 = (function (self__,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q,r,s){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q,r,s);
});
var G__37394__21 = (function (self__,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q,r,s,t){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q,r,s,t);
});
var G__37394__22 = (function (self__,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q,r,s,t,rest){
var self__ = this;
var self____$1 = this;
var _ = self____$1;
return cljs.core.apply.call(null,self__.pfn,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q,r,s,t,rest);
});
G__37394 = function(self__,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q,r,s,t,rest){
switch(arguments.length){
case 1:
return G__37394__1.call(this,self__);
case 2:
return G__37394__2.call(this,self__,a);
case 3:
return G__37394__3.call(this,self__,a,b);
case 4:
return G__37394__4.call(this,self__,a,b,c);
case 5:
return G__37394__5.call(this,self__,a,b,c,d);
case 6:
return G__37394__6.call(this,self__,a,b,c,d,e);
case 7:
return G__37394__7.call(this,self__,a,b,c,d,e,f__$1);
case 8:
return G__37394__8.call(this,self__,a,b,c,d,e,f__$1,g);
case 9:
return G__37394__9.call(this,self__,a,b,c,d,e,f__$1,g,h);
case 10:
return G__37394__10.call(this,self__,a,b,c,d,e,f__$1,g,h,i);
case 11:
return G__37394__11.call(this,self__,a,b,c,d,e,f__$1,g,h,i,j);
case 12:
return G__37394__12.call(this,self__,a,b,c,d,e,f__$1,g,h,i,j,k);
case 13:
return G__37394__13.call(this,self__,a,b,c,d,e,f__$1,g,h,i,j,k,l);
case 14:
return G__37394__14.call(this,self__,a,b,c,d,e,f__$1,g,h,i,j,k,l,m);
case 15:
return G__37394__15.call(this,self__,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n);
case 16:
return G__37394__16.call(this,self__,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o);
case 17:
return G__37394__17.call(this,self__,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p);
case 18:
return G__37394__18.call(this,self__,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q);
case 19:
return G__37394__19.call(this,self__,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q,r);
case 20:
return G__37394__20.call(this,self__,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q,r,s);
case 21:
return G__37394__21.call(this,self__,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q,r,s,t);
case 22:
return G__37394__22.call(this,self__,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q,r,s,t,rest);
}
throw(new Error('Invalid arity: ' + (arguments.length - 1)));
};
G__37394.cljs$core$IFn$_invoke$arity$1 = G__37394__1;
G__37394.cljs$core$IFn$_invoke$arity$2 = G__37394__2;
G__37394.cljs$core$IFn$_invoke$arity$3 = G__37394__3;
G__37394.cljs$core$IFn$_invoke$arity$4 = G__37394__4;
G__37394.cljs$core$IFn$_invoke$arity$5 = G__37394__5;
G__37394.cljs$core$IFn$_invoke$arity$6 = G__37394__6;
G__37394.cljs$core$IFn$_invoke$arity$7 = G__37394__7;
G__37394.cljs$core$IFn$_invoke$arity$8 = G__37394__8;
G__37394.cljs$core$IFn$_invoke$arity$9 = G__37394__9;
G__37394.cljs$core$IFn$_invoke$arity$10 = G__37394__10;
G__37394.cljs$core$IFn$_invoke$arity$11 = G__37394__11;
G__37394.cljs$core$IFn$_invoke$arity$12 = G__37394__12;
G__37394.cljs$core$IFn$_invoke$arity$13 = G__37394__13;
G__37394.cljs$core$IFn$_invoke$arity$14 = G__37394__14;
G__37394.cljs$core$IFn$_invoke$arity$15 = G__37394__15;
G__37394.cljs$core$IFn$_invoke$arity$16 = G__37394__16;
G__37394.cljs$core$IFn$_invoke$arity$17 = G__37394__17;
G__37394.cljs$core$IFn$_invoke$arity$18 = G__37394__18;
G__37394.cljs$core$IFn$_invoke$arity$19 = G__37394__19;
G__37394.cljs$core$IFn$_invoke$arity$20 = G__37394__20;
G__37394.cljs$core$IFn$_invoke$arity$21 = G__37394__21;
G__37394.cljs$core$IFn$_invoke$arity$22 = G__37394__22;
return G__37394;
})()
;
reagent.impl.util.PartialFn.prototype.apply = (function (self__,args37393){
var self__ = this;
var self____$1 = this;
return self____$1.call.apply(self____$1,[self____$1].concat(cljs.core.aclone.call(null,args37393)));
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$0 = (function (){
var self__ = this;
var _ = this;
return self__.pfn.call(null);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$1 = (function (a){
var self__ = this;
var _ = this;
return self__.pfn.call(null,a);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$2 = (function (a,b){
var self__ = this;
var _ = this;
return self__.pfn.call(null,a,b);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$3 = (function (a,b,c){
var self__ = this;
var _ = this;
return self__.pfn.call(null,a,b,c);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$4 = (function (a,b,c,d){
var self__ = this;
var _ = this;
return self__.pfn.call(null,a,b,c,d);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$5 = (function (a,b,c,d,e){
var self__ = this;
var _ = this;
return self__.pfn.call(null,a,b,c,d,e);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$6 = (function (a,b,c,d,e,f__$1){
var self__ = this;
var _ = this;
return self__.pfn.call(null,a,b,c,d,e,f__$1);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$7 = (function (a,b,c,d,e,f__$1,g){
var self__ = this;
var _ = this;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$8 = (function (a,b,c,d,e,f__$1,g,h){
var self__ = this;
var _ = this;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$9 = (function (a,b,c,d,e,f__$1,g,h,i){
var self__ = this;
var _ = this;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$10 = (function (a,b,c,d,e,f__$1,g,h,i,j){
var self__ = this;
var _ = this;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$11 = (function (a,b,c,d,e,f__$1,g,h,i,j,k){
var self__ = this;
var _ = this;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j,k);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$12 = (function (a,b,c,d,e,f__$1,g,h,i,j,k,l){
var self__ = this;
var _ = this;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j,k,l);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$13 = (function (a,b,c,d,e,f__$1,g,h,i,j,k,l,m){
var self__ = this;
var _ = this;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j,k,l,m);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$14 = (function (a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n){
var self__ = this;
var _ = this;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$15 = (function (a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o){
var self__ = this;
var _ = this;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$16 = (function (a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p){
var self__ = this;
var _ = this;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$17 = (function (a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q){
var self__ = this;
var _ = this;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$18 = (function (a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q,r){
var self__ = this;
var _ = this;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q,r);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$19 = (function (a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q,r,s){
var self__ = this;
var _ = this;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q,r,s);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$20 = (function (a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q,r,s,t){
var self__ = this;
var _ = this;
return self__.pfn.call(null,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q,r,s,t);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IFn$_invoke$arity$21 = (function (a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q,r,s,t,rest){
var self__ = this;
var _ = this;
return cljs.core.apply.call(null,self__.pfn,a,b,c,d,e,f__$1,g,h,i,j,k,l,m,n,o,p,q,r,s,t,rest);
});
reagent.impl.util.PartialFn.prototype.cljs$core$IEquiv$_equiv$arity$2 = (function (_,other){
var self__ = this;
var ___$1 = this;
return (cljs.core._EQ_.call(null,self__.f,other.f)) && (cljs.core._EQ_.call(null,self__.args,other.args));
});
reagent.impl.util.PartialFn.prototype.cljs$core$IHash$_hash$arity$1 = (function (_){
var self__ = this;
var ___$1 = this;
return cljs.core.hash.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [self__.f,self__.args], null));
});
reagent.impl.util.PartialFn.getBasis = (function (){
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"pfn","pfn",-513383568,null),new cljs.core.Symbol(null,"f","f",43394975,null),new cljs.core.Symbol(null,"args","args",-1338879193,null)], null);
});
reagent.impl.util.PartialFn.cljs$lang$type = true;
reagent.impl.util.PartialFn.cljs$lang$ctorStr = "reagent.impl.util/PartialFn";
reagent.impl.util.PartialFn.cljs$lang$ctorPrWriter = (function (this__36169__auto__,writer__36170__auto__,opt__36171__auto__){
return cljs.core._write.call(null,writer__36170__auto__,"reagent.impl.util/PartialFn");
});
reagent.impl.util.__GT_PartialFn = (function reagent$impl$util$__GT_PartialFn(pfn,f,args){
return (new reagent.impl.util.PartialFn(pfn,f,args));
});
reagent.impl.util.make_partial_fn = (function reagent$impl$util$make_partial_fn(f,args){
return reagent.impl.util.__GT_PartialFn.call(null,cljs.core.apply.call(null,cljs.core.partial,f,args),f,args);
});
reagent.impl.util.merge_class = (function reagent$impl$util$merge_class(p1,p2){
var class$ = (function (){var temp__5457__auto__ = new cljs.core.Keyword(null,"class","class",-2030961996).cljs$core$IFn$_invoke$arity$1(p1);
if(cljs.core.truth_(temp__5457__auto__)){
var c1 = temp__5457__auto__;
var temp__5457__auto____$1 = new cljs.core.Keyword(null,"class","class",-2030961996).cljs$core$IFn$_invoke$arity$1(p2);
if(cljs.core.truth_(temp__5457__auto____$1)){
var c2 = temp__5457__auto____$1;
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(c1)," ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(c2)].join('');
} else {
return null;
}
} else {
return null;
}
})();
if((class$ == null)){
return p2;
} else {
return cljs.core.assoc.call(null,p2,new cljs.core.Keyword(null,"class","class",-2030961996),class$);
}
});
reagent.impl.util.merge_style = (function reagent$impl$util$merge_style(p1,p2){
var style = (function (){var temp__5457__auto__ = new cljs.core.Keyword(null,"style","style",-496642736).cljs$core$IFn$_invoke$arity$1(p1);
if(cljs.core.truth_(temp__5457__auto__)){
var s1 = temp__5457__auto__;
var temp__5457__auto____$1 = new cljs.core.Keyword(null,"style","style",-496642736).cljs$core$IFn$_invoke$arity$1(p2);
if(cljs.core.truth_(temp__5457__auto____$1)){
var s2 = temp__5457__auto____$1;
return cljs.core.merge.call(null,s1,s2);
} else {
return null;
}
} else {
return null;
}
})();
if((style == null)){
return p2;
} else {
return cljs.core.assoc.call(null,p2,new cljs.core.Keyword(null,"style","style",-496642736),style);
}
});
reagent.impl.util.merge_props = (function reagent$impl$util$merge_props(p1,p2){
if((p1 == null)){
return p2;
} else {
if(cljs.core.map_QMARK_.call(null,p1)){
} else {
throw (new Error(["Assert failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(["Property must be a map, not ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.pr_str.call(null,p1))].join('')),"\n","(map? p1)"].join('')));
}
return reagent.impl.util.merge_style.call(null,p1,reagent.impl.util.merge_class.call(null,p1,cljs.core.merge.call(null,p1,p2)));
}
});
reagent.impl.util._STAR_always_update_STAR_ = false;
reagent.impl.util.force_update = (function reagent$impl$util$force_update(comp,deep){
if(cljs.core.truth_(deep)){
var _STAR_always_update_STAR_37395 = reagent.impl.util._STAR_always_update_STAR_;
reagent.impl.util._STAR_always_update_STAR_ = true;
try{return (comp["forceUpdate"])();
}finally {reagent.impl.util._STAR_always_update_STAR_ = _STAR_always_update_STAR_37395;
}} else {
return (comp["forceUpdate"])();
}
});
//# sourceMappingURL=util.js.map?rel=1517021940603
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"\/home\/didier\/clojupyter\/website\/target\/cljsbuild\/public\/js\/out\/reagent\/impl\/util.js","sources":["util.cljs?rel=1517021940607"],"lineCount":574,"mappings":";AAAA;;;;;;;AAOA,GAAA,OAASA;AAAT;AAAA,AAAA,AAASA,0BACP,sCAAA,pCAAM,OAASC,uBAAUA,QACnB,OAASC,yBAAY,iBAAAC,oBAAI,QAAA,RAACD;AAAL,AAAA,oBAAAC;AAAAA;;AACI,MAAO,KAAAC,MAAA;;KAFtC,AAGY,kBAAO,KAAAA,MAAA;;;AAErB,GAAA,OAASC;AAAT;AAAA,AAAA,AAASA,iCACP,4DAAA,1DAAM,OAASC,kCAAqBA,mBAC9B,OAASJ,yBAAY,iBAAAC,oBAAI,QAAA,RAACD;AAAL,AAAA,oBAAAC;AAAAA;;AACI,MAAO,KAAAC,MAAA;;KAFtC,AAGY,kBAAO,KAAAA,MAAA;;;AAErB,AAAKG,8BAAU,CAAK,OAASC,4BACT,EAAA,yBAAA,vBAAIA,DAAU,QAAA;AAElC,6CAAA,7CAAwBC;AAMxB,8BAAA,9BAAMC,oEAAWC;AAAjB,AACE,IAAMC,MAAI,yBAAA,zBAACC;AAAX,AACE;kBAAKC;AAAL,AACE,IAAMC,IAAE,wBAAA,AAAAC,xBAACC,kDAAKL,KAAIE;AAAlB,AACE,GAAA,EAAQ,MAAA,LAAMC;AACZA;;AACA,IAA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AEC,EAAEC,EAAE1B,EAAELine truncated
+2
View File
@@ -0,0 +1,2 @@
(ns reagent.interop
(:require-macros [reagent.interop]))
@@ -0,0 +1 @@
{:rename-macros {}, :renames {}, :use-macros {}, :excludes #{}, :name reagent.interop, :imports nil, :requires nil, :cljs.spec/speced-vars [], :uses nil, :cljs.spec/registry-ref [], :require-macros {reagent.interop reagent.interop}, :doc nil}
+5
View File
@@ -0,0 +1,5 @@
// Compiled by ClojureScript 1.9.946 {}
goog.provide('reagent.interop');
goog.require('cljs.core');
//# sourceMappingURL=interop.js.map?rel=1517021940281
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"\/home\/didier\/clojupyter\/website\/target\/cljsbuild\/public\/js\/out\/reagent\/interop.js","sources":["interop.cljs?rel=1517021940281"],"lineCount":5,"mappings":";AAAA","names":[]}
+592
View File
@@ -0,0 +1,592 @@
(ns reagent.ratom
(:refer-clojure :exclude [atom])
(:require-macros [reagent.ratom :refer [with-let]])
(:require [reagent.impl.util :as util]
[reagent.debug :refer-macros [dbg log warn error dev? time]]
[reagent.impl.batching :as batch]
[clojure.set :as s]))
(declare ^:dynamic *ratom-context*)
(defonce ^boolean debug false)
(defonce ^:private generation 0)
(defonce ^:private -running (clojure.core/atom 0))
(defn ^boolean reactive? []
(some? *ratom-context*))
;;; Utilities
(defn running []
(+ @-running))
(defn- ^number arr-len [x]
(if (nil? x) 0 (alength x)))
(defn- ^boolean arr-eq [x y]
(let [len (arr-len x)]
(and (== len (arr-len y))
(loop [i 0]
(or (== i len)
(if (identical? (aget x i) (aget y i))
(recur (inc i))
false))))))
(defn- in-context [obj f]
(binding [*ratom-context* obj]
(f)))
(defn- deref-capture [f r]
(set! (.-captured r) nil)
(when (dev?)
(set! (.-ratomGeneration r) (set! generation (inc generation))))
(let [res (in-context r f)
c (.-captured r)]
(set! (.-dirty? r) false)
;; Optimize common case where derefs occur in same order
(when-not (arr-eq c (.-watching r))
(._update-watching r c))
res))
(defn- notify-deref-watcher! [derefed]
(when-some [r *ratom-context*]
(let [c (.-captured r)]
(if (nil? c)
(set! (.-captured r) (array derefed))
(.push c derefed)))))
(defn- check-watches [old new]
(when debug
(swap! -running + (- (count new) (count old))))
new)
(defn- add-w [this key f]
(let [w (.-watches this)]
(set! (.-watches this) (check-watches w (assoc w key f)))
(set! (.-watchesArr this) nil)))
(defn- remove-w [this key]
(let [w (.-watches this)]
(set! (.-watches this) (check-watches w (dissoc w key)))
(set! (.-watchesArr this) nil)))
(defn- notify-w [this old new]
(let [w (.-watchesArr this)
a (if (nil? w)
;; Copy watches to array for speed
(->> (.-watches this)
(reduce-kv #(doto %1 (.push %2) (.push %3)) #js[])
(set! (.-watchesArr this)))
w)]
(let [len (alength a)]
(loop [i 0]
(when (< i len)
(let [k (aget a i)
f (aget a (inc i))]
(f k this old new))
(recur (+ 2 i)))))))
(defn- pr-atom [a writer opts s]
(-write writer (str "#<" s " "))
(pr-writer (binding [*ratom-context* nil] (-deref a)) writer opts)
(-write writer ">"))
;;; Queueing
(defonce ^:private rea-queue nil)
(defn- rea-enqueue [r]
(when (nil? rea-queue)
(set! rea-queue (array))
(batch/schedule))
(.push rea-queue r))
(defn flush! []
(loop []
(let [q rea-queue]
(when-not (nil? q)
(set! rea-queue nil)
(dotimes [i (alength q)]
(._queued-run (aget q i)))
(recur)))))
(set! batch/ratom-flush flush!)
;;; Atom
(defprotocol IReactiveAtom)
(deftype RAtom [^:mutable state meta validator ^:mutable watches]
IAtom
IReactiveAtom
IEquiv
(-equiv [o other] (identical? o other))
IDeref
(-deref [this]
(notify-deref-watcher! this)
state)
IReset
(-reset! [a new-value]
(when-not (nil? validator)
(assert (validator new-value) "Validator rejected reference state"))
(let [old-value state]
(set! state new-value)
(when-not (nil? watches)
(notify-w a old-value new-value))
new-value))
ISwap
(-swap! [a f] (-reset! a (f state)))
(-swap! [a f x] (-reset! a (f state x)))
(-swap! [a f x y] (-reset! a (f state x y)))
(-swap! [a f x y more] (-reset! a (apply f state x y more)))
IMeta
(-meta [_] meta)
IPrintWithWriter
(-pr-writer [a w opts] (pr-atom a w opts "Atom:"))
IWatchable
(-notify-watches [this old new] (notify-w this old new))
(-add-watch [this key f] (add-w this key f))
(-remove-watch [this key] (remove-w this key))
IHash
(-hash [this] (goog/getUid this)))
(defn atom
"Like clojure.core/atom, except that it keeps track of derefs."
([x] (->RAtom x nil nil nil))
([x & {:keys [meta validator]}] (->RAtom x meta validator nil)))
;;; track
(declare make-reaction)
(def ^{:private true :const true} cache-key "reagReactionCache")
(defn- cached-reaction [f o k obj destroy]
(let [m (aget o cache-key)
m (if (nil? m) {} m)
r (m k nil)]
(cond
(some? r) (-deref r)
(nil? *ratom-context*) (f)
:else (let [r (make-reaction
f :on-dispose (fn [x]
(when debug (swap! -running dec))
(as-> (aget o cache-key) _
(dissoc _ k)
(aset o cache-key _))
(when (some? obj)
(set! (.-reaction obj) nil))
(when (some? destroy)
(destroy x))))
v (-deref r)]
(aset o cache-key (assoc m k r))
(when debug (swap! -running inc))
(when (some? obj)
(set! (.-reaction obj) r))
v))))
(deftype Track [f args ^:mutable reaction]
IReactiveAtom
IDeref
(-deref [this]
(if-some [r reaction]
(-deref r)
(cached-reaction #(apply f args) f args this nil)))
IEquiv
(-equiv [_ other]
(and (instance? Track other)
(= f (.-f other))
(= args (.-args other))))
IHash
(-hash [_] (hash [f args]))
IPrintWithWriter
(-pr-writer [a w opts] (pr-atom a w opts "Track:")))
(defn make-track [f args]
(Track. f args nil))
(defn make-track! [f args]
(let [t (make-track f args)
r (make-reaction #(-deref t)
:auto-run true)]
@r
r))
(defn track [f & args]
{:pre [(ifn? f)]}
(make-track f args))
(defn track! [f & args]
{:pre [(ifn? f)]}
(make-track! f args))
;;; cursor
(deftype RCursor [ratom path ^:mutable reaction
^:mutable state ^:mutable watches]
IAtom
IReactiveAtom
IEquiv
(-equiv [_ other]
(and (instance? RCursor other)
(= path (.-path other))
(= ratom (.-ratom other))))
Object
(_peek [this]
(binding [*ratom-context* nil]
(-deref this)))
(_set-state [this oldstate newstate]
(when-not (identical? oldstate newstate)
(set! state newstate)
(when (some? watches)
(notify-w this oldstate newstate))))
IDeref
(-deref [this]
(let [oldstate state
newstate (if-some [r reaction]
(-deref r)
(let [f (if (satisfies? IDeref ratom)
#(get-in @ratom path)
#(ratom path))]
(cached-reaction f ratom path this nil)))]
(._set-state this oldstate newstate)
newstate))
IReset
(-reset! [this new-value]
(let [oldstate state]
(._set-state this oldstate new-value)
(if (satisfies? IDeref ratom)
(if (= path [])
(reset! ratom new-value)
(swap! ratom assoc-in path new-value))
(ratom path new-value))
new-value))
ISwap
(-swap! [a f] (-reset! a (f (._peek a))))
(-swap! [a f x] (-reset! a (f (._peek a) x)))
(-swap! [a f x y] (-reset! a (f (._peek a) x y)))
(-swap! [a f x y more] (-reset! a (apply f (._peek a) x y more)))
IPrintWithWriter
(-pr-writer [a w opts] (pr-atom a w opts (str "Cursor: " path)))
IWatchable
(-notify-watches [this old new] (notify-w this old new))
(-add-watch [this key f] (add-w this key f))
(-remove-watch [this key] (remove-w this key))
IHash
(-hash [_] (hash [ratom path])))
(defn cursor
[src path]
(assert (or (satisfies? IReactiveAtom src)
(and (ifn? src)
(not (vector? src))))
(str "src must be a reactive atom or a function, not "
(pr-str src)))
(->RCursor src path nil nil nil))
;;; with-let support
(defn with-let-destroy [v]
(when-some [f (.-destroy v)]
(f)))
(defn with-let-values [key]
(if-some [c *ratom-context*]
(cached-reaction array c key
nil with-let-destroy)
(array)))
;;;; reaction
(defprotocol IDisposable
(dispose! [this])
(add-on-dispose! [this f]))
(defprotocol IRunnable
(run [this]))
(defn- handle-reaction-change [this sender old new]
(._handle-change this sender old new))
(deftype Reaction [f ^:mutable state ^:mutable ^boolean dirty? ^boolean nocache?
^:mutable watching ^:mutable watches ^:mutable auto-run
^:mutable caught]
IAtom
IReactiveAtom
IWatchable
(-notify-watches [this old new] (notify-w this old new))
(-add-watch [this key f] (add-w this key f))
(-remove-watch [this key]
(let [was-empty (empty? watches)]
(remove-w this key)
(when (and (not was-empty)
(empty? watches)
(nil? auto-run))
(dispose! this))))
IReset
(-reset! [a newval]
(assert (fn? (.-on-set a)) "Reaction is read only; on-set is not allowed")
(let [oldval state]
(set! state newval)
(.on-set a oldval newval)
(notify-w a oldval newval)
newval))
ISwap
(-swap! [a f] (-reset! a (f (._peek-at a))))
(-swap! [a f x] (-reset! a (f (._peek-at a) x)))
(-swap! [a f x y] (-reset! a (f (._peek-at a) x y)))
(-swap! [a f x y more] (-reset! a (apply f (._peek-at a) x y more)))
Object
(_peek-at [this]
(binding [*ratom-context* nil]
(-deref this)))
(_handle-change [this sender oldval newval]
(when-not (or (identical? oldval newval)
dirty?)
(if (nil? auto-run)
(do
(set! dirty? true)
(rea-enqueue this))
(if (true? auto-run)
(._run this false)
(auto-run this)))))
(_update-watching [this derefed]
(let [new (set derefed)
old (set watching)]
(set! watching derefed)
(doseq [w (s/difference new old)]
(-add-watch w this handle-reaction-change))
(doseq [w (s/difference old new)]
(-remove-watch w this))))
(_queued-run [this]
(when (and dirty? (some? watching))
(._run this true)))
(_try-capture [this f]
(try
(set! caught nil)
(deref-capture f this)
(catch :default e
(set! state e)
(set! caught e)
(set! dirty? false))))
(_run [this check]
(let [oldstate state
res (if check
(._try-capture this f)
(deref-capture f this))]
(when-not nocache?
(set! state res)
;; Use = to determine equality from reactions, since
;; they are likely to produce new data structures.
(when-not (or (nil? watches)
(= oldstate res))
(notify-w this oldstate res)))
res))
(_set-opts [this {:keys [auto-run on-set on-dispose no-cache]}]
(when (some? auto-run)
(set! (.-auto-run this) auto-run))
(when (some? on-set)
(set! (.-on-set this) on-set))
(when (some? on-dispose)
(set! (.-on-dispose this) on-dispose))
(when (some? no-cache)
(set! (.-nocache? this) no-cache)))
IRunnable
(run [this]
(flush!)
(._run this false))
IDeref
(-deref [this]
(when-some [e caught]
(throw e))
(let [non-reactive (nil? *ratom-context*)]
(when non-reactive
(flush!))
(if (and non-reactive (nil? auto-run))
(when dirty?
(let [oldstate state]
(set! state (f))
(when-not (or (nil? watches) (= oldstate state))
(notify-w this oldstate state))))
(do
(notify-deref-watcher! this)
(when dirty?
(._run this false)))))
state)
IDisposable
(dispose! [this]
(let [s state
wg watching]
(set! watching nil)
(set! state nil)
(set! auto-run nil)
(set! dirty? true)
(doseq [w (set wg)]
(-remove-watch w this))
(when (some? (.-on-dispose this))
(.on-dispose this s))
(when-some [a (.-on-dispose-arr this)]
(dotimes [i (alength a)]
((aget a i) this)))))
(add-on-dispose! [this f]
;; f is called with the reaction as argument when it is no longer active
(if-some [a (.-on-dispose-arr this)]
(.push a f)
(set! (.-on-dispose-arr this) (array f))))
IEquiv
(-equiv [o other] (identical? o other))
IPrintWithWriter
(-pr-writer [a w opts] (pr-atom a w opts (str "Reaction " (hash a) ":")))
IHash
(-hash [this] (goog/getUid this)))
(defn make-reaction [f & {:keys [auto-run on-set on-dispose]}]
(let [reaction (->Reaction f nil true false nil nil nil nil)]
(._set-opts reaction {:auto-run auto-run
:on-set on-set
:on-dispose on-dispose})
reaction))
(def ^:private temp-reaction (make-reaction nil))
(defn run-in-reaction [f obj key run opts]
(let [r temp-reaction
res (deref-capture f r)]
(when-not (nil? (.-watching r))
(set! temp-reaction (make-reaction nil))
(._set-opts r opts)
(set! (.-f r) f)
(set! (.-auto-run r) #(run obj))
(aset obj key r))
res))
(defn check-derefs [f]
(let [ctx (js-obj)
res (in-context ctx f)]
[res (some? (.-captured ctx))]))
;;; wrap
(deftype Wrapper [^:mutable state callback ^:mutable ^boolean changed
^:mutable watches]
IAtom
IDeref
(-deref [this]
(when (dev?)
(when (and changed (some? *ratom-context*))
(warn "derefing stale wrap: "
(pr-str this))))
state)
IReset
(-reset! [this newval]
(let [oldval state]
(set! changed true)
(set! state newval)
(when (some? watches)
(notify-w this oldval newval))
(callback newval)
newval))
ISwap
(-swap! [a f] (-reset! a (f state)))
(-swap! [a f x] (-reset! a (f state x)))
(-swap! [a f x y] (-reset! a (f state x y)))
(-swap! [a f x y more] (-reset! a (apply f state x y more)))
IEquiv
(-equiv [_ other]
(and (instance? Wrapper other)
;; If either of the wrappers have changed, equality
;; cannot be relied on.
(not changed)
(not (.-changed other))
(= state (.-state other))
(= callback (.-callback other))))
IWatchable
(-notify-watches [this old new] (notify-w this old new))
(-add-watch [this key f] (add-w this key f))
(-remove-watch [this key] (remove-w this key))
IPrintWithWriter
(-pr-writer [a w opts] (pr-atom a w opts "Wrap:")))
(defn make-wrapper [value callback-fn args]
(->Wrapper value
(util/make-partial-fn callback-fn args)
false nil))
#_(do
(defn ratom-perf []
(set! debug false)
(dotimes [_ 10]
(let [nite 100000
a (atom 0)
f (fn []
(quot @a 10))
mid (make-reaction f)
res (track! (fn []
;; (with-let [x 1])
;; @(track f)
(inc @mid)
))]
@res
(time (dotimes [x nite]
(swap! a inc)
(flush!)))
(dispose! res))))
(ratom-perf))
+1
View File
@@ -0,0 +1 @@
{:rename-macros {}, :renames {}, :externs {Error {}, console {}}, :use-macros {with-let reagent.ratom, log reagent.debug, dbg reagent.debug, warn reagent.debug, dev? reagent.debug, time reagent.debug, error reagent.debug}, :excludes #{atom}, :name reagent.ratom, :imports nil, :requires {util reagent.impl.util, reagent.impl.util reagent.impl.util, reagent.debug reagent.debug, batch reagent.impl.batching, reagent.impl.batching reagent.impl.batching, s clojure.set, clojure.set clojure.set}, :cljs.spec/speced-vars [], :uses nil, :defs {pr-atom {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/ratom.cljs", :line 89, :column 8, :end-line 89, :end-column 15, :private true, :arglists (quote ([a writer opts s]))}, :private true, :name reagent.ratom/pr-atom, :variadic false, :file "target/cljsbuild/public/js/out/reagent/ratom.cljs", :end-column 15, :method-params ([a writer opts s]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 89, :end-line 89, :max-fixed-arity 4, :fn-var true, :arglists (quote ([a writer opts s]))}, ->RCursor {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/ratom.cljs", :line 240, :column 10, :end-line 240, :end-column 17, :protocols #{cljs.core/IWatchable cljs.core/IAtom cljs.core/IEquiv cljs.core/IHash cljs.core/IReset cljs.core/ISwap reagent.ratom/IReactiveAtom cljs.core/IDeref cljs.core/IPrintWithWriter reagent.ratom/Object}, :skip-protocol-flag #{cljs.core/IWatchable cljs.core/IAtom cljs.core/IEquiv cljs.core/IHash cljs.core/IReset cljs.core/ISwap cljs.core/IDeref cljs.core/IPrintWithWriter}, :factory :positional, :arglists (quote ([ratom path reaction state watches]))}, :protocols #{cljs.core/IWatchable cljs.core/IAtom cljs.core/IEquiv cljs.core/IHash cljs.core/IReset cljs.core/ISwap reagent.ratom/IReactiveAtom cljs.core/IDeref cljs.core/IPrintWithWriter reagent.ratom/Object}, :name reagent.ratom/->RCursor, :variadic false, :file "target/cljsbuild/public/js/out/reagent/ratom.cljs", :end-column 17, :method-params ([ratom path reaction state watches]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :factory :positional, :line 240, :end-line 240, :max-fixed-arity 5, :fn-var true, :arglists (quote ([ratom path reaction state watches])), :skip-protocol-flag #{cljs.core/IWatchable cljs.core/IAtom cljs.core/IEquiv cljs.core/IHash cljs.core/IReset cljs.core/ISwap cljs.core/IDeref cljs.core/IPrintWithWriter}}, notify-deref-watcher! {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/ratom.cljs", :line 51, :column 8, :end-line 51, :end-column 29, :private true, :arglists (quote ([derefed]))}, :private true, :name reagent.ratom/notify-deref-watcher!, :variadic false, :file "target/cljsbuild/public/js/out/reagent/ratom.cljs", :end-column 29, :method-params ([derefed]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 51, :end-line 51, :max-fixed-arity 1, :fn-var true, :arglists (quote ([derefed]))}, rea-enqueue {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/ratom.cljs", :line 99, :column 8, :end-line 99, :end-column 19, :private true, :arglists (quote ([r]))}, :private true, :name reagent.ratom/rea-enqueue, :variadic false, :file "target/cljsbuild/public/js/out/reagent/ratom.cljs", :end-column 19, :method-params ([r]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 99, :end-line 99, :max-fixed-arity 1, :fn-var true, :arglists (quote ([r]))}, in-context {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/ratom.cljs", :line 35, :column 8, :end-line 35, :end-column 18, :private true, :arglists (quote ([obj f]))}, :private true, :name reagent.ratom/in-context, :variadic false, :file "target/cljsbuild/public/js/out/reagent/ratom.cljs", :end-column 18, :method-params ([obj f]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 35, :end-line 35, :max-fixed-arity 2, :fn-var true, :arglists (quote ([obj f]))}, make-track {:protocol-inline nil, :meta {:file "/home/didier/clojupyter/website/target/cljsbuild/public/js/out/reagent/ratom.cljs", :line 220, :column 7, :end-line 220, :end-column 17, :arglists (quote ([f args]))}, :name reagent.ratom/make-track, :variadic false, :file "target/cljsbuild/public/js/out/reagent/ratom.cljs", :end-column 17, :method-params ([f args]), :protocol-impl nil, :arglists-meta (nil nil), :column 1, :line 220, :end-line 220, :max-fixed-arity 2, :fn-var true, :arglists (quote ([f args]))}, RAtom {:num-fields 4, :protocols #{cljs.core/IWatchable cljs.core/IAtom cljs.core/IEquiv cljs.core/IHash cljs.core/IReset cljs.core/ISwap reagent.ratom/IReactiveAtom cljs.core/IMeta cljs.core/IDeref cljs.core/IPrintWithWriter}, :name reagent.ratom/RAtom, :file "target/cljsbuild/public/js/out/reagent/ratom.cljs", :end-column 15, :type true, :columnLine truncated
File diff suppressed because it is too large. Load diff
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"\/home\/didier\/clojupyter\/website\/target\/cljsbuild\/public\/js\/out\/reagent\/ratom.js","sources":["ratom.cljs?rel=1517021940991"],"lineCount":1575,"mappings":";AAAA;;;;;;AAQA,AAAA,AACA,GAAA,OAAkBA;AAAlB;AA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