eleva 1.0.0-rc.5 โ 1.0.0-rc.7
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 -6
- package/dist/eleva-plugins.cjs.js +861 -29
- package/dist/eleva-plugins.cjs.js.map +1 -1
- package/dist/eleva-plugins.esm.js +861 -30
- package/dist/eleva-plugins.esm.js.map +1 -1
- package/dist/eleva-plugins.umd.js +861 -29
- package/dist/eleva-plugins.umd.js.map +1 -1
- package/dist/eleva-plugins.umd.min.js +2 -2
- package/dist/eleva-plugins.umd.min.js.map +1 -1
- package/dist/eleva.cjs.js +31 -25
- package/dist/eleva.cjs.js.map +1 -1
- package/dist/eleva.esm.js +31 -25
- package/dist/eleva.esm.js.map +1 -1
- package/dist/eleva.umd.js +31 -25
- 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 +2 -2
- package/dist/plugins/attr.umd.js.map +1 -1
- package/dist/plugins/attr.umd.min.js +1 -1
- package/dist/plugins/attr.umd.min.js.map +1 -1
- package/dist/plugins/props.umd.js +235 -2
- package/dist/plugins/props.umd.js.map +1 -1
- package/dist/plugins/props.umd.min.js +2 -2
- package/dist/plugins/props.umd.min.js.map +1 -1
- package/dist/plugins/router.umd.js +22 -25
- package/dist/plugins/router.umd.js.map +1 -1
- package/dist/plugins/router.umd.min.js +1 -1
- package/dist/plugins/router.umd.min.js.map +1 -1
- package/dist/plugins/store.umd.js +632 -0
- package/dist/plugins/store.umd.js.map +1 -0
- package/dist/plugins/store.umd.min.js +3 -0
- package/dist/plugins/store.umd.min.js.map +1 -0
- package/package.json +4 -4
- package/src/plugins/Props.js +206 -1
- package/src/plugins/Store.js +741 -0
- package/src/plugins/index.js +6 -1
- package/types/plugins/Props.d.ts.map +1 -1
- package/types/plugins/Store.d.ts +86 -0
- package/types/plugins/Store.d.ts.map +1 -0
- package/types/plugins/index.d.ts +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.6` - 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.6`
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
|
|
@@ -78,6 +78,7 @@ Welcome to Eleva! This is my humble, experimental playground for a fresh approac
|
|
|
78
78
|
- [Core Framework Only (Lightweight)](#core-framework-only-lightweight)
|
|
79
79
|
- [AttrPlugin](#attrplugin)
|
|
80
80
|
- [RouterPlugin](#routerplugin)
|
|
81
|
+
- [StorePlugin](#storeplugin)
|
|
81
82
|
- [Development](#development)
|
|
82
83
|
- [Testing](#testing)
|
|
83
84
|
- [Contributing](#contributing)
|
|
@@ -140,7 +141,7 @@ This unique, developer-first approach makes Eleva a standout choice for building
|
|
|
140
141
|
- **๐ Lifecycle Hooks:** Complete lifecycle management with before/after mount and update hooks
|
|
141
142
|
- **๐งน Automatic Cleanup:** Proper cleanup of resources, watchers, and child components on unmount
|
|
142
143
|
- **๐ Plugin System:** Extensible architecture with a simple plugin API
|
|
143
|
-
- **๐ฏ Built-in Plugins:** AttrPlugin for advanced attributes
|
|
144
|
+
- **๐ฏ Built-in Plugins:** AttrPlugin for advanced attributes, RouterPlugin for client-side routing, and StorePlugin for reactive state management
|
|
144
145
|
- **๐ฆ UMD & ES Module Builds:** Supports modern build tools and browser environments
|
|
145
146
|
- **๐ค Friendly API:** A gentle learning curve for both beginners and seasoned developers
|
|
146
147
|
- **๐ Tiny Footprint & TypeScript Support:** Approximately ~6 KB minified with built-in TypeScript declarations
|
|
@@ -159,6 +160,7 @@ Eleva is ideal for developers seeking a lightweight, flexible, and high-performa
|
|
|
159
160
|
- **๐ Extensible:** Easily add features like routing or state management through plugins.
|
|
160
161
|
- **๐ Built-in Routing:** Advanced client-side routing with navigation guards and reactive state via RouterPlugin.
|
|
161
162
|
- **๐ฏ Advanced Attributes:** Sophisticated attribute handling with ARIA support via AttrPlugin.
|
|
163
|
+
- **๐ช Reactive State Management:** Centralized, reactive data store with persistence and namespacing via StorePlugin.
|
|
162
164
|
- **๐ฆ Module Format Flexibility:** Choose from ESM, CommonJS, or UMD formats based on your project's needs.
|
|
163
165
|
|
|
164
166
|
---
|
|
@@ -483,28 +485,155 @@ router.currentRoute.subscribe(route => {
|
|
|
483
485
|
router.navigate('/users/123', { replace: true });
|
|
484
486
|
```
|
|
485
487
|
|
|
488
|
+
#### StorePlugin
|
|
489
|
+
|
|
490
|
+
๐ช **Reactive state management** with centralized data store, persistence, namespacing, and cross-component reactive updates:
|
|
491
|
+
|
|
492
|
+
```javascript
|
|
493
|
+
import Eleva from 'eleva';
|
|
494
|
+
import { Store } from 'eleva/plugins';
|
|
495
|
+
|
|
496
|
+
const app = new Eleva("myApp");
|
|
497
|
+
|
|
498
|
+
// Install store with configuration
|
|
499
|
+
app.use(Store, {
|
|
500
|
+
state: {
|
|
501
|
+
theme: "light",
|
|
502
|
+
counter: 0,
|
|
503
|
+
user: {
|
|
504
|
+
name: "John Doe",
|
|
505
|
+
email: "john@example.com"
|
|
506
|
+
}
|
|
507
|
+
},
|
|
508
|
+
actions: {
|
|
509
|
+
increment: (state) => state.counter.value++,
|
|
510
|
+
decrement: (state) => state.counter.value--,
|
|
511
|
+
toggleTheme: (state) => {
|
|
512
|
+
state.theme.value = state.theme.value === "light" ? "dark" : "light";
|
|
513
|
+
},
|
|
514
|
+
updateUser: (state, updates) => {
|
|
515
|
+
state.user.value = { ...state.user.value, ...updates };
|
|
516
|
+
}
|
|
517
|
+
},
|
|
518
|
+
// Optional: Namespaced modules
|
|
519
|
+
namespaces: {
|
|
520
|
+
auth: {
|
|
521
|
+
state: { token: null, isLoggedIn: false },
|
|
522
|
+
actions: {
|
|
523
|
+
login: (state, token) => {
|
|
524
|
+
state.auth.token.value = token;
|
|
525
|
+
state.auth.isLoggedIn.value = true;
|
|
526
|
+
},
|
|
527
|
+
logout: (state) => {
|
|
528
|
+
state.auth.token.value = null;
|
|
529
|
+
state.auth.isLoggedIn.value = false;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
},
|
|
534
|
+
// Optional: State persistence
|
|
535
|
+
persistence: {
|
|
536
|
+
enabled: true,
|
|
537
|
+
key: "myApp-store",
|
|
538
|
+
storage: "localStorage", // or "sessionStorage"
|
|
539
|
+
include: ["theme", "user"] // Only persist specific keys
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
// Use store in components
|
|
544
|
+
app.component("Counter", {
|
|
545
|
+
setup({ store }) {
|
|
546
|
+
return {
|
|
547
|
+
count: store.state.counter,
|
|
548
|
+
theme: store.state.theme,
|
|
549
|
+
increment: () => store.dispatch("increment"),
|
|
550
|
+
decrement: () => store.dispatch("decrement")
|
|
551
|
+
};
|
|
552
|
+
},
|
|
553
|
+
template: (ctx) => `
|
|
554
|
+
<div class="${ctx.theme.value}">
|
|
555
|
+
<h3>Counter: ${ctx.count.value}</h3>
|
|
556
|
+
<button @click="decrement">-</button>
|
|
557
|
+
<button @click="increment">+</button>
|
|
558
|
+
</div>
|
|
559
|
+
`
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
// Create state and actions at runtime
|
|
563
|
+
app.component("TodoManager", {
|
|
564
|
+
setup({ store }) {
|
|
565
|
+
// Register new module dynamically
|
|
566
|
+
store.registerModule("todos", {
|
|
567
|
+
state: { items: [], filter: "all" },
|
|
568
|
+
actions: {
|
|
569
|
+
addTodo: (state, text) => {
|
|
570
|
+
state.todos.items.value.push({
|
|
571
|
+
id: Date.now(),
|
|
572
|
+
text,
|
|
573
|
+
completed: false
|
|
574
|
+
});
|
|
575
|
+
},
|
|
576
|
+
toggleTodo: (state, id) => {
|
|
577
|
+
const todo = state.todos.items.value.find(t => t.id === id);
|
|
578
|
+
if (todo) todo.completed = !todo.completed;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
// Create individual state properties
|
|
584
|
+
const notification = store.createState("notification", null);
|
|
585
|
+
|
|
586
|
+
// Create individual actions
|
|
587
|
+
store.createAction("showNotification", (state, message) => {
|
|
588
|
+
state.notification.value = message;
|
|
589
|
+
setTimeout(() => state.notification.value = null, 3000);
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
return {
|
|
593
|
+
todos: store.state.todos.items,
|
|
594
|
+
notification,
|
|
595
|
+
addTodo: (text) => store.dispatch("todos.addTodo", text),
|
|
596
|
+
notify: (msg) => store.dispatch("showNotification", msg)
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
// Subscribe to store changes
|
|
602
|
+
const unsubscribe = app.store.subscribe((mutation, state) => {
|
|
603
|
+
console.log('Store updated:', mutation.type, state);
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
// Access store globally
|
|
607
|
+
console.log(app.store.getState()); // Get current state values
|
|
608
|
+
app.dispatch("increment"); // Dispatch actions globally
|
|
609
|
+
```
|
|
610
|
+
|
|
486
611
|
**Bundle Sizes:**
|
|
487
612
|
- Core framework only: ~6KB (minified)
|
|
488
613
|
- Core + AttrPlugin: ~8.5KB (minified)
|
|
489
614
|
- Core + RouterPlugin: ~9KB (minified)
|
|
490
|
-
- Core +
|
|
615
|
+
- Core + StorePlugin: ~9.5KB (minified)
|
|
616
|
+
- Core + All plugins: ~13KB (minified)
|
|
491
617
|
|
|
492
618
|
**Available Plugin Formats:**
|
|
493
619
|
|
|
494
620
|
**For Bundlers (Tree-Shaking Supported):**
|
|
495
|
-
- ESM: `import { Attr, Router } from 'eleva/plugins'`
|
|
496
|
-
- CJS: `const { Attr, Router } = require('eleva/plugins')`
|
|
621
|
+
- ESM: `import { Attr, Router, Store } from 'eleva/plugins'`
|
|
622
|
+
- CJS: `const { Attr, Router, Store } = require('eleva/plugins')`
|
|
497
623
|
|
|
498
624
|
**For CDN (Individual Plugins - Smaller Bundle Size):**
|
|
499
625
|
- UMD: `<script src="https://unpkg.com/eleva@latest/dist/eleva.umd.min.js"></script>`
|
|
500
626
|
- UMD: `<script src="https://unpkg.com/eleva@latest/dist/plugins/attr.umd.min.js"></script>`
|
|
501
627
|
- UMD: `<script src="https://unpkg.com/eleva@latest/dist/plugins/router.umd.min.js"></script>`
|
|
628
|
+
- UMD: `<script src="https://unpkg.com/eleva@latest/dist/plugins/store.umd.min.js"></script>`
|
|
502
629
|
|
|
503
630
|
**Individual Plugin Imports (Best for Tree-Shaking):**
|
|
504
631
|
- ESM: `import { Attr } from 'eleva/plugins/attr'`
|
|
505
632
|
- ESM: `import { Router } from 'eleva/plugins/router'`
|
|
633
|
+
- ESM: `import { Store } from 'eleva/plugins/store'`
|
|
506
634
|
- CJS: `const { Attr } = require('eleva/plugins/attr')`
|
|
507
635
|
- CJS: `const { Router } = require('eleva/plugins/router')`
|
|
636
|
+
- CJS: `const { Store } = require('eleva/plugins/store')`
|
|
508
637
|
|
|
509
638
|
For detailed API documentation, please check the [docs](docs/index.md) folder.
|
|
510
639
|
|