eleva 1.0.0-alpha → 1.0.0-rc.2
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 +1 -1
- package/README.md +186 -137
- package/dist/eleva.cjs.js +978 -0
- package/dist/eleva.cjs.js.map +1 -0
- package/dist/eleva.d.ts +521 -79
- package/dist/eleva.esm.js +751 -265
- package/dist/eleva.esm.js.map +1 -1
- package/dist/eleva.umd.js +751 -265
- package/dist/eleva.umd.js.map +1 -1
- package/dist/eleva.umd.min.js +3 -0
- package/dist/eleva.umd.min.js.map +1 -0
- package/package.json +188 -62
- package/src/core/Eleva.js +388 -140
- package/src/modules/Emitter.js +64 -18
- package/src/modules/Renderer.js +257 -85
- package/src/modules/Signal.js +55 -13
- package/src/modules/TemplateEngine.js +45 -27
- package/types/core/Eleva.d.ts +317 -48
- package/types/core/Eleva.d.ts.map +1 -1
- package/types/modules/Emitter.d.ts +51 -19
- package/types/modules/Emitter.d.ts.map +1 -1
- package/types/modules/Renderer.d.ts +86 -12
- package/types/modules/Renderer.d.ts.map +1 -1
- package/types/modules/Signal.d.ts +48 -16
- package/types/modules/Signal.d.ts.map +1 -1
- package/types/modules/TemplateEngine.d.ts +38 -14
- package/types/modules/TemplateEngine.d.ts.map +1 -1
- package/dist/eleva.min.js +0 -2
- package/dist/eleva.min.js.map +0 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,24 +1,58 @@
|
|
|
1
|
-
#
|
|
1
|
+
# eleva.js 🚀
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
_Built with love for native JavaScript—because sometimes, less really is more!_ 😊
|
|
3
|
+
Pure JavaScript, Pure Performance, Simply Elegant.
|
|
5
4
|
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://github.com/TarekRaafat/eleva)
|
|
6
7
|
[](https://www.npmjs.com/package/eleva)
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+

|
|
9
|
+

|
|
10
|
+
[](https://codecov.io/gh/TarekRaafat/eleva)
|
|
11
|
+
[](https://bundlephobia.com/package/eleva@latest)
|
|
12
|
+
[](https://bundlephobia.com/package/eleva@latest)
|
|
13
|
+
[](https://www.jsdelivr.com/package/npm/eleva)
|
|
14
|
+
[](https://canonical.com)
|
|
15
|
+
|
|
16
|
+
<br>
|
|
17
|
+
|
|
18
|
+
<p align="center">
|
|
19
|
+
<a href="https://tarekraafat.github.io/eleva/"><img src="./docs/imgs/eleva.js Full Logo.png" alt="eleva.js Full Logo" width="50%"></a>
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
<p align="center">
|
|
23
|
+
<a href="https://canonical.com" target="_blank" rel="noopener">
|
|
24
|
+
<img src="https://raw.githubusercontent.com/SebastJava/Ubuntu-logo/649d55eca403302fb06281d9dd94798bb0568e8d/logo-v2025-plain-450x708.svg" alt="Canonical Logo" width="80"/>
|
|
25
|
+
</a>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
<p align="center">
|
|
29
|
+
<em>Eleva.js is proudly supported by Canonical - the company behind Ubuntu.</em>
|
|
30
|
+
</p>
|
|
31
|
+
|
|
32
|
+
<p align="center">
|
|
33
|
+
<a href="https://www.producthunt.com/posts/eleva?embed=true&utm_source=badge-featured&utm_medium=badge&utm_souce=badge-eleva" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=938663&theme=light&t=1741247713068" alt="eleva.js - A minimalist, pure vanilla javascript frontend framework. | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
|
|
34
|
+
</p>
|
|
35
|
+
|
|
36
|
+
<br>
|
|
37
|
+
<br>
|
|
38
|
+
<br>
|
|
39
|
+
|
|
40
|
+
**A minimalist, lightweight, pure vanilla JavaScript frontend runtime framework.**
|
|
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
|
+
|
|
43
|
+
> **Stability Notice**: This is `v1.0.0-rc.2` - The core functionality is stable. Seeking community feedback before the final v1.0.0 release.
|
|
9
44
|
|
|
10
|
-
|
|
11
|
-
> Not recommended for production use yet. Follow the [versioning guide](#versioning) for updates.
|
|
45
|
+
**Version:** `1.0.0-rc.2`
|
|
12
46
|
|
|
13
|
-
**Version:** `1.0.0-alpha`
|
|
14
47
|
|
|
15
|
-
|
|
48
|
+
|
|
49
|
+
Welcome to Eleva! This is my humble, experimental playground for a fresh approach to frontend development. Eleva was born out of my genuine passion for pure vanilla JavaScript-no frameworks, no bloat, just the power of native code. I hope you'll have fun exploring, testing, and contributing to make Eleva even better. 🚀
|
|
16
50
|
|
|
17
51
|
---
|
|
18
52
|
|
|
19
53
|
## Table of Contents
|
|
20
54
|
|
|
21
|
-
- [
|
|
55
|
+
- [eleva.js 🚀](#elevajs-)
|
|
22
56
|
- [Table of Contents](#table-of-contents)
|
|
23
57
|
- [Introduction](#introduction)
|
|
24
58
|
- [Design Philosophy](#design-philosophy)
|
|
@@ -50,50 +84,43 @@ Welcome to Eleva! This is my humble, experimental playground for a fresh approac
|
|
|
50
84
|
|
|
51
85
|
## Introduction
|
|
52
86
|
|
|
53
|
-
Eleva is a lightweight, no-nonsense runtime framework for frontend applications. Built with love for **pure vanilla JavaScript**, Eleva lets you create highly modular and scalable applications without the overhead of large frameworks. I built Eleva to prove that you don't need
|
|
87
|
+
Eleva is a lightweight, no-nonsense runtime framework for frontend applications. Built with love for **pure vanilla JavaScript**, Eleva features a minimal core with essential functionality that can be extended through a powerful plugin system. This approach lets you create highly modular and scalable applications without the overhead of large frameworks. I built Eleva to prove that you don't need heavy frameworks or libraries to build amazing user interfaces-sometimes, the simplest approach is the most powerful.
|
|
54
88
|
|
|
55
89
|
**My Inspiration:**
|
|
56
|
-
The idea
|
|
90
|
+
The idea behind Eleva comes from a deep appreciation for native JavaScript. I wanted to create a tool that stays true to the language without introducing new syntax or complexity, making it easy to integrate into your projects.
|
|
57
91
|
|
|
58
92
|
**Core Principles:**
|
|
59
93
|
|
|
60
|
-
- **🌱 Minimalism:** Only the
|
|
61
|
-
- **🔌 Extensibility:**
|
|
94
|
+
- **🌱 Minimalism:** Only essential features in the core, keeping the framework lean and focused.
|
|
95
|
+
- **🔌 Extensibility:** Extend functionality by plugging in your own ideas, such as custom state management, routing, and more.
|
|
62
96
|
- **🚀 Performance:** Fast, efficient, and designed with modern browsers in mind.
|
|
63
|
-
- **🍦 Pure Vanilla:** No dependencies, no magic
|
|
97
|
+
- **🍦 Pure Vanilla:** No dependencies, no magic-just plain JavaScript.
|
|
64
98
|
|
|
65
99
|
---
|
|
66
100
|
|
|
67
101
|
## Design Philosophy
|
|
68
102
|
|
|
69
|
-
**Eleva is an unopinionated
|
|
103
|
+
**Eleva is an unopinionated framework with a minimal core philosophy.**
|
|
70
104
|
|
|
71
|
-
Unlike
|
|
105
|
+
Unlike monolithic frameworks that include everything out-of-the-box, Eleva intentionally provides only essential features in its core, relying on a powerful plugin system for extensibility. This architectural choice means:
|
|
72
106
|
|
|
73
|
-
- **🔄 Flexibility:**
|
|
74
|
-
- **🎯 Native JavaScript:**
|
|
75
|
-
- **⚙️ Configurability:**
|
|
76
|
-
- **🆓 Freedom:**
|
|
107
|
+
- **🔄 Flexibility:** Architect your application your way-no rigid structure required.
|
|
108
|
+
- **🎯 Native JavaScript:** Built using pure vanilla JavaScript, Eleva integrates seamlessly with your existing code without unfamiliar syntax.
|
|
109
|
+
- **⚙️ Configurability:** Extend Eleva's functionality with a simple API and optional plugins.
|
|
110
|
+
- **🆓 Freedom:** Decide the best way to implement features without unnecessary constraints.
|
|
77
111
|
|
|
78
|
-
This unopinionated approach makes Eleva versatile and ideal for developers who
|
|
112
|
+
This unopinionated approach makes Eleva versatile and ideal for developers who want full control over their application's design.
|
|
79
113
|
|
|
80
114
|
---
|
|
81
115
|
|
|
82
116
|
## Handcrafted & Developer-Centric Design
|
|
83
117
|
|
|
84
|
-
Eleva is built with
|
|
85
|
-
|
|
86
|
-
- **🎨 Craftsmanship:**
|
|
87
|
-
Every line of code in Eleva is written with care, ensuring that the library remains lightweight, efficient, and easy to understand.
|
|
88
|
-
|
|
89
|
-
- **🛠️ Developer-Centric:**
|
|
90
|
-
Eleva is designed for you—the developer. Its intuitive API and minimalistic core mean you spend less time wrestling with the framework and more time building your application.
|
|
91
|
-
|
|
92
|
-
- **🌟 Innovative & Fresh:**
|
|
93
|
-
By sticking to pure vanilla JavaScript and avoiding unnecessary abstractions, Eleva offers a refreshing alternative to the complex and opinionated frameworks out there.
|
|
118
|
+
Eleva is built with meticulous attention to detail and a deep passion for pure vanilla JavaScript. Every aspect of its design and architecture is handcrafted with the developer in mind. This makes Eleva not only innovative but also a solid foundation for your projects.
|
|
94
119
|
|
|
95
|
-
-
|
|
96
|
-
|
|
120
|
+
- **🎨 Craftsmanship:** Every line of code is written with care, keeping the framework lightweight, efficient, and easy to understand.
|
|
121
|
+
- **🛠️ Developer-Centric:** Its intuitive API and minimal core mean you spend less time wrestling with the framework and more time building your application.
|
|
122
|
+
- **🌟 Innovative & Fresh:** Stick to pure vanilla JavaScript and avoid unnecessary abstractions.
|
|
123
|
+
- **🏗️ Solid & Reliable:** Focused on performance and modularity, Eleva scales with your project's needs.
|
|
97
124
|
|
|
98
125
|
This unique, developer-first approach makes Eleva a standout choice for building high-performance frontend applications without compromising on simplicity or control.
|
|
99
126
|
|
|
@@ -101,40 +128,31 @@ This unique, developer-first approach makes Eleva a standout choice for building
|
|
|
101
128
|
|
|
102
129
|
## Features
|
|
103
130
|
|
|
104
|
-
- **🧩 Component-Based Architecture:** Create reusable UI components
|
|
105
|
-
- **⚡ Signal-Based Reactivity:** Fine-grained reactivity that updates only what
|
|
106
|
-
- **🔔 Event Handling:** Built-in event emitter for robust inter-component communication
|
|
107
|
-
- **📝 Template Parsing:** Secure and dynamic interpolation with a custom TemplateEngine
|
|
108
|
-
- **🔄 DOM Diffing & Patching:** High-performance updates without a virtual DOM
|
|
109
|
-
-
|
|
110
|
-
-
|
|
111
|
-
-
|
|
131
|
+
- **🧩 Component-Based Architecture:** Create reusable UI components with a rich context API
|
|
132
|
+
- **⚡ Signal-Based Reactivity:** Fine-grained reactivity that updates only what's needed
|
|
133
|
+
- **🔔 Event Handling:** Built-in event emitter for robust inter-component communication
|
|
134
|
+
- **📝 Template Parsing:** Secure and dynamic interpolation with a custom TemplateEngine
|
|
135
|
+
- **🔄 DOM Diffing & Patching:** High-performance updates without a virtual DOM
|
|
136
|
+
- **🔄 Lifecycle Hooks:** Complete lifecycle management with before/after mount and update hooks
|
|
137
|
+
- **🧹 Automatic Cleanup:** Proper cleanup of resources, watchers, and child components on unmount
|
|
138
|
+
- **🔌 Plugin System:** Extensible architecture with a simple plugin API
|
|
139
|
+
- **📦 UMD & ES Module Builds:** Supports modern build tools and browser environments
|
|
140
|
+
- **🤝 Friendly API:** A gentle learning curve for both beginners and seasoned developers
|
|
141
|
+
- **💎 Tiny Footprint & TypeScript Support:** Approximately ~6 KB minified with built-in TypeScript declarations
|
|
112
142
|
|
|
113
143
|
---
|
|
114
144
|
|
|
115
145
|
## When to Use Eleva
|
|
116
146
|
|
|
117
|
-
Eleva is
|
|
147
|
+
Eleva is ideal for developers seeking a lightweight, flexible, and high-performance solution for building frontend applications. Here are some scenarios where Eleva shines:
|
|
118
148
|
|
|
119
|
-
- **🚀 Small to Medium Projects:**
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
-
|
|
126
|
-
Eleva is unopinionated, meaning it doesn't force you into a rigid structure. You can architect your application your way while enjoying a straightforward API and a flexible plugin system.
|
|
127
|
-
|
|
128
|
-
- **🎯 Developer-Friendly & Native JavaScript:**
|
|
129
|
-
If you prefer working with pure vanilla JavaScript without the need to learn new syntax or complex abstractions, Eleva is built with you in mind. Plus, it comes with built-in TypeScript declarations for strong type support.
|
|
130
|
-
|
|
131
|
-
- **🧪 Rapid Prototyping & Experimentation:**
|
|
132
|
-
Eleva's simplicity and ease of integration make it a great choice for prototyping ideas quickly. Its modular architecture means you can start small and extend the functionality as your project evolves.
|
|
133
|
-
|
|
134
|
-
- **🔌 Extensibility through Plugins:**
|
|
135
|
-
With a robust plugin system, Eleva can be easily extended to include features like routing, state management, or custom behaviors, making it suitable for both simple and complex applications.
|
|
136
|
-
|
|
137
|
-
In short, if you're looking for a solid, developer-centric framework that provides high performance, simplicity, and the freedom to build your application your way, Eleva is an excellent choice.
|
|
149
|
+
- **🚀 Small to Medium Projects:** Perfect for web apps or websites that don't require the overhead of a full-fledged framework.
|
|
150
|
+
- **⚡ Performance-Critical Applications:** Optimized reactivity and DOM diffing ensure smooth performance without bloat.
|
|
151
|
+
- **🔄 Unopinionated & Flexible:** Architect your application your way with a straightforward API and plugin system.
|
|
152
|
+
- **🎯 Developer-Friendly:** Stick to pure vanilla JavaScript with familiar syntax and built-in TypeScript support.
|
|
153
|
+
- **🧪 Rapid Prototyping:** Quickly prototype ideas with a minimal and extendable framework.
|
|
154
|
+
- **🔌 Extensible:** Easily add features like routing or state management through plugins.
|
|
155
|
+
- **📦 Module Format Flexibility:** Choose from ESM, CommonJS, or UMD formats based on your project's needs.
|
|
138
156
|
|
|
139
157
|
---
|
|
140
158
|
|
|
@@ -142,80 +160,86 @@ In short, if you're looking for a solid, developer-centric framework that provid
|
|
|
142
160
|
|
|
143
161
|
I believe in clear versioning that reflects the maturity of the project:
|
|
144
162
|
|
|
145
|
-
- **Pre-release Versions (Alpha/Beta):** Early versions like `1.
|
|
146
|
-
- **Semantic Versioning:** Once
|
|
147
|
-
- **Fresh Start:**
|
|
163
|
+
- **Pre-release Versions (Alpha/Beta):** Early versions like `1.2.0-alpha` indicate the API is still evolving. Expect frequent updates and share your feedback!
|
|
164
|
+
- **Semantic Versioning:** Once stable, I'll follow semantic versioning strictly to clearly communicate any breaking changes.
|
|
165
|
+
- **Fresh Start:** This release (`1.2.0-alpha`) marks a significant update with enhanced inline documentation, improved JSDoc annotations, and a refined mounting context that now includes an `emitter` property.
|
|
148
166
|
|
|
149
167
|
---
|
|
150
168
|
|
|
151
169
|
## Version Guide
|
|
152
170
|
|
|
153
|
-
I follow [Semantic Versioning (SemVer)](https://semver.org/)
|
|
154
|
-
|
|
155
|
-
- **🔢 Major Version:**
|
|
156
|
-
A change in the first digit (e.g., from `1.0.0` to `2.0.0`) indicates breaking changes or a major overhaul of the framework.
|
|
157
|
-
- **🔢 Minor Version:**
|
|
158
|
-
A change in the second digit (e.g., from `1.0.0` to `1.1.0`) signifies the addition of new features in a backward-compatible manner.
|
|
159
|
-
- **🔢 Patch Version:**
|
|
160
|
-
A change in the third digit (e.g., from `1.0.0` to `1.0.1`) reflects backward-compatible bug fixes and minor improvements.
|
|
161
|
-
- **📌 Pre-release Identifiers:**
|
|
162
|
-
Suffixes like `-alpha`, `-beta`, or `-rc` indicate that the release is not yet stable. For example, `1.0.0-alpha` means this is an experimental version of the upcoming stable `1.0.0` release.
|
|
171
|
+
I follow [Semantic Versioning (SemVer)](https://semver.org/):
|
|
163
172
|
|
|
164
|
-
|
|
173
|
+
- **🔢 Major Version:** Breaking changes or major overhauls (e.g., from `1.0.0` to `2.0.0`).
|
|
174
|
+
- **🔢 Minor Version:** New features in a backward-compatible manner (e.g., from `1.1.0` to `1.2.0`).
|
|
175
|
+
- **🔢 Patch Version:** Backward-compatible bug fixes and minor improvements (e.g., `1.0.1`).
|
|
176
|
+
- **📌 Pre-release Identifiers:** Suffixes like `-alpha`, `-beta`, or `-rc` denote unstable releases (e.g., `1.2.0-alpha`).
|
|
165
177
|
|
|
166
178
|
---
|
|
167
179
|
|
|
168
180
|
## Performance
|
|
169
181
|
|
|
170
|
-
Eleva is crafted
|
|
182
|
+
Eleva is crafted for performance:
|
|
171
183
|
|
|
172
|
-
- **Lightweight:**
|
|
173
|
-
- **Efficient Reactivity:** Signal-based updates ensure only
|
|
174
|
-
- **Optimized Diffing:**
|
|
175
|
-
- **No Bloat:** Pure vanilla JavaScript
|
|
184
|
+
- **Lightweight:** Approximately ~6 KB minified and ~2 KB gzipped.
|
|
185
|
+
- **Efficient Reactivity:** Signal-based updates ensure only necessary DOM parts are updated.
|
|
186
|
+
- **Optimized Diffing:** Renderer efficiently patches changes without the overhead of a virtual DOM.
|
|
187
|
+
- **No Bloat:** Pure vanilla JavaScript with zero dependencies keeps your project nimble.
|
|
188
|
+
- **Tree-Shakable:** ESM format allows bundlers to eliminate unused code.
|
|
189
|
+
- **Format-Specific Optimizations:** Each module format is optimized for its target environment.
|
|
176
190
|
|
|
177
191
|
---
|
|
178
192
|
|
|
179
193
|
## Performance Benchmarks
|
|
180
194
|
|
|
181
|
-
|
|
195
|
+
Preliminary benchmarks illustrate Eleva's efficiency compared to popular frameworks:
|
|
182
196
|
|
|
183
|
-
| Framework
|
|
184
|
-
|
|
|
185
|
-
| **Eleva** |
|
|
186
|
-
| React
|
|
187
|
-
| Vue
|
|
188
|
-
| Angular
|
|
197
|
+
| **Framework** | **Bundle Size** (KB) | **Initial Load Time** (ms) | **DOM Update Speed** (s) | **Peak Memory Usage** (KB) | **Overall Performance Score** (lower is better) |
|
|
198
|
+
| ----------------------------- | -------------------- | -------------------------- | ------------------------ | -------------------------- | ----------------------------------------------- |
|
|
199
|
+
| **Eleva** (Direct DOM) | **2** | **0.05** | **0.002** | **0.25** | **0.58 (Best)** |
|
|
200
|
+
| **React** (Virtual DOM) | 4.1 | 5.34 | 0.020 | 0.25 | 9.71 |
|
|
201
|
+
| **Vue** (Reactive State) | 45 | 4.72 | 0.021 | 3.10 | 13.21 |
|
|
202
|
+
| **Angular** (Two-way Binding) | 62 | 5.26 | 0.021 | 0.25 | 16.88 (Slowest) |
|
|
189
203
|
|
|
190
|
-
|
|
204
|
+
Detailed [Benchmark Metrics Report](BENCHMARK.md)
|
|
205
|
+
|
|
206
|
+
> ⚠️ **Disclaimer:** Benchmarks are based on internal tests and may vary by project and environment.
|
|
191
207
|
|
|
192
208
|
---
|
|
193
209
|
|
|
194
210
|
## Eleva vs. Popular Frameworks
|
|
195
211
|
|
|
196
|
-
|
|
212
|
+
Eleva offers a refreshing alternative to frameworks like React, Vue, and Angular:
|
|
197
213
|
|
|
198
|
-
- **Simplicity:** No virtual DOM,
|
|
199
|
-
- **Modularity:** Easily extend
|
|
200
|
-
- **Size:**
|
|
201
|
-
- **Learning Curve:**
|
|
214
|
+
- **Simplicity:** No virtual DOM, JSX, or complex state management-just plain JavaScript.
|
|
215
|
+
- **Modularity:** Easily extend via plugins to suit your project's needs.
|
|
216
|
+
- **Size:** A fraction of the size of mainstream frameworks.
|
|
217
|
+
- **Learning Curve:** Familiar syntax and a clear API make it accessible to all developers.
|
|
202
218
|
|
|
203
|
-
|
|
219
|
+
_Note:_ Eleva isn't trying to replace these giants but provides a lightweight option when you want simplicity and speed. 🌟
|
|
204
220
|
|
|
205
221
|
---
|
|
206
222
|
|
|
207
223
|
## Installation
|
|
208
224
|
|
|
209
|
-
Eleva is available on npm.
|
|
225
|
+
Eleva is available on npm. Try it out and share your thoughts!
|
|
210
226
|
|
|
211
227
|
```bash
|
|
212
228
|
npm install eleva
|
|
213
229
|
```
|
|
214
230
|
|
|
215
|
-
Or include it directly
|
|
231
|
+
Or include it directly via CDN:
|
|
216
232
|
|
|
217
233
|
```html
|
|
218
|
-
|
|
234
|
+
<!-- jsDelivr (Recommended) -->
|
|
235
|
+
<script src="https://cdn.jsdelivr.net/npm/eleva"></script>
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
or
|
|
239
|
+
|
|
240
|
+
```html
|
|
241
|
+
<!-- unpkg -->
|
|
242
|
+
<script src="https://unpkg.com/eleva"></script>
|
|
219
243
|
```
|
|
220
244
|
|
|
221
245
|
---
|
|
@@ -226,33 +250,46 @@ Or include it directly in your HTML via CDN:
|
|
|
226
250
|
|
|
227
251
|
```js
|
|
228
252
|
// Import Eleva (using ES modules)
|
|
229
|
-
import
|
|
253
|
+
import Eleva from "eleva";
|
|
230
254
|
|
|
231
255
|
// Create a new Eleva instance
|
|
232
256
|
const app = new Eleva("MyApp");
|
|
233
257
|
|
|
234
258
|
// Define a component
|
|
235
259
|
app.component("HelloWorld", {
|
|
260
|
+
// The setup method is optional; if omitted, an empty state is used.
|
|
236
261
|
setup({ signal }) {
|
|
237
262
|
const count = signal(0);
|
|
238
|
-
return {
|
|
263
|
+
return {
|
|
264
|
+
count,
|
|
265
|
+
onMount: ({ container, context }) => {
|
|
266
|
+
console.log('Component mounted!');
|
|
267
|
+
}
|
|
268
|
+
};
|
|
239
269
|
},
|
|
240
270
|
template: ({ count }) => `
|
|
241
271
|
<div>
|
|
242
272
|
<h1>Hello, Eleva! 👋</h1>
|
|
243
|
-
<p>Count: ${count}</p>
|
|
244
|
-
<button @click="() => count++">Increment</button>
|
|
273
|
+
<p>Count: ${count.value}</p>
|
|
274
|
+
<button @click="() => count.value++">Increment</button>
|
|
245
275
|
</div>
|
|
246
|
-
|
|
276
|
+
`
|
|
247
277
|
});
|
|
248
278
|
|
|
249
|
-
// Mount the component
|
|
250
|
-
app.mount("
|
|
279
|
+
// Mount the component and handle the Promise
|
|
280
|
+
app.mount(document.getElementById("app"), "HelloWorld")
|
|
281
|
+
.then(instance => {
|
|
282
|
+
console.log("Component mounted:", instance);
|
|
283
|
+
// Later...
|
|
284
|
+
// instance.unmount();
|
|
285
|
+
});
|
|
251
286
|
```
|
|
252
287
|
|
|
288
|
+
Interactive Demo: [CodePen](https://codepen.io/tarekraafat/pen/GgRrxdY?editors=1010)
|
|
289
|
+
|
|
253
290
|
### UMD Example
|
|
254
291
|
|
|
255
|
-
Include Eleva via a script tag
|
|
292
|
+
Include Eleva via a script tag and use the global variable:
|
|
256
293
|
|
|
257
294
|
```html
|
|
258
295
|
<!DOCTYPE html>
|
|
@@ -263,7 +300,7 @@ Include Eleva via a script tag, and it will be available as a global variable:
|
|
|
263
300
|
</head>
|
|
264
301
|
<body>
|
|
265
302
|
<div id="app"></div>
|
|
266
|
-
<script src="https://
|
|
303
|
+
<script src="https://cdn.jsdelivr.net/npm/eleva"></script>
|
|
267
304
|
<script>
|
|
268
305
|
const app = new Eleva("MyApp");
|
|
269
306
|
app.component("HelloWorld", {
|
|
@@ -272,56 +309,58 @@ Include Eleva via a script tag, and it will be available as a global variable:
|
|
|
272
309
|
return { count };
|
|
273
310
|
},
|
|
274
311
|
template: ({ count }) => `
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
312
|
+
<div>
|
|
313
|
+
<h1>Hello, Eleva! 👋</h1>
|
|
314
|
+
<p>Count: ${count.value}</p>
|
|
315
|
+
<button @click="() => count.value++">Increment</button>
|
|
316
|
+
</div>
|
|
317
|
+
`,
|
|
281
318
|
});
|
|
282
|
-
app.mount("
|
|
319
|
+
app.mount(document.getElementById("app"), "HelloWorld");
|
|
283
320
|
</script>
|
|
284
321
|
</body>
|
|
285
322
|
</html>
|
|
286
323
|
```
|
|
287
324
|
|
|
325
|
+
Interactive Demo: [CodePen](https://codepen.io/tarekraafat/pen/jEOyzYN?editors=1010)
|
|
326
|
+
|
|
288
327
|
---
|
|
289
328
|
|
|
290
329
|
## API Reference
|
|
291
330
|
|
|
292
331
|
### TemplateEngine
|
|
293
332
|
|
|
294
|
-
- **`TemplateEngine.parse(template, data)`**
|
|
333
|
+
- **`TemplateEngine.parse(template, data)`**
|
|
295
334
|
Replaces `{{ expression }}` patterns in the template with evaluated values.
|
|
296
|
-
- **`TemplateEngine.evaluate(expr, data)`**
|
|
335
|
+
- **`TemplateEngine.evaluate(expr, data)`**
|
|
297
336
|
Safely evaluates JavaScript expressions within a given context.
|
|
298
337
|
|
|
299
338
|
### Signal
|
|
300
339
|
|
|
301
|
-
- **`new Signal(
|
|
340
|
+
- **`new Signal(initialValue)`**
|
|
302
341
|
Creates a reactive data holder.
|
|
303
|
-
- **`.value` (getter/setter)**
|
|
342
|
+
- **`.value` (getter/setter)**
|
|
304
343
|
Get or update the current value and trigger watchers.
|
|
305
|
-
- **`.watch(
|
|
344
|
+
- **`.watch(callback)`**
|
|
306
345
|
Registers a function to run when the value updates.
|
|
307
346
|
|
|
308
347
|
### Emitter
|
|
309
348
|
|
|
310
|
-
-
|
|
349
|
+
- **`new Emitter()`**
|
|
350
|
+
Creates an Emitter instance.
|
|
351
|
+
- **`.on(event, handler)`**
|
|
311
352
|
Listen to events.
|
|
312
|
-
- **`.off(event, handler)`**
|
|
353
|
+
- **`.off(event, handler)`**
|
|
313
354
|
Remove event listeners.
|
|
314
|
-
- **`.emit(event, ...args)`**
|
|
355
|
+
- **`.emit(event, ...args)`**
|
|
315
356
|
Trigger events with additional arguments.
|
|
316
357
|
|
|
317
358
|
### Renderer
|
|
318
359
|
|
|
319
|
-
- **`
|
|
320
|
-
|
|
321
|
-
-
|
|
322
|
-
|
|
323
|
-
- **`updateAttributes(oldEl, newEl)`**
|
|
324
|
-
Sync element attributes.
|
|
360
|
+
- **`new Renderer()`**
|
|
361
|
+
Creates a Renderer instance.
|
|
362
|
+
- **`.patchDOM(container, newHtml)`**:
|
|
363
|
+
Updates container content with the new HTML.
|
|
325
364
|
|
|
326
365
|
### Eleva (Core)
|
|
327
366
|
|
|
@@ -331,16 +370,16 @@ Include Eleva via a script tag, and it will be available as a global variable:
|
|
|
331
370
|
Install plugins.
|
|
332
371
|
- **`.component(name, definition)`**
|
|
333
372
|
Register a component.
|
|
334
|
-
- **`.mount(
|
|
373
|
+
- **`.mount(container, compName, props)`**
|
|
335
374
|
Mount a component to the DOM.
|
|
336
375
|
|
|
337
|
-
For detailed API documentation, please check the [docs](docs/) folder.
|
|
376
|
+
For detailed API documentation, please check the [docs](docs/index.md) folder.
|
|
338
377
|
|
|
339
378
|
---
|
|
340
379
|
|
|
341
380
|
## Development
|
|
342
381
|
|
|
343
|
-
I welcome developers to dive in and
|
|
382
|
+
I welcome developers to dive in and experiment with Eleva! Here's how to get started locally:
|
|
344
383
|
|
|
345
384
|
1. **Clone the Repository:**
|
|
346
385
|
|
|
@@ -361,7 +400,7 @@ I welcome developers to dive in and play around with Eleva! Here's how you can g
|
|
|
361
400
|
npm run dev
|
|
362
401
|
```
|
|
363
402
|
|
|
364
|
-
4. **Build for Production:**
|
|
403
|
+
4. **Build for Production without TypeScript Declarations:**
|
|
365
404
|
|
|
366
405
|
```bash
|
|
367
406
|
npm run build
|
|
@@ -374,23 +413,29 @@ I welcome developers to dive in and play around with Eleva! Here's how you can g
|
|
|
374
413
|
npm run build:types:bundle
|
|
375
414
|
```
|
|
376
415
|
|
|
416
|
+
6. **Build for Production with TypeScript Declarations:**
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
npm run build:all
|
|
420
|
+
```
|
|
421
|
+
|
|
377
422
|
---
|
|
378
423
|
|
|
379
424
|
## Testing
|
|
380
425
|
|
|
381
|
-
I use Jest for
|
|
426
|
+
I use Jest for testing. Run the test suite with:
|
|
382
427
|
|
|
383
428
|
```bash
|
|
384
429
|
npm test
|
|
385
430
|
```
|
|
386
431
|
|
|
387
|
-
|
|
432
|
+
Contributions to tests are very welcome! 🧪
|
|
388
433
|
|
|
389
434
|
---
|
|
390
435
|
|
|
391
436
|
## Contributing
|
|
392
437
|
|
|
393
|
-
I
|
|
438
|
+
I'd love to have you onboard as a contributor! Whether you're adding new features, squashing bugs, or sharing ideas, your input is invaluable. Please check out [CONTRIBUTING](CONTRIBUTING.md) for guidelines on getting started.
|
|
394
439
|
|
|
395
440
|
---
|
|
396
441
|
|
|
@@ -408,11 +453,15 @@ Eleva is open-source and available under the [MIT License](LICENSE).
|
|
|
408
453
|
|
|
409
454
|
---
|
|
410
455
|
|
|
411
|
-
**Note:** This is
|
|
456
|
+
**Note:** This is a beta release. I'm still polishing things up, so expect some bumps along the way. Your feedback and contributions will help shape Eleva into something truly amazing. Let's build something great together! 💪✨
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
|
|
460
|
+
[](https://nodei.co/npm/eleva/)
|
|
412
461
|
|
|
413
462
|
---
|
|
414
463
|
|
|
415
464
|
[Documentation](/docs/index.md) |
|
|
416
465
|
[Examples](/examples) |
|
|
417
|
-
[Changelog](
|
|
466
|
+
[Changelog](/CHANGELOG.md) |
|
|
418
467
|
[GitHub Discussions](https://github.com/TarekRaafat/eleva/discussions)
|