From 032152fa56525d37d855d1f62a338de27e390b66 Mon Sep 17 00:00:00 2001 From: Juho Teperi Date: Fri, 18 Aug 2017 21:00:33 +0300 Subject: [PATCH] wip --- README.md | 3 +- build.boot | 11 +- examples/mixins/src/core.cljs | 5 +- examples/stateful/src/core.cljs | 9 +- pom.xml | 341 +++++++++++++++++--------------- project.clj | 11 +- src/main/om/core.cljs | 11 +- src/main/om/dom.cljc | 2 +- src/main/om/dom.cljs | 31 +-- src/main/om/next.cljc | 14 +- src/test/om/next/tests.cljc | 2 +- 11 files changed, 235 insertions(+), 205 deletions(-) diff --git a/README.md b/README.md index dbf7f065..af56f22b 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ dependency information: ```clojure (ns example (:require [goog.dom :as gdom] + [react-dom :as react-dom] [om.dom :as dom] [om.next :as om :refer [defui]])) @@ -49,7 +50,7 @@ dependency information: (def hello (om/factory Hello)) -(.render js/ReactDOM (hello) (gdom/getElement "example")) +(react-dom/render (hello) (gdom/getElement "example")) ``` ## Tutorials diff --git a/build.boot b/build.boot index b538af0b..8b8099fe 100644 --- a/build.boot +++ b/build.boot @@ -1,17 +1,18 @@ (set-env! :source-paths #{"src/main"} :dependencies '[[org.clojure/clojure "1.9.0-alpha16" :scope "provided"] - [org.clojure/clojurescript "1.9.542" :scope "provided" + [org.clojure/clojurescript "1.9.908" :scope "provided" :classifier "aot" :exclusions [org.clojure/clojure org.clojure/data.json]] - [org.clojure/clojurescript "1.9.542" :scope "provided" + [org.clojure/clojurescript "1.9.908" :scope "provided" :exclusions [org.clojure/clojure org.clojure/data.json]] [org.clojure/data.json "0.2.6" :scope "provided" :classifier "aot"] - [cljsjs/react "15.5.4-0"] - [cljsjs/react-dom "15.5.4-0"] + [cljsjs/react "15.6.1-1"] + [cljsjs/react-dom "15.6.1-1"] + [cljsjs/react-dom-server "15.6.1-1"] [com.cognitect/transit-clj "0.8.300"] [com.cognitect/transit-cljs "0.8.239"] @@ -20,7 +21,7 @@ [figwheel-sidecar "0.5.10" :scope "test" :exclusions [org.clojure/clojurescript org.clojure/tools.reader]] - [devcards "0.2.3" :scope "test" + [devcards "0.3.0-SNAPSHOT" :scope "test" :exclusions [org.clojure/clojurescript]] [com.cemerick/piggieback "0.2.1" :scope "test" :exclusions [org.clojure/clojure diff --git a/examples/mixins/src/core.cljs b/examples/mixins/src/core.cljs index a0d841dc..bcfe2615 100644 --- a/examples/mixins/src/core.cljs +++ b/examples/mixins/src/core.cljs @@ -1,6 +1,7 @@ (ns examples.mixins.core (:require [om.core :as om :include-macros true] - [om.dom :as dom :include-macros true]) + [om.dom :as dom :include-macros true] + [react :as react]) (:import [goog.ui IdGenerator])) (enable-console-print!) @@ -13,7 +14,7 @@ (def MyComponent (let [obj (om/specify-state-methods! (clj->js om/pure-methods))] (aset obj "mixins" #js [TestMixin]) - (js/React.createClass obj))) + (react/createClass obj))) (om/root (fn [app owner] diff --git a/examples/stateful/src/core.cljs b/examples/stateful/src/core.cljs index 03a4350c..701a5d54 100644 --- a/examples/stateful/src/core.cljs +++ b/examples/stateful/src/core.cljs @@ -1,6 +1,7 @@ (ns examples.stateful.core (:require [om.core :as om :include-macros true] - [om.dom :as dom :include-macros true])) + [om.dom :as dom :include-macros true] + [react :as react])) (defn counter-view [data owner] (reify @@ -18,7 +19,7 @@ (update-in x korks f))) (def MyClass* - (js/React.createClass + (react/createClass #js {:getInitialState (fn [] #js {:value {:count 0}}) @@ -34,6 +35,6 @@ (-transact! [m korks f _] (.setState this #js {:value (applyf m korks f)})))))))})) -(def MyClass (js/React.createFactory MyClass*)) +(def MyClass (react/createFactory MyClass*)) -(js/React.renderComponent (MyClass.) (.getElementById js/document "app")) +(react/renderComponent (MyClass.) (.getElementById js/document "app")) diff --git a/pom.xml b/pom.xml index d0368d7b..111ef503 100644 --- a/pom.xml +++ b/pom.xml @@ -1,162 +1,183 @@ - 4.0.0 - org.omcljs - om - jar - dev - om - A functional UI framework - http://github.com/omcljs/om - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - scm:git:git://github.com/omcljs/om.git - scm:git:ssh://git@github.com/omcljs/om.git - https://github.com/omcljs/om - - - src/main - - - resources - - - src/devcards - - - src/test - - - - - - - central - http://repo1.maven.org/maven2/ - - false - - - true - - - - clojars - https://clojars.org/repo/ - - true - - - true - - - - - - org.clojure - clojure - 1.9.0-alpha16 - provided - - - org.clojure - clojurescript - 1.9.542 - aot - provided - - - org.clojure - data.json - - - - - org.clojure - data.json - 0.2.6 - aot - provided - - - org.clojure - core.async - 0.3.443 - test - - - org.clojure - tools.reader - - - - - com.cognitect - transit-clj - 0.8.300 - - - com.cognitect - transit-cljs - 0.8.239 - - - cljsjs - react - 15.5.4-0 - - - cljsjs - react-dom - 15.5.4-0 - - - org.clojure - tools.nrepl - 0.2.13 - test - - - figwheel-sidecar - figwheel-sidecar - 0.5.10 - test - - - org.clojure - clojurescript - - - org.clojure - tools.reader - - - - - devcards - devcards - 0.2.3 - test - - - org.clojure - clojurescript - - - - - - - David Nolen - david.nolen@gmail.com - - + 4.0.0 + org.omcljs + om + jar + 1.1.0-SNAPSHOT + om + ClojureScript interface to Facebook's React + http://github.com/swannodette/om + + + Eclipse + http://www.eclipse.org/legal/epl-v10.html + + + + scm:git:git://github.com/omcljs/om.git + scm:git:ssh://git@github.com/omcljs/om.git + bc1c30f8c2e17bfc0821da7283c7aa2253ad0e89 + + https://github.com/omcljs/om + + + src/main + test + + + resources + + + + + resources + + + target + target/classes + + + org.codehaus.mojo + build-helper-maven-plugin + 1.7 + + + add-source + generate-sources + + add-source + + + + src/devcards + src/test + + + + + + + + + + central + https://repo1.maven.org/maven2/ + + false + + + true + + + + clojars + https://clojars.org/repo/ + + true + + + true + + + + + + + + + org.clojure + clojure + 1.9.0-alpha17 + provided + + + org.clojure + clojurescript + 1.9.908 + aot + + + org.clojure + clojure + + + org.clojure + data.json + + + provided + + + org.clojure + data.json + 0.2.6 + aot + provided + + + cljsjs + react + 15.6.1-1 + + + cljsjs + react-dom + 15.6.1-1 + + + com.cognitect + transit-clj + 0.8.300 + + + com.cognitect + transit-cljs + 0.8.239 + + + org.clojure + core.async + 0.2.385 + + + org.clojure + tools.reader + + + test + + + figwheel-sidecar + figwheel-sidecar + 0.5.10 + + + org.clojure + clojurescript + + + org.clojure + tools.reader + + + test + + + devcards + devcards + 0.2.3 + + + org.clojure + clojurescript + + + test + + + + diff --git a/project.clj b/project.clj index 7a54f37f..ba4990af 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject org.omcljs/om "1.0.0-beta2-SNAPSHOT" +(defproject org.omcljs/om "1.1.0-SNAPSHOT" :description "ClojureScript interface to Facebook's React" :url "http://github.com/swannodette/om" :license {:name "Eclipse" @@ -11,12 +11,13 @@ :source-paths ["src/main" "src/devcards" "src/test"] :dependencies [[org.clojure/clojure "1.9.0-alpha17" :scope "provided"] - [org.clojure/clojurescript "1.9.542" :scope "provided" :classifier "aot" + [org.clojure/clojurescript "1.9.908" :scope "provided" :classifier "aot" :exclusions [org.clojure/clojure org.clojure/data.json]] [org.clojure/data.json "0.2.6" :scope "provided" :classifier "aot"] - [cljsjs/react "15.5.4-0"] - [cljsjs/react-dom "15.5.4-0"] + [cljsjs/react "15.6.1-1"] + [cljsjs/react-dom "15.6.1-1"] + [cljsjs/react-dom-server "15.6.1-1"] [com.cognitect/transit-clj "0.8.300"] [com.cognitect/transit-cljs "0.8.239"] @@ -25,7 +26,7 @@ [figwheel-sidecar "0.5.10" :scope "test" :exclusions [org.clojure/clojurescript org.clojure/tools.reader]] - [devcards "0.2.3" :scope "test" + [devcards "0.3.0-SNAPSHOT" :scope "test" :exclusions [org.clojure/clojurescript]]] :plugins [[lein-cljsbuild "1.1.6"]] diff --git a/src/main/om/core.cljs b/src/main/om/core.cljs index 3accfb07..380b9c00 100644 --- a/src/main/om/core.cljs +++ b/src/main/om/core.cljs @@ -1,6 +1,7 @@ (ns om.core (:require-macros om.core) - (:require [cljsjs.react] + (:require [react :as react] + [react-dom :as react-dom] [om.dom :as dom :include-macros true] [goog.object :as gobj] [goog.dom :as gdom] @@ -900,7 +901,7 @@ (let [rdesc (or descriptor *descriptor* pure-descriptor)] (when (or (nil? (gobj/get f "om$descriptor")) (not (identical? rdesc (gobj/get f "om$tag")))) - (let [factory (js/React.createFactory (js/React.createClass rdesc))] + (let [factory (react/createFactory (react/createClass rdesc))] (gobj/set f "om$descriptor" factory) (gobj/set f "om$tag" rdesc)))) (gobj/get f "om$descriptor"))) @@ -1208,7 +1209,7 @@ (tear-down state watch-key) (swap! refresh-set disj rootf) (swap! roots dissoc target) - (js/ReactDOM.unmountComponentAtNode target))) + (react-dom/unmountComponentAtNode target))) (rootf)))) (defn detach-root @@ -1275,10 +1276,10 @@ "A helper function to get at React DOM refs. Given a owning pure node extract the DOM ref specified by name." ([owner] - (js/ReactDOM.findDOMNode owner)) + (react-dom/findDOMNode owner)) ([owner name] {:pre [(string? name)]} - (some-> (.-refs owner) (aget name) (js/ReactDOM.findDOMNode)))) + (some-> (.-refs owner) (aget name) (react-dom/findDOMNode)))) (defn get-ref "A helper function to get at React refs. Given an owning pure node extract diff --git a/src/main/om/dom.cljc b/src/main/om/dom.cljc index 6bd99a8b..0bc76066 100644 --- a/src/main/om/dom.cljc +++ b/src/main/om/dom.cljc @@ -625,7 +625,7 @@ (defn create-element "Create a DOM element for which there exists no corresponding function. Useful to create DOM elements not included in React.DOM. Equivalent - to calling `js/React.createElement`" + to calling `React.createElement`" ([tag] (create-element tag nil)) ([tag opts & children] diff --git a/src/main/om/dom.cljs b/src/main/om/dom.cljs index 05e61170..86188608 100644 --- a/src/main/om/dom.cljs +++ b/src/main/om/dom.cljs @@ -1,16 +1,17 @@ (ns om.dom (:refer-clojure :exclude [map mask meta time select]) (:require-macros [om.dom :as dom]) - (:require [cljsjs.react] - [cljsjs.react.dom] + (:require [react :as react] + [react-dom :as react-dom] + ["react-dom/server" :as react-dom-server] [om.util :as util] [goog.object :as gobj])) (dom/gen-react-dom-fns) (defn wrap-form-element [ctor display-name] - (js/React.createFactory - (js/React.createClass + (react/createFactory + (react/createClass #js {:getDisplayName (fn [] display-name) @@ -40,38 +41,38 @@ :children (aget (.-props this) "children")}) (ctor props))))}))) -(def input (wrap-form-element js/React.DOM.input "input")) +(def input (wrap-form-element react/DOM.input "input")) -(def textarea (wrap-form-element js/React.DOM.textarea "textarea")) +(def textarea (wrap-form-element react/DOM.textarea "textarea")) -(def option (wrap-form-element js/React.DOM.option "option")) +(def option (wrap-form-element react/DOM.option "option")) -(def select (wrap-form-element js/React.DOM.select "select")) +(def select (wrap-form-element react/DOM.select "select")) (defn render "Equivalent to React.render" [component el] - (js/ReactDOM.render component el)) + (react-dom/render component el)) (defn render-to-str "Equivalent to React.renderToString" [c] - (js/ReactDOMServer.renderToString c)) + (react-dom-server/renderToString c)) (defn node "Returns the dom node associated with a component's React ref." ([component] - (js/ReactDOM.findDOMNode component)) + (react-dom/findDOMNode component)) ([component name] - (some-> (.-refs component) (gobj/get name) (js/ReactDOM.findDOMNode)))) + (some-> (.-refs component) (gobj/get name) (react-dom/findDOMNode)))) (defn create-element "Create a DOM element for which there exists no corresponding function. Useful to create DOM elements not included in React.DOM. Equivalent - to calling `js/React.createElement`" + to calling `react/createElement`" ([tag] (create-element tag nil)) ([tag opts] - (js/React.createElement tag opts)) + (react/createElement tag opts)) ([tag opts & children] - (js/React.createElement tag opts children))) + (react/createElement tag opts children))) diff --git a/src/main/om/next.cljc b/src/main/om/next.cljc index ce2e1013..07dd56df 100644 --- a/src/main/om/next.cljc +++ b/src/main/om/next.cljc @@ -9,7 +9,9 @@ :cljs [[goog.string :as gstring] [goog.object :as gobj] [goog.log :as glog] - [om.next.cache :as c]]) + [om.next.cache :as c] + [react :as react] + [react-dom :as react-dom]]) [om.next.impl.parser :as parser] [om.tempid :as tempid] [om.transit :as transit] @@ -409,13 +411,13 @@ {:doc docstring}))) [] (this-as this# - (.apply js/React.Component this# (js-arguments)) + (.apply react/Component this# (js-arguments)) (if-not (nil? (.-initLocalState this#)) (set! (.-state this#) (.initLocalState this#)) (set! (.-state this#) (cljs.core/js-obj))) this#)) set-react-proto! `(set! (.-prototype ~name) - (goog.object/clone js/React.Component.prototype)) + (goog.object/clone react/Component.prototype)) ctor (if (-> name meta :once) `(when-not (cljs.core/exists? ~name) ~ctor @@ -898,7 +900,7 @@ t (if-not (nil? *reconciler*) (p/basis-t *reconciler*) 0)] - (js/React.createElement class + (react/createElement class #js {:key key :ref ref :omcljs$reactKey key @@ -2770,9 +2772,9 @@ optimize (fn [cs] (sort-by depth cs)) history 100 root-render #?(:clj (fn [c target] c) - :cljs #(js/ReactDOM.render %1 %2)) + :cljs #(react-dom/render %1 %2)) root-unmount #?(:clj (fn [x]) - :cljs #(js/ReactDOM.unmountComponentAtNode %)) + :cljs #(react-dom/unmountComponentAtNode %)) pathopt false migrate default-migrate easy-reads true} diff --git a/src/test/om/next/tests.cljc b/src/test/om/next/tests.cljc index ec7bb820..e43bbc7a 100644 --- a/src/test/om/next/tests.cljc +++ b/src/test/om/next/tests.cljc @@ -1,6 +1,6 @@ (ns om.next.tests #?(:clj (:refer-clojure :exclude [read])) - (:require #?@(:cljs [[cljsjs.react]]) + (:require #?@(:cljs [[react :as react]]) [clojure.test :refer [deftest is are testing run-tests]] [clojure.zip :as zip] [om.next :as om #?(:clj :refer :cljs :refer-macros) [defui ui]]