mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 06:02:32 -05:00
✨ Disable wasm loading if feature is disabled
This commit is contained in:
parent
b17d7c0289
commit
1de35b2e3a
3 changed files with 42 additions and 37 deletions
|
@ -127,7 +127,7 @@
|
|||
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ stream]
|
||||
(let [stopper (rx/filter (ptk/type? ::finalize) stream)]
|
||||
(let [stopper (rx/filter (ptk/type? ::finalize-team) stream)]
|
||||
(->> (rx/merge
|
||||
(rx/of (fetch-teams))
|
||||
(->> stream
|
||||
|
|
|
@ -267,30 +267,34 @@
|
|||
[project-id file-id]
|
||||
(ptk/reify ::fetch-bundle-stage-1
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ stream]
|
||||
(->> (rp/cmd! :get-project {:id project-id})
|
||||
(rx/mapcat (fn [project]
|
||||
(rx/concat
|
||||
;; Wait the wasm module to be loaded or failed to
|
||||
;; load. We need to wait the promise to be resolved
|
||||
;; before continue with the next workspace loading
|
||||
;; steps
|
||||
(->> (rx/from wasm/module)
|
||||
(rx/ignore))
|
||||
(watch [_ state stream]
|
||||
(let [render-wasm? (features/active-feature? state "render-wasm/v1")]
|
||||
(->> (rp/cmd! :get-project {:id project-id})
|
||||
(rx/mapcat (fn [project]
|
||||
(rx/concat
|
||||
;; Wait the wasm module to be loaded or failed to
|
||||
;; load. We need to wait the promise to be resolved
|
||||
;; before continue with the next workspace loading
|
||||
;; steps
|
||||
|
||||
(->> (rp/cmd! :get-team {:id (:team-id project)})
|
||||
(rx/mapcat (fn [team]
|
||||
(let [bundle {:team team
|
||||
:project project
|
||||
:file-id file-id
|
||||
:project-id project-id}]
|
||||
;; FIXME: this should not be handled here, pending
|
||||
;; refactor of urls and team initialization
|
||||
;; normalization
|
||||
(rx/of (dtm/set-current-team team)
|
||||
(ptk/data-event ::bundle-stage-1 bundle)))))))))
|
||||
(rx/take-until
|
||||
(rx/filter (ptk/type? ::fetch-bundle) stream))))))
|
||||
(if ^boolean render-wasm?
|
||||
(->> (rx/from @wasm/module)
|
||||
(rx/ignore))
|
||||
(rx/empty))
|
||||
|
||||
(->> (rp/cmd! :get-team {:id (:team-id project)})
|
||||
(rx/mapcat (fn [team]
|
||||
(let [bundle {:team team
|
||||
:project project
|
||||
:file-id file-id
|
||||
:project-id project-id}]
|
||||
;; FIXME: this should not be handled here, pending
|
||||
;; refactor of urls and team initialization
|
||||
;; normalization
|
||||
(rx/of (dtm/set-current-team team)
|
||||
(ptk/data-event ::bundle-stage-1 bundle)))))))))
|
||||
(rx/take-until
|
||||
(rx/filter (ptk/type? ::fetch-bundle) stream)))))))
|
||||
|
||||
(defn- fetch-bundle-stage-2
|
||||
[{:keys [file-id project-id project] :as bundle}]
|
||||
|
|
|
@ -239,16 +239,17 @@
|
|||
(set! (.-height canvas) (* dpr (.-clientHeight ^js canvas))))
|
||||
|
||||
(defonce module
|
||||
(if (exists? js/dynamicImport)
|
||||
(let [uri (cf/resolve-static-asset "js/render_wasm.js")]
|
||||
(->> (js/dynamicImport (str uri))
|
||||
(p/mcat (fn [module]
|
||||
(let [default (unchecked-get module "default")]
|
||||
(default))))
|
||||
(p/fmap (fn [module]
|
||||
(set! internal-module module)
|
||||
true))
|
||||
(p/merr (fn [cause]
|
||||
(js/console.error cause)
|
||||
(p/resolved false)))))
|
||||
(p/resolved false)))
|
||||
(delay
|
||||
(if (exists? js/dynamicImport)
|
||||
(let [uri (cf/resolve-static-asset "js/render_wasm.js")]
|
||||
(->> (js/dynamicImport (str uri))
|
||||
(p/mcat (fn [module]
|
||||
(let [default (unchecked-get module "default")]
|
||||
(default))))
|
||||
(p/fmap (fn [module]
|
||||
(set! internal-module module)
|
||||
true))
|
||||
(p/merr (fn [cause]
|
||||
(js/console.error cause)
|
||||
(p/resolved false)))))
|
||||
(p/resolved false))))
|
||||
|
|
Loading…
Add table
Reference in a new issue