Add reader tag support for geom point

This commit is contained in:
Andrey Antukh
2025-07-24 18:37:56 +02:00
parent eba2ff7d8d
commit 0934095e96
2 changed files with 17 additions and 22 deletions

View File

@@ -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}

View File

@@ -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!