mirror of
https://github.com/penpot/penpot.git
synced 2025-06-18 12:11:38 +02:00
♻️ Change thumbnail-renderer to rasterizer
This commit is contained in:
parent
e2812391c4
commit
51a8e8799b
9 changed files with 29 additions and 35 deletions
|
@ -113,8 +113,8 @@
|
|||
(normalize-uri (or (obj/get global "penpotPublicURI")
|
||||
(obj/get location "origin"))))
|
||||
|
||||
(def thumbnail-renderer-uri
|
||||
(or (some-> (obj/get global "penpotThumbnailRendererURI") normalize-uri)
|
||||
(def rasterizer-uri
|
||||
(or (some-> (obj/get global "penpotRasterizerURI") normalize-uri)
|
||||
public-uri))
|
||||
|
||||
(def worker-uri
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
[app.main.data.websocket :as ws]
|
||||
[app.main.errors]
|
||||
[app.main.features :as feat]
|
||||
[app.main.rasterizer :as thr]
|
||||
[app.main.store :as st]
|
||||
[app.main.thumbnail-renderer :as tr]
|
||||
[app.main.ui :as ui]
|
||||
[app.main.ui.alert]
|
||||
[app.main.ui.confirm]
|
||||
|
@ -112,7 +112,7 @@
|
|||
(i18n/init! cf/translations)
|
||||
(theme/init! cf/themes)
|
||||
(cur/init-styles)
|
||||
(tr/init!)
|
||||
(thr/init!)
|
||||
(init-ui)
|
||||
(st/emit! (initialize)))
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
;;
|
||||
;; Copyright (c) KALEIDOS INC
|
||||
|
||||
(ns app.main.thumbnail-renderer
|
||||
"A main entry point for the thumbnail renderer API interface.
|
||||
(ns app.main.rasterizer
|
||||
"A main entry point for the rasterizer API interface.
|
||||
|
||||
This ns is responsible to provide an API for create thumbnail
|
||||
renderer iframes and interact with them using asyncrhonous
|
||||
|
@ -23,7 +23,7 @@
|
|||
(defonce instance nil)
|
||||
(defonce msgbus (rx/subject))
|
||||
(defonce origin
|
||||
(dm/str (assoc cf/thumbnail-renderer-uri :path "/thumbnail-renderer.html")))
|
||||
(dm/str (assoc cf/rasterizer-uri :path "/rasterizer.html")))
|
||||
|
||||
(declare send-message!)
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
|||
(when (and (object? evdata) (str/starts-with? origin evorigin))
|
||||
(let [scope (unchecked-get evdata "scope")
|
||||
type (unchecked-get evdata "type")]
|
||||
(when (= "penpot/thumbnail-renderer" scope)
|
||||
(when (= "penpot/rasterizer" scope)
|
||||
(when (= type "ready")
|
||||
(set! ready? true)
|
||||
(process-queued-messages!))
|
||||
|
@ -66,7 +66,7 @@
|
|||
(let [id (dm/str (uuid/next))
|
||||
payload #js {:data data :styles styles :width width}
|
||||
message #js {:id id
|
||||
:scope "penpot/thumbnail-renderer"
|
||||
:scope "penpot/rasterizer"
|
||||
:payload payload}]
|
||||
|
||||
(if ^boolean ready?
|
|
@ -14,11 +14,11 @@
|
|||
[app.main.data.messages :as msg]
|
||||
[app.main.features :as features]
|
||||
[app.main.fonts :as fonts]
|
||||
[app.main.rasterizer :as thr]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.render :refer [component-svg]]
|
||||
[app.main.repo :as rp]
|
||||
[app.main.store :as st]
|
||||
[app.main.thumbnail-renderer :as thr]
|
||||
[app.main.ui.components.color-bullet :as bc]
|
||||
[app.main.ui.dashboard.file-menu :refer [file-menu]]
|
||||
[app.main.ui.dashboard.import :refer [use-import-file]]
|
||||
|
|
|
@ -121,14 +121,12 @@
|
|||
(mf/use-fn
|
||||
(mf/deps thumbnail-uri)
|
||||
(fn []
|
||||
(let [image-node (mf/ref-val frame-image-ref)]
|
||||
(dom/set-data! image-node "ready" "true")
|
||||
;; If we don't have the thumbnail data saved (normally the first load) we update the data
|
||||
;; when available
|
||||
(when-not (some? thumbnail-uri)
|
||||
(st/emit! (dwt/update-thumbnail page-id id)))
|
||||
;; If we don't have the thumbnail data saved (normally the first load) we update the data
|
||||
;; when available
|
||||
(when-not (some? thumbnail-uri)
|
||||
(st/emit! (dwt/update-thumbnail page-id id)))
|
||||
|
||||
(reset! render-frame* false))))
|
||||
(reset! render-frame* false)))
|
||||
|
||||
generate-thumbnail
|
||||
(mf/use-fn
|
||||
|
@ -175,10 +173,6 @@
|
|||
on-update-frame
|
||||
(mf/use-fn
|
||||
(fn []
|
||||
(let [image-node (mf/ref-val frame-image-ref)]
|
||||
(when (not= "false" (dom/get-data image-node "ready"))
|
||||
(dom/set-data! image-node "ready" "false")))
|
||||
|
||||
(when-not ^boolean (mf/ref-val disable-ref)
|
||||
(reset! svg-uri* nil)
|
||||
(reset! bitmap-uri* nil)
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
;;
|
||||
;; Copyright (c) KALEIDOS INC
|
||||
|
||||
(ns app.thumbnail-renderer
|
||||
"A main entry point for the thumbnail renderer process that is
|
||||
(ns app.rasterizer
|
||||
"A main entry point for the rasterizer process that is
|
||||
executed on a separated iframe."
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
|
@ -205,7 +205,7 @@
|
|||
payload (unchecked-get evdata "payload")
|
||||
scope (unchecked-get evdata "scope")]
|
||||
(when (and (some? payload)
|
||||
(= scope "penpot/thumbnail-renderer"))
|
||||
(= scope "penpot/rasterizer"))
|
||||
(->> (render payload)
|
||||
(rx/subs (partial send-success! id)
|
||||
(partial send-failure! id))))))))
|
||||
|
@ -220,7 +220,7 @@
|
|||
[id type payload]
|
||||
(let [message #js {:id id
|
||||
:type type
|
||||
:scope "penpot/thumbnail-renderer"
|
||||
:scope "penpot/rasterizer"
|
||||
:payload payload}]
|
||||
(when-not (identical? js/window js/parent)
|
||||
(.postMessage js/parent message parent-origin))))
|
Loading…
Add table
Add a link
Reference in a new issue