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