mirror of
https://github.com/penpot/penpot.git
synced 2025-01-26 08:29:42 -05:00
🎉 Add support for store plain js objects in transit.
This commit is contained in:
parent
aea7b9b6bf
commit
5ce741ba6d
1 changed files with 20 additions and 0 deletions
|
@ -11,15 +11,35 @@
|
|||
[uxbox.util.geom.matrix :as gmt]
|
||||
[uxbox.util.time :as dt]))
|
||||
|
||||
(deftype Blob [content]
|
||||
IDeref
|
||||
(-deref [_] content))
|
||||
|
||||
(defn blob?
|
||||
[v]
|
||||
(instance? Blob v))
|
||||
|
||||
(def blob-write-handler
|
||||
(t/write-handler
|
||||
(constantly "jsonblob")
|
||||
(fn [v] (js/JSON.stringify @v))))
|
||||
|
||||
(def blob-read-handler
|
||||
(t/read-handler
|
||||
(fn [value]
|
||||
(->Blob (js/JSON.parse value)))))
|
||||
|
||||
;; --- Transit Handlers
|
||||
|
||||
(def ^:privare +read-handlers+
|
||||
{"u" uuid
|
||||
"jsonblob" blob-read-handler
|
||||
"matrix" gmt/matrix-read-handler
|
||||
"point" gpt/point-read-handler})
|
||||
|
||||
(def ^:privare +write-handlers+
|
||||
{gmt/Matrix gmt/matrix-write-handler
|
||||
Blob blob-write-handler
|
||||
gpt/Point gpt/point-write-handler})
|
||||
|
||||
;; --- Public Api
|
||||
|
|
Loading…
Add table
Reference in a new issue