mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 06:58:58 -05:00
⚡ Use subdomain for rasterizer (OOPIF)
This commit is contained in:
parent
7404933e99
commit
16c8c4bd2a
3 changed files with 29 additions and 14 deletions
|
@ -61,10 +61,19 @@
|
|||
[message]
|
||||
(.push ^js queue message))
|
||||
|
||||
(defn- replace-uris
|
||||
"Replaces URIs for rasterizer ones in styles"
|
||||
[styles]
|
||||
(let [public-uri (str cf/public-uri)
|
||||
rasterizer-uri (str cf/rasterizer-uri)]
|
||||
(if-not (= public-uri rasterizer-uri)
|
||||
(str/replace styles public-uri rasterizer-uri)
|
||||
styles)))
|
||||
|
||||
(defn render
|
||||
"Renders an SVG"
|
||||
[{:keys [data styles width result] :as params}]
|
||||
(let [styles (d/nilv styles "")
|
||||
(let [styles (replace-uris (d/nilv styles ""))
|
||||
result (d/nilv result "blob")
|
||||
id (dm/str (uuid/next))
|
||||
payload #js {:data data :styles styles :width width :result result}
|
||||
|
|
|
@ -553,13 +553,15 @@
|
|||
[fixed-width
|
||||
fixed-height] (th/get-relative-size width height)
|
||||
|
||||
data (rds/renderToStaticMarkup
|
||||
(mf/element frame-imposter
|
||||
#js {:objects objects
|
||||
:frame shape
|
||||
:vbox viewbox
|
||||
:width width
|
||||
:height height}))]
|
||||
|
||||
data (with-redefs [cfg/public-uri cfg/rasterizer-uri]
|
||||
(rds/renderToStaticMarkup
|
||||
(mf/element frame-imposter
|
||||
#js {:objects objects
|
||||
:frame shape
|
||||
:vbox viewbox
|
||||
:width width
|
||||
:height height})))]
|
||||
|
||||
(->> (fonts/render-font-styles-cached fonts)
|
||||
(rx/catch (fn [cause]
|
||||
|
@ -567,11 +569,11 @@
|
|||
:cause cause)
|
||||
(rx/empty)))
|
||||
(rx/map (fn [styles]
|
||||
{:id object-id
|
||||
:data data
|
||||
:viewbox viewbox
|
||||
:width fixed-width
|
||||
:height fixed-height
|
||||
:styles styles}))))
|
||||
{:id object-id
|
||||
:data data
|
||||
:viewbox viewbox
|
||||
:width fixed-width
|
||||
:height fixed-height
|
||||
:styles styles}))))
|
||||
(do (l/warn :msg "imposter shape is nil")
|
||||
(rx/empty))))
|
||||
|
|
|
@ -221,6 +221,10 @@
|
|||
scope (unchecked-get evdata "scope")]
|
||||
(when (and (some? payload)
|
||||
(= scope "penpot/rasterizer"))
|
||||
(log/dbg :hint "received message"
|
||||
:id id
|
||||
:payload payload
|
||||
:scope scope)
|
||||
(->> (render payload)
|
||||
(rx/subs (partial send-success! id)
|
||||
(partial send-failure! id))))))))
|
||||
|
|
Loading…
Add table
Reference in a new issue