frontend-hamroun 1.2.52 → 1.2.54
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 +72 -602
- package/package.json +1 -1
package/README.md
CHANGED
@@ -1,67 +1,31 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# 🚀 Frontend Hamroun
|
1
|
+
# Frontend Hamroun
|
4
2
|
|
5
3
|
A lightweight full-stack JavaScript framework with Virtual DOM and hooks implementation
|
6
4
|
|
7
|
-
[
|
21
|
-
- [Quick Start](#-quick-start)
|
22
|
-
- [Features](#-features)
|
23
|
-
- [Client-side Features](#-client-side-features)
|
24
|
-
- [Server-side Features](#-server-side-features)
|
25
|
-
- [Server-Side Rendering](#-server-side-rendering)
|
26
|
-
- [Performance Optimization](#-performance-optimization)
|
27
|
-
- [CLI Tools](#-cli-tools)
|
28
|
-
- [TypeScript Support](#-typescript-support)
|
29
|
-
- [Browser Compatibility](#-browser-compatibility)
|
30
|
-
- [Contributing](#-contributing)
|
31
|
-
- [Documentation](#-documentation)
|
5
|
+
[](https://www.npmjs.com/package/frontend-hamroun)
|
6
|
+
[](https://bundlephobia.com/result?p=frontend-hamroun)
|
7
|
+
[](https://www.npmjs.com/package/frontend-hamroun)
|
8
|
+
[](LICENSE)
|
32
9
|
|
33
|
-
|
34
|
-
|
35
|
-
## 🔌 Installation
|
10
|
+
## Installation
|
36
11
|
|
37
12
|
```bash
|
38
13
|
npm install frontend-hamroun
|
39
14
|
```
|
40
15
|
|
41
|
-
|
42
|
-
|
43
|
-
### ✨ Quick Links
|
44
|
-
|
45
|
-
[](https://github.com/hamroun/frontend-hamroun)
|
46
|
-
[](https://github.com/hamroun/frontend-hamroun/examples)
|
47
|
-
[](https://github.com/hamroun/frontend-hamroun/docs/API.md)
|
48
|
-
[](https://discord.gg/frontendhamroun)
|
49
|
-
|
50
|
-
</div>
|
51
|
-
|
52
|
-
## 🚀 Quick Start
|
16
|
+
## Quick Start
|
53
17
|
|
54
|
-
Create a new project
|
18
|
+
Create a new project using:
|
55
19
|
|
56
20
|
```bash
|
57
|
-
# Using create-frontend-app
|
21
|
+
# Using the create-frontend-app command
|
58
22
|
npx create-frontend-app my-app
|
59
23
|
|
60
24
|
# Or using the frontend-hamroun CLI
|
61
25
|
npx frontend-hamroun create my-app
|
62
26
|
```
|
63
27
|
|
64
|
-
Then
|
28
|
+
Then:
|
65
29
|
|
66
30
|
```bash
|
67
31
|
cd my-app
|
@@ -69,92 +33,17 @@ npm install
|
|
69
33
|
npm run dev
|
70
34
|
```
|
71
35
|
|
72
|
-
|
73
|
-
|
74
|
-
### 🎮 Interactive Demo
|
75
|
-
|
76
|
-
[](https://codesandbox.io)
|
77
|
-
[](https://stackblitz.com)
|
78
|
-
|
79
|
-
</div>
|
80
|
-
|
81
|
-
## 🎯 Features
|
82
|
-
|
83
|
-
<div class="features-grid" style="display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px;">
|
84
|
-
|
85
|
-
<div class="feature-card" style="background: #f8f9fa; border-radius: 8px; padding: 20px;">
|
86
|
-
<h3>🔍 Lightweight Core</h3>
|
87
|
-
<p><strong><5KB</strong> gzipped for essential runtime</p>
|
88
|
-
</div>
|
89
|
-
|
90
|
-
<div class="feature-card" style="background: #f8f9fa; border-radius: 8px; padding: 20px;">
|
91
|
-
<h3>⚡ Full-Stack Solution</h3>
|
92
|
-
<p>Client and server capabilities in one package</p>
|
93
|
-
</div>
|
94
|
-
|
95
|
-
<div class="feature-card" style="background: #f8f9fa; border-radius: 8px; padding: 20px;">
|
96
|
-
<h3>🔄 Virtual DOM</h3>
|
97
|
-
<p>Efficient rendering and diffing algorithm</p>
|
98
|
-
</div>
|
99
|
-
|
100
|
-
<div class="feature-card" style="background: #f8f9fa; border-radius: 8px; padding: 20px;">
|
101
|
-
<h3>🪝 Hooks API</h3>
|
102
|
-
<p>Complete hooks system for state management</p>
|
103
|
-
</div>
|
104
|
-
|
105
|
-
<div class="feature-card" style="background: #f8f9fa; border-radius: 8px; padding: 20px;">
|
106
|
-
<h3>🌐 Server-Side Rendering</h3>
|
107
|
-
<p>Optimized SSR with hydration</p>
|
108
|
-
</div>
|
109
|
-
|
110
|
-
<div class="feature-card" style="background: #f8f9fa; border-radius: 8px; padding: 20px;">
|
111
|
-
<h3>🔐 Authentication</h3>
|
112
|
-
<p>Built-in JWT authentication system</p>
|
113
|
-
</div>
|
114
|
-
|
115
|
-
<div class="feature-card" style="background: #f8f9fa; border-radius: 8px; padding: 20px;">
|
116
|
-
<h3>💾 Database Integration</h3>
|
117
|
-
<p>Support for MongoDB, MySQL, PostgreSQL</p>
|
118
|
-
</div>
|
119
|
-
|
120
|
-
<div class="feature-card" style="background: #f8f9fa; border-radius: 8px; padding: 20px;">
|
121
|
-
<h3>🧩 TypeScript Support</h3>
|
122
|
-
<p>Full type definitions included</p>
|
123
|
-
</div>
|
124
|
-
|
125
|
-
</div>
|
126
|
-
|
127
|
-
<br>
|
128
|
-
|
129
|
-
## 📊 Framework Comparison
|
130
|
-
|
131
|
-
| Feature | Frontend Hamroun | React | Vue | Angular |
|
132
|
-
|---------|------------------|-------|-----|---------|
|
133
|
-
| Bundle Size | < 5KB | 42KB | 33KB | 65KB |
|
134
|
-
| Virtual DOM | ✅ | ✅ | ✅ | ❌ |
|
135
|
-
| Hooks API | ✅ | ✅ | ⚠️ | ❌ |
|
136
|
-
| Built-in SSR | ✅ | ❌ | ⚠️ | ✅ |
|
137
|
-
| Built-in API Server | ✅ | ❌ | ❌ | ❌ |
|
138
|
-
| DB Integration | ✅ | ❌ | ❌ | ❌ |
|
139
|
-
| Learning Curve | Low | Medium | Low | High |
|
140
|
-
|
141
|
-
<br>
|
142
|
-
|
143
|
-
## 💻 Basic Usage
|
36
|
+
## Basic Usage
|
144
37
|
|
145
38
|
```jsx
|
146
39
|
import { render, useState } from 'frontend-hamroun';
|
147
40
|
|
148
41
|
function App() {
|
149
42
|
const [count, setCount] = useState(0);
|
150
|
-
|
151
43
|
return (
|
152
|
-
<div
|
153
|
-
<h1>
|
154
|
-
<
|
155
|
-
<button onClick={() => setCount(count + 1)}>
|
156
|
-
Increment
|
157
|
-
</button>
|
44
|
+
<div>
|
45
|
+
<h1>Count: {count}</h1>
|
46
|
+
<button onClick={() => setCount(count + 1)}>Increment</button>
|
158
47
|
</div>
|
159
48
|
);
|
160
49
|
}
|
@@ -162,15 +51,23 @@ function App() {
|
|
162
51
|
render(<App />, document.getElementById('root'));
|
163
52
|
```
|
164
53
|
|
165
|
-
|
166
|
-
<img src="https://via.placeholder.com/600x300?text=Application+Screenshot" alt="Application Screenshot" width="600" style="border-radius: 8px;"/>
|
167
|
-
</div>
|
54
|
+
## Features
|
168
55
|
|
169
|
-
|
56
|
+
- **Lightweight Core**: <5KB gzipped for essential runtime
|
57
|
+
- **Full-Stack Solution**: Client and server capabilities in one package
|
58
|
+
- **Virtual DOM**: Efficient rendering and diffing algorithm
|
59
|
+
- **Hooks API**: Complete hooks system (useState, useEffect, useMemo, useRef)
|
60
|
+
- **Context API**: Simple state management across components
|
61
|
+
- **Server-Side Rendering**: Optimized SSR with hydration
|
62
|
+
- **Database Integration**: Support for MongoDB, MySQL, and PostgreSQL
|
63
|
+
- **Authentication**: Built-in JWT authentication system
|
64
|
+
- **API Routing**: Express-based file system routing
|
65
|
+
- **TypeScript Support**: Full type definitions included
|
66
|
+
- **Interactive CLI**: Powerful tools for project scaffolding and component creation
|
170
67
|
|
171
|
-
|
68
|
+
## Client-side Features
|
172
69
|
|
173
|
-
|
70
|
+
### Component Development
|
174
71
|
|
175
72
|
```jsx
|
176
73
|
import { useState, useEffect } from 'frontend-hamroun';
|
@@ -186,81 +83,22 @@ function Counter() {
|
|
186
83
|
return (
|
187
84
|
<div className="counter">
|
188
85
|
<h2>Counter: {count}</h2>
|
189
|
-
<
|
190
|
-
|
191
|
-
<button onClick={() => setCount(count - 1)}>-</button>
|
192
|
-
</div>
|
86
|
+
<button onClick={() => setCount(count + 1)}>+</button>
|
87
|
+
<button onClick={() => setCount(count - 1)}>-</button>
|
193
88
|
</div>
|
194
89
|
);
|
195
90
|
}
|
196
91
|
```
|
197
92
|
|
198
|
-
|
199
|
-
<summary><b>🔍 View Hooks API Reference</b></summary>
|
93
|
+
### Hooks API
|
200
94
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
setCount(count + 1); // Direct update
|
207
|
-
setCount(prev => prev + 1); // Functional update
|
208
|
-
```
|
95
|
+
- **useState**: Manage component state
|
96
|
+
- **useEffect**: Handle side effects
|
97
|
+
- **useMemo**: Memoize expensive calculations
|
98
|
+
- **useRef**: Reference DOM elements and persist values
|
99
|
+
- **useErrorBoundary**: Create error boundaries
|
209
100
|
|
210
|
-
|
211
|
-
```jsx
|
212
|
-
useEffect(() => {
|
213
|
-
// Effect logic
|
214
|
-
const subscription = api.subscribe();
|
215
|
-
|
216
|
-
return () => {
|
217
|
-
// Cleanup logic
|
218
|
-
subscription.unsubscribe();
|
219
|
-
};
|
220
|
-
}, [dependency]); // Dependency array
|
221
|
-
```
|
222
|
-
|
223
|
-
#### 🔄 useMemo
|
224
|
-
```jsx
|
225
|
-
const expensiveValue = useMemo(() => {
|
226
|
-
return computeExpensiveValue(a, b);
|
227
|
-
}, [a, b]); // Recomputes only when a or b changes
|
228
|
-
```
|
229
|
-
|
230
|
-
#### 🔄 useRef
|
231
|
-
```jsx
|
232
|
-
const inputRef = useRef(null);
|
233
|
-
|
234
|
-
// Access the DOM element directly
|
235
|
-
useEffect(() => {
|
236
|
-
inputRef.current.focus();
|
237
|
-
}, []);
|
238
|
-
|
239
|
-
return <input ref={inputRef} />;
|
240
|
-
```
|
241
|
-
|
242
|
-
#### 🔄 useErrorBoundary
|
243
|
-
```jsx
|
244
|
-
const [error, resetError] = useErrorBoundary();
|
245
|
-
|
246
|
-
if (error) {
|
247
|
-
return (
|
248
|
-
<div className="error-boundary">
|
249
|
-
<h2>Something went wrong</h2>
|
250
|
-
<p>{error.message}</p>
|
251
|
-
<button onClick={resetError}>Try again</button>
|
252
|
-
</div>
|
253
|
-
);
|
254
|
-
}
|
255
|
-
```
|
256
|
-
|
257
|
-
</details>
|
258
|
-
|
259
|
-
### 🔄 Context API
|
260
|
-
|
261
|
-
Share state across your component tree:
|
262
|
-
|
263
|
-
<div class="code-with-diagram" style="display: flex; align-items: flex-start; gap: 20px;">
|
101
|
+
### Context API
|
264
102
|
|
265
103
|
```jsx
|
266
104
|
// Create context
|
@@ -274,9 +112,7 @@ function App() {
|
|
274
112
|
<ThemeContext.Provider value={theme}>
|
275
113
|
<Header />
|
276
114
|
<Main />
|
277
|
-
<button onClick={() => setTheme(
|
278
|
-
theme === 'light' ? 'dark' : 'light'
|
279
|
-
)}>
|
115
|
+
<button onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}>
|
280
116
|
Toggle theme
|
281
117
|
</button>
|
282
118
|
</ThemeContext.Provider>
|
@@ -286,35 +122,11 @@ function App() {
|
|
286
122
|
// Consumer
|
287
123
|
function Header() {
|
288
124
|
const theme = useContext(ThemeContext);
|
289
|
-
return
|
290
|
-
<header className={theme}>
|
291
|
-
<h1>My App</h1>
|
292
|
-
</header>
|
293
|
-
);
|
125
|
+
return <header className={theme}><h1>My App</h1></header>;
|
294
126
|
}
|
295
127
|
```
|
296
128
|
|
297
|
-
|
298
|
-
<strong>Context Flow Diagram</strong><br>
|
299
|
-
<pre style="background: #f0f0f0; padding: 10px; margin-top: 10px; border-radius: 5px;">
|
300
|
-
App (Provider)
|
301
|
-
│
|
302
|
-
├─► Header (Consumer)
|
303
|
-
│ Uses theme value
|
304
|
-
│
|
305
|
-
├─► Main
|
306
|
-
│ │
|
307
|
-
│ └─► Article (Consumer)
|
308
|
-
│ Uses theme value
|
309
|
-
│
|
310
|
-
└─► Footer (Consumer)
|
311
|
-
Uses theme value
|
312
|
-
</pre>
|
313
|
-
</div>
|
314
|
-
|
315
|
-
</div>
|
316
|
-
|
317
|
-
## 🖥️ Server-Side Features
|
129
|
+
## Server-Side Features
|
318
130
|
|
319
131
|
### Express Server Integration
|
320
132
|
|
@@ -340,18 +152,8 @@ await app.start();
|
|
340
152
|
console.log('Server running at http://localhost:3000');
|
341
153
|
```
|
342
154
|
|
343
|
-
<div align="center">
|
344
|
-
<img src="https://via.placeholder.com/600x300?text=Server+Architecture+Diagram" alt="Server Architecture" width="600" style="border-radius: 8px;"/>
|
345
|
-
</div>
|
346
|
-
|
347
155
|
### API Routes
|
348
156
|
|
349
|
-
Create API endpoints easily with file-based routing:
|
350
|
-
|
351
|
-
<div class="file-structure" style="display: flex; gap: 20px;">
|
352
|
-
|
353
|
-
<div class="code-example" style="flex: 1;">
|
354
|
-
|
355
157
|
```js
|
356
158
|
// api/users.js - Automatically mapped to /api/users
|
357
159
|
export async function get(req, res) {
|
@@ -363,179 +165,18 @@ export async function post(req, res) {
|
|
363
165
|
const { name, email } = req.body;
|
364
166
|
|
365
167
|
if (!name || !email) {
|
366
|
-
return res.status(400).json({
|
367
|
-
error: 'Name and email are required'
|
368
|
-
});
|
168
|
+
return res.status(400).json({ error: 'Name and email are required' });
|
369
169
|
}
|
370
170
|
|
371
|
-
const result = await req.db.collection('users').insertOne({
|
372
|
-
name,
|
373
|
-
email
|
374
|
-
});
|
375
|
-
|
171
|
+
const result = await req.db.collection('users').insertOne({ name, email });
|
376
172
|
res.status(201).json(result);
|
377
173
|
}
|
378
174
|
```
|
379
175
|
|
380
|
-
|
381
|
-
|
382
|
-
<div class="file-structure-diagram" style="background: #f8f9fa; border-radius: 8px; padding: 15px; min-width: 250px;">
|
383
|
-
<strong>File-based Routing</strong><br>
|
384
|
-
<pre style="background: #f0f0f0; padding: 10px; margin-top: 10px; border-radius: 5px;">
|
385
|
-
api/
|
386
|
-
├── users.js
|
387
|
-
│ ├── get() → GET /api/users
|
388
|
-
│ └── post() → POST /api/users
|
389
|
-
├── posts/
|
390
|
-
│ ├── index.js
|
391
|
-
│ │ └── get() → GET /api/posts
|
392
|
-
│ └── [id].js
|
393
|
-
│ └── get() → GET /api/posts/:id
|
394
|
-
└── auth/
|
395
|
-
├── login.js
|
396
|
-
│ └── post() → POST /api/auth/login
|
397
|
-
└── register.js
|
398
|
-
└── post() → POST /api/auth/register
|
399
|
-
</pre>
|
400
|
-
</div>
|
401
|
-
|
402
|
-
</div>
|
403
|
-
|
404
|
-
<details>
|
405
|
-
<summary><b>🔍 View Database Integration Examples</b></summary>
|
406
|
-
|
407
|
-
### 💾 Database Integration
|
408
|
-
|
409
|
-
Access your database directly in API routes:
|
410
|
-
|
411
|
-
<div class="tabs">
|
412
|
-
<div class="tab" id="mongodb">
|
413
|
-
|
414
|
-
#### MongoDB Example
|
415
|
-
|
416
|
-
```js
|
417
|
-
// MongoDB example
|
418
|
-
export async function get(req, res) {
|
419
|
-
const { id } = req.params;
|
420
|
-
const user = await req.db.collection('users').findOne({
|
421
|
-
_id: new ObjectId(id)
|
422
|
-
});
|
423
|
-
|
424
|
-
if (!user) {
|
425
|
-
return res.status(404).json({ error: 'User not found' });
|
426
|
-
}
|
427
|
-
|
428
|
-
res.json(user);
|
429
|
-
}
|
430
|
-
```
|
431
|
-
|
432
|
-
</div>
|
433
|
-
<div class="tab" id="mysql">
|
434
|
-
|
435
|
-
#### MySQL Example
|
436
|
-
|
437
|
-
```js
|
438
|
-
// MySQL example
|
439
|
-
export async function get(req, res) {
|
440
|
-
const [users] = await req.db.execute(
|
441
|
-
'SELECT * FROM users WHERE active = ?',
|
442
|
-
[true]
|
443
|
-
);
|
444
|
-
res.json(users);
|
445
|
-
}
|
446
|
-
```
|
447
|
-
|
448
|
-
</div>
|
449
|
-
<div class="tab" id="postgres">
|
450
|
-
|
451
|
-
#### PostgreSQL Example
|
452
|
-
|
453
|
-
```js
|
454
|
-
// PostgreSQL example
|
455
|
-
export async function get(req, res) {
|
456
|
-
const result = await req.db.query(
|
457
|
-
'SELECT * FROM users WHERE role = $1',
|
458
|
-
['admin']
|
459
|
-
);
|
460
|
-
res.json(result.rows);
|
461
|
-
}
|
462
|
-
```
|
463
|
-
|
464
|
-
</div>
|
465
|
-
</div>
|
466
|
-
|
467
|
-
</details>
|
468
|
-
|
469
|
-
<details>
|
470
|
-
<summary><b>🔍 View Authentication Example</b></summary>
|
471
|
-
|
472
|
-
### 🔐 Authentication
|
473
|
-
|
474
|
-
Built-in JWT authentication:
|
475
|
-
|
476
|
-
```js
|
477
|
-
// api/auth/login.js
|
478
|
-
export async function post(req, res) {
|
479
|
-
const { username, password } = req.body;
|
480
|
-
const user = await req.db.collection('users').findOne({ username });
|
481
|
-
|
482
|
-
if (!user || !await req.auth.comparePasswords(password, user.password)) {
|
483
|
-
return res.status(401).json({ error: 'Invalid credentials' });
|
484
|
-
}
|
485
|
-
|
486
|
-
const token = req.auth.generateToken(user);
|
487
|
-
res.json({
|
488
|
-
token,
|
489
|
-
user: { id: user._id, username: user.username }
|
490
|
-
});
|
491
|
-
}
|
492
|
-
|
493
|
-
// Protected route
|
494
|
-
// api/profile.js
|
495
|
-
export async function get(req, res) {
|
496
|
-
// req.auth.requireAuth middleware automatically added
|
497
|
-
// req.user contains the authenticated user
|
498
|
-
res.json(req.user);
|
499
|
-
}
|
500
|
-
```
|
501
|
-
|
502
|
-
</details>
|
503
|
-
|
504
|
-
<details>
|
505
|
-
<summary><b>🔍 View Middleware Example</b></summary>
|
506
|
-
|
507
|
-
### Middleware Support
|
508
|
-
|
509
|
-
Add custom middleware to your routes:
|
510
|
-
|
511
|
-
```js
|
512
|
-
// middleware/logger.js
|
513
|
-
export default function logger(req, res, next) {
|
514
|
-
console.log(`${req.method} ${req.path}`);
|
515
|
-
next();
|
516
|
-
}
|
517
|
-
|
518
|
-
// server.js
|
519
|
-
import logger from './middleware/logger';
|
520
|
-
|
521
|
-
const app = await server.createServer({
|
522
|
-
// ...other options
|
523
|
-
middleware: [logger]
|
524
|
-
});
|
525
|
-
```
|
526
|
-
|
527
|
-
</details>
|
528
|
-
|
529
|
-
## 🌐 Server-Side Rendering
|
530
|
-
|
531
|
-
Frontend Hamroun provides seamless SSR with hydration:
|
532
|
-
|
533
|
-
<div class="ssr-diagram-container" style="display: flex; gap: 20px; margin-bottom: 20px;">
|
534
|
-
|
535
|
-
<div class="code-example" style="flex: 1;">
|
176
|
+
## Server-Side Rendering
|
536
177
|
|
537
178
|
```jsx
|
538
|
-
//
|
179
|
+
// Server-side
|
539
180
|
import { renderToString } from 'frontend-hamroun/ssr';
|
540
181
|
import App from './App';
|
541
182
|
|
@@ -557,47 +198,17 @@ app.get('*', async (req, res) => {
|
|
557
198
|
`);
|
558
199
|
});
|
559
200
|
|
560
|
-
//
|
201
|
+
// Client-side
|
561
202
|
import { hydrate } from 'frontend-hamroun';
|
562
203
|
import App from './App';
|
563
204
|
|
564
|
-
hydrate(<App url={window.location.pathname} />,
|
565
|
-
document.getElementById('root'));
|
205
|
+
hydrate(<App url={window.location.pathname} />, document.getElementById('root'));
|
566
206
|
```
|
567
207
|
|
568
|
-
|
569
|
-
|
570
|
-
<div class="ssr-flow-diagram" style="background: #f8f9fa; border-radius: 8px; padding: 15px; min-width: 250px;">
|
571
|
-
<strong>SSR Flow</strong><br>
|
572
|
-
<pre style="background: #f0f0f0; padding: 10px; margin-top: 10px; border-radius: 5px;">
|
573
|
-
1. HTTP Request
|
574
|
-
↓
|
575
|
-
2. Server renders React to HTML
|
576
|
-
↓
|
577
|
-
3. HTML sent to browser
|
578
|
-
↓
|
579
|
-
4. Browser displays HTML
|
580
|
-
↓
|
581
|
-
5. JavaScript loads
|
582
|
-
↓
|
583
|
-
6. Hydration attaches event
|
584
|
-
handlers to existing DOM
|
585
|
-
↓
|
586
|
-
7. App becomes interactive
|
587
|
-
</pre>
|
588
|
-
</div>
|
589
|
-
|
590
|
-
</div>
|
591
|
-
|
592
|
-
<div align="center">
|
593
|
-
<img src="https://via.placeholder.com/700x200?text=SSR+vs+CSR+Performance+Comparison" alt="SSR Performance" width="700" style="border-radius: 8px;"/>
|
594
|
-
</div>
|
595
|
-
|
596
|
-
## ⚡ Performance Optimization
|
208
|
+
## Performance Features
|
597
209
|
|
598
210
|
### Batch Updates
|
599
|
-
|
600
|
-
Group state updates for better performance:
|
211
|
+
Group multiple state updates together to prevent unnecessary re-renders:
|
601
212
|
|
602
213
|
```jsx
|
603
214
|
import { batchUpdates } from 'frontend-hamroun';
|
@@ -612,121 +223,33 @@ function handleSubmit() {
|
|
612
223
|
}
|
613
224
|
```
|
614
225
|
|
615
|
-
|
616
|
-
|
617
|
-
The framework uses an efficient diffing algorithm to minimize DOM operations:
|
618
|
-
|
619
|
-
<div class="diffing-container" style="display: flex; gap: 20px; margin-bottom: 20px;">
|
620
|
-
|
621
|
-
<div class="code-example" style="flex: 1;">
|
622
|
-
|
623
|
-
```jsx
|
624
|
-
// This only updates the changed parts of the DOM
|
625
|
-
function Counter() {
|
626
|
-
const [count, setCount] = useState(0);
|
627
|
-
return (
|
628
|
-
<div>
|
629
|
-
<h1>Counter</h1>
|
630
|
-
<p>Count: {count}</p> {/* Only this text node updates */}
|
631
|
-
<button onClick={() => setCount(count + 1)}>
|
632
|
-
Increment
|
633
|
-
</button>
|
634
|
-
</div>
|
635
|
-
);
|
636
|
-
}
|
637
|
-
```
|
638
|
-
|
639
|
-
</div>
|
640
|
-
|
641
|
-
<div class="diffing-diagram" style="background: #f8f9fa; border-radius: 8px; padding: 15px; min-width: 250px;">
|
642
|
-
<strong>Diffing Process</strong><br>
|
643
|
-
<pre style="background: #f0f0f0; padding: 10px; margin-top: 10px; border-radius: 5px;">
|
644
|
-
Old Virtual DOM
|
645
|
-
↓
|
646
|
-
New Virtual DOM
|
647
|
-
↓
|
648
|
-
Compare Trees
|
649
|
-
↓
|
650
|
-
Identify Differences
|
651
|
-
↓
|
652
|
-
Update Only Changed
|
653
|
-
DOM Elements
|
654
|
-
</pre>
|
655
|
-
</div>
|
656
|
-
|
657
|
-
</div>
|
658
|
-
|
659
|
-
<div align="center">
|
660
|
-
<img src="https://via.placeholder.com/700x200?text=Performance+Benchmark+Graph" alt="Performance Benchmark" width="700" style="border-radius: 8px;"/>
|
661
|
-
</div>
|
662
|
-
|
663
|
-
## 🛠️ CLI Tools
|
226
|
+
## CLI Tools
|
664
227
|
|
665
228
|
Frontend Hamroun includes powerful CLI tools for development:
|
666
229
|
|
667
|
-
<div class="cli-examples" style="background: #f8f9fa; border-radius: 8px; padding: 20px; margin-bottom: 20px;">
|
668
|
-
|
669
230
|
```bash
|
670
|
-
# Create a new project
|
231
|
+
# Create a new project
|
671
232
|
npx frontend-hamroun create my-app
|
672
233
|
|
673
|
-
# Generate a new component
|
234
|
+
# Generate a new component
|
674
235
|
npx frontend-hamroun add:component Button
|
675
236
|
|
676
|
-
# Create a new page
|
237
|
+
# Create a new page
|
677
238
|
npx frontend-hamroun add:page Home
|
678
239
|
|
679
240
|
# Generate an API route
|
680
241
|
npx frontend-hamroun add:api users --methods=get,post,put,delete
|
681
|
-
|
682
|
-
# View development tools and tips
|
683
|
-
npx frontend-hamroun dev:tools
|
684
242
|
```
|
685
243
|
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
<ul>
|
696
|
-
<li>Quick setup</li>
|
697
|
-
<li>No build step in development</li>
|
698
|
-
<li>Focused on simplicity</li>
|
699
|
-
<li>Perfect for learning</li>
|
700
|
-
</ul>
|
701
|
-
</div>
|
702
|
-
|
703
|
-
<div class="template-card" style="background: #f0fff4; border-radius: 8px; padding: 15px; min-width: 250px; border-left: 5px solid #34a853;">
|
704
|
-
<h3>🌐 SSR Template</h3>
|
705
|
-
<p>Server-side rendering with hydration</p>
|
706
|
-
<ul>
|
707
|
-
<li>SEO-friendly</li>
|
708
|
-
<li>Fast initial load</li>
|
709
|
-
<li>Express server included</li>
|
710
|
-
<li>Optimized for content sites</li>
|
711
|
-
</ul>
|
712
|
-
</div>
|
713
|
-
|
714
|
-
<div class="template-card" style="background: #fff8e1; border-radius: 8px; padding: 15px; min-width: 250px; border-left: 5px solid #fbbc04;">
|
715
|
-
<h3>⚡ Fullstack App</h3>
|
716
|
-
<p>Complete solution with API, authentication, and database</p>
|
717
|
-
<ul>
|
718
|
-
<li>API routes included</li>
|
719
|
-
<li>Database integration</li>
|
720
|
-
<li>Authentication ready</li>
|
721
|
-
<li>Production-ready setup</li>
|
722
|
-
</ul>
|
723
|
-
</div>
|
724
|
-
|
725
|
-
</div>
|
726
|
-
|
727
|
-
## 📘 TypeScript Support
|
728
|
-
|
729
|
-
Frontend Hamroun is built with TypeScript and includes full type definitions:
|
244
|
+
## Project Templates
|
245
|
+
|
246
|
+
Choose from multiple project templates:
|
247
|
+
|
248
|
+
1. **Basic App**: Client-side SPA with essential features
|
249
|
+
2. **SSR Template**: Server-side rendering with hydration
|
250
|
+
3. **Fullstack App**: Complete solution with API, authentication, and database
|
251
|
+
|
252
|
+
## TypeScript Support
|
730
253
|
|
731
254
|
```tsx
|
732
255
|
import { useState } from 'frontend-hamroun';
|
@@ -752,67 +275,14 @@ function UserProfile({ id, name, email }: UserProps) {
|
|
752
275
|
}
|
753
276
|
```
|
754
277
|
|
755
|
-
##
|
756
|
-
|
757
|
-
Frontend Hamroun works in all modern browsers
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
<div>Firefox</div>
|
767
|
-
<div>Latest 2 versions</div>
|
768
|
-
</div>
|
769
|
-
<div style="text-align: center; padding: 10px;">
|
770
|
-
<div style="font-size: 2em;">🧭</div>
|
771
|
-
<div>Safari</div>
|
772
|
-
<div>Latest 2 versions</div>
|
773
|
-
</div>
|
774
|
-
<div style="text-align: center; padding: 10px;">
|
775
|
-
<div style="font-size: 2em;">🌐</div>
|
776
|
-
<div>Edge</div>
|
777
|
-
<div>Latest 2 versions</div>
|
778
|
-
</div>
|
779
|
-
<div style="text-align: center; padding: 10px;">
|
780
|
-
<div style="font-size: 2em;">🏛️</div>
|
781
|
-
<div>IE11</div>
|
782
|
-
<div>With polyfills</div>
|
783
|
-
</div>
|
784
|
-
</div>
|
785
|
-
|
786
|
-
## 👥 Contributing
|
787
|
-
|
788
|
-
Contributions are welcome! See [CONTRIBUTING.md](./docs/CONTRIBUTING.md) for details.
|
789
|
-
|
790
|
-
<div class="contribution-workflow" style="background: #f8f9fa; border-radius: 8px; padding: 20px; margin: 20px 0;">
|
791
|
-
<h3>Contribution Workflow</h3>
|
792
|
-
<ol>
|
793
|
-
<li>Fork the repository</li>
|
794
|
-
<li>Create your feature branch: <code>git checkout -b feature/amazing-feature</code></li>
|
795
|
-
<li>Commit your changes: <code>git commit -m 'Add amazing feature'</code></li>
|
796
|
-
<li>Push to the branch: <code>git push origin feature/amazing-feature</code></li>
|
797
|
-
<li>Open a Pull Request</li>
|
798
|
-
</ol>
|
799
|
-
</div>
|
800
|
-
|
801
|
-
## 📚 Documentation
|
802
|
-
|
803
|
-
For complete documentation, visit [our documentation site](https://github.com/hamroun/frontend-hamroun).
|
804
|
-
|
805
|
-
<div align="center">
|
806
|
-
|
807
|
-
<div style="margin-top: 40px;">
|
808
|
-
<h3>💖 Support the Project</h3>
|
809
|
-
|
810
|
-
[](https://github.com/sponsors/hamroun)
|
811
|
-
[](https://github.com/hamroun/frontend-hamroun)
|
812
|
-
</div>
|
813
|
-
|
814
|
-
<div style="margin-top: 30px;">
|
815
|
-
<p>MIT © Hamroun</p>
|
816
|
-
</div>
|
817
|
-
|
818
|
-
</div>
|
278
|
+
## Browser Compatibility
|
279
|
+
|
280
|
+
Frontend Hamroun works in all modern browsers (Chrome, Firefox, Safari, Edge) and in IE11 with appropriate polyfills.
|
281
|
+
|
282
|
+
## Documentation
|
283
|
+
|
284
|
+
For complete documentation, visit our [GitHub repository](https://github.com/hamroun/frontend-hamroun).
|
285
|
+
|
286
|
+
## License
|
287
|
+
|
288
|
+
MIT © Hamroun
|