0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-25 00:06:09 -05:00

Merge pull request #3493 from penpot/niwinz-staging-bugfixes-6

🐛 Several bugfixes
This commit is contained in:
Alejandro 2023-08-04 13:35:12 +02:00 committed by GitHub
commit c69f6da2d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 72 additions and 68 deletions

View file

@ -47,7 +47,7 @@
(assoc :public-uri (cf/get :public-uri)) (assoc :public-uri (cf/get :public-uri))
(assoc :logger/name logger) (assoc :logger/name logger)
(assoc :logger/level level) (assoc :logger/level level)
(dissoc :request/params))] (dissoc :request/params :value :params :data))]
(merge (merge
{:context (-> (into (sorted-map) context) {:context (-> (into (sorted-map) context)
(pp/pprint-str :width 200 :length 50 :level 10)) (pp/pprint-str :width 200 :length 50 :level 10))
@ -55,7 +55,7 @@
:hint (or (ex-message cause) @message) :hint (or (ex-message cause) @message)
:trace (ex/format-throwable cause :data? false :explain? false :header? false :summary? false)} :trace (ex/format-throwable cause :data? false :explain? false :header? false :summary? false)}
(when-let [params (:request/params context)] (when-let [params (or (:request/params context) (:params context))]
{:params (pp/pprint-str params :width 200)}) {:params (pp/pprint-str params :width 200)})
(when-let [value (:value context)] (when-let [value (:value context)]
@ -67,7 +67,6 @@
(when-let [explain (ex/explain data {:level 10 :length 50})] (when-let [explain (ex/explain data {:level 10 :length 50})]
{:explain explain})))) {:explain explain}))))
(defn error-record? (defn error-record?
[{:keys [::l/level ::l/cause]}] [{:keys [::l/level ::l/cause]}]
(and (= :error level) (and (= :error level)

View file

@ -489,16 +489,8 @@
(l/error :hint "worker: unhandled exception" :cause cause)))))) (l/error :hint "worker: unhandled exception" :cause cause))))))
(defn- get-error-context (defn- get-error-context
[error item] [_ item]
(let [data (ex-data error)] {:params item})
(merge
{:hint (ex-message error)
:spec-problems (some->> data ::s/problems (take 10) seq vec)
:spec-value (some->> data ::s/value)
:data (some-> data (dissoc ::s/problems ::s/value ::s/spec))
:params item}
(when-let [explain (ex/explain data)]
{:spec-explain explain}))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; CRON ;; CRON
@ -597,10 +589,10 @@
(catch InterruptedException _ (catch InterruptedException _
(l/debug :hint "cron: task interrupted" :task-id id)) (l/debug :hint "cron: task interrupted" :task-id id))
(catch Throwable cause (catch Throwable cause
(l/error :hint "cron: unhandled exception on running task" (binding [l/*context* (get-error-context cause task)]
::l/context (get-error-context cause task) (l/error :hint "cron: unhandled exception on running task"
:task-id id :task-id id
:cause cause)) :cause cause)))
(finally (finally
(when-not (px/interrupted? :current) (when-not (px/interrupted? :current)
(schedule-cron-task cfg task)))))) (schedule-cron-task cfg task))))))

View file

@ -8,6 +8,7 @@
(:require (:require
[app.common.colors :as clr] [app.common.colors :as clr]
[app.common.data :as d] [app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.exceptions :as ex] [app.common.exceptions :as ex]
[app.common.geom.matrix :as gmt] [app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt] [app.common.geom.point :as gpt]
@ -123,56 +124,65 @@
(assoc-in [:fills 0 :fill-opacity] (-> (get-in shape [:svg-attrs :style :fill-opacity]) (assoc-in [:fills 0 :fill-opacity] (-> (get-in shape [:svg-attrs :style :fill-opacity])
(d/parse-double 1))))))) (d/parse-double 1)))))))
(defn setup-stroke [shape]
(let [stroke-linecap (-> (or (get-in shape [:svg-attrs :stroke-linecap])
(get-in shape [:svg-attrs :style :stroke-linecap]))
((d/nilf str/trim))
((d/nilf keyword)))
color-attr (str/trim (get-in shape [:svg-attrs :stroke]))
color-attr (if (= color-attr "currentColor") clr/black color-attr)
color-style (str/trim (get-in shape [:svg-attrs :style :stroke]))
color-style (if (= color-style "currentColor") clr/black color-style)
shape (defn- setup-stroke
(cond-> shape [shape]
;; Color present as attribute (let [attrs (get shape :svg-attrs)
(uc/color? color-attr) style (get attrs :style)
(-> (update :svg-attrs dissoc :stroke)
(assoc-in [:strokes 0 :stroke-color] (uc/parse-color color-attr)))
;; Color present as style stroke (or (str/trim (:stroke attrs))
(uc/color? color-style) (str/trim (:stroke style)))
(-> (update-in [:svg-attrs :style] dissoc :stroke)
(assoc-in [:strokes 0 :stroke-color] (uc/parse-color color-style)))
(get-in shape [:svg-attrs :stroke-opacity]) color (cond
(-> (update :svg-attrs dissoc :stroke-opacity) (= stroke "currentColor") clr/black
(assoc-in [:strokes 0 :stroke-opacity] (-> (get-in shape [:svg-attrs :stroke-opacity]) (= stroke "none") nil
(d/parse-double 1)))) :else (uc/parse-color stroke))
(get-in shape [:svg-attrs :style :stroke-opacity]) opacity (when (some? color)
(-> (update-in [:svg-attrs :style] dissoc :stroke-opacity) (d/parse-double
(assoc-in [:strokes 0 :stroke-opacity] (-> (get-in shape [:svg-attrs :style :stroke-opacity]) (or (:stroke-opacity attrs)
(d/parse-double 1)))) (:stroke-opacity style))
1))
(get-in shape [:svg-attrs :stroke-width]) width (when (some? color)
(-> (update :svg-attrs dissoc :stroke-width) (d/parse-double
(assoc-in [:strokes 0 :stroke-width] (-> (get-in shape [:svg-attrs :stroke-width]) (or (:stroke-width attrs)
(d/parse-double)))) (:stroke-width style))
1))
(get-in shape [:svg-attrs :style :stroke-width]) linecap (or (get attrs :stroke-linecap)
(-> (update-in [:svg-attrs :style] dissoc :stroke-width) (get style :stroke-linecap))
(assoc-in [:strokes 0 :stroke-width] (-> (get-in shape [:svg-attrs :style :stroke-width]) linecap (some-> linecap str/trim keyword)
(d/parse-double))))
(and stroke-linecap (= (:type shape) :path)) attrs (-> attrs
(-> (update-in [:svg-attrs :style] dissoc :stroke-linecap) (dissoc :stroke)
(cond-> (#{:round :square} stroke-linecap) (dissoc :stroke-width)
(assoc :stroke-cap-start stroke-linecap (dissoc :stroke-opacity)
:stroke-cap-end stroke-linecap))))] (update :style (fn [style]
(-> style
(dissoc :stroke)
(dissoc :stroke-linecap)
(dissoc :stroke-width)
(dissoc :stroke-opacity)))))]
(cond-> shape (cond-> (assoc shape :svg-attrs attrs)
(d/any-key? (get-in shape [:strokes 0]) :stroke-color :stroke-opacity :stroke-width :stroke-cap-start :stroke-cap-end) (some? color)
(assoc-in [:strokes 0 :stroke-color] color)
(and (some? color) (some? opacity))
(assoc-in [:strokes 0 :stroke-opacity] opacity)
(and (some? color) (some? width))
(assoc-in [:strokes 0 :stroke-width] width)
(and (some? linecap) (= (:type shape) :path)
(or (= linecap :round) (= linecap :square)))
(assoc :stroke-cap-start linecap
:stroke-cap-end linecap)
(d/any-key? (dm/get-in shape [:strokes 0])
:stroke-color :stroke-opacity :stroke-width
:stroke-cap-start :stroke-cap-end)
(assoc-in [:strokes 0 :stroke-style] :svg)))) (assoc-in [:strokes 0 :stroke-style] :svg))))
(defn setup-opacity [shape] (defn setup-opacity [shape]

View file

@ -106,7 +106,7 @@
(mf/set-ref-val! prev-val-ref node))))] (mf/set-ref-val! prev-val-ref node))))]
(mf/with-effect [] (mf/with-layout-effect []
;; On dismount we need to disconnect the current observer ;; On dismount we need to disconnect the current observer
(fn [] (fn []
(when-let [observer (mf/ref-val observer-ref)] (when-let [observer (mf/ref-val observer-ref)]

View file

@ -89,7 +89,7 @@
(obj/merge! attrs (clj->js fill-attrs))))) (obj/merge! attrs (clj->js fill-attrs)))))
(defn add-stroke [attrs stroke-data render-id index] (defn add-stroke [attrs stroke-data render-id index]
(let [stroke-style (:stroke-style stroke-data :none) (let [stroke-style (:stroke-style stroke-data :solid)
stroke-color-gradient-id (str "stroke-color-gradient_" render-id "_" index) stroke-color-gradient-id (str "stroke-color-gradient_" render-id "_" index)
stroke-width (:stroke-width stroke-data 1)] stroke-width (:stroke-width stroke-data 1)]
(if (not= stroke-style :none) (if (not= stroke-style :none)

View file

@ -8,6 +8,7 @@
"Color conversion utils." "Color conversion utils."
(:require (:require
[app.common.data :as d] [app.common.data :as d]
[app.common.data.macros :as dm]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[app.util.object :as obj] [app.util.object :as obj]
[app.util.strings :as ust] [app.util.strings :as ust]
@ -176,14 +177,16 @@
(= id :multiple) (= id :multiple)
(= file-id :multiple))) (= file-id :multiple)))
(defn color? [^string color-str] (defn color?
(and (not (nil? color-str)) [color]
(seq color-str) (and (string? color)
(gcolor/isValidColor color-str))) (gcolor/isValidColor color)))
(defn parse-color [^string color-str] (defn parse-color
(let [result (gcolor/parse color-str)] [color]
(str (.-hex ^js result)))) (when (color? color)
(let [result (gcolor/parse color)]
(dm/str (.-hex ^js result)))))
(def color-names (def color-names
(obj/get-keys ^js gcolor/names)) (obj/get-keys ^js gcolor/names))