From 946f641917697595facf44b4cea33594246fa7ae Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 22 Sep 2025 11:12:43 +0200 Subject: [PATCH 1/6] :paperclip: Disable possible problematic migrations --- common/src/app/common/files/migrations.cljc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/app/common/files/migrations.cljc b/common/src/app/common/files/migrations.cljc index 2284f95e45..86f84fa5d7 100644 --- a/common/src/app/common/files/migrations.cljc +++ b/common/src/app/common/files/migrations.cljc @@ -1650,6 +1650,6 @@ "0007-clear-invalid-strokes-and-fills-v2" "0008-fix-library-colors-v4" "0009-clean-library-colors" - "0009-add-partial-text-touched-flags" - "0010-fix-swap-slots-pointing-non-existent-shapes" + #_"0009-add-partial-text-touched-flags" + #_"0010-fix-swap-slots-pointing-non-existent-shapes" "0011-fix-invalid-text-touched-flags"])) From 0b346e02ff5f1f5a916148c3dc34269d9060e2aa Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 22 Sep 2025 11:30:42 +0200 Subject: [PATCH 2/6] :bug: Fix incorrect options pass on decode-file --- backend/src/app/binfile/common.clj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/app/binfile/common.clj b/backend/src/app/binfile/common.clj index 9e614cc148..6299ab9179 100644 --- a/backend/src/app/binfile/common.clj +++ b/backend/src/app/binfile/common.clj @@ -188,9 +188,9 @@ and decoding." [cfg file-id & {:as opts}] (db/run! cfg (fn [{:keys [::db/conn] :as cfg}] - (some->> (db/get* conn :file {:id file-id} - (assoc opts ::db/remove-deleted false)) - (decode-file cfg))))) + (when-let [row (db/get* conn :file {:id file-id} + (assoc opts ::db/remove-deleted false))] + (decode-file cfg row opts))))) (defn clean-file-features [file] From cb4c155b324d379c1c550d1f5625b7739f8979b1 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 22 Sep 2025 11:38:52 +0200 Subject: [PATCH 3/6] :paperclip: Uncomment previously commented migrations --- common/src/app/common/files/migrations.cljc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/app/common/files/migrations.cljc b/common/src/app/common/files/migrations.cljc index 86f84fa5d7..2284f95e45 100644 --- a/common/src/app/common/files/migrations.cljc +++ b/common/src/app/common/files/migrations.cljc @@ -1650,6 +1650,6 @@ "0007-clear-invalid-strokes-and-fills-v2" "0008-fix-library-colors-v4" "0009-clean-library-colors" - #_"0009-add-partial-text-touched-flags" - #_"0010-fix-swap-slots-pointing-non-existent-shapes" + "0009-add-partial-text-touched-flags" + "0010-fix-swap-slots-pointing-non-existent-shapes" "0011-fix-invalid-text-touched-flags"])) From 8954b05d762acd5fe7e8dca5bfcf5550188358ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Mon, 22 Sep 2025 17:41:31 +0200 Subject: [PATCH 4/6] :bug: Fix error exporting a file with deleted tokens (#7356) --- CHANGES.md | 1 + backend/src/app/binfile/v3.clj | 11 ++++---- common/src/app/common/types/tokens_lib.cljc | 28 +++++++++++++-------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 0b4d53f3b1..0135f34f27 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -62,6 +62,7 @@ - Fix moving elements up or down while pressing alt [Taiga Issue #11992](https://tree.taiga.io/project/penpot/issue/11992) - Fix conflicting shortcuts (remove dec/inc line height and letter spacing) [Taiga #12102](https://tree.taiga.io/project/penpot/issue/12102) - Fix conflicting shortcuts (remove text-align shortcuts) [Taiga #12047](https://tree.taiga.io/project/penpot/issue/12047) +- Fix export file with empty tokens library [Taiga #12137](https://tree.taiga.io/project/penpot/issue/12137) ## 2.9.0 diff --git a/backend/src/app/binfile/v3.clj b/backend/src/app/binfile/v3.clj index 4e43f07b92..cb480d209a 100644 --- a/backend/src/app/binfile/v3.clj +++ b/backend/src/app/binfile/v3.clj @@ -27,7 +27,7 @@ [app.common.types.page :as ctp] [app.common.types.plugins :as ctpg] [app.common.types.shape :as cts] - [app.common.types.tokens-lib :as cto] + [app.common.types.tokens-lib :as ctob] [app.common.types.typography :as cty] [app.common.uuid :as uuid] [app.config :as cf] @@ -120,7 +120,7 @@ (sm/encoder cty/schema:typography sm/json-transformer)) (def encode-tokens-lib - (sm/encoder cto/schema:tokens-lib sm/json-transformer)) + (sm/encoder ctob/schema:tokens-lib sm/json-transformer)) (def encode-plugin-data (sm/encoder ctpg/schema:plugin-data sm/json-transformer)) @@ -158,7 +158,7 @@ (sm/decoder cty/schema:typography sm/json-transformer)) (def decode-tokens-lib - (sm/decoder cto/schema:tokens-lib sm/json-transformer)) + (sm/decoder ctob/schema:tokens-lib sm/json-transformer)) (def decode-plugin-data (sm/decoder ctpg/schema:plugin-data sm/json-transformer)) @@ -196,7 +196,7 @@ (sm/check-fn cty/schema:typography)) (def validate-tokens-lib - (sm/check-fn cto/schema:tokens-lib)) + (sm/check-fn ctob/schema:tokens-lib)) (def validate-plugin-data (sm/check-fn ctpg/schema:plugin-data)) @@ -349,7 +349,8 @@ typography (encode-typography object)] (write-entry! output path typography))) - (when tokens-lib + (when (and tokens-lib + (not (ctob/empty-lib? tokens-lib))) (let [path (str "files/" file-id "/tokens.json") encoded-tokens (encode-tokens-lib tokens-lib)] (write-entry! output path encoded-tokens))))) diff --git a/common/src/app/common/types/tokens_lib.cljc b/common/src/app/common/types/tokens_lib.cljc index 7e098e5cab..be0525be68 100644 --- a/common/src/app/common/types/tokens_lib.cljc +++ b/common/src/app/common/types/tokens_lib.cljc @@ -768,7 +768,8 @@ (theme-active? [_ group name] "predicate if token theme is active") (activate-theme [_ group name] "adds theme from the active-themes") (deactivate-theme [_ group name] "removes theme from the active-themes") - (toggle-theme-active? [_ group name] "toggles theme in the active-themes")) + (toggle-theme-active? [_ group name] "toggles theme in the active-themes") + (get-hidden-theme [_] "get the hidden temporary theme")) (def schema:token-themes [:and @@ -906,6 +907,7 @@ (defprotocol ITokensLib "A library of tokens, sets and themes." + (empty-lib? [_] "True if the lib does not contain any token, set or theme") (set-path-exists? [_ path] "if a set at `path` exists") (set-group-path-exists? [_ path] "if a set group at `path` exists") (add-token-in-set [_ set-name token] "add token to a set") @@ -1235,7 +1237,16 @@ Will return a value that matches this schema: (filter #(theme-active? this (:group %) (:name %)))) (tree-seq d/ordered-map? vals themes))) + (get-hidden-theme [this] + (get-theme this hidden-theme-group hidden-theme-name)) + ITokensLib + (empty-lib? [this] + (and (empty? sets) + (or (empty? themes) + (and (= (theme-count this) 1) + (get-hidden-theme this))))) + (set-path-exists? [_ set-path] (some? (get-in sets (set-full-path->set-prefixed-full-path set-path)))) @@ -1338,10 +1349,6 @@ Will return a value that matches this schema: cljs.core/IEncodeJS (-clj->js [this] (clj->js (datafy this))))) -(defn get-hidden-theme - [tokens-lib] - (get-theme tokens-lib hidden-theme-group hidden-theme-name)) - (defn valid-tokens-lib? [o] (and (instance? TokensLib o) @@ -1752,11 +1759,12 @@ Will return a value that matches this schema: active-set-names (get-active-themes-set-names tokens-lib)] - (-> sets - (assoc "$themes" themes) - (assoc "$metadata" {"tokenSetOrder" ordered-set-names - "activeThemes" active-themes - "activeSets" active-set-names})))) + (when-not (empty-lib? tokens-lib) + (-> sets + (assoc "$themes" themes) + (assoc "$metadata" {"tokenSetOrder" ordered-set-names + "activeThemes" active-themes + "activeSets" active-set-names}))))) (defn get-tokens-of-unknown-type "Search for all tokens in the decoded json file that have a type that is not currently From 59f7ede4ff34c83271edcfbf1215a4ac525c4dd3 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 23 Sep 2025 09:57:38 +0200 Subject: [PATCH 5/6] :bug: Add migration for properly decode all position data on text shapes --- backend/dev/user.clj | 7 ++++--- common/src/app/common/files/migrations.cljc | 23 ++++++++++++++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/backend/dev/user.clj b/backend/dev/user.clj index 522b5ae643..04040776ef 100644 --- a/backend/dev/user.clj +++ b/backend/dev/user.clj @@ -6,22 +6,24 @@ (ns user (:require + [app.binfile.common :as bfc] [app.common.data :as d] [app.common.debug :as debug] [app.common.exceptions :as ex] [app.common.files.helpers :as cfh] [app.common.fressian :as fres] [app.common.geom.matrix :as gmt] + [app.common.json :as json] [app.common.logging :as l] [app.common.perf :as perf] [app.common.pprint :as pp] [app.common.schema :as sm] [app.common.schema.desc-js-like :as smdj] [app.common.schema.desc-native :as smdn] - [app.common.schema.openapi :as oapi] [app.common.schema.generators :as sg] + [app.common.schema.openapi :as oapi] [app.common.spec :as us] - [app.common.json :as json] + [app.common.time :as ct] [app.common.transit :as t] [app.common.types.file :as ctf] [app.common.uuid :as uuid] @@ -31,7 +33,6 @@ [app.srepl.helpers :as srepl.helpers] [app.srepl.main :as srepl] [app.util.blob :as blob] - [app.common.time :as ct] [clj-async-profiler.core :as prof] [clojure.contrib.humanize :as hum] [clojure.java.io :as io] diff --git a/common/src/app/common/files/migrations.cljc b/common/src/app/common/files/migrations.cljc index 2284f95e45..f368db6069 100644 --- a/common/src/app/common/files/migrations.cljc +++ b/common/src/app/common/files/migrations.cljc @@ -31,6 +31,7 @@ [app.common.types.shape :as cts] [app.common.types.shape.interactions :as ctsi] [app.common.types.shape.shadow :as ctss] + [app.common.types.shape.text :as ctst] [app.common.types.text :as types.text] [app.common.uuid :as uuid] [clojure.set :as set] @@ -1585,6 +1586,25 @@ (-> data (update :pages-index d/update-vals update-page)))) +(defmethod migrate-data "0012-fix-position-data" + [data _] + (let [decode-fn + (sm/decoder ctst/schema:position-data sm/json-transformer) + + update-object + (fn [object] + (if (cfh/text-shape? object) + (d/update-when object :position-data decode-fn) + object)) + + update-container + (fn [container] + (d/update-when container :objects d/update-vals update-object))] + + (-> data + (update :pages-index d/update-vals update-container) + (d/update-when :components d/update-vals update-container)))) + (def available-migrations (into (d/ordered-set) ["legacy-2" @@ -1652,4 +1672,5 @@ "0009-clean-library-colors" "0009-add-partial-text-touched-flags" "0010-fix-swap-slots-pointing-non-existent-shapes" - "0011-fix-invalid-text-touched-flags"])) + "0011-fix-invalid-text-touched-flags" + "0012-fix-position-data"])) From 11b75408fe4d2e206e2f8e2287c8650c575b0b39 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 23 Sep 2025 11:38:33 +0200 Subject: [PATCH 6/6] :bug: Fix regression on importing binfile-v1 files (#7359) --- frontend/src/app/worker/import.cljs | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/app/worker/import.cljs b/frontend/src/app/worker/import.cljs index e9c235be44..a191b9466f 100644 --- a/frontend/src/app/worker/import.cljs +++ b/frontend/src/app/worker/import.cljs @@ -148,6 +148,7 @@ (->> (rp/cmd! ::sse/import-binfile {:name (str/replace (:name data) #".penpot$" "") :file file + :version 1 :project-id project-id}) (rx/tap (fn [event] (let [payload (sse/get-payload event)