#!/usr/bin/env bash set -euo pipefail cd "$(dirname "$0")/.." export PATH="$HOME/.bun/bin:$PATH" echo "Building webui..." cd packages/webui bun run build HTML=$(cat dist/index.html) echo "Generating ui.ts..." cat > ../worker/src/ui.ts << 'TSEOF' export function renderUI(): string { return UI_HTML; } TSEOF # Use node to safely embed the HTML as a JS string node -e " const fs = require('fs'); const html = fs.readFileSync('dist/index.html', 'utf8'); const src = 'export function renderUI(): string {\n return ' + JSON.stringify(html) + ';\n}\n'; fs.writeFileSync('../worker/src/ui.ts', src); " echo "Done. Generated packages/worker/src/ui.ts"