Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

Build the library crates for the web, and keep them building

Jareer297a1907e250
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 1b2e998b..1ba88072 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -60,3 +60,26 @@ jobs:
- run: cargo test --workspace
working-directory: engine
+ # The engine crates that carry no native library build for the web. This
+ # job is what keeps that true: a std::thread or a blocking wait that
+ # creeps into concat-core or concat-project fails here, not when someone
+ # next tries the target. See engine/README.md for the list.
+ web:
+ name: Engine on wasm32
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v7
+ - uses: dtolnay/rust-toolchain@stable
+ with:
+ components: clippy
+ targets: wasm32-unknown-unknown
+ - uses: Swatinem/rust-cache@v2
+ with:
+ workspaces: engine
+ key: wasm32
+ - run: >
+ cargo clippy
+ -p concat-core -p concat-project -p concat-effects -p concat-render -p concat-text
+ --features concat-render/gpu --target wasm32-unknown-unknown
+ -- -D warnings
+ working-directory: engine
diff --git a/engine/README.md b/engine/README.md
index 66964833..1a019dd5 100644
--- a/engine/README.md
+++ b/engine/README.md
@@ -60,6 +60,20 @@ dependency pinned: `nix build` (then `./result/bin/concat`), `nix run`, or
`nix develop` for a shell with the toolchain and libraries in it. Linux
x86_64 and aarch64.
+The crates that carry no native library - `concat-core`, `concat-project`,
+`concat-effects`, `concat-render` (the wgpu compositor included, on WebGPU)
+and `concat-text` - also build for the web, and CI keeps them building:
+
+```sh
+cargo check -p concat-core -p concat-project -p concat-effects -p concat-render -p concat-text \
+ --features concat-render/gpu --target wasm32-unknown-unknown
+```
+
+The rest is native by nature: `concat-media` links FFmpeg, `concat-host`
+talks to the audio device and the file system, `concat-speech` compiles in
+whisper.cpp and sherpa-onnx, and `concat` is a window. `concat-export` goes
+with them for now because its render loop reads through `concat-media`.
+
## Reading this codebase cold
1. [`../ARCHITECTURE.md`](../ARCHITECTURE.md) - the map of the whole system. Read it first.
diff --git a/engine/crates/concat-render/src/gpu.rs b/engine/crates/concat-render/src/gpu.rs
index bda3a721..b412367b 100644
--- a/engine/crates/concat-render/src/gpu.rs
+++ b/engine/crates/concat-render/src/gpu.rs
@@ -165,6 +165,11 @@ pub struct WgpuCompositor {
impl WgpuCompositor {
/// Builds a compositor on the best available adapter, or `None` when the
/// machine has nothing usable - callers fall back to the CPU path.
+ ///
+ /// Native only: it blocks on the adapter and device requests, and on the
+ /// web there is no thread to block. A web caller awaits those requests
+ /// itself and hands the result to [`WgpuCompositor::with_device`].
+ #[cfg(not(target_arch = "wasm32"))]
pub fn new() -> Option<Self> {
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor::new_without_display_handle());
let adapter = pollster::block_on(instance.request_adapter(&wgpu::RequestAdapterOptions {
diff --git a/engine/rust-toolchain.toml b/engine/rust-toolchain.toml
index 1b5f5c36..36c87b3f 100644
--- a/engine/rust-toolchain.toml
+++ b/engine/rust-toolchain.toml
@@ -2,3 +2,6 @@
[toolchain]
channel = "1.93"
components = ["rustfmt", "clippy"]
+# The engine crates that carry no native library build for the web too, and
+# CI checks that they keep doing so; see README.md.
+targets = ["wasm32-unknown-unknown"]