0
Fork 0
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:
Aitor 2023-11-21 16:47:48 +01:00 committed by Andrey Antukh
parent 7404933e99
commit 16c8c4bd2a
3 changed files with 29 additions and 14 deletions

View file

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

View file

@ -553,13 +553,15 @@
[fixed-width
fixed-height] (th/get-relative-size width height)
data (rds/renderToStaticMarkup
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}))]
:height height})))]
(->> (fonts/render-font-styles-cached fonts)
(rx/catch (fn [cause]

View file

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