0
Fork 0
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:
Andrey Antukh 2016-06-12 13:38:18 +03:00
parent 0a17a44560
commit c13e86c735
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
6 changed files with 13 additions and 14 deletions

View file

@ -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"

View file

@ -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"]

View file

@ -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"

View file

@ -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)})))

View file

@ -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!)

View file

@ -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))