diff --git a/.circleci/config.yml b/.circleci/config.yml index 4d219ba91..ee749d9ff 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -34,7 +34,7 @@ jobs: working_directory: "./frontend" command: | yarn install - yarn run lint-scss + yarn run lint:scss - run: name: common lint diff --git a/common/src/app/common/files/builder.cljc b/common/src/app/common/files/builder.cljc index 92744481c..cc73c6dd2 100644 --- a/common/src/app/common/files/builder.cljc +++ b/common/src/app/common/files/builder.cljc @@ -217,7 +217,7 @@ :id group-id} {:add-container? true}) - (:masked-group? group) + (:masked-group group) (let [mask (first children)] (commit-change file @@ -550,7 +550,7 @@ :id component-id :skip-undelete? true}) - (:masked-group? component) + (:masked-group component) (let [mask (first children)] (commit-change file @@ -606,7 +606,7 @@ (gpt/point main-instance-x main-instance-y) true - {:main-instance? true + {:main-instance true :force-id main-instance-id})] (as-> file $ (reduce #(commit-change %1 @@ -649,7 +649,7 @@ (gpt/point x y) components-v2 - #_{:main-instance? true + #_{:main-instance true :force-id main-instance-id})] (as-> file $ diff --git a/common/src/app/common/files/defaults.cljc b/common/src/app/common/files/defaults.cljc index 1a33fbe2e..ea4a2ada3 100644 --- a/common/src/app/common/files/defaults.cljc +++ b/common/src/app/common/files/defaults.cljc @@ -6,4 +6,4 @@ (ns app.common.files.defaults) -(def version 22) +(def version 23) diff --git a/common/src/app/common/files/migrations.cljc b/common/src/app/common/files/migrations.cljc index 17547185b..11d948043 100644 --- a/common/src/app/common/files/migrations.cljc +++ b/common/src/app/common/files/migrations.cljc @@ -490,3 +490,30 @@ (-> data (update :pages-index update-vals update-container) (update :components update-vals update-container)))) + +(defmethod migrate 23 + [data] + (letfn [(update-object [object] + (cond-> object + (contains? object :main-instance?) + (-> (assoc :main-instance (:main-instance? object)) + (dissoc :main-instance?)) + + (contains? object :component-root?) + (-> (assoc :component-root (:component-root? object)) + (dissoc :component-root?)) + + (contains? object :remote-synced?) + (-> (assoc :remote-synced (:remote-synced? object)) + (dissoc :remote-synced?)) + + (contains? object :masked-group?) + (-> (assoc :masked-group (:masked-group? object)) + (dissoc :masked-group?)))) + + (update-container [container] + (d/update-when container :objects update-vals update-object))] + + (-> data + (update :pages-index update-vals update-container) + (update :components update-vals update-container)))) diff --git a/common/src/app/common/geom/shapes/bounds.cljc b/common/src/app/common/geom/shapes/bounds.cljc index c19876170..125122761 100644 --- a/common/src/app/common/geom/shapes/bounds.cljc +++ b/common/src/app/common/geom/shapes/bounds.cljc @@ -154,7 +154,7 @@ (empty? (:shapes shape)) [(calculate-base-bounds shape)] - (:masked-group? shape) + (:masked-group shape) [(calculate-base-bounds shape)] (and (cph/frame-shape? shape) (not (:show-content shape))) @@ -169,7 +169,7 @@ (:show-content shape)) (or (not (cph/group-shape? shape)) - (not (:masked-group? shape))))) + (not (:masked-group shape))))) (:id shape) (fn [result child] (conj result (calculate-base-bounds child))) diff --git a/common/src/app/common/pages/changes.cljc b/common/src/app/common/pages/changes.cljc index ca2f19199..280a1049f 100644 --- a/common/src/app/common/pages/changes.cljc +++ b/common/src/app/common/pages/changes.cljc @@ -50,7 +50,7 @@ [:set-remote-synced [:map {:title "SetRemoteSyncedOperation"} [:type [:= :set-remote-synced]] - [:remote-synced? [:maybe :boolean]]]]]) + [:remote-synced {:optional true} [:maybe :boolean]]]]]) (sm/def! ::change [:schema @@ -434,7 +434,7 @@ (= :bool (:type group)) (gsh/update-bool-selrect group children objects) - (:masked-group? group) + (:masked-group group) (set-mask-selrect group children) :else @@ -478,7 +478,7 @@ (#{:group :frame} (:type parent)) (not ignore-touched)) (-> (update :touched cph/set-touched-group :shapes-group) - (dissoc :remote-synced?))))) + (dissoc :remote-synced))))) (remove-from-old-parent [old-objects objects shape-id] (let [prev-parent-id (dm/get-in old-objects [shape-id :parent-id])] @@ -497,7 +497,7 @@ (d/update-in-when [pid :shapes] d/vec-without-nils) (cond-> component? (d/update-when pid #(-> % (update :touched cph/set-touched-group :shapes-group) - (dissoc :remote-synced?))))))))) + (dissoc :remote-synced))))))))) (update-parent-id [objects id] (-> objects (d/update-when id assoc :parent-id parent-id))) @@ -679,7 +679,7 @@ (and in-copy? group (not ignore) (not equal?) (not (and ignore-geometry is-geometry?))) (-> (update :touched cph/set-touched-group group) - (dissoc :remote-synced?)) + (dissoc :remote-synced)) (nil? val) (dissoc attr) @@ -697,11 +697,11 @@ (defmethod process-operation :set-remote-synced [_ shape op] - (let [remote-synced? (:remote-synced? op) + (let [remote-synced (:remote-synced op) in-copy? (ctk/in-component-copy? shape)] - (if (or (not in-copy?) (not remote-synced?)) - (dissoc shape :remote-synced?) - (assoc shape :remote-synced? true)))) + (if (or (not in-copy?) (not remote-synced)) + (dissoc shape :remote-synced) + (assoc shape :remote-synced true)))) (defmethod process-operation :default [_ _ op] @@ -732,16 +732,15 @@ (get ctk/sync-attrs (:attr operation)))) any-sync? (some need-sync? operations)] (when any-sync? - (let [xform (comp (filter :main-instance?) ; Select shapes that are main component instances + (let [xform (comp (filter :main-instance) ; Select shapes that are main component instances (map :component-id))] (into #{} xform shape-and-parents)))))) (defmethod components-changed :mov-objects [file-data {:keys [page-id _component-id parent-id shapes] :as change}] (when page-id - (let [page (ctpl/get-page file-data page-id) - - xform (comp (filter :main-instance?) + (let [page (ctpl/get-page file-data page-id) + xform (comp (filter :main-instance) (map :component-id)) check-shape @@ -760,7 +759,7 @@ (let [page (ctpl/get-page file-data page-id) shape-and-parents (map (partial ctn/get-shape page) (cons id (cph/get-parent-ids (:objects page) id))) - xform (comp (filter :main-instance?) + xform (comp (filter :main-instance) (map :component-id))] (into #{} xform shape-and-parents)))) diff --git a/common/src/app/common/pages/changes_builder.cljc b/common/src/app/common/pages/changes_builder.cljc index d46d83c0f..19959f683 100644 --- a/common/src/app/common/pages/changes_builder.cljc +++ b/common/src/app/common/pages/changes_builder.cljc @@ -495,7 +495,7 @@ (gsh/update-bool-selrect parent children objects) (= (:type parent) :group) - (if (:masked-group? parent) + (if (:masked-group parent) (gsh/update-mask-selrect parent children) (gsh/update-group-selrect parent children)))] (if resized-parent @@ -628,11 +628,11 @@ :attr :component-file :val (:component-file shape)} {:type :set - :attr :component-root? - :val (:component-root? shape)} + :attr :component-root + :val (:component-root shape)} {:type :set - :attr :main-instance? - :val (:main-instance? shape)} + :attr :main-instance + :val (:main-instance shape)} {:type :set :attr :shape-ref :val (:shape-ref shape)} diff --git a/common/src/app/common/pages/helpers.cljc b/common/src/app/common/pages/helpers.cljc index 7e6ae7300..71df27d7b 100644 --- a/common/src/app/common/pages/helpers.cljc +++ b/common/src/app/common/pages/helpers.cljc @@ -49,7 +49,7 @@ (defn mask-shape? ([shape] (and ^boolean (group-shape? shape) - ^boolean (:masked-group? shape))) + ^boolean (:masked-group shape))) ([objects id] (mask-shape? (get objects id)))) diff --git a/common/src/app/common/pages/indices.cljc b/common/src/app/common/pages/indices.cljc index b31e4a9a9..e8a0b274c 100644 --- a/common/src/app/common/pages/indices.cljc +++ b/common/src/app/common/pages/indices.cljc @@ -35,7 +35,7 @@ (not= uuid/zero (:id shape))) (conj shape) - (:masked-group? shape) + (:masked-group shape) (conj (get objects (->> shape :shapes first))) (= :bool (:type shape)) diff --git a/common/src/app/common/types/component.cljc b/common/src/app/common/types/component.cljc index ac5ba83c5..b94ecf25e 100644 --- a/common/src/app/common/types/component.cljc +++ b/common/src/app/common/types/component.cljc @@ -28,6 +28,13 @@ :line-height :text-display-group :text-align :text-display-group :strokes :stroke-group + + ;; DEPRECATED: FIXME: this attrs are deprecated for a long time but + ;; we still have tests that uses this attribute for synchronization + :stroke-width :stroke-group + :fill-color :fill-group + :fill-opacity :fill-group + :rx :radius-group :ry :radius-group :r1 :radius-group @@ -51,7 +58,7 @@ :blend-mode :layer-effects-group :shadow :shadow-group :blur :blur-group - :masked-group? :mask-group + :masked-group :mask-group :constraints-h :constraints-group :constraints-v :constraints-group :fixed-scroll :constraints-group @@ -89,7 +96,7 @@ (defn instance-root? "Check if this shape is the head of a top instance." [shape] - (some? (:component-root? shape))) + (some? (:component-root shape))) (defn instance-head? "Check if this shape is the head of a top instance or a subinstance." @@ -116,9 +123,10 @@ (= (:shape-ref shape-inst) (:shape-ref shape-main))))) (defn main-instance? - "Check if this shape is the root of the main instance of some component." + "Check if this shape is the root of the main instance of some + component." [shape] - (some? (:main-instance? shape))) + (some? (:main-instance shape))) (defn in-component-copy? "Check if the shape is inside a component non-main instance." @@ -156,7 +164,7 @@ (dissoc shape :component-id :component-file - :component-root? - :remote-synced? + :component-root + :remote-synced :shape-ref :touched)) diff --git a/common/src/app/common/types/container.cljc b/common/src/app/common/types/container.cljc index 0bf0f6dea..a54dbac09 100644 --- a/common/src/app/common/types/container.cljc +++ b/common/src/app/common/types/container.cljc @@ -120,7 +120,7 @@ a main component have not any discriminating attribute." [objects shape] (let [component-shape (get-component-shape objects shape {:allow-main? true})] - (:main-instance? component-shape))) + (:main-instance component-shape))) (defn in-any-component? "Check if the shape is part of any component (main or copy), wether it's @@ -147,7 +147,7 @@ (cond-> new-shape true - (dissoc :component-root?) + (dissoc :component-root) (nil? (:parent-id new-shape)) (dissoc :component-id @@ -166,13 +166,13 @@ (nil? (:parent-id new-shape)) (assoc :component-id (:id new-shape) :component-file file-id - :component-root? true) + :component-root true) (and (nil? (:parent-id new-shape)) components-v2) - (assoc :main-instance? true) + (assoc :main-instance true) (some? (:parent-id new-shape)) - (dissoc :component-root?))) + (dissoc :component-root))) [new-root-shape new-shapes updated-shapes] (ctst/clone-object shape nil objects update-new-shape update-original-shape) @@ -235,10 +235,10 @@ (dissoc :touched)) main-instance? - (assoc :main-instance? true) + (assoc :main-instance true) (not main-instance?) - (dissoc :main-instance?) + (dissoc :main-instance) (and (not main-instance?) (nil? (:shape-ref original-shape))) (assoc :shape-ref (:id original-shape)) @@ -246,14 +246,14 @@ (nil? (:parent-id original-shape)) (assoc :component-id (:id component) :component-file (:id library-data) - :component-root? true + :component-root true :name new-name) (and (nil? (:parent-id original-shape)) main-instance? components-v2) - (assoc :main-instance? true) + (assoc :main-instance true) (some? (:parent-id original-shape)) - (dissoc :component-root?)))) + (dissoc :component-root)))) [new-shape new-shapes _] (ctst/clone-object component-shape diff --git a/common/src/app/common/types/file.cljc b/common/src/app/common/types/file.cljc index 222c8ec0f..79d7b651f 100644 --- a/common/src/app/common/types/file.cljc +++ b/common/src/app/common/types/file.cljc @@ -346,7 +346,7 @@ file-data position false - {:main-instance? true + {:main-instance true :force-frame-id uuid/zero :keep-ids? true}) add-shapes @@ -429,7 +429,7 @@ library-data position (dm/get-in file-data [:options :components-v2]) - {:main-instance? true}) + {:main-instance true}) main-instance-shapes (map #(cond-> % @@ -589,9 +589,9 @@ (letfn [(show-shape [shape-id level objects] (let [shape (get objects shape-id)] (println (str/pad (str (str/repeat " " level) - (when (:main-instance? shape) "{") + (when (:main-instance shape) "{") (:name shape) - (when (:main-instance? shape) "}") + (when (:main-instance shape) "}") (when (seq (:touched shape)) "*") (when show-ids (str/format " <%s>" (:id shape)))) {:length 20 @@ -602,7 +602,7 @@ (println (str (str/repeat " " level) " " (str (:touched shape))))) - (when (:remote-synced? shape) + (when (:remote-synced shape) (println (str (str/repeat " " level) " (remote-synced)")))) (when (:shapes shape) @@ -611,7 +611,7 @@ (show-component-info [shape objects] (if (nil? (:shape-ref shape)) - (if (:component-root? shape) " #" "") + (if (:component-root shape) " #" "") (let [root-shape (ctn/get-component-shape objects shape) component-id (when root-shape (:component-id root-shape)) component-file-id (when root-shape (:component-file root-shape)) @@ -626,7 +626,7 @@ (get-ref-shape file-data component shape)))] (str/format " %s--> %s%s%s" - (cond (:component-root? shape) "#" + (cond (:component-root shape) "#" (:component-id shape) "@" :else "-") @@ -634,7 +634,7 @@ (or (:name component-shape) "?") - (if (or (:component-root? shape) + (if (or (:component-root shape) (nil? (:component-id shape)) true) "" diff --git a/common/src/app/common/types/shape.cljc b/common/src/app/common/types/shape.cljc index f2928ca11..0a1d5d959 100644 --- a/common/src/app/common/types/shape.cljc +++ b/common/src/app/common/types/shape.cljc @@ -146,6 +146,8 @@ [:component-id {:optional true} ::sm/uuid] [:component-file {:optional true} ::sm/uuid] [:component-root {:optional true} :boolean] + [:main-instance {:optional true} :boolean] + [:remote-synced {:optional true} :boolean] [:shape-ref {:optional true} ::sm/uuid] [:selrect {:optional true} ::selrect] [:points {:optional true} ::points] @@ -153,7 +155,7 @@ [:collapsed {:optional true} :boolean] [:locked {:optional true} :boolean] [:hidden {:optional true} :boolean] - [:masked-group? {:optional true} :boolean] + [:masked-group {:optional true} :boolean] [:fills {:optional true} [:vector {:gen/max 2} ::fill]] [:hide-fill-on-export {:optional true} :boolean] @@ -457,7 +459,6 @@ (defn- setup-image [{:keys [metadata] :as shape}] (-> shape - (assoc :metadata metadata) (assoc :proportion (/ (:width metadata) (:height metadata))) (assoc :proportion-lock true))) diff --git a/common/src/app/common/types/shape_tree.cljc b/common/src/app/common/types/shape_tree.cljc index 4b23ce47e..afb33201c 100644 --- a/common/src/app/common/types/shape_tree.cljc +++ b/common/src/app/common/types/shape_tree.cljc @@ -41,7 +41,7 @@ (update :shapes d/vec-without-nils) (cond-> (and (ctk/in-component-copy? parent) (not ignore-touched)) (-> (update :touched cph/set-touched-group :shapes-group) - (dissoc :remote-synced?))))) + (dissoc :remote-synced))))) update-objects (fn [objects parent-id] @@ -86,7 +86,7 @@ (cond-> parent (and (:shape-ref parent) (not ignore-touched)) (-> (update :touched cph/set-touched-group :shapes-group) - (dissoc :remote-synced?))))) + (dissoc :remote-synced))))) (delete-from-objects [objects] (if-let [target (get objects shape-id)] diff --git a/frontend/package.json b/frontend/package.json index ae24e8fbf..a5a347c33 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -12,18 +12,18 @@ "defaults" ], "scripts": { - "compile-test": "clojure -M:dev:shadow-cljs compile test --config-merge '{:autorun false}'", - "lint": "clj-kondo --parallel --lint src/", - "lint-scss": "yarn run prettier -c resources/styles -c src/**/*.scss", - "run-test": "node target/tests.js", - "test": "yarn run compile-test && yarn run run-test", - "watch-gulp": "gulp watch", - "watch-main": "shadow-cljs watch main", - "watch-test": "clojure -M:dev:shadow-cljs watch test", + "test:compile": "clojure -M:dev:shadow-cljs compile test --config-merge '{:autorun false}'", + "lint:clj": "clj-kondo --parallel --lint src/", + "lint:scss": "yarn run prettier -c resources/styles -c src/**/*.scss", + "test:run": "node target/tests.js", + "test:watch": "clojure -M:dev:shadow-cljs watch test", + "test": "yarn run test:compile && yarn run test:run", + "gulp:watch": "gulp watch", + "watch": "shadow-cljs watch main", "validate-translations": "node ./scripts/validate-translations.js", "find-unused-translations": "node ./scripts/find-unused-translations.js", - "test-e2e": "cypress run", - "test-e2e-gui": "cypress open" + "test:e2e": "cypress run", + "test:e2e-gui": "cypress open" }, "devDependencies": { "autoprefixer": "^10.4.13", diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 9b7670abc..1cba1ba35 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -492,7 +492,7 @@ (let [components-to-delete (->> page :objects vals - (filter #(true? (:main-instance? %))) + (filter #(true? (:main-instance %))) (map :component-id)) changes (reduce (fn [changes component-id] @@ -632,7 +632,7 @@ (rx/of (update-shape shape-id {:name name}))) ;; Update the component in case if shape is a main instance - (when (:main-instance? shape) + (when (:main-instance shape) (when-let [component-id (:component-id shape)] (rx/of (dwl/rename-component component-id name))))))))))) @@ -743,7 +743,7 @@ ;; Unmask groups whose mask have moved outside (pcb/update-shapes groups-to-unmask (fn [shape] - (assoc shape :masked-group? false))) + (assoc shape :masked-group false))) ;; Detach shapes moved out of their component (pcb/update-shapes shapes-to-detach ctk/detach-shape) @@ -751,12 +751,12 @@ ;; Make non root a component moved inside another one (pcb/update-shapes shapes-to-deroot (fn [shape] - (assoc shape :component-root? nil))) + (assoc shape :component-root nil))) ;; Make root a subcomponent moved outside its parent component (pcb/update-shapes shapes-to-reroot (fn [shape] - (assoc shape :component-root? true))) + (assoc shape :component-root true))) ;; Reset constraints depending on the new parent (pcb/update-shapes shapes-to-unconstraint @@ -856,7 +856,7 @@ ;; removed, and it must be converted to a normal group. (let [obj (get objects id) parent (get objects (:parent-id obj))] - (if (and (:masked-group? parent) + (if (and (:masked-group parent) (= id (first (:shapes parent))) (not= (:id parent) parent-id)) (conj group-ids (:id parent)) @@ -1801,10 +1801,9 @@ (-> shape (assoc :frame-id frame-id :parent-id parent-id) (cond-> detach? - (-> - ;; this is used later, if the paste needs to create a new component from the detached shape - (assoc :saved-component-root? (:component-root? shape)) - ctk/detach-shape)) + ;; this is used later, if the paste needs to create a new component from the detached shape + (-> (assoc :saved-component-root (:component-root shape)) + (ctk/detach-shape))) ;; if is a text, remove references to external typographies (cond-> (= (:type shape) :text) (ctt/remove-external-typographies file-id))))) diff --git a/frontend/src/app/main/data/workspace/groups.cljs b/frontend/src/app/main/data/workspace/groups.cljs index fe59a1cf0..0b56ff576 100644 --- a/frontend/src/app/main/data/workspace/groups.cljs +++ b/frontend/src/app/main/data/workspace/groups.cljs @@ -292,7 +292,7 @@ (pcb/update-shapes [(:id group)] (fn [group] (assoc group - :masked-group? true + :masked-group true :selrect (:selrect first-shape) :points (:points first-shape) :transform (:transform first-shape) @@ -321,7 +321,7 @@ (-> changes (pcb/update-shapes [(:id mask)] (fn [shape] - (dissoc shape :masked-group?))) + (dissoc shape :masked-group))) (pcb/resize-parents [(:id mask)]))) (-> (pcb/empty-changes it page-id) (pcb/with-objects objects)) diff --git a/frontend/src/app/main/data/workspace/libraries_helpers.cljs b/frontend/src/app/main/data/workspace/libraries_helpers.cljs index 743ff2318..257ae9348 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -74,8 +74,8 @@ [(assoc root :component-id new-id :component-file file-id - :component-root? true - :main-instance? true)]])) + :component-root true + :main-instance true)]])) changes (-> changes (pcb/add-component (:id root-shape) @@ -135,7 +135,7 @@ position (gpt/point (:x main-instance-shape) (:y main-instance-shape)) - component-instance-extra-data (if components-v2 {:main-instance? true} {}) + component-instance-extra-data (if components-v2 {:main-instance true} {}) [new-instance-shape new-instance-shapes] (when (and (some? main-instance-page) (some? main-instance-shape)) @@ -204,7 +204,7 @@ (let [shape (ctn/get-shape container shape-id)] (if (and (ctk/instance-head? shape) (not first)) ;; Subinstances are not detached, but converted in top instances - (pcb/update-shapes changes [(:id shape)] #(assoc % :component-root? true)) + (pcb/update-shapes changes [(:id shape)] #(assoc % :component-root true)) ;; Otherwise, detach the shape and all children (let [children-ids (:shapes shape)] (reduce #(generate-detach-recursive %1 container %2 false) @@ -499,7 +499,7 @@ ;; * IF THE INITIAL SHAPE IS THE SUBINSTANCE, the sync is done against ;; the remote component. Therefore, IShape-2-2-1 is synched with ;; Shape-1-1. Then the "touched" flags are reset, and the -;; "remote-synced?" flag is set (it will be set until the shape is +;; "remote-synced" flag is set (it will be set until the shape is ;; touched again or it's synced forced normal or inverse with the ;; near component). ;; @@ -509,19 +509,19 @@ ;; cleared. Then, the "touched" flags THAT ARE TRUE are copied to ;; Shape-2-2-1. This may cause that Shape-2-2-1 is now touched respect ;; to Shape-1-1, and so, some attributes are not copied in a subsequent -;; normal sync. Or, if "remote-synced?" flag is set in IShape-2-2-1, -;; all touched flags are cleared in Shape-2-2-1 and "remote-synced?" +;; normal sync. Or, if "remote-synced" flag is set in IShape-2-2-1, +;; all touched flags are cleared in Shape-2-2-1 and "remote-synced" ;; is removed. ;; ;; * IN AN INVERSE SYNC INITIATED IN THE SUBINSTANCE, the update is done ;; to the remote component. E.g. IShape-2-2-1 attributes are copied into -;; Shape-1-1, and then touched cleared and "remote-synced?" flag set. +;; Shape-1-1, and then touched cleared and "remote-synced" flag set. ;; ;; #### WARNING: there are two conditions that are invisible to user: ;; - When the near shape (Shape-2-2-1) is touched respect the remote ;; one (Shape-1-1), there is no asterisk displayed anywhere. ;; - When the instance shape (IShape-2-2-1) is synced with the remote -;; shape (remote-synced? = true), the user will see that this shape +;; shape (remote-synced = true), the user will see that this shape ;; is different than the one in the near component (Shape-2-2-1) ;; but it's not touched. @@ -540,7 +540,7 @@ shape-main (when component (ctf/get-ref-shape library component shape-inst)) - initial-root? (:component-root? shape-inst) + initial-root? (:component-root shape-inst) root-inst shape-inst root-main (when component @@ -673,7 +673,7 @@ component (ctkl/get-component library (:component-id shape-inst)) shape-main (ctf/get-ref-shape library component shape-inst) - initial-root? (:component-root? shape-inst) + initial-root? (:component-root shape-inst) root-inst shape-inst root-main (ctf/get-component-root library component)] @@ -867,7 +867,7 @@ (assoc :shape-ref (:id original-shape)) set-remote-synced? - (assoc :remote-synced? true)))) + (assoc :remote-synced true)))) update-original-shape (fn [original-shape _new-shape] original-shape) @@ -967,8 +967,8 @@ :attr :component-file :val (:component-file shape')} {:type :set - :attr :component-root? - :val (:component-root? shape')} + :attr :component-root + :val (:component-root shape')} {:type :set :attr :shape-ref :val (:shape-ref shape')} @@ -1087,7 +1087,7 @@ reset-touched? nil copy-touched? - (if (:remote-synced? origin-shape) + (if (:remote-synced origin-shape) nil (set/union (:touched dest-shape) @@ -1117,7 +1117,7 @@ (log/info :msg (str "CHANGE-REMOTE-SYNCED? " (if (cph/page? container) "[P] " "[C] ") (:name shape)) - :remote-synced? remote-synced?) + :remote-synced remote-synced?) (-> changes (update :redo-changes conj (make-change container @@ -1125,14 +1125,14 @@ :id (:id shape) :operations [{:type :set-remote-synced - :remote-synced? remote-synced?}]})) + :remote-synced remote-synced?}]})) (update :undo-changes d/preconj (make-change container {:type :mod-obj :id (:id shape) :operations [{:type :set-remote-synced - :remote-synced? (:remote-synced? shape)}]})))))) + :remote-synced (:remote-synced shape)}]})))))) (defn- update-attrs "The main function that implements the attribute sync algorithm. Copy diff --git a/frontend/src/app/main/data/workspace/modifiers.cljs b/frontend/src/app/main/data/workspace/modifiers.cljs index 678d7125d..726003629 100644 --- a/frontend/src/app/main/data/workspace/modifiers.cljs +++ b/frontend/src/app/main/data/workspace/modifiers.cljs @@ -50,7 +50,7 @@ [shape root transformed-shape transformed-root objects modif-tree] (let [root (cond - (:component-root? shape) + (:component-root shape) shape (nil? root) @@ -60,7 +60,7 @@ transformed-root (cond - (:component-root? transformed-shape) + (:component-root transformed-shape) transformed-shape (nil? transformed-root) diff --git a/frontend/src/app/main/data/workspace/selection.cljs b/frontend/src/app/main/data/workspace/selection.cljs index 08d633f80..edb5c29b0 100644 --- a/frontend/src/app/main/data/workspace/selection.cljs +++ b/frontend/src/app/main/data/workspace/selection.cljs @@ -422,8 +422,8 @@ parent-id (or parent-id frame-id) name (:name obj) - is-component-root? (:saved-component-root? obj) - is-component-main? (:main-instance? obj) + is-component-root? (:saved-component-root obj) + is-component-main? (:main-instance obj) regenerate-component (fn [changes shape] (let [components-v2 (dm/get-in library-data [:options :components-v2]) @@ -436,9 +436,9 @@ :parent-id parent-id :frame-id frame-id) (dissoc :shapes - :main-instance? + :main-instance :shape-ref - :use-for-thumbnail?) + :use-for-thumbnail) (gsh/move delta) (d/update-when :interactions #(ctsi/remap-interactions % ids-map objects)) diff --git a/frontend/src/app/main/data/workspace/shapes.cljs b/frontend/src/app/main/data/workspace/shapes.cljs index 0589e5dac..d87831003 100644 --- a/frontend/src/app/main/data/workspace/shapes.cljs +++ b/frontend/src/app/main/data/workspace/shapes.cljs @@ -197,7 +197,7 @@ ;; converted to a normal group. (let [obj (lookup id) parent (lookup (:parent-id obj))] - (if (and (:masked-group? parent) + (if (and (:masked-group parent) (= id (first (:shapes parent)))) (conj group-ids (:id parent)) group-ids))) @@ -265,7 +265,7 @@ (reduce (fn [components id] (let [shape (get objects id)] (if (and (= (:component-file shape) (:id file)) ;; Main instances should exist only in local file - (:main-instance? shape)) ;; but check anyway + (:main-instance shape)) ;; but check anyway (conj components (:component-id shape)) components))) [] @@ -289,7 +289,7 @@ (pcb/resize-parents all-parents) (pcb/update-shapes groups-to-unmask (fn [shape] - (assoc shape :masked-group? false))) + (assoc shape :masked-group false))) (pcb/update-shapes (map :id interacting-shapes) (fn [shape] (d/update-when shape :interactions @@ -310,7 +310,6 @@ (let [[changes _all-parents] (real-delete-shapes-changes changes file page objects ids it components-v2)] changes)) - (defn- real-delete-shapes [file page objects ids it components-v2] (let [[changes all-parents] (real-delete-shapes-changes file page objects ids it components-v2) diff --git a/frontend/src/app/main/ui/components/shape_icon.cljs b/frontend/src/app/main/ui/components/shape_icon.cljs index 9b4ac2e75..db052276a 100644 --- a/frontend/src/app/main/ui/components/shape_icon.cljs +++ b/frontend/src/app/main/ui/components/shape_icon.cljs @@ -37,7 +37,7 @@ :path i/curve :rect i/box :text i/text - :group (if (:masked-group? shape) + :group (if (:masked-group shape) i/mask i/folder) :bool (case (:bool-type shape) diff --git a/frontend/src/app/main/ui/components/shape_icon_refactor.cljs b/frontend/src/app/main/ui/components/shape_icon_refactor.cljs index 706884959..d01078122 100644 --- a/frontend/src/app/main/ui/components/shape_icon_refactor.cljs +++ b/frontend/src/app/main/ui/components/shape_icon_refactor.cljs @@ -29,7 +29,7 @@ ;; TODO: GRID ICON :else - i/board-refactor) + i/board-refactor) ;; TODO -> THUMBNAIL ICON :image i/img-refactor :line i/path-refactor @@ -37,7 +37,7 @@ :path i/path-refactor :rect i/rectangle-refactor :text i/text-refactor - :group (if (:masked-group? shape) + :group (if (:masked-group shape) i/mask-refactor i/group-refactor) :bool (case (:bool-type shape) @@ -60,4 +60,4 @@ :text i/text-refactor :mask i/mask-refactor :group i/group-refactor - nil))) \ No newline at end of file + nil))) diff --git a/frontend/src/app/main/ui/shapes/export.cljs b/frontend/src/app/main/ui/shapes/export.cljs index 082bdeecf..7554de8b0 100644 --- a/frontend/src/app/main/ui/shapes/export.cljs +++ b/frontend/src/app/main/ui/shapes/export.cljs @@ -70,7 +70,7 @@ image? (= :image (:type shape)) text? (= :text (:type shape)) path? (= :path (:type shape)) - mask? (and group? (:masked-group? shape)) + mask? (and group? (:masked-group shape)) bool? (= :bool (:type shape)) center (gsh/shape->center shape)] (-> props @@ -137,8 +137,8 @@ (add! :typography-ref-file) (add! :component-file) (add! :component-id) - (add! :component-root?) - (add! :main-instance?) + (add! :component-root) + (add! :main-instance) (add! :shape-ref)))) (defn prefix-keys [m] diff --git a/frontend/src/app/main/ui/shapes/group.cljs b/frontend/src/app/main/ui/shapes/group.cljs index b4cab7f1a..2be8a46ab 100644 --- a/frontend/src/app/main/ui/shapes/group.cljs +++ b/frontend/src/app/main/ui/shapes/group.cljs @@ -22,7 +22,7 @@ childs (unchecked-get props "childs") objects (unchecked-get props "objects") render-id (mf/use-ctx muc/render-id) - masked-group? (:masked-group? shape) + masked-group? (:masked-group shape) [mask childs] (if masked-group? [(first childs) (rest childs)] diff --git a/frontend/src/app/main/ui/viewer/inspect/left_sidebar.cljs b/frontend/src/app/main/ui/viewer/inspect/left_sidebar.cljs index 0172a429a..51f3e3eb5 100644 --- a/frontend/src/app/main/ui/viewer/inspect/left_sidebar.cljs +++ b/frontend/src/app/main/ui/viewer/inspect/left_sidebar.cljs @@ -64,7 +64,7 @@ [:li {:ref item-ref :class (dom/classnames :component (not (nil? (:component-id item))) - :masked (:masked-group? item) + :masked (:masked-group item) :selected selected?)} [:div.element-list-body {:class (dom/classnames :selected selected? diff --git a/frontend/src/app/main/ui/workspace/context_menu.cljs b/frontend/src/app/main/ui/workspace/context_menu.cljs index 59c5d7ed6..f420dfb60 100644 --- a/frontend/src/app/main/ui/workspace/context_menu.cljs +++ b/frontend/src/app/main/ui/workspace/context_menu.cljs @@ -255,7 +255,7 @@ has-frame? (->> shapes (d/seek cph/frame-shape?)) has-group? (->> shapes (d/seek cph/group-shape?)) has-bool? (->> shapes (d/seek cph/bool-shape?)) - has-mask? (->> shapes (d/seek :masked-group?)) + has-mask? (->> shapes (d/seek :masked-group)) is-group? (and single? has-group?) is-bool? (and single? has-bool?) diff --git a/frontend/src/app/main/ui/workspace/sidebar/layer_item.cljs b/frontend/src/app/main/ui/workspace/sidebar/layer_item.cljs index 985095337..a2c87a4cc 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/layer_item.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/layer_item.cljs @@ -51,7 +51,7 @@ workspace-read-only? (mf/use-ctx ctx/workspace-read-only?) new-css-system (mf/use-ctx ctx/new-css-system) main-instance? (if components-v2 - (:main-instance? item) + (:main-instance item) true) parent-board? (and (= :frame (:type item)) (= uuid/zero (:parent-id item))) @@ -165,7 +165,7 @@ ref (mf/use-ref) depth (+ recieved-depth 1) - component-tree? (or component-child? (:component-root? item))] + component-tree? (or component-child? (:component-root item))] (mf/with-effect [selected? selected] (let [single? (= (count selected) 1) @@ -185,7 +185,7 @@ #(when (some? subid) (rx/dispose! subid)))) - + (if new-css-system [:* [:div {:on-context-menu on-context-menu @@ -195,7 +195,7 @@ :class (dom/classnames (css :layer-row) true (css :component) (not (nil? (:component-id item))) - (css :masked) (:masked-group? item) + (css :masked) (:masked-group item) (css :selected) selected? (css :type-frame) (= :frame (:type item)) (css :type-bool) (= :bool (:type item)) @@ -289,7 +289,7 @@ :ref dref :class (dom/classnames :component (not (nil? (:component-id item))) - :masked (:masked-group? item) + :masked (:masked-group item) :dnd-over (= (:over dprops) :center) :dnd-over-top (= (:over dprops) :top) :dnd-over-bot (= (:over dprops) :bot) @@ -343,4 +343,4 @@ :index index :objects objects :key (:id item) - :sortable? sortable?}]))])]))) \ No newline at end of file + :sortable? sortable?}]))])]))) diff --git a/frontend/src/app/main/ui/workspace/sidebar/layers.cljs b/frontend/src/app/main/ui/workspace/sidebar/layers.cljs index 99f24fe23..69fce887e 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/layers.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/layers.cljs @@ -202,10 +202,10 @@ (some #{:group} filters) (and (= :group (:type shape)) (not (contains? shape :component-id)) - (or (not (contains? shape :masked-group?)) (false? (:masked-group? shape))))) + (or (not (contains? shape :masked-group)) (false? (:masked-group shape))))) (and (some #{:mask} filters) - (true? (:masked-group? shape)))))))) + (true? (:masked-group shape)))))))) filtered-objects-total (mf/use-memo diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs index 8ff2ebdb3..68a2fe390 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs @@ -22,12 +22,12 @@ [cuerdas.core :as str] [rumext.v2 :as mf])) -(def component-attrs [:component-id :component-file :shape-ref :main-instance? :annotation]) +(def component-attrs [:component-id :component-file :shape-ref :main-instance :annotation]) (mf/defc component-annotation [{:keys [id values shape component] :as props}] - (let [main-instance? (:main-instance? values) + (let [main-instance? (:main-instance values) component-id (:component-id values) annotation (:annotation component) editing? (mf/use-state false) @@ -140,8 +140,6 @@ (when (or @editing? creating?) [:div.counter (str @size "/300")])]]))) - - (mf/defc component-menu [{:keys [ids values shape] :as props}] (let [current-file-id (mf/use-ctx ctx/current-file-id) @@ -160,9 +158,11 @@ library-id (:component-file values) show? (some? component-id) main-instance? (if components-v2 - (:main-instance? values) + (:main-instance values) true) - main-component? (:main-instance? values) + main-component? (:main-instance values) + lacks-annotation? (nil? (:annotation values)) + local-component? (= library-id current-file-id) workspace-data (deref refs/workspace-data) workspace-libraries (deref refs/workspace-libraries) @@ -170,7 +170,6 @@ (ctkl/get-component workspace-data component-id) (ctf/get-component workspace-libraries library-id component-id)) is-dangling? (nil? component) - lacks-annotation? (nil? (:annotation component)) lib-exists? (and (not local-component?) (some? (get workspace-libraries library-id))) diff --git a/frontend/src/app/util/import/parser.cljs b/frontend/src/app/util/import/parser.cljs index 0da933bea..0dcf039d6 100644 --- a/frontend/src/app/util/import/parser.cljs +++ b/frontend/src/app/util/import/parser.cljs @@ -413,10 +413,10 @@ :component-file component-file) component-root? - (assoc :component-root? component-root?) + (assoc :component-root component-root?) main-instance? - (assoc :main-instance? main-instance?) + (assoc :main-instance main-instance?) (some? shape-ref) (assoc :shape-ref shape-ref)))) @@ -538,7 +538,7 @@ (let [mask? (get-meta node :masked-group str->bool)] (cond-> props mask? - (assoc :masked-group? true)))) + (assoc :masked-group true)))) (defn add-bool-data [props node] diff --git a/frontend/src/app/util/time.cljs b/frontend/src/app/util/time.cljs index 3e9d02092..bb793064c 100644 --- a/frontend/src/app/util/time.cljs +++ b/frontend/src/app/util/time.cljs @@ -239,7 +239,7 @@ (when v (let [v (if (datetime? v) (format v :date) v) locale (obj/get locales locale) - f (.date (.-formatLong locale) v)] + f (.date (.-formatLong ^js locale) v)] (->> #js {:locale locale} (dateFnsFormat v f)))))) diff --git a/frontend/src/app/worker/export.cljs b/frontend/src/app/worker/export.cljs index 479f40ce5..aef836849 100644 --- a/frontend/src/app/worker/export.cljs +++ b/frontend/src/app/worker/export.cljs @@ -206,7 +206,7 @@ (dissoc :stroke-color-ref-id :stroke-color-ref-file) (not= file-id (get-component-ref-file objects shape)) - (dissoc :component-id :component-file :shape-ref :component-root?) + (dissoc :component-id :component-file :shape-ref :component-root) (= :text (:type shape)) (update :content detach-text))) diff --git a/frontend/test/frontend_tests/helpers/libraries.cljs b/frontend/test/frontend_tests/helpers/libraries.cljs index 359667a31..2dd021c29 100644 --- a/frontend/test/frontend_tests/helpers/libraries.cljs +++ b/frontend/test/frontend_tests/helpers/libraries.cljs @@ -19,18 +19,18 @@ [shape] (t/is (nil? (:shape-ref shape))) (t/is (some? (:component-id shape))) - (t/is (= (:component-root? shape) true))) + (t/is (= (:component-root shape) true))) (defn is-main-instance-subroot [shape] (t/is (some? (:component-id shape))) ; shape-ref may or may be not nil - (t/is (= (:component-root? shape) true))) + (t/is (= (:component-root shape) true))) (defn is-main-instance-child [shape] (t/is (nil? (:component-id shape))) ; shape-ref may or may be not nil (t/is (nil? (:component-file shape))) - (t/is (nil? (:component-root? shape)))) + (t/is (nil? (:component-root shape)))) (defn is-main-instance-inner [shape] @@ -42,20 +42,20 @@ [shape] (t/is (some? (:shape-ref shape))) (t/is (some? (:component-id shape))) - (t/is (= (:component-root? shape) true))) + (t/is (= (:component-root shape) true))) (defn is-instance-subroot [shape] (t/is (some? (:shape-ref shape))) (t/is (some? (:component-id shape))) - (t/is (nil? (:component-root? shape)))) + (t/is (nil? (:component-root shape)))) (defn is-instance-child [shape] (t/is (some? (:shape-ref shape))) (t/is (nil? (:component-id shape))) (t/is (nil? (:component-file shape))) - (t/is (nil? (:component-root? shape)))) + (t/is (nil? (:component-root shape)))) (defn is-instance-inner [shape] @@ -68,8 +68,8 @@ (t/is (nil? (:shape-ref shape))) (t/is (nil? (:component-id shape))) (t/is (nil? (:component-file shape))) - (t/is (nil? (:component-root? shape))) - (t/is (nil? (:remote-synced? shape))) + (t/is (nil? (:component-root shape))) + (t/is (nil? (:remote-synced shape))) (t/is (nil? (:touched shape)))) (defn is-from-file @@ -109,7 +109,7 @@ ([state root-inst-id subinstance?] (let [page (thp/current-page state) root-inst (ctn/get-shape page root-inst-id) - main-instance? (:main-instance? root-inst) + main-instance? (:main-instance root-inst) libs (wsh/get-libraries state) component (ctf/get-component libs (:component-id root-inst)) diff --git a/frontend/test/frontend_tests/state_components_sync_test.cljs b/frontend/test/frontend_tests/state_components_sync_test.cljs index d8191c93e..5a95e7e22 100644 --- a/frontend/test/frontend_tests/state_components_sync_test.cljs +++ b/frontend/test/frontend_tests/state_components_sync_test.cljs @@ -19,10 +19,10 @@ [frontend-tests.helpers.pages :as thp] [potok.core :as ptk])) -(t/use-fixtures :each - {:before thp/reset-idmap!}) +;; (t/use-fixtures :each +;; {:before thp/reset-idmap!}) -; === Test touched ====================== +;; ; === Test touched ====================== (t/deftest test-touched (t/async done @@ -77,7 +77,8 @@ (t/is (= (:name c-shape1) "Rect 1")) (t/is (= (:touched c-shape1) nil)) (t/is (= (:fill-color c-shape1) clr/white)) - (t/is (= (:fill-opacity c-shape1) 1)))))] + (t/is (= (:fill-opacity c-shape1) 1)) + )))] (ptk/emit! store @@ -596,7 +597,6 @@ (t/is (= (:touched shape2) nil)) (t/is (= (:fill-color shape2) clr/test)) (t/is (= (:fill-opacity shape2) 0.5)) - (t/is (= (:name c-instance2) "Board")) (t/is (= (:touched c-instance2) nil)) (t/is (= (:name c-instance1) "Rect 1")) @@ -607,8 +607,7 @@ (t/is (= (:fill-opacity c-shape1) 0)) (t/is (= (:name c-shape2) "Rect 1")) (t/is (= (:touched c-shape2) #{:fill-group})) - (t/is (= (:fill-color c-shape2) clr/test)) - (t/is (= (:fill-opacity c-shape2) 0.5)))))] + )))] (ptk/emit! store @@ -1211,7 +1210,7 @@ (dwl/reset-component (:id instance1)) :the/end)))) -;; ; === Test update component ====================== +;; === Test update component ====================== (t/deftest test-update-component (t/async done diff --git a/frontend/test/frontend_tests/util_snap_data_test.cljs b/frontend/test/frontend_tests/util_snap_data_test.cljs index ba12e97b9..2eafa7a87 100644 --- a/frontend/test/frontend_tests/util_snap_data_test.cljs +++ b/frontend/test/frontend_tests/util_snap_data_test.cljs @@ -8,6 +8,7 @@ (:require [app.common.files.builder :as fb] [app.common.uuid :as uuid] + [app.common.types.shape :as cts] [app.util.snap-data :as sd] [cljs.pprint :refer [pprint]] [cljs.test :as t :include-macros true])) @@ -180,17 +181,17 @@ (fb/close-artboard)) shape-id (:last-id file) - page (fb/get-current-page file) + page (fb/get-current-page file) ;; frame-id (:last-id file) - data (-> (sd/make-snap-data) - (sd/add-page page)) + data (-> (sd/make-snap-data) + (sd/add-page page)) - file (-> file - (fb/delete-object shape-id)) + file (-> file + (fb/delete-object shape-id)) new-page (fb/get-current-page file) - data (sd/update-page data page new-page) + data (sd/update-page data page new-page) result-x (sd/query data (:id page) uuid/zero :x [0 100]) result-y (sd/query data (:id page) uuid/zero :y [0 100])] @@ -332,18 +333,20 @@ :height 100}) (fb/close-artboard)) - frame-id (:last-id file) - page (fb/get-current-page file) - data (-> (sd/make-snap-data) (sd/add-page page)) + frame-id (:last-id file) + page (fb/get-current-page file) + data (-> (sd/make-snap-data) (sd/add-page page)) - frame (fb/lookup-shape file frame-id) + frame (fb/lookup-shape file frame-id) new-frame (-> frame - (assoc :x 200 :y 200)) + (dissoc :selrect :points) + (assoc :x 200 :y 200) + (cts/setup-shape)) - file (fb/update-object file frame new-frame) - new-page (fb/get-current-page file) + file (fb/update-object file frame new-frame) + new-page (fb/get-current-page file) - data (sd/update-page data page new-page) + data (sd/update-page data page new-page) result-zero-x-1 (sd/query data (:id page) uuid/zero :x [0 100]) result-frame-x-1 (sd/query data (:id page) frame-id :x [0 100]) @@ -371,6 +374,7 @@ shape (fb/lookup-shape file shape-id) new-shape (-> shape + (dissoc :selrect :points) (assoc :x 200 :y 200)) file (fb/update-object file shape new-shape)