mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 23:49:45 -05:00
Move worker code into uxbox-worker namespace.
This commit is contained in:
parent
0a17a44560
commit
c13e86c735
6 changed files with 13 additions and 14 deletions
|
@ -5,7 +5,7 @@
|
|||
(let [start (System/nanoTime)]
|
||||
(b/build
|
||||
(b/inputs "src" "vendor")
|
||||
{:main 'uxbox.worker
|
||||
{:main 'uxbox-worker.main
|
||||
:output-to "resources/public/js/worker.js"
|
||||
:output-dir "resources/public/js/worker"
|
||||
:asset-path "js"
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
:output-to "resources/public/js/main.js"
|
||||
:output-dir "resources/public/js"
|
||||
:verbose true}}
|
||||
|
||||
#_{:id "preview"
|
||||
;; :figwheel {:on-jsload "uxbox.ui/init"}
|
||||
:source-paths ["src" "vendor"]
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
(b/watch
|
||||
(b/inputs "src" "vendor")
|
||||
{:main 'uxbox.worker
|
||||
{:main 'uxbox-worker.main
|
||||
:output-to "resources/public/js/worker.js"
|
||||
:output-dir "resources/public/js/worker"
|
||||
:asset-path "js"
|
||||
|
|
|
@ -4,26 +4,26 @@
|
|||
;;
|
||||
;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz>
|
||||
|
||||
(ns uxbox.worker.align
|
||||
(ns uxbox-worker.align
|
||||
"Workspace aligment indexes worker."
|
||||
(:require [beicon.core :as rx]
|
||||
[kdtree.core :as kd]
|
||||
[uxbox.worker.core :as wrk]
|
||||
[uxbox-worker.impl :as impl]
|
||||
[uxbox.util.geom.point :as gpt]))
|
||||
|
||||
(defonce tree (kd/create))
|
||||
|
||||
(defmethod wrk/handler :grid/init
|
||||
(defmethod impl/handler :grid/init
|
||||
[{:keys [sender width height x-axis y-axis] :as opts}]
|
||||
(time
|
||||
(let [value (kd/generate width height (or x-axis 10) (or y-axis 10))]
|
||||
(set! tree value)))
|
||||
(wrk/reply! sender nil))
|
||||
(impl/reply! sender nil))
|
||||
|
||||
(defmethod wrk/handler :grid/align
|
||||
(defmethod impl/handler :grid/align
|
||||
[{:keys [sender point] :as message}]
|
||||
(let [point #js [(:x point) (:y point)]
|
||||
results (js->clj (kd/nearest tree point 1))
|
||||
[[x y] d] (first results)
|
||||
result (gpt/point x y)]
|
||||
(wrk/reply! sender {:point (gpt/point x y)})))
|
||||
(impl/reply! sender {:point (gpt/point x y)})))
|
|
@ -4,7 +4,7 @@
|
|||
;;
|
||||
;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz>
|
||||
|
||||
(ns uxbox.worker.core
|
||||
(ns uxbox-worker.impl
|
||||
(:require [uxbox.util.transit :as t]))
|
||||
|
||||
(enable-console-print!)
|
|
@ -4,18 +4,18 @@
|
|||
;;
|
||||
;; Copyright (c) 2016 Andrey Antukh <niwi@niwi.nz>
|
||||
|
||||
(ns uxbox.worker
|
||||
(ns uxbox-worker.main
|
||||
(:require [beicon.core :as rx]
|
||||
[uxbox.util.transit :as t]
|
||||
[uxbox.worker.core :as wrk]
|
||||
[uxbox.worker.align]))
|
||||
[uxbox-worker.impl :as impl]
|
||||
[uxbox-worker.align]))
|
||||
|
||||
(enable-console-print!)
|
||||
|
||||
(defn- on-message
|
||||
[event]
|
||||
(let [message (t/decode (.-data event))]
|
||||
(wrk/handler message)))
|
||||
(impl/handler message)))
|
||||
|
||||
(defonce _
|
||||
(.addEventListener js/self "message" on-message))
|
Loading…
Add table
Reference in a new issue