mirror of
https://github.com/penpot/penpot.git
synced 2025-12-12 06:24:17 +01:00
Merge pull request #7687 from penpot/ladybenko-12440-fix-corrupt-files
Some checks failed
_DEVELOP / build-bundle (push) Has been cancelled
_DEVELOP / build-docker (push) Has been cancelled
_STAGING / build-bundle (push) Has been cancelled
_STAGING / build-docker (push) Has been cancelled
Commit Message Check / Check Commit Message (push) Has been cancelled
Some checks failed
_DEVELOP / build-bundle (push) Has been cancelled
_DEVELOP / build-docker (push) Has been cancelled
_STAGING / build-bundle (push) Has been cancelled
_STAGING / build-docker (push) Has been cancelled
Commit Message Check / Check Commit Message (push) Has been cancelled
🐛 Fix wasm crash when loading a file with missing font assets
This commit is contained in:
@@ -102,12 +102,13 @@
|
|||||||
|
|
||||||
(defn use-shape
|
(defn use-shape
|
||||||
[id]
|
[id]
|
||||||
(let [buffer (uuid/get-u32 id)]
|
(when wasm/context-initialized?
|
||||||
(h/call wasm/internal-module "_use_shape"
|
(let [buffer (uuid/get-u32 id)]
|
||||||
(aget buffer 0)
|
(h/call wasm/internal-module "_use_shape"
|
||||||
(aget buffer 1)
|
(aget buffer 0)
|
||||||
(aget buffer 2)
|
(aget buffer 1)
|
||||||
(aget buffer 3))))
|
(aget buffer 2)
|
||||||
|
(aget buffer 3)))))
|
||||||
|
|
||||||
(defn set-parent-id
|
(defn set-parent-id
|
||||||
[id]
|
[id]
|
||||||
@@ -1078,13 +1079,15 @@
|
|||||||
|
|
||||||
;; Initialize Wasm Render Engine
|
;; Initialize Wasm Render Engine
|
||||||
(h/call wasm/internal-module "_init" (/ (.-width ^js canvas) dpr) (/ (.-height ^js canvas) dpr))
|
(h/call wasm/internal-module "_init" (/ (.-width ^js canvas) dpr) (/ (.-height ^js canvas) dpr))
|
||||||
(h/call wasm/internal-module "_set_render_options" flags dpr)))
|
(h/call wasm/internal-module "_set_render_options" flags dpr))
|
||||||
|
(set! wasm/context-initialized? true))
|
||||||
(set-canvas-size canvas)
|
(set-canvas-size canvas)
|
||||||
context-init?))
|
context-init?))
|
||||||
|
|
||||||
(defn clear-canvas
|
(defn clear-canvas
|
||||||
[]
|
[]
|
||||||
;; TODO: perform corresponding cleaning
|
;; TODO: perform corresponding cleaning
|
||||||
|
(set! wasm/context-initialized? false)
|
||||||
(h/call wasm/internal-module "_clean_up"))
|
(h/call wasm/internal-module "_clean_up"))
|
||||||
|
|
||||||
(defn show-grid
|
(defn show-grid
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
[app.common.types.shape.layout :as ctl]
|
[app.common.types.shape.layout :as ctl]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.render-wasm.api :as api]
|
[app.render-wasm.api :as api]
|
||||||
|
[app.render-wasm.wasm :as wasm]
|
||||||
[beicon.v2.core :as rx]
|
[beicon.v2.core :as rx]
|
||||||
[cljs.core :as c]
|
[cljs.core :as c]
|
||||||
[cuerdas.core :as str]))
|
[cuerdas.core :as str]))
|
||||||
@@ -126,114 +127,115 @@
|
|||||||
;; The `set-wasm-attr!` can return a list of callbacks to be executed in a second pass.
|
;; The `set-wasm-attr!` can return a list of callbacks to be executed in a second pass.
|
||||||
(defn- set-wasm-attr!
|
(defn- set-wasm-attr!
|
||||||
[shape k]
|
[shape k]
|
||||||
(let [v (get shape k)
|
(when wasm/context-initialized?
|
||||||
id (get shape :id)]
|
(let [v (get shape k)
|
||||||
(case k
|
id (get shape :id)]
|
||||||
:parent-id (api/set-parent-id v)
|
(case k
|
||||||
:type (do
|
:parent-id (api/set-parent-id v)
|
||||||
(api/set-shape-type v)
|
:type (do
|
||||||
(when (or (= v :path) (= v :bool))
|
(api/set-shape-type v)
|
||||||
(api/set-shape-path-content (:content shape))))
|
(when (or (= v :path) (= v :bool))
|
||||||
:bool-type (api/set-shape-bool-type v)
|
(api/set-shape-path-content (:content shape))))
|
||||||
:selrect (do
|
:bool-type (api/set-shape-bool-type v)
|
||||||
(api/set-shape-selrect v)
|
:selrect (do
|
||||||
(when (= (:type shape) :svg-raw)
|
(api/set-shape-selrect v)
|
||||||
(api/set-shape-svg-raw-content (api/get-static-markup shape))))
|
(when (= (:type shape) :svg-raw)
|
||||||
:show-content (if (= (:type shape) :frame)
|
(api/set-shape-svg-raw-content (api/get-static-markup shape))))
|
||||||
(api/set-shape-clip-content (not v))
|
:show-content (if (= (:type shape) :frame)
|
||||||
(api/set-shape-clip-content false))
|
(api/set-shape-clip-content (not v))
|
||||||
:rotation (api/set-shape-rotation v)
|
(api/set-shape-clip-content false))
|
||||||
:transform (api/set-shape-transform v)
|
:rotation (api/set-shape-rotation v)
|
||||||
:fills (into [] (api/set-shape-fills id v false))
|
:transform (api/set-shape-transform v)
|
||||||
:strokes (into [] (api/set-shape-strokes id v false))
|
:fills (into [] (api/set-shape-fills id v false))
|
||||||
:blend-mode (api/set-shape-blend-mode v)
|
:strokes (into [] (api/set-shape-strokes id v false))
|
||||||
:opacity (api/set-shape-opacity v)
|
:blend-mode (api/set-shape-blend-mode v)
|
||||||
:hidden (api/set-shape-hidden v)
|
:opacity (api/set-shape-opacity v)
|
||||||
:shapes (api/set-shape-children v)
|
:hidden (api/set-shape-hidden v)
|
||||||
:blur (api/set-shape-blur v)
|
:shapes (api/set-shape-children v)
|
||||||
:shadow (api/set-shape-shadows v)
|
:blur (api/set-shape-blur v)
|
||||||
:constraints-h (api/set-constraints-h v)
|
:shadow (api/set-shape-shadows v)
|
||||||
:constraints-v (api/set-constraints-v v)
|
:constraints-h (api/set-constraints-h v)
|
||||||
|
:constraints-v (api/set-constraints-v v)
|
||||||
|
|
||||||
:r1
|
:r1
|
||||||
(api/set-shape-corners [v (dm/get-prop shape :r2) (dm/get-prop shape :r3) (dm/get-prop shape :r4)])
|
(api/set-shape-corners [v (dm/get-prop shape :r2) (dm/get-prop shape :r3) (dm/get-prop shape :r4)])
|
||||||
|
|
||||||
:r2
|
:r2
|
||||||
(api/set-shape-corners [(dm/get-prop shape :r1) v (dm/get-prop shape :r3) (dm/get-prop shape :r4)])
|
(api/set-shape-corners [(dm/get-prop shape :r1) v (dm/get-prop shape :r3) (dm/get-prop shape :r4)])
|
||||||
|
|
||||||
:r3
|
:r3
|
||||||
(api/set-shape-corners [(dm/get-prop shape :r1) (dm/get-prop shape :r2) v (dm/get-prop shape :r4)])
|
(api/set-shape-corners [(dm/get-prop shape :r1) (dm/get-prop shape :r2) v (dm/get-prop shape :r4)])
|
||||||
|
|
||||||
:r4
|
:r4
|
||||||
(api/set-shape-corners [(dm/get-prop shape :r1) (dm/get-prop shape :r2) (dm/get-prop shape :r3) v])
|
(api/set-shape-corners [(dm/get-prop shape :r1) (dm/get-prop shape :r2) (dm/get-prop shape :r3) v])
|
||||||
|
|
||||||
:svg-attrs
|
:svg-attrs
|
||||||
(when (= (:type shape) :path)
|
(when (= (:type shape) :path)
|
||||||
(api/set-shape-path-attrs v))
|
(api/set-shape-path-attrs v))
|
||||||
|
|
||||||
:masked-group
|
:masked-group
|
||||||
(when (and (= (:type shape) :group) (:masked-group shape))
|
(when (and (= (:type shape) :group) (:masked-group shape))
|
||||||
(api/set-masked (:masked-group shape)))
|
(api/set-masked (:masked-group shape)))
|
||||||
|
|
||||||
:content
|
:content
|
||||||
(cond
|
|
||||||
(or (= (:type shape) :path)
|
|
||||||
(= (:type shape) :bool))
|
|
||||||
(api/set-shape-path-content v)
|
|
||||||
|
|
||||||
(= (:type shape) :svg-raw)
|
|
||||||
(api/set-shape-svg-raw-content (api/get-static-markup shape))
|
|
||||||
|
|
||||||
(= (:type shape) :text)
|
|
||||||
(api/set-shape-text id v false))
|
|
||||||
|
|
||||||
:grow-type
|
|
||||||
(api/set-shape-grow-type v)
|
|
||||||
|
|
||||||
(:layout-item-align-self
|
|
||||||
:layout-item-margin
|
|
||||||
:layout-item-margin-type
|
|
||||||
:layout-item-h-sizing
|
|
||||||
:layout-item-v-sizing
|
|
||||||
:layout-item-max-h
|
|
||||||
:layout-item-min-h
|
|
||||||
:layout-item-max-w
|
|
||||||
:layout-item-min-w
|
|
||||||
:layout-item-absolute
|
|
||||||
:layout-item-z-index)
|
|
||||||
(api/set-layout-child shape)
|
|
||||||
|
|
||||||
:layout-grid-rows
|
|
||||||
(api/set-grid-layout-rows v)
|
|
||||||
|
|
||||||
:layout-grid-columns
|
|
||||||
(api/set-grid-layout-columns v)
|
|
||||||
|
|
||||||
:layout-grid-cells
|
|
||||||
(api/set-grid-layout-cells v)
|
|
||||||
|
|
||||||
(:layout
|
|
||||||
:layout-flex-dir
|
|
||||||
:layout-gap-type
|
|
||||||
:layout-gap
|
|
||||||
:layout-align-items
|
|
||||||
:layout-align-content
|
|
||||||
:layout-justify-items
|
|
||||||
:layout-justify-content
|
|
||||||
:layout-wrap-type
|
|
||||||
:layout-padding-type
|
|
||||||
:layout-padding)
|
|
||||||
(do
|
|
||||||
(api/clear-layout)
|
|
||||||
(cond
|
(cond
|
||||||
(ctl/grid-layout? shape)
|
(or (= (:type shape) :path)
|
||||||
(api/set-grid-layout-data shape)
|
(= (:type shape) :bool))
|
||||||
|
(api/set-shape-path-content v)
|
||||||
|
|
||||||
(ctl/flex-layout? shape)
|
(= (:type shape) :svg-raw)
|
||||||
(api/set-flex-layout shape)))
|
(api/set-shape-svg-raw-content (api/get-static-markup shape))
|
||||||
|
|
||||||
|
(= (:type shape) :text)
|
||||||
|
(api/set-shape-text id v false))
|
||||||
|
|
||||||
|
:grow-type
|
||||||
|
(api/set-shape-grow-type v)
|
||||||
|
|
||||||
|
(:layout-item-align-self
|
||||||
|
:layout-item-margin
|
||||||
|
:layout-item-margin-type
|
||||||
|
:layout-item-h-sizing
|
||||||
|
:layout-item-v-sizing
|
||||||
|
:layout-item-max-h
|
||||||
|
:layout-item-min-h
|
||||||
|
:layout-item-max-w
|
||||||
|
:layout-item-min-w
|
||||||
|
:layout-item-absolute
|
||||||
|
:layout-item-z-index)
|
||||||
|
(api/set-layout-child shape)
|
||||||
|
|
||||||
|
:layout-grid-rows
|
||||||
|
(api/set-grid-layout-rows v)
|
||||||
|
|
||||||
|
:layout-grid-columns
|
||||||
|
(api/set-grid-layout-columns v)
|
||||||
|
|
||||||
|
:layout-grid-cells
|
||||||
|
(api/set-grid-layout-cells v)
|
||||||
|
|
||||||
|
(:layout
|
||||||
|
:layout-flex-dir
|
||||||
|
:layout-gap-type
|
||||||
|
:layout-gap
|
||||||
|
:layout-align-items
|
||||||
|
:layout-align-content
|
||||||
|
:layout-justify-items
|
||||||
|
:layout-justify-content
|
||||||
|
:layout-wrap-type
|
||||||
|
:layout-padding-type
|
||||||
|
:layout-padding)
|
||||||
|
(do
|
||||||
|
(api/clear-layout)
|
||||||
|
(cond
|
||||||
|
(ctl/grid-layout? shape)
|
||||||
|
(api/set-grid-layout-data shape)
|
||||||
|
|
||||||
|
(ctl/flex-layout? shape)
|
||||||
|
(api/set-flex-layout shape)))
|
||||||
|
|
||||||
;; Property not in WASM
|
;; Property not in WASM
|
||||||
nil)))
|
nil))))
|
||||||
|
|
||||||
(defn process-shape!
|
(defn process-shape!
|
||||||
[shape properties]
|
[shape properties]
|
||||||
@@ -256,8 +258,9 @@
|
|||||||
(rx/mapcat (fn [[shape-id props]] (process-shape! (get objects shape-id) props)))
|
(rx/mapcat (fn [[shape-id props]] (process-shape! (get objects shape-id) props)))
|
||||||
(rx/subs!
|
(rx/subs!
|
||||||
(fn [_]
|
(fn [_]
|
||||||
(api/update-shape-tiles)
|
(when wasm/context-initialized?
|
||||||
(api/request-render "set-wasm-attrs")))))
|
(api/update-shape-tiles)
|
||||||
|
(api/request-render "set-wasm-attrs"))))))
|
||||||
|
|
||||||
;; `conj` empty set initialization
|
;; `conj` empty set initialization
|
||||||
(def conj* (fnil conj #{}))
|
(def conj* (fnil conj #{}))
|
||||||
|
|||||||
@@ -2,4 +2,5 @@
|
|||||||
|
|
||||||
(defonce internal-frame-id nil)
|
(defonce internal-frame-id nil)
|
||||||
(defonce internal-module #js {})
|
(defonce internal-module #js {})
|
||||||
(defonce serializers #js {})
|
(defonce serializers #js {})
|
||||||
|
(defonce context-initialized? false)
|
||||||
|
|||||||
Reference in New Issue
Block a user