From 767410d8d855c90692613f60eed42d8274faa4d2 Mon Sep 17 00:00:00 2001 From: Dan Holmsand Date: Sat, 21 Mar 2015 13:53:37 +0100 Subject: [PATCH 1/7] Update clojurescript, figwheel and cljsbuild. Stop using :figwheel-always, that seems to be broken in the new figwheel. --- demo/reagentdemo/core.cljs | 11 +++++++---- env/dev/reagentdemo/dev.cljs | 11 ++++++++--- project.clj | 11 ++++++----- test/reagenttest/runtests.cljs | 13 ++++++++----- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/demo/reagentdemo/core.cljs b/demo/reagentdemo/core.cljs index fbf57af..d846f7f 100644 --- a/demo/reagentdemo/core.cljs +++ b/demo/reagentdemo/core.cljs @@ -1,4 +1,4 @@ -(ns ^:figwheel-always reagentdemo.core +(ns reagentdemo.core (:require [reagent.core :as reagent :refer [atom]] [reagent.interop :as i :refer-macros [.' .!]] [clojure.string :as string] @@ -39,6 +39,9 @@ [tools/page-content] [github-badge]]) -(tools/start! {:body [#'demo] - :css-infiles ["site/public/css/examples.css" - "site/public/css/main.css"]}) +(defn init! [] + (tools/start! {:body [#'demo] + :css-infiles ["site/public/css/examples.css" + "site/public/css/main.css"]})) + +(init!) diff --git a/env/dev/reagentdemo/dev.cljs b/env/dev/reagentdemo/dev.cljs index fe61a3f..d2e84fe 100644 --- a/env/dev/reagentdemo/dev.cljs +++ b/env/dev/reagentdemo/dev.cljs @@ -1,9 +1,14 @@ (ns reagentdemo.dev - (:require [reagentdemo.core] - [reagenttest.runtests] + (:require [reagentdemo.core :as demo] + [reagenttest.runtests :as tests] [reagent.core :as r] [figwheel.client :as fw])) +(defn reload [] + (demo/init!) + (tests/init!)) + (when r/is-client (fw/start - {:websocket-url "ws://localhost:3449/figwheel-ws"})) + {:on-jsload reload + :websocket-url "ws://localhost:3449/figwheel-ws"})) diff --git a/project.clj b/project.clj index f2ba928..d0e74d4 100644 --- a/project.clj +++ b/project.clj @@ -4,10 +4,10 @@ :description "A simple ClojureScript interface to React" :dependencies [[org.clojure/clojure "1.6.0"] - [org.clojure/clojurescript "0.0-2816"] + [org.clojure/clojurescript "0.0-3126"] [cljsjs/react "0.12.2-5"]] - :plugins [[lein-cljsbuild "1.0.4"]] + :plugins [[lein-cljsbuild "1.0.5"]] :source-paths ["src"] @@ -15,8 +15,8 @@ {:builds {:client {:source-paths ["test"]}}}} :dev [:test - {:dependencies [[figwheel "0.2.3-SNAPSHOT"]] - :plugins [[lein-figwheel "0.2.3-SNAPSHOT"]] + {:dependencies [[figwheel "0.2.5"]] + :plugins [[lein-figwheel "0.2.5"]] :source-paths ["demo"] ;; for lighttable :resource-paths ["site" "outsite"] :figwheel {:css-dirs ["site/public/css"]} @@ -69,4 +69,5 @@ :compiler {:output-to "outsite/public/js/main.js"}}}} :figwheel {:http-server-root "public" ;; assumes "resources" - :repl false}) + ;; broken in figwheel 0.2.5: :repl false + }) diff --git a/test/reagenttest/runtests.cljs b/test/reagenttest/runtests.cljs index 68d2553..1241918 100644 --- a/test/reagenttest/runtests.cljs +++ b/test/reagenttest/runtests.cljs @@ -1,4 +1,4 @@ -(ns ^:figwheel-always reagenttest.runtests +(ns reagenttest.runtests (:require [reagenttest.testreagent] [reagenttest.testcursor] [reagenttest.testinterop] @@ -44,7 +44,10 @@ (js/setTimeout all-tests 100) (all-tests))) -(when (some? (test/deftest empty-test)) - ;; Only run with :load-tests true - (reset! demo/test-results [#'test-output-mini]) - (run-tests)) +(defn init! [] + (when (some? (test/deftest empty-test)) + ;; Only run with :load-tests true + (reset! demo/test-results [#'test-output-mini]) + (run-tests))) + +(init!) From 60d99c44febf90b922c712ef8c62947abf4ba07a Mon Sep 17 00:00:00 2001 From: Dan Holmsand Date: Sun, 22 Mar 2015 11:49:23 +0100 Subject: [PATCH 2/7] Make site generation work with new cljs --- Makefile | 4 ++-- bin/cljs-load.js | 13 +++++++++---- bin/gen-site.js | 4 ++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 00de469..e8503e0 100644 --- a/Makefile +++ b/Makefile @@ -15,11 +15,11 @@ run: figwheel # development build with auto-reloading and site generation runsite: - @$(MAKE) run PROF=dev,site,$(PROF) + @$(MAKE) run PROF=+site,$(PROF) # development build with figwheel, but no tests runnotest: - @$(MAKE) run PROF=dev-notest,$(PROF) + @$(MAKE) run PROF=+dev-notest,$(PROF) # production build with auto-rebuild runprod: clean diff --git a/bin/cljs-load.js b/bin/cljs-load.js index 440f7cc..27110eb 100644 --- a/bin/cljs-load.js +++ b/bin/cljs-load.js @@ -8,7 +8,9 @@ var run = function (src) { vm.runInThisContext(fs.readFileSync(src), src); } -var loadSrc = function (mainFile, outputDir, devModule) { +var imported = {}; + +var loadSrc = function (mainFile, outputDir, devFile) { var googDir = path.join(outputDir, "goog"); var optNone = false; if (outputDir) { @@ -21,13 +23,16 @@ var loadSrc = function (mainFile, outputDir, devModule) { } global.CLOSURE_IMPORT_SCRIPT = function (src) { var s = path.resolve(path.resolve(cwd, path.join(googDir, src))); - run(s); - return true; + if (!(s in imported)) { + imported[s] = true; + run(s); + return true; + } }; run(path.join(googDir, "base.js")); run(path.join(outputDir, "cljs_deps.js")); - goog.require(devModule); + run(path.join(outputDir, devFile)); } else { run(mainFile); } diff --git a/bin/gen-site.js b/bin/gen-site.js index ff8cffe..999da6e 100755 --- a/bin/gen-site.js +++ b/bin/gen-site.js @@ -3,7 +3,7 @@ var cljsLoad = require("./cljs-load"); var srcFile = "outsite/public/js/main.js"; var outputDirectory = "outsite/public/js/out/"; -var moduleName = "reagentdemo.dev"; +var devFile = "reagentdemo/dev.js"; var beep = "\u0007"; @@ -15,7 +15,7 @@ if (typeof location === "undefined") { var gensite = function () { console.log("Loading " + srcFile); - var optNone = cljsLoad.load(srcFile, outputDirectory, moduleName); + var optNone = cljsLoad.load(srcFile, outputDirectory, devFile); sitetools.core.genpages({"opt-none": optNone}); } From cdd3c851a0374825b166681152420d638307ba4e Mon Sep 17 00:00:00 2001 From: Dan Holmsand Date: Mon, 25 May 2015 21:31:43 +0200 Subject: [PATCH 3/7] Fix cursor bug Cursor wasn't updated when changing both the cursor and an underlying atom at once. --- src/reagent/ratom.cljs | 2 +- test/reagenttest/testcursor.cljs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/reagent/ratom.cljs b/src/reagent/ratom.cljs index 92a8131..5993387 100644 --- a/src/reagent/ratom.cljs +++ b/src/reagent/ratom.cljs @@ -240,7 +240,7 @@ IComputedImpl (-handle-change [this sender oldval newval] - (when (and active? (not dirty?) (not (identical? oldval newval))) + (when (and active? (not (identical? oldval newval))) (set! dirty? true) ((or auto-run run) this))) diff --git a/test/reagenttest/testcursor.cljs b/test/reagenttest/testcursor.cljs index 73f64bd..2afdc75 100644 --- a/test/reagenttest/testcursor.cljs +++ b/test/reagenttest/testcursor.cljs @@ -426,3 +426,19 @@ (swap! a update-in [:b] inc) (is (= 4 (swap! b inc))) (is (= 4 @b)))) + +(deftest test-double-reset + (let [a (r/atom {:foo {:active? false}}) + c (r/cursor a [:foo]) + f (fn [] + (swap! c assoc :not-pristine true) + (swap! a update-in [:foo :active?] not)) + spy (atom nil) + r (run! + (reset! spy (:active? @c)))] + (is (= @spy false)) + (f) + (is (= @spy true)) + (f) + (is (= @spy false)) + (dispose r))) From 05bb63f25480230ca3ba29a09dd974a664285b4a Mon Sep 17 00:00:00 2001 From: Dan Holmsand Date: Fri, 29 May 2015 10:50:23 +0200 Subject: [PATCH 4/7] Update React to 0.13.3-0, and more Newer ClojureScript, figwheel, Clojure, cljsbuild --- project.clj | 14 +++++++------- src/reagent/ratom.cljs | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/project.clj b/project.clj index d0e74d4..00c5a32 100644 --- a/project.clj +++ b/project.clj @@ -3,11 +3,11 @@ :license {:name "MIT"} :description "A simple ClojureScript interface to React" - :dependencies [[org.clojure/clojure "1.6.0"] - [org.clojure/clojurescript "0.0-3126"] - [cljsjs/react "0.12.2-5"]] + :dependencies [[org.clojure/clojure "1.7.0-RC1"] + [org.clojure/clojurescript "0.0-3297"] + [cljsjs/react "0.13.3-0"]] - :plugins [[lein-cljsbuild "1.0.5"]] + :plugins [[lein-cljsbuild "1.0.6"]] :source-paths ["src"] @@ -15,8 +15,8 @@ {:builds {:client {:source-paths ["test"]}}}} :dev [:test - {:dependencies [[figwheel "0.2.5"]] - :plugins [[lein-figwheel "0.2.5"]] + {:dependencies [[figwheel "0.3.3"]] + :plugins [[lein-figwheel "0.3.3"]] :source-paths ["demo"] ;; for lighttable :resource-paths ["site" "outsite"] :figwheel {:css-dirs ["site/public/css"]} @@ -69,5 +69,5 @@ :compiler {:output-to "outsite/public/js/main.js"}}}} :figwheel {:http-server-root "public" ;; assumes "resources" - ;; broken in figwheel 0.2.5: :repl false + :repl false }) diff --git a/src/reagent/ratom.cljs b/src/reagent/ratom.cljs index 5993387..073f3cd 100644 --- a/src/reagent/ratom.cljs +++ b/src/reagent/ratom.cljs @@ -1,5 +1,5 @@ (ns reagent.ratom - (:refer-clojure :exclude [atom]) + (:refer-clojure :exclude [atom run!]) (:require-macros [reagent.debug :refer (dbg log warn dev?)]) (:require [reagent.impl.util :as util])) From 569322949b31921a5eeedb4158414da86027ea49 Mon Sep 17 00:00:00 2001 From: Dan Holmsand Date: Sun, 31 May 2015 11:51:11 +0200 Subject: [PATCH 5/7] Take advantage of new figwheel --- env/dev/reagentdemo/dev.cljs | 14 -------------- project.clj | 8 ++++---- src/reagent/ratom.clj | 3 ++- src/reagent/ratom.cljs | 7 ++++--- test/reagenttest/runtests.cljs | 4 ++++ 5 files changed, 14 insertions(+), 22 deletions(-) delete mode 100644 env/dev/reagentdemo/dev.cljs diff --git a/env/dev/reagentdemo/dev.cljs b/env/dev/reagentdemo/dev.cljs deleted file mode 100644 index d2e84fe..0000000 --- a/env/dev/reagentdemo/dev.cljs +++ /dev/null @@ -1,14 +0,0 @@ -(ns reagentdemo.dev - (:require [reagentdemo.core :as demo] - [reagenttest.runtests :as tests] - [reagent.core :as r] - [figwheel.client :as fw])) - -(defn reload [] - (demo/init!) - (tests/init!)) - -(when r/is-client - (fw/start - {:on-jsload reload - :websocket-url "ws://localhost:3449/figwheel-ws"})) diff --git a/project.clj b/project.clj index 00c5a32..9c4abc3 100644 --- a/project.clj +++ b/project.clj @@ -23,8 +23,9 @@ :cljsbuild {:builds {:client - {:source-paths ["env/dev"] - :compiler {:main "reagentdemo.dev" + {;;:source-paths ["env/dev"] + :figwheel {:on-jsload "reagenttest.runtests/reload"} + :compiler {:main "reagenttest.runtests" :source-map true :source-map-timestamp true :optimizations :none @@ -69,5 +70,4 @@ :compiler {:output-to "outsite/public/js/main.js"}}}} :figwheel {:http-server-root "public" ;; assumes "resources" - :repl false - }) + :repl false}) diff --git a/src/reagent/ratom.clj b/src/reagent/ratom.clj index 11c8770..b14ced4 100644 --- a/src/reagent/ratom.clj +++ b/src/reagent/ratom.clj @@ -1,4 +1,5 @@ -(ns reagent.ratom) +(ns reagent.ratom + (:refer-clojure :exclude [run!])) (defmacro reaction [& body] `(reagent.ratom/make-reaction diff --git a/src/reagent/ratom.cljs b/src/reagent/ratom.cljs index 073f3cd..b796be2 100644 --- a/src/reagent/ratom.cljs +++ b/src/reagent/ratom.cljs @@ -1,7 +1,8 @@ (ns reagent.ratom - (:refer-clojure :exclude [atom run!]) - (:require-macros [reagent.debug :refer (dbg log warn dev?)]) - (:require [reagent.impl.util :as util])) + (:refer-clojure :exclude [atom]) + (:require-macros [reagent.ratom]) + (:require [reagent.impl.util :as util] + [reagent.debug :refer-macros [dbg log warn dev?]])) (declare ^:dynamic *ratom-context*) diff --git a/test/reagenttest/runtests.cljs b/test/reagenttest/runtests.cljs index 1241918..1321d2e 100644 --- a/test/reagenttest/runtests.cljs +++ b/test/reagenttest/runtests.cljs @@ -50,4 +50,8 @@ (reset! demo/test-results [#'test-output-mini]) (run-tests))) +(defn reload [] + (demo/init!) + (init!)) + (init!) From 2d6e74d477cf7e373ed10b1dcdb46b33c58ea07d Mon Sep 17 00:00:00 2001 From: Dan Holmsand Date: Sun, 31 May 2015 11:57:16 +0200 Subject: [PATCH 6/7] Use :require-macros throughout --- src/reagent/debug.cljs | 4 ++-- src/reagent/interop.cljs | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/reagent/debug.cljs b/src/reagent/debug.cljs index a6d1aa6..64cc3d0 100644 --- a/src/reagent/debug.cljs +++ b/src/reagent/debug.cljs @@ -1,3 +1,3 @@ -(ns reagent.debug) +(ns reagent.debug + (:require-macros [reagent.debug])) -;; Empty file, to allow require with :refer-macros diff --git a/src/reagent/interop.cljs b/src/reagent/interop.cljs index c4e7f83..078819c 100644 --- a/src/reagent/interop.cljs +++ b/src/reagent/interop.cljs @@ -1,3 +1,2 @@ -(ns reagent.interop) - -;; Empty +(ns reagent.interop + (:require-macros [reagent.interop])) From 9bfd1a250bf0a443393dcf440af2b630798aef60 Mon Sep 17 00:00:00 2001 From: Dan Holmsand Date: Tue, 2 Jun 2015 11:02:46 +0200 Subject: [PATCH 7/7] Update clojurescript --- project.clj | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/project.clj b/project.clj index 9c4abc3..9e1517d 100644 --- a/project.clj +++ b/project.clj @@ -4,7 +4,7 @@ :description "A simple ClojureScript interface to React" :dependencies [[org.clojure/clojure "1.7.0-RC1"] - [org.clojure/clojurescript "0.0-3297"] + [org.clojure/clojurescript "0.0-3308"] [cljsjs/react "0.13.3-0"]] :plugins [[lein-cljsbuild "1.0.6"]] @@ -23,8 +23,7 @@ :cljsbuild {:builds {:client - {;;:source-paths ["env/dev"] - :figwheel {:on-jsload "reagenttest.runtests/reload"} + {:figwheel {:on-jsload "reagenttest.runtests/reload"} :compiler {:main "reagenttest.runtests" :source-map true :source-map-timestamp true