♻️ Rename fill to fills namespace

This commit is contained in:
Andrey Antukh 2025-07-09 08:45:42 +02:00
parent 158f759cde
commit 4e2998a366
18 changed files with 75 additions and 74 deletions

View file

@ -26,7 +26,7 @@
[app.common.types.component :as ctk]
[app.common.types.container :as ctn]
[app.common.types.file :as ctf]
[app.common.types.fill :as types.fill]
[app.common.types.fills :as types.fills]
[app.common.types.path :as path]
[app.common.types.path.segment :as path.segment]
[app.common.types.shape :as cts]
@ -838,7 +838,7 @@
(d/update-when :components d/update-vals update-container))))
(def ^:private valid-fill?
(sm/lazy-validator types.fill/schema:fill))
(sm/lazy-validator types.fills/schema:fill))
(defmethod migrate-data "legacy-43"
[data _]
@ -1466,7 +1466,7 @@
(clear-fill [fill]
(-> fill
(select-keys types.fill/fill-attrs)
(select-keys types.fills/fill-attrs)
(d/update-when :fill-image clear-color-image)
(d/update-when :fill-color-gradient clear-color-gradient)))

View file

@ -4,11 +4,11 @@
;;
;; Copyright (c) KALEIDOS INC
(ns app.common.types.fill
(ns app.common.types.fills
(:require
[app.common.schema :as sm]
[app.common.types.color :as types.color]
[app.common.types.fill.impl :as impl]
[app.common.types.fills.impl :as impl]
[clojure.set :as set]))
(def ^:const MAX-GRADIENT-STOPS impl/MAX-GRADIENT-STOPS)

View file

@ -4,7 +4,7 @@
;;
;; Copyright (c) KALEIDOS INC
(ns app.common.types.fill.impl
(ns app.common.types.fills.impl
(:require
#?(:clj [clojure.data.json :as json])
#?(:cljs [app.common.weak-map :as weak-map])

View file

@ -25,6 +25,7 @@
(def ^:cosnt bool-group-style-properties bool/group-style-properties)
(def ^:const bool-style-properties bool/style-properties)
(def ^:const default-bool-fills bool/default-fills)
(def schema:content impl/schema:content)

View file

@ -21,7 +21,7 @@
[app.common.text :as txt]
[app.common.transit :as t]
[app.common.types.color :as types.color]
[app.common.types.fill :refer [schema:fill]]
[app.common.types.fills :refer [schema:fill]]
[app.common.types.grid :as ctg]
[app.common.types.path :as path]
[app.common.types.path.segment :as path.segment]

View file

@ -7,7 +7,7 @@
(ns app.common.types.shape.text
(:require
[app.common.schema :as sm]
[app.common.types.fill :refer [schema:fill]]
[app.common.types.fills :refer [schema:fill]]
[app.common.types.shape :as-alias shape]
[app.common.types.shape.text.position-data :as-alias position-data]))

View file

@ -19,7 +19,7 @@
(t/use-fixtures :each thi/test-fixture)
(t/deftest test-sync-unchanged-copy-when-changed-attribute
(t/deftest sync-unchanged-copy-when-changed-attribute
(let [;; ==== Setup
file (-> (thf/sample-file :file1)
(tho/add-frame-with-text :main-root :main-child "hello world")
@ -55,7 +55,7 @@
(t/is (= "32" (:font-size line)))
(t/is (= "hello world" (:text line)))))
(t/deftest test-sync-unchanged-copy-when-changed-text
(t/deftest sync-unchanged-copy-when-changed-text
(let [;; ==== Setup
file (-> (thf/sample-file :file1)
(tho/add-frame-with-text :main-root :main-child "hello world")
@ -91,7 +91,7 @@
(t/is (= "14" (:font-size line)))
(t/is (= "Bye" (:text line)))))
(t/deftest test-sync-unchanged-copy-when-changed-both
(t/deftest sync-unchanged-copy-when-changed-both
(let [;; ==== Setup
file (-> (thf/sample-file :file1)
(tho/add-frame-with-text :main-root :main-child "hello world")
@ -129,7 +129,7 @@
(t/is (= "32" (:font-size line)))
(t/is (= "Bye" (:text line)))))
(t/deftest test-sync-updated-attr-copy-when-changed-attribute
(t/deftest sync-updated-attr-copy-when-changed-attribute
(let [;; ==== Setup
file0 (-> (thf/sample-file :file1)
(tho/add-frame-with-text :main-root :main-child "hello world")
@ -176,7 +176,7 @@
(t/is (= "14" (:font-size line)))
(t/is (= "hello world" (:text line)))))
(t/deftest test-sync-updated-attr-copy-when-changed-text
(t/deftest sync-updated-attr-copy-when-changed-text
(let [;; ==== Setup
file0 (-> (thf/sample-file :file1)
(tho/add-frame-with-text :main-root :main-child "hello world")
@ -223,7 +223,7 @@
;; The text is updated because only attrs were touched
(t/is (= "Bye" (:text line)))))
(t/deftest test-sync-updated-attr-copy-when-changed-both
(t/deftest sync-updated-attr-copy-when-changed-both
(let [;; ==== Setup
file0 (-> (thf/sample-file :file1)
(tho/add-frame-with-text :main-root :main-child "hello world")
@ -273,7 +273,7 @@
;; The text is updated because only attrs were touched
(t/is (= "Bye" (:text line)))))
(t/deftest test-sync-updated-text-copy-when-changed-attribute
(t/deftest sync-updated-text-copy-when-changed-attribute
(let [;; ==== Setup
file0 (-> (thf/sample-file :file1)
(tho/add-frame-with-text :main-root :main-child "hello world")
@ -320,7 +320,7 @@
(t/is (= "32" (:font-size line)))
(t/is (= "Hi" (:text line)))))
(t/deftest test-sync-updated-text-copy-when-changed-text
(t/deftest sync-updated-text-copy-when-changed-text
(let [;; ==== Setup
file0 (-> (thf/sample-file :file1)
(tho/add-frame-with-text :main-root :main-child "hello world")
@ -367,7 +367,7 @@
;; The text doesn't change, because it was touched
(t/is (= "Hi" (:text line)))))
(t/deftest test-sync-updated-text-copy-when-changed-both
(t/deftest sync-updated-text-copy-when-changed-both
(let [;; ==== Setup
file0 (-> (thf/sample-file :file1)
(tho/add-frame-with-text :main-root :main-child "hello world")
@ -417,7 +417,7 @@
;; The text doesn't change, because it was touched
(t/is (= "Hi" (:text line)))))
(t/deftest test-sync-updated-both-copy-when-changed-attribute
(t/deftest sync-updated-both-copy-when-changed-attribute
(let [;; ==== Setup
file0 (-> (thf/sample-file :file1)
(tho/add-frame-with-text :main-root :main-child "hello world")
@ -466,7 +466,7 @@
(t/is (= "14" (:font-size line)))
(t/is (= "Hi" (:text line)))))
(t/deftest test-sync-updated-both-copy-when-changed-text
(t/deftest sync-updated-both-copy-when-changed-text
(let [;; ==== Setup
file0 (-> (thf/sample-file :file1)
(tho/add-frame-with-text :main-root :main-child "hello world")
@ -515,7 +515,7 @@
;; The text doesn't change, because it was touched
(t/is (= "Hi" (:text line)))))
(t/deftest test-sync-updated-both-copy-when-changed-both
(t/deftest sync-updated-both-copy-when-changed-both
(let [;; ==== Setup
file0 (-> (thf/sample-file :file1)
(tho/add-frame-with-text :main-root :main-child "hello world")
@ -567,7 +567,7 @@
;; The text doesn't change, because it was touched
(t/is (= "Hi" (:text line)))))
(t/deftest test-sync-updated-structure-same-attrs-copy-when-changed-attribute
(t/deftest sync-updated-structure-same-attrs-copy-when-changed-attribute
(let [;; ==== Setup
file0 (-> (thf/sample-file :file1)
(tho/add-frame-with-text :main-root :main-child "hello world")
@ -619,7 +619,7 @@
(t/is (= "32" (:font-size line)))
(t/is (= "hello world" (:text line)))))
(t/deftest test-sync-updated-structure-same-attrs-copy-when-changed-text
(t/deftest sync-updated-structure-same-attrs-copy-when-changed-text
(let [;; ==== Setup
file0 (-> (thf/sample-file :file1)
(tho/add-frame-with-text :main-root :main-child "hello world")
@ -668,7 +668,7 @@
;; The text doesn't change, because the structure was touched
(t/is (= "hello world" (:text line)))))
(t/deftest test-sync-updated-structure-same-attrs-copy-when-changed-both
(t/deftest sync-updated-structure-same-attrs-copy-when-changed-both
(let [;; ==== Setup
file0 (-> (thf/sample-file :file1)
(tho/add-frame-with-text :main-root :main-child "hello world")
@ -722,7 +722,7 @@
;; The text doesn't change, because the structure was touched
(t/is (= "hello world" (:text line)))))
(t/deftest test-sync-updated-structure-diff-attrs-copy-when-changed-attribute
(t/deftest sync-updated-structure-diff-attrs-copy-when-changed-attribute
(let [;; ==== Setup
file0 (-> (thf/sample-file :file1)
(tho/add-frame-with-text :main-root :main-child "hello world")
@ -775,7 +775,7 @@
(t/is (= "14" (:font-size line)))
(t/is (= "hello world" (:text line)))))
(t/deftest test-sync-updated-structure-diff-attrs-copy-when-changed-text
(t/deftest sync-updated-structure-diff-attrs-copy-when-changed-text
(let [;; ==== Setup
file0 (-> (thf/sample-file :file1)
(tho/add-frame-with-text :main-root :main-child "hello world")
@ -825,7 +825,7 @@
;; The text doesn't change, because the structure was touched
(t/is (= "hello world" (:text line)))))
(t/deftest test-sync-updated-structure-diff-attrs-copy-when-changed-both
(t/deftest sync-updated-structure-diff-attrs-copy-when-changed-both
(let [;; ==== Setup
file0 (-> (thf/sample-file :file1)
(tho/add-frame-with-text :main-root :main-child "hello world")
@ -878,4 +878,4 @@
;; The attr doesn't change, because not all the attrs on the structure are equal
(t/is (= "14" (:font-size line)))
;; The text doesn't change, because the structure was touched
(t/is (= "hello world" (:text line)))))
(t/is (= "hello world" (:text line)))))

View file

@ -15,7 +15,7 @@
[app.common.schema.generators :as sg]
[app.common.schema.test :as smt]
[app.common.transit :as trans]
[app.common.types.fill :as types.fill]
[app.common.types.fills :as types.fills]
[app.common.uuid :as uuid]
[clojure.test :as t]))
@ -85,8 +85,8 @@
:fill-opacity 0.7})
(t/deftest build-from-plain-1
(let [fills (types.fill/from-plain [sample-fill-1])]
(t/is (types.fill/fills? fills))
(let [fills (types.fills/from-plain [sample-fill-1])]
(t/is (types.fills/fills? fills))
(t/is (= 1 (count fills)))
(t/is (equivalent-fill? (first fills) sample-fill-1))))
@ -99,8 +99,8 @@
:keep-aspect-ratio false}})
(t/deftest build-from-plain-2
(let [fills (types.fill/from-plain [sample-fill-2])]
(t/is (types.fill/fills? fills))
(let [fills (types.fills/from-plain [sample-fill-2])]
(t/is (types.fills/fills? fills))
(t/is (= 1 (count fills)))
(t/is (equivalent-fill? (first fills) sample-fill-2))))
@ -117,8 +117,8 @@
:stops [{:color "#631aa8", :offset 0.5}]}})
(t/deftest build-from-plain-3
(let [fills (types.fill/from-plain [sample-fill-3])]
(t/is (types.fill/fills? fills))
(let [fills (types.fills/from-plain [sample-fill-3])]
(t/is (types.fills/fills? fills))
(t/is (= 1 (count fills)))
(t/is (equivalent-fill? (first fills) sample-fill-3))))
@ -136,8 +136,8 @@
:fill-color-ref-id #uuid "2eef07f1-e38a-8062-8006-3aa264d5b785"})
(t/deftest build-from-plain-4
(let [fills (types.fill/from-plain [sample-fill-4])]
(t/is (types.fill/fills? fills))
(let [fills (types.fills/from-plain [sample-fill-4])]
(t/is (types.fills/fills? fills))
(t/is (= 1 (count fills)))
(t/is (equivalent-fill? (first fills) sample-fill-4))))
@ -154,8 +154,8 @@
:stops [{:color "#bba1aa", :opacity 0.37, :offset 0.84}]}})
(t/deftest build-from-plain-5
(let [fills (types.fill/from-plain [sample-fill-5])]
(t/is (types.fill/fills? fills))
(let [fills (types.fills/from-plain [sample-fill-5])]
(t/is (types.fills/fills? fills))
(t/is (= 1 (count fills)))
(t/is (equivalent-fill? (first fills) sample-fill-5))))
@ -170,14 +170,14 @@
:stops [{:color "#e15610", :offset 0.4} {:color "#005a9e", :opacity 0.62, :offset 0.81}]}})
(t/deftest build-from-plain-6
(let [fills (types.fill/from-plain [sample-fill-6])]
(t/is (types.fill/fills? fills))
(let [fills (types.fills/from-plain [sample-fill-6])]
(t/is (types.fills/fills? fills))
(t/is (= 1 (count fills)))
(t/is (equivalent-fill? (first fills) sample-fill-6))))
(t/deftest fills-datatype-roundtrip
(smt/check!
(smt/for [fill (->> (sg/generator types.fill/schema:fill)
(smt/for [fill (->> (sg/generator types.fills/schema:fill)
(sg/fmap d/without-nils)
(sg/fmap (fn [fill]
(cond-> fill
@ -187,27 +187,27 @@
(contains? fill :fill-color-ref-file)))
(-> (assoc :fill-color-ref-file (uuid/next))
(assoc :fill-color-ref-id (uuid/next)))))))]
(let [bfills (types.fill/from-plain [fill])]
(let [bfills (types.fills/from-plain [fill])]
(and (= (count bfills) 1)
(equivalent-fill? (first bfills) fill))))
{:num 2000}))
(t/deftest equality-operation
(let [fills1 (types.fill/from-plain [sample-fill-6])
fills2 (types.fill/from-plain [sample-fill-6])]
(let [fills1 (types.fills/from-plain [sample-fill-6])
fills2 (types.fills/from-plain [sample-fill-6])]
(t/is (= fills1 fills2))))
(t/deftest reduce-impl
(let [fills1 (types.fill/from-plain [sample-fill-6])
(let [fills1 (types.fills/from-plain [sample-fill-6])
fills2 (reduce (fn [result fill]
(conj result fill))
[]
fills1)
fills3 (types.fill/from-plain fills2)]
fills3 (types.fills/from-plain fills2)]
(t/is (= fills1 fills3))))
(t/deftest indexed-access
(let [fills1 (types.fill/from-plain [sample-fill-6])
(let [fills1 (types.fills/from-plain [sample-fill-6])
fill0 (nth fills1 0)
fill1 (nth fills1 1)]
(t/is (nil? fill1))

View file

@ -20,7 +20,7 @@
[app.common.logic.shapes :as cls]
[app.common.transit :as t]
[app.common.types.component :as ctc]
[app.common.types.fill :as types.fill]
[app.common.types.fills :as types.fills]
[app.common.types.shape :as cts]
[app.common.types.shape-tree :as ctst]
[app.common.uuid :as uuid]
@ -144,7 +144,7 @@
(letfn [(process-map-form [form]
(let [fills (get form :fills)]
(if (vector? fills)
(assoc form :fills (types.fill/from-plain fills))
(assoc form :fills (types.fills/from-plain fills))
form)))
(process-form [form]

View file

@ -13,7 +13,7 @@
[app.common.schema :as sm]
[app.common.text :as txt]
[app.common.types.color :as types.color]
[app.common.types.fill :as types.fill]
[app.common.types.fills :as types.fills]
[app.common.types.shape :as shp]
[app.common.types.shape.shadow :refer [check-shadow]]
[app.config :as cfg]
@ -153,7 +153,7 @@
(d/without-nils)
:always
(types.fill/check-fill))
(types.fills/check-fill))
transform-attrs
#(transform % fill)]
@ -893,7 +893,7 @@
(update state :colorpicker
(fn [{:keys [stops editing-stop] :as state}]
(let [cap-stops? (or (features/active-feature? state "render-wasm/v1") (contains? cfg/flags :frontend-binary-fills))
can-add-stop? (or (not cap-stops?) (< (count stops) types.fill/MAX-GRADIENT-STOPS))]
can-add-stop? (or (not cap-stops?) (< (count stops) types.fills/MAX-GRADIENT-STOPS))]
(if can-add-stop?
(if (cc/uniform-spread? stops)
;; Add to uniform
@ -939,7 +939,7 @@
(fn [state]
(let [stops (:stops state)
cap-stops? (or (features/active-feature? state "render-wasm/v1") (contains? cfg/flags :frontend-binary-fills))
can-add-stop? (or (not cap-stops?) (< (count stops) types.fill/MAX-GRADIENT-STOPS))]
can-add-stop? (or (not cap-stops?) (< (count stops) types.fills/MAX-GRADIENT-STOPS))]
(if can-add-stop? (let [new-stop (-> (cc/interpolate-gradient stops offset)
(split-color-components))
stops (conj stops new-stop)
@ -963,7 +963,7 @@
(contains? cfg/flags :frontend-binary-fills))
stops (mapv split-color-components
(if cap-stops?
(take types.fill/MAX-GRADIENT-STOPS stops)
(take types.fills/MAX-GRADIENT-STOPS stops)
stops))]
(-> state
(assoc :current-color (get stops stop))

View file

@ -16,7 +16,7 @@
[app.common.geom.shapes :as gsh]
[app.common.math :as mth]
[app.common.text :as txt]
[app.common.types.fill :as types.fill]
[app.common.types.fills :as types.fills]
[app.common.types.modifiers :as ctm]
[app.common.uuid :as uuid]
[app.main.data.event :as ev]
@ -237,7 +237,7 @@
(defn- to-new-fills
[data]
[(d/without-nils (select-keys data types.fill/fill-attrs))])
[(d/without-nils (select-keys data types.fills/fill-attrs))])
(defn- shape-current-values
[shape pred attrs]
@ -247,7 +247,7 @@
(if (txt/is-text-node? node)
(let [fills
(cond
(types.fill/has-valid-fill-attrs? node)
(types.fills/has-valid-fill-attrs? node)
(to-new-fills node)
(some? (:fills node))
@ -466,7 +466,7 @@
(defn migrate-node
[node]
(let [color-attrs (not-empty (select-keys node types.fill/fill-attrs))]
(let [color-attrs (not-empty (select-keys node types.fills/fill-attrs))]
(cond-> node
(nil? (:fills node))
(assoc :fills [])

View file

@ -12,7 +12,7 @@
[app.common.data.macros :as dm]
[app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt]
[app.common.types.fill :as types.fill]
[app.common.types.fills :as types.fills]
[app.config :as cfg]
[app.main.data.event :as-alias ev]
[app.main.data.modal :as modal]
@ -413,7 +413,7 @@
(when (= selected-mode :gradient)
[:> gradients*
{:type (:type state)
:stops (if cap-stops? (vec (take types.fill/MAX-GRADIENT-STOPS (:stops state))) (:stops state))
:stops (if cap-stops? (vec (take types.fills/MAX-GRADIENT-STOPS (:stops state))) (:stops state))
:editing-stop (:editing-stop state)
:on-stop-edit-start handle-stop-edit-start
:on-stop-edit-finish handle-stop-edit-finish

View file

@ -11,7 +11,7 @@
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.math :as mth]
[app.common.types.fill :as types.fill]
[app.common.types.fills :as types.fills]
[app.config :as cfg]
[app.main.features :as features]
[app.main.ui.components.numeric-input :refer [numeric-input*]]
@ -288,7 +288,7 @@
(when on-reverse-stops
(on-reverse-stops))))
cap-stops? (or (features/use-feature "render-wasm/v1") (contains? cfg/flags :frontend-binary-fills))
add-stop-disabled? (when cap-stops? (>= (count stops) types.fill/MAX-GRADIENT-STOPS))]
add-stop-disabled? (when cap-stops? (>= (count stops) types.fills/MAX-GRADIENT-STOPS))]
[:div {:class (stl/css :gradient-panel)}
[:div {:class (stl/css :gradient-preview)}

View file

@ -8,7 +8,7 @@
(:require-macros [app.main.style :as stl])
(:require
[app.common.types.color :as ctc]
[app.common.types.fill :as types.fill]
[app.common.types.fills :as types.fills]
[app.common.types.shape.attrs :refer [default-color]]
[app.config :as cfg]
[app.main.data.workspace :as udw]
@ -28,7 +28,7 @@
(def ^:private
xf:take-max-fills
(take types.fill/MAX-FILLS))
(take types.fills/MAX-FILLS))
(def ^:private
xf:enumerate
@ -101,7 +101,7 @@
can-add-fills?
(if binary-fills-enabled?
(and (not multiple?)
(< (count fills) types.fill/MAX-FILLS))
(< (count fills) types.fills/MAX-FILLS))
(not ^boolean multiple?))
label

View file

@ -15,7 +15,7 @@
[app.common.geom.shapes :as gsh]
[app.common.geom.shapes.points :as gsp]
[app.common.math :as mth]
[app.common.types.fill :as types.fill]
[app.common.types.fills :as types.fills]
[app.config :as cfg]
[app.main.data.workspace.colors :as dc]
[app.main.features :as features]
@ -135,7 +135,7 @@
handler-state (mf/use-state {:display? false :offset 0 :hover nil})
cap-stops? (or (features/use-feature "render-wasm/v1") (contains? cfg/flags :frontend-binary-fills))
can-add-stop? (if cap-stops? (< (count stops) types.fill/MAX-GRADIENT-STOPS) true)
can-add-stop? (if cap-stops? (< (count stops) types.fills/MAX-GRADIENT-STOPS) true)
endpoint-on-pointer-down
(fn [position event]
@ -527,7 +527,7 @@
gradient (:gradient state)
cap-stops? (or (features/use-feature "render-wasm/v1") (contains? cfg/flags :frontend-binary-fills))
stops (if cap-stops?
(vec (take types.fill/MAX-GRADIENT-STOPS (:stops state)))
(vec (take types.fills/MAX-GRADIENT-STOPS (:stops state)))
(:stops state))
editing-stop (:editing-stop state)]

View file

@ -20,7 +20,7 @@
[app.common.types.component :as ctk]
[app.common.types.container :as ctn]
[app.common.types.file :as ctf]
[app.common.types.fill :as types.fill]
[app.common.types.fills :as types.fills]
[app.common.types.grid :as ctg]
[app.common.types.path :as path]
[app.common.types.path.segment :as path.segm]
@ -709,7 +709,7 @@
id (:id shape)
value (parser/parse-fills value)]
(cond
(not (sm/validate [:vector types.fill/schema:fill] value))
(not (sm/validate [:vector types.fills/schema:fill] value))
(u/display-not-valid :fills value)
(cfh/text-shape? shape)

View file

@ -12,7 +12,7 @@
[app.common.data.macros :as dm]
[app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt]
[app.common.types.fill :as types.fill]
[app.common.types.fills :as types.fills]
[app.common.types.path :as path]
[app.common.types.shape.layout :as ctl]
[app.common.uuid :as uuid]
@ -248,7 +248,7 @@
[shape-id fills]
(if (empty? fills)
(h/call wasm/internal-module "_clear_shape_fills")
(let [fills (take types.fill/MAX-FILLS fills)
(let [fills (take types.fills/MAX-FILLS fills)
image-fills (filter :fill-image fills)
offset (mem/alloc-bytes (* (count fills) sr-fills/FILL-BYTE-SIZE))
heap (mem/get-heap-u8)

View file

@ -1,7 +1,7 @@
(ns app.render-wasm.serializers.fills
(:require
[app.common.data.macros :as dm]
[app.common.types.fill :as types.fill]
[app.common.types.fills :as types.fills]
[app.common.uuid :as uuid]
[app.render-wasm.serializers.color :as clr]))
@ -41,7 +41,7 @@
end-x (:end-x gradient)
end-y (:end-y gradient)
width (or (:width gradient) 0)
stops (take types.fill/MAX-GRADIENT-STOPS (:stops gradient))
stops (take types.fills/MAX-GRADIENT-STOPS (:stops gradient))
type (if (= (:type gradient) :linear) 0x01 0x02)]
(.setUint8 dview offset type true)
(.setFloat32 dview (+ offset 4) start-x true)