mirror of
https://github.com/penpot/penpot.git
synced 2025-12-23 22:48:40 -05:00
Compare commits
7 Commits
2.12.0-RC4
...
niwinz-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
465b6361a2 | ||
|
|
e6d4372948 | ||
|
|
193e5c88e8 | ||
|
|
a79b98f1b7 | ||
|
|
45a986d4e6 | ||
|
|
642d08b07d | ||
|
|
94041b5293 |
@@ -41,8 +41,10 @@
|
||||
[datoteka.fs :as fs]
|
||||
[datoteka.io :as io])
|
||||
(:import
|
||||
java.io.File
|
||||
java.io.InputStream
|
||||
java.io.OutputStreamWriter
|
||||
java.lang.AutoCloseable
|
||||
java.util.zip.ZipEntry
|
||||
java.util.zip.ZipFile
|
||||
java.util.zip.ZipOutputStream))
|
||||
@@ -251,9 +253,9 @@
|
||||
(write-entry! output path params)
|
||||
|
||||
(with-open [input (sto/get-object-data storage sobject)]
|
||||
(.putNextEntry output (ZipEntry. (str "objects/" id ext)))
|
||||
(.putNextEntry ^ZipOutputStream output (ZipEntry. (str "objects/" id ext)))
|
||||
(io/copy input output :size (:size sobject))
|
||||
(.closeEntry output))))))
|
||||
(.closeEntry ^ZipOutputStream output))))))
|
||||
|
||||
(defn- export-file
|
||||
[{:keys [::file-id ::output] :as cfg}]
|
||||
@@ -447,7 +449,7 @@
|
||||
(defn- read-manifest
|
||||
[^ZipFile input]
|
||||
(let [entry (get-zip-entry input "manifest.json")]
|
||||
(with-open [reader (zip-entry-reader input entry)]
|
||||
(with-open [^AutoCloseable reader (zip-entry-reader input entry)]
|
||||
(let [manifest (json/read reader :key-fn json/read-kebab-key)]
|
||||
(decode-manifest manifest)))))
|
||||
|
||||
@@ -537,12 +539,12 @@
|
||||
|
||||
(defn- read-entry
|
||||
[^ZipFile input entry]
|
||||
(with-open [reader (zip-entry-reader input entry)]
|
||||
(with-open [^AutoCloseable reader (zip-entry-reader input entry)]
|
||||
(json/read reader :key-fn json/read-kebab-key)))
|
||||
|
||||
(defn- read-plain-entry
|
||||
[^ZipFile input entry]
|
||||
(with-open [reader (zip-entry-reader input entry)]
|
||||
(with-open [^AutoCloseable reader (zip-entry-reader input entry)]
|
||||
(json/read reader)))
|
||||
|
||||
(defn- read-file
|
||||
@@ -1006,8 +1008,8 @@
|
||||
(try
|
||||
(l/info :hint "start exportation" :export-id (str id))
|
||||
(binding [bfc/*state* (volatile! (bfc/initial-state))]
|
||||
(with-open [output (io/output-stream output)]
|
||||
(with-open [output (ZipOutputStream. output)]
|
||||
(with-open [^AutoCloseable output (io/output-stream output)]
|
||||
(with-open [^AutoCloseable output (ZipOutputStream. output)]
|
||||
(let [cfg (assoc cfg ::output output)]
|
||||
(export-files cfg)
|
||||
(export-storage-objects cfg)))))
|
||||
@@ -1051,7 +1053,7 @@
|
||||
|
||||
(l/info :hint "import: started" :id (str id))
|
||||
(try
|
||||
(with-open [input (ZipFile. (fs/file input))]
|
||||
(with-open [input (ZipFile. ^File (fs/file input))]
|
||||
(import-files (assoc cfg ::bfc/input input)))
|
||||
|
||||
(catch Throwable cause
|
||||
@@ -1066,6 +1068,6 @@
|
||||
|
||||
(defn get-manifest
|
||||
[path]
|
||||
(with-open [input (ZipFile. (fs/file path))]
|
||||
(with-open [^AutoCloseable input (ZipFile. ^File (fs/file path))]
|
||||
(-> (read-manifest input)
|
||||
(validate-manifest))))
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
(println "event:" (d/name name))
|
||||
(println "data:" (t/encode-str data {:type :json-verbose}))
|
||||
(println))]
|
||||
(.getBytes data "UTF-8"))
|
||||
(.getBytes ^String data "UTF-8"))
|
||||
(catch Throwable cause
|
||||
(l/err :hint "unexpected error on encoding value on sse stream"
|
||||
:cause cause)
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
(defn- parse-svg
|
||||
[text]
|
||||
(let [text (strip-doctype text)]
|
||||
(dm/with-open [istream (IOUtils/toInputStream text "UTF-8")]
|
||||
(dm/with-open [istream (IOUtils/toInputStream ^String text "UTF-8")]
|
||||
(xml/parse istream secure-parser-factory))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
@@ -212,8 +212,8 @@
|
||||
deleted 0]
|
||||
(if-let [chunk (get-chunk pool)]
|
||||
(let [[nfo ndo] (db/tx-run! cfg process-chunk! chunk)]
|
||||
(recur (+ freezed nfo)
|
||||
(+ deleted ndo)))
|
||||
(recur (long (+ freezed nfo))
|
||||
(long (+ deleted ndo))))
|
||||
(do
|
||||
(l/inf :hint "task finished"
|
||||
:to-freeze freezed
|
||||
|
||||
@@ -313,7 +313,7 @@
|
||||
(db/exec-one! conn ["SET LOCAL rules.deletion_protection TO off"])
|
||||
(proc-fn cfg)))]
|
||||
(if (pos? result)
|
||||
(recur (+ total result))
|
||||
(recur (long (+ total result)))
|
||||
total))))
|
||||
|
||||
(defmethod ig/assert-key ::handler
|
||||
@@ -335,7 +335,7 @@
|
||||
(if-let [proc-fn (first procs)]
|
||||
(let [result (execute-proc! cfg proc-fn)]
|
||||
(recur (rest procs)
|
||||
(+ total result)))
|
||||
(long (+ total result))))
|
||||
(do
|
||||
(l/inf :hint "task finished" :deleted total)
|
||||
{:processed total}))))))
|
||||
|
||||
@@ -19,42 +19,42 @@
|
||||
(if (:ns &env)
|
||||
`(.getInt8 ~target ~offset true)
|
||||
(let [target (with-meta target {:tag 'java.nio.ByteBuffer})]
|
||||
`(long (.get ~target ~offset)))))
|
||||
`(long (.get ~target (unchecked-int ~offset))))))
|
||||
|
||||
(defmacro read-unsigned-byte
|
||||
[target offset]
|
||||
(if (:ns &env)
|
||||
`(.getUint8 ~target ~offset true)
|
||||
(let [target (with-meta target {:tag 'java.nio.ByteBuffer})]
|
||||
`(bit-and (long (.get ~target ~offset)) 0xff))))
|
||||
`(bit-and (long (.get ~target (unchecked-int ~offset))) 0xff))))
|
||||
|
||||
(defmacro read-bool
|
||||
[target offset]
|
||||
(if (:ns &env)
|
||||
`(== 1 (.getInt8 ~target ~offset true))
|
||||
(let [target (with-meta target {:tag 'java.nio.ByteBuffer})]
|
||||
`(== 1 (.get ~target ~offset)))))
|
||||
`(== 1 (.get ~target (unchecked-int ~offset))))))
|
||||
|
||||
(defmacro read-short
|
||||
[target offset]
|
||||
(if (:ns &env)
|
||||
`(.getInt16 ~target ~offset true)
|
||||
(let [target (with-meta target {:tag 'java.nio.ByteBuffer})]
|
||||
`(.getShort ~target ~offset))))
|
||||
`(.getShort ~target (unchecked-int ~offset)))))
|
||||
|
||||
(defmacro read-int
|
||||
[target offset]
|
||||
(if (:ns &env)
|
||||
`(.getInt32 ~target ~offset true)
|
||||
(let [target (with-meta target {:tag 'java.nio.ByteBuffer})]
|
||||
`(long (.getInt ~target ~offset)))))
|
||||
`(long (.getInt ~target (unchecked-int ~offset))))))
|
||||
|
||||
(defmacro read-float
|
||||
[target offset]
|
||||
(if (:ns &env)
|
||||
`(.getFloat32 ~target ~offset true)
|
||||
(let [target (with-meta target {:tag 'java.nio.ByteBuffer})]
|
||||
`(double (.getFloat ~target ~offset)))))
|
||||
`(double (.getFloat ~target (unchecked-int ~offset))))))
|
||||
|
||||
(defmacro read-uuid
|
||||
[target offset]
|
||||
@@ -68,8 +68,8 @@
|
||||
(let [target (with-meta target {:tag 'java.nio.ByteBuffer})]
|
||||
`(try
|
||||
(.order ~target ByteOrder/BIG_ENDIAN)
|
||||
(let [msb# (.getLong ~target (+ ~offset 0))
|
||||
lsb# (.getLong ~target (+ ~offset 8))]
|
||||
(let [msb# (.getLong ~target (unchecked-int (+ ~offset 0)))
|
||||
lsb# (.getLong ~target (unchecked-int (+ ~offset 8)))]
|
||||
(java.util.UUID. (long msb#) (long lsb#)))
|
||||
(finally
|
||||
(.order ~target ByteOrder/LITTLE_ENDIAN))))))
|
||||
@@ -79,35 +79,35 @@
|
||||
(if (:ns &env)
|
||||
`(.setInt8 ~target ~offset ~value true)
|
||||
(let [target (with-meta target {:tag 'java.nio.ByteBuffer})]
|
||||
`(.put ~target ~offset (unchecked-byte ~value)))))
|
||||
`(.put ~target (unchecked-int ~offset) (unchecked-byte ~value)))))
|
||||
|
||||
(defmacro write-bool
|
||||
[target offset value]
|
||||
(if (:ns &env)
|
||||
`(.setInt8 ~target ~offset (if ~value 0x01 0x00) true)
|
||||
(let [target (with-meta target {:tag 'java.nio.ByteBuffer})]
|
||||
`(.put ~target ~offset (unchecked-byte (if ~value 0x01 0x00))))))
|
||||
`(.put ~target (unchecked-int ~offset) (unchecked-byte (if ~value 0x01 0x00))))))
|
||||
|
||||
(defmacro write-short
|
||||
[target offset value]
|
||||
(if (:ns &env)
|
||||
`(.setInt16 ~target ~offset ~value true)
|
||||
(let [target (with-meta target {:tag 'java.nio.ByteBuffer})]
|
||||
`(.putShort ~target ~offset (unchecked-short ~value)))))
|
||||
`(.putShort ~target (unchecked-int ~offset) (unchecked-short ~value)))))
|
||||
|
||||
(defmacro write-int
|
||||
[target offset value]
|
||||
(if (:ns &env)
|
||||
`(.setInt32 ~target ~offset ~value true)
|
||||
(let [target (with-meta target {:tag 'java.nio.ByteBuffer})]
|
||||
`(.putInt ~target ~offset (unchecked-int ~value)))))
|
||||
`(.putInt ~target (unchecked-int ~offset) (unchecked-int ~value)))))
|
||||
|
||||
(defmacro write-float
|
||||
[target offset value]
|
||||
(if (:ns &env)
|
||||
`(.setFloat32 ~target ~offset ~value true)
|
||||
(let [target (with-meta target {:tag 'java.nio.ByteBuffer})]
|
||||
`(.putFloat ~target ~offset (unchecked-float ~value)))))
|
||||
`(.putFloat ~target (unchecked-int ~offset) (unchecked-float ~value)))))
|
||||
|
||||
(defmacro write-uuid
|
||||
[target offset value]
|
||||
@@ -122,8 +122,8 @@
|
||||
value (with-meta value {:tag 'java.util.UUID})]
|
||||
`(try
|
||||
(.order ~target ByteOrder/BIG_ENDIAN)
|
||||
(.putLong ~target (+ ~offset 0) (.getMostSignificantBits ~value))
|
||||
(.putLong ~target (+ ~offset 8) (.getLeastSignificantBits ~value))
|
||||
(.putLong ~target (unchecked-int (+ ~offset 0)) (.getMostSignificantBits ~value))
|
||||
(.putLong ~target (unchecked-int (+ ~offset 8)) (.getLeastSignificantBits ~value))
|
||||
(finally
|
||||
(.order ~target ByteOrder/LITTLE_ENDIAN))))))
|
||||
|
||||
|
||||
@@ -25,16 +25,7 @@
|
||||
|
||||
;; --- Matrix Impl
|
||||
|
||||
(defn format-precision
|
||||
[mtx precision]
|
||||
(when mtx
|
||||
(dm/fmt "matrix(%, %, %, %, %, %)"
|
||||
(mth/to-fixed (.-a mtx) precision)
|
||||
(mth/to-fixed (.-b mtx) precision)
|
||||
(mth/to-fixed (.-c mtx) precision)
|
||||
(mth/to-fixed (.-d mtx) precision)
|
||||
(mth/to-fixed (.-e mtx) precision)
|
||||
(mth/to-fixed (.-f mtx) precision))))
|
||||
(declare format-precision)
|
||||
|
||||
(cr/defrecord Matrix [^double a
|
||||
^double b
|
||||
@@ -46,6 +37,17 @@
|
||||
(toString [this]
|
||||
(format-precision this precision)))
|
||||
|
||||
(defn format-precision
|
||||
[mtx precision]
|
||||
(when mtx
|
||||
(dm/fmt "matrix(%, %, %, %, %, %)"
|
||||
(mth/to-fixed (.-a ^Matrix mtx) precision)
|
||||
(mth/to-fixed (.-b ^Matrix mtx) precision)
|
||||
(mth/to-fixed (.-c ^Matrix mtx) precision)
|
||||
(mth/to-fixed (.-d ^Matrix mtx) precision)
|
||||
(mth/to-fixed (.-e ^Matrix mtx) precision)
|
||||
(mth/to-fixed (.-f ^Matrix mtx) precision))))
|
||||
|
||||
(defn matrix?
|
||||
"Return true if `v` is Matrix instance."
|
||||
[v]
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
|
||||
[_ modif-tree]
|
||||
(reduce set-child-modifiers [layout-line modif-tree] children)]
|
||||
(recur modif-tree (first pending) (rest pending) to-idx))
|
||||
(recur modif-tree (first pending) (rest pending) (long to-idx)))
|
||||
|
||||
modif-tree)))))
|
||||
|
||||
|
||||
@@ -255,10 +255,10 @@
|
||||
(if-let [pt (first pts)]
|
||||
(let [x (dm/get-prop pt :x)
|
||||
y (dm/get-prop pt :y)]
|
||||
(recur (mth/min minx x)
|
||||
(mth/min miny y)
|
||||
(mth/max maxx x)
|
||||
(mth/max maxy y)
|
||||
(recur (double (mth/min minx x))
|
||||
(double (mth/min miny y))
|
||||
(double (mth/max maxx x))
|
||||
(double (mth/max maxy y))
|
||||
(rest pts)))
|
||||
(when (d/num? minx miny maxx maxy)
|
||||
(make-rect minx miny (- maxx minx) (- maxy miny)))))))
|
||||
|
||||
@@ -177,7 +177,7 @@
|
||||
(rest children)))))]
|
||||
|
||||
(recur next-areas
|
||||
(+ from-idx (:num-children current-line))
|
||||
(+ from-idx (long (:num-children current-line)))
|
||||
(+ (:x line-area) (:width line-area))
|
||||
(+ (:y line-area) (:height line-area))
|
||||
(rest lines)))))))
|
||||
|
||||
@@ -393,7 +393,7 @@
|
||||
min-fr
|
||||
(let [{:keys [size type value]} (first tracks)
|
||||
min-fr (if (= type :flex) (max min-fr (/ size value)) min-fr)]
|
||||
(recur (rest tracks) min-fr)))))
|
||||
(recur (rest tracks) (double min-fr))))))
|
||||
|
||||
(defn calc-layout-data
|
||||
([parent transformed-parent-bounds children bounds objects]
|
||||
|
||||
@@ -403,7 +403,7 @@
|
||||
|
||||
(if (>= to 1)
|
||||
result
|
||||
(recur to result))))))
|
||||
(recur (long to) result))))))
|
||||
|
||||
(defn curve-split
|
||||
"Splits a curve into two at the given parametric value `t`.
|
||||
|
||||
@@ -190,4 +190,4 @@
|
||||
(recur (first subpath)
|
||||
(rest subpath)
|
||||
first-point
|
||||
signed-area))))))
|
||||
(long signed-area)))))))
|
||||
|
||||
@@ -1909,7 +1909,7 @@ Will return a value that matches this schema:
|
||||
(->TokensLib sets themes active-themes))))
|
||||
|
||||
#?(:clj
|
||||
(defn- write-tokens-lib
|
||||
(defn- write-tokens-lib-v1-4
|
||||
[n w ^TokensLib o]
|
||||
(fres/write-tag! w n 3)
|
||||
(fres/write-object! w (.-sets o))
|
||||
@@ -1917,13 +1917,61 @@ Will return a value that matches this schema:
|
||||
(fres/write-object! w (.-active-themes o))))
|
||||
|
||||
#?(:clj
|
||||
(defn- read-tokens-lib
|
||||
(defn- read-tokens-lib-v1-4
|
||||
[r]
|
||||
(let [sets (fres/read-object! r)
|
||||
themes (fres/read-object! r)
|
||||
active-themes (fres/read-object! r)]
|
||||
(->TokensLib sets themes active-themes))))
|
||||
|
||||
|
||||
#?(:clj
|
||||
(defn- read-tokens-lib-v1-5
|
||||
[r]
|
||||
(let [sets (fres/read-object! r)
|
||||
tokens (fres/read-object! r)
|
||||
themes (fres/read-object! r)
|
||||
|
||||
lib (make-tokens-lib)
|
||||
lib (reduce (fn [tlib set]
|
||||
(let [tokens (get tokens (:id set) [])
|
||||
set (make-token-set (assoc set :tokens tokens))]
|
||||
(add-set tlib set)))
|
||||
lib
|
||||
sets)
|
||||
lib (reduce (fn [tlib theme]
|
||||
(let [theme (make-token-theme theme)]
|
||||
(add-theme tlib theme)))
|
||||
lib
|
||||
themes)]
|
||||
|
||||
lib)))
|
||||
|
||||
#?(:clj
|
||||
(defn- write-tokens-lib-v1-5
|
||||
[n w ^TokensLib o]
|
||||
(fres/write-tag! w n 3)
|
||||
(let [sets (->> (get-sets o)
|
||||
(map datafy))
|
||||
|
||||
tokens (->> sets
|
||||
(map datafy)
|
||||
(map (fn [set]
|
||||
(d/vec2 (:id set)
|
||||
(reduce-kv (fn [result k v]
|
||||
(assoc result k (datafy v)))
|
||||
(:tokens set)
|
||||
(:tokens set)))))
|
||||
(reduce conj {}))
|
||||
|
||||
sets (mapv #(dissoc % :tokens) sets)
|
||||
themes (->> (get-themes o)
|
||||
(map datafy))]
|
||||
|
||||
(fres/write-object! w sets)
|
||||
(fres/write-object! w tokens)
|
||||
(fres/write-object! w themes))))
|
||||
|
||||
#?(:clj
|
||||
(fres/add-handlers!
|
||||
{:name "penpot/token/v1"
|
||||
@@ -1967,8 +2015,11 @@ Will return a value that matches this schema:
|
||||
{:name "penpot/tokens-lib/v1.3"
|
||||
:rfn read-tokens-lib-v1-3}
|
||||
|
||||
{:name "penpot/tokens-lib/v1.4"
|
||||
:rfn read-tokens-lib-v1-4}
|
||||
|
||||
;; CURRENT TOKENS LIB READER & WRITTER
|
||||
{:name "penpot/tokens-lib/v1.4"
|
||||
:class TokensLib
|
||||
:wfn write-tokens-lib
|
||||
:rfn read-tokens-lib}))
|
||||
:rfn read-tokens-lib-v1-5
|
||||
:wfn write-tokens-lib-v1-5}))
|
||||
|
||||
@@ -168,7 +168,7 @@
|
||||
(gpt/point 20 65.2)
|
||||
(gpt/point 12 -10)]
|
||||
result (grc/points->rect points)
|
||||
expect {:x -1, :y -10, :width 21, :height 75.2}]
|
||||
expect {:x -1.0, :y -10.0, :width 21.0, :height 75.2}]
|
||||
|
||||
(t/is (= (:x expect) (:x result)))
|
||||
(t/is (= (:y expect) (:y result)))
|
||||
|
||||
Reference in New Issue
Block a user