luxaura 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +342 -0
- package/bin/luxaura.js +632 -0
- package/examples/TodoApp.lux +97 -0
- package/package.json +35 -0
- package/src/compiler/index.js +389 -0
- package/src/index.js +44 -0
- package/src/parser/index.js +319 -0
- package/src/runtime/luxaura.runtime.js +350 -0
- package/src/vault/server.js +207 -0
- package/templates/luxaura.config +43 -0
- package/ui-kit/luxaura.min.css +779 -0
- package/ui-kit/luxaura.min.js +271 -0
package/README.md
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
# Luxaura Framework
|
|
2
|
+
|
|
3
|
+
> **Intent-Based Full-Stack Web Framework** — build complete apps with `.lux` files.
|
|
4
|
+
|
|
5
|
+
[](#)
|
|
6
|
+
[](#)
|
|
7
|
+
[](#)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## What is Luxaura?
|
|
12
|
+
|
|
13
|
+
Luxaura is a full-stack web framework where you describe **what** you want — not how to build it. A single `.lux` file contains your UI, state, styles, and backend logic. The compiler handles the rest.
|
|
14
|
+
|
|
15
|
+
```yaml
|
|
16
|
+
# counter.lux
|
|
17
|
+
|
|
18
|
+
state
|
|
19
|
+
count: 0
|
|
20
|
+
|
|
21
|
+
style
|
|
22
|
+
self
|
|
23
|
+
padding: 8
|
|
24
|
+
Action
|
|
25
|
+
radius: medium
|
|
26
|
+
background: #6c63ff
|
|
27
|
+
|
|
28
|
+
view
|
|
29
|
+
Box
|
|
30
|
+
Title "Counter: {count}"
|
|
31
|
+
Action "Increment"
|
|
32
|
+
on click:
|
|
33
|
+
count = count + 1
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install -g luxaura
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Or use it as a project dependency:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm install luxaura
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Quick Start
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# 1. Create a new project
|
|
56
|
+
luxaura new my-app
|
|
57
|
+
|
|
58
|
+
# 2. Enter the project
|
|
59
|
+
cd my-app
|
|
60
|
+
|
|
61
|
+
# 3. Start the dev server (HMR enabled)
|
|
62
|
+
luxaura run
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Open `http://localhost:3000` — your app is live.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## CLI Reference
|
|
70
|
+
|
|
71
|
+
| Command | Description |
|
|
72
|
+
|---|---|
|
|
73
|
+
| `luxaura new <name>` | Create a new project with the full folder structure |
|
|
74
|
+
| `luxaura run` | Start the dev server with Hot Module Replacement |
|
|
75
|
+
| `luxaura build` | Compile for production (splits client/server code) |
|
|
76
|
+
| `luxaura install <lib>` | Install a CSS/JS library (e.g. Tailwind, Bootstrap) |
|
|
77
|
+
| `luxaura generate <type> <name>` | Scaffold a `component`, `page`, or `api` |
|
|
78
|
+
| `luxaura format` | Auto-fix `.lux` file indentation |
|
|
79
|
+
| `luxaura secure` | Scan for XSS, SQL injection, and server-leak risks |
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## .lux File Anatomy
|
|
84
|
+
|
|
85
|
+
Every `.lux` file has five blocks:
|
|
86
|
+
|
|
87
|
+
```yaml
|
|
88
|
+
# 1. PROPS — inputs from parent components
|
|
89
|
+
props
|
|
90
|
+
title: String
|
|
91
|
+
count: Number = 0
|
|
92
|
+
|
|
93
|
+
# 2. STATE — reactive internal data
|
|
94
|
+
state
|
|
95
|
+
name: "World"
|
|
96
|
+
active: false
|
|
97
|
+
|
|
98
|
+
# 3. SERVER — backend logic (Node.js). NEVER sent to browser.
|
|
99
|
+
server
|
|
100
|
+
import db from "luxaura/db"
|
|
101
|
+
def saveUser(name):
|
|
102
|
+
return db.insert("users", { name })
|
|
103
|
+
|
|
104
|
+
# 4. STYLE — smart properties + CSS
|
|
105
|
+
style
|
|
106
|
+
self
|
|
107
|
+
padding: 6
|
|
108
|
+
shadow: soft
|
|
109
|
+
Title
|
|
110
|
+
fontSize: 2xl
|
|
111
|
+
fontWeight: bold
|
|
112
|
+
|
|
113
|
+
# 5. VIEW — UI component tree
|
|
114
|
+
view
|
|
115
|
+
Container
|
|
116
|
+
Title "{title}"
|
|
117
|
+
Text "Hello, {name}!"
|
|
118
|
+
Action "Save"
|
|
119
|
+
on click:
|
|
120
|
+
await server.saveUser(name)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Semantic Components
|
|
126
|
+
|
|
127
|
+
No HTML tags. Use intent-based components:
|
|
128
|
+
|
|
129
|
+
| Category | Components |
|
|
130
|
+
|---|---|
|
|
131
|
+
| **Layout** | `Box`, `Row`, `Column`, `Grid`, `Container` |
|
|
132
|
+
| **Navigation** | `Nav`, `Sidebar`, `Footer`, `Header` |
|
|
133
|
+
| **Content** | `Title`, `Text`, `Image`, `Icon`, `Badge` |
|
|
134
|
+
| **Interaction** | `Action`, `Input`, `Form`, `Switch`, `Link` |
|
|
135
|
+
| **Data** | `Table`, `List`, `ListItem` |
|
|
136
|
+
| **Overlay** | `Modal`, `Overlay`, `Card` |
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Smart Style Properties
|
|
141
|
+
|
|
142
|
+
```yaml
|
|
143
|
+
style
|
|
144
|
+
self
|
|
145
|
+
padding: 4 # → padding: 16px (4 × 4px base)
|
|
146
|
+
shadow: soft # → box-shadow: 0 2px 12px rgba(...)
|
|
147
|
+
radius: large # → border-radius: 16px
|
|
148
|
+
fontSize: xl # → font-size: 1.5rem
|
|
149
|
+
fontWeight: bold # → font-weight: 700
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Available tokens:
|
|
153
|
+
- **shadow**: `none`, `soft`, `medium`, `hard`
|
|
154
|
+
- **radius**: `none`, `small`, `medium`, `large`, `full`
|
|
155
|
+
- **fontSize**: `xs`, `sm`, `md`, `lg`, `xl`, `2xl`, `3xl`
|
|
156
|
+
- **fontWeight**: `thin`, `light`, `normal`, `medium`, `bold`, `black`
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## The Vault (Backend Security)
|
|
161
|
+
|
|
162
|
+
Code in the `server` block runs **exclusively on the server**. The compiler strips it completely from the client bundle.
|
|
163
|
+
|
|
164
|
+
```yaml
|
|
165
|
+
server
|
|
166
|
+
import db from "luxaura/db"
|
|
167
|
+
|
|
168
|
+
def getUser(id):
|
|
169
|
+
# This code NEVER reaches the browser
|
|
170
|
+
return db.query("SELECT * FROM users WHERE id = ?", [id])
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Frontend calls it naturally:
|
|
174
|
+
|
|
175
|
+
```yaml
|
|
176
|
+
view
|
|
177
|
+
Action "Load User"
|
|
178
|
+
on click:
|
|
179
|
+
result = await server.getUser(userId)
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Features:
|
|
183
|
+
- **Auto-CSRF**: Every RPC request is signed with a rotating token
|
|
184
|
+
- **Auto-Sanitization**: String inputs are sanitized before processing
|
|
185
|
+
- **Code Stripping**: Build verifiably excludes server code from `dist/client`
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## The Physics Engine (Auto-Responsiveness)
|
|
190
|
+
|
|
191
|
+
Layouts adapt automatically without media queries:
|
|
192
|
+
|
|
193
|
+
- `Row` → stacks to `Column` on mobile
|
|
194
|
+
- Buttons/inputs auto-enlarge to 44px touch targets on mobile
|
|
195
|
+
- `Image` with `responsive: true` never overflows its container
|
|
196
|
+
- `Nav` auto-collapses on small screens
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Utility Classes
|
|
201
|
+
|
|
202
|
+
```html
|
|
203
|
+
<!-- In your .lux view or class: attributes -->
|
|
204
|
+
class: "lux-flex lux-center lux-gap-4"
|
|
205
|
+
class: "lux-text-xl lux-font-bold lux-text-primary"
|
|
206
|
+
class: "lux-card lux-shadow-lg lux-rounded-lg"
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Full class list available in `luxaura.min.css`.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Modules (Built-in API)
|
|
214
|
+
|
|
215
|
+
```yaml
|
|
216
|
+
server
|
|
217
|
+
import db from "luxaura/db" # Database queries
|
|
218
|
+
import router from "luxaura/router" # Navigation
|
|
219
|
+
import http from "luxaura/http" # External API calls
|
|
220
|
+
import auth from "luxaura/auth" # Authentication
|
|
221
|
+
import storage from "luxaura/storage" # localStorage wrapper
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Headless Mode
|
|
227
|
+
|
|
228
|
+
Use Luxaura as a frontend-only framework, proxying to any backend:
|
|
229
|
+
|
|
230
|
+
```
|
|
231
|
+
# luxaura.config
|
|
232
|
+
mode: headless
|
|
233
|
+
proxy: http://localhost:8080
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
API requests are automatically forwarded to your existing backend.
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Plugin System
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
luxaura install tailwindcss
|
|
244
|
+
luxaura install bootstrap
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Then use classes directly in your `.lux` views:
|
|
248
|
+
|
|
249
|
+
```yaml
|
|
250
|
+
view
|
|
251
|
+
Box
|
|
252
|
+
Action "Submit"
|
|
253
|
+
class: "bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Project Structure
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
my-app/
|
|
262
|
+
├── luxaura.config # Global config (theme, db, mode)
|
|
263
|
+
├── assets/ # Images, fonts (auto-optimized)
|
|
264
|
+
├── pages/ # Route entry points (index.lux, about.lux)
|
|
265
|
+
├── modules/ # Reusable components (Navbar.lux, Card.lux)
|
|
266
|
+
├── server/ # Shared server utilities
|
|
267
|
+
└── dist/
|
|
268
|
+
├── client/ # Public assets (HTML, JS, CSS)
|
|
269
|
+
└── server/ # Secure server modules (Vault)
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Programmatic API
|
|
275
|
+
|
|
276
|
+
```javascript
|
|
277
|
+
const luxaura = require('luxaura');
|
|
278
|
+
|
|
279
|
+
// Parse a .lux file
|
|
280
|
+
const ast = luxaura.parse(source, 'MyComponent.lux');
|
|
281
|
+
|
|
282
|
+
// Compile AST to JS/CSS/HTML
|
|
283
|
+
const output = luxaura.compile(ast, { componentName: 'MyComponent' });
|
|
284
|
+
|
|
285
|
+
console.log(output.clientJS); // Client bundle
|
|
286
|
+
console.log(output.serverJS); // Server vault module
|
|
287
|
+
console.log(output.css); // Component styles
|
|
288
|
+
console.log(output.html); // HTML shell
|
|
289
|
+
|
|
290
|
+
// One-shot transform
|
|
291
|
+
const output2 = luxaura.transform(source, 'MyComponent.lux');
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Runtime JavaScript API
|
|
297
|
+
|
|
298
|
+
```javascript
|
|
299
|
+
// Mount a component
|
|
300
|
+
const ctx = window.__Lux__.mount('MyApp', '#root', { title: 'Hello' });
|
|
301
|
+
|
|
302
|
+
// Toast notifications
|
|
303
|
+
__Lux__.toast.success('Saved!');
|
|
304
|
+
__Lux__.toast.error('Something went wrong');
|
|
305
|
+
__Lux__.toast.info('Loading...');
|
|
306
|
+
|
|
307
|
+
// Theme switching
|
|
308
|
+
__Lux__.setTheme('dark');
|
|
309
|
+
__Lux__.setTheme('light');
|
|
310
|
+
|
|
311
|
+
// Navigation
|
|
312
|
+
__Lux__.router.navigate('/about');
|
|
313
|
+
|
|
314
|
+
// HTTP requests
|
|
315
|
+
const data = await __Lux__.http.get('https://api.example.com/data');
|
|
316
|
+
|
|
317
|
+
// Storage
|
|
318
|
+
__Lux__.storage.local.set('key', 'value');
|
|
319
|
+
__Lux__.storage.local.get('key');
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## Security
|
|
325
|
+
|
|
326
|
+
Run the built-in security scanner before deploying:
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
luxaura secure
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
Detects:
|
|
333
|
+
- XSS risks (`innerHTML`, `eval`, `document.write`)
|
|
334
|
+
- SQL injection patterns (string concatenation in queries)
|
|
335
|
+
- Accidental server code outside `server` blocks
|
|
336
|
+
- Sensitive environment variable exposure
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## License
|
|
341
|
+
|
|
342
|
+
MIT © Luxaura Contributors
|