@echo off
setlocal enabledelayedexpansion
remremremremremremremremremremrem
set "REPO_ROOT=%~dp0"
set "DEMO_DIR=%REPO_ROOT%demo"
echo === AGG-Rust demo launcher ===
echo.
remwhere bun >nul 2>&1
if errorlevel 1 (
echo [ERROR] 'bun' was not found on your PATH.
echo The demo dev server and TypeScript build require Bun.
echo Install it from https://bun.sh/ ^(e.g. 'winget install Oven-sh.Bun'^),
echo then re-run this script.
goto :fail
)
remwhere wasm-pack >nul 2>&1
if errorlevel 1 (
echo [ERROR] 'wasm-pack' was not found on your PATH.
echo The demo builds the Rust crate to WebAssembly using wasm-pack.
echo Install it with 'cargo install wasm-pack' ^(needs a Rust toolchain^),
echo then re-run this script.
goto :fail
)
remwhere powershell >nul 2>&1
if errorlevel 1 (
echo [ERROR] 'powershell' was not found on your PATH.
echo The demo's build:wasm step runs demo/build-wasm.ps1 via PowerShell.
goto :fail
)
if not exist "%DEMO_DIR%\package.json" (
echo [ERROR] Could not find the demo project at:
echo %DEMO_DIR%
echo This script must live in the repository root next to the 'demo' folder.
goto :fail
)
pushd "%DEMO_DIR%" || goto :fail
remif not exist "%DEMO_DIR%\node_modules" (
echo [1/3] Installing demo JS dependencies ^(bun install^)...
call bun install
if errorlevel 1 (
echo [ERROR] 'bun install' failed.
popd
goto :fail
)
) else (
echo [1/3] Demo JS dependencies already installed - skipping bun install.
)
echo.
remremremremremif not exist "%DEMO_DIR%\public\pkg" (
echo [2/3] Building WASM package ^(first run^)...
pushd "%REPO_ROOT%" || goto :fail
call wasm-pack build demo/wasm --target web --out-dir ../public/pkg --no-typescript
if errorlevel 1 (
echo [ERROR] WASM build failed.
popd
popd
goto :fail
)
popd
) else (
echo [2/3] WASM package already present - skipping initial build:wasm.
)
echo.
remif not exist "%DEMO_DIR%\public\dist" (
echo [3/3] Building TypeScript bundle ^(first run^)...
call bun run build
if errorlevel 1 (
echo [ERROR] TypeScript build failed.
popd
goto :fail
)
) else (
echo [3/3] TypeScript bundle already present - skipping initial build.
)
echo.
echo Starting watch-mode dev server...
echo Open http://localhost:3000 in your browser.
echo Press Ctrl+C to stop.
echo.
call bun run dev
set "EXITCODE=%errorlevel%"
popd
endlocal
exit /b %EXITCODE%
:fail
echo.
echo Demo launch aborted.
echo.
pause
endlocal
exit /b 1