Remove bundled React

No longer needed, since we use cljsjs/react instead.

Also remove obsolete interop macros, and some general cleanup
This commit is contained in:
Dan Holmsand 2015-02-01 15:13:08 +01:00
parent 58fd72cd86
commit 83fd1361df
8 changed files with 5 additions and 18237 deletions

View File

@ -1,7 +1,5 @@
REACT_VERSION = 0.12.2
PROF =
PORT = 3449
@ -94,12 +92,6 @@ gh-pages-add:
show-outdated:
lein ancient :all
download-react:
curl -L "http://fb.me/react-$(REACT_VERSION).js" \
-o vendor/reagent/react.js
curl -L "http://fb.me/react-$(REACT_VERSION).min.js" \
-o vendor/reagent/react.min.js
VERSION := `sed -n -e '/(defproject reagent/ s/.*"\(.*\)"/\1/p' project.clj`
setversion:

View File

@ -1,10 +1,5 @@
(ns reagentdemo.news
(:require [reagent.core :as reagent :refer [atom]]
[reagent.interop :refer-macros [.' .!]]
[reagent.debug :refer-macros [dbg println]]
[reagentdemo.common :as common :refer [demo-component]]
[sitetools :as tools :refer [link]]
[reagentdemo.news.anyargs :as anyargs]
(:require [reagentdemo.news.anyargs :as anyargs]
[reagentdemo.news.async :as async]
[reagentdemo.news.undodemo :as undodemo]
[reagentdemo.news.clockpost :as clock]

View File

@ -42,7 +42,8 @@
(assert (or (nil? title)
(string? title)))
(swap! config update-in [:page-map] assoc pageurl comp)
(swap! config update-in [:page-titles] assoc pageurl title)))
(swap! config update-in [:page-titles] assoc pageurl title)
pageurl))
;;; Components

View File

@ -48,71 +48,3 @@
(let [[field names] (dot-args object field)]
(assert field (str "Field name must start with - in " field))
`(aset ~object ~@names ~value)))
(def js-imports (atom nil))
(defmacro import-js
[dev-src min-src sym-name]
(assert (string? dev-src))
(assert (string? min-src))
(assert (string? sym-name))
(let [impns (get @js-imports sym-name)]
(if (and (not (nil? impns))
(not= *ns* impns))
;; Our symbol was already imported in another namespace; so we avoid
;; duplicate imports.
true
(let [srcfile (if *assert* dev-src min-src)
sym sym-name
src (slurp (io/resource srcfile))]
(swap! js-imports assoc sym-name *ns*)
`(js/eval ~(str "if (typeof " sym " != 'undefined' && "
"typeof console != 'undefined') { "
"console.log('" sym " is already defined'); "
"} else { (function (exports, module) { "
src "; \n
if (typeof " sym " === 'undefined' && "
"typeof console != 'undefined') { "
"console.log('" sym " not defined in " srcfile "');
}
if (typeof global != 'undefined') {
global." sym " = " sym ";
} else if (typeof window != 'undefined') {
window." sym " = " sym ";
} })(); } \n
//@ sourceURL=" srcfile "\n"))))))
(defmacro import-react
[]
"Import React.js.
This can be used instead of adding :preamble in project.clj
(or adding react.js in a script tag). This may be more convenient when
using :optimizations :none, since that doesn't take :preamble into account.
Imports minimized version of React if :elide-asserts is true."
`(import-js "reagent/react.js" "reagent/react.min.js" "React"))
(defmacro fvar
[f]
(assert (symbol? f))
(let [fns (or (namespace f)
(str *ns*))
fref (str *ns* "/" f)]
`(let [f# (aget reagent.interop/fvars ~fref)]
(if-not (nil? f#)
f#
(do
(assert (not (nil? ~f))
~(str "undefined fn: " f))
(let [old# (aget ~f "-fvar")
v# (if (not (nil? old#))
old#
(doto #(.apply ~f nil (~'js* "arguments"))
(aset "name" (.-name ~f))
(aset "fvar" true)))]
(aset ~f "-fvar" v#)
(aset reagent.interop/fvars ~fref v#)))))))
(defmacro fvar?
[f]
`(and (fn? ~f)
(not (nil? (aget ~f "fvar")))))

View File

@ -1,4 +1,3 @@
(ns reagent.interop)
(def fvars #js {})
;; Empty

View File

@ -1,7 +1,7 @@
(ns testinterop
(:require [cljs.test :as t :refer-macros [is deftest]]
[reagent.debug :refer-macros [dbg]]
[reagent.interop :refer-macros [.' .! fvar fvar?]]))
[reagent.interop :refer-macros [.' .!]]))
(deftest iterop-quote
@ -48,22 +48,3 @@
(is (= "1bar2" (.' (.' o :foo)
call o 1)))))
(def f nil)
(deftest interop-fvar
(set! f (fn [& args] (into ["foo"] args)))
(let [f' (fvar f)]
(is (= ["foo"] (f')))
(is (= ["foo" 1] (f' 1)))
(is (= ["foo" 1 2] (f' 1 2)))
(is (= ["foo" 1 2 3] (f' 1 2 3)))
(set! f (fn [] "foobar"))
(is (= "foobar" (f')))
(is (identical? f' (fvar f)))
(is (fvar? f'))
(is (not (fvar? f)))
(is (fn? f'))))

18116
vendor/reagent/react.js vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long