mirror of
https://github.com/penpot/penpot.git
synced 2025-04-16 00:41:25 -05:00
✨ Add verify
macro for true runtime spec asserts.
This commits mainly renames the old `assert` to `verify` and adds new `assert` that laverages `:elide-asserts` on clojurescript and *assert* value on clojure. This approach enables an assert macro that does not performs any runtime checks and compiles to more performant code in both cases: development mode and production mode.
This commit is contained in:
parent
391b926397
commit
8057fb54a6
14 changed files with 126 additions and 109 deletions
backend/src/uxbox
common/uxbox/common
frontend/src/uxbox/main
|
@ -35,8 +35,8 @@
|
|||
"Schedule the email for sending."
|
||||
([email context] (send! db/pool email context))
|
||||
([conn email context]
|
||||
(us/assert fn? email)
|
||||
(us/assert map? context)
|
||||
(us/verify fn? email)
|
||||
(us/verify map? context)
|
||||
(let [defaults {:from (:email-from cfg/config)
|
||||
:reply-to (:email-reply-to cfg/config)}
|
||||
data (->> (merge defaults context)
|
||||
|
|
|
@ -43,8 +43,8 @@
|
|||
width 200
|
||||
height 200}
|
||||
:as opts}]
|
||||
(us/assert ::thumbnail-opts opts)
|
||||
(us/assert fs/path? input)
|
||||
(us/verify ::thumbnail-opts opts)
|
||||
(us/verify fs/path? input)
|
||||
(let [tmp (fs/create-tempfile :suffix (str "." format))
|
||||
opr (doto (IMOperation.)
|
||||
(.addImage)
|
||||
|
@ -60,7 +60,7 @@
|
|||
|
||||
(defn make-thumbnail
|
||||
[input {:keys [width height format quality] :as opts}]
|
||||
(us/assert ::thumbnail-opts opts)
|
||||
(us/verify ::thumbnail-opts opts)
|
||||
(let [[filename ext] (fs/split-ext (fs/name input))
|
||||
suffix (->> [width height quality format]
|
||||
(interpose ".")
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
(defn- delete-project
|
||||
"Clean deleted projects."
|
||||
[{:keys [id] :as props}]
|
||||
(us/assert ::delete-project props)
|
||||
(us/verify ::delete-project props)
|
||||
(db/with-atomic [conn db/pool]
|
||||
(-> (db/query-one conn [sql:delete-project id])
|
||||
(p/then (constantly nil)))))
|
||||
|
|
|
@ -266,7 +266,7 @@
|
|||
|
||||
(defn schedule!
|
||||
[conn {:keys [name delay props queue key] :as options}]
|
||||
(us/assert ::task-options options)
|
||||
(us/verify ::task-options options)
|
||||
(let [queue (if (string? queue) queue "default")
|
||||
duration (-> (tm/duration delay)
|
||||
(duration->pginterval))
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
([id extra-context]
|
||||
(s/assert keyword? id)
|
||||
(fn [context]
|
||||
(us/assert ::context context)
|
||||
(us/verify ::context context)
|
||||
(when-let [spec (s/get-spec id)]
|
||||
(s/assert spec context))
|
||||
|
||||
|
|
|
@ -110,15 +110,20 @@
|
|||
|
||||
;; --- Macros
|
||||
|
||||
(defn assert*
|
||||
(defn spec-assert
|
||||
[spec x]
|
||||
(s/assert* spec x))
|
||||
|
||||
#?(:clj
|
||||
(defmacro assert
|
||||
"Always active assertion macro (does not obey to :elide-asserts)"
|
||||
[spec x]
|
||||
`(assert* ~spec ~x)))
|
||||
(defmacro assert
|
||||
"Always active assertion macro (does not obey to :elide-asserts)"
|
||||
[spec x]
|
||||
(when *assert*
|
||||
`(spec-assert ~spec ~x)))
|
||||
|
||||
(defmacro verify
|
||||
"Always active assertion macro (does not obey to :elide-asserts)"
|
||||
[spec x]
|
||||
`(spec-assert ~spec ~x))
|
||||
|
||||
;; --- Public Api
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
|
||||
(defn login
|
||||
[{:keys [username password] :as data}]
|
||||
(us/assert ::login-params data)
|
||||
(us/verify ::login-params data)
|
||||
(ptk/reify ::login
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -119,8 +119,8 @@
|
|||
|
||||
(defn request-profile-recovery
|
||||
[data on-success]
|
||||
(us/assert ::recovery-request data)
|
||||
(us/assert fn? on-success)
|
||||
(us/verify ::recovery-request data)
|
||||
(us/verify fn? on-success)
|
||||
(ptk/reify ::request-profile-recovery
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
|
@ -141,7 +141,7 @@
|
|||
|
||||
(defn recover-profile
|
||||
[{:keys [token password on-error on-success] :as data}]
|
||||
(us/assert ::recover-profile data)
|
||||
(us/verify ::recover-profile data)
|
||||
(ptk/reify ::recover-profile
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
|
||||
(defn initialize
|
||||
[id]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/verify ::us/uuid id)
|
||||
(ptk/reify ::initialize
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -71,7 +71,7 @@
|
|||
|
||||
(defn watch-page-changes
|
||||
[id]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/verify ::us/uuid id)
|
||||
(reify
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
|
@ -87,7 +87,7 @@
|
|||
|
||||
(defn pinned-history-fetched
|
||||
[items]
|
||||
(us/assert ::history-entries items)
|
||||
(us/verify ::history-entries items)
|
||||
(ptk/reify ::pinned-history-fetched
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -104,7 +104,7 @@
|
|||
|
||||
(defn fetch-pinned-history
|
||||
[id]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/verify ::us/uuid id)
|
||||
(ptk/reify ::fetch-pinned-history
|
||||
ptk/WatchEvent
|
||||
(watch [_ state s]
|
||||
|
@ -117,7 +117,7 @@
|
|||
|
||||
(defn history-fetched
|
||||
[items]
|
||||
(us/assert ::history-entries items)
|
||||
(us/verify ::history-entries items)
|
||||
(ptk/reify ::history-fetched
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -140,7 +140,7 @@
|
|||
([id]
|
||||
(fetch-history id nil))
|
||||
([id {:keys [since max]}]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/verify ::us/uuid id)
|
||||
(ptk/reify ::fetch-history
|
||||
ptk/WatchEvent
|
||||
(watch [_ state s]
|
||||
|
@ -182,7 +182,7 @@
|
|||
|
||||
(defn select
|
||||
[version]
|
||||
(us/assert int? version)
|
||||
(us/verify int? version)
|
||||
(ptk/reify ::select
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -238,7 +238,7 @@
|
|||
|
||||
(defn history-updated
|
||||
[item]
|
||||
(us/assert ::history-entry item)
|
||||
(us/verify ::history-entry item)
|
||||
(ptk/reify ::history-item-updated
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
|
||||
(defn collections-fetched
|
||||
[items]
|
||||
(us/assert (s/every ::collection-entity) items)
|
||||
(us/verify (s/every ::collection-entity) items)
|
||||
(ptk/reify ::collections-fetched
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -83,7 +83,7 @@
|
|||
|
||||
(defn collection-created
|
||||
[item]
|
||||
(us/assert ::collection-entity item)
|
||||
(us/verify ::collection-entity item)
|
||||
(ptk/reify ::collection-created
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -109,7 +109,7 @@
|
|||
|
||||
(defn collection-updated
|
||||
[item]
|
||||
(us/assert ::collection-entity item)
|
||||
(us/verify ::collection-entity item)
|
||||
(CollectionUpdated. item))
|
||||
|
||||
;; --- Update Collection
|
||||
|
@ -161,7 +161,7 @@
|
|||
|
||||
(defn image-created
|
||||
[item]
|
||||
(us/assert ::image-entity item)
|
||||
(us/verify ::image-entity item)
|
||||
(ptk/reify ::image-created
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -174,8 +174,8 @@
|
|||
(defn create-images
|
||||
([id files] (create-images id files identity))
|
||||
([id files on-uploaded]
|
||||
(us/assert (s/nilable ::us/uuid) id)
|
||||
(us/assert fn? on-uploaded)
|
||||
(us/verify (s/nilable ::us/uuid) id)
|
||||
(us/verify fn? on-uploaded)
|
||||
(ptk/reify ::create-images
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -225,7 +225,7 @@
|
|||
|
||||
(defn images-fetched
|
||||
[items]
|
||||
(us/assert (s/every ::image-entity) items)
|
||||
(us/verify (s/every ::image-entity) items)
|
||||
(ptk/reify ::images-fetched
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -239,7 +239,7 @@
|
|||
(defn fetch-images
|
||||
"Fetch a list of images of the selected collection"
|
||||
[id]
|
||||
(us/assert (s/nilable ::us/uuid) id)
|
||||
(us/verify (s/nilable ::us/uuid) id)
|
||||
(ptk/reify ::fetch-images
|
||||
ptk/WatchEvent
|
||||
(watch [_ state s]
|
||||
|
|
|
@ -134,7 +134,7 @@
|
|||
|
||||
(defn projects-fetched
|
||||
[projects]
|
||||
(us/assert (s/every ::project) projects)
|
||||
(us/verify (s/every ::project) projects)
|
||||
(ptk/reify ::projects-fetched
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -158,7 +158,7 @@
|
|||
|
||||
(defn fetch-file
|
||||
[id]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/verify ::us/uuid id)
|
||||
(ptk/reify ::fetch-file
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
|
@ -169,7 +169,7 @@
|
|||
|
||||
(defn files-fetched
|
||||
[files]
|
||||
(us/assert (s/every ::file) files)
|
||||
(us/verify (s/every ::file) files)
|
||||
(ptk/reify ::files-fetched
|
||||
cljs.core/IDeref
|
||||
(-deref [_] files)
|
||||
|
@ -227,7 +227,7 @@
|
|||
|
||||
(defn delete-project
|
||||
[id]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/verify ::us/uuid id)
|
||||
(ptk/reify ::delete-project
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -242,7 +242,7 @@
|
|||
|
||||
(defn delete-file
|
||||
[id]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/verify ::us/uuid id)
|
||||
(ptk/reify ::delete-file
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -273,7 +273,7 @@
|
|||
|
||||
(defn go-to
|
||||
[file-id]
|
||||
(us/assert ::us/uuid file-id)
|
||||
(us/verify ::us/uuid file-id)
|
||||
(ptk/reify ::go-to
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
|
@ -284,7 +284,7 @@
|
|||
|
||||
(defn go-to-project
|
||||
[id]
|
||||
(us/assert (s/nilable ::us/uuid) id)
|
||||
(us/verify (s/nilable ::us/uuid) id)
|
||||
(ptk/reify ::go-to-project
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
|
@ -299,7 +299,7 @@
|
|||
|
||||
(defn fetch-pages
|
||||
[file-id]
|
||||
(us/assert ::us/uuid file-id)
|
||||
(us/verify ::us/uuid file-id)
|
||||
(reify
|
||||
ptk/WatchEvent
|
||||
(watch [_ state s]
|
||||
|
@ -310,7 +310,7 @@
|
|||
|
||||
(defn pages-fetched
|
||||
[pages]
|
||||
(us/assert (s/every ::page) pages)
|
||||
(us/verify (s/every ::page) pages)
|
||||
(ptk/reify ::pages-fetched
|
||||
IDeref
|
||||
(-deref [_] pages)
|
||||
|
@ -326,7 +326,7 @@
|
|||
(defn fetch-page
|
||||
"Fetch page by id."
|
||||
[id]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/verify ::us/uuid id)
|
||||
(reify
|
||||
ptk/WatchEvent
|
||||
(watch [_ state s]
|
||||
|
@ -337,7 +337,7 @@
|
|||
|
||||
(defn page-fetched
|
||||
[data]
|
||||
(us/assert ::page data)
|
||||
(us/verify ::page data)
|
||||
(ptk/reify ::page-fetched
|
||||
IDeref
|
||||
(-deref [_] data)
|
||||
|
@ -368,7 +368,7 @@
|
|||
|
||||
(defn page-created
|
||||
[{:keys [id file-id] :as page}]
|
||||
(us/assert ::page page)
|
||||
(us/verify ::page page)
|
||||
(ptk/reify ::page-created
|
||||
cljs.core/IDeref
|
||||
(-deref [_] page)
|
||||
|
@ -393,8 +393,8 @@
|
|||
|
||||
(defn rename-page
|
||||
[id name]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/assert string? name)
|
||||
(us/verify ::us/uuid id)
|
||||
(us/verify string? name)
|
||||
(ptk/reify ::rename-page
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -452,7 +452,7 @@
|
|||
|
||||
(defn page-persisted
|
||||
[{:keys [id] :as page}]
|
||||
(us/assert ::page page)
|
||||
(us/verify ::page page)
|
||||
(ptk/reify ::page-persisted
|
||||
cljs.core/IDeref
|
||||
(-deref [_] page)
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
(defn watch-page-changes
|
||||
[id]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/verify ::us/uuid id)
|
||||
(ptk/reify ::watch-page-changes
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
|
@ -40,7 +40,7 @@
|
|||
|
||||
(defn save-undo-entry
|
||||
[id]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/verify ::us/uuid id)
|
||||
(letfn [(cons-entry [stack entry]
|
||||
(let [stack (cons entry stack)]
|
||||
(if (> (count stack) MAX-STACK-SIZE)
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
(defn profile-fetched
|
||||
[data]
|
||||
(us/assert ::profile-fetched data)
|
||||
(us/verify ::profile-fetched data)
|
||||
(ptk/reify ::profile-fetched
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -73,9 +73,9 @@
|
|||
|
||||
(defn form->update-profile
|
||||
[data on-success on-error]
|
||||
(us/assert ::update-profile-params data)
|
||||
(us/assert fn? on-error)
|
||||
(us/assert fn? on-success)
|
||||
(us/verify ::update-profile-params data)
|
||||
(us/verify fn? on-error)
|
||||
(us/verify fn? on-success)
|
||||
(reify
|
||||
ptk/WatchEvent
|
||||
(watch [_ state s]
|
||||
|
@ -102,9 +102,9 @@
|
|||
|
||||
(defn update-password
|
||||
[data {:keys [on-success on-error]}]
|
||||
(us/assert ::update-password-params data)
|
||||
(us/assert fn? on-success)
|
||||
(us/assert fn? on-error)
|
||||
(us/verify ::update-password-params data)
|
||||
(us/verify fn? on-success)
|
||||
(us/verify fn? on-error)
|
||||
(reify
|
||||
ptk/WatchEvent
|
||||
(watch [_ state s]
|
||||
|
@ -132,6 +132,6 @@
|
|||
(defn update-photo
|
||||
([file] (update-photo file (constantly nil)))
|
||||
([file done]
|
||||
(us/assert ::file file)
|
||||
(us/assert fn? done)
|
||||
(us/verify ::file file)
|
||||
(us/verify fn? done)
|
||||
(UpdatePhoto. file done)))
|
||||
|
|
|
@ -127,7 +127,7 @@
|
|||
|
||||
(defn handle-who
|
||||
[{:keys [users] :as msg}]
|
||||
(us/assert set? users)
|
||||
(us/verify set? users)
|
||||
(ptk/reify ::handle-who
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -279,8 +279,8 @@
|
|||
(defn initialize
|
||||
"Initialize the workspace state."
|
||||
[file-id page-id]
|
||||
(us/assert ::us/uuid file-id)
|
||||
(us/assert ::us/uuid page-id)
|
||||
(us/verify ::us/uuid file-id)
|
||||
(us/verify ::us/uuid page-id)
|
||||
(ptk/reify ::initialize
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
|
@ -303,7 +303,7 @@
|
|||
|
||||
(defn- initialize-layout
|
||||
[file-id]
|
||||
(us/assert ::us/uuid file-id)
|
||||
(us/verify ::us/uuid file-id)
|
||||
(ptk/reify ::initialize-layout
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -311,7 +311,7 @@
|
|||
|
||||
(defn- initialize-file
|
||||
[file-id]
|
||||
(us/assert ::us/uuid file-id)
|
||||
(us/verify ::us/uuid file-id)
|
||||
(ptk/reify ::initialize-file
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -345,8 +345,8 @@
|
|||
|
||||
(defn finalize
|
||||
[file-id page-id]
|
||||
(us/assert ::us/uuid file-id)
|
||||
(us/assert ::us/uuid page-id)
|
||||
(us/verify ::us/uuid file-id)
|
||||
(us/verify ::us/uuid page-id)
|
||||
(ptk/reify ::finalize
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -404,7 +404,7 @@
|
|||
|
||||
(defn toggle-layout-flag
|
||||
[flag]
|
||||
(us/assert keyword? flag)
|
||||
(us/verify keyword? flag)
|
||||
(ptk/reify ::toggle-layout-flag
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -418,7 +418,7 @@
|
|||
|
||||
(defn activate-flag
|
||||
[flag]
|
||||
(us/assert keyword? flag)
|
||||
(us/verify keyword? flag)
|
||||
(ptk/reify ::activate-flag
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -430,7 +430,7 @@
|
|||
|
||||
(defn deactivate-flag
|
||||
[flag]
|
||||
(us/assert keyword? flag)
|
||||
(us/verify keyword? flag)
|
||||
(ptk/reify ::deactivate-flag
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -438,7 +438,7 @@
|
|||
|
||||
(defn toggle-flag
|
||||
[flag]
|
||||
(us/assert keyword? flag)
|
||||
(us/verify keyword? flag)
|
||||
(ptk/reify ::toggle-flag
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
|
@ -559,7 +559,7 @@
|
|||
|
||||
;; (defn initialize-alignment
|
||||
;; [id]
|
||||
;; (us/assert ::us/uuid id)
|
||||
;; (us/verify ::us/uuid id)
|
||||
;; (ptk/reify ::initialize-alignment
|
||||
;; ptk/WatchEvent
|
||||
;; (watch [_ state stream]
|
||||
|
@ -617,7 +617,7 @@
|
|||
|
||||
(defn add-shape
|
||||
[data]
|
||||
(us/assert ::shape-attrs data)
|
||||
(us/verify ::shape-attrs data)
|
||||
(let [id (uuid/next)]
|
||||
(ptk/reify ::add-shape
|
||||
ptk/UpdateEvent
|
||||
|
@ -646,7 +646,7 @@
|
|||
|
||||
(defn add-canvas
|
||||
[data]
|
||||
(us/assert ::shape-attrs data)
|
||||
(us/verify ::shape-attrs data)
|
||||
(let [id (uuid/next)]
|
||||
(ptk/reify ::add-canvas
|
||||
ptk/UpdateEvent
|
||||
|
@ -695,7 +695,7 @@
|
|||
|
||||
(defn select-shape
|
||||
[id]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/verify ::us/uuid id)
|
||||
(ptk/reify ::select-shape
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -755,8 +755,8 @@
|
|||
|
||||
(defn update-shape
|
||||
[id attrs]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/assert ::shape-attrs attrs)
|
||||
(us/verify ::us/uuid id)
|
||||
(us/verify ::shape-attrs attrs)
|
||||
(ptk/reify ::update-shape
|
||||
IBatchedChange
|
||||
ptk/UpdateEvent
|
||||
|
@ -767,7 +767,7 @@
|
|||
|
||||
(defn update-options
|
||||
[opts]
|
||||
(us/assert ::cp/options opts)
|
||||
(us/verify ::cp/options opts)
|
||||
(ptk/reify ::update-options
|
||||
IBatchedChange
|
||||
ptk/UpdateEvent
|
||||
|
@ -778,7 +778,7 @@
|
|||
|
||||
(defn update-selected-shapes
|
||||
[attrs]
|
||||
(s/assert ::shape-attrs attrs)
|
||||
(us/verify ::shape-attrs attrs)
|
||||
(ptk/reify ::update-selected-shapes
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
|
@ -819,8 +819,8 @@
|
|||
|
||||
(defn move-selected
|
||||
[direction align?]
|
||||
(us/assert ::direction direction)
|
||||
(us/assert boolean? align?)
|
||||
(us/verify ::direction direction)
|
||||
(us/verify boolean? align?)
|
||||
|
||||
(ptk/reify ::move-selected
|
||||
ptk/WatchEvent
|
||||
|
@ -872,8 +872,8 @@
|
|||
|
||||
(defn rename-shape
|
||||
[id name]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/assert string? name)
|
||||
(us/verify ::us/uuid id)
|
||||
(us/verify string? name)
|
||||
(ptk/reify ::rename-shape
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -894,7 +894,7 @@
|
|||
|
||||
(defn order-selected-shapes
|
||||
[loc]
|
||||
(us/assert ::direction loc)
|
||||
(us/verify ::direction loc)
|
||||
(ptk/reify ::move-selected-layer
|
||||
IBatchedChange
|
||||
ptk/UpdateEvent
|
||||
|
@ -924,8 +924,8 @@
|
|||
|
||||
(defn temporal-shape-order-change
|
||||
[id index]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/assert number? index)
|
||||
(us/verify ::us/uuid id)
|
||||
(us/verify number? index)
|
||||
(ptk/reify ::change-shape-order
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -953,8 +953,8 @@
|
|||
|
||||
(defn change-canvas-order
|
||||
[{:keys [id index] :as params}]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/assert ::us/number index)
|
||||
(us/verify ::us/uuid id)
|
||||
(us/verify ::us/number index)
|
||||
(ptk/reify ::change-canvas-order
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -969,7 +969,7 @@
|
|||
(defn initial-selection-align
|
||||
"Align the selection of shapes."
|
||||
[ids]
|
||||
(us/assert ::set-of-uuid ids)
|
||||
(us/verify ::set-of-uuid ids)
|
||||
(ptk/reify ::initialize-shapes-align-in-bulk
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
|
@ -986,8 +986,8 @@
|
|||
|
||||
(defn assoc-temporal-modifier-in-bulk
|
||||
[ids xfmt]
|
||||
(us/assert ::set-of-uuid ids)
|
||||
(us/assert gmt/matrix? xfmt)
|
||||
(us/verify ::set-of-uuid ids)
|
||||
(us/verify gmt/matrix? xfmt)
|
||||
(ptk/reify ::assoc-temporal-modifier-in-bulk
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -997,8 +997,8 @@
|
|||
"Apply the same displacement delta to all shapes identified by the
|
||||
set if ids."
|
||||
[ids delta]
|
||||
(us/assert ::set-of-uuid ids)
|
||||
(us/assert gpt/point? delta)
|
||||
(us/verify ::set-of-uuid ids)
|
||||
(us/verify gpt/point? delta)
|
||||
(letfn [(process-shape [state id]
|
||||
(let [prev (get-in state [:workspace-data :shapes-by-id id :modifier-mtx] (gmt/matrix))
|
||||
xfmt (gmt/translate prev delta)]
|
||||
|
@ -1038,7 +1038,7 @@
|
|||
|
||||
(defn commit-changes
|
||||
[changes]
|
||||
(us/assert ::cp/changes changes)
|
||||
(us/verify ::cp/changes changes)
|
||||
(ptk/reify ::commit-changes
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -1060,7 +1060,7 @@
|
|||
|
||||
(defn shapes-changes-commited
|
||||
[{:keys [page-id version changes] :as params}]
|
||||
(us/assert ::shapes-changes-commited params)
|
||||
(us/verify ::shapes-changes-commited params)
|
||||
(ptk/reify ::shapes-changes-commited
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -1126,14 +1126,26 @@
|
|||
of the shape using the width and height attrs
|
||||
instread final point of coordinates."
|
||||
[id dimensions]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/assert ::update-dimensions dimensions)
|
||||
(us/verify ::us/uuid id)
|
||||
(us/verify ::update-dimensions dimensions)
|
||||
(ptk/reify ::update-dimensions
|
||||
IBatchedChange
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(update-in state [:workspace-data :shapes-by-id id] geom/resize-dim dimensions))))
|
||||
|
||||
|
||||
(defn update-rect-dimensions
|
||||
[id attr value]
|
||||
(us/verify ::us/uuid id)
|
||||
(us/verify #{:width :height} attr)
|
||||
(us/verify ::us/number value)
|
||||
(ptk/reify ::update-rect-dimensions
|
||||
IBatchedChange
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(update-in state [:workspace-data :shapes-by-id id] geom/resize-rect attr value))))
|
||||
|
||||
;; --- Shape Proportions
|
||||
|
||||
(defn toggle-shape-proportion-lock
|
||||
|
@ -1156,8 +1168,8 @@
|
|||
|
||||
(defn update-position
|
||||
[id position]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/assert ::position position)
|
||||
(us/verify ::us/uuid id)
|
||||
(us/verify ::position position)
|
||||
(ptk/reify ::update-position
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -1169,9 +1181,9 @@
|
|||
(defn update-path
|
||||
"Update a concrete point in the path shape."
|
||||
[id index delta]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/assert ::us/integer index)
|
||||
(us/assert gpt/point? delta)
|
||||
(us/verify ::us/uuid id)
|
||||
(us/verify ::us/integer index)
|
||||
(us/verify gpt/point? delta)
|
||||
(ptk/reify ::update-path
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -1203,7 +1215,7 @@
|
|||
|
||||
(defn hide-shape
|
||||
[id]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/verify ::us/uuid id)
|
||||
(ptk/reify ::hide-shape
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -1211,7 +1223,7 @@
|
|||
|
||||
(defn show-shape
|
||||
[id]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/verify ::us/uuid id)
|
||||
(ptk/reify ::hide-shape
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -1237,7 +1249,7 @@
|
|||
|
||||
(defn block-shape
|
||||
[id]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/verify ::us/uuid id)
|
||||
(ptk/reify ::hide-shape
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -1245,7 +1257,7 @@
|
|||
|
||||
(defn unblock-shape
|
||||
[id]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/verify ::us/uuid id)
|
||||
(ptk/reify ::hide-shape
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -1271,7 +1283,7 @@
|
|||
|
||||
(defn select-canvas
|
||||
[id]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/verify ::us/uuid id)
|
||||
(ptk/reify ::select-canvas
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -1292,7 +1304,7 @@
|
|||
|
||||
(defn go-to-page
|
||||
[page-id]
|
||||
(us/assert ::us/uuid page-id)
|
||||
(us/verify ::us/uuid page-id)
|
||||
(ptk/reify ::go-to
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
|
|
|
@ -36,6 +36,6 @@
|
|||
|
||||
(defn initialize-alignment
|
||||
[params]
|
||||
(us/assert ::initialize-alignment-params params)
|
||||
(us/verify ::initialize-alignment-params params)
|
||||
(let [message (assoc params :cmd :grid-init)]
|
||||
(uw/send! worker message)))
|
||||
|
|
Loading…
Add table
Reference in a new issue