eleva 1.0.0-rc.3 โ 1.0.0-rc.4
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 +135 -2
- package/dist/eleva-plugins.cjs.js +1330 -0
- package/dist/eleva-plugins.cjs.js.map +1 -0
- package/dist/eleva-plugins.esm.js +1327 -0
- package/dist/eleva-plugins.esm.js.map +1 -0
- package/dist/eleva-plugins.umd.js +1336 -0
- package/dist/eleva-plugins.umd.js.map +1 -0
- package/dist/eleva-plugins.umd.min.js +3 -0
- package/dist/eleva-plugins.umd.min.js.map +1 -0
- package/dist/eleva.cjs.js +15 -34
- package/dist/eleva.cjs.js.map +1 -1
- package/dist/eleva.d.ts +0 -1
- package/dist/eleva.esm.js +15 -34
- package/dist/eleva.esm.js.map +1 -1
- package/dist/eleva.umd.js +15 -34
- package/dist/eleva.umd.js.map +1 -1
- package/dist/eleva.umd.min.js +2 -2
- package/dist/eleva.umd.min.js.map +1 -1
- package/dist/plugins/attr.umd.js +231 -0
- package/dist/plugins/attr.umd.js.map +1 -0
- package/dist/plugins/attr.umd.min.js +3 -0
- package/dist/plugins/attr.umd.min.js.map +1 -0
- package/dist/plugins/router.umd.js +1115 -0
- package/dist/plugins/router.umd.js.map +1 -0
- package/dist/plugins/router.umd.min.js +3 -0
- package/dist/plugins/router.umd.min.js.map +1 -0
- package/package.json +40 -1
- package/src/core/Eleva.js +6 -7
- package/src/modules/Renderer.js +8 -36
- package/src/plugins/Attr.js +252 -0
- package/src/plugins/Router.js +1217 -0
- package/src/plugins/index.js +34 -0
- package/types/core/Eleva.d.ts +0 -1
- package/types/core/Eleva.d.ts.map +1 -1
- package/types/modules/Renderer.d.ts.map +1 -1
- package/types/plugins/Attr.d.ts +28 -0
- package/types/plugins/Attr.d.ts.map +1 -0
- package/types/plugins/Router.d.ts +500 -0
- package/types/plugins/Router.d.ts.map +1 -0
- package/types/plugins/index.d.ts +3 -0
- package/types/plugins/index.d.ts.map +1 -0
package/README.md
CHANGED
|
@@ -40,9 +40,9 @@ Pure JavaScript, Pure Performance, Simply Elegant.
|
|
|
40
40
|
**A minimalist, lightweight, pure vanilla JavaScript frontend runtime framework.**
|
|
41
41
|
_Built with love for native JavaScript and designed with a minimal core that can be extended through a powerful plugin system-because sometimes, less really is more!_ ๐
|
|
42
42
|
|
|
43
|
-
> **Stability Notice**: This is `v1.0.0-rc.
|
|
43
|
+
> **Stability Notice**: This is `v1.0.0-rc.4` - The core functionality is stable. Seeking community feedback before the final v1.0.0 release.
|
|
44
44
|
|
|
45
|
-
**Version:** `1.0.0-rc.
|
|
45
|
+
**Version:** `1.0.0-rc.4`
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
|
|
@@ -74,6 +74,10 @@ Welcome to Eleva! This is my humble, experimental playground for a fresh approac
|
|
|
74
74
|
- [Emitter](#emitter)
|
|
75
75
|
- [Renderer](#renderer)
|
|
76
76
|
- [Eleva (Core)](#eleva-core)
|
|
77
|
+
- [Plugins](#plugins)
|
|
78
|
+
- [Core Framework Only (Lightweight)](#core-framework-only-lightweight)
|
|
79
|
+
- [AttrPlugin](#attrplugin)
|
|
80
|
+
- [RouterPlugin](#routerplugin)
|
|
77
81
|
- [Development](#development)
|
|
78
82
|
- [Testing](#testing)
|
|
79
83
|
- [Contributing](#contributing)
|
|
@@ -136,6 +140,7 @@ This unique, developer-first approach makes Eleva a standout choice for building
|
|
|
136
140
|
- **๐ Lifecycle Hooks:** Complete lifecycle management with before/after mount and update hooks
|
|
137
141
|
- **๐งน Automatic Cleanup:** Proper cleanup of resources, watchers, and child components on unmount
|
|
138
142
|
- **๐ Plugin System:** Extensible architecture with a simple plugin API
|
|
143
|
+
- **๐ฏ Built-in Plugins:** AttrPlugin for advanced attributes and RouterPlugin for client-side routing
|
|
139
144
|
- **๐ฆ UMD & ES Module Builds:** Supports modern build tools and browser environments
|
|
140
145
|
- **๐ค Friendly API:** A gentle learning curve for both beginners and seasoned developers
|
|
141
146
|
- **๐ Tiny Footprint & TypeScript Support:** Approximately ~6 KB minified with built-in TypeScript declarations
|
|
@@ -152,6 +157,8 @@ Eleva is ideal for developers seeking a lightweight, flexible, and high-performa
|
|
|
152
157
|
- **๐ฏ Developer-Friendly:** Stick to pure vanilla JavaScript with familiar syntax and built-in TypeScript support.
|
|
153
158
|
- **๐งช Rapid Prototyping:** Quickly prototype ideas with a minimal and extendable framework.
|
|
154
159
|
- **๐ Extensible:** Easily add features like routing or state management through plugins.
|
|
160
|
+
- **๐ Built-in Routing:** Advanced client-side routing with navigation guards and reactive state via RouterPlugin.
|
|
161
|
+
- **๐ฏ Advanced Attributes:** Sophisticated attribute handling with ARIA support via AttrPlugin.
|
|
155
162
|
- **๐ฆ Module Format Flexibility:** Choose from ESM, CommonJS, or UMD formats based on your project's needs.
|
|
156
163
|
|
|
157
164
|
---
|
|
@@ -373,6 +380,132 @@ Interactive Demo: [CodePen](https://codepen.io/tarekraafat/pen/jEOyzYN?editors=1
|
|
|
373
380
|
- **`.mount(container, compName, props)`**
|
|
374
381
|
Mount a component to the DOM.
|
|
375
382
|
|
|
383
|
+
### Plugins
|
|
384
|
+
|
|
385
|
+
Eleva's plugin system allows you to extend functionality as needed. Plugins are **separately bundled** from the core framework, ensuring optimal tree-shaking and minimal bundle sizes.
|
|
386
|
+
|
|
387
|
+
#### Core Framework Only (Lightweight)
|
|
388
|
+
|
|
389
|
+
```javascript
|
|
390
|
+
import Eleva from 'eleva';
|
|
391
|
+
|
|
392
|
+
const app = new Eleva("myApp");
|
|
393
|
+
// Core framework only - ~6KB minified
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
#### AttrPlugin
|
|
397
|
+
|
|
398
|
+
Advanced attribute handling for ARIA, data attributes, boolean properties, and dynamic property detection:
|
|
399
|
+
|
|
400
|
+
```javascript
|
|
401
|
+
import Eleva from 'eleva';
|
|
402
|
+
import { Attr } from 'eleva/plugins';
|
|
403
|
+
|
|
404
|
+
const app = new Eleva("myApp");
|
|
405
|
+
app.use(Attr, {
|
|
406
|
+
enableAria: true, // ARIA attribute handling
|
|
407
|
+
enableData: true, // Data attribute management
|
|
408
|
+
enableBoolean: true, // Boolean attribute processing
|
|
409
|
+
enableDynamic: true // Dynamic property detection
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
// Use advanced attributes in components
|
|
413
|
+
app.component("myComponent", {
|
|
414
|
+
template: (ctx) => `
|
|
415
|
+
<button
|
|
416
|
+
aria-expanded="${ctx.isExpanded.value}"
|
|
417
|
+
data-user-id="${ctx.userId.value}"
|
|
418
|
+
disabled="${ctx.isLoading.value}"
|
|
419
|
+
class="btn ${ctx.variant.value}"
|
|
420
|
+
>
|
|
421
|
+
${ctx.text.value}
|
|
422
|
+
</button>
|
|
423
|
+
`
|
|
424
|
+
});
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
#### RouterPlugin
|
|
428
|
+
|
|
429
|
+
๐ **Advanced client-side routing** with multiple modes, navigation guards, reactive state, and component resolution:
|
|
430
|
+
|
|
431
|
+
```javascript
|
|
432
|
+
import Eleva from 'eleva';
|
|
433
|
+
import { Router } from 'eleva/plugins';
|
|
434
|
+
|
|
435
|
+
const app = new Eleva("myApp");
|
|
436
|
+
|
|
437
|
+
// Define components
|
|
438
|
+
const HomePage = { template: () => `<h1>Home</h1>` };
|
|
439
|
+
const AboutPage = { template: () => `<h1>About</h1>` };
|
|
440
|
+
const UserPage = {
|
|
441
|
+
template: (ctx) => `<h1>User: ${ctx.router.params.id}</h1>`
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
// Install router with advanced configuration
|
|
445
|
+
const router = app.use(Router, {
|
|
446
|
+
mount: '#app', // Mount element selector
|
|
447
|
+
mode: 'hash', // 'hash', 'history', or 'query'
|
|
448
|
+
routes: [
|
|
449
|
+
{
|
|
450
|
+
path: '/',
|
|
451
|
+
component: HomePage,
|
|
452
|
+
meta: { title: 'Home' }
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
path: '/about',
|
|
456
|
+
component: AboutPage,
|
|
457
|
+
beforeEnter: (to, from) => {
|
|
458
|
+
// Navigation guard
|
|
459
|
+
return true;
|
|
460
|
+
}
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
path: '/users/:id',
|
|
464
|
+
component: UserPage,
|
|
465
|
+
afterEnter: (to, from) => {
|
|
466
|
+
// Lifecycle hook
|
|
467
|
+
console.log('User page entered');
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
],
|
|
471
|
+
onBeforeEach: (to, from) => {
|
|
472
|
+
// Global navigation guard
|
|
473
|
+
return true;
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
// Access reactive router state
|
|
478
|
+
router.currentRoute.subscribe(route => {
|
|
479
|
+
console.log('Route changed:', route);
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
// Programmatic navigation
|
|
483
|
+
router.navigate('/users/123', { replace: true });
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
**Bundle Sizes:**
|
|
487
|
+
- Core framework only: ~6KB (minified)
|
|
488
|
+
- Core + AttrPlugin: ~8.5KB (minified)
|
|
489
|
+
- Core + RouterPlugin: ~9KB (minified)
|
|
490
|
+
- Core + Both plugins: ~11KB (minified)
|
|
491
|
+
|
|
492
|
+
**Available Plugin Formats:**
|
|
493
|
+
|
|
494
|
+
**For Bundlers (Tree-Shaking Supported):**
|
|
495
|
+
- ESM: `import { Attr, Router } from 'eleva/plugins'`
|
|
496
|
+
- CJS: `const { Attr, Router } = require('eleva/plugins')`
|
|
497
|
+
|
|
498
|
+
**For CDN (Individual Plugins - Smaller Bundle Size):**
|
|
499
|
+
- UMD: `<script src="https://unpkg.com/eleva@latest/dist/eleva.umd.min.js"></script>`
|
|
500
|
+
- UMD: `<script src="https://unpkg.com/eleva@latest/dist/plugins/attr.umd.min.js"></script>`
|
|
501
|
+
- UMD: `<script src="https://unpkg.com/eleva@latest/dist/plugins/router.umd.min.js"></script>`
|
|
502
|
+
|
|
503
|
+
**Individual Plugin Imports (Best for Tree-Shaking):**
|
|
504
|
+
- ESM: `import { Attr } from 'eleva/plugins/attr'`
|
|
505
|
+
- ESM: `import { Router } from 'eleva/plugins/router'`
|
|
506
|
+
- CJS: `const { Attr } = require('eleva/plugins/attr')`
|
|
507
|
+
- CJS: `const { Router } = require('eleva/plugins/router')`
|
|
508
|
+
|
|
376
509
|
For detailed API documentation, please check the [docs](docs/index.md) folder.
|
|
377
510
|
|
|
378
511
|
---
|