mirror of
https://github.com/penpot/penpot.git
synced 2026-08-29 08:08:46 +00:00
♻️ Reuse embed param for exporter static renders
The bitmap and svg renderers requested image embedding with a new render-embed parameter while the render entrypoint already supports an equivalent one, so both were semantically duplicated knobs. - switch exporters to the existing :embed parameter - drop the render-embed schema entry and resolution logic - populate the images cache only when embedding is active so non embedding consumers do not download every object image upfront SVG exports of shapes with image fills now contain embedded data uris instead of url references; this restores the original intent of the exporter rewrite and keeps svg and bitmaps deterministic. AI-assisted-by: glm-5.3-flash
This commit is contained in:
parent
ae2ce0c6c9
commit
abb76d8b9e
@ -58,9 +58,9 @@
|
||||
(p/let [params {:file-id file-id
|
||||
:page-id page-id
|
||||
:share-id share-id
|
||||
:embed true
|
||||
:object-id (mapv :id objects)
|
||||
:route "objects"
|
||||
:render-embed true
|
||||
:skip-children skip-children
|
||||
:wasm (when is-wasm "true")
|
||||
:scale scale}
|
||||
|
||||
@ -345,7 +345,7 @@
|
||||
(p/let [params {:file-id file-id
|
||||
:page-id page-id
|
||||
:share-id share-id
|
||||
:render-embed true
|
||||
:embed true
|
||||
:object-id (mapv :id objects)
|
||||
:route "objects"}
|
||||
uri (-> (cf/get-internal-uri)
|
||||
|
||||
@ -126,7 +126,7 @@
|
||||
:skip-children skip-children}]]))))))
|
||||
|
||||
(defn- fetch-objects-bundle
|
||||
[& {:keys [file-id page-id share-id object-id] :as options}]
|
||||
[& {:keys [file-id page-id share-id object-id embed?] :as options}]
|
||||
(ptk/reify ::fetch-objects-bundle
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
@ -146,10 +146,16 @@
|
||||
(rx/map (fn [objects]
|
||||
(render/adapt-objects-for-shape objects object-id)))
|
||||
(rx/merge-map (fn [objects]
|
||||
(rx/concat
|
||||
(->> (render/populate-images-cache objects)
|
||||
(rx/ignore))
|
||||
(rx/of #(assoc % :objects objects))))))))))
|
||||
(if-not embed?
|
||||
(rx/of #(assoc % :objects objects))
|
||||
|
||||
;; Populate the images cache before rendering so
|
||||
;; data-uri substitutions are instantly available
|
||||
;; on the first paint.
|
||||
(rx/concat
|
||||
(->> (render/populate-images-cache objects)
|
||||
(rx/ignore))
|
||||
(rx/of #(assoc % :objects objects)))))))))))
|
||||
|
||||
(def ^:private schema:render-objects
|
||||
[:map {:title "render-objets"}
|
||||
@ -157,7 +163,6 @@
|
||||
[:file-id ::sm/uuid]
|
||||
[:share-id {:optional true} ::sm/uuid]
|
||||
[:embed {:optional true} :boolean]
|
||||
[:render-embed {:optional true} :boolean]
|
||||
[:skip-children {:optional true} :boolean]
|
||||
[:object-id
|
||||
[:or [::sm/set ::sm/uuid] ::sm/uuid]]])
|
||||
@ -173,10 +178,13 @@
|
||||
(defn- render-objects
|
||||
[params]
|
||||
(try
|
||||
(let [{:keys [file-id page-id embed render-embed share-id object-id skip-children wasm scale] :as params}
|
||||
(coerce-render-objects-params params)
|
||||
embed (if (some? render-embed) render-embed embed)]
|
||||
(st/emit! (fetch-objects-bundle :file-id file-id :page-id page-id :share-id share-id :object-id object-id))
|
||||
(let [{:keys [file-id page-id embed share-id object-id skip-children wasm scale] :as params}
|
||||
(coerce-render-objects-params params)]
|
||||
(st/emit! (fetch-objects-bundle :file-id file-id
|
||||
:page-id page-id
|
||||
:share-id share-id
|
||||
:object-id object-id
|
||||
:embed? embed))
|
||||
(if (uuid? object-id)
|
||||
(mf/html
|
||||
[:& object-svg
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user