From 4b22a0ebfbcd13a438ca5f43966e199e20e03e97 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 29 May 2025 12:08:50 +0200 Subject: [PATCH] :bug: Make the library generate output compatible with penpot 2.7.x --- common/src/app/common/files/builder.cljc | 26 +++++++++++++++++++++--- library/src/lib/export.cljs | 10 ++++++++- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/common/src/app/common/files/builder.cljc b/common/src/app/common/files/builder.cljc index 19e6681930..9bdbef8ec1 100644 --- a/common/src/app/common/files/builder.cljc +++ b/common/src/app/common/files/builder.cljc @@ -10,7 +10,7 @@ (:require [app.common.data :as d] [app.common.data.macros :as dm] - [app.common.features :as cfeat] + ;; [app.common.features :as cfeat] [app.common.files.changes :as ch] [app.common.files.migrations :as fmig] [app.common.geom.shapes :as gsh] @@ -198,11 +198,31 @@ (-> (get-current-objects state) (get shape-id))) +;; WORKAROUND: A copy of features from staging for make the library +;; generate files compatible with version released right now. This +;; should be removed and replaced with cfeat/default-features when 2.8 +;; version is released + +(def default-features + #{"fdata/shape-data-type" + "styles/v2" + "layout/grid" + "components/v2" + "plugins/runtime" + "design-tokens/v1"}) + +;; WORKAROUND: the same as features +(def available-migrations + (-> fmig/available-migrations + (disj "003-convert-path-content") + (disj "0002-clean-shape-interactions") + (disj "0003-fix-root-shape"))) + (defn add-file [state params] (let [params (-> params - (assoc :features cfeat/default-features) - (assoc :migrations fmig/available-migrations) + (assoc :features default-features) + (assoc :migrations available-migrations) (update :id default-uuid)) file (types.file/make-file params :create-page false)] (-> state diff --git a/library/src/lib/export.cljs b/library/src/lib/export.cljs index f2b7fec266..5d9ee3efa0 100644 --- a/library/src/lib/export.cljs +++ b/library/src/lib/export.cljs @@ -82,6 +82,14 @@ :is-shared :version}) +(defn- encode-shape* + [{:keys [type] :as shape}] + (let [shape (if (or (= type :path) + (= type :bool)) + (update shape :content vec) + shape)] + (-> shape encode-shape json/encode))) + (defn- generate-file-export-procs [{:keys [id data] :as file}] (cons @@ -109,7 +117,7 @@ (map (fn [[shape-id shape]] (let [shape (assoc shape :page-id page-id)] [(str "files/" id "/pages/" page-id "/" shape-id ".json") - (delay (-> shape encode-shape json/encode))])) + (delay (encode-shape* shape))])) objects))))))) (->> (get data :components)