mirror of
https://github.com/penpot/penpot.git
synced 2025-02-03 04:49:03 -05:00
🚧 Comment worker code (temporary disabled).
This commit is contained in:
parent
4ee138f71e
commit
53700e3cb6
7 changed files with 97 additions and 95 deletions
|
@ -5,7 +5,7 @@
|
||||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
;; defined by the Mozilla Public License, v. 2.0.
|
;; defined by the Mozilla Public License, v. 2.0.
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2015-2019 Andrey Antukh <niwi@niwi.nz>
|
;; Copyright (c) 2015-2020 Andrey Antukh <niwi@niwi.nz>
|
||||||
|
|
||||||
(ns uxbox.main.data.workspace
|
(ns uxbox.main.data.workspace
|
||||||
(:require
|
(:require
|
||||||
|
@ -1779,23 +1779,23 @@
|
||||||
|
|
||||||
;; --- Initial Path Point Alignment
|
;; --- Initial Path Point Alignment
|
||||||
|
|
||||||
;; TODO: revisit on alignemt refactor
|
;; ;; TODO: revisit on alignemt refactor
|
||||||
(deftype InitialPathPointAlign [id index]
|
;; (deftype InitialPathPointAlign [id index]
|
||||||
ptk/WatchEvent
|
;; ptk/WatchEvent
|
||||||
(watch [_ state s]
|
;; (watch [_ state s]
|
||||||
(let [shape (get-in state [:workspace-data :objects id])
|
;; (let [shape (get-in state [:workspace-data :objects id])
|
||||||
point (get-in shape [:segments index])]
|
;; point (get-in shape [:segments index])]
|
||||||
(->> (uwrk/align-point point)
|
;; (->> (uwrk/align-point point)
|
||||||
(rx/map #(update-path id index %))))))
|
;; (rx/map #(update-path id index %))))))
|
||||||
|
|
||||||
(defn initial-path-point-align
|
;; (defn initial-path-point-align
|
||||||
"Event responsible of align a specified point of the
|
;; "Event responsible of align a specified point of the
|
||||||
shape by `index` with the grid."
|
;; shape by `index` with the grid."
|
||||||
[id index]
|
;; [id index]
|
||||||
{:pre [(uuid? id)
|
;; {:pre [(uuid? id)
|
||||||
(number? index)
|
;; (number? index)
|
||||||
(not (neg? index))]}
|
;; (not (neg? index))]}
|
||||||
(InitialPathPointAlign. id index))
|
;; (InitialPathPointAlign. id index))
|
||||||
|
|
||||||
;; --- Shape Visibility
|
;; --- Shape Visibility
|
||||||
|
|
||||||
|
|
|
@ -79,10 +79,10 @@
|
||||||
(->> (rx/concat (rx/of current)
|
(->> (rx/concat (rx/of current)
|
||||||
(rx/sample 10 mouse-position))
|
(rx/sample 10 mouse-position))
|
||||||
(rx/map #(gpt/divide % (gpt/point @refs/selected-zoom)))
|
(rx/map #(gpt/divide % (gpt/point @refs/selected-zoom)))
|
||||||
(rx/mapcat (fn [point]
|
;; (rx/mapcat (fn [point]
|
||||||
(if @refs/selected-alignment
|
;; (if @refs/selected-alignment
|
||||||
(uwrk/align-point point)
|
;; (uwrk/align-point point)
|
||||||
(rx/of point))))
|
;; (rx/of point))))
|
||||||
(rx/buffer 2 1)
|
(rx/buffer 2 1)
|
||||||
(rx/map (fn [[old new]]
|
(rx/map (fn [[old new]]
|
||||||
(gpt/subtract new old)))))
|
(gpt/subtract new old)))))
|
||||||
|
|
|
@ -136,7 +136,7 @@
|
||||||
stoper (rx/filter stoper? stream)
|
stoper (rx/filter stoper? stream)
|
||||||
|
|
||||||
mouse (->> ms/mouse-position
|
mouse (->> ms/mouse-position
|
||||||
(rx/mapcat #(conditional-align % align?))
|
;; (rx/mapcat #(conditional-align % align?))
|
||||||
(rx/map #(gpt/divide % (gpt/point zoom))))]
|
(rx/map #(gpt/divide % (gpt/point zoom))))]
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(->> mouse
|
(->> mouse
|
||||||
|
@ -187,7 +187,7 @@
|
||||||
(rx/share))
|
(rx/share))
|
||||||
|
|
||||||
mouse (->> (rx/sample 10 ms/mouse-position)
|
mouse (->> (rx/sample 10 ms/mouse-position)
|
||||||
(rx/mapcat #(conditional-align % align?))
|
;; (rx/mapcat #(conditional-align % align?))
|
||||||
(rx/map #(gpt/divide % (gpt/point zoom))))
|
(rx/map #(gpt/divide % (gpt/point zoom))))
|
||||||
|
|
||||||
points (->> stream
|
points (->> stream
|
||||||
|
@ -256,7 +256,7 @@
|
||||||
align? (refs/alignment-activated? flags)
|
align? (refs/alignment-activated? flags)
|
||||||
stoper (rx/filter stoper-event? stream)
|
stoper (rx/filter stoper-event? stream)
|
||||||
mouse (->> (rx/sample 10 ms/mouse-position)
|
mouse (->> (rx/sample 10 ms/mouse-position)
|
||||||
(rx/mapcat #(conditional-align % align?))
|
;; (rx/mapcat #(conditional-align % align?))
|
||||||
(rx/map #(gpt/divide % (gpt/point zoom))))]
|
(rx/map #(gpt/divide % (gpt/point zoom))))]
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(rx/of initialize-drawing)
|
(rx/of initialize-drawing)
|
||||||
|
@ -349,7 +349,7 @@
|
||||||
:on-mouse-enter on-mouse-enter
|
:on-mouse-enter on-mouse-enter
|
||||||
:on-mouse-leave on-mouse-leave}])])))
|
:on-mouse-leave on-mouse-leave}])])))
|
||||||
|
|
||||||
(defn- conditional-align [point align?]
|
;; (defn- conditional-align [point align?]
|
||||||
(if align?
|
;; (if align?
|
||||||
(uwrk/align-point point)
|
;; (uwrk/align-point point)
|
||||||
(rx/of point)))
|
;; (rx/of point)))
|
||||||
|
|
|
@ -46,10 +46,11 @@
|
||||||
|
|
||||||
;; Applies alginment to point if it is currently
|
;; Applies alginment to point if it is currently
|
||||||
;; activated on the current workspace
|
;; activated on the current workspace
|
||||||
(apply-grid-alignment [point]
|
;; (apply-grid-alignment [point]
|
||||||
(if @refs/selected-alignment
|
;; (if @refs/selected-alignment
|
||||||
(uwrk/align-point point)
|
;; (uwrk/align-point point)
|
||||||
(rx/of point)))]
|
;; (rx/of point)))
|
||||||
|
]
|
||||||
(reify
|
(reify
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
|
@ -59,7 +60,7 @@
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(->> ms/mouse-position
|
(->> ms/mouse-position
|
||||||
(rx/map apply-zoom)
|
(rx/map apply-zoom)
|
||||||
(rx/mapcat apply-grid-alignment)
|
;; (rx/mapcat apply-grid-alignment)
|
||||||
(rx/with-latest vector ms/mouse-position-ctrl)
|
(rx/with-latest vector ms/mouse-position-ctrl)
|
||||||
(rx/map normalize-proportion-lock)
|
(rx/map normalize-proportion-lock)
|
||||||
(rx/mapcat (partial resize shape))
|
(rx/mapcat (partial resize shape))
|
||||||
|
@ -202,8 +203,8 @@
|
||||||
(let [stoper (get-edition-stream-stoper)
|
(let [stoper (get-edition-stream-stoper)
|
||||||
stream (->> (ms/mouse-position-deltas @ms/mouse-position)
|
stream (->> (ms/mouse-position-deltas @ms/mouse-position)
|
||||||
(rx/take-until stoper))]
|
(rx/take-until stoper))]
|
||||||
(when @refs/selected-alignment
|
;; (when @refs/selected-alignment
|
||||||
(st/emit! (dw/initial-path-point-align (:id shape) index)))
|
;; (st/emit! (dw/initial-path-point-align (:id shape) index)))
|
||||||
(rx/subscribe stream #(on-handler-move % index))))
|
(rx/subscribe stream #(on-handler-move % index))))
|
||||||
|
|
||||||
(get-edition-stream-stoper []
|
(get-edition-stream-stoper []
|
||||||
|
|
|
@ -12,30 +12,30 @@
|
||||||
[uxbox.common.spec :as us]
|
[uxbox.common.spec :as us]
|
||||||
[uxbox.util.workers :as uw]))
|
[uxbox.util.workers :as uw]))
|
||||||
|
|
||||||
(s/def ::width number?)
|
;; (s/def ::width number?)
|
||||||
(s/def ::height number?)
|
;; (s/def ::height number?)
|
||||||
(s/def ::x-axis number?)
|
;; (s/def ::x-axis number?)
|
||||||
(s/def ::y-axis number?)
|
;; (s/def ::y-axis number?)
|
||||||
|
|
||||||
(s/def ::initialize-alignment-params
|
;; (s/def ::initialize-alignment-params
|
||||||
(s/keys :req-un [::width
|
;; (s/keys :req-un [::width
|
||||||
::height
|
;; ::height
|
||||||
::x-axis
|
;; ::x-axis
|
||||||
::y-axis]))
|
;; ::y-axis]))
|
||||||
|
|
||||||
;; This excludes webworker instantiation on nodejs where
|
;; ;; This excludes webworker instantiation on nodejs where
|
||||||
;; the tests are run.
|
;; ;; the tests are run.
|
||||||
(when (not= *target* "nodejs")
|
;; (when (not= *target* "nodejs")
|
||||||
(defonce worker (uw/init "js/worker.js")))
|
;; (defonce worker (uw/init "js/worker.js")))
|
||||||
|
|
||||||
(defn align-point
|
;; (defn align-point
|
||||||
[point]
|
;; [point]
|
||||||
(let [message {:cmd :grid-align :point point}]
|
;; (let [message {:cmd :grid-align :point point}]
|
||||||
(->> (uw/ask! worker message)
|
;; (->> (uw/ask! worker message)
|
||||||
(rx/map :point))))
|
;; (rx/map :point))))
|
||||||
|
|
||||||
(defn initialize-alignment
|
;; (defn initialize-alignment
|
||||||
[params]
|
;; [params]
|
||||||
(us/verify ::initialize-alignment-params params)
|
;; (us/verify ::initialize-alignment-params params)
|
||||||
(let [message (assoc params :cmd :grid-init)]
|
;; (let [message (assoc params :cmd :grid-init)]
|
||||||
(uw/send! worker message)))
|
;; (uw/send! worker message)))
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
(:require [cljs.reader :as r]
|
(:require [cljs.reader :as r]
|
||||||
[cuerdas.core :as str]))
|
[cuerdas.core :as str]))
|
||||||
|
|
||||||
;; TODO: partially move to uxbox.common.helpers
|
;; TODO: partially move to uxbox.common.data
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Data structure manipulation
|
;; Data structure manipulation
|
||||||
|
|
|
@ -60,12 +60,12 @@
|
||||||
;; :output-to "resources/public/js/view.js"}
|
;; :output-to "resources/public/js/view.js"}
|
||||||
}})
|
}})
|
||||||
|
|
||||||
(def worker-build-options
|
;; (def worker-build-options
|
||||||
{:main 'uxbox.worker
|
;; {:main 'uxbox.worker
|
||||||
:target :webworker
|
;; :target :webworker
|
||||||
:output-to "resources/public/js/worker.js"
|
;; :output-to "resources/public/js/worker.js"
|
||||||
:output-dir "resources/public/js/worker"
|
;; :output-dir "resources/public/js/worker"
|
||||||
:asset-path "/js/worker"})
|
;; :asset-path "/js/worker"})
|
||||||
|
|
||||||
(def main-dist-build-options
|
(def main-dist-build-options
|
||||||
(-> (merge default-build-options
|
(-> (merge default-build-options
|
||||||
|
@ -84,22 +84,22 @@
|
||||||
(assoc-in [:modules :main :output-to] "target/dist/dbg/js/main.js")
|
(assoc-in [:modules :main :output-to] "target/dist/dbg/js/main.js")
|
||||||
#_(assoc-in [:modules :view :output-to] "target/dist/dbg/js/view.js")))
|
#_(assoc-in [:modules :view :output-to] "target/dist/dbg/js/view.js")))
|
||||||
|
|
||||||
(def worker-dist-build-options
|
;; (def worker-dist-build-options
|
||||||
(merge default-build-options
|
;; (merge default-build-options
|
||||||
worker-build-options
|
;; worker-build-options
|
||||||
dist-build-options
|
;; dist-build-options
|
||||||
{:output-to "target/dist/js/worker.js"
|
;; {:output-to "target/dist/js/worker.js"
|
||||||
:output-dir "target/dist/js/worker"
|
;; :output-dir "target/dist/js/worker"
|
||||||
:source-map "target/dist/js/worker.js.map"}))
|
;; :source-map "target/dist/js/worker.js.map"}))
|
||||||
|
|
||||||
(def worker-dist-dbg-build-options
|
;; (def worker-dist-dbg-build-options
|
||||||
(merge worker-dist-build-options
|
;; (merge worker-dist-build-options
|
||||||
{:optimizations :advanced
|
;; {:optimizations :advanced
|
||||||
:pseudo-names true
|
;; :pseudo-names true
|
||||||
:pretty-print true
|
;; :pretty-print true
|
||||||
:output-to "target/dist/dbg/js/worker.js"
|
;; :output-to "target/dist/dbg/js/worker.js"
|
||||||
:output-dir "target/dist/dbg/js/worker"
|
;; :output-dir "target/dist/dbg/js/worker"
|
||||||
:source-map "target/dist/dbg/js/worker.js.map"}))
|
;; :source-map "target/dist/dbg/js/worker.js.map"}))
|
||||||
|
|
||||||
;; --- Tasks Definitions
|
;; --- Tasks Definitions
|
||||||
|
|
||||||
|
@ -109,11 +109,11 @@
|
||||||
;; (pprint cfg)
|
;; (pprint cfg)
|
||||||
(api/build (api/inputs "src") cfg)))
|
(api/build (api/inputs "src") cfg)))
|
||||||
|
|
||||||
(defmethod task "dist:worker"
|
;; (defmethod task "dist:worker"
|
||||||
[args]
|
;; [args]
|
||||||
(let [cfg worker-dist-build-options]
|
;; (let [cfg worker-dist-build-options]
|
||||||
;; (pprint cfg)
|
;; ;; (pprint cfg)
|
||||||
(api/build (api/inputs "src") cfg)))
|
;; (api/build (api/inputs "src") cfg)))
|
||||||
|
|
||||||
(defmethod task "dist-dbg:main"
|
(defmethod task "dist-dbg:main"
|
||||||
[args]
|
[args]
|
||||||
|
@ -121,18 +121,18 @@
|
||||||
;; (pprint cfg)
|
;; (pprint cfg)
|
||||||
(api/build (api/inputs "src") cfg)))
|
(api/build (api/inputs "src") cfg)))
|
||||||
|
|
||||||
(defmethod task "dist-dbg:worker"
|
;; (defmethod task "dist-dbg:worker"
|
||||||
[args]
|
;; [args]
|
||||||
(let [cfg worker-dist-dbg-build-options]
|
;; (let [cfg worker-dist-dbg-build-options]
|
||||||
;; (pprint cfg)
|
;; ;; (pprint cfg)
|
||||||
(api/build (api/inputs "src") cfg)))
|
;; (api/build (api/inputs "src") cfg)))
|
||||||
|
|
||||||
(defmethod task "dist:all"
|
(defmethod task "dist:all"
|
||||||
[args]
|
[args]
|
||||||
(task ["dist:main"])
|
(task ["dist:main"])
|
||||||
(task ["dist:worker"])
|
#_(task ["dist:worker"])
|
||||||
(task ["dist-dbg:main"])
|
(task ["dist-dbg:main"])
|
||||||
(task ["dist-dbg:worker"]))
|
#_(task ["dist-dbg:worker"]))
|
||||||
|
|
||||||
(defmethod task "repl:node"
|
(defmethod task "repl:node"
|
||||||
[args]
|
[args]
|
||||||
|
@ -189,8 +189,9 @@
|
||||||
(def figwheel-builds
|
(def figwheel-builds
|
||||||
{:main {:id "main"
|
{:main {:id "main"
|
||||||
:options (merge default-build-options main-build-options)}
|
:options (merge default-build-options main-build-options)}
|
||||||
:worker {:id "worker"
|
;; :worker {:id "worker"
|
||||||
:options (merge default-build-options worker-build-options)}})
|
;; :options (merge default-build-options worker-build-options)}
|
||||||
|
})
|
||||||
|
|
||||||
(def figwheel-options
|
(def figwheel-options
|
||||||
{:open-url false
|
{:open-url false
|
||||||
|
@ -208,7 +209,7 @@
|
||||||
(figwheel/start
|
(figwheel/start
|
||||||
figwheel-options
|
figwheel-options
|
||||||
(:main figwheel-builds)
|
(:main figwheel-builds)
|
||||||
(:worker figwheel-builds)))
|
#_(:worker figwheel-builds)))
|
||||||
|
|
||||||
;;; Build script entrypoint. This should be the last expression.
|
;;; Build script entrypoint. This should be the last expression.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue