Commit e6b0a119 authored by Ricardo J. Mendez's avatar Ricardo J. Mendez

Split builds

This way we don't end up with React code on the content script or
potentially clashing event handlers. We also will not need to dance
around initialization with secondary js files that don't really bring
anything to the table and need to be separately maintained.

https://app.asana.com/0/50978096561390/61116417923233
parent 181863db
......@@ -10,22 +10,50 @@
[prismatic/dommy "1.1.0"]
[re-frame "0.4.1" :exclusions [cljsjs/react]]
]
:source-paths ["src/app" "src/devcards"]
:profiles {:dev {:plugins [[lein-cljsbuild "1.1.0"]
[lein-chromebuild "0.3.0"]]
:cljsbuild {:builds
{:dev
{:source-paths ["src/app"]
:compiler {:output-to "target/unpacked/booklet.js"
:output-dir "target/js"
:externs ["externs/misc-externs.js"]
:main "booklet.background"
:optimizations :whitespace
:pretty-print true}}}}
:source-paths ["src/ui" "src/common" "src/background" "src/content"]
:chromebuild {:resource-paths ["resources/js"
"resources/html"
"resources/images"
"resources/css"]
:target-path "target/unpacked"}
}})
:plugins [[lein-cljsbuild "1.1.0"]
[lein-chromebuild "0.3.0"]]
:cljsbuild {:builds
{:background
{:source-paths ["src/background" "src/common"]
:compiler {:output-to "target/unpacked/background.js"
:output-dir "target/js/background"
:main "booklet.background"
:optimizations :whitespace
:pretty-print true}}
:content
{:source-paths ["src/content" "src/common"]
:compiler {:output-to "target/unpacked/content.js"
:output-dir "target/js/content"
:main "booklet.content"
:optimizations :whitespace
:pretty-print true}}
:ui
{:source-paths ["src/ui" "src/common"]
:compiler {:output-to "target/unpacked/ui.js"
:output-dir "target/js/ui"
:main "booklet.display"
:optimizations :whitespace
:pretty-print true}}}
}
:chromebuild {:resource-paths ["resources/js"
"resources/html"
"resources/images"
"resources/css"]
:target-path "target/unpacked"}
:profiles {:release
{:cljsbuild
{:builds
{:background {:compiler {:optimizations :advanced
:pretty-print false}}
:content {:compiler {:optimizations :advanced
:pretty-print false}}
:ui {:compiler {:optimizations :advanced
:pretty-print false}}}}
}})
......@@ -27,9 +27,7 @@
<script type="text/javascript" src="/booklet.js"></script>
<script type="text/javascript" src="/core.js"></script>
<script type="text/javascript" src="/ui.js"></script>
</body>
</html>
booklet.background.init();
booklet.content.init();
\ No newline at end of file
booklet.core.init();
......@@ -18,7 +18,6 @@
],
"background": {
"scripts": [
"booklet.js",
"background.js"
],
"persistent": false
......@@ -27,7 +26,7 @@
{
"matches": ["https://*.startpage.com/*", "https://duckduckgo.com/*"],
"run_at": "document_end",
"js": ["booklet.js", "content-init.js"]
"js": ["content.js"]
}
],
"manifest_version": 2
......
......@@ -322,6 +322,8 @@
(recur channel)
))
(defn init []
(defn ^:export main []
(init-time-tracking)
(init-click-handling))
(main)
\ No newline at end of file
(ns booklet.shared-handlers
(:require [booklet.utils :refer [on-channel from-transit]]
[cljs.core.async :refer [>! <!]]
[cljs.core :refer [random-uuid]]
[cljsjs.react-bootstrap]
[khroma.log :as console]
[re-frame.core :refer [dispatch register-sub register-handler subscribe dispatch-sync]])
(:require-macros [cljs.core :refer [goog-define]]
[cljs.core.async.macros :refer [go go-loop]]
[reagent.ratom :refer [reaction]]))
(register-handler
:log-content
(fn [app-state [_ content]]
(console/log "Log event:" content)
app-state
))
\ No newline at end of file
(ns booklet.content
(:require [booklet.utils :refer [on-channel from-transit to-transit]]
(:require [booklet.utils :refer [from-transit]]
[dommy.core :refer-macros [sel sel1] :as dommy]
[khroma.runtime :as runtime]
[khroma.log :as console]
......@@ -44,10 +44,12 @@
)))
(defn ^:export init []
(defn ^:export main []
(console/log "Init on content script!")
(do-transformations!)
(let [bg (runtime/connect)]
(go
(>! bg :content-initialized)
(console/log "<-- Background replied" (<! bg)))))
\ No newline at end of file
(console/log "<-- Background replied" (<! bg)))))
(main)
\ No newline at end of file
(ns booklet.core
(ns booklet.display
(:require [ajax.core :refer [GET POST PUT]]
[booklet.utils :refer [on-channel from-transit]]
[cljs.core.async :refer [>! <!]]
......@@ -67,14 +67,6 @@
:ui-state {:section :time-track}}))
(register-handler
:log-content
(fn [app-state [_ content]]
(console/log "Log event:" content)
app-state
))
(register-handler
:modal-info-set
(fn [app-state [_ info]]
......@@ -103,7 +95,6 @@
(def ModalHeader (reagent/adapt-react-class js/ReactBootstrap.ModalHeader))
;;;;----------------------------
;;;; Components
;;;;----------------------------
......@@ -257,8 +248,10 @@
(reagent/render-component [main-section] (.getElementById js/document "main-section")))
(defn init []
(defn ^:export main []
(dispatch-sync [::initialize])
(on-channel storage/on-changed dispatch ::storage-changed)
(idle/set-detection-interval 60)
(mount-components))
(main)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment