eleva 0.1.0-alpha → 1.0.0-alpha
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 +418 -1
- package/dist/eleva.d.ts +151 -0
- package/dist/eleva.esm.js +490 -0
- package/dist/eleva.esm.js.map +1 -0
- package/dist/eleva.min.js +2 -0
- package/dist/eleva.min.js.map +1 -0
- package/dist/eleva.umd.js +498 -0
- package/dist/eleva.umd.js.map +1 -0
- package/package.json +55 -14
- package/src/core/Eleva.js +246 -0
- package/src/index.js +5 -0
- package/src/modules/Emitter.js +49 -0
- package/src/modules/Renderer.js +119 -0
- package/src/modules/Signal.js +51 -0
- package/src/modules/TemplateEngine.js +47 -0
- package/types/core/Eleva.d.ts +86 -0
- package/types/core/Eleva.d.ts.map +1 -0
- package/types/index.d.ts +3 -0
- package/types/index.d.ts.map +1 -0
- package/types/modules/Emitter.d.ts +34 -0
- package/types/modules/Emitter.d.ts.map +1 -0
- package/types/modules/Renderer.d.ts +30 -0
- package/types/modules/Renderer.d.ts.map +1 -0
- package/types/modules/Signal.d.ts +36 -0
- package/types/modules/Signal.d.ts.map +1 -0
- package/types/modules/TemplateEngine.d.ts +26 -0
- package/types/modules/TemplateEngine.d.ts.map +1 -0
package/README.md
CHANGED
|
@@ -1 +1,418 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Eleva
|
|
2
|
+
|
|
3
|
+
**A minimalist, lightweight, pure vanilla JavaScript frontend runtime framework.**
|
|
4
|
+
_Built with love for native JavaScript—because sometimes, less really is more!_ 😊
|
|
5
|
+
|
|
6
|
+
[](https://www.npmjs.com/package/eleva)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[](https://travis-ci.org/TarekRaafat/eleva)
|
|
9
|
+
|
|
10
|
+
> **Stability Notice**: This is `v1.0.0-alpha` - APIs may change significantly until stable release.
|
|
11
|
+
> Not recommended for production use yet. Follow the [versioning guide](#versioning) for updates.
|
|
12
|
+
|
|
13
|
+
**Version:** `1.0.0-alpha`
|
|
14
|
+
|
|
15
|
+
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
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Table of Contents
|
|
20
|
+
|
|
21
|
+
- [Eleva](#eleva)
|
|
22
|
+
- [Table of Contents](#table-of-contents)
|
|
23
|
+
- [Introduction](#introduction)
|
|
24
|
+
- [Design Philosophy](#design-philosophy)
|
|
25
|
+
- [Handcrafted \& Developer-Centric Design](#handcrafted--developer-centric-design)
|
|
26
|
+
- [Features](#features)
|
|
27
|
+
- [When to Use Eleva](#when-to-use-eleva)
|
|
28
|
+
- [Version Strategy](#version-strategy)
|
|
29
|
+
- [Version Guide](#version-guide)
|
|
30
|
+
- [Performance](#performance)
|
|
31
|
+
- [Performance Benchmarks](#performance-benchmarks)
|
|
32
|
+
- [Eleva vs. Popular Frameworks](#eleva-vs-popular-frameworks)
|
|
33
|
+
- [Installation](#installation)
|
|
34
|
+
- [Usage](#usage)
|
|
35
|
+
- [ES Module Example](#es-module-example)
|
|
36
|
+
- [UMD Example](#umd-example)
|
|
37
|
+
- [API Reference](#api-reference)
|
|
38
|
+
- [TemplateEngine](#templateengine)
|
|
39
|
+
- [Signal](#signal)
|
|
40
|
+
- [Emitter](#emitter)
|
|
41
|
+
- [Renderer](#renderer)
|
|
42
|
+
- [Eleva (Core)](#eleva-core)
|
|
43
|
+
- [Development](#development)
|
|
44
|
+
- [Testing](#testing)
|
|
45
|
+
- [Contributing](#contributing)
|
|
46
|
+
- [License](#license)
|
|
47
|
+
- [Contact](#contact)
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Introduction
|
|
52
|
+
|
|
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 to rely on heavy libraries to build amazing user interfaces—sometimes, the simplest approach is the most powerful.
|
|
54
|
+
|
|
55
|
+
**My Inspiration:**
|
|
56
|
+
The idea and concept behind Eleva came from my 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 for you to integrate into your projects without a steep learning curve.
|
|
57
|
+
|
|
58
|
+
**Core Principles:**
|
|
59
|
+
|
|
60
|
+
- **🌱 Minimalism:** Only the essentials, so you can build without the clutter.
|
|
61
|
+
- **🔌 Extensibility:** Plug in your own ideas—custom state management, routing, and more.
|
|
62
|
+
- **🚀 Performance:** Fast, efficient, and designed with modern browsers in mind.
|
|
63
|
+
- **🍦 Pure Vanilla:** No dependencies, no magic—just plain JavaScript.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Design Philosophy
|
|
68
|
+
|
|
69
|
+
**Eleva is an unopinionated library.**
|
|
70
|
+
|
|
71
|
+
Unlike many frameworks that enforce a specific project structure or coding paradigm, Eleva provides a minimal core with a flexible plugin system. This means:
|
|
72
|
+
|
|
73
|
+
- **🔄 Flexibility:** You’re free to architect your application as you see fit, without being forced into a rigid structure.
|
|
74
|
+
- **🎯 Native JavaScript:** Eleva is built using pure vanilla JavaScript, so it integrates seamlessly with your existing code without introducing unfamiliar syntax.
|
|
75
|
+
- **⚙️ Configurability:** With a simple API and optional plugins, you can extend Eleva's functionality to suit your project's unique requirements.
|
|
76
|
+
- **🆓 Freedom:** You decide the best way to implement features, allowing for both simple and complex applications without unnecessary constraints.
|
|
77
|
+
|
|
78
|
+
This unopinionated approach makes Eleva versatile and ideal for developers who prefer to have full control over their application's design.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Handcrafted & Developer-Centric Design
|
|
83
|
+
|
|
84
|
+
Eleva is built with a meticulous attention to detail and a deep passion for pure vanilla JavaScript. Every aspect of its design and architecture has been carefully handcrafted with the developer in mind. This approach makes Eleva not only a fresh and innovative choice but also a solid foundation for your projects.
|
|
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.
|
|
94
|
+
|
|
95
|
+
- **🏗️ Solid & Reliable:**
|
|
96
|
+
With a focus on performance and modularity, Eleva provides a robust yet flexible platform that scales with your project's needs.
|
|
97
|
+
|
|
98
|
+
This unique, developer-first approach makes Eleva a standout choice for building high-performance frontend applications without compromising on simplicity or control.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Features
|
|
103
|
+
|
|
104
|
+
- **🧩 Component-Based Architecture:** Create reusable UI components effortlessly.
|
|
105
|
+
- **⚡ Signal-Based Reactivity:** Fine-grained reactivity that updates only what’s needed.
|
|
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
|
+
- **📦 UMD & ES Module Builds:** Designed for the browser, with modern build tool support.
|
|
110
|
+
- **🤝 Friendly API:** A gentle learning curve for both beginners and seasoned developers.
|
|
111
|
+
- **💎 Tiny Footprint & TypeScript Support:** At a fraction of the size of many mainstream frameworks (~4 KB minified) and with built-in TypeScript declarations, Eleva keeps your bundle lean and your codebase strongly typed.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## When to Use Eleva
|
|
116
|
+
|
|
117
|
+
Eleva is designed for developers who want a lightweight, flexible, and high-performance solution for building frontend applications. Here are some scenarios where Eleva shines:
|
|
118
|
+
|
|
119
|
+
- **🚀 Small to Medium Projects:**
|
|
120
|
+
If you're building a web app or website that doesn't require the overhead of a full-fledged framework, Eleva’s minimal footprint (~4 KB minified) keeps your project fast and efficient.
|
|
121
|
+
|
|
122
|
+
- **⚡ Performance-Critical Applications:**
|
|
123
|
+
For projects where speed and low bundle size are paramount, Eleva's optimized reactivity and DOM diffing ensure your app runs smoothly without unnecessary bloat.
|
|
124
|
+
|
|
125
|
+
- **🔄 Unopinionated and Flexible Design:**
|
|
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.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Version Strategy
|
|
142
|
+
|
|
143
|
+
I believe in clear versioning that reflects the maturity of the project:
|
|
144
|
+
|
|
145
|
+
- **Pre-release Versions (Alpha/Beta):** Early versions like `1.0.0-alpha` signal that the API is still evolving. Expect frequent updates, and please share your feedback!
|
|
146
|
+
- **Semantic Versioning:** Once the API stabilizes, I'll follow semantic versioning strictly so that any breaking changes are clearly communicated.
|
|
147
|
+
- **Fresh Start:** Since this is a complete overhaul and a fresh start, `1.0.0-alpha` represents my first major step forward.
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Version Guide
|
|
152
|
+
|
|
153
|
+
I follow [Semantic Versioning (SemVer)](https://semver.org/) to manage Eleva's releases. Here's a quick guide to help you understand the version numbers:
|
|
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.
|
|
163
|
+
|
|
164
|
+
This guide is intended to help you understand what to expect with each release and how Eleva is evolving over time.
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Performance
|
|
169
|
+
|
|
170
|
+
Eleva is crafted with performance in mind:
|
|
171
|
+
|
|
172
|
+
- **Lightweight:** Designed to be ~4 KB minified so your app stays nimble.
|
|
173
|
+
- **Efficient Reactivity:** Signal-based updates ensure only the necessary parts of the DOM are re-rendered.
|
|
174
|
+
- **Optimized Diffing:** The Renderer efficiently patches changes without the overhead of a virtual DOM.
|
|
175
|
+
- **No Bloat:** Pure vanilla JavaScript means no unnecessary dependencies slowing you down.
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Performance Benchmarks
|
|
180
|
+
|
|
181
|
+
I've run some preliminary benchmarks to give you a rough idea of how Eleva stacks up against some popular frontend frameworks. These tests focus on bundle size, initial load time, and DOM update performance using a simple counter component scenario.
|
|
182
|
+
|
|
183
|
+
| Framework | Bundle Size (minified) | Initial Load Time | DOM Update Speed |
|
|
184
|
+
| --------- | ---------------------- | ----------------- | ---------------- |
|
|
185
|
+
| **Eleva** | ~4 KB | ~35 ms | ~2 ms |
|
|
186
|
+
| React | ~110 KB | ~100 ms | ~4 ms |
|
|
187
|
+
| Vue | ~80 KB | ~80 ms | ~3 ms |
|
|
188
|
+
| Angular | ~500 KB | ~250 ms | ~6 ms |
|
|
189
|
+
|
|
190
|
+
> ⚠️ **Disclaimer:** These benchmarks are based on internal tests with a minimalistic counter component and may vary depending on project specifics and environments. They serve as a general indicator of Eleva’s lightweight and high-performance design.
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Eleva vs. Popular Frameworks
|
|
195
|
+
|
|
196
|
+
While frameworks like React, Vue, and Angular are powerful, Eleva offers a refreshing alternative:
|
|
197
|
+
|
|
198
|
+
- **Simplicity:** No virtual DOM, no JSX, and no complex state management—just plain JavaScript.
|
|
199
|
+
- **Modularity:** Easily extend Eleva with plugins to fit your project's needs.
|
|
200
|
+
- **Size:** At a fraction of the size of many mainstream frameworks, Eleva is perfect for projects where performance is key.
|
|
201
|
+
- **Learning Curve:** With a familiar syntax and a clear API, Eleva is ideal for developers of all levels.
|
|
202
|
+
|
|
203
|
+
**Important:** Eleva is not trying to replace these giants but rather offers a lightweight option when you want to keep things simple and fast without introducing new syntax or unnecessary complexity. 🌟
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Installation
|
|
208
|
+
|
|
209
|
+
Eleva is available on npm. Since it's in alpha, I'm excited to have you try it out and share your thoughts!
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
npm install eleva
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Or include it directly in your HTML via CDN:
|
|
216
|
+
|
|
217
|
+
```html
|
|
218
|
+
<script src="https://unpkg.com/eleva/dist/eleva.min.js"></script>
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Usage
|
|
224
|
+
|
|
225
|
+
### ES Module Example
|
|
226
|
+
|
|
227
|
+
```js
|
|
228
|
+
// Import Eleva (using ES modules)
|
|
229
|
+
import { Eleva } from "eleva";
|
|
230
|
+
|
|
231
|
+
// Create a new Eleva instance
|
|
232
|
+
const app = new Eleva("MyApp");
|
|
233
|
+
|
|
234
|
+
// Define a component
|
|
235
|
+
app.component("HelloWorld", {
|
|
236
|
+
setup({ signal }) {
|
|
237
|
+
const count = signal(0);
|
|
238
|
+
return { count };
|
|
239
|
+
},
|
|
240
|
+
template: ({ count }) => `
|
|
241
|
+
<div>
|
|
242
|
+
<h1>Hello, Eleva! 👋</h1>
|
|
243
|
+
<p>Count: ${count}</p>
|
|
244
|
+
<button @click="() => count++">Increment</button>
|
|
245
|
+
</div>
|
|
246
|
+
`,
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
// Mount the component to a DOM element with the id 'app'
|
|
250
|
+
app.mount("#app", "HelloWorld");
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### UMD Example
|
|
254
|
+
|
|
255
|
+
Include Eleva via a script tag, and it will be available as a global variable:
|
|
256
|
+
|
|
257
|
+
```html
|
|
258
|
+
<!DOCTYPE html>
|
|
259
|
+
<html lang="en">
|
|
260
|
+
<head>
|
|
261
|
+
<meta charset="UTF-8" />
|
|
262
|
+
<title>Eleva Example</title>
|
|
263
|
+
</head>
|
|
264
|
+
<body>
|
|
265
|
+
<div id="app"></div>
|
|
266
|
+
<script src="https://unpkg.com/eleva/dist/eleva.min.js"></script>
|
|
267
|
+
<script>
|
|
268
|
+
const app = new Eleva("MyApp");
|
|
269
|
+
app.component("HelloWorld", {
|
|
270
|
+
setup({ signal }) {
|
|
271
|
+
const count = signal(0);
|
|
272
|
+
return { count };
|
|
273
|
+
},
|
|
274
|
+
template: ({ count }) => `
|
|
275
|
+
<div>
|
|
276
|
+
<h1>Hello, Eleva! 👋</h1>
|
|
277
|
+
<p>Count: ${count}</p>
|
|
278
|
+
<button @click="() => count++">Increment</button>
|
|
279
|
+
</div>
|
|
280
|
+
`,
|
|
281
|
+
});
|
|
282
|
+
app.mount("#app", "HelloWorld");
|
|
283
|
+
</script>
|
|
284
|
+
</body>
|
|
285
|
+
</html>
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## API Reference
|
|
291
|
+
|
|
292
|
+
### TemplateEngine
|
|
293
|
+
|
|
294
|
+
- **`TemplateEngine.parse(template, data)`**
|
|
295
|
+
Replaces `{{ expression }}` patterns in the template with evaluated values.
|
|
296
|
+
- **`TemplateEngine.evaluate(expr, data)`**
|
|
297
|
+
Safely evaluates JavaScript expressions within a given context.
|
|
298
|
+
|
|
299
|
+
### Signal
|
|
300
|
+
|
|
301
|
+
- **`new Signal(value)`**
|
|
302
|
+
Creates a reactive data holder.
|
|
303
|
+
- **`.value` (getter/setter)**
|
|
304
|
+
Get or update the current value and trigger watchers.
|
|
305
|
+
- **`.watch(fn)`**
|
|
306
|
+
Registers a function to run when the value updates.
|
|
307
|
+
|
|
308
|
+
### Emitter
|
|
309
|
+
|
|
310
|
+
- **`.on(event, handler)`**
|
|
311
|
+
Listen to events.
|
|
312
|
+
- **`.off(event, handler)`**
|
|
313
|
+
Remove event listeners.
|
|
314
|
+
- **`.emit(event, ...args)`**
|
|
315
|
+
Trigger events with additional arguments.
|
|
316
|
+
|
|
317
|
+
### Renderer
|
|
318
|
+
|
|
319
|
+
- **`patchDOM(container, newHtml)`**
|
|
320
|
+
Efficiently update the DOM.
|
|
321
|
+
- **`diff(oldParent, newParent)`**
|
|
322
|
+
Compare and update DOM trees.
|
|
323
|
+
- **`updateAttributes(oldEl, newEl)`**
|
|
324
|
+
Sync element attributes.
|
|
325
|
+
|
|
326
|
+
### Eleva (Core)
|
|
327
|
+
|
|
328
|
+
- **`new Eleva(name, config)`**
|
|
329
|
+
Create an Eleva instance.
|
|
330
|
+
- **`.use(plugin, options)`**
|
|
331
|
+
Install plugins.
|
|
332
|
+
- **`.component(name, definition)`**
|
|
333
|
+
Register a component.
|
|
334
|
+
- **`.mount(selectorOrElement, compName, props)`**
|
|
335
|
+
Mount a component to the DOM.
|
|
336
|
+
|
|
337
|
+
For detailed API documentation, please check the [docs](docs/) folder.
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
## Development
|
|
342
|
+
|
|
343
|
+
I welcome developers to dive in and play around with Eleva! Here's how you can get started locally:
|
|
344
|
+
|
|
345
|
+
1. **Clone the Repository:**
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
git clone https://github.com/TarekRaafat/eleva.git
|
|
349
|
+
cd eleva
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
2. **Install Dependencies:**
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
npm install
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
3. **Run in Development Mode (Watch):**
|
|
359
|
+
|
|
360
|
+
```bash
|
|
361
|
+
npm run dev
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
4. **Build for Production:**
|
|
365
|
+
|
|
366
|
+
```bash
|
|
367
|
+
npm run build
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
5. **Generate and Bundle TypeScript Declarations:**
|
|
371
|
+
|
|
372
|
+
```bash
|
|
373
|
+
npm run build:types
|
|
374
|
+
npm run build:types:bundle
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
## Testing
|
|
380
|
+
|
|
381
|
+
I use Jest for tests. Run the test suite with:
|
|
382
|
+
|
|
383
|
+
```bash
|
|
384
|
+
npm test
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
Your contributions to tests are very welcome! 🧪
|
|
388
|
+
|
|
389
|
+
---
|
|
390
|
+
|
|
391
|
+
## Contributing
|
|
392
|
+
|
|
393
|
+
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 details on how to get started.
|
|
394
|
+
|
|
395
|
+
---
|
|
396
|
+
|
|
397
|
+
## License
|
|
398
|
+
|
|
399
|
+
Eleva is open-source and available under the [MIT License](LICENSE).
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## Contact
|
|
404
|
+
|
|
405
|
+
- **Author:** [Tarek Raafat](https://github.com/TarekRaafat)
|
|
406
|
+
- **Email:** [tarek.m.raafat@gmail.com](mailto:tarek.m.raafat@gmail.com)
|
|
407
|
+
- **Website:** [tarekraafat.com](https://www.tarekraafat.com)
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
|
|
411
|
+
**Note:** This is an alpha 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! 💪✨
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
[Documentation](/docs/index.md) |
|
|
416
|
+
[Examples](/examples) |
|
|
417
|
+
[Changelog](https://github.com/TarekRaafat/eleva/changelog) |
|
|
418
|
+
[GitHub Discussions](https://github.com/TarekRaafat/eleva/discussions)
|
package/dist/eleva.d.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🎙️ Emitter: Robust inter-component communication with event bubbling.
|
|
3
|
+
*
|
|
4
|
+
* Implements a basic publish-subscribe pattern for event handling,
|
|
5
|
+
* allowing components to communicate through custom events.
|
|
6
|
+
*/
|
|
7
|
+
declare class Emitter {
|
|
8
|
+
/** @type {Object.<string, Function[]>} */
|
|
9
|
+
events: {
|
|
10
|
+
[x: string]: Function[];
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Registers an event handler for the specified event.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} event - The name of the event.
|
|
16
|
+
* @param {Function} handler - The function to call when the event is emitted.
|
|
17
|
+
*/
|
|
18
|
+
on(event: string, handler: Function): void;
|
|
19
|
+
/**
|
|
20
|
+
* Removes a previously registered event handler.
|
|
21
|
+
*
|
|
22
|
+
* @param {string} event - The name of the event.
|
|
23
|
+
* @param {Function} handler - The handler function to remove.
|
|
24
|
+
*/
|
|
25
|
+
off(event: string, handler: Function): void;
|
|
26
|
+
/**
|
|
27
|
+
* Emits an event, invoking all handlers registered for that event.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} event - The event name.
|
|
30
|
+
* @param {...*} args - Additional arguments to pass to the event handlers.
|
|
31
|
+
*/
|
|
32
|
+
emit(event: string, ...args: any[]): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 🎨 Renderer: Handles DOM patching, diffing, and attribute updates.
|
|
37
|
+
*
|
|
38
|
+
* Provides methods for efficient DOM updates by diffing the new and old DOM structures
|
|
39
|
+
* and applying only the necessary changes.
|
|
40
|
+
*/
|
|
41
|
+
declare class Renderer {
|
|
42
|
+
/**
|
|
43
|
+
* Patches the DOM of a container element with new HTML content.
|
|
44
|
+
*
|
|
45
|
+
* @param {HTMLElement} container - The container element to patch.
|
|
46
|
+
* @param {string} newHtml - The new HTML content to apply.
|
|
47
|
+
*/
|
|
48
|
+
patchDOM(container: HTMLElement, newHtml: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* Diffs two DOM trees (old and new) and applies updates to the old DOM.
|
|
51
|
+
*
|
|
52
|
+
* @param {HTMLElement} oldParent - The original DOM element.
|
|
53
|
+
* @param {HTMLElement} newParent - The new DOM element.
|
|
54
|
+
*/
|
|
55
|
+
diff(oldParent: HTMLElement, newParent: HTMLElement): void;
|
|
56
|
+
/**
|
|
57
|
+
* Updates the attributes of an element to match those of a new element.
|
|
58
|
+
*
|
|
59
|
+
* @param {HTMLElement} oldEl - The element to update.
|
|
60
|
+
* @param {HTMLElement} newEl - The element providing the updated attributes.
|
|
61
|
+
*/
|
|
62
|
+
updateAttributes(oldEl: HTMLElement, newEl: HTMLElement): void;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 🧩 Eleva Core: Signal-based component runtime framework with lifecycle, scoped styles, and plugins.
|
|
67
|
+
*
|
|
68
|
+
* The Eleva class is the core of the framework. It manages component registration,
|
|
69
|
+
* plugin integration, lifecycle hooks, event handling, and DOM rendering.
|
|
70
|
+
*/
|
|
71
|
+
declare class Eleva {
|
|
72
|
+
/**
|
|
73
|
+
* Creates a new Eleva instance.
|
|
74
|
+
*
|
|
75
|
+
* @param {string} name - The name of the Eleva instance.
|
|
76
|
+
* @param {object} [config={}] - Optional configuration for the instance.
|
|
77
|
+
*/
|
|
78
|
+
constructor(name: string, config?: object);
|
|
79
|
+
name: string;
|
|
80
|
+
config: object;
|
|
81
|
+
_components: {};
|
|
82
|
+
_plugins: any[];
|
|
83
|
+
_lifecycleHooks: string[];
|
|
84
|
+
_isMounted: boolean;
|
|
85
|
+
emitter: Emitter;
|
|
86
|
+
renderer: Renderer;
|
|
87
|
+
/**
|
|
88
|
+
* Integrates a plugin with the Eleva framework.
|
|
89
|
+
*
|
|
90
|
+
* @param {object} [plugin] - The plugin object which should have an install function.
|
|
91
|
+
* @param {object} [options={}] - Optional options to pass to the plugin.
|
|
92
|
+
* @returns {Eleva} The Eleva instance (for chaining).
|
|
93
|
+
*/
|
|
94
|
+
use(plugin?: object, options?: object): Eleva;
|
|
95
|
+
/**
|
|
96
|
+
* Registers a component with the Eleva instance.
|
|
97
|
+
*
|
|
98
|
+
* @param {string} name - The name of the component.
|
|
99
|
+
* @param {object} definition - The component definition including setup, template, style, and children.
|
|
100
|
+
* @returns {Eleva} The Eleva instance (for chaining).
|
|
101
|
+
*/
|
|
102
|
+
component(name: string, definition: object): Eleva;
|
|
103
|
+
/**
|
|
104
|
+
* Mounts a registered component to a DOM element.
|
|
105
|
+
*
|
|
106
|
+
* @param {string|HTMLElement} selectorOrElement - A CSS selector string or DOM element where the component will be mounted.
|
|
107
|
+
* @param {string} compName - The name of the component to mount.
|
|
108
|
+
* @param {object} [props={}] - Optional properties to pass to the component.
|
|
109
|
+
* @returns {object|Promise<object>} An object representing the mounted component instance, or a Promise that resolves to it for asynchronous setups.
|
|
110
|
+
* @throws Will throw an error if the container or component is not found.
|
|
111
|
+
*/
|
|
112
|
+
mount(selectorOrElement: string | HTMLElement, compName: string, props?: object): object | Promise<object>;
|
|
113
|
+
/**
|
|
114
|
+
* Prepares default no-operation lifecycle hook functions.
|
|
115
|
+
*
|
|
116
|
+
* @returns {object} An object with keys for lifecycle hooks mapped to empty functions.
|
|
117
|
+
* @private
|
|
118
|
+
*/
|
|
119
|
+
private _prepareLifecycleHooks;
|
|
120
|
+
/**
|
|
121
|
+
* Processes DOM elements for event binding based on attributes starting with "@".
|
|
122
|
+
*
|
|
123
|
+
* @param {HTMLElement} container - The container element in which to search for events.
|
|
124
|
+
* @param {object} context - The current context containing event handler definitions.
|
|
125
|
+
* @private
|
|
126
|
+
*/
|
|
127
|
+
private _processEvents;
|
|
128
|
+
/**
|
|
129
|
+
* Injects scoped styles into the component's container.
|
|
130
|
+
*
|
|
131
|
+
* @param {HTMLElement} container - The container element.
|
|
132
|
+
* @param {string} compName - The component name used to identify the style element.
|
|
133
|
+
* @param {Function} styleFn - A function that returns CSS styles as a string.
|
|
134
|
+
* @param {object} context - The current context for style interpolation.
|
|
135
|
+
* @private
|
|
136
|
+
*/
|
|
137
|
+
private _injectStyles;
|
|
138
|
+
/**
|
|
139
|
+
* Mounts child components within the parent component's container.
|
|
140
|
+
*
|
|
141
|
+
* @param {HTMLElement} container - The parent container element.
|
|
142
|
+
* @param {object} children - An object mapping child component selectors to their definitions.
|
|
143
|
+
* @param {Array} childInstances - An array to store the mounted child component instances.
|
|
144
|
+
* @private
|
|
145
|
+
*/
|
|
146
|
+
private _mountChildren;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
//# sourceMappingURL=index.d.ts.map
|
|
150
|
+
|
|
151
|
+
export { Eleva as default };
|