|
| 1 | +# DEVUP UI - PROJECT KNOWLEDGE BASE |
| 2 | + |
| 3 | +**Generated:** 2026-01-07 |
| 4 | +**Commit:** 06887f92 |
| 5 | +**Branch:** main |
| 6 | + |
| 7 | +## OVERVIEW |
| 8 | + |
| 9 | +Zero-runtime CSS-in-JS preprocessor. Rust core (Oxc parser) → WASM → TypeScript plugins for Vite/Next/Webpack/Rsbuild/Bun. Build-time extraction, no client JS for styling. |
| 10 | + |
| 11 | +## STRUCTURE |
| 12 | + |
| 13 | +``` |
| 14 | +devup-ui/ |
| 15 | +├── libs/ # Rust core - CSS extraction engine (SEE libs/AGENTS.md) |
| 16 | +│ ├── extractor/ # JSX→CSS transformation (9k lines) |
| 17 | +│ ├── sheet/ # CSS generation + theming |
| 18 | +│ └── css/ # Utilities, selectors, optimization |
| 19 | +├── bindings/ # WASM bridge (SEE bindings/devup-ui-wasm/AGENTS.md) |
| 20 | +│ └── devup-ui-wasm/ # wasm-bindgen exports to JS |
| 21 | +├── packages/ # NPM packages |
| 22 | +│ ├── react/ # @devup-ui/react - Components + API (SEE packages/react/AGENTS.md) |
| 23 | +│ ├── components/ # @devup-ui/components - Button, Input, Select... |
| 24 | +│ ├── plugin-utils/ # Shared config loading |
| 25 | +│ ├── *-plugin/ # Build tool plugins (vite, next, webpack, rsbuild, bun) |
| 26 | +│ ├── eslint-plugin/ # Lint rules |
| 27 | +│ └── reset-css/ # CSS reset |
| 28 | +├── apps/ # Demo apps (vite, next, rsbuild, landing) |
| 29 | +└── benchmark/ # Performance comparisons vs Tailwind, StyleX, etc. |
| 30 | +``` |
| 31 | + |
| 32 | +## WHERE TO LOOK |
| 33 | + |
| 34 | +| Task | Location | Notes | |
| 35 | +|------|----------|-------| |
| 36 | +| Add CSS property | `libs/css/src/constant.rs` | Property mappings | |
| 37 | +| Add pseudo selector | `packages/react/src/types/props/selector/` | TypeScript types | |
| 38 | +| Modify extraction | `libs/extractor/src/lib.rs` | Core logic + tests | |
| 39 | +| Theme system | `libs/sheet/src/theme.rs` | Color/typography | |
| 40 | +| Plugin behavior | `packages/*-plugin/src/plugin.ts` | All follow same pattern | |
| 41 | +| Component API | `packages/react/src/components/` | Box, Flex, Text... | |
| 42 | +| WASM exports | `bindings/devup-ui-wasm/src/lib.rs` | JS-exposed functions | |
| 43 | + |
| 44 | +## CODE MAP |
| 45 | + |
| 46 | +### Rust Core (libs/) |
| 47 | + |
| 48 | +| Module | File | Lines | Role | |
| 49 | +|--------|------|-------|------| |
| 50 | +| extractor | `lib.rs` | 9,094 | Main extraction + tests | |
| 51 | +| sheet | `lib.rs` | 1,821 | CSS output generation | |
| 52 | +| theme | `theme.rs` | 1,526 | Color/typography system | |
| 53 | +| css_utils | `css_utils.rs` | 1,239 | Template literal parsing | |
| 54 | +| visit | `visit.rs` | 669 | AST visitor pattern | |
| 55 | + |
| 56 | +### TypeScript Packages |
| 57 | + |
| 58 | +| Package | Entry | Exports | |
| 59 | +|---------|-------|---------| |
| 60 | +| @devup-ui/react | `src/index.ts` | Box, Flex, Text, styled, css, globalCss, keyframes | |
| 61 | +| @devup-ui/components | `src/index.ts` | Button, Input, Select, Checkbox, Toggle, Stepper | |
| 62 | +| @devup-ui/wasm | `pkg/index.js` | codeExtract, getCss, registerTheme | |
| 63 | + |
| 64 | +## CONVENTIONS |
| 65 | + |
| 66 | +### Rust |
| 67 | +- `oxc` crate for JS/TS parsing (NOT swc) |
| 68 | +- Snapshot testing with `insta` |
| 69 | +- Parameterized tests with `rstest` |
| 70 | +- Serial tests with `serial_test` when touching globals |
| 71 | + |
| 72 | +### TypeScript |
| 73 | +- Bun as package manager AND test runner |
| 74 | +- 100% coverage thresholds enforced |
| 75 | +- ESM-first, dual CJS/ESM builds |
| 76 | +- `bun-test-env-dom` for component tests |
| 77 | + |
| 78 | +### Styling Props |
| 79 | +- Shorthand: `bg`, `p`, `m`, `w`, `h` (NOT `background`, `padding`...) |
| 80 | +- Responsive: `prop={[mobile, tablet, desktop]}` |
| 81 | +- Theme tokens: `$primary`, `$text` prefix |
| 82 | +- Selectors: `_hover`, `_focus`, `_before` |
| 83 | + |
| 84 | +### Class Naming |
| 85 | +- Base-37 encoding: `a`, `b`...`aa`, `ab` |
| 86 | +- Prefix configurable via `setPrefix()` |
| 87 | +- Minimal output size prioritized |
| 88 | + |
| 89 | +## ANTI-PATTERNS (THIS PROJECT) |
| 90 | + |
| 91 | +- **NEVER** use runtime styling - all processed at build time |
| 92 | +- **NEVER** use `as any` or `@ts-ignore` - strict types enforced |
| 93 | +- **NEVER** suppress Rust warnings - `clippy -D warnings` in CI |
| 94 | +- **NEVER** skip tests - 100% coverage required |
| 95 | +- **AVOID** adding dependencies - minimal footprint goal |
| 96 | + |
| 97 | +## UNIQUE STYLES |
| 98 | + |
| 99 | +### Zero-Runtime Components |
| 100 | +All React components throw `Error('Cannot run on the runtime')` - they're compile-time only placeholders that get replaced with `<div className="..." />`. |
| 101 | + |
| 102 | +### Theme Configuration |
| 103 | +`devup.json` at project root: |
| 104 | +```json |
| 105 | +{ |
| 106 | + "theme": { |
| 107 | + "colors": { "default": {...}, "dark": {...} }, |
| 108 | + "typography": { "heading": {...} } |
| 109 | + } |
| 110 | +} |
| 111 | +``` |
| 112 | + |
| 113 | +### Plugin Pattern |
| 114 | +All plugins wrap bundler config: |
| 115 | +```ts |
| 116 | +// vite.config.ts |
| 117 | +export default DevupUI(viteConfig, { singleCss: true }) |
| 118 | +``` |
| 119 | + |
| 120 | +## COMMANDS |
| 121 | + |
| 122 | +```bash |
| 123 | +# Development |
| 124 | +bun install # Install deps |
| 125 | +bun run build # Build all packages (WASM first) |
| 126 | +bun run dev # Dev mode all packages |
| 127 | + |
| 128 | +# Testing |
| 129 | +bun test # JS/TS tests |
| 130 | +cargo test # Rust tests |
| 131 | +cargo tarpaulin # Rust coverage |
| 132 | + |
| 133 | +# Linting |
| 134 | +bun run lint # ESLint + cargo fmt + clippy |
| 135 | +bun run lint:fix # Auto-fix |
| 136 | + |
| 137 | +# Benchmarks |
| 138 | +bun benchmark # Compare vs other CSS-in-JS libs |
| 139 | +``` |
| 140 | + |
| 141 | +## NOTES |
| 142 | + |
| 143 | +- **Build order matters**: WASM → plugin-utils → react → plugins |
| 144 | +- **Turbopack compatible**: Use `singleCss: true` for best perf |
| 145 | +- **RSC ready**: No client-side JS, works with React Server Components |
| 146 | +- **TypeScript theme types**: Auto-generated from `devup.json` |
0 commit comments