eleva 1.0.0-alpha → 1.1.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 +87 -96
- package/dist/eleva.d.ts +94 -38
- package/dist/eleva.esm.js +84 -66
- package/dist/eleva.esm.js.map +1 -1
- package/dist/eleva.min.js +1 -1
- package/dist/eleva.min.js.map +1 -1
- package/dist/eleva.umd.js +84 -66
- package/dist/eleva.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/core/Eleva.js +57 -39
- package/src/modules/Emitter.js +7 -7
- package/src/modules/Renderer.js +8 -8
- package/src/modules/Signal.js +5 -5
- package/src/modules/TemplateEngine.js +10 -11
- package/types/core/Eleva.d.ts +83 -27
- package/types/core/Eleva.d.ts.map +1 -1
- package/types/modules/Emitter.d.ts +9 -9
- package/types/modules/Emitter.d.ts.map +1 -1
- package/types/modules/Renderer.d.ts +2 -2
- package/types/modules/Signal.d.ts +6 -6
- package/types/modules/Signal.d.ts.map +1 -1
- package/types/modules/TemplateEngine.d.ts +15 -12
- package/types/modules/TemplateEngine.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -3,14 +3,19 @@
|
|
|
3
3
|
**A minimalist, lightweight, pure vanilla JavaScript frontend runtime framework.**
|
|
4
4
|
_Built with love for native JavaScript—because sometimes, less really is more!_ 😊
|
|
5
5
|
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
7
|
[](https://www.npmjs.com/package/eleva)
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+

|
|
9
|
+

|
|
10
|
+
[](https://bundlephobia.com/package/eleva@latest)
|
|
11
|
+
[](https://bundlephobia.com/package/eleva@latest)
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
> Not recommended for production use yet. Follow the [versioning guide](#versioning) for updates.
|
|
13
|
+
<!-- [](https://www.jsdelivr.com/package/npm/eleva) -->
|
|
12
14
|
|
|
13
|
-
**
|
|
15
|
+
> **Stability Notice**: This is `v1.1.0-alpha` - APIs may change significantly until the stable release.
|
|
16
|
+
> Not recommended for production use yet. Follow the [versioning guide](#version-guide) for updates.
|
|
17
|
+
|
|
18
|
+
**Version:** `1.1.0-alpha`
|
|
14
19
|
|
|
15
20
|
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
21
|
|
|
@@ -50,14 +55,14 @@ Welcome to Eleva! This is my humble, experimental playground for a fresh approac
|
|
|
50
55
|
|
|
51
56
|
## Introduction
|
|
52
57
|
|
|
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
|
|
58
|
+
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 libraries to build amazing user interfaces—sometimes, the simplest approach is the most powerful.
|
|
54
59
|
|
|
55
60
|
**My Inspiration:**
|
|
56
|
-
The idea
|
|
61
|
+
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
62
|
|
|
58
63
|
**Core Principles:**
|
|
59
64
|
|
|
60
|
-
- **🌱 Minimalism:** Only the essentials, so you can build without
|
|
65
|
+
- **🌱 Minimalism:** Only the essentials, so you can build without clutter.
|
|
61
66
|
- **🔌 Extensibility:** Plug in your own ideas—custom state management, routing, and more.
|
|
62
67
|
- **🚀 Performance:** Fast, efficient, and designed with modern browsers in mind.
|
|
63
68
|
- **🍦 Pure Vanilla:** No dependencies, no magic—just plain JavaScript.
|
|
@@ -70,30 +75,23 @@ The idea and concept behind Eleva came from my deep appreciation for native Java
|
|
|
70
75
|
|
|
71
76
|
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
77
|
|
|
73
|
-
- **🔄 Flexibility:**
|
|
74
|
-
- **🎯 Native JavaScript:**
|
|
75
|
-
- **⚙️ Configurability:**
|
|
76
|
-
- **🆓 Freedom:**
|
|
78
|
+
- **🔄 Flexibility:** Architect your application your way—no rigid structure required.
|
|
79
|
+
- **🎯 Native JavaScript:** Built using pure vanilla JavaScript, Eleva integrates seamlessly with your existing code without unfamiliar syntax.
|
|
80
|
+
- **⚙️ Configurability:** Extend Eleva's functionality with a simple API and optional plugins.
|
|
81
|
+
- **🆓 Freedom:** Decide the best way to implement features without unnecessary constraints.
|
|
77
82
|
|
|
78
|
-
This unopinionated approach makes Eleva versatile and ideal for developers who
|
|
83
|
+
This unopinionated approach makes Eleva versatile and ideal for developers who want full control over their application's design.
|
|
79
84
|
|
|
80
85
|
---
|
|
81
86
|
|
|
82
87
|
## Handcrafted & Developer-Centric Design
|
|
83
88
|
|
|
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.
|
|
89
|
+
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.
|
|
91
90
|
|
|
92
|
-
-
|
|
93
|
-
|
|
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.
|
|
91
|
+
- **🎨 Craftsmanship:** Every line of code is written with care, keeping the library lightweight, efficient, and easy to understand.
|
|
92
|
+
- **🛠️ Developer-Centric:** Its intuitive API and minimal core mean you spend less time wrestling with the framework and more time building your application.
|
|
93
|
+
- **🌟 Innovative & Fresh:** Stick to pure vanilla JavaScript and avoid unnecessary abstractions.
|
|
94
|
+
- **🏗️ Solid & Reliable:** Focused on performance and modularity, Eleva scales with your project’s needs.
|
|
97
95
|
|
|
98
96
|
This unique, developer-first approach makes Eleva a standout choice for building high-performance frontend applications without compromising on simplicity or control.
|
|
99
97
|
|
|
@@ -106,35 +104,22 @@ This unique, developer-first approach makes Eleva a standout choice for building
|
|
|
106
104
|
- **🔔 Event Handling:** Built-in event emitter for robust inter-component communication.
|
|
107
105
|
- **📝 Template Parsing:** Secure and dynamic interpolation with a custom TemplateEngine.
|
|
108
106
|
- **🔄 DOM Diffing & Patching:** High-performance updates without a virtual DOM.
|
|
109
|
-
- **📦 UMD & ES Module Builds:**
|
|
107
|
+
- **📦 UMD & ES Module Builds:** Supports modern build tools and browser environments.
|
|
110
108
|
- **🤝 Friendly API:** A gentle learning curve for both beginners and seasoned developers.
|
|
111
|
-
- **💎 Tiny Footprint & TypeScript Support:**
|
|
109
|
+
- **💎 Tiny Footprint & TypeScript Support:** Approximately ~4 KB minified with built-in TypeScript declarations, to keep your bundle lean and your codebase strongly typed.
|
|
112
110
|
|
|
113
111
|
---
|
|
114
112
|
|
|
115
113
|
## When to Use Eleva
|
|
116
114
|
|
|
117
|
-
Eleva is
|
|
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.
|
|
115
|
+
Eleva is ideal for developers seeking a lightweight, flexible, and high-performance solution for building frontend applications. Here are some scenarios where Eleva shines:
|
|
133
116
|
|
|
134
|
-
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
117
|
+
- **🚀 Small to Medium Projects:** Perfect for web apps or websites that don’t require the overhead of a full-fledged framework.
|
|
118
|
+
- **⚡ Performance-Critical Applications:** Optimized reactivity and DOM diffing ensure smooth performance without bloat.
|
|
119
|
+
- **🔄 Unopinionated & Flexible:** Architect your application your way with a straightforward API and plugin system.
|
|
120
|
+
- **🎯 Developer-Friendly:** Stick to pure vanilla JavaScript with familiar syntax and built-in TypeScript support.
|
|
121
|
+
- **🧪 Rapid Prototyping:** Quickly prototype ideas with a minimal and extendable framework.
|
|
122
|
+
- **🔌 Extensible:** Easily add features like routing or state management through plugins.
|
|
138
123
|
|
|
139
124
|
---
|
|
140
125
|
|
|
@@ -142,82 +127,82 @@ In short, if you're looking for a solid, developer-centric framework that provid
|
|
|
142
127
|
|
|
143
128
|
I believe in clear versioning that reflects the maturity of the project:
|
|
144
129
|
|
|
145
|
-
- **Pre-release Versions (Alpha/Beta):** Early versions like `1.
|
|
146
|
-
- **Semantic Versioning:** Once
|
|
147
|
-
- **Fresh Start:**
|
|
130
|
+
- **Pre-release Versions (Alpha/Beta):** Early versions like `1.1.0-alpha` indicate the API is still evolving. Expect frequent updates and share your feedback!
|
|
131
|
+
- **Semantic Versioning:** Once stable, I’ll follow semantic versioning strictly to clearly communicate any breaking changes.
|
|
132
|
+
- **Fresh Start:** This release (`1.1.0-alpha`) marks a significant update with new features and improvements.
|
|
148
133
|
|
|
149
134
|
---
|
|
150
135
|
|
|
151
136
|
## Version Guide
|
|
152
137
|
|
|
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.
|
|
138
|
+
I follow [Semantic Versioning (SemVer)](https://semver.org/):
|
|
163
139
|
|
|
164
|
-
|
|
140
|
+
- **🔢 Major Version:** Breaking changes or major overhauls (e.g., from `1.0.0` to `2.0.0`).
|
|
141
|
+
- **🔢 Minor Version:** New features in a backward-compatible manner (e.g., from `1.0.0` to `1.1.0`).
|
|
142
|
+
- **🔢 Patch Version:** Backward-compatible bug fixes and minor improvements (e.g., `1.0.1`).
|
|
143
|
+
- **📌 Pre-release Identifiers:** Suffixes like `-alpha`, `-beta`, or `-rc` denote unstable releases (e.g., `1.1.0-alpha`).
|
|
165
144
|
|
|
166
145
|
---
|
|
167
146
|
|
|
168
147
|
## Performance
|
|
169
148
|
|
|
170
|
-
Eleva is crafted
|
|
149
|
+
Eleva is crafted for performance:
|
|
171
150
|
|
|
172
|
-
- **Lightweight:**
|
|
173
|
-
- **Efficient Reactivity:** Signal-based updates ensure only
|
|
174
|
-
- **Optimized Diffing:**
|
|
175
|
-
- **No Bloat:** Pure vanilla JavaScript
|
|
151
|
+
- **Lightweight:** Approximately ~4 KB minified and ~1.9 KB gzipped.
|
|
152
|
+
- **Efficient Reactivity:** Signal-based updates ensure only necessary DOM parts are updated.
|
|
153
|
+
- **Optimized Diffing:** Renderer efficiently patches changes without the overhead of a virtual DOM.
|
|
154
|
+
- **No Bloat:** Pure vanilla JavaScript with zero dependencies keeps your project nimble.
|
|
176
155
|
|
|
177
156
|
---
|
|
178
157
|
|
|
179
158
|
## Performance Benchmarks
|
|
180
159
|
|
|
181
|
-
|
|
160
|
+
Preliminary benchmarks illustrate Eleva’s efficiency compared to popular frameworks:
|
|
182
161
|
|
|
183
162
|
| Framework | Bundle Size (minified) | Initial Load Time | DOM Update Speed |
|
|
184
163
|
| --------- | ---------------------- | ----------------- | ---------------- |
|
|
185
|
-
| **Eleva** |
|
|
164
|
+
| **Eleva** | **~4 KB** | **~35 ms** | **~2 ms** |
|
|
186
165
|
| React | ~110 KB | ~100 ms | ~4 ms |
|
|
187
166
|
| Vue | ~80 KB | ~80 ms | ~3 ms |
|
|
188
167
|
| Angular | ~500 KB | ~250 ms | ~6 ms |
|
|
189
168
|
|
|
190
|
-
> ⚠️ **Disclaimer:**
|
|
169
|
+
> ⚠️ **Disclaimer:** Benchmarks are based on internal tests with a minimal counter component and may vary by project and environment.
|
|
191
170
|
|
|
192
171
|
---
|
|
193
172
|
|
|
194
173
|
## Eleva vs. Popular Frameworks
|
|
195
174
|
|
|
196
|
-
|
|
175
|
+
Eleva offers a refreshing alternative to frameworks like React, Vue, and Angular:
|
|
197
176
|
|
|
198
|
-
- **Simplicity:** No virtual DOM,
|
|
199
|
-
- **Modularity:** Easily extend
|
|
200
|
-
- **Size:**
|
|
201
|
-
- **Learning Curve:**
|
|
177
|
+
- **Simplicity:** No virtual DOM, JSX, or complex state management—just plain JavaScript.
|
|
178
|
+
- **Modularity:** Easily extend via plugins to suit your project’s needs.
|
|
179
|
+
- **Size:** A fraction of the size of mainstream frameworks.
|
|
180
|
+
- **Learning Curve:** Familiar syntax and a clear API make it accessible to all developers.
|
|
202
181
|
|
|
203
|
-
|
|
182
|
+
_Note:_ Eleva isn’t trying to replace these giants but provides a lightweight option when you want simplicity and speed. 🌟
|
|
204
183
|
|
|
205
184
|
---
|
|
206
185
|
|
|
207
186
|
## Installation
|
|
208
187
|
|
|
209
|
-
Eleva is available on npm.
|
|
188
|
+
Eleva is available on npm. Try it out and share your thoughts!
|
|
210
189
|
|
|
211
190
|
```bash
|
|
212
191
|
npm install eleva
|
|
213
192
|
```
|
|
214
193
|
|
|
215
|
-
Or include it directly
|
|
194
|
+
Or include it directly via CDN:
|
|
216
195
|
|
|
217
196
|
```html
|
|
197
|
+
<!-- unpkg -->
|
|
218
198
|
<script src="https://unpkg.com/eleva/dist/eleva.min.js"></script>
|
|
219
199
|
```
|
|
220
200
|
|
|
201
|
+
```html
|
|
202
|
+
<!-- jsDelivr -->
|
|
203
|
+
<script src="https://cdn.jsdelivr.net/npm/eleva/dist/eleva.min.js"></script>
|
|
204
|
+
```
|
|
205
|
+
|
|
221
206
|
---
|
|
222
207
|
|
|
223
208
|
## Usage
|
|
@@ -226,13 +211,14 @@ Or include it directly in your HTML via CDN:
|
|
|
226
211
|
|
|
227
212
|
```js
|
|
228
213
|
// Import Eleva (using ES modules)
|
|
229
|
-
import
|
|
214
|
+
import Eleva from "eleva";
|
|
230
215
|
|
|
231
216
|
// Create a new Eleva instance
|
|
232
217
|
const app = new Eleva("MyApp");
|
|
233
218
|
|
|
234
219
|
// Define a component
|
|
235
220
|
app.component("HelloWorld", {
|
|
221
|
+
// The setup method is optional; if omitted, an empty state is used.
|
|
236
222
|
setup({ signal }) {
|
|
237
223
|
const count = signal(0);
|
|
238
224
|
return { count };
|
|
@@ -246,13 +232,13 @@ app.component("HelloWorld", {
|
|
|
246
232
|
`,
|
|
247
233
|
});
|
|
248
234
|
|
|
249
|
-
// Mount the component to a DOM element
|
|
250
|
-
app.mount("
|
|
235
|
+
// Mount the component to a DOM element (not a selector).
|
|
236
|
+
app.mount(document.getElementById("app"), "HelloWorld");
|
|
251
237
|
```
|
|
252
238
|
|
|
253
239
|
### UMD Example
|
|
254
240
|
|
|
255
|
-
Include Eleva via a script tag
|
|
241
|
+
Include Eleva via a script tag and use the global variable:
|
|
256
242
|
|
|
257
243
|
```html
|
|
258
244
|
<!DOCTYPE html>
|
|
@@ -272,14 +258,14 @@ Include Eleva via a script tag, and it will be available as a global variable:
|
|
|
272
258
|
return { count };
|
|
273
259
|
},
|
|
274
260
|
template: ({ count }) => `
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
261
|
+
<div>
|
|
262
|
+
<h1>Hello, Eleva! 👋</h1>
|
|
263
|
+
<p>Count: ${count}</p>
|
|
264
|
+
<button @click="() => count++">Increment</button>
|
|
265
|
+
</div>
|
|
266
|
+
`,
|
|
281
267
|
});
|
|
282
|
-
app.mount("
|
|
268
|
+
app.mount(document.getElementById("app"), "HelloWorld");
|
|
283
269
|
</script>
|
|
284
270
|
</body>
|
|
285
271
|
</html>
|
|
@@ -331,16 +317,17 @@ Include Eleva via a script tag, and it will be available as a global variable:
|
|
|
331
317
|
Install plugins.
|
|
332
318
|
- **`.component(name, definition)`**
|
|
333
319
|
Register a component.
|
|
334
|
-
- **`.mount(
|
|
335
|
-
Mount a component to the DOM.
|
|
320
|
+
- **`.mount(container, compName, props)`**
|
|
321
|
+
Mount a component to the DOM.
|
|
322
|
+
_Note:_ This method now expects a DOM element (not a CSS selector) and supports both global component names (strings) and direct component definitions (objects). It returns a Promise, ensuring consistent asynchronous handling.
|
|
336
323
|
|
|
337
|
-
For detailed API documentation, please check the [docs](docs/) folder.
|
|
324
|
+
For detailed API documentation, please check the [docs](docs/index.md) folder.
|
|
338
325
|
|
|
339
326
|
---
|
|
340
327
|
|
|
341
328
|
## Development
|
|
342
329
|
|
|
343
|
-
I welcome developers to dive in and
|
|
330
|
+
I welcome developers to dive in and experiment with Eleva! Here’s how to get started locally:
|
|
344
331
|
|
|
345
332
|
1. **Clone the Repository:**
|
|
346
333
|
|
|
@@ -378,19 +365,19 @@ I welcome developers to dive in and play around with Eleva! Here's how you can g
|
|
|
378
365
|
|
|
379
366
|
## Testing
|
|
380
367
|
|
|
381
|
-
I use Jest for
|
|
368
|
+
I use Jest for testing. Run the test suite with:
|
|
382
369
|
|
|
383
370
|
```bash
|
|
384
371
|
npm test
|
|
385
372
|
```
|
|
386
373
|
|
|
387
|
-
|
|
374
|
+
Contributions to tests are very welcome! 🧪
|
|
388
375
|
|
|
389
376
|
---
|
|
390
377
|
|
|
391
378
|
## Contributing
|
|
392
379
|
|
|
393
|
-
I’d love to have you onboard as a contributor! Whether you
|
|
380
|
+
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
381
|
|
|
395
382
|
---
|
|
396
383
|
|
|
@@ -412,7 +399,11 @@ Eleva is open-source and available under the [MIT License](LICENSE).
|
|
|
412
399
|
|
|
413
400
|
---
|
|
414
401
|
|
|
402
|
+
[](https://nodei.co/npm/eleva/)
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
415
406
|
[Documentation](/docs/index.md) |
|
|
416
407
|
[Examples](/examples) |
|
|
417
|
-
[Changelog](
|
|
408
|
+
[Changelog](/changelog.md) |
|
|
418
409
|
[GitHub Discussions](https://github.com/TarekRaafat/eleva/discussions)
|
package/dist/eleva.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 🎙️ Emitter
|
|
3
|
-
*
|
|
4
|
-
* Implements a basic publish-subscribe pattern for event handling,
|
|
5
|
-
*
|
|
2
|
+
* @class 🎙️ Emitter
|
|
3
|
+
* @classdesc Robust inter-component communication with event bubbling.
|
|
4
|
+
* Implements a basic publish-subscribe pattern for event handling, allowing components
|
|
5
|
+
* to communicate through custom events.
|
|
6
6
|
*/
|
|
7
7
|
declare class Emitter {
|
|
8
8
|
/** @type {Object.<string, Function[]>} */
|
|
@@ -13,28 +13,28 @@ declare class Emitter {
|
|
|
13
13
|
* Registers an event handler for the specified event.
|
|
14
14
|
*
|
|
15
15
|
* @param {string} event - The name of the event.
|
|
16
|
-
* @param {
|
|
16
|
+
* @param {function(...any): void} handler - The function to call when the event is emitted.
|
|
17
17
|
*/
|
|
18
|
-
on(event: string, handler:
|
|
18
|
+
on(event: string, handler: (...args: any[]) => void): void;
|
|
19
19
|
/**
|
|
20
20
|
* Removes a previously registered event handler.
|
|
21
21
|
*
|
|
22
22
|
* @param {string} event - The name of the event.
|
|
23
|
-
* @param {
|
|
23
|
+
* @param {function(...any): void} handler - The handler function to remove.
|
|
24
24
|
*/
|
|
25
|
-
off(event: string, handler:
|
|
25
|
+
off(event: string, handler: (...args: any[]) => void): void;
|
|
26
26
|
/**
|
|
27
27
|
* Emits an event, invoking all handlers registered for that event.
|
|
28
28
|
*
|
|
29
29
|
* @param {string} event - The event name.
|
|
30
|
-
* @param {
|
|
30
|
+
* @param {...any} args - Additional arguments to pass to the event handlers.
|
|
31
31
|
*/
|
|
32
32
|
emit(event: string, ...args: any[]): void;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* 🎨 Renderer
|
|
37
|
-
*
|
|
36
|
+
* @class 🎨 Renderer
|
|
37
|
+
* @classdesc Handles DOM patching, diffing, and attribute updates.
|
|
38
38
|
* Provides methods for efficient DOM updates by diffing the new and old DOM structures
|
|
39
39
|
* and applying only the necessary changes.
|
|
40
40
|
*/
|
|
@@ -63,57 +63,83 @@ declare class Renderer {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
66
|
+
* @typedef {Object} ComponentDefinition
|
|
67
|
+
* @property {function(Object<string, any>): (Object<string, any>|Promise<Object<string, any>>)} [setup]
|
|
68
|
+
* A setup function that initializes the component state and returns an object or a promise that resolves to an object.
|
|
69
|
+
* @property {function(Object<string, any>): string} template
|
|
70
|
+
* A function that returns the HTML template string for the component.
|
|
71
|
+
* @property {function(Object<string, any>): string} [style]
|
|
72
|
+
* An optional function that returns scoped CSS styles as a string.
|
|
73
|
+
* @property {Object<string, ComponentDefinition>} [children]
|
|
74
|
+
* An optional mapping of CSS selectors to child component definitions.
|
|
75
|
+
*/
|
|
76
|
+
/**
|
|
77
|
+
* @class 🧩 Eleva
|
|
78
|
+
* @classdesc Signal-based component runtime framework with lifecycle hooks, scoped styles, and plugin support.
|
|
79
|
+
* Manages component registration, plugin integration, event handling, and DOM rendering.
|
|
70
80
|
*/
|
|
71
81
|
declare class Eleva {
|
|
72
82
|
/**
|
|
73
83
|
* Creates a new Eleva instance.
|
|
74
84
|
*
|
|
75
85
|
* @param {string} name - The name of the Eleva instance.
|
|
76
|
-
* @param {
|
|
86
|
+
* @param {Object<string, any>} [config={}] - Optional configuration for the instance.
|
|
77
87
|
*/
|
|
78
|
-
constructor(name: string, config?:
|
|
88
|
+
constructor(name: string, config?: {
|
|
89
|
+
[x: string]: any;
|
|
90
|
+
});
|
|
91
|
+
/** @type {string} */
|
|
79
92
|
name: string;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
93
|
+
/** @type {Object<string, any>} */
|
|
94
|
+
config: {
|
|
95
|
+
[x: string]: any;
|
|
96
|
+
};
|
|
97
|
+
/** @type {Object<string, ComponentDefinition>} */
|
|
98
|
+
_components: {
|
|
99
|
+
[x: string]: ComponentDefinition;
|
|
100
|
+
};
|
|
101
|
+
/** @type {Array<Object>} */
|
|
102
|
+
_plugins: Array<Object>;
|
|
103
|
+
/** @private */
|
|
104
|
+
private _lifecycleHooks;
|
|
105
|
+
/** @private {boolean} */
|
|
106
|
+
private _isMounted;
|
|
85
107
|
emitter: Emitter;
|
|
86
108
|
renderer: Renderer;
|
|
87
109
|
/**
|
|
88
110
|
* Integrates a plugin with the Eleva framework.
|
|
89
111
|
*
|
|
90
|
-
* @param {
|
|
91
|
-
* @param {
|
|
112
|
+
* @param {Object} plugin - The plugin object which should have an `install` function.
|
|
113
|
+
* @param {Object<string, any>} [options={}] - Optional options to pass to the plugin.
|
|
92
114
|
* @returns {Eleva} The Eleva instance (for chaining).
|
|
93
115
|
*/
|
|
94
|
-
use(plugin
|
|
116
|
+
use(plugin: Object, options?: {
|
|
117
|
+
[x: string]: any;
|
|
118
|
+
}): Eleva;
|
|
95
119
|
/**
|
|
96
120
|
* Registers a component with the Eleva instance.
|
|
97
121
|
*
|
|
98
122
|
* @param {string} name - The name of the component.
|
|
99
|
-
* @param {
|
|
123
|
+
* @param {ComponentDefinition} definition - The component definition including setup, template, style, and children.
|
|
100
124
|
* @returns {Eleva} The Eleva instance (for chaining).
|
|
101
125
|
*/
|
|
102
|
-
component(name: string, definition:
|
|
126
|
+
component(name: string, definition: ComponentDefinition): Eleva;
|
|
103
127
|
/**
|
|
104
128
|
* Mounts a registered component to a DOM element.
|
|
105
129
|
*
|
|
106
|
-
* @param {
|
|
107
|
-
* @param {string} compName - The name of the component to mount.
|
|
108
|
-
* @param {
|
|
130
|
+
* @param {HTMLElement} container - A DOM element where the component will be mounted.
|
|
131
|
+
* @param {string|ComponentDefinition} compName - The name of the component to mount or a component definition.
|
|
132
|
+
* @param {Object<string, any>} [props={}] - Optional properties to pass to the component.
|
|
109
133
|
* @returns {object|Promise<object>} An object representing the mounted component instance, or a Promise that resolves to it for asynchronous setups.
|
|
110
|
-
* @throws
|
|
134
|
+
* @throws {Error} If the container is not found or if the component is not registered.
|
|
111
135
|
*/
|
|
112
|
-
mount(
|
|
136
|
+
mount(container: HTMLElement, compName: string | ComponentDefinition, props?: {
|
|
137
|
+
[x: string]: any;
|
|
138
|
+
}): object | Promise<object>;
|
|
113
139
|
/**
|
|
114
140
|
* Prepares default no-operation lifecycle hook functions.
|
|
115
141
|
*
|
|
116
|
-
* @returns {
|
|
142
|
+
* @returns {Object<string, function(): void>} An object with keys for lifecycle hooks mapped to empty functions.
|
|
117
143
|
* @private
|
|
118
144
|
*/
|
|
119
145
|
private _prepareLifecycleHooks;
|
|
@@ -121,7 +147,7 @@ declare class Eleva {
|
|
|
121
147
|
* Processes DOM elements for event binding based on attributes starting with "@".
|
|
122
148
|
*
|
|
123
149
|
* @param {HTMLElement} container - The container element in which to search for events.
|
|
124
|
-
* @param {
|
|
150
|
+
* @param {Object<string, any>} context - The current context containing event handler definitions.
|
|
125
151
|
* @private
|
|
126
152
|
*/
|
|
127
153
|
private _processEvents;
|
|
@@ -130,8 +156,8 @@ declare class Eleva {
|
|
|
130
156
|
*
|
|
131
157
|
* @param {HTMLElement} container - The container element.
|
|
132
158
|
* @param {string} compName - The component name used to identify the style element.
|
|
133
|
-
* @param {
|
|
134
|
-
* @param {
|
|
159
|
+
* @param {function(Object<string, any>): string} [styleFn] - A function that returns CSS styles as a string.
|
|
160
|
+
* @param {Object<string, any>} context - The current context for style interpolation.
|
|
135
161
|
* @private
|
|
136
162
|
*/
|
|
137
163
|
private _injectStyles;
|
|
@@ -139,12 +165,42 @@ declare class Eleva {
|
|
|
139
165
|
* Mounts child components within the parent component's container.
|
|
140
166
|
*
|
|
141
167
|
* @param {HTMLElement} container - The parent container element.
|
|
142
|
-
* @param {
|
|
143
|
-
* @param {Array} childInstances - An array to store the mounted child component instances.
|
|
168
|
+
* @param {Object<string, ComponentDefinition>} [children] - An object mapping child component selectors to their definitions.
|
|
169
|
+
* @param {Array<object>} childInstances - An array to store the mounted child component instances.
|
|
144
170
|
* @private
|
|
145
171
|
*/
|
|
146
172
|
private _mountChildren;
|
|
147
173
|
}
|
|
174
|
+
type ComponentDefinition = {
|
|
175
|
+
/**
|
|
176
|
+
* A setup function that initializes the component state and returns an object or a promise that resolves to an object.
|
|
177
|
+
*/
|
|
178
|
+
setup?: ((arg0: {
|
|
179
|
+
[x: string]: any;
|
|
180
|
+
}) => ({
|
|
181
|
+
[x: string]: any;
|
|
182
|
+
} | Promise<{
|
|
183
|
+
[x: string]: any;
|
|
184
|
+
}>)) | undefined;
|
|
185
|
+
/**
|
|
186
|
+
* A function that returns the HTML template string for the component.
|
|
187
|
+
*/
|
|
188
|
+
template: (arg0: {
|
|
189
|
+
[x: string]: any;
|
|
190
|
+
}) => string;
|
|
191
|
+
/**
|
|
192
|
+
* An optional function that returns scoped CSS styles as a string.
|
|
193
|
+
*/
|
|
194
|
+
style?: ((arg0: {
|
|
195
|
+
[x: string]: any;
|
|
196
|
+
}) => string) | undefined;
|
|
197
|
+
/**
|
|
198
|
+
* An optional mapping of CSS selectors to child component definitions.
|
|
199
|
+
*/
|
|
200
|
+
children?: {
|
|
201
|
+
[x: string]: ComponentDefinition;
|
|
202
|
+
} | undefined;
|
|
203
|
+
};
|
|
148
204
|
|
|
149
205
|
//# sourceMappingURL=index.d.ts.map
|
|
150
206
|
|