Skip to content

feat: add webui-wasm crate#54

Merged
mohamedmansour merged 7 commits intomainfrom
feature/wasm
Feb 25, 2026
Merged

feat: add webui-wasm crate#54
mohamedmansour merged 7 commits intomainfrom
feature/wasm

Conversation

@mohamedmansour
Copy link
Copy Markdown
Contributor

Introduce a new webui-wasm crate that compiles the full WebUI parse → protocol → render pipeline to WebAssembly, enabling an interactive browser-based playground with zero server dependencies.

WebAssembly crate (crates/webui-wasm):

  • Exposes build_and_render(), build_protocol(), and render() via wasm-bindgen for JavaScript consumption
  • Uses the real webui-parser with CssStrategy::Inline so component styles work in-memory without external CSS files
  • Feature-gates walkdir/filesystem behind 'fs' feature so webui-parser compiles cleanly for wasm32-unknown-unknown
  • Removes 6 unused deps from webui-parser (tokio, anyhow, tree-sitter-typescript, lazy_static, nom, streaming-iterator)
  • Bumps tree-sitter-language to 0.1.7 for bundled WASM C headers

Build tooling:

  • Cross-platform cargo xtask build-wasm command with auto-detection of LLVM clang, wasi-libc, and WASM headers per OS
  • Friendly colored error messages with platform-specific install hints using the console crate (matches webui-cli style)
  • JS glue patching to replace tree-sitter env imports with inline C stdlib stubs for browser compatibility
  • Reusable GitHub Actions composite action (.github/actions/setup-wasm) shared by PR checks and docs deployment workflows
  • Refactored xtask into modules: main.rs, build_wasm.rs, build_apps.rs, util.rs

Introduce a new webui-wasm crate that compiles the full WebUI
parse → protocol → render pipeline to WebAssembly, enabling an
interactive browser-based playground with zero server dependencies.

WebAssembly crate (crates/webui-wasm):
- Exposes build_and_render(), build_protocol(), and render() via
  wasm-bindgen for JavaScript consumption
- Uses the real webui-parser with CssStrategy::Inline so component
  styles work in-memory without external CSS files
- Feature-gates walkdir/filesystem behind 'fs' feature so
  webui-parser compiles cleanly for wasm32-unknown-unknown
- Removes 6 unused deps from webui-parser (tokio, anyhow,
  tree-sitter-typescript, lazy_static, nom, streaming-iterator)
- Bumps tree-sitter-language to 0.1.7 for bundled WASM C headers

Build tooling:
- Cross-platform cargo xtask build-wasm command with auto-detection
  of LLVM clang, wasi-libc, and WASM headers per OS
- Friendly colored error messages with platform-specific install
  hints using the console crate (matches webui-cli style)
- JS glue patching to replace tree-sitter env imports with inline
  C stdlib stubs for browser compatibility
- Reusable GitHub Actions composite action (.github/actions/setup-wasm)
  shared by PR checks and docs deployment workflows
- Refactored xtask into modules: main.rs, build_wasm.rs, build_apps.rs, util.rs
@mohamedmansour mohamedmansour changed the title feat: add webui-wasm crate for WebAssembly playground feat: add webui-wasm crate Feb 25, 2026
Comment thread .github/workflows/pr.yml Fixed
Remove the label-based gate that required a 'wasm' label on the
PR for the WASM build job to run. The job now runs unconditionally
on every PR, matching the CI job behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread .github/workflows/pr.yml Fixed
mohamedmansour and others added 4 commits February 24, 2026 17:13
…n permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
The webui-protocol crate needs protoc for prost-build. Add
protobuf-compiler to the apt-get install in the composite action.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
tree-sitter-html's scanner.c uses strncpy and towupper which
are not in tree-sitter-language's minimal WASM header stubs.
Install the wasi-libc package (available on Ubuntu 24.04) to
provide the complete C stdlib headers needed for WASM compilation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The wasi-libc apt package installs headers to /usr/include/wasm32-wasi
(not /usr/share/wasi-sysroot/include/wasm32-wasi). Update both the
CI action and xtask detection to check this path first.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mohamedmansour mohamedmansour requested a review from a team February 25, 2026 01:43
Ubuntu's system clang already supports --target=wasm32-unknown-unknown.
tree-sitter-language 0.1.7 ships bundled WASM C headers (via cargo fetch).
Add -Wno-implicit-function-declaration for missing strncpy/towupper
declarations in the minimal stubs — these link fine from wasm stubs.

Removes: clang, llvm, lld, wasi-libc apt packages from CI.
Keeps: protobuf-compiler (for prost-build) and wasm-pack.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@akroshg
Copy link
Copy Markdown
Contributor

akroshg commented Feb 25, 2026

Does it require the README change on how to play with wasm?

@mohamedmansour mohamedmansour merged commit 5c58489 into main Feb 25, 2026
10 checks passed
@mohamedmansour mohamedmansour deleted the feature/wasm branch February 26, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants