From 0934095e96a01ffa9b2b164c63863ee7e7958932 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 24 Jul 2025 18:37:56 +0200 Subject: [PATCH] :sparkles: Add reader tag support for geom point --- backend/src/data_readers.clj | 3 ++- common/src/app/common/geom/point.cljc | 36 +++++++++++---------------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/backend/src/data_readers.clj b/backend/src/data_readers.clj index 10e9987d67..9cfc3f0794 100644 --- a/backend/src/data_readers.clj +++ b/backend/src/data_readers.clj @@ -1,3 +1,4 @@ {penpot/inst app.common.time/inst penpot/cron app.util.cron/cron - penpot/duration app.common.time/duration} + penpot/duration app.common.time/duration + penpot/point app.common.geom.point/decode-point} diff --git a/common/src/app/common/geom/point.cljc b/common/src/app/common/geom/point.cljc index eb9b3b90ac..fd82a7af2a 100644 --- a/common/src/app/common/geom/point.cljc +++ b/common/src/app/common/geom/point.cljc @@ -8,10 +8,6 @@ (:refer-clojure :exclude [divide min max abs zero?]) (:require #?(:clj [app.common.fressian :as fres]) - #?(:cljs [cljs.core :as c] - :clj [clojure.core :as c]) - #?(:cljs [cljs.pprint :as pp] - :clj [clojure.pprint :as pp]) [app.common.data :as d] [app.common.data.macros :as dm] [app.common.exceptions :as ex] @@ -20,9 +16,9 @@ [app.common.schema :as sm] [app.common.schema.generators :as sg] [app.common.schema.openapi :as-alias oapi] - [app.common.spec :as us] [app.common.transit :as t] - [clojure.spec.alpha :as s] + [clojure.core :as c] + [clojure.pprint :as pp] [cuerdas.core :as str]) #?(:clj (:import @@ -32,25 +28,11 @@ (cr/defrecord Point [x y]) -(defn s - [pt] - (dm/str "(" (dm/get-prop pt :x) "," (dm/get-prop pt :y) ")")) - (defn point? "Return true if `v` is Point instance." [v] (instance? Point v)) -;; FIXME: deprecated -(s/def ::x ::us/safe-number) -(s/def ::y ::us/safe-number) - -(s/def ::point-attrs - (s/keys :req-un [::x ::y])) - -(s/def ::point - (s/and ::point-attrs point?)) - (def ^:private schema:point-attrs [:map {:title "PointAttrs"} [:x ::sm/safe-number] @@ -536,7 +518,19 @@ ;; --- Debug -(defmethod pp/simple-dispatch Point [obj] (pr obj)) +#?(:clj + (defmethod print-method Point + [o w] + (print-dup o w))) + +#?(:clj + (defmethod print-dup Point + [^Point pt ^java.io.Writer writer] + (.write writer (str "#penpot/point \"" (dm/get-prop pt :x) "," (dm/get-prop pt :y) "\"")))) + +(defmethod pp/simple-dispatch Point + [obj] + (pr obj)) #?(:clj (fres/add-handlers!