fynixui 1.0.11 → 1.0.13
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/LICENSE +21 -21
- package/README.md +396 -0
- package/dist/README.md +396 -0
- package/dist/custom/DataTable.js +359 -0
- package/dist/custom/button.js +241 -1
- package/dist/custom/index.js +2 -1
- package/dist/error/errorOverlay.js +1 -1
- package/dist/hooks/nixFor.js +15 -17
- package/dist/package.json +2 -3
- package/dist/plugins/vite-plugin-res.js +26 -4
- package/dist/router/router.js +108 -217
- package/dist/runtime.js +1261 -1026
- package/dist-types/context/context.d.ts +1 -1
- package/dist-types/custom/DataTable.d.ts +54 -0
- package/dist-types/custom/button.d.ts +35 -1
- package/dist-types/custom/index.d.ts +2 -1
- package/dist-types/hooks/nixFor.d.ts +1 -1
- package/dist-types/router/router.d.ts +14 -10
- package/dist-types/runtime.d.ts +118 -40
- package/package.json +256 -254
- package/types/fnx.d.ts +34 -34
- package/types/global.d.ts +277 -279
- package/types/jsx.d.ts +1046 -993
- package/types/vite-env.d.ts +545 -545
package/dist/README.md
ADDED
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# Fynix Core
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
**A lightweight, fiber-based runtime with built-in security and fine-grained reactivity**
|
|
10
|
+
|
|
11
|
+
[ Quick Start](#-quick-start) • [ Docs](#-architecture) • [ Security](#-security) • [ Features](#-key-features)
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Key Features
|
|
18
|
+
|
|
19
|
+
<table>
|
|
20
|
+
<tr>
|
|
21
|
+
<td align="center"><br><b>Fiber Architecture</b><br>Time-sliced rendering</td>
|
|
22
|
+
<td align="center"><br><b>Security Built-in</b><br>XSS protection by default</td>
|
|
23
|
+
<td align="center"><br><b>Zero Dependencies</b><br>No supply chain risk</td>
|
|
24
|
+
</tr>
|
|
25
|
+
<tr>
|
|
26
|
+
<td align="center"><br><b>Surgical Updates</b><br>Only affected fibers render</td>
|
|
27
|
+
<td align="center"><br><b>TypeScript Native</b><br>Full type safety</td>
|
|
28
|
+
<td align="center"><br><b>High Performance</b><br>Optimized for speed</td>
|
|
29
|
+
</tr>
|
|
30
|
+
</table>
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Quick Facts
|
|
35
|
+
|
|
36
|
+
| Aspect | Status |
|
|
37
|
+
| ---------------------- | ----------------------- |
|
|
38
|
+
| **Build Size** | ~15KB gzipped |
|
|
39
|
+
| **External Deps** | 0 |
|
|
40
|
+
| **TypeScript Support** | Full |
|
|
41
|
+
| **Browser Support** | Modern browsers |
|
|
42
|
+
| **Security** | Built-in XSS protection |
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Overview
|
|
47
|
+
|
|
48
|
+
Fynix Core is a modern web framework built on **fiber architecture** and **fine-grained reactivity**. Unlike traditional frameworks that re-render entire component trees, Fynix uses targeted fiber updates to only re-render components that actually changed, resulting in dramatically better performance.
|
|
49
|
+
|
|
50
|
+
**Key Stats:**
|
|
51
|
+
|
|
52
|
+
- **Zero Runtime Dependencies** - No supply chain risk
|
|
53
|
+
- **Security Built-in** - XSS protection at the framework level
|
|
54
|
+
- **Lightweight** - Tiny bundle size with fiber reconciliation
|
|
55
|
+
- **Surgical Re-renders** - Only affected fibers update, not entire trees
|
|
56
|
+
- **Full TypeScript** - Native JSX support with complete type safety
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Architecture
|
|
61
|
+
|
|
62
|
+
### The Fynix Render Pipeline
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
VNode Tree (h() / JSX)
|
|
66
|
+
↓
|
|
67
|
+
FiberReconciler
|
|
68
|
+
(Fiber Tree Construction)
|
|
69
|
+
↓
|
|
70
|
+
Time-Sliced Work Loop
|
|
71
|
+
(FynixScheduler handles priority)
|
|
72
|
+
↓
|
|
73
|
+
Commit Phase
|
|
74
|
+
(DOM Mutations)
|
|
75
|
+
↓
|
|
76
|
+
Browser Paint
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Core Concepts
|
|
80
|
+
|
|
81
|
+
**1. VNode (Virtual DOM Node)**
|
|
82
|
+
|
|
83
|
+
- Lightweight, immutable representation of UI
|
|
84
|
+
- Created by `h()` function or JSX syntax
|
|
85
|
+
- Never directly mutates the DOM
|
|
86
|
+
- Preserved as the public API
|
|
87
|
+
|
|
88
|
+
**2. FynixFiber (Internal Work Unit)**
|
|
89
|
+
|
|
90
|
+
- Each fiber represents one VNode
|
|
91
|
+
- Forms a singly-linked tree: `child → sibling → parent`
|
|
92
|
+
- Contains component context, hooks, and lifecycle state
|
|
93
|
+
- `alternate` pointer enables diffing without touching the DOM mid-render
|
|
94
|
+
|
|
95
|
+
**3. Work Loop (Time-Sliced Scheduling)**
|
|
96
|
+
|
|
97
|
+
- Priority-based task scheduler
|
|
98
|
+
- Yields to higher-priority work (user interactions)
|
|
99
|
+
- Background work (prefetching, non-critical updates) runs idle
|
|
100
|
+
- Ensures UI stays responsive even under heavy load
|
|
101
|
+
|
|
102
|
+
**4. Commit Phase**
|
|
103
|
+
|
|
104
|
+
- Applies all DOM mutations in one synchronous pass
|
|
105
|
+
- No partial updates, no layout thrashing
|
|
106
|
+
- Operations: `PLACEMENT`, `UPDATE`, `DELETION`
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Runtime Features
|
|
111
|
+
|
|
112
|
+
### 1. **Priority-Based Scheduling**
|
|
113
|
+
|
|
114
|
+
Fine-grained control over when and how updates are processed:
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
enum Priority {
|
|
118
|
+
immediate = "Right now (sync)",
|
|
119
|
+
high = "Next rAF (~16ms)",
|
|
120
|
+
normal = "Batched updates",
|
|
121
|
+
low = "Background work",
|
|
122
|
+
idle = "requestIdleCallback",
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Performance Impact:**
|
|
127
|
+
|
|
128
|
+
- User interactions (clicks) → `high` priority
|
|
129
|
+
- State updates → `normal` priority
|
|
130
|
+
- Prefetching → `low` priority
|
|
131
|
+
- Analytics → `idle` priority
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
interface Update {
|
|
135
|
+
id: string;
|
|
136
|
+
type: UpdateType; // "state" | "props" | "effect" | "layout"
|
|
137
|
+
priority: Priority;
|
|
138
|
+
component?: ComponentContext;
|
|
139
|
+
callback: () => void;
|
|
140
|
+
timestamp: number;
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### 2. **Fine-Grained Reactivity**
|
|
145
|
+
|
|
146
|
+
**nixState** tracks exactly which components depend on which state values:
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
const count = nixState(0);
|
|
150
|
+
|
|
151
|
+
// Only this component's fiber updates
|
|
152
|
+
count.set(count.value + 1);
|
|
153
|
+
|
|
154
|
+
// NOT the entire tree
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**How it works:**
|
|
158
|
+
|
|
159
|
+
1. Component subscribes to `nixState`
|
|
160
|
+
2. State change marks only THIS fiber as dirty
|
|
161
|
+
3. Scheduler queues fiber for update
|
|
162
|
+
4. Commit phase applies single fiber update
|
|
163
|
+
5. Parent & sibling trees untouched
|
|
164
|
+
|
|
165
|
+
### 3. **Double-Buffered Fiber Tree**
|
|
166
|
+
|
|
167
|
+
Safe diffing without touching the DOM during reconciliation:
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
interface FynixFiber {
|
|
171
|
+
// Current render
|
|
172
|
+
props: VNodeProps;
|
|
173
|
+
child: FynixFiber | null;
|
|
174
|
+
sibling: FynixFiber | null;
|
|
175
|
+
|
|
176
|
+
// Previous render (for diffing)
|
|
177
|
+
alternate: FynixFiber | null;
|
|
178
|
+
|
|
179
|
+
// Reconciliation metadata
|
|
180
|
+
effectTag: "PLACEMENT" | "UPDATE" | "DELETION";
|
|
181
|
+
updatePriority: Priority;
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### 4. **Component Context Lifecycle**
|
|
186
|
+
|
|
187
|
+
Each component gets persistent state storage:
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
interface ComponentContext {
|
|
191
|
+
hooks: any[]; // Hook values
|
|
192
|
+
effects: Function[]; // Effect cleanup functions
|
|
193
|
+
_fiber: FynixFiber; // Back-reference to fiber
|
|
194
|
+
_subscriptions: Set<...>; // Active subscriptions
|
|
195
|
+
_isMounted: boolean; // Lifecycle tracking
|
|
196
|
+
version: number; // Render count
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## Router Features
|
|
203
|
+
|
|
204
|
+
### 1. **File-Based Routing**
|
|
205
|
+
|
|
206
|
+
Automatic route discovery with pattern matching:
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
interface FynixRouter {
|
|
210
|
+
mountRouter(selector?: string): void;
|
|
211
|
+
navigate(path: string, props?: Record<string, any>): void;
|
|
212
|
+
replace(path: string, props?: Record<string, any>): void;
|
|
213
|
+
back(): void;
|
|
214
|
+
cleanup(): void;
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### 2. **Dynamic Routes with Params**
|
|
219
|
+
|
|
220
|
+
Automatic parameter extraction from URL patterns:
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
interface DynamicRoute {
|
|
224
|
+
pattern: string; // e.g., "/products/:id"
|
|
225
|
+
regex: RegExp; // Compiled for fast matching
|
|
226
|
+
component: RouteComponent;
|
|
227
|
+
params: string[]; // ["id"] extracted from pattern
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### 3. **Reactive Location Signal**
|
|
232
|
+
|
|
233
|
+
Components automatically re-render on route changes:
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
interface LocationSignal {
|
|
237
|
+
path: string; // Current route path
|
|
238
|
+
params: Record<string, string>; // URL parameters
|
|
239
|
+
search: string; // Query string
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Components automatically re-render on route changes
|
|
243
|
+
location.subscribe((newLocation) => {
|
|
244
|
+
// Handle route change
|
|
245
|
+
});
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### 4. **Enterprise Props Caching**
|
|
249
|
+
|
|
250
|
+
Prevents state loss during navigation:
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
interface HistoryState {
|
|
254
|
+
__fynixCacheKey?: string;
|
|
255
|
+
serializedProps?: Record<string, any>;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Limits
|
|
259
|
+
const MAX_CACHE_SIZE = 50;
|
|
260
|
+
const RENDER_DEBOUNCE = 10; // ms
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### 5. **SEO-Friendly Route Metadata**
|
|
264
|
+
|
|
265
|
+
Define page titles and meta tags per route:
|
|
266
|
+
|
|
267
|
+
```typescript
|
|
268
|
+
interface RouteMeta {
|
|
269
|
+
title?: string;
|
|
270
|
+
description?: string;
|
|
271
|
+
keywords?: string;
|
|
272
|
+
twitterCard?: string;
|
|
273
|
+
ogTitle?: string;
|
|
274
|
+
ogDescription?: string;
|
|
275
|
+
ogImage?: string;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
interface RouteComponent {
|
|
279
|
+
(props: any): VNode | Promise<VNode>;
|
|
280
|
+
props?: Record<string, any> | (() => Record<string, any>);
|
|
281
|
+
meta?: RouteMeta | ((params: Record<string, string>) => RouteMeta);
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Lazy Loading
|
|
286
|
+
|
|
287
|
+
Routes support lazy loading via `nixLazy`:
|
|
288
|
+
|
|
289
|
+
```typescript
|
|
290
|
+
interface FynixRouterOptions {
|
|
291
|
+
lazy?: boolean; // Enable lazy route loading
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Installation
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
npx fynixcli <app-name>
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### JSX Syntax
|
|
302
|
+
|
|
303
|
+
```typescript
|
|
304
|
+
import { nixState, VNode } from "fynixui";
|
|
305
|
+
|
|
306
|
+
export function Counter(): VNode {
|
|
307
|
+
const count = nixState<number>(0);
|
|
308
|
+
|
|
309
|
+
return (
|
|
310
|
+
<div class="p-8 text-center">
|
|
311
|
+
<h1 class="text-4xl font-black mb-4">
|
|
312
|
+
Count: {count.value}
|
|
313
|
+
</h1>
|
|
314
|
+
<button
|
|
315
|
+
r-click={() => count.set(count.value + 1)}
|
|
316
|
+
r-class="px-6 py-3 rounded-lg bg-gradient-to-r
|
|
317
|
+
from-violet-500 to-cyan-500
|
|
318
|
+
text-white font-bold hover:shadow-lg
|
|
319
|
+
transition-shadow"
|
|
320
|
+
>
|
|
321
|
+
Increment
|
|
322
|
+
</button>
|
|
323
|
+
</div>
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
## Security
|
|
329
|
+
|
|
330
|
+
### Built-in XSS Protection
|
|
331
|
+
|
|
332
|
+
**HTML Entity Encoding**
|
|
333
|
+
|
|
334
|
+
- Automatic sanitization of text nodes
|
|
335
|
+
- `<`, `>`, `&`, `"`, `'` are encoded
|
|
336
|
+
|
|
337
|
+
**Protocol Blocking**
|
|
338
|
+
|
|
339
|
+
- `javascript:` URLs blocked
|
|
340
|
+
- `data:` URIs blocked
|
|
341
|
+
- `vbscript:` blocked
|
|
342
|
+
- Safe protocols only: `http://`, `https://`, relative paths
|
|
343
|
+
|
|
344
|
+
**Inline Handler Blocking**
|
|
345
|
+
|
|
346
|
+
- `onclick`, `onmouseover`, etc. rejected
|
|
347
|
+
- Use `r-click`, `r-input` instead (delegated events)
|
|
348
|
+
|
|
349
|
+
**innerHTML Restriction**
|
|
350
|
+
|
|
351
|
+
- `innerHTML` assignment blocked
|
|
352
|
+
- `outerHTML` blocked
|
|
353
|
+
- Use VNode API instead
|
|
354
|
+
|
|
355
|
+
### Security Best Practices
|
|
356
|
+
|
|
357
|
+
```typescript
|
|
358
|
+
// BLOCKED (inline handler)
|
|
359
|
+
<button onclick="alert('hack')">Click</button>
|
|
360
|
+
|
|
361
|
+
// ALLOWED (delegated event)
|
|
362
|
+
<button r-click={() => alert('safe')}>Click</button>
|
|
363
|
+
|
|
364
|
+
// BLOCKED (data URI)
|
|
365
|
+
<img src="data:text/html,<script>..." />
|
|
366
|
+
|
|
367
|
+
// ALLOWED (secure source)
|
|
368
|
+
<img src="/images/photo.jpg" />
|
|
369
|
+
|
|
370
|
+
// BLOCKED (innerHTML)
|
|
371
|
+
element.innerHTML = userInput;
|
|
372
|
+
|
|
373
|
+
// ALLOWED (VNode)
|
|
374
|
+
<div>{userInput}</div>
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
## Contributing
|
|
378
|
+
|
|
379
|
+
Contributions welcome! Please submit issues and pull requests to our [GitHub repository](https://github.com/Lazycoder229/fynix).
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
## License
|
|
384
|
+
|
|
385
|
+
MIT License © 2026 Resty Gonzales
|
|
386
|
+
|
|
387
|
+
See [LICENSE](./LICENSE) for full details.
|
|
388
|
+
|
|
389
|
+
<div align="center">
|
|
390
|
+
|
|
391
|
+
**Made with by the Fynix team**
|
|
392
|
+
|
|
393
|
+
[](https://github.com/Lazycoder229/fynix)
|
|
394
|
+
[](https://twitter.com/fynix)
|
|
395
|
+
|
|
396
|
+
</div>
|