Something went wrong. Try again.
Ghostty for the web with xterm.js API compatibility
Something went wrong. Try again.
1.4 kB · 56 lines
Shell
at vimscroll
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657#!/bin/bashset -e
echo "🔨 Building ghostty-vt.wasm..."
# Check for Zigif ! command -v zig &> /dev/null; then echo "❌ Error: Zig not found" echo "" echo "Install Zig 0.15.2+:" echo " macOS: brew install zig" echo " Linux: https://ziglang.org/download/" echo "" exit 1fi
ZIG_VERSION=$(zig version)echo "✓ Found Zig $ZIG_VERSION"
# Initialize/update submoduleif [ ! -d "ghostty/.git" ]; then echo "📦 Initializing Ghostty submodule..." git submodule update --init --recursiveelse echo "📦 Ghostty submodule already initialized"fi
# Apply patchecho "🔧 Applying WASM API patch..."cd ghosttygit apply --check ../patches/ghostty-wasm-api.patch || { echo "❌ Patch doesn't apply cleanly" echo "Ghostty may have changed. Check patches/ghostty-wasm-api.patch" exit 1}git apply ../patches/ghostty-wasm-api.patch
# Build WASMecho "⚙️ Building WASM (takes ~20 seconds)..."zig build lib-vt -Dtarget=wasm32-freestanding -Doptimize=ReleaseSmall
# Copy to project rootcd ..cp ghostty/zig-out/bin/ghostty-vt.wasm ./
# Revert patch to keep submodule cleanecho "🧹 Cleaning up..."cd ghosttygit apply -R ../patches/ghostty-wasm-api.patch# Remove new files created by the patchrm -f include/ghostty/vt/terminal.hrm -f src/terminal/c/terminal.zigcd ..
SIZE=$(du -h ghostty-vt.wasm | cut -f1)echo "✅ Built ghostty-vt.wasm ($SIZE)"