import { Hype } from '@because/hype' import { createThemes, define, stylesToCSS } from '@because/forge' import { readdir, readlink, stat } from 'fs/promises' import { join } from 'path' import type { Child } from 'hono/jsx' const APPS_DIR = process.env.APPS_DIR! const app = new Hype({ prettyHTML: false }) const theme = createThemes({ light: { bg: '#ffffff', text: '#1a1a1a', textMuted: '#666666', border: '#dddddd', borderSubtle: '#eeeeee', borderStrong: '#333333', hover: '#f5f5f5', link: '#0066cc', error: '#d32f2f', errorBg: '#ffebee', accent: '#2e7d32', accentBg: '#e8f5e9', }, dark: { bg: '#1a1a1a', text: '#e5e5e5', textMuted: '#999999', border: '#404040', borderSubtle: '#333333', borderStrong: '#555555', hover: '#2a2a2a', link: '#5c9eff', error: '#ff6b6b', errorBg: '#3d1f1f', accent: '#81c784', accentBg: '#1b3d1f', }, }) const Container = define('Container', { fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', padding: '20px', maxWidth: '800px', margin: '0 auto', color: theme('text'), }) const Header = define('Header', { marginBottom: '20px', paddingBottom: '10px', borderBottom: `2px solid ${theme('borderStrong')}`, }) const Title = define('Title', { margin: 0, fontSize: '24px', fontWeight: 'bold', }) const Subtitle = define('Subtitle', { color: theme('textMuted'), fontSize: '18px', marginTop: '5px', }) const VersionList = define('VersionList', { listStyle: 'none', padding: 0, margin: '20px 0', border: `1px solid ${theme('border')}`, borderRadius: '4px', overflow: 'hidden', }) const VersionItem = define('VersionItem', { padding: '12px 15px', borderBottom: `1px solid ${theme('borderSubtle')}`, display: 'flex', alignItems: 'center', justifyContent: 'space-between', states: { ':last-child': { borderBottom: 'none', }, ':hover': { backgroundColor: theme('hover'), }, }, }) const VersionLink = define('VersionLink', { base: 'a', textDecoration: 'none', color: theme('link'), fontFamily: 'monospace', fontSize: '15px', states: { ':hover': { textDecoration: 'underline', }, }, }) const Badge = define('Badge', { fontSize: '12px', padding: '2px 8px', borderRadius: '4px', backgroundColor: theme('accentBg'), color: theme('accent'), fontWeight: 'bold', }) const ErrorBox = define('ErrorBox', { color: theme('error'), padding: '20px', backgroundColor: theme('errorBg'), borderRadius: '4px', margin: '20px 0', }) const initScript = ` (function() { var theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; document.body.setAttribute('data-theme', theme); window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function(e) { document.body.setAttribute('data-theme', e.matches ? 'dark' : 'light'); }); function sendHeight() { var container = document.querySelector('.Container'); if (!container) return; var rect = container.getBoundingClientRect(); window.parent.postMessage({ type: 'resize-iframe', height: rect.bottom + 20 }, '*'); } sendHeight(); setTimeout(sendHeight, 50); new ResizeObserver(sendHeight).observe(document.body); })(); ` const baseStyles = ` body { background: ${theme('bg')}; margin: 0; } ` interface LayoutProps { title: string subtitle?: string children: Child } function Layout({ title, subtitle, children }: LayoutProps) { return (