mirror of
https://github.com/penpot/penpot.git
synced 2025-08-06 10:10:00 +02:00
✨ Resolve almost all linter issues on common module.
This commit is contained in:
parent
548664f6ce
commit
2ec769981a
18 changed files with 86 additions and 89 deletions
|
@ -1,7 +1,12 @@
|
||||||
{:lint-as {potok.core/reify clojure.core/reify
|
{:lint-as {potok.core/reify clojure.core/reify
|
||||||
promesa.core/let clojure.core/let
|
promesa.core/let clojure.core/let
|
||||||
rumext.alpha/defc clojure.core/defn
|
rumext.alpha/defc clojure.core/defn
|
||||||
|
app.common.data/export clojure.core/def
|
||||||
app.db/with-atomic clojure.core/with-open}
|
app.db/with-atomic clojure.core/with-open}
|
||||||
|
|
||||||
|
:hooks
|
||||||
|
{:analyze-call {app.common.data/export hooks.export/export}}
|
||||||
|
|
||||||
:output
|
:output
|
||||||
{:exclude-files ["data_readers.clj"]}
|
{:exclude-files ["data_readers.clj"]}
|
||||||
|
|
||||||
|
|
11
.clj-kondo/hooks/export.clj
Normal file
11
.clj-kondo/hooks/export.clj
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
(ns hooks.export
|
||||||
|
(:require [clj-kondo.hooks-api :as api]))
|
||||||
|
|
||||||
|
(defn export
|
||||||
|
[{:keys [:node]}]
|
||||||
|
(let [[_ sname] (:children node)
|
||||||
|
result (api/list-node
|
||||||
|
[(api/token-node (symbol "def"))
|
||||||
|
(api/token-node (symbol (name (:value sname))))
|
||||||
|
sname])]
|
||||||
|
{:node result}))
|
|
@ -10,14 +10,15 @@
|
||||||
#?(:cljs
|
#?(:cljs
|
||||||
(:require-macros [app.common.data]))
|
(:require-macros [app.common.data]))
|
||||||
(:require
|
(:require
|
||||||
[linked.set :as lks]
|
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
[clojure.set :as set]
|
[clojure.set :as set]
|
||||||
#?(:clj [cljs.analyzer.api :as aapi])
|
#?(:clj [cljs.analyzer.api :as aapi])
|
||||||
#?(:cljs [cljs.reader :as r]
|
#?(:cljs [cljs.reader :as r]
|
||||||
:clj [clojure.edn :as r])
|
:clj [clojure.edn :as r])
|
||||||
#?(:cljs [cljs.core :as core]
|
#?(:cljs [cljs.core :as core]
|
||||||
:clj [clojure.core :as core]))
|
:clj [clojure.core :as core])
|
||||||
|
[linked.set :as lks])
|
||||||
|
|
||||||
#?(:clj
|
#?(:clj
|
||||||
(:import linked.set.LinkedSet)))
|
(:import linked.set.LinkedSet)))
|
||||||
|
|
||||||
|
@ -482,8 +483,8 @@
|
||||||
"
|
"
|
||||||
[m1 m2]
|
[m1 m2]
|
||||||
|
|
||||||
(let [m1ks (keys m1)
|
(let [m1ks (set (keys m1))
|
||||||
m2ks (keys m2)
|
m2ks (set (keys m2))
|
||||||
keys (set/union m1ks m2ks)
|
keys (set/union m1ks m2ks)
|
||||||
|
|
||||||
diff-attr
|
diff-attr
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
(assoc-in stack [:items index] value))
|
(assoc-in stack [:items index] value))
|
||||||
|
|
||||||
(defn undo
|
(defn undo
|
||||||
[{index :index items :items :as stack}]
|
[stack]
|
||||||
(update stack :index dec))
|
(update stack :index dec))
|
||||||
|
|
||||||
(defn redo
|
(defn redo
|
||||||
|
@ -56,5 +56,5 @@
|
||||||
(update :index inc)))
|
(update :index inc)))
|
||||||
|
|
||||||
(defn size
|
(defn size
|
||||||
[{index :index items :items :as stack}]
|
[{index :index :as stack}]
|
||||||
(inc index))
|
(inc index))
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
|
|
||||||
(ns app.common.geom.align
|
(ns app.common.geom.align
|
||||||
(:require
|
(:require
|
||||||
[clojure.spec.alpha :as s]
|
[app.common.data :as d]
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.common.data :as d]))
|
[clojure.spec.alpha :as s]))
|
||||||
|
|
||||||
;; --- Alignment
|
;; --- Alignment
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,8 @@
|
||||||
(:require
|
(:require
|
||||||
#?(:cljs [cljs.pprint :as pp]
|
#?(:cljs [cljs.pprint :as pp]
|
||||||
:clj [clojure.pprint :as pp])
|
:clj [clojure.pprint :as pp])
|
||||||
[cuerdas.core :as str]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.data :as d]
|
[app.common.math :as mth]))
|
||||||
[app.common.math :as mth]
|
|
||||||
[app.common.geom.point :as gpt]))
|
|
||||||
|
|
||||||
;; --- Matrix Impl
|
;; --- Matrix Impl
|
||||||
|
|
||||||
|
|
|
@ -7,14 +7,13 @@
|
||||||
(ns app.common.geom.shapes
|
(ns app.common.geom.shapes
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.math :as mth]
|
|
||||||
[app.common.geom.matrix :as gmt]
|
[app.common.geom.matrix :as gmt]
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.geom.shapes.common :as gco]
|
[app.common.geom.shapes.common :as gco]
|
||||||
|
[app.common.geom.shapes.intersect :as gin]
|
||||||
[app.common.geom.shapes.path :as gsp]
|
[app.common.geom.shapes.path :as gsp]
|
||||||
[app.common.geom.shapes.rect :as gpr]
|
[app.common.geom.shapes.rect :as gpr]
|
||||||
[app.common.geom.shapes.transforms :as gtr]
|
[app.common.geom.shapes.transforms :as gtr]
|
||||||
[app.common.geom.shapes.intersect :as gin]
|
|
||||||
[app.common.spec :as us]))
|
[app.common.spec :as us]))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,8 @@
|
||||||
|
|
||||||
(ns app.common.geom.shapes.intersect
|
(ns app.common.geom.shapes.intersect
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
|
||||||
[app.common.geom.point :as gpt]
|
|
||||||
[app.common.geom.matrix :as gmt]
|
[app.common.geom.matrix :as gmt]
|
||||||
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.geom.shapes.path :as gpp]
|
[app.common.geom.shapes.path :as gpp]
|
||||||
[app.common.geom.shapes.rect :as gpr]
|
[app.common.geom.shapes.rect :as gpr]
|
||||||
[app.common.math :as mth]))
|
[app.common.math :as mth]))
|
||||||
|
@ -113,11 +112,10 @@
|
||||||
;; Even-odd algorithm
|
;; Even-odd algorithm
|
||||||
;; Cast a ray from the point in any direction and count the intersections
|
;; Cast a ray from the point in any direction and count the intersections
|
||||||
;; if it's odd the point is inside the polygon
|
;; if it's odd the point is inside the polygon
|
||||||
(let []
|
(->> lines
|
||||||
(->> lines
|
(filter #(intersect-ray? p %))
|
||||||
(filter #(intersect-ray? p %))
|
(count)
|
||||||
(count)
|
(odd?)))
|
||||||
(odd?))))
|
|
||||||
|
|
||||||
(defn- next-windup
|
(defn- next-windup
|
||||||
"Calculates the next windup number for the nonzero algorithm"
|
"Calculates the next windup number for the nonzero algorithm"
|
||||||
|
@ -173,7 +171,7 @@
|
||||||
(defn overlaps-path?
|
(defn overlaps-path?
|
||||||
"Checks if the given rect overlaps with the path in any point"
|
"Checks if the given rect overlaps with the path in any point"
|
||||||
[shape rect]
|
[shape rect]
|
||||||
|
|
||||||
(let [;; If paths are too complex the intersection is too expensive
|
(let [;; If paths are too complex the intersection is too expensive
|
||||||
;; we fallback to check its bounding box otherwise the performance penalty
|
;; we fallback to check its bounding box otherwise the performance penalty
|
||||||
;; is too big
|
;; is too big
|
||||||
|
@ -186,7 +184,7 @@
|
||||||
(points->lines (:points shape))
|
(points->lines (:points shape))
|
||||||
(gpp/path->lines shape))
|
(gpp/path->lines shape))
|
||||||
start-point (-> shape :content (first) :params (gpt/point))]
|
start-point (-> shape :content (first) :params (gpt/point))]
|
||||||
|
|
||||||
(or (is-point-inside-nonzero? (first rect-points) path-lines)
|
(or (is-point-inside-nonzero? (first rect-points) path-lines)
|
||||||
(is-point-inside-nonzero? start-point rect-lines)
|
(is-point-inside-nonzero? start-point rect-lines)
|
||||||
(intersects-lines? rect-lines path-lines))))
|
(intersects-lines? rect-lines path-lines))))
|
||||||
|
@ -197,14 +195,14 @@
|
||||||
|
|
||||||
(let [center (gpt/point cx cy)
|
(let [center (gpt/point cx cy)
|
||||||
transform (gmt/transform-in center transform)
|
transform (gmt/transform-in center transform)
|
||||||
{px :x py :y} (gpt/transform point transform)]
|
{px :x py :y} (gpt/transform point transform)
|
||||||
;; Ellipse inequality formula
|
;; Ellipse inequality formula
|
||||||
;; https://en.wikipedia.org/wiki/Ellipse#Shifted_ellipse
|
;; https://en.wikipedia.org/wiki/Ellipse#Shifted_ellipse
|
||||||
(let [v (+ (/ (mth/sq (- px cx))
|
v (+ (/ (mth/sq (- px cx))
|
||||||
(mth/sq rx))
|
(mth/sq rx))
|
||||||
(/ (mth/sq (- py cy))
|
(/ (mth/sq (- py cy))
|
||||||
(mth/sq ry)))]
|
(mth/sq ry)))]
|
||||||
(<= v 1))))
|
(<= v 1)))
|
||||||
|
|
||||||
(defn intersects-line-ellipse?
|
(defn intersects-line-ellipse?
|
||||||
"Checks wether a single line intersects with the given ellipse"
|
"Checks wether a single line intersects with the given ellipse"
|
||||||
|
@ -272,13 +270,13 @@
|
||||||
|
|
||||||
center (gpt/point (+ x (/ width 2))
|
center (gpt/point (+ x (/ width 2))
|
||||||
(+ y (/ height 2)))
|
(+ y (/ height 2)))
|
||||||
|
|
||||||
ellipse-data {:cx (:x center)
|
ellipse-data {:cx (:x center)
|
||||||
:cy (:y center)
|
:cy (:y center)
|
||||||
:rx (/ width 2)
|
:rx (/ width 2)
|
||||||
:ry (/ height 2)
|
:ry (/ height 2)
|
||||||
:transform (:transform-inverse shape)}]
|
:transform (:transform-inverse shape)}]
|
||||||
|
|
||||||
(or (is-point-inside-evenodd? center rect-lines)
|
(or (is-point-inside-evenodd? center rect-lines)
|
||||||
(is-point-inside-ellipse? (first rect-points) ellipse-data)
|
(is-point-inside-ellipse? (first rect-points) ellipse-data)
|
||||||
(intersects-lines-ellipse? rect-lines ellipse-data))))
|
(intersects-lines-ellipse? rect-lines ellipse-data))))
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
|
|
||||||
(ns app.common.geom.shapes.path
|
(ns app.common.geom.shapes.path
|
||||||
(:require
|
(:require
|
||||||
|
[app.common.data :as d]
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.geom.shapes.rect :as gpr]
|
[app.common.geom.shapes.rect :as gpr]
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]))
|
||||||
[app.common.data :as d]))
|
|
||||||
|
|
||||||
(defn content->points [content]
|
(defn content->points [content]
|
||||||
(->> content
|
(->> content
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
;; When the term a is close to zero we have a linear equation
|
;; When the term a is close to zero we have a linear equation
|
||||||
[(/ (- c) b)]
|
[(/ (- c) b)]
|
||||||
|
|
||||||
;; If a is not close to zero return the two roots for a cuadratic
|
;; If a is not close to zero return the two roots for a cuadratic
|
||||||
(not (mth/almost-zero? a))
|
(not (mth/almost-zero? a))
|
||||||
[(/ (+ (- b) sqrt-b2-4ac)
|
[(/ (+ (- b) sqrt-b2-4ac)
|
||||||
(* 2 a))
|
(* 2 a))
|
||||||
|
@ -267,7 +267,7 @@
|
||||||
|
|
||||||
(and (< (d ht) (d t1)) (< (d ht) (d t2)))
|
(and (< (d ht) (d t1)) (< (d ht) (d t2)))
|
||||||
[ht1 ht2]
|
[ht1 ht2]
|
||||||
|
|
||||||
(< (d t1) (d t2))
|
(< (d t1) (d t2))
|
||||||
[t1 ht]
|
[t1 ht]
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@
|
||||||
(if (and (some? acc) (or (not cur) (<= min-dist cur-dist)))
|
(if (and (some? acc) (or (not cur) (<= min-dist cur-dist)))
|
||||||
[min-p min-dist]
|
[min-p min-dist]
|
||||||
[cur-p cur-dist]))]
|
[cur-p cur-dist]))]
|
||||||
|
|
||||||
(->> (:content shape)
|
(->> (:content shape)
|
||||||
(d/with-prev)
|
(d/with-prev)
|
||||||
(map point+distance)
|
(map point+distance)
|
||||||
|
|
|
@ -7,13 +7,13 @@
|
||||||
(ns app.common.geom.shapes.transforms
|
(ns app.common.geom.shapes.transforms
|
||||||
(:require
|
(:require
|
||||||
[app.common.attrs :as attrs]
|
[app.common.attrs :as attrs]
|
||||||
|
[app.common.data :as d]
|
||||||
[app.common.geom.matrix :as gmt]
|
[app.common.geom.matrix :as gmt]
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.geom.shapes.common :as gco]
|
[app.common.geom.shapes.common :as gco]
|
||||||
[app.common.geom.shapes.path :as gpa]
|
[app.common.geom.shapes.path :as gpa]
|
||||||
[app.common.geom.shapes.rect :as gpr]
|
[app.common.geom.shapes.rect :as gpr]
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
[app.common.data :as d]
|
|
||||||
[app.common.text :as txt]))
|
[app.common.text :as txt]))
|
||||||
|
|
||||||
;; --- Relative Movement
|
;; --- Relative Movement
|
||||||
|
@ -58,12 +58,6 @@
|
||||||
dy (- (d/check-num y) (-> shape :selrect :y))]
|
dy (- (d/check-num y) (-> shape :selrect :y))]
|
||||||
(move shape (gpt/point dx dy))))
|
(move shape (gpt/point dx dy))))
|
||||||
|
|
||||||
|
|
||||||
(defn- modif-rotation [shape]
|
|
||||||
(let [cur-rotation (d/check-num (:rotation shape))
|
|
||||||
delta-angle (d/check-num (get-in shape [:modifiers :rotation]))]
|
|
||||||
(mod (+ cur-rotation delta-angle) 360)))
|
|
||||||
|
|
||||||
(defn transform-matrix
|
(defn transform-matrix
|
||||||
"Returns a transformation matrix without changing the shape properties.
|
"Returns a transformation matrix without changing the shape properties.
|
||||||
The result should be used in a `transform` attribute in svg"
|
The result should be used in a `transform` attribute in svg"
|
||||||
|
@ -86,14 +80,13 @@
|
||||||
(gpt/point 0 0))]
|
(gpt/point 0 0))]
|
||||||
(inverse-transform-matrix shape shape-center)))
|
(inverse-transform-matrix shape shape-center)))
|
||||||
([{:keys [flip-x flip-y] :as shape} center]
|
([{:keys [flip-x flip-y] :as shape} center]
|
||||||
(let []
|
(-> (gmt/matrix)
|
||||||
(-> (gmt/matrix)
|
(gmt/translate center)
|
||||||
(gmt/translate center)
|
(cond->
|
||||||
(cond->
|
flip-x (gmt/scale (gpt/point -1 1))
|
||||||
flip-x (gmt/scale (gpt/point -1 1))
|
flip-y (gmt/scale (gpt/point 1 -1)))
|
||||||
flip-y (gmt/scale (gpt/point 1 -1)))
|
(gmt/multiply (:transform-inverse shape (gmt/matrix)))
|
||||||
(gmt/multiply (:transform-inverse shape (gmt/matrix)))
|
(gmt/translate (gpt/negate center)))))
|
||||||
(gmt/translate (gpt/negate center))))))
|
|
||||||
|
|
||||||
(defn transform-point-center
|
(defn transform-point-center
|
||||||
"Transform a point around the shape center"
|
"Transform a point around the shape center"
|
||||||
|
@ -333,8 +326,9 @@
|
||||||
(dissoc :modifiers))))
|
(dissoc :modifiers))))
|
||||||
shape)))
|
shape)))
|
||||||
|
|
||||||
|
;; TODO: looks like orig-shape is useless argument
|
||||||
(defn apply-text-resize
|
(defn apply-text-resize
|
||||||
[shape orig-shape modifiers]
|
[shape _orig-shape modifiers]
|
||||||
(if (and (= (:type shape) :text)
|
(if (and (= (:type shape) :text)
|
||||||
(:resize-scale-text modifiers))
|
(:resize-scale-text modifiers))
|
||||||
(let [merge-attrs (fn [attrs]
|
(let [merge-attrs (fn [attrs]
|
||||||
|
@ -376,7 +370,7 @@
|
||||||
:y (- (:y new-selrect 0) (:y selrect 0))
|
:y (- (:y new-selrect 0) (:y selrect 0))
|
||||||
:width (- (:width new-selrect 1) (:width selrect 1))
|
:width (- (:width new-selrect 1) (:width selrect 1))
|
||||||
:height (- (:height new-selrect 1) (:height selrect 1))}]
|
:height (- (:height new-selrect 1) (:height selrect 1))}]
|
||||||
|
|
||||||
(cond-> group
|
(cond-> group
|
||||||
(and (some? svg-viewbox) (some? selrect) (some? new-selrect))
|
(and (some? svg-viewbox) (some? selrect) (some? new-selrect))
|
||||||
(update :svg-viewbox
|
(update :svg-viewbox
|
||||||
|
@ -388,9 +382,6 @@
|
||||||
|
|
||||||
(defn update-group-selrect [group children]
|
(defn update-group-selrect [group children]
|
||||||
(let [shape-center (gco/center-shape group)
|
(let [shape-center (gco/center-shape group)
|
||||||
transform (:transform group (gmt/matrix))
|
|
||||||
transform-inverse (:transform-inverse group (gmt/matrix))
|
|
||||||
|
|
||||||
;; Points for every shape inside the group
|
;; Points for every shape inside the group
|
||||||
points (->> children (mapcat :points))
|
points (->> children (mapcat :points))
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,11 @@
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.common.pages.helpers :as cph]
|
|
||||||
[app.common.pages.spec :as ps]
|
|
||||||
[app.common.spec :as us]
|
|
||||||
[app.common.pages.common :refer [component-sync-attrs]]
|
[app.common.pages.common :refer [component-sync-attrs]]
|
||||||
|
[app.common.pages.helpers :as cph]
|
||||||
[app.common.pages.init :as init]
|
[app.common.pages.init :as init]
|
||||||
[app.common.pages.spec :as spec]))
|
[app.common.pages.spec :as spec]
|
||||||
|
[app.common.spec :as us]))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Page Transformation Changes
|
;; Page Transformation Changes
|
||||||
|
@ -33,7 +32,7 @@
|
||||||
(when verify?
|
(when verify?
|
||||||
(us/assert ::spec/changes items))
|
(us/assert ::spec/changes items))
|
||||||
|
|
||||||
(let [pages (into #{} (map :page-id) items)
|
(let [pages (into #{} (map :page-id) items)
|
||||||
result (->> items
|
result (->> items
|
||||||
(reduce #(or (process-change %1 %2) %1) data))]
|
(reduce #(or (process-change %1 %2) %1) data))]
|
||||||
|
|
||||||
|
@ -42,7 +41,7 @@
|
||||||
(doseq [page-id pages]
|
(doseq [page-id pages]
|
||||||
(let [page (get-in result [:pages-index page-id])]
|
(let [page (get-in result [:pages-index page-id])]
|
||||||
(doseq [[id shape] (:objects page)]
|
(doseq [[id shape] (:objects page)]
|
||||||
(if-not (= shape (get-in data [:pages-index page-id :objects id]))
|
(when-not (= shape (get-in data [:pages-index page-id :objects id]))
|
||||||
;; If object has change verify is correct
|
;; If object has change verify is correct
|
||||||
(us/verify ::spec/shape shape))))))
|
(us/verify ::spec/shape shape))))))
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[clojure.set :as set]
|
|
||||||
[cuerdas.core :as str]))
|
[cuerdas.core :as str]))
|
||||||
|
|
||||||
(defn walk-pages
|
(defn walk-pages
|
||||||
|
@ -119,14 +118,14 @@
|
||||||
(conj! pending current)
|
(conj! pending current)
|
||||||
(first children)
|
(first children)
|
||||||
(rest children))
|
(rest children))
|
||||||
[result pending]))]
|
[result pending]))
|
||||||
|
|
||||||
;; If we have still pending, advance the iterator
|
;; If we have still pending, advance the iterator
|
||||||
(let [length (count pending)]
|
length (count pending)]
|
||||||
(if (pos? length)
|
(if (pos? length)
|
||||||
(let [next (get pending (dec length))]
|
(let [next (get pending (dec length))]
|
||||||
(recur result (pop! pending) next))
|
(recur result (pop! pending) next))
|
||||||
(persistent! result))))))
|
(persistent! result)))))
|
||||||
|
|
||||||
(defn get-children-objects
|
(defn get-children-objects
|
||||||
"Retrieve all children objects recursively for a given object"
|
"Retrieve all children objects recursively for a given object"
|
||||||
|
@ -403,14 +402,14 @@
|
||||||
[objects shape-id]
|
[objects shape-id]
|
||||||
(let [shape (get objects shape-id)
|
(let [shape (get objects shape-id)
|
||||||
parent (get objects (:parent-id shape))
|
parent (get objects (:parent-id shape))
|
||||||
[parent-idx _] (d/seek (fn [[idx child-id]] (= child-id shape-id))
|
[parent-idx _] (d/seek (fn [[_idx child-id]] (= child-id shape-id))
|
||||||
(d/enumerate (:shapes parent)))]
|
(d/enumerate (:shapes parent)))]
|
||||||
parent-idx))
|
parent-idx))
|
||||||
|
|
||||||
(defn split-path
|
(defn split-path
|
||||||
[path]
|
|
||||||
"Decompose a string in the form 'one / two / three' into
|
"Decompose a string in the form 'one / two / three' into
|
||||||
an array of strings, normalizing spaces."
|
an array of strings, normalizing spaces."
|
||||||
|
[path]
|
||||||
(->> (str/split path "/")
|
(->> (str/split path "/")
|
||||||
(map str/trim)
|
(map str/trim)
|
||||||
(remove str/empty?)))
|
(remove str/empty?)))
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
(ns app.common.pages.indices
|
(ns app.common.pages.indices
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.geom.shapes :as gsh]
|
|
||||||
[app.common.pages.helpers :as helpers]
|
[app.common.pages.helpers :as helpers]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[clojure.set :as set]))
|
[clojure.set :as set]))
|
||||||
|
@ -100,7 +99,8 @@
|
||||||
"Retrieves the mask information for an object"
|
"Retrieves the mask information for an object"
|
||||||
[objects parents-index]
|
[objects parents-index]
|
||||||
(let [retrieve-masks
|
(let [retrieve-masks
|
||||||
(fn [id parents]
|
(fn [_ parents]
|
||||||
|
;; TODO: use transducers?
|
||||||
(->> parents
|
(->> parents
|
||||||
(map #(get objects %))
|
(map #(get objects %))
|
||||||
(filter #(:masked-group? %))
|
(filter #(:masked-group? %))
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
(ns app.common.pages.init
|
(ns app.common.pages.init
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.uuid :as uuid]
|
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
[app.common.pages.common :refer [file-version default-color]]))
|
[app.common.pages.common :refer [file-version default-color]]
|
||||||
|
[app.common.uuid :as uuid]))
|
||||||
|
|
||||||
(def root uuid/zero)
|
(def root uuid/zero)
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,13 @@
|
||||||
|
|
||||||
(ns app.common.pages.migrations
|
(ns app.common.pages.migrations
|
||||||
(:require
|
(:require
|
||||||
[app.common.pages :as cp]
|
[app.common.data :as d]
|
||||||
|
[app.common.geom.matrix :as gmt]
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.common.geom.shapes.path :as gsp]
|
[app.common.geom.shapes.path :as gsp]
|
||||||
[app.common.geom.matrix :as gmt]
|
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.pages :as cp]
|
||||||
[app.common.data :as d]))
|
[app.common.uuid :as uuid]))
|
||||||
|
|
||||||
;; TODO: revisit this and rename to file-migrations
|
;; TODO: revisit this and rename to file-migrations
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@
|
||||||
(= :curve (:type object))
|
(= :curve (:type object))
|
||||||
(assoc :type :path)
|
(assoc :type :path)
|
||||||
|
|
||||||
(or (#{:curve :path} (:type object)))
|
(#{:curve :path} (:type object))
|
||||||
(migrate-path)
|
(migrate-path)
|
||||||
|
|
||||||
(= :frame (:type object))
|
(= :frame (:type object))
|
||||||
|
|
|
@ -11,11 +11,9 @@
|
||||||
(:require
|
(:require
|
||||||
#?(:clj [clojure.spec.alpha :as s]
|
#?(:clj [clojure.spec.alpha :as s]
|
||||||
:cljs [cljs.spec.alpha :as s])
|
:cljs [cljs.spec.alpha :as s])
|
||||||
|
|
||||||
[expound.alpha :as expound]
|
|
||||||
[app.common.uuid :as uuid]
|
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
|
[app.common.uuid :as uuid]
|
||||||
[cuerdas.core :as str]))
|
[cuerdas.core :as str]))
|
||||||
|
|
||||||
(s/check-asserts true)
|
(s/check-asserts true)
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
|
|
||||||
(ns app.common.text
|
(ns app.common.text
|
||||||
(:require
|
(:require
|
||||||
[app.common.attrs :as attrs]
|
|
||||||
[app.common.uuid :as uuid]
|
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.transit :as t]
|
[app.common.transit :as t]
|
||||||
[clojure.walk :as walk]
|
[clojure.walk :as walk]
|
||||||
|
|
|
@ -212,5 +212,5 @@
|
||||||
[v]
|
[v]
|
||||||
(try
|
(try
|
||||||
(-> v decode-str nil? not)
|
(-> v decode-str nil? not)
|
||||||
(catch #?(:cljs js/SyntaxError :clj Exception) e
|
(catch #?(:cljs js/SyntaxError :clj Exception) _e
|
||||||
false)))
|
false)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue