Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/actions/setup-wasm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: 'Setup and Build WASM'
description: 'Install WASM toolchain, build webui-wasm, and verify output'

runs:
using: 'composite'
steps:
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.93
targets: wasm32-unknown-unknown

- name: Rust Cache
uses: Swatinem/rust-cache@v2

- name: Install wasm-pack
shell: bash
run: cargo install wasm-pack

- name: Install LLVM
shell: bash
run: sudo apt-get update && sudo apt-get install -y clang llvm lld

- name: Setup WASM headers
shell: bash
run: |
cargo fetch
WASM_HEADERS=$(find $HOME/.cargo/registry/src -path "*/tree-sitter-language-*/wasm/include" -type d | head -1)
if [ -n "$WASM_HEADERS" ]; then
echo "WASI_INCLUDE=$WASM_HEADERS" >> $GITHUB_ENV
else
echo "::error::Could not find tree-sitter-language WASM headers"
exit 1
fi

- name: Build WASM
shell: bash
run: cargo xtask build-wasm

- name: Verify WASM output
shell: bash
run: |
test -f docs/public/wasm/webui_wasm_bg.wasm
test -f docs/public/wasm/webui_wasm.js
! grep -q "from 'env'" docs/public/wasm/webui_wasm.js
15 changes: 8 additions & 7 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,40 @@ on:
branches: [ "main" ]
paths:
- 'docs/**'
- 'crates/webui-wasm/**'
- 'crates/webui-parser/**'
- 'crates/webui-handler/**'
- 'crates/webui-protocol/**'
workflow_dispatch:

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
# Step 1: Checkout the repository
- name: Checkout Repository
uses: actions/checkout@v4

# Step 2: Setup Node.js environment
- name: Build WASM playground
uses: ./.github/actions/setup-wasm

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '22'

# Step 3: Setup pnpm

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: latest
run_install: false

# Step 4: Install dependencies
- name: Install Dependencies
run: cd docs && pnpm install

# Step 5: Build the Vitepress site
- name: Build Site
run: cd docs && pnpm build

# Step 6: Deploy to GitHub Pages
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,10 @@

- name: Build docs
run: pnpm --filter @webui/docs build

wasm:
name: WASM Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-wasm
Comment thread Fixed
Comment thread Fixed
65 changes: 31 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"crates/webui-parser",
"crates/webui-protocol",
"crates/webui-state",
"crates/webui-wasm",
"xtask",
]
resolver = "2"
Expand All @@ -30,6 +31,8 @@ tokio = { version = "1.49.0", features = ["full"] }
clap = { version = "4", features = ["derive"] }
console = "0.15"
prost = "0.13"
wasm-bindgen = "0.2"
serde-wasm-bindgen = "0.6"

# Test dependencies
criterion = "0.8.2"
Expand Down
12 changes: 3 additions & 9 deletions crates/webui-parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,21 @@ repository.workspace = true

[features]
default = ["fs"]
fs = []
fs = ["walkdir"]

[dependencies]
webui-expressions = { path = "../webui-expressions" }
webui-protocol = { path = "../webui-protocol" }
serde = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }
anyhow = { workspace = true }
tokio = { workspace = true }
tree-sitter = "0.26.5"
tree-sitter-language = "0.1.7"
tree-sitter-html = "0.23.2"
tree-sitter-css = "0.25.0"
tree-sitter-typescript = "0.23.2"
walkdir = "2.5.0"
lazy_static = "1.5.0"
nom = "8.0.0"
streaming-iterator = "0.1.9"
walkdir = { version = "2.5.0", optional = true }

[dev-dependencies]
mockall = { workspace = true }
tokio-test = { workspace = true }
tempfile = { workspace = true }
webui-test-utils = { path = "../webui-test-utils" }
26 changes: 26 additions & 0 deletions crates/webui-wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "webui-wasm"
description = "WebAssembly bindings for WebUI framework — powers the online playground"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true

[package.metadata.wasm-pack.profile.release]
wasm-opt = false

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
webui-parser = { path = "../webui-parser", default-features = false }
webui-handler = { path = "../webui-handler" }
webui-protocol = { path = "../webui-protocol" }
serde = { workspace = true }
serde_json = { workspace = true }
wasm-bindgen = { workspace = true }
serde-wasm-bindgen = { workspace = true }

[dev-dependencies]
webui-test-utils = { path = "../webui-test-utils" }
Loading
Loading