eleva 0.1.0-alpha โ†’ 1.0.0-rc.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Tarek
3
+ Copyright (c) 2025 Eleva
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1 +1,467 @@
1
- # eleva
1
+ # eleva.js ๐Ÿš€
2
+
3
+ Pure JavaScript, Pure Performance, Simply Elegant.
4
+
5
+ [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
+ [![GitHub package.json version](https://img.shields.io/github/package-json/v/tarekraafat/eleva?label=github)](https://github.com/TarekRaafat/eleva)
7
+ [![Version](https://img.shields.io/npm/v/eleva.svg?style=flat)](https://www.npmjs.com/package/eleva)
8
+ ![100% Javascript](https://img.shields.io/github/languages/top/TarekRaafat/eleva?color=yellow)
9
+ ![Zero Dependencies](https://img.shields.io/badge/dependencies-0-green.svg)
10
+ [![codecov](https://codecov.io/gh/TarekRaafat/eleva/branch/master/graph/badge.svg?token=LFA6KENM24)](https://codecov.io/gh/TarekRaafat/eleva)
11
+ [![Minified Size](https://badgen.net/bundlephobia/min/eleva@latest)](https://bundlephobia.com/package/eleva@latest)
12
+ [![Gzipped Size](https://badgen.net/bundlephobia/minzip/eleva@latest)](https://bundlephobia.com/package/eleva@latest)
13
+ [![](https://data.jsdelivr.com/v1/package/npm/eleva/badge)](https://www.jsdelivr.com/package/npm/eleva)
14
+ [![Supported by Canonical](https://img.shields.io/badge/Supported%20by-Canonical-E95420?logo=ubuntu&logoColor=white)](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&#0032;minimalist&#0044;&#0032;pure&#0032;vanilla&#0032;javascript&#0032;frontend&#0032;framework&#0046; | 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-because sometimes, less really is more!_ ๐Ÿ˜Š
42
+
43
+ > **Stability Notice**: This is `v1.0.0-rc.1` - The core functionality is stable, but I'm seeking community feedback before the final v1.0.0 release.
44
+
45
+ **Version:** `1.0.0-rc.1`
46
+
47
+
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. ๐Ÿš€
50
+
51
+ ---
52
+
53
+ ## Table of Contents
54
+
55
+ - [eleva.js ๐Ÿš€](#elevajs-)
56
+ - [Table of Contents](#table-of-contents)
57
+ - [Introduction](#introduction)
58
+ - [Design Philosophy](#design-philosophy)
59
+ - [Handcrafted \& Developer-Centric Design](#handcrafted--developer-centric-design)
60
+ - [Features](#features)
61
+ - [When to Use Eleva](#when-to-use-eleva)
62
+ - [Version Strategy](#version-strategy)
63
+ - [Version Guide](#version-guide)
64
+ - [Performance](#performance)
65
+ - [Performance Benchmarks](#performance-benchmarks)
66
+ - [Eleva vs. Popular Frameworks](#eleva-vs-popular-frameworks)
67
+ - [Installation](#installation)
68
+ - [Usage](#usage)
69
+ - [ES Module Example](#es-module-example)
70
+ - [UMD Example](#umd-example)
71
+ - [API Reference](#api-reference)
72
+ - [TemplateEngine](#templateengine)
73
+ - [Signal](#signal)
74
+ - [Emitter](#emitter)
75
+ - [Renderer](#renderer)
76
+ - [Eleva (Core)](#eleva-core)
77
+ - [Development](#development)
78
+ - [Testing](#testing)
79
+ - [Contributing](#contributing)
80
+ - [License](#license)
81
+ - [Contact](#contact)
82
+
83
+ ---
84
+
85
+ ## Introduction
86
+
87
+ 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 heavy frameworks or libraries to build amazing user interfaces-sometimes, the simplest approach is the most powerful.
88
+
89
+ **My Inspiration:**
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.
91
+
92
+ **Core Principles:**
93
+
94
+ - **๐ŸŒฑ Minimalism:** Only the essentials, so you can build without clutter.
95
+ - **๐Ÿ”Œ Extensibility:** Plug in your own ideas-custom state management, routing, and more.
96
+ - **๐Ÿš€ Performance:** Fast, efficient, and designed with modern browsers in mind.
97
+ - **๐Ÿฆ Pure Vanilla:** No dependencies, no magic-just plain JavaScript.
98
+
99
+ ---
100
+
101
+ ## Design Philosophy
102
+
103
+ **Eleva is an unopinionated framework.**
104
+
105
+ Unlike many frameworks that enforce a specific project structure or coding paradigm, Eleva provides a minimal core with a flexible plugin system. This means:
106
+
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.
111
+
112
+ This unopinionated approach makes Eleva versatile and ideal for developers who want full control over their application's design.
113
+
114
+ ---
115
+
116
+ ## Handcrafted & Developer-Centric Design
117
+
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.
119
+
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.
124
+
125
+ This unique, developer-first approach makes Eleva a standout choice for building high-performance frontend applications without compromising on simplicity or control.
126
+
127
+ ---
128
+
129
+ ## Features
130
+
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
142
+
143
+ ---
144
+
145
+ ## When to Use Eleva
146
+
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:
148
+
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.
156
+
157
+ ---
158
+
159
+ ## Version Strategy
160
+
161
+ I believe in clear versioning that reflects the maturity of the project:
162
+
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.
166
+
167
+ ---
168
+
169
+ ## Version Guide
170
+
171
+ I follow [Semantic Versioning (SemVer)](https://semver.org/):
172
+
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`).
177
+
178
+ ---
179
+
180
+ ## Performance
181
+
182
+ Eleva is crafted for performance:
183
+
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.
190
+
191
+ ---
192
+
193
+ ## Performance Benchmarks
194
+
195
+ Preliminary benchmarks illustrate Eleva's efficiency compared to popular frameworks:
196
+
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) |
203
+
204
+ Detailed [Benchmark Metrics Report](BENCHMARK.md)
205
+
206
+ > โš ๏ธ **Disclaimer:** Benchmarks are based on internal tests and may vary by project and environment.
207
+
208
+ ---
209
+
210
+ ## Eleva vs. Popular Frameworks
211
+
212
+ Eleva offers a refreshing alternative to frameworks like React, Vue, and Angular:
213
+
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.
218
+
219
+ _Note:_ Eleva isn't trying to replace these giants but provides a lightweight option when you want simplicity and speed. ๐ŸŒŸ
220
+
221
+ ---
222
+
223
+ ## Installation
224
+
225
+ Eleva is available on npm. Try it out and share your thoughts!
226
+
227
+ ```bash
228
+ npm install eleva
229
+ ```
230
+
231
+ Or include it directly via CDN:
232
+
233
+ ```html
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>
243
+ ```
244
+
245
+ ---
246
+
247
+ ## Usage
248
+
249
+ ### ES Module Example
250
+
251
+ ```js
252
+ // Import Eleva (using ES modules)
253
+ import Eleva from "eleva";
254
+
255
+ // Create a new Eleva instance
256
+ const app = new Eleva("MyApp");
257
+
258
+ // Define a component
259
+ app.component("HelloWorld", {
260
+ // The setup method is optional; if omitted, an empty state is used.
261
+ setup({ signal }) {
262
+ const count = signal(0);
263
+ return {
264
+ count,
265
+ onMount: ({ container, context }) => {
266
+ console.log('Component mounted!');
267
+ }
268
+ };
269
+ },
270
+ template: ({ count }) => `
271
+ <div>
272
+ <h1>Hello, Eleva! ๐Ÿ‘‹</h1>
273
+ <p>Count: ${count.value}</p>
274
+ <button @click="() => count.value++">Increment</button>
275
+ </div>
276
+ `
277
+ });
278
+
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
+ });
286
+ ```
287
+
288
+ Interactive Demo: [CodePen](https://codepen.io/tarekraafat/pen/GgRrxdY?editors=1010)
289
+
290
+ ### UMD Example
291
+
292
+ Include Eleva via a script tag and use the global variable:
293
+
294
+ ```html
295
+ <!DOCTYPE html>
296
+ <html lang="en">
297
+ <head>
298
+ <meta charset="UTF-8" />
299
+ <title>Eleva Example</title>
300
+ </head>
301
+ <body>
302
+ <div id="app"></div>
303
+ <script src="https://cdn.jsdelivr.net/npm/eleva"></script>
304
+ <script>
305
+ const app = new Eleva("MyApp");
306
+ app.component("HelloWorld", {
307
+ setup({ signal }) {
308
+ const count = signal(0);
309
+ return { count };
310
+ },
311
+ template: ({ count }) => `
312
+ <div>
313
+ <h1>Hello, Eleva! ๐Ÿ‘‹</h1>
314
+ <p>Count: ${count.value}</p>
315
+ <button @click="() => count.value++">Increment</button>
316
+ </div>
317
+ `,
318
+ });
319
+ app.mount(document.getElementById("app"), "HelloWorld");
320
+ </script>
321
+ </body>
322
+ </html>
323
+ ```
324
+
325
+ Interactive Demo: [CodePen](https://codepen.io/tarekraafat/pen/jEOyzYN?editors=1010)
326
+
327
+ ---
328
+
329
+ ## API Reference
330
+
331
+ ### TemplateEngine
332
+
333
+ - **`TemplateEngine.parse(template, data)`**
334
+ Replaces `{{ expression }}` patterns in the template with evaluated values.
335
+ - **`TemplateEngine.evaluate(expr, data)`**
336
+ Safely evaluates JavaScript expressions within a given context.
337
+
338
+ ### Signal
339
+
340
+ - **`new Signal(initialValue)`**
341
+ Creates a reactive data holder.
342
+ - **`.value` (getter/setter)**
343
+ Get or update the current value and trigger watchers.
344
+ - **`.watch(callback)`**
345
+ Registers a function to run when the value updates.
346
+
347
+ ### Emitter
348
+
349
+ - **`new Emitter()`**
350
+ Creates an Emitter instance.
351
+ - **`.on(event, handler)`**
352
+ Listen to events.
353
+ - **`.off(event, handler)`**
354
+ Remove event listeners.
355
+ - **`.emit(event, ...args)`**
356
+ Trigger events with additional arguments.
357
+
358
+ ### Renderer
359
+
360
+ - **`new Renderer()`**
361
+ Creates a Renderer instance.
362
+ - **`.patchDOM(container, newHtml)`**:
363
+ Updates container content with the new HTML.
364
+
365
+ ### Eleva (Core)
366
+
367
+ - **`new Eleva(name, config)`**
368
+ Create an Eleva instance.
369
+ - **`.use(plugin, options)`**
370
+ Install plugins.
371
+ - **`.component(name, definition)`**
372
+ Register a component.
373
+ - **`.mount(container, compName, props)`**
374
+ Mount a component to the DOM.
375
+
376
+ For detailed API documentation, please check the [docs](docs/index.md) folder.
377
+
378
+ ---
379
+
380
+ ## Development
381
+
382
+ I welcome developers to dive in and experiment with Eleva! Here's how to get started locally:
383
+
384
+ 1. **Clone the Repository:**
385
+
386
+ ```bash
387
+ git clone https://github.com/TarekRaafat/eleva.git
388
+ cd eleva
389
+ ```
390
+
391
+ 2. **Install Dependencies:**
392
+
393
+ ```bash
394
+ npm install
395
+ ```
396
+
397
+ 3. **Run in Development Mode (Watch):**
398
+
399
+ ```bash
400
+ npm run dev
401
+ ```
402
+
403
+ 4. **Build for Production without TypeScript Declarations:**
404
+
405
+ ```bash
406
+ npm run build
407
+ ```
408
+
409
+ 5. **Generate and Bundle TypeScript Declarations:**
410
+
411
+ ```bash
412
+ npm run build:types
413
+ npm run build:types:bundle
414
+ ```
415
+
416
+ 6. **Build for Production with TypeScript Declarations:**
417
+
418
+ ```bash
419
+ npm run build:all
420
+ ```
421
+
422
+ ---
423
+
424
+ ## Testing
425
+
426
+ I use Jest for testing. Run the test suite with:
427
+
428
+ ```bash
429
+ npm test
430
+ ```
431
+
432
+ Contributions to tests are very welcome! ๐Ÿงช
433
+
434
+ ---
435
+
436
+ ## Contributing
437
+
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.
439
+
440
+ ---
441
+
442
+ ## License
443
+
444
+ Eleva is open-source and available under the [MIT License](LICENSE).
445
+
446
+ ---
447
+
448
+ ## Contact
449
+
450
+ - **Author:** [Tarek Raafat](https://github.com/TarekRaafat)
451
+ - **Email:** [tarek.m.raafat@gmail.com](mailto:tarek.m.raafat@gmail.com)
452
+ - **Website:** [tarekraafat.com](https://www.tarekraafat.com)
453
+
454
+ ---
455
+
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
+ [![NPM](https://nodei.co/npm/eleva.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/eleva/)
461
+
462
+ ---
463
+
464
+ [Documentation](/docs/index.md) |
465
+ [Examples](/examples) |
466
+ [Changelog](/CHANGELOG.md) |
467
+ [GitHub Discussions](https://github.com/TarekRaafat/eleva/discussions)