# Axo Framework
**Crea más rápido. Hazlo completo. Extiéndelo todo.**
Axo es un framework UI multiplataforma con motor **Rust** (wgpu) y capa de scripting **Lua**. Ideal para apps internas, dashboards embebidos, terminales POS, y herramientas de nicho.
## Stack
| Renderizado | wgpu (Vulkan/Metal/DX12/WebGL2) |
| Layout | Taffy (Flexbox/CSS Grid) |
| Scripting | Lua 5.4 via mlua |
| Hot Reload | File watcher (notify) |
| Texto | ab_glyph (outline rendering) |
| Objetivos | Linux, macOS, Windows, Android, iOS, Web |
## Quickstart
```bash
# Instalar
cargo install --path cli
# Crear proyecto
axo init my-app
cd my-app
# Desarrollo con hot reload
axo dev
# Build producción
axo build --mode release
```
## Conceptos
### UI desde Lua
```lua
local UI = require("axo")
function App()
return UI.View({
style = {
width = "100%",
height = "100%",
backgroundColor = "#1a1a2e",
flexDirection = "column",
justifyContent = "center",
alignItems = "center",
},
children = {
UI.Text("Hola Axo!", {
fontSize = 24,
color = "#ffffff",
}),
UI.Button({
text = "Click",
onClick = "handleClick",
style = {
backgroundColor = "#e94560",
width = 200,
height = 50,
margin = 10,
},
}),
},
})
end
function handleClick()
log("Boton presionado!")
end
return App
```
### onClick — Nombres de función global
`onClick` recibe un **string** con el nombre de una función Lua global. Cuando el usuario hace clic, Axo busca y ejecuta esa función.
```lua
-- Function reference (almacenada automáticamente)
UI.Button({ onClick = function() print("click") end })
-- Global function name
UI.Button({ onClick = "handleClick" })
```
### Device API
Acceso a hardware del dispositivo desde Lua:
```lua
local info = Device.info()
print(info.os_name, info.screen_width)
Device.requestPermission("camera")
Device.getLocation()
Device.showNotification("Titulo", "Mensaje")
local data = Device.readFile("data.txt")
Device.writeFile("data.txt", "contenido")
```
| `Device.info()` | OS, versión, modelo, pantalla |
| `Device.checkPermission(name)` | Estado de permiso |
| `Device.requestPermission(name)` | Solicitar permiso |
| `Device.getLocation()` | GPS (lat, lng, accuracy) |
| `Device.getSensors()` | Acelerómetro, giroscopio |
| `Device.readFile(path)` | Leer archivo |
| `Device.writeFile(path, content)` | Escribir archivo |
| `Device.deleteFile(path)` | Eliminar archivo |
| `Device.showNotification(title, body)` | Notificación |
| `Device.takePhoto()` | Cámara (stub) |
### Permisos disponibles
- `"camera"`, `"location"`, `"storage"`, `"notifications"`, `"microphone"`, `"contacts"`
## CLI
```bash
axo init <nombre> # Scaffold proyecto
axo dev # Desarrollo con hot reload
axo build # Build debug
axo build --mode release # Build producción
axo release # Build + bundle
```
## Estructura del proyecto
```
my-app/
├── app/
│ ├── app.lua # Entry point (debe retornar App())
│ └── axo/init.lua # Std library (View, Text, Button, etc.)
└── README.md
```
## Arquitectura
```
┌─────────────────┐ ┌──────────────────┐
│ Lua App │ │ Rust Core │
│ app.lua │◄───►│ wgpu + Taffy │
│ init.lua │ │ + ab_glyph │
└────────┬────────┘ └────────┬─────────┘
│ │
▼ ▼
Device API Hot Reload
(permisos, (file watcher)
GPS, storage)
```
## Licencia
MIT
# Axo-Framework