diff --git a/common/src/app/common/types/tokens_lib.cljc b/common/src/app/common/types/tokens_lib.cljc index 5e278588a7..89d9eb2032 100644 --- a/common/src/app/common/types/tokens_lib.cljc +++ b/common/src/app/common/types/tokens_lib.cljc @@ -909,7 +909,8 @@ Will return a value that matches this schema: `:all` All of the nested sets are active `:partial` Mixed active state of nested sets") (get-tokens-in-active-sets [_] "set of set names that are active in the the active themes") - (get-all-tokens [_] "all tokens in the lib") + (get-all-tokens [_] "all tokens in the lib, as a sequence") + (get-all-tokens-map [_] "all tokens in the lib, as a map name -> token") (get-tokens [_ set-id] "return a map of tokens in the set, indexed by token-name")) (declare parse-multi-set-dtcg-json) @@ -1306,6 +1307,10 @@ Will return a value that matches this schema: tokens)) (get-all-tokens [this] + (mapcat #(vals (get-tokens- %)) + (get-sets this))) + + (get-all-tokens-map [this] (reduce (fn [tokens' set] (into tokens' (map (fn [x] [(:name x) x]) (vals (get-tokens- set))))) diff --git a/frontend/src/app/main/data/workspace/tokens/import_export.cljs b/frontend/src/app/main/data/workspace/tokens/import_export.cljs index e7f872243d..7370da7921 100644 --- a/frontend/src/app/main/data/workspace/tokens/import_export.cljs +++ b/frontend/src/app/main/data/workspace/tokens/import_export.cljs @@ -74,7 +74,7 @@ (when unknown-tokens (st/emit! (show-unknown-types-warning unknown-tokens))) (try - (->> (ctob/get-all-tokens tokens-lib) + (->> (ctob/get-all-tokens-map tokens-lib) (sd/resolve-tokens-with-verbose-errors) (rx/map (fn [_] tokens-lib)) diff --git a/frontend/src/app/main/data/workspace/tokens/remapping.cljs b/frontend/src/app/main/data/workspace/tokens/remapping.cljs index 8442cbcd02..be9a1290c9 100644 --- a/frontend/src/app/main/data/workspace/tokens/remapping.cljs +++ b/frontend/src/app/main/data/workspace/tokens/remapping.cljs @@ -20,6 +20,9 @@ [cuerdas.core :as str] [potok.v2.core :as ptk])) +;; Change this to :info :debug or :trace to debug this module, or :warn to reset to default +(log/set-level! :warn) + ;; Token Reference Scanning ;; ======================== @@ -72,7 +75,7 @@ ;; Scan tokens library for alias references to the specific token matching-aliases (if tokens-lib (let [all-tokens (ctob/get-all-tokens tokens-lib)] - (mapcat #(scan-token-value-references % old-token-name) (vals all-tokens))) + (mapcat #(scan-token-value-references % old-token-name) all-tokens)) [])] (log/info :hint "token-scan-details" :token-name old-token-name diff --git a/frontend/test/frontend_tests/tokens/style_dictionary_test.cljs b/frontend/test/frontend_tests/tokens/style_dictionary_test.cljs index 2341d7baf6..bf8aad0c35 100644 --- a/frontend/test/frontend_tests/tokens/style_dictionary_test.cljs +++ b/frontend/test/frontend_tests/tokens/style_dictionary_test.cljs @@ -39,7 +39,7 @@ (ctob/make-token {:name "borderRadius.largeFn" :value "{borderRadius.sm} * 200000000" :type :border-radius})) - (ctob/get-all-tokens))] + (ctob/get-all-tokens-map))] (-> (sd/resolve-tokens tokens) (rx/sub! (fn [resolved-tokens]