mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 06:58:58 -05:00
⚡ Cache rasterizer resources
This commit is contained in:
parent
aa6fdf10f9
commit
f477de962d
1 changed files with 14 additions and 7 deletions
|
@ -25,6 +25,8 @@
|
|||
(declare send-success!)
|
||||
(declare send-failure!)
|
||||
|
||||
(defonce data-uri-cache (js/Map.))
|
||||
|
||||
(defonce parent-origin
|
||||
(dm/str cf/public-uri))
|
||||
|
||||
|
@ -86,13 +88,18 @@
|
|||
(defn- fetch-as-data-uri
|
||||
"Fetches a URL as a Data URI."
|
||||
[uri]
|
||||
(if (.has data-uri-cache uri)
|
||||
(let [blob (.get data-uri-cache uri)]
|
||||
(rx/from (.text blob)))
|
||||
(->> (http/send! {:uri uri
|
||||
:response-type :blob
|
||||
:method :get
|
||||
:mode :cors
|
||||
:omit-default-headers true})
|
||||
(rx/map :body)
|
||||
(rx/mapcat wapi/read-file-as-data-url)))
|
||||
(rx/mapcat wapi/read-file-as-data-url)
|
||||
(rx/tap (fn [data-uri]
|
||||
(.set data-uri-cache uri (wapi/create-blob data-uri "text/plain")))))))
|
||||
|
||||
(defn- svg-update-image!
|
||||
"Updates an image in an SVG to a Data URI."
|
||||
|
|
Loading…
Add table
Reference in a new issue