🔧 Set wasm export by flag instead of team feature (#11449)

This commit is contained in:
Elena Torró 2026-09-01 12:47:05 +02:00 committed by GitHub
parent f5aad7b1ae
commit b458dc764e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 10 additions and 25 deletions

View File

@ -134,7 +134,6 @@
:feature-text-editor-v2-html-paste "text-editor/v2-html-paste" :feature-text-editor-v2-html-paste "text-editor/v2-html-paste"
:feature-text-editor-wasm "text-editor-wasm/v1" :feature-text-editor-wasm "text-editor-wasm/v1"
:feature-render-wasm "render-wasm/v1" :feature-render-wasm "render-wasm/v1"
:feature-wasm-export "wasm-export/v1"
:feature-variants "variants/v1" :feature-variants "variants/v1"
:feature-token-input "tokens/numeric-input" :feature-token-input "tokens/numeric-input"
nil)) nil))

View File

@ -256,23 +256,10 @@
(def ^:private wasm-export-types #{:jpeg :webp :png :pdf :svg}) (def ^:private wasm-export-types #{:jpeg :webp :png :pdf :svg})
(defn- wasm-export-enabled? (defn- wasm-export-enabled?
"WASM export is available when the `wasm-export/v1` feature is active AND
render-wasm is active for the current file. When render-wasm is inactive its
shape tree isn't loaded, so a client-side WASM render would crash.
This governs the client-side render only; it says nothing about the exporter."
[state] [state]
(and (features/active-feature? state "wasm-export/v1") (and (contains? cf/flags :wasm-export)
(features/active-feature? state "render-wasm/v1"))) (features/active-feature? state "render-wasm/v1")))
(defn- wasm-export-available?
"Whether the *exporter* renders with render-wasm. Its `enable-wasm-export`
flag has to be on too, otherwise the browser backend does the work and the
job API would promise capabilities the server does not have."
[state]
(and (wasm-export-enabled? state)
(contains? cf/flags :wasm-export)))
(defn- use-wasm-export? (defn- use-wasm-export?
"Whether to take the client-side WASM export path for `export`." "Whether to take the client-side WASM export path for `export`."
[state export] [state export]
@ -308,7 +295,7 @@
:profile-id profile-id :profile-id profile-id
:cmd :export-shapes :cmd :export-shapes
:wait true :wait true
:is-wasm (wasm-export-available? state)})] :is-wasm (wasm-export-enabled? state)})]
(rx/concat (rx/concat
(dwp/force-persist-and-wait 400) (dwp/force-persist-and-wait 400)
@ -337,7 +324,7 @@
:cmd cmd :cmd cmd
:profile-id profile-id :profile-id profile-id
:force-multiple true :force-multiple true
:is-wasm (wasm-export-available? state)} :is-wasm (wasm-export-enabled? state)}
(some? name) (some? name)
(assoc :name name)) (assoc :name name))
@ -365,7 +352,7 @@
;; locally. With wasm export active the job API is used instead: it ;; locally. With wasm export active the job API is used instead: it
;; answers with the exporter's own object count and gives a handle ;; answers with the exporter's own object count and gives a handle
;; to cancel. ;; to cancel.
(->> (if (wasm-export-available? state) (->> (if (wasm-export-enabled? state)
(->> (rp/cmd! :create-export-job params) (->> (rp/cmd! :create-export-job params)
(rx/map (fn [{job-id :id :keys [total] :as job}] (rx/map (fn [{job-id :id :keys [total] :as job}]
(vreset! resource-id (:resource-id job)) (vreset! resource-id (:resource-id job))

View File

@ -1203,7 +1203,7 @@
;; Call exporter to get image URI, then fetch blob and resolve the deferred. ;; Call exporter to get image URI, then fetch blob and resolve the deferred.
(->> (if (and (features/active-feature? state "render-wasm/v1") (->> (if (and (features/active-feature? state "render-wasm/v1")
(features/active-feature? state "wasm-export/v1")) (contains? cf/flags :wasm-export))
(rx/of {:uri (wasm.exports/export-image-uri export)}) (rx/of {:uri (wasm.exports/export-image-uri export)})
(rp/cmd! :export (rp/cmd! :export
{:exports [export] {:exports [export]

View File

@ -33,6 +33,7 @@
[app.common.types.shape.shadow :as ctss] [app.common.types.shape.shadow :as ctss]
[app.common.types.text :as txt] [app.common.types.text :as txt]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.config :as cf]
[app.main.data.exports.assets :as de] [app.main.data.exports.assets :as de]
[app.main.data.exports.wasm :as wasm.exports] [app.main.data.exports.wasm :as wasm.exports]
[app.main.data.persistence :as dwp] [app.main.data.persistence :as dwp]
@ -48,7 +49,6 @@
[app.main.data.workspace.texts :as dwt] [app.main.data.workspace.texts :as dwt]
[app.main.data.workspace.tokens.application :as dwta] [app.main.data.workspace.tokens.application :as dwta]
[app.main.data.workspace.variants :as dwv] [app.main.data.workspace.variants :as dwv]
[app.main.features :as features]
[app.main.repo :as rp] [app.main.repo :as rp]
[app.main.store :as st] [app.main.store :as st]
[app.plugins.exports :as exports] [app.plugins.exports :as exports]
@ -1528,7 +1528,7 @@
(u/not-valid plugin-id :export value) (u/not-valid plugin-id :export value)
:else :else
(if (and (features/active-feature? @st/state "wasm-export/v1") (if (and (contains? cf/flags :wasm-export)
(contains? #{:jpeg :webp :png} (:type value :png))) (contains? #{:jpeg :webp :png} (:type value :png)))
;; New export with wasm ;; New export with wasm
(let [uri (wasm.exports/export-image-uri (let [uri (wasm.exports/export-image-uri

View File

@ -80,10 +80,9 @@ flowchart TB
The client-side WASM export — rendering in the browser through the vector path The client-side WASM export — rendering in the browser through the vector path
(`render_shape_pdf` / `render_shape_pixels`) — is wired **only for single (`render_shape_pdf` / `render_shape_pixels`) — is wired **only for single
exports** (`request-simple-export` in `frontend/.../exports/assets.cljs`), and exports** (`request-simple-export` in `frontend/.../exports/assets.cljs`), and
only when render-wasm is active and the `wasm-export/v1` feature is enabled only when render-wasm is active and the `enable-wasm-export` flag is set. The
(instance-wide through the `enable-feature-wasm-export` flag, or per team exporter service reads the same flag to decide whether it can serve the
through the team `features` column). The exporter service keeps its own headless WASM path.
`:wasm-export` flag to decide whether it can serve the headless WASM path.
**Multiple/batch export** (`request-multiple-export`) always runs **server-side** **Multiple/batch export** (`request-multiple-export`) always runs **server-side**
via the `:export-shapes` command; it merely passes an `:is-wasm` hint so the via the `:export-shapes` command; it merely passes an `:is-wasm` hint so the