eleva 1.1.0-alpha → 1.2.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 +32 -20
- package/dist/eleva.d.ts +42 -81
- package/dist/eleva.esm.js +52 -13
- 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 +52 -13
- package/dist/eleva.umd.js.map +1 -1
- package/package.json +2 -1
- package/src/core/Eleva.js +47 -12
- package/src/modules/Emitter.js +1 -1
- package/src/modules/Signal.js +2 -0
- package/types/core/Eleva.d.ts +42 -19
- package/types/core/Eleva.d.ts.map +1 -1
- package/types/modules/Emitter.d.ts +1 -1
- package/types/modules/Emitter.d.ts.map +1 -1
- package/types/modules/Signal.d.ts +4 -2
- package/types/modules/Signal.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
# Eleva
|
|
1
|
+
# Eleva 🚀
|
|
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
|
|
|
6
5
|
[](https://opensource.org/licenses/MIT)
|
|
7
6
|
[](https://www.npmjs.com/package/eleva)
|
|
@@ -10,12 +9,15 @@ _Built with love for native JavaScript—because sometimes, less really is more!
|
|
|
10
9
|
[](https://bundlephobia.com/package/eleva@latest)
|
|
11
10
|
[](https://bundlephobia.com/package/eleva@latest)
|
|
12
11
|
|
|
12
|
+
**A minimalist, lightweight, pure vanilla JavaScript frontend runtime framework.**
|
|
13
|
+
_Built with love for native JavaScript—because sometimes, less really is more!_ 😊
|
|
14
|
+
|
|
13
15
|
<!-- [](https://www.jsdelivr.com/package/npm/eleva) -->
|
|
14
16
|
|
|
15
|
-
> **Stability Notice**: This is `v1.
|
|
17
|
+
> **Stability Notice**: This is `v1.2.0-alpha` - APIs may change significantly until the stable release.
|
|
16
18
|
> Not recommended for production use yet. Follow the [versioning guide](#version-guide) for updates.
|
|
17
19
|
|
|
18
|
-
**Version:** `1.
|
|
20
|
+
**Version:** `1.2.0-alpha`
|
|
19
21
|
|
|
20
22
|
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. 🚀
|
|
21
23
|
|
|
@@ -23,7 +25,7 @@ Welcome to Eleva! This is my humble, experimental playground for a fresh approac
|
|
|
23
25
|
|
|
24
26
|
## Table of Contents
|
|
25
27
|
|
|
26
|
-
- [Eleva](#eleva)
|
|
28
|
+
- [Eleva 🚀](#eleva-)
|
|
27
29
|
- [Table of Contents](#table-of-contents)
|
|
28
30
|
- [Introduction](#introduction)
|
|
29
31
|
- [Design Philosophy](#design-philosophy)
|
|
@@ -127,9 +129,9 @@ Eleva is ideal for developers seeking a lightweight, flexible, and high-performa
|
|
|
127
129
|
|
|
128
130
|
I believe in clear versioning that reflects the maturity of the project:
|
|
129
131
|
|
|
130
|
-
- **Pre-release Versions (Alpha/Beta):** Early versions like `1.
|
|
132
|
+
- **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!
|
|
131
133
|
- **Semantic Versioning:** Once stable, I’ll follow semantic versioning strictly to clearly communicate any breaking changes.
|
|
132
|
-
- **Fresh Start:** This release (`1.
|
|
134
|
+
- **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.
|
|
133
135
|
|
|
134
136
|
---
|
|
135
137
|
|
|
@@ -138,9 +140,9 @@ I believe in clear versioning that reflects the maturity of the project:
|
|
|
138
140
|
I follow [Semantic Versioning (SemVer)](https://semver.org/):
|
|
139
141
|
|
|
140
142
|
- **🔢 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.
|
|
143
|
+
- **🔢 Minor Version:** New features in a backward-compatible manner (e.g., from `1.1.0` to `1.2.0`).
|
|
142
144
|
- **🔢 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.
|
|
145
|
+
- **📌 Pre-release Identifiers:** Suffixes like `-alpha`, `-beta`, or `-rc` denote unstable releases (e.g., `1.2.0-alpha`).
|
|
144
146
|
|
|
145
147
|
---
|
|
146
148
|
|
|
@@ -148,7 +150,7 @@ I follow [Semantic Versioning (SemVer)](https://semver.org/):
|
|
|
148
150
|
|
|
149
151
|
Eleva is crafted for performance:
|
|
150
152
|
|
|
151
|
-
- **Lightweight:** Approximately ~4 KB minified and ~1.
|
|
153
|
+
- **Lightweight:** Approximately ~4 KB minified and ~1.8 KB gzipped.
|
|
152
154
|
- **Efficient Reactivity:** Signal-based updates ensure only necessary DOM parts are updated.
|
|
153
155
|
- **Optimized Diffing:** Renderer efficiently patches changes without the overhead of a virtual DOM.
|
|
154
156
|
- **No Bloat:** Pure vanilla JavaScript with zero dependencies keeps your project nimble.
|
|
@@ -226,8 +228,8 @@ app.component("HelloWorld", {
|
|
|
226
228
|
template: ({ count }) => `
|
|
227
229
|
<div>
|
|
228
230
|
<h1>Hello, Eleva! 👋</h1>
|
|
229
|
-
<p>Count: ${count}</p>
|
|
230
|
-
<button @click="() => count++">Increment</button>
|
|
231
|
+
<p>Count: ${count.value}</p>
|
|
232
|
+
<button @click="() => count.value++">Increment</button>
|
|
231
233
|
</div>
|
|
232
234
|
`,
|
|
233
235
|
});
|
|
@@ -236,6 +238,8 @@ app.component("HelloWorld", {
|
|
|
236
238
|
app.mount(document.getElementById("app"), "HelloWorld");
|
|
237
239
|
```
|
|
238
240
|
|
|
241
|
+
Interactive Demo: [CodePen](https://codepen.io/tarekraafat/pen/GgRrxdY?editors=1010)
|
|
242
|
+
|
|
239
243
|
### UMD Example
|
|
240
244
|
|
|
241
245
|
Include Eleva via a script tag and use the global variable:
|
|
@@ -260,8 +264,8 @@ Include Eleva via a script tag and use the global variable:
|
|
|
260
264
|
template: ({ count }) => `
|
|
261
265
|
<div>
|
|
262
266
|
<h1>Hello, Eleva! 👋</h1>
|
|
263
|
-
<p>Count: ${count}</p>
|
|
264
|
-
<button @click="() => count++">Increment</button>
|
|
267
|
+
<p>Count: ${count.value}</p>
|
|
268
|
+
<button @click="() => count.value++">Increment</button>
|
|
265
269
|
</div>
|
|
266
270
|
`,
|
|
267
271
|
});
|
|
@@ -271,6 +275,8 @@ Include Eleva via a script tag and use the global variable:
|
|
|
271
275
|
</html>
|
|
272
276
|
```
|
|
273
277
|
|
|
278
|
+
Interactive Demo: [CodePen](https://codepen.io/tarekraafat/pen/jEOyzYN?editors=1010)
|
|
279
|
+
|
|
274
280
|
---
|
|
275
281
|
|
|
276
282
|
## API Reference
|
|
@@ -303,11 +309,11 @@ Include Eleva via a script tag and use the global variable:
|
|
|
303
309
|
### Renderer
|
|
304
310
|
|
|
305
311
|
- **`patchDOM(container, newHtml)`**
|
|
306
|
-
Efficiently
|
|
312
|
+
Efficiently updates the DOM.
|
|
307
313
|
- **`diff(oldParent, newParent)`**
|
|
308
|
-
|
|
314
|
+
Compares and updates DOM trees.
|
|
309
315
|
- **`updateAttributes(oldEl, newEl)`**
|
|
310
|
-
|
|
316
|
+
Synchronizes element attributes.
|
|
311
317
|
|
|
312
318
|
### Eleva (Core)
|
|
313
319
|
|
|
@@ -319,7 +325,7 @@ Include Eleva via a script tag and use the global variable:
|
|
|
319
325
|
Register a component.
|
|
320
326
|
- **`.mount(container, compName, props)`**
|
|
321
327
|
Mount a component to the DOM.
|
|
322
|
-
_Note:_
|
|
328
|
+
_Note:_ The mounting context now includes an `emitter` property (the full event emitter instance) for simplified event handling. Use `context.emitter.on(...)` and `context.emitter.emit(...)` for event management.
|
|
323
329
|
|
|
324
330
|
For detailed API documentation, please check the [docs](docs/index.md) folder.
|
|
325
331
|
|
|
@@ -348,7 +354,7 @@ I welcome developers to dive in and experiment with Eleva! Here’s how to get s
|
|
|
348
354
|
npm run dev
|
|
349
355
|
```
|
|
350
356
|
|
|
351
|
-
4. **Build for Production:**
|
|
357
|
+
4. **Build for Production without TypeScript Declarations:**
|
|
352
358
|
|
|
353
359
|
```bash
|
|
354
360
|
npm run build
|
|
@@ -361,6 +367,12 @@ I welcome developers to dive in and experiment with Eleva! Here’s how to get s
|
|
|
361
367
|
npm run build:types:bundle
|
|
362
368
|
```
|
|
363
369
|
|
|
370
|
+
6. **Build for Production with TypeScript Declarations:**
|
|
371
|
+
|
|
372
|
+
```bash
|
|
373
|
+
npm run build:all
|
|
374
|
+
```
|
|
375
|
+
|
|
364
376
|
---
|
|
365
377
|
|
|
366
378
|
## Testing
|
package/dist/eleva.d.ts
CHANGED
|
@@ -1,77 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
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
|
-
*/
|
|
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(...any): void} handler - The function to call when the event is emitted.
|
|
17
|
-
*/
|
|
18
|
-
on(event: string, handler: (...args: any[]) => void): void;
|
|
19
|
-
/**
|
|
20
|
-
* Removes a previously registered event handler.
|
|
21
|
-
*
|
|
22
|
-
* @param {string} event - The name of the event.
|
|
23
|
-
* @param {function(...any): void} handler - The handler function to remove.
|
|
24
|
-
*/
|
|
25
|
-
off(event: string, handler: (...args: any[]) => void): void;
|
|
26
|
-
/**
|
|
27
|
-
* Emits an event, invoking all handlers registered for that event.
|
|
28
|
-
*
|
|
29
|
-
* @param {string} event - The event name.
|
|
30
|
-
* @param {...any} args - Additional arguments to pass to the event handlers.
|
|
31
|
-
*/
|
|
32
|
-
emit(event: string, ...args: any[]): void;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @class 🎨 Renderer
|
|
37
|
-
* @classdesc Handles DOM patching, diffing, and attribute updates.
|
|
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
|
-
/**
|
|
2
|
+
* Defines the structure and behavior of a component.
|
|
66
3
|
* @typedef {Object} ComponentDefinition
|
|
67
4
|
* @property {function(Object<string, any>): (Object<string, any>|Promise<Object<string, any>>)} [setup]
|
|
68
|
-
*
|
|
5
|
+
* Optional setup function that initializes the component's reactive state and lifecycle.
|
|
6
|
+
* Receives props and context as an argument and should return an object containing the component's state.
|
|
7
|
+
* Can return either a synchronous object or a Promise that resolves to an object for async initialization.
|
|
8
|
+
*
|
|
69
9
|
* @property {function(Object<string, any>): string} template
|
|
70
|
-
*
|
|
10
|
+
* Required function that defines the component's HTML structure.
|
|
11
|
+
* Receives the merged context (props + setup data) and must return an HTML template string.
|
|
12
|
+
* Supports dynamic expressions using {{ }} syntax for reactive data binding.
|
|
13
|
+
*
|
|
71
14
|
* @property {function(Object<string, any>): string} [style]
|
|
72
|
-
*
|
|
15
|
+
* Optional function that defines component-scoped CSS styles.
|
|
16
|
+
* Receives the merged context and returns a CSS string that will be automatically scoped to the component.
|
|
17
|
+
* Styles are injected into the component's container and only affect elements within it.
|
|
18
|
+
*
|
|
73
19
|
* @property {Object<string, ComponentDefinition>} [children]
|
|
74
|
-
*
|
|
20
|
+
* Optional object that defines nested child components.
|
|
21
|
+
* Keys are CSS selectors that match elements in the template where child components should be mounted.
|
|
22
|
+
* Values are ComponentDefinition objects that define the structure and behavior of each child component.
|
|
75
23
|
*/
|
|
76
24
|
/**
|
|
77
25
|
* @class 🧩 Eleva
|
|
@@ -88,24 +36,26 @@ declare class Eleva {
|
|
|
88
36
|
constructor(name: string, config?: {
|
|
89
37
|
[x: string]: any;
|
|
90
38
|
});
|
|
91
|
-
/** @type {string} */
|
|
39
|
+
/** @type {string} The unique identifier name for this Eleva instance */
|
|
92
40
|
name: string;
|
|
93
|
-
/** @type {Object<string, any>} */
|
|
41
|
+
/** @type {Object<string, any>} Optional configuration object for the Eleva instance */
|
|
94
42
|
config: {
|
|
95
43
|
[x: string]: any;
|
|
96
44
|
};
|
|
97
|
-
/** @type {Object<string, ComponentDefinition>} */
|
|
45
|
+
/** @type {Object<string, ComponentDefinition>} Object storing registered component definitions by name */
|
|
98
46
|
_components: {
|
|
99
47
|
[x: string]: ComponentDefinition;
|
|
100
48
|
};
|
|
101
|
-
/** @
|
|
102
|
-
_plugins
|
|
103
|
-
/** @private */
|
|
49
|
+
/** @private {Array<Object>} Collection of installed plugin instances */
|
|
50
|
+
private _plugins;
|
|
51
|
+
/** @private {string[]} Array of lifecycle hook names supported by the component */
|
|
104
52
|
private _lifecycleHooks;
|
|
105
|
-
/** @private {boolean} */
|
|
53
|
+
/** @private {boolean} Flag indicating if component is currently mounted */
|
|
106
54
|
private _isMounted;
|
|
107
|
-
emitter
|
|
108
|
-
|
|
55
|
+
/** @private {Emitter} Instance of the event emitter for handling component events */
|
|
56
|
+
private emitter;
|
|
57
|
+
/** @private {Renderer} Instance of the renderer for handling DOM updates and patching */
|
|
58
|
+
private renderer;
|
|
109
59
|
/**
|
|
110
60
|
* Integrates a plugin with the Eleva framework.
|
|
111
61
|
*
|
|
@@ -171,9 +121,14 @@ declare class Eleva {
|
|
|
171
121
|
*/
|
|
172
122
|
private _mountChildren;
|
|
173
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Defines the structure and behavior of a component.
|
|
126
|
+
*/
|
|
174
127
|
type ComponentDefinition = {
|
|
175
128
|
/**
|
|
176
|
-
*
|
|
129
|
+
* Optional setup function that initializes the component's reactive state and lifecycle.
|
|
130
|
+
* Receives props and context as an argument and should return an object containing the component's state.
|
|
131
|
+
* Can return either a synchronous object or a Promise that resolves to an object for async initialization.
|
|
177
132
|
*/
|
|
178
133
|
setup?: ((arg0: {
|
|
179
134
|
[x: string]: any;
|
|
@@ -183,19 +138,25 @@ type ComponentDefinition = {
|
|
|
183
138
|
[x: string]: any;
|
|
184
139
|
}>)) | undefined;
|
|
185
140
|
/**
|
|
186
|
-
*
|
|
141
|
+
* Required function that defines the component's HTML structure.
|
|
142
|
+
* Receives the merged context (props + setup data) and must return an HTML template string.
|
|
143
|
+
* Supports dynamic expressions using {{ }} syntax for reactive data binding.
|
|
187
144
|
*/
|
|
188
145
|
template: (arg0: {
|
|
189
146
|
[x: string]: any;
|
|
190
147
|
}) => string;
|
|
191
148
|
/**
|
|
192
|
-
*
|
|
149
|
+
* Optional function that defines component-scoped CSS styles.
|
|
150
|
+
* Receives the merged context and returns a CSS string that will be automatically scoped to the component.
|
|
151
|
+
* Styles are injected into the component's container and only affect elements within it.
|
|
193
152
|
*/
|
|
194
153
|
style?: ((arg0: {
|
|
195
154
|
[x: string]: any;
|
|
196
155
|
}) => string) | undefined;
|
|
197
156
|
/**
|
|
198
|
-
*
|
|
157
|
+
* Optional object that defines nested child components.
|
|
158
|
+
* Keys are CSS selectors that match elements in the template where child components should be mounted.
|
|
159
|
+
* Values are ComponentDefinition objects that define the structure and behavior of each child component.
|
|
199
160
|
*/
|
|
200
161
|
children?: {
|
|
201
162
|
[x: string]: ComponentDefinition;
|
package/dist/eleva.esm.js
CHANGED
|
@@ -56,7 +56,9 @@ class Signal {
|
|
|
56
56
|
* @param {*} value - The initial value of the signal.
|
|
57
57
|
*/
|
|
58
58
|
constructor(value) {
|
|
59
|
+
/** @private {*} Internal storage for the signal's current value */
|
|
59
60
|
this._value = value;
|
|
61
|
+
/** @private {Set<function>} Collection of callback functions to be notified when value changes */
|
|
60
62
|
this._watchers = new Set();
|
|
61
63
|
}
|
|
62
64
|
|
|
@@ -104,7 +106,7 @@ class Emitter {
|
|
|
104
106
|
* Creates a new Emitter instance.
|
|
105
107
|
*/
|
|
106
108
|
constructor() {
|
|
107
|
-
/** @type {Object.<string, Function[]>} */
|
|
109
|
+
/** @type {Object.<string, Function[]>} Storage for event handlers mapped by event name */
|
|
108
110
|
this.events = {};
|
|
109
111
|
}
|
|
110
112
|
|
|
@@ -254,15 +256,27 @@ class Renderer {
|
|
|
254
256
|
}
|
|
255
257
|
|
|
256
258
|
/**
|
|
259
|
+
* Defines the structure and behavior of a component.
|
|
257
260
|
* @typedef {Object} ComponentDefinition
|
|
258
261
|
* @property {function(Object<string, any>): (Object<string, any>|Promise<Object<string, any>>)} [setup]
|
|
259
|
-
*
|
|
262
|
+
* Optional setup function that initializes the component's reactive state and lifecycle.
|
|
263
|
+
* Receives props and context as an argument and should return an object containing the component's state.
|
|
264
|
+
* Can return either a synchronous object or a Promise that resolves to an object for async initialization.
|
|
265
|
+
*
|
|
260
266
|
* @property {function(Object<string, any>): string} template
|
|
261
|
-
*
|
|
267
|
+
* Required function that defines the component's HTML structure.
|
|
268
|
+
* Receives the merged context (props + setup data) and must return an HTML template string.
|
|
269
|
+
* Supports dynamic expressions using {{ }} syntax for reactive data binding.
|
|
270
|
+
*
|
|
262
271
|
* @property {function(Object<string, any>): string} [style]
|
|
263
|
-
*
|
|
272
|
+
* Optional function that defines component-scoped CSS styles.
|
|
273
|
+
* Receives the merged context and returns a CSS string that will be automatically scoped to the component.
|
|
274
|
+
* Styles are injected into the component's container and only affect elements within it.
|
|
275
|
+
*
|
|
264
276
|
* @property {Object<string, ComponentDefinition>} [children]
|
|
265
|
-
*
|
|
277
|
+
* Optional object that defines nested child components.
|
|
278
|
+
* Keys are CSS selectors that match elements in the template where child components should be mounted.
|
|
279
|
+
* Values are ComponentDefinition objects that define the structure and behavior of each child component.
|
|
266
280
|
*/
|
|
267
281
|
|
|
268
282
|
/**
|
|
@@ -278,19 +292,21 @@ class Eleva {
|
|
|
278
292
|
* @param {Object<string, any>} [config={}] - Optional configuration for the instance.
|
|
279
293
|
*/
|
|
280
294
|
constructor(name, config = {}) {
|
|
281
|
-
/** @type {string} */
|
|
295
|
+
/** @type {string} The unique identifier name for this Eleva instance */
|
|
282
296
|
this.name = name;
|
|
283
|
-
/** @type {Object<string, any>} */
|
|
297
|
+
/** @type {Object<string, any>} Optional configuration object for the Eleva instance */
|
|
284
298
|
this.config = config;
|
|
285
|
-
/** @type {Object<string, ComponentDefinition>} */
|
|
299
|
+
/** @type {Object<string, ComponentDefinition>} Object storing registered component definitions by name */
|
|
286
300
|
this._components = {};
|
|
287
|
-
/** @
|
|
301
|
+
/** @private {Array<Object>} Collection of installed plugin instances */
|
|
288
302
|
this._plugins = [];
|
|
289
|
-
/** @private */
|
|
303
|
+
/** @private {string[]} Array of lifecycle hook names supported by the component */
|
|
290
304
|
this._lifecycleHooks = ["onBeforeMount", "onMount", "onBeforeUpdate", "onUpdate", "onUnmount"];
|
|
291
|
-
/** @private {boolean} */
|
|
305
|
+
/** @private {boolean} Flag indicating if component is currently mounted */
|
|
292
306
|
this._isMounted = false;
|
|
307
|
+
/** @private {Emitter} Instance of the event emitter for handling component events */
|
|
293
308
|
this.emitter = new Emitter();
|
|
309
|
+
/** @private {Renderer} Instance of the renderer for handling DOM updates and patching */
|
|
294
310
|
this.renderer = new Renderer();
|
|
295
311
|
}
|
|
296
312
|
|
|
@@ -341,16 +357,33 @@ class Eleva {
|
|
|
341
357
|
} else {
|
|
342
358
|
throw new Error("Invalid component parameter.");
|
|
343
359
|
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Destructure the component definition to access core functionality.
|
|
363
|
+
* - setup: Optional function for component initialization and state management
|
|
364
|
+
* - template: Required function that returns the component's HTML structure
|
|
365
|
+
* - style: Optional function for component-scoped CSS styles
|
|
366
|
+
* - children: Optional object defining nested child components
|
|
367
|
+
*/
|
|
344
368
|
const {
|
|
345
369
|
setup,
|
|
346
370
|
template,
|
|
347
371
|
style,
|
|
348
372
|
children
|
|
349
373
|
} = definition;
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Creates the initial context object for the component instance.
|
|
377
|
+
* This context provides core functionality and will be merged with setup data.
|
|
378
|
+
* @type {Object<string, any>}
|
|
379
|
+
* @property {Object<string, any>} props - Component properties passed during mounting
|
|
380
|
+
* @property {Emitter} emitter - Event emitter instance for component event handling
|
|
381
|
+
* @property {function(any): Signal} signal - Factory function to create reactive Signal instances
|
|
382
|
+
* @property {Object<string, function(): void>} ...lifecycleHooks - Prepared lifecycle hook functions
|
|
383
|
+
*/
|
|
350
384
|
const context = {
|
|
351
385
|
props,
|
|
352
|
-
|
|
353
|
-
on: this.emitter.on.bind(this.emitter),
|
|
386
|
+
emitter: this.emitter,
|
|
354
387
|
signal: v => new Signal(v),
|
|
355
388
|
...this._prepareLifecycleHooks()
|
|
356
389
|
};
|
|
@@ -391,6 +424,12 @@ class Eleva {
|
|
|
391
424
|
mergedContext.onUpdate && mergedContext.onUpdate();
|
|
392
425
|
}
|
|
393
426
|
};
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Sets up reactive watchers for all Signal instances in the component's data.
|
|
430
|
+
* When a Signal's value changes, the component will re-render to reflect the updates.
|
|
431
|
+
* Stores unsubscribe functions to clean up watchers when component unmounts.
|
|
432
|
+
*/
|
|
394
433
|
Object.values(data).forEach(val => {
|
|
395
434
|
if (val instanceof Signal) watcherUnsubscribers.push(val.watch(render));
|
|
396
435
|
});
|
package/dist/eleva.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eleva.esm.js","sources":["../src/modules/TemplateEngine.js","../src/modules/Signal.js","../src/modules/Emitter.js","../src/modules/Renderer.js","../src/core/Eleva.js"],"sourcesContent":["\"use strict\";\n\n/**\n * @class 🔒 TemplateEngine\n * @classdesc Secure interpolation & dynamic attribute parsing.\n * Provides methods to parse template strings by replacing interpolation expressions\n * with dynamic data values and to evaluate expressions within a given data context.\n */\nexport class TemplateEngine {\n /**\n * Parses a template string and replaces interpolation expressions with corresponding values.\n *\n * @param {string} template - The template string containing expressions in the format `{{ expression }}`.\n * @param {Object<string, any>} data - The data object to use for evaluating expressions.\n * @returns {string} The resulting string with evaluated values.\n */\n static parse(template, data) {\n return template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, expr) => {\n const value = this.evaluate(expr, data);\n return value === undefined ? \"\" : value;\n });\n }\n\n /**\n * Evaluates a JavaScript expression using the provided data context.\n *\n * @param {string} expr - The JavaScript expression to evaluate.\n * @param {Object<string, any>} data - The data context for evaluating the expression.\n * @returns {any} The result of the evaluated expression, or an empty string if undefined or on error.\n */\n static evaluate(expr, data) {\n try {\n const keys = Object.keys(data);\n const values = Object.values(data);\n const result = new Function(...keys, `return ${expr}`)(...values);\n return result === undefined ? \"\" : result;\n } catch (error) {\n console.error(`Template evaluation error:`, {\n expression: expr,\n data,\n error: error.message,\n });\n return \"\";\n }\n }\n}\n","\"use strict\";\n\n/**\n * @class ⚡ Signal\n * @classdesc Fine-grained reactivity.\n * A reactive data holder that notifies registered watchers when its value changes,\n * enabling fine-grained DOM patching rather than full re-renders.\n */\nexport class Signal {\n /**\n * Creates a new Signal instance.\n *\n * @param {*} value - The initial value of the signal.\n */\n constructor(value) {\n this._value = value;\n this._watchers = new Set();\n }\n\n /**\n * Gets the current value of the signal.\n *\n * @returns {*} The current value.\n */\n get value() {\n return this._value;\n }\n\n /**\n * Sets a new value for the signal and notifies all registered watchers if the value has changed.\n *\n * @param {*} newVal - The new value to set.\n */\n set value(newVal) {\n if (newVal !== this._value) {\n this._value = newVal;\n this._watchers.forEach((fn) => fn(newVal));\n }\n }\n\n /**\n * Registers a watcher function that will be called whenever the signal's value changes.\n *\n * @param {function(any): void} fn - The callback function to invoke on value change.\n * @returns {function(): boolean} A function to unsubscribe the watcher.\n */\n watch(fn) {\n this._watchers.add(fn);\n return () => this._watchers.delete(fn);\n }\n}\n","\"use strict\";\n\n/**\n * @class 🎙️ Emitter\n * @classdesc Robust inter-component communication with event bubbling.\n * Implements a basic publish-subscribe pattern for event handling, allowing components\n * to communicate through custom events.\n */\nexport class Emitter {\n /**\n * Creates a new Emitter instance.\n */\n constructor() {\n /** @type {Object.<string, Function[]>} */\n this.events = {};\n }\n\n /**\n * Registers an event handler for the specified event.\n *\n * @param {string} event - The name of the event.\n * @param {function(...any): void} handler - The function to call when the event is emitted.\n */\n on(event, handler) {\n (this.events[event] || (this.events[event] = [])).push(handler);\n }\n\n /**\n * Removes a previously registered event handler.\n *\n * @param {string} event - The name of the event.\n * @param {function(...any): void} handler - The handler function to remove.\n */\n off(event, handler) {\n if (this.events[event]) {\n this.events[event] = this.events[event].filter((h) => h !== handler);\n }\n }\n\n /**\n * Emits an event, invoking all handlers registered for that event.\n *\n * @param {string} event - The event name.\n * @param {...any} args - Additional arguments to pass to the event handlers.\n */\n emit(event, ...args) {\n (this.events[event] || []).forEach((handler) => handler(...args));\n }\n}\n","\"use strict\";\n\n/**\n * @class 🎨 Renderer\n * @classdesc Handles DOM patching, diffing, and attribute updates.\n * Provides methods for efficient DOM updates by diffing the new and old DOM structures\n * and applying only the necessary changes.\n */\nexport class Renderer {\n /**\n * Patches the DOM of a container element with new HTML content.\n *\n * @param {HTMLElement} container - The container element to patch.\n * @param {string} newHtml - The new HTML content to apply.\n */\n patchDOM(container, newHtml) {\n const tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = newHtml;\n this.diff(container, tempContainer);\n }\n\n /**\n * Diffs two DOM trees (old and new) and applies updates to the old DOM.\n *\n * @param {HTMLElement} oldParent - The original DOM element.\n * @param {HTMLElement} newParent - The new DOM element.\n */\n diff(oldParent, newParent) {\n const oldNodes = Array.from(oldParent.childNodes);\n const newNodes = Array.from(newParent.childNodes);\n const max = Math.max(oldNodes.length, newNodes.length);\n for (let i = 0; i < max; i++) {\n const oldNode = oldNodes[i];\n const newNode = newNodes[i];\n\n // Case 1: Append new nodes that don't exist in the old tree.\n if (!oldNode && newNode) {\n oldParent.appendChild(newNode.cloneNode(true));\n continue;\n }\n // Case 2: Remove old nodes not present in the new tree.\n if (oldNode && !newNode) {\n oldParent.removeChild(oldNode);\n continue;\n }\n\n // Case 3: For element nodes, compare keys if available.\n if (\n oldNode.nodeType === Node.ELEMENT_NODE &&\n newNode.nodeType === Node.ELEMENT_NODE\n ) {\n const oldKey = oldNode.getAttribute(\"key\");\n const newKey = newNode.getAttribute(\"key\");\n if (oldKey || newKey) {\n if (oldKey !== newKey) {\n oldParent.replaceChild(newNode.cloneNode(true), oldNode);\n continue;\n }\n }\n }\n\n // Case 4: Replace nodes if types or tag names differ.\n if (\n oldNode.nodeType !== newNode.nodeType ||\n oldNode.nodeName !== newNode.nodeName\n ) {\n oldParent.replaceChild(newNode.cloneNode(true), oldNode);\n continue;\n }\n // Case 5: For text nodes, update content if different.\n if (oldNode.nodeType === Node.TEXT_NODE) {\n if (oldNode.nodeValue !== newNode.nodeValue) {\n oldNode.nodeValue = newNode.nodeValue;\n }\n continue;\n }\n // Case 6: For element nodes, update attributes and then diff children.\n if (oldNode.nodeType === Node.ELEMENT_NODE) {\n this.updateAttributes(oldNode, newNode);\n this.diff(oldNode, newNode);\n }\n }\n }\n\n /**\n * Updates the attributes of an element to match those of a new element.\n *\n * @param {HTMLElement} oldEl - The element to update.\n * @param {HTMLElement} newEl - The element providing the updated attributes.\n */\n updateAttributes(oldEl, newEl) {\n const attributeToPropertyMap = {\n value: \"value\",\n checked: \"checked\",\n selected: \"selected\",\n disabled: \"disabled\",\n };\n\n // Remove old attributes that no longer exist.\n Array.from(oldEl.attributes).forEach((attr) => {\n if (attr.name.startsWith(\"@\")) return;\n if (!newEl.hasAttribute(attr.name)) {\n oldEl.removeAttribute(attr.name);\n }\n });\n // Add or update attributes from newEl.\n Array.from(newEl.attributes).forEach((attr) => {\n if (attr.name.startsWith(\"@\")) return;\n if (oldEl.getAttribute(attr.name) !== attr.value) {\n oldEl.setAttribute(attr.name, attr.value);\n if (attributeToPropertyMap[attr.name]) {\n oldEl[attributeToPropertyMap[attr.name]] = attr.value;\n } else if (attr.name in oldEl) {\n oldEl[attr.name] = attr.value;\n }\n }\n });\n }\n}\n","\"use strict\";\n\nimport { TemplateEngine } from \"../modules/TemplateEngine.js\";\nimport { Signal } from \"../modules/Signal.js\";\nimport { Emitter } from \"../modules/Emitter.js\";\nimport { Renderer } from \"../modules/Renderer.js\";\n\n/**\n * @typedef {Object} ComponentDefinition\n * @property {function(Object<string, any>): (Object<string, any>|Promise<Object<string, any>>)} [setup]\n * A setup function that initializes the component state and returns an object or a promise that resolves to an object.\n * @property {function(Object<string, any>): string} template\n * A function that returns the HTML template string for the component.\n * @property {function(Object<string, any>): string} [style]\n * An optional function that returns scoped CSS styles as a string.\n * @property {Object<string, ComponentDefinition>} [children]\n * An optional mapping of CSS selectors to child component definitions.\n */\n\n/**\n * @class 🧩 Eleva\n * @classdesc Signal-based component runtime framework with lifecycle hooks, scoped styles, and plugin support.\n * Manages component registration, plugin integration, event handling, and DOM rendering.\n */\nexport class Eleva {\n /**\n * Creates a new Eleva instance.\n *\n * @param {string} name - The name of the Eleva instance.\n * @param {Object<string, any>} [config={}] - Optional configuration for the instance.\n */\n constructor(name, config = {}) {\n /** @type {string} */\n this.name = name;\n /** @type {Object<string, any>} */\n this.config = config;\n /** @type {Object<string, ComponentDefinition>} */\n this._components = {};\n /** @type {Array<Object>} */\n this._plugins = [];\n /** @private */\n this._lifecycleHooks = [\n \"onBeforeMount\",\n \"onMount\",\n \"onBeforeUpdate\",\n \"onUpdate\",\n \"onUnmount\",\n ];\n /** @private {boolean} */\n this._isMounted = false;\n this.emitter = new Emitter();\n this.renderer = new Renderer();\n }\n\n /**\n * Integrates a plugin with the Eleva framework.\n *\n * @param {Object} plugin - The plugin object which should have an `install` function.\n * @param {Object<string, any>} [options={}] - Optional options to pass to the plugin.\n * @returns {Eleva} The Eleva instance (for chaining).\n */\n use(plugin, options = {}) {\n if (typeof plugin.install === \"function\") {\n plugin.install(this, options);\n }\n this._plugins.push(plugin);\n return this;\n }\n\n /**\n * Registers a component with the Eleva instance.\n *\n * @param {string} name - The name of the component.\n * @param {ComponentDefinition} definition - The component definition including setup, template, style, and children.\n * @returns {Eleva} The Eleva instance (for chaining).\n */\n component(name, definition) {\n this._components[name] = definition;\n return this;\n }\n\n /**\n * Mounts a registered component to a DOM element.\n *\n * @param {HTMLElement} container - A DOM element where the component will be mounted.\n * @param {string|ComponentDefinition} compName - The name of the component to mount or a component definition.\n * @param {Object<string, any>} [props={}] - Optional properties to pass to the component.\n * @returns {object|Promise<object>} An object representing the mounted component instance, or a Promise that resolves to it for asynchronous setups.\n * @throws {Error} If the container is not found or if the component is not registered.\n */\n mount(container, compName, props = {}) {\n if (!container) throw new Error(`Container not found: ${container}`);\n\n let definition;\n if (typeof compName === \"string\") {\n definition = this._components[compName];\n if (!definition)\n throw new Error(`Component \"${compName}\" not registered.`);\n } else if (typeof compName === \"object\") {\n definition = compName;\n } else {\n throw new Error(\"Invalid component parameter.\");\n }\n\n const { setup, template, style, children } = definition;\n const context = {\n props,\n emit: this.emitter.emit.bind(this.emitter),\n on: this.emitter.on.bind(this.emitter),\n signal: (v) => new Signal(v),\n ...this._prepareLifecycleHooks(),\n };\n\n /**\n * Processes the mounting of the component.\n *\n * @param {Object<string, any>} data - Data returned from the component's setup function.\n * @returns {object} An object with the container, merged context data, and an unmount function.\n */\n const processMount = (data) => {\n const mergedContext = { ...context, ...data };\n const watcherUnsubscribers = [];\n const childInstances = [];\n\n if (!this._isMounted) {\n mergedContext.onBeforeMount && mergedContext.onBeforeMount();\n } else {\n mergedContext.onBeforeUpdate && mergedContext.onBeforeUpdate();\n }\n\n /**\n * Renders the component by parsing the template, patching the DOM,\n * processing events, injecting styles, and mounting child components.\n */\n const render = () => {\n const newHtml = TemplateEngine.parse(\n template(mergedContext),\n mergedContext\n );\n this.renderer.patchDOM(container, newHtml);\n this._processEvents(container, mergedContext);\n this._injectStyles(container, compName, style, mergedContext);\n this._mountChildren(container, children, childInstances);\n if (!this._isMounted) {\n mergedContext.onMount && mergedContext.onMount();\n this._isMounted = true;\n } else {\n mergedContext.onUpdate && mergedContext.onUpdate();\n }\n };\n\n Object.values(data).forEach((val) => {\n if (val instanceof Signal) watcherUnsubscribers.push(val.watch(render));\n });\n\n render();\n\n return {\n container,\n data: mergedContext,\n /**\n * Unmounts the component, cleaning up watchers, child components, and clearing the container.\n *\n * @returns {void}\n */\n unmount: () => {\n watcherUnsubscribers.forEach((fn) => fn());\n childInstances.forEach((child) => child.unmount());\n mergedContext.onUnmount && mergedContext.onUnmount();\n container.innerHTML = \"\";\n },\n };\n };\n\n // Handle asynchronous setup.\n return Promise.resolve(\n typeof setup === \"function\" ? setup(context) : {}\n ).then((data) => processMount(data));\n }\n\n /**\n * Prepares default no-operation lifecycle hook functions.\n *\n * @returns {Object<string, function(): void>} An object with keys for lifecycle hooks mapped to empty functions.\n * @private\n */\n _prepareLifecycleHooks() {\n return this._lifecycleHooks.reduce((acc, hook) => {\n acc[hook] = () => {};\n return acc;\n }, {});\n }\n\n /**\n * Processes DOM elements for event binding based on attributes starting with \"@\".\n *\n * @param {HTMLElement} container - The container element in which to search for events.\n * @param {Object<string, any>} context - The current context containing event handler definitions.\n * @private\n */\n _processEvents(container, context) {\n container.querySelectorAll(\"*\").forEach((el) => {\n [...el.attributes].forEach(({ name, value }) => {\n if (name.startsWith(\"@\")) {\n const event = name.slice(1);\n const handler = TemplateEngine.evaluate(value, context);\n if (typeof handler === \"function\") {\n el.addEventListener(event, handler);\n el.removeAttribute(name);\n }\n }\n });\n });\n }\n\n /**\n * Injects scoped styles into the component's container.\n *\n * @param {HTMLElement} container - The container element.\n * @param {string} compName - The component name used to identify the style element.\n * @param {function(Object<string, any>): string} [styleFn] - A function that returns CSS styles as a string.\n * @param {Object<string, any>} context - The current context for style interpolation.\n * @private\n */\n _injectStyles(container, compName, styleFn, context) {\n if (styleFn) {\n let styleEl = container.querySelector(\n `style[data-eleva-style=\"${compName}\"]`\n );\n if (!styleEl) {\n styleEl = document.createElement(\"style\");\n styleEl.setAttribute(\"data-eleva-style\", compName);\n container.appendChild(styleEl);\n }\n styleEl.textContent = TemplateEngine.parse(styleFn(context), context);\n }\n }\n\n /**\n * Mounts child components within the parent component's container.\n *\n * @param {HTMLElement} container - The parent container element.\n * @param {Object<string, ComponentDefinition>} [children] - An object mapping child component selectors to their definitions.\n * @param {Array<object>} childInstances - An array to store the mounted child component instances.\n * @private\n */\n _mountChildren(container, children, childInstances) {\n childInstances.forEach((child) => child.unmount());\n childInstances.length = 0;\n\n Object.keys(children || {}).forEach((childSelector) => {\n container.querySelectorAll(childSelector).forEach((childEl) => {\n const props = {};\n [...childEl.attributes].forEach(({ name, value }) => {\n if (name.startsWith(\"eleva-prop-\")) {\n props[name.slice(\"eleva-prop-\".length)] = value;\n }\n });\n const instance = this.mount(childEl, children[childSelector], props);\n childInstances.push(instance);\n });\n });\n }\n}\n"],"names":["TemplateEngine","parse","template","data","replace","_","expr","value","evaluate","undefined","keys","Object","values","result","Function","error","console","expression","message","Signal","constructor","_value","_watchers","Set","newVal","forEach","fn","watch","add","delete","Emitter","events","on","event","handler","push","off","filter","h","emit","args","Renderer","patchDOM","container","newHtml","tempContainer","document","createElement","innerHTML","diff","oldParent","newParent","oldNodes","Array","from","childNodes","newNodes","max","Math","length","i","oldNode","newNode","appendChild","cloneNode","removeChild","nodeType","Node","ELEMENT_NODE","oldKey","getAttribute","newKey","replaceChild","nodeName","TEXT_NODE","nodeValue","updateAttributes","oldEl","newEl","attributeToPropertyMap","checked","selected","disabled","attributes","attr","name","startsWith","hasAttribute","removeAttribute","setAttribute","Eleva","config","_components","_plugins","_lifecycleHooks","_isMounted","emitter","renderer","use","plugin","options","install","component","definition","mount","compName","props","Error","setup","style","children","context","bind","signal","v","_prepareLifecycleHooks","processMount","mergedContext","watcherUnsubscribers","childInstances","onBeforeMount","onBeforeUpdate","render","_processEvents","_injectStyles","_mountChildren","onMount","onUpdate","val","unmount","child","onUnmount","Promise","resolve","then","reduce","acc","hook","querySelectorAll","el","slice","addEventListener","styleFn","styleEl","querySelector","textContent","childSelector","childEl","instance"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,cAAc,CAAC;AAC1B;AACF;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,OAAOC,KAAKA,CAACC,QAAQ,EAAEC,IAAI,EAAE;IAC3B,OAAOD,QAAQ,CAACE,OAAO,CAAC,sBAAsB,EAAE,CAACC,CAAC,EAAEC,IAAI,KAAK;MAC3D,MAAMC,KAAK,GAAG,IAAI,CAACC,QAAQ,CAACF,IAAI,EAAEH,IAAI,CAAC;AACvC,MAAA,OAAOI,KAAK,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AAK;AACnD,UAAA,IAAI8E,IAAI,CAACC,UAAU,CAAC,aAAa,CAAC,EAAE;YAClCoB,KAAK,CAACrB,IAAI,CAACuD,KAAK,CAAC,aAAa,CAACjF,MAAM,CAAC,CAAC,GAAGpD,KAAK;AACjD;AACF,SAAC,CAAC;AACF,QAAA,MAAM6I,QAAQ,GAAG,IAAI,CAAC5C,KAAK,CAAC2C,OAAO,EAAErC,QAAQ,CAACoC,aAAa,CAAC,EAAExC,KAAK,CAAC;AACpEa,QAAAA,cAAc,CAACpF,IAAI,CAACiH,QAAQ,CAAC;AAC/B,OAAC,CAAC;AACJ,KAAC,CAAC;AACJ;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"eleva.esm.js","sources":["../src/modules/TemplateEngine.js","../src/modules/Signal.js","../src/modules/Emitter.js","../src/modules/Renderer.js","../src/core/Eleva.js"],"sourcesContent":["\"use strict\";\n\n/**\n * @class 🔒 TemplateEngine\n * @classdesc Secure interpolation & dynamic attribute parsing.\n * Provides methods to parse template strings by replacing interpolation expressions\n * with dynamic data values and to evaluate expressions within a given data context.\n */\nexport class TemplateEngine {\n /**\n * Parses a template string and replaces interpolation expressions with corresponding values.\n *\n * @param {string} template - The template string containing expressions in the format `{{ expression }}`.\n * @param {Object<string, any>} data - The data object to use for evaluating expressions.\n * @returns {string} The resulting string with evaluated values.\n */\n static parse(template, data) {\n return template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, expr) => {\n const value = this.evaluate(expr, data);\n return value === undefined ? \"\" : value;\n });\n }\n\n /**\n * Evaluates a JavaScript expression using the provided data context.\n *\n * @param {string} expr - The JavaScript expression to evaluate.\n * @param {Object<string, any>} data - The data context for evaluating the expression.\n * @returns {any} The result of the evaluated expression, or an empty string if undefined or on error.\n */\n static evaluate(expr, data) {\n try {\n const keys = Object.keys(data);\n const values = Object.values(data);\n const result = new Function(...keys, `return ${expr}`)(...values);\n return result === undefined ? \"\" : result;\n } catch (error) {\n console.error(`Template evaluation error:`, {\n expression: expr,\n data,\n error: error.message,\n });\n return \"\";\n }\n }\n}\n","\"use strict\";\n\n/**\n * @class ⚡ Signal\n * @classdesc Fine-grained reactivity.\n * A reactive data holder that notifies registered watchers when its value changes,\n * enabling fine-grained DOM patching rather than full re-renders.\n */\nexport class Signal {\n /**\n * Creates a new Signal instance.\n *\n * @param {*} value - The initial value of the signal.\n */\n constructor(value) {\n /** @private {*} Internal storage for the signal's current value */\n this._value = value;\n /** @private {Set<function>} Collection of callback functions to be notified when value changes */\n this._watchers = new Set();\n }\n\n /**\n * Gets the current value of the signal.\n *\n * @returns {*} The current value.\n */\n get value() {\n return this._value;\n }\n\n /**\n * Sets a new value for the signal and notifies all registered watchers if the value has changed.\n *\n * @param {*} newVal - The new value to set.\n */\n set value(newVal) {\n if (newVal !== this._value) {\n this._value = newVal;\n this._watchers.forEach((fn) => fn(newVal));\n }\n }\n\n /**\n * Registers a watcher function that will be called whenever the signal's value changes.\n *\n * @param {function(any): void} fn - The callback function to invoke on value change.\n * @returns {function(): boolean} A function to unsubscribe the watcher.\n */\n watch(fn) {\n this._watchers.add(fn);\n return () => this._watchers.delete(fn);\n }\n}\n","\"use strict\";\n\n/**\n * @class 🎙️ Emitter\n * @classdesc Robust inter-component communication with event bubbling.\n * Implements a basic publish-subscribe pattern for event handling, allowing components\n * to communicate through custom events.\n */\nexport class Emitter {\n /**\n * Creates a new Emitter instance.\n */\n constructor() {\n /** @type {Object.<string, Function[]>} Storage for event handlers mapped by event name */\n this.events = {};\n }\n\n /**\n * Registers an event handler for the specified event.\n *\n * @param {string} event - The name of the event.\n * @param {function(...any): void} handler - The function to call when the event is emitted.\n */\n on(event, handler) {\n (this.events[event] || (this.events[event] = [])).push(handler);\n }\n\n /**\n * Removes a previously registered event handler.\n *\n * @param {string} event - The name of the event.\n * @param {function(...any): void} handler - The handler function to remove.\n */\n off(event, handler) {\n if (this.events[event]) {\n this.events[event] = this.events[event].filter((h) => h !== handler);\n }\n }\n\n /**\n * Emits an event, invoking all handlers registered for that event.\n *\n * @param {string} event - The event name.\n * @param {...any} args - Additional arguments to pass to the event handlers.\n */\n emit(event, ...args) {\n (this.events[event] || []).forEach((handler) => handler(...args));\n }\n}\n","\"use strict\";\n\n/**\n * @class 🎨 Renderer\n * @classdesc Handles DOM patching, diffing, and attribute updates.\n * Provides methods for efficient DOM updates by diffing the new and old DOM structures\n * and applying only the necessary changes.\n */\nexport class Renderer {\n /**\n * Patches the DOM of a container element with new HTML content.\n *\n * @param {HTMLElement} container - The container element to patch.\n * @param {string} newHtml - The new HTML content to apply.\n */\n patchDOM(container, newHtml) {\n const tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = newHtml;\n this.diff(container, tempContainer);\n }\n\n /**\n * Diffs two DOM trees (old and new) and applies updates to the old DOM.\n *\n * @param {HTMLElement} oldParent - The original DOM element.\n * @param {HTMLElement} newParent - The new DOM element.\n */\n diff(oldParent, newParent) {\n const oldNodes = Array.from(oldParent.childNodes);\n const newNodes = Array.from(newParent.childNodes);\n const max = Math.max(oldNodes.length, newNodes.length);\n for (let i = 0; i < max; i++) {\n const oldNode = oldNodes[i];\n const newNode = newNodes[i];\n\n // Case 1: Append new nodes that don't exist in the old tree.\n if (!oldNode && newNode) {\n oldParent.appendChild(newNode.cloneNode(true));\n continue;\n }\n // Case 2: Remove old nodes not present in the new tree.\n if (oldNode && !newNode) {\n oldParent.removeChild(oldNode);\n continue;\n }\n\n // Case 3: For element nodes, compare keys if available.\n if (\n oldNode.nodeType === Node.ELEMENT_NODE &&\n newNode.nodeType === Node.ELEMENT_NODE\n ) {\n const oldKey = oldNode.getAttribute(\"key\");\n const newKey = newNode.getAttribute(\"key\");\n if (oldKey || newKey) {\n if (oldKey !== newKey) {\n oldParent.replaceChild(newNode.cloneNode(true), oldNode);\n continue;\n }\n }\n }\n\n // Case 4: Replace nodes if types or tag names differ.\n if (\n oldNode.nodeType !== newNode.nodeType ||\n oldNode.nodeName !== newNode.nodeName\n ) {\n oldParent.replaceChild(newNode.cloneNode(true), oldNode);\n continue;\n }\n // Case 5: For text nodes, update content if different.\n if (oldNode.nodeType === Node.TEXT_NODE) {\n if (oldNode.nodeValue !== newNode.nodeValue) {\n oldNode.nodeValue = newNode.nodeValue;\n }\n continue;\n }\n // Case 6: For element nodes, update attributes and then diff children.\n if (oldNode.nodeType === Node.ELEMENT_NODE) {\n this.updateAttributes(oldNode, newNode);\n this.diff(oldNode, newNode);\n }\n }\n }\n\n /**\n * Updates the attributes of an element to match those of a new element.\n *\n * @param {HTMLElement} oldEl - The element to update.\n * @param {HTMLElement} newEl - The element providing the updated attributes.\n */\n updateAttributes(oldEl, newEl) {\n const attributeToPropertyMap = {\n value: \"value\",\n checked: \"checked\",\n selected: \"selected\",\n disabled: \"disabled\",\n };\n\n // Remove old attributes that no longer exist.\n Array.from(oldEl.attributes).forEach((attr) => {\n if (attr.name.startsWith(\"@\")) return;\n if (!newEl.hasAttribute(attr.name)) {\n oldEl.removeAttribute(attr.name);\n }\n });\n // Add or update attributes from newEl.\n Array.from(newEl.attributes).forEach((attr) => {\n if (attr.name.startsWith(\"@\")) return;\n if (oldEl.getAttribute(attr.name) !== attr.value) {\n oldEl.setAttribute(attr.name, attr.value);\n if (attributeToPropertyMap[attr.name]) {\n oldEl[attributeToPropertyMap[attr.name]] = attr.value;\n } else if (attr.name in oldEl) {\n oldEl[attr.name] = attr.value;\n }\n }\n });\n }\n}\n","\"use strict\";\n\nimport { TemplateEngine } from \"../modules/TemplateEngine.js\";\nimport { Signal } from \"../modules/Signal.js\";\nimport { Emitter } from \"../modules/Emitter.js\";\nimport { Renderer } from \"../modules/Renderer.js\";\n\n/**\n * Defines the structure and behavior of a component.\n * @typedef {Object} ComponentDefinition\n * @property {function(Object<string, any>): (Object<string, any>|Promise<Object<string, any>>)} [setup]\n * Optional setup function that initializes the component's reactive state and lifecycle.\n * Receives props and context as an argument and should return an object containing the component's state.\n * Can return either a synchronous object or a Promise that resolves to an object for async initialization.\n *\n * @property {function(Object<string, any>): string} template\n * Required function that defines the component's HTML structure.\n * Receives the merged context (props + setup data) and must return an HTML template string.\n * Supports dynamic expressions using {{ }} syntax for reactive data binding.\n *\n * @property {function(Object<string, any>): string} [style]\n * Optional function that defines component-scoped CSS styles.\n * Receives the merged context and returns a CSS string that will be automatically scoped to the component.\n * Styles are injected into the component's container and only affect elements within it.\n *\n * @property {Object<string, ComponentDefinition>} [children]\n * Optional object that defines nested child components.\n * Keys are CSS selectors that match elements in the template where child components should be mounted.\n * Values are ComponentDefinition objects that define the structure and behavior of each child component.\n */\n\n/**\n * @class 🧩 Eleva\n * @classdesc Signal-based component runtime framework with lifecycle hooks, scoped styles, and plugin support.\n * Manages component registration, plugin integration, event handling, and DOM rendering.\n */\nexport class Eleva {\n /**\n * Creates a new Eleva instance.\n *\n * @param {string} name - The name of the Eleva instance.\n * @param {Object<string, any>} [config={}] - Optional configuration for the instance.\n */\n constructor(name, config = {}) {\n /** @type {string} The unique identifier name for this Eleva instance */\n this.name = name;\n /** @type {Object<string, any>} Optional configuration object for the Eleva instance */\n this.config = config;\n /** @type {Object<string, ComponentDefinition>} Object storing registered component definitions by name */\n this._components = {};\n /** @private {Array<Object>} Collection of installed plugin instances */\n this._plugins = [];\n /** @private {string[]} Array of lifecycle hook names supported by the component */\n this._lifecycleHooks = [\n \"onBeforeMount\",\n \"onMount\",\n \"onBeforeUpdate\",\n \"onUpdate\",\n \"onUnmount\",\n ];\n /** @private {boolean} Flag indicating if component is currently mounted */\n this._isMounted = false;\n /** @private {Emitter} Instance of the event emitter for handling component events */\n this.emitter = new Emitter();\n /** @private {Renderer} Instance of the renderer for handling DOM updates and patching */\n this.renderer = new Renderer();\n }\n\n /**\n * Integrates a plugin with the Eleva framework.\n *\n * @param {Object} plugin - The plugin object which should have an `install` function.\n * @param {Object<string, any>} [options={}] - Optional options to pass to the plugin.\n * @returns {Eleva} The Eleva instance (for chaining).\n */\n use(plugin, options = {}) {\n if (typeof plugin.install === \"function\") {\n plugin.install(this, options);\n }\n this._plugins.push(plugin);\n return this;\n }\n\n /**\n * Registers a component with the Eleva instance.\n *\n * @param {string} name - The name of the component.\n * @param {ComponentDefinition} definition - The component definition including setup, template, style, and children.\n * @returns {Eleva} The Eleva instance (for chaining).\n */\n component(name, definition) {\n this._components[name] = definition;\n return this;\n }\n\n /**\n * Mounts a registered component to a DOM element.\n *\n * @param {HTMLElement} container - A DOM element where the component will be mounted.\n * @param {string|ComponentDefinition} compName - The name of the component to mount or a component definition.\n * @param {Object<string, any>} [props={}] - Optional properties to pass to the component.\n * @returns {object|Promise<object>} An object representing the mounted component instance, or a Promise that resolves to it for asynchronous setups.\n * @throws {Error} If the container is not found or if the component is not registered.\n */\n mount(container, compName, props = {}) {\n if (!container) throw new Error(`Container not found: ${container}`);\n\n let definition;\n if (typeof compName === \"string\") {\n definition = this._components[compName];\n if (!definition)\n throw new Error(`Component \"${compName}\" not registered.`);\n } else if (typeof compName === \"object\") {\n definition = compName;\n } else {\n throw new Error(\"Invalid component parameter.\");\n }\n\n /**\n * Destructure the component definition to access core functionality.\n * - setup: Optional function for component initialization and state management\n * - template: Required function that returns the component's HTML structure\n * - style: Optional function for component-scoped CSS styles\n * - children: Optional object defining nested child components\n */\n const { setup, template, style, children } = definition;\n\n /**\n * Creates the initial context object for the component instance.\n * This context provides core functionality and will be merged with setup data.\n * @type {Object<string, any>}\n * @property {Object<string, any>} props - Component properties passed during mounting\n * @property {Emitter} emitter - Event emitter instance for component event handling\n * @property {function(any): Signal} signal - Factory function to create reactive Signal instances\n * @property {Object<string, function(): void>} ...lifecycleHooks - Prepared lifecycle hook functions\n */\n const context = {\n props,\n emitter: this.emitter,\n signal: (v) => new Signal(v),\n ...this._prepareLifecycleHooks(),\n };\n\n /**\n * Processes the mounting of the component.\n *\n * @param {Object<string, any>} data - Data returned from the component's setup function.\n * @returns {object} An object with the container, merged context data, and an unmount function.\n */\n const processMount = (data) => {\n const mergedContext = { ...context, ...data };\n const watcherUnsubscribers = [];\n const childInstances = [];\n\n if (!this._isMounted) {\n mergedContext.onBeforeMount && mergedContext.onBeforeMount();\n } else {\n mergedContext.onBeforeUpdate && mergedContext.onBeforeUpdate();\n }\n\n /**\n * Renders the component by parsing the template, patching the DOM,\n * processing events, injecting styles, and mounting child components.\n */\n const render = () => {\n const newHtml = TemplateEngine.parse(\n template(mergedContext),\n mergedContext\n );\n this.renderer.patchDOM(container, newHtml);\n this._processEvents(container, mergedContext);\n this._injectStyles(container, compName, style, mergedContext);\n this._mountChildren(container, children, childInstances);\n if (!this._isMounted) {\n mergedContext.onMount && mergedContext.onMount();\n this._isMounted = true;\n } else {\n mergedContext.onUpdate && mergedContext.onUpdate();\n }\n };\n\n /**\n * Sets up reactive watchers for all Signal instances in the component's data.\n * When a Signal's value changes, the component will re-render to reflect the updates.\n * Stores unsubscribe functions to clean up watchers when component unmounts.\n */\n Object.values(data).forEach((val) => {\n if (val instanceof Signal) watcherUnsubscribers.push(val.watch(render));\n });\n\n render();\n\n return {\n container,\n data: mergedContext,\n /**\n * Unmounts the component, cleaning up watchers, child components, and clearing the container.\n *\n * @returns {void}\n */\n unmount: () => {\n watcherUnsubscribers.forEach((fn) => fn());\n childInstances.forEach((child) => child.unmount());\n mergedContext.onUnmount && mergedContext.onUnmount();\n container.innerHTML = \"\";\n },\n };\n };\n\n // Handle asynchronous setup.\n return Promise.resolve(\n typeof setup === \"function\" ? setup(context) : {}\n ).then((data) => processMount(data));\n }\n\n /**\n * Prepares default no-operation lifecycle hook functions.\n *\n * @returns {Object<string, function(): void>} An object with keys for lifecycle hooks mapped to empty functions.\n * @private\n */\n _prepareLifecycleHooks() {\n return this._lifecycleHooks.reduce((acc, hook) => {\n acc[hook] = () => {};\n return acc;\n }, {});\n }\n\n /**\n * Processes DOM elements for event binding based on attributes starting with \"@\".\n *\n * @param {HTMLElement} container - The container element in which to search for events.\n * @param {Object<string, any>} context - The current context containing event handler definitions.\n * @private\n */\n _processEvents(container, context) {\n container.querySelectorAll(\"*\").forEach((el) => {\n [...el.attributes].forEach(({ name, value }) => {\n if (name.startsWith(\"@\")) {\n const event = name.slice(1);\n const handler = TemplateEngine.evaluate(value, context);\n if (typeof handler === \"function\") {\n el.addEventListener(event, handler);\n el.removeAttribute(name);\n }\n }\n });\n });\n }\n\n /**\n * Injects scoped styles into the component's container.\n *\n * @param {HTMLElement} container - The container element.\n * @param {string} compName - The component name used to identify the style element.\n * @param {function(Object<string, any>): string} [styleFn] - A function that returns CSS styles as a string.\n * @param {Object<string, any>} context - The current context for style interpolation.\n * @private\n */\n _injectStyles(container, compName, styleFn, context) {\n if (styleFn) {\n let styleEl = container.querySelector(\n `style[data-eleva-style=\"${compName}\"]`\n );\n if (!styleEl) {\n styleEl = document.createElement(\"style\");\n styleEl.setAttribute(\"data-eleva-style\", compName);\n container.appendChild(styleEl);\n }\n styleEl.textContent = TemplateEngine.parse(styleFn(context), context);\n }\n }\n\n /**\n * Mounts child components within the parent component's container.\n *\n * @param {HTMLElement} container - The parent container element.\n * @param {Object<string, ComponentDefinition>} [children] - An object mapping child component selectors to their definitions.\n * @param {Array<object>} childInstances - An array to store the mounted child component instances.\n * @private\n */\n _mountChildren(container, children, childInstances) {\n childInstances.forEach((child) => child.unmount());\n childInstances.length = 0;\n\n Object.keys(children || {}).forEach((childSelector) => {\n container.querySelectorAll(childSelector).forEach((childEl) => {\n const props = {};\n [...childEl.attributes].forEach(({ name, value }) => {\n if (name.startsWith(\"eleva-prop-\")) {\n props[name.slice(\"eleva-prop-\".length)] = value;\n }\n });\n const instance = this.mount(childEl, children[childSelector], props);\n childInstances.push(instance);\n });\n });\n }\n}\n"],"names":["TemplateEngine","parse","template","data","replace","_","expr","value","evaluate","undefined","keys","Object","values","result","Function","error","console","expression","message","Signal","constructor","_value","_watchers","Set","newVal","forEach","fn","watch","add","delete","Emitter","events","on","event","handler","push","off","filter","h","emit","args","Renderer","patchDOM","container","newHtml","tempContainer","document","createElement","innerHTML","diff","oldParent","newParent","oldNodes","Array","from","childNodes","newNodes","max","Math","length","i","oldNode","newNode","appendChild","cloneNode","removeChild","nodeType","Node","ELEMENT_NODE","oldKey","getAttribute","newKey","replaceChild","nodeName","TEXT_NODE","nodeValue","updateAttributes","oldEl","newEl","attributeToPropertyMap","checked","selected","disabled","attributes","attr","name","startsWith","hasAttribute","removeAttribute","setAttribute","Eleva","config","_components","_plugins","_lifecycleHooks","_isMounted","emitter","renderer","use","plugin","options","install","component","definition","mount","compName","props","Error","setup","style","children","context","signal","v","_prepareLifecycleHooks","processMount","mergedContext","watcherUnsubscribers","childInstances","onBeforeMount","onBeforeUpdate","render","_processEvents","_injectStyles","_mountChildren","onMount","onUpdate","val","unmount","child","onUnmount","Promise","resolve","then","reduce","acc","hook","querySelectorAll","el","slice","addEventListener","styleFn","styleEl","querySelector","textContent","childSelector","childEl","instance"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,cAAc,CAAC;AAC1B;AACF;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,OAAOC,KAAKA,CAACC,QAAQ,EAAEC,IAAI,EAAE;IAC3B,OAAOD,QAAQ,CAACE,OAAO,CAAC,sBAAsB,EAAE,CAACC,CAAC,EAAEC,IAAI,KAAK;MAC3D,MAAMC,KAAK,GAAG,IAAI,CAACC,QAAQ,CAACF,IAAI,EAAEH,IAAI,CAAC;AACvC,MAAA,OAAOI,KAAK,KAAKE,SAAS,GAAG,EAAE,GAAGF,KAAK;AACzC,KAAC,CAAC;AACJ;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,OAAOC,QAAQA,CAACF,IAAI,EAAEH,IAAI,EAAE;IAC1B,IAAI;AACF,MAAA,MAAMO,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACP,IAAI,CAAC;AAC9B,MAAA,MAAMS,MAAM,GAAGD,MAAM,CAACC,MAAM,CAACT,IAAI,CAAC;AAClC,MAAA,MAAMU,MAAM,GAAG,IAAIC,QAAQ,CAAC,GAAGJ,IAAI,EAAE,CAAA,OAAA,EAAUJ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