eleva 1.2.18-beta → 1.2.19-beta

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 CHANGED
@@ -29,9 +29,9 @@ Pure JavaScript, Pure Performance, Simply Elegant.
29
29
  **A minimalist, lightweight, pure vanilla JavaScript frontend runtime framework.**
30
30
  _Built with love for native JavaScript-because sometimes, less really is more!_ 😊
31
31
 
32
- > **Stability Notice**: This is `v1.2.18-beta` - The core functionality is stable, but I'm seeking community feedback before the final v1.0.0 release.
32
+ > **Stability Notice**: This is `v1.2.19-beta` - The core functionality is stable, but I'm seeking community feedback before the final v1.0.0 release.
33
33
 
34
- **Version:** `1.2.18-beta`
34
+ **Version:** `1.2.19-beta`
35
35
 
36
36
 
37
37
 
package/dist/eleva.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! Eleva v1.2.18-beta | MIT License | https://elevajs.com */
1
+ /*! Eleva v1.2.19-beta | MIT License | https://elevajs.com */
2
2
  'use strict';
3
3
 
4
4
  /**
@@ -292,11 +292,11 @@ class Renderer {
292
292
  * Patches the DOM of the given container with the provided HTML string.
293
293
  *
294
294
  * @public
295
- * @param {HTMLElement} container - The container whose DOM will be patched.
295
+ * @param {HTMLElement} container - The container element to patch.
296
296
  * @param {string} newHtml - The new HTML string.
297
- * @throws {TypeError} If the container is not an HTMLElement or newHtml is not a string.
298
- * @throws {Error} If the DOM patching fails.
299
297
  * @returns {void}
298
+ * @throws {TypeError} If container is not an HTMLElement or newHtml is not a string.
299
+ * @throws {Error} If DOM patching fails.
300
300
  */
301
301
  patchDOM(container, newHtml) {
302
302
  if (!(container instanceof HTMLElement)) {
@@ -317,8 +317,8 @@ class Renderer {
317
317
  * Performs a diff between two DOM nodes and patches the old node to match the new node.
318
318
  *
319
319
  * @private
320
- * @param {Node} oldParent - The old parent node to be patched.
321
- * @param {Node} newParent - The new parent node to compare.
320
+ * @param {HTMLElement} oldParent - The original DOM element.
321
+ * @param {HTMLElement} newParent - The new DOM element.
322
322
  * @returns {void}
323
323
  */
324
324
  _diff(oldParent, newParent) {
@@ -334,34 +334,27 @@ class Renderer {
334
334
  let oldStartNode = oldChildren[oldStartIdx];
335
335
  let newStartNode = newChildren[newStartIdx];
336
336
  if (!oldStartNode) {
337
- oldStartIdx++;
338
- continue;
339
- }
340
- if (!newStartNode) {
341
- newStartIdx++;
342
- continue;
343
- }
344
- if (this._keysMatch(oldStartNode, newStartNode)) {
337
+ oldStartNode = oldChildren[++oldStartIdx];
338
+ } else if (this._isSameNode(oldStartNode, newStartNode)) {
345
339
  this._patchNode(oldStartNode, newStartNode);
346
340
  oldStartIdx++;
347
341
  newStartIdx++;
348
342
  } else {
349
- oldKeyMap ??= this._createKeyMap(oldChildren, oldStartIdx, oldEndIdx);
350
- const newKey = newStartNode.nodeType === Node.ELEMENT_NODE ? newStartNode.getAttribute("key") : null;
351
- const moveIndex = newKey ? oldKeyMap.get(newKey) : undefined;
352
- const oldNodeToMove = moveIndex !== undefined ? oldChildren[moveIndex] : null;
343
+ if (!oldKeyMap) {
344
+ oldKeyMap = this._createKeyMap(oldChildren, oldStartIdx, oldEndIdx);
345
+ }
346
+ const key = this._getNodeKey(newStartNode);
347
+ const oldNodeToMove = key ? oldKeyMap.get(key) : null;
353
348
  if (oldNodeToMove) {
354
349
  this._patchNode(oldNodeToMove, newStartNode);
355
350
  oldParent.insertBefore(oldNodeToMove, oldStartNode);
356
- if (moveIndex !== undefined) oldChildren[moveIndex] = null;
351
+ oldChildren[oldChildren.indexOf(oldNodeToMove)] = null;
357
352
  } else {
358
353
  oldParent.insertBefore(newStartNode.cloneNode(true), oldStartNode);
359
354
  }
360
355
  newStartIdx++;
361
356
  }
362
357
  }
363
-
364
- // Cleanup
365
358
  if (oldStartIdx > oldEndIdx) {
366
359
  const refNode = newChildren[newEndIdx + 1] ? oldChildren[oldStartIdx] : null;
367
360
  for (let i = newStartIdx; i <= newEndIdx; i++) {
@@ -369,58 +362,51 @@ class Renderer {
369
362
  }
370
363
  } else if (newStartIdx > newEndIdx) {
371
364
  for (let i = oldStartIdx; i <= oldEndIdx; i++) {
372
- const node = oldChildren[i];
373
- if (node && !(node.nodeName === "STYLE" && node.hasAttribute("data-e-style"))) {
374
- oldParent.removeChild(node);
375
- }
365
+ if (oldChildren[i]) this._removeNode(oldParent, oldChildren[i]);
376
366
  }
377
367
  }
378
368
  }
379
369
 
380
370
  /**
381
- * Checks if the node types match.
371
+ * Patches a single node.
382
372
  *
383
373
  * @private
384
- * @param {Node} oldNode - The old node.
385
- * @param {Node} newNode - The new node.
386
- * @returns {boolean} True if the nodes match, false otherwise.
387
- */
388
- _keysMatch(oldNode, newNode) {
389
- if (oldNode.nodeType !== Node.ELEMENT_NODE) return true;
390
- const oldKey = oldNode.getAttribute("key");
391
- const newKey = newNode.getAttribute("key");
392
- return oldKey === newKey;
393
- }
394
-
395
- /**
396
- * Patches a node.
397
- *
398
- * @private
399
- * @param {Node} oldNode - The old node to patch.
400
- * @param {Node} newNode - The new node to patch.
374
+ * @param {Node} oldNode - The original DOM node.
375
+ * @param {Node} newNode - The new DOM node.
401
376
  * @returns {void}
402
377
  */
403
378
  _patchNode(oldNode, newNode) {
404
379
  if (oldNode?._eleva_instance) return;
405
- if (oldNode.nodeType !== newNode.nodeType || oldNode.nodeName !== newNode.nodeName) {
380
+ if (!this._isSameNode(oldNode, newNode)) {
406
381
  oldNode.replaceWith(newNode.cloneNode(true));
407
382
  return;
408
383
  }
409
384
  if (oldNode.nodeType === Node.ELEMENT_NODE) {
410
- const oldEl = oldNode;
411
- const newEl = newNode;
412
- this._updateAttributes(oldEl, newEl);
413
- this._diff(oldEl, newEl);
385
+ this._updateAttributes(oldNode, newNode);
386
+ this._diff(oldNode, newNode);
414
387
  } else if (oldNode.nodeType === Node.TEXT_NODE && oldNode.nodeValue !== newNode.nodeValue) {
415
388
  oldNode.nodeValue = newNode.nodeValue;
416
389
  }
417
390
  }
418
391
 
419
392
  /**
420
- * Updates the attributes of an element.
393
+ * Removes a node from its parent.
421
394
  *
422
395
  * @private
423
- * @param {HTMLElement} oldEl - The old element to update.
396
+ * @param {HTMLElement} parent - The parent element containing the node to remove.
397
+ * @param {Node} node - The node to remove.
398
+ * @returns {void}
399
+ */
400
+ _removeNode(parent, node) {
401
+ if (node.nodeName === "STYLE" && node.hasAttribute("data-e-style")) return;
402
+ parent.removeChild(node);
403
+ }
404
+
405
+ /**
406
+ * Updates the attributes of an element to match a new element's attributes.
407
+ *
408
+ * @private
409
+ * @param {HTMLElement} oldEl - The original element to update.
424
410
  * @param {HTMLElement} newEl - The new element to update.
425
411
  * @returns {void}
426
412
  */
@@ -434,15 +420,16 @@ class Renderer {
434
420
  name,
435
421
  value
436
422
  } = newAttrs[i];
437
- if (name[0] === "@" || oldEl.getAttribute(name) === value) continue;
423
+ if (name.startsWith("@")) continue;
424
+ if (oldEl.getAttribute(name) === value) continue;
438
425
  oldEl.setAttribute(name, value);
439
- if (name[0] === "a" && name[4] === "-") {
440
- const s = name.slice(5);
441
- oldEl["aria" + s.replace(CAMEL_RE, (_, l) => l.toUpperCase())] = value;
442
- } else if (name[0] === "d" && name[3] === "-") {
426
+ if (name.startsWith("aria-")) {
427
+ const prop = "aria" + name.slice(5).replace(CAMEL_RE, (_, l) => l.toUpperCase());
428
+ oldEl[prop] = value;
429
+ } else if (name.startsWith("data-")) {
443
430
  oldEl.dataset[name.slice(5)] = value;
444
431
  } else {
445
- const prop = name.includes("-") ? name.replace(CAMEL_RE, (_, l) => l.toUpperCase()) : name;
432
+ const prop = name.replace(CAMEL_RE, (_, l) => l.toUpperCase());
446
433
  if (prop in oldEl) {
447
434
  const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(oldEl), prop);
448
435
  const isBoolean = typeof oldEl[prop] === "boolean" || descriptor?.get && typeof descriptor.get.call(oldEl) === "boolean";
@@ -464,6 +451,22 @@ class Renderer {
464
451
  }
465
452
  }
466
453
 
454
+ /**
455
+ * Determines if two nodes are the same based on their type, name, and key attributes.
456
+ *
457
+ * @private
458
+ * @param {Node} oldNode - The first node to compare.
459
+ * @param {Node} newNode - The second node to compare.
460
+ * @returns {boolean} True if the nodes are considered the same, false otherwise.
461
+ */
462
+ _isSameNode(oldNode, newNode) {
463
+ if (!oldNode || !newNode) return false;
464
+ const oldKey = oldNode.nodeType === Node.ELEMENT_NODE ? oldNode.getAttribute("key") : null;
465
+ const newKey = newNode.nodeType === Node.ELEMENT_NODE ? newNode.getAttribute("key") : null;
466
+ if (oldKey && newKey) return oldKey === newKey;
467
+ return !oldKey && !newKey && oldNode.nodeType === newNode.nodeType && oldNode.nodeName === newNode.nodeName;
468
+ }
469
+
467
470
  /**
468
471
  * Creates a key map for the children of a parent node.
469
472
  *
@@ -471,19 +474,28 @@ class Renderer {
471
474
  * @param {Array<Node>} children - The children of the parent node.
472
475
  * @param {number} start - The start index of the children.
473
476
  * @param {number} end - The end index of the children.
474
- * @returns {Map<string, number>} A map of key to child index.
477
+ * @returns {Map<string, Node>} A key map for the children.
475
478
  */
476
479
  _createKeyMap(children, start, end) {
477
480
  const map = new Map();
478
481
  for (let i = start; i <= end; i++) {
479
482
  const child = children[i];
480
- if (child?.nodeType === Node.ELEMENT_NODE) {
481
- const key = child.getAttribute("key");
482
- if (key) map.set(key, i);
483
- }
483
+ const key = this._getNodeKey(child);
484
+ if (key) map.set(key, child);
484
485
  }
485
486
  return map;
486
487
  }
488
+
489
+ /**
490
+ * Extracts the key attribute from a node if it exists.
491
+ *
492
+ * @private
493
+ * @param {Node} node - The node to extract the key from.
494
+ * @returns {string|null} The key attribute value or null if not found.
495
+ */
496
+ _getNodeKey(node) {
497
+ return node?.nodeType === Node.ELEMENT_NODE ? node.getAttribute("key") : null;
498
+ }
487
499
  }
488
500
 
489
501
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"eleva.cjs.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 A secure template engine that handles interpolation and dynamic attribute parsing.\n * Provides a safe way to evaluate expressions in templates while preventing XSS attacks.\n * All methods are static and can be called directly on the class.\n *\n * @example\n * const template = \"Hello, {{name}}!\";\n * const data = { name: \"World\" };\n * const result = TemplateEngine.parse(template, data); // Returns: \"Hello, World!\"\n */\nexport class TemplateEngine {\n /**\n * @private {RegExp} Regular expression for matching template expressions in the format {{ expression }}\n * @type {RegExp}\n */\n static expressionPattern = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n\n /**\n * Parses a template string, replacing expressions with their evaluated values.\n * Expressions are evaluated in the provided data context.\n *\n * @public\n * @static\n * @param {string} template - The template string to parse.\n * @param {Record<string, unknown>} data - The data context for evaluating expressions.\n * @returns {string} The parsed template with expressions replaced by their values.\n * @example\n * const result = TemplateEngine.parse(\"{{user.name}} is {{user.age}} years old\", {\n * user: { name: \"John\", age: 30 }\n * }); // Returns: \"John is 30 years old\"\n */\n static parse(template, data) {\n if (typeof template !== \"string\") return template;\n return template.replace(this.expressionPattern, (_, expression) =>\n this.evaluate(expression, data)\n );\n }\n\n /**\n * Evaluates an expression in the context of the provided data object.\n * Note: This does not provide a true sandbox and evaluated expressions may access global scope.\n * The use of the `with` statement is necessary for expression evaluation but has security implications.\n * Expressions should be carefully validated before evaluation.\n *\n * @public\n * @static\n * @param {string} expression - The expression to evaluate.\n * @param {Record<string, unknown>} data - The data context for evaluation.\n * @returns {unknown} The result of the evaluation, or an empty string if evaluation fails.\n * @example\n * const result = TemplateEngine.evaluate(\"user.name\", { user: { name: \"John\" } }); // Returns: \"John\"\n * const age = TemplateEngine.evaluate(\"user.age\", { user: { age: 30 } }); // Returns: 30\n */\n static evaluate(expression, data) {\n if (typeof expression !== \"string\") return expression;\n try {\n return new Function(\"data\", `with(data) { return ${expression}; }`)(data);\n } catch {\n return \"\";\n }\n }\n}\n","\"use strict\";\n\n/**\n * @class ⚡ Signal\n * @classdesc A reactive data holder that enables fine-grained reactivity in the Eleva framework.\n * Signals notify registered watchers when their value changes, enabling efficient DOM updates\n * through targeted patching rather than full re-renders.\n * Updates are batched using microtasks to prevent multiple synchronous notifications.\n * The class is generic, allowing type-safe handling of any value type T.\n *\n * @example\n * const count = new Signal(0);\n * count.watch((value) => console.log(`Count changed to: ${value}`));\n * count.value = 1; // Logs: \"Count changed to: 1\"\n * @template T\n */\nexport class Signal {\n /**\n * Creates a new Signal instance with the specified initial value.\n *\n * @public\n * @param {T} value - The initial value of the signal.\n */\n constructor(value) {\n /** @private {T} Internal storage for the signal's current value */\n this._value = value;\n /** @private {Set<(value: T) => void>} Collection of callback functions to be notified when value changes */\n this._watchers = new Set();\n /** @private {boolean} Flag to prevent multiple synchronous watcher notifications and batch updates into microtasks */\n this._pending = false;\n }\n\n /**\n * Gets the current value of the signal.\n *\n * @public\n * @returns {T} 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 * The notification is batched using microtasks to prevent multiple synchronous updates.\n *\n * @public\n * @param {T} newVal - The new value to set.\n * @returns {void}\n */\n set value(newVal) {\n if (this._value === newVal) return;\n\n this._value = newVal;\n this._notify();\n }\n\n /**\n * Registers a watcher function that will be called whenever the signal's value changes.\n * The watcher will receive the new value as its argument.\n *\n * @public\n * @param {(value: T) => void} fn - The callback function to invoke on value change.\n * @returns {() => boolean} A function to unsubscribe the watcher.\n * @example\n * const unsubscribe = signal.watch((value) => console.log(value));\n * // Later...\n * unsubscribe(); // Stops watching for changes\n */\n watch(fn) {\n this._watchers.add(fn);\n return () => this._watchers.delete(fn);\n }\n\n /**\n * Notifies all registered watchers of a value change using microtask scheduling.\n * Uses a pending flag to batch multiple synchronous updates into a single notification.\n * All watcher callbacks receive the current value when executed.\n *\n * @private\n * @returns {void}\n */\n _notify() {\n if (this._pending) return;\n\n this._pending = true;\n queueMicrotask(() => {\n /** @type {(fn: (value: T) => void) => void} */\n this._watchers.forEach((fn) => fn(this._value));\n this._pending = false;\n });\n }\n}\n","\"use strict\";\n\n/**\n * @class 📡 Emitter\n * @classdesc A robust event emitter that enables inter-component communication through a publish-subscribe pattern.\n * Components can emit events and listen for events from other components, facilitating loose coupling\n * and reactive updates across the application.\n * Events are handled synchronously in the order they were registered, with proper cleanup\n * of unsubscribed handlers.\n * Event names should follow the format 'namespace:action' (e.g., 'user:login', 'cart:update').\n *\n * @example\n * const emitter = new Emitter();\n * emitter.on('user:login', (user) => console.log(`User logged in: ${user.name}`));\n * emitter.emit('user:login', { name: 'John' }); // Logs: \"User logged in: John\"\n */\nexport class Emitter {\n /**\n * Creates a new Emitter instance.\n *\n * @public\n */\n constructor() {\n /** @private {Map<string, Set<(data: unknown) => void>>} Map of event names to their registered handler functions */\n this._events = new Map();\n }\n\n /**\n * Registers an event handler for the specified event name.\n * The handler will be called with the event data when the event is emitted.\n * Event names should follow the format 'namespace:action' for consistency.\n *\n * @public\n * @param {string} event - The name of the event to listen for (e.g., 'user:login').\n * @param {(data: unknown) => void} handler - The callback function to invoke when the event occurs.\n * @returns {() => void} A function to unsubscribe the event handler.\n * @example\n * const unsubscribe = emitter.on('user:login', (user) => console.log(user));\n * // Later...\n * unsubscribe(); // Stops listening for the event\n */\n on(event, handler) {\n if (!this._events.has(event)) this._events.set(event, new Set());\n\n this._events.get(event).add(handler);\n return () => this.off(event, handler);\n }\n\n /**\n * Removes an event handler for the specified event name.\n * If no handler is provided, all handlers for the event are removed.\n * Automatically cleans up empty event sets to prevent memory leaks.\n *\n * @public\n * @param {string} event - The name of the event to remove handlers from.\n * @param {(data: unknown) => void} [handler] - The specific handler function to remove.\n * @returns {void}\n * @example\n * // Remove a specific handler\n * emitter.off('user:login', loginHandler);\n * // Remove all handlers for an event\n * emitter.off('user:login');\n */\n off(event, handler) {\n if (!this._events.has(event)) return;\n if (handler) {\n const handlers = this._events.get(event);\n handlers.delete(handler);\n // Remove the event if there are no handlers left\n if (handlers.size === 0) this._events.delete(event);\n } else {\n this._events.delete(event);\n }\n }\n\n /**\n * Emits an event with the specified data to all registered handlers.\n * Handlers are called synchronously in the order they were registered.\n * If no handlers are registered for the event, the emission is silently ignored.\n *\n * @public\n * @param {string} event - The name of the event to emit.\n * @param {...unknown} args - Optional arguments to pass to the event handlers.\n * @returns {void}\n * @example\n * // Emit an event with data\n * emitter.emit('user:login', { name: 'John', role: 'admin' });\n * // Emit an event with multiple arguments\n * emitter.emit('cart:update', { items: [] }, { total: 0 });\n */\n emit(event, ...args) {\n if (!this._events.has(event)) return;\n this._events.get(event).forEach((handler) => handler(...args));\n }\n}\n","\"use strict\";\n\n/**\n * A regular expression to match hyphenated lowercase letters.\n * @private\n * @type {RegExp}\n */\nconst CAMEL_RE = /-([a-z])/g;\n\n/**\n * @class 🎨 Renderer\n * @classdesc A high-performance DOM renderer that implements an optimized direct DOM diffing algorithm.\n *\n * Key features:\n * - Single-pass diffing algorithm for efficient DOM updates\n * - Key-based node reconciliation for optimal performance\n * - Intelligent attribute handling for ARIA, data attributes, and boolean properties\n * - Preservation of special Eleva-managed instances and style elements\n * - Memory-efficient with reusable temporary containers\n *\n * The renderer is designed to minimize DOM operations while maintaining\n * exact attribute synchronization and proper node identity preservation.\n * It's particularly optimized for frequent updates and complex DOM structures.\n *\n * @example\n * const renderer = new Renderer();\n * const container = document.getElementById(\"app\");\n * const newHtml = \"<div>Updated content</div>\";\n * renderer.patchDOM(container, newHtml);\n */\nexport class Renderer {\n /**\n * Creates a new Renderer instance.\n * @public\n */\n constructor() {\n /**\n * A temporary container to hold the new HTML content while diffing.\n * @private\n * @type {HTMLElement}\n */\n this._tempContainer = document.createElement(\"div\");\n }\n\n /**\n * Patches the DOM of the given container with the provided HTML string.\n *\n * @public\n * @param {HTMLElement} container - The container whose DOM will be patched.\n * @param {string} newHtml - The new HTML string.\n * @throws {TypeError} If the container is not an HTMLElement or newHtml is not a string.\n * @throws {Error} If the DOM patching fails.\n * @returns {void}\n */\n patchDOM(container, newHtml) {\n if (!(container instanceof HTMLElement)) {\n throw new TypeError(\"Container must be an HTMLElement\");\n }\n if (typeof newHtml !== \"string\") {\n throw new TypeError(\"newHtml must be a string\");\n }\n\n try {\n this._tempContainer.innerHTML = newHtml;\n this._diff(container, this._tempContainer);\n } catch (error) {\n throw new Error(`Failed to patch DOM: ${error.message}`);\n }\n }\n\n /**\n * Performs a diff between two DOM nodes and patches the old node to match the new node.\n *\n * @private\n * @param {Node} oldParent - The old parent node to be patched.\n * @param {Node} newParent - The new parent node to compare.\n * @returns {void}\n */\n _diff(oldParent, newParent) {\n if (oldParent === newParent || oldParent.isEqualNode?.(newParent)) return;\n\n const oldChildren = Array.from(oldParent.childNodes);\n const newChildren = Array.from(newParent.childNodes);\n let oldStartIdx = 0,\n newStartIdx = 0;\n let oldEndIdx = oldChildren.length - 1;\n let newEndIdx = newChildren.length - 1;\n let oldKeyMap = null;\n\n while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {\n let oldStartNode = oldChildren[oldStartIdx];\n let newStartNode = newChildren[newStartIdx];\n\n if (!oldStartNode) {\n oldStartIdx++;\n continue;\n }\n if (!newStartNode) {\n newStartIdx++;\n continue;\n }\n\n if (this._keysMatch(oldStartNode, newStartNode)) {\n this._patchNode(oldStartNode, newStartNode);\n oldStartIdx++;\n newStartIdx++;\n } else {\n oldKeyMap ??= this._createKeyMap(oldChildren, oldStartIdx, oldEndIdx);\n\n const newKey =\n newStartNode.nodeType === Node.ELEMENT_NODE\n ? newStartNode.getAttribute(\"key\")\n : null;\n const moveIndex = newKey ? oldKeyMap.get(newKey) : undefined;\n const oldNodeToMove =\n moveIndex !== undefined ? oldChildren[moveIndex] : null;\n\n if (oldNodeToMove) {\n this._patchNode(oldNodeToMove, newStartNode);\n oldParent.insertBefore(oldNodeToMove, oldStartNode);\n\n if (moveIndex !== undefined) oldChildren[moveIndex] = null;\n } else {\n oldParent.insertBefore(newStartNode.cloneNode(true), oldStartNode);\n }\n newStartIdx++;\n }\n }\n\n // Cleanup\n if (oldStartIdx > oldEndIdx) {\n const refNode = newChildren[newEndIdx + 1]\n ? oldChildren[oldStartIdx]\n : null;\n for (let i = newStartIdx; i <= newEndIdx; i++) {\n if (newChildren[i])\n oldParent.insertBefore(newChildren[i].cloneNode(true), refNode);\n }\n } else if (newStartIdx > newEndIdx) {\n for (let i = oldStartIdx; i <= oldEndIdx; i++) {\n const node = oldChildren[i];\n if (\n node &&\n !(node.nodeName === \"STYLE\" && node.hasAttribute(\"data-e-style\"))\n ) {\n oldParent.removeChild(node);\n }\n }\n }\n }\n\n /**\n * Checks if the node types match.\n *\n * @private\n * @param {Node} oldNode - The old node.\n * @param {Node} newNode - The new node.\n * @returns {boolean} True if the nodes match, false otherwise.\n */\n _keysMatch(oldNode, newNode) {\n if (oldNode.nodeType !== Node.ELEMENT_NODE) return true;\n const oldKey = oldNode.getAttribute(\"key\");\n const newKey = newNode.getAttribute(\"key\");\n return oldKey === newKey;\n }\n\n /**\n * Patches a node.\n *\n * @private\n * @param {Node} oldNode - The old node to patch.\n * @param {Node} newNode - The new node to patch.\n * @returns {void}\n */\n _patchNode(oldNode, newNode) {\n if (oldNode?._eleva_instance) return;\n\n if (\n oldNode.nodeType !== newNode.nodeType ||\n oldNode.nodeName !== newNode.nodeName\n ) {\n oldNode.replaceWith(newNode.cloneNode(true));\n return;\n }\n\n if (oldNode.nodeType === Node.ELEMENT_NODE) {\n const oldEl = oldNode;\n const newEl = newNode;\n this._updateAttributes(oldEl, newEl);\n this._diff(oldEl, newEl);\n } else if (\n oldNode.nodeType === Node.TEXT_NODE &&\n oldNode.nodeValue !== newNode.nodeValue\n ) {\n oldNode.nodeValue = newNode.nodeValue;\n }\n }\n\n /**\n * Updates the attributes of an element.\n *\n * @private\n * @param {HTMLElement} oldEl - The old element to update.\n * @param {HTMLElement} newEl - The new element to update.\n * @returns {void}\n */\n _updateAttributes(oldEl, newEl) {\n const oldAttrs = oldEl.attributes;\n const newAttrs = newEl.attributes;\n\n // Single pass for new/updated attributes\n for (let i = 0; i < newAttrs.length; i++) {\n const { name, value } = newAttrs[i];\n if (name[0] === \"@\" || oldEl.getAttribute(name) === value) continue;\n\n oldEl.setAttribute(name, value);\n\n if (name[0] === \"a\" && name[4] === \"-\") {\n const s = name.slice(5);\n oldEl[\"aria\" + s.replace(CAMEL_RE, (_, l) => l.toUpperCase())] = value;\n } else if (name[0] === \"d\" && name[3] === \"-\") {\n oldEl.dataset[name.slice(5)] = value;\n } else {\n const prop = name.includes(\"-\")\n ? name.replace(CAMEL_RE, (_, l) => l.toUpperCase())\n : name;\n\n if (prop in oldEl) {\n const descriptor = Object.getOwnPropertyDescriptor(\n Object.getPrototypeOf(oldEl),\n prop\n );\n const isBoolean =\n typeof oldEl[prop] === \"boolean\" ||\n (descriptor?.get &&\n typeof descriptor.get.call(oldEl) === \"boolean\");\n if (isBoolean) {\n oldEl[prop] =\n value !== \"false\" &&\n (value === \"\" || value === prop || value === \"true\");\n } else {\n oldEl[prop] = value;\n }\n }\n }\n }\n\n // Remove any attributes no longer present\n for (let i = oldAttrs.length - 1; i >= 0; i--) {\n const name = oldAttrs[i].name;\n if (!newEl.hasAttribute(name)) {\n oldEl.removeAttribute(name);\n }\n }\n }\n\n /**\n * Creates a key map for the children of a parent node.\n *\n * @private\n * @param {Array<Node>} children - The children of the parent node.\n * @param {number} start - The start index of the children.\n * @param {number} end - The end index of the children.\n * @returns {Map<string, number>} A map of key to child index.\n */\n _createKeyMap(children, start, end) {\n const map = new Map();\n for (let i = start; i <= end; i++) {\n const child = children[i];\n if (child?.nodeType === Node.ELEMENT_NODE) {\n const key = child.getAttribute(\"key\");\n if (key) map.set(key, i);\n }\n }\n return map;\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(ComponentContext): (Record<string, unknown>|Promise<Record<string, unknown>>)} [setup]\n * Optional setup function that initializes the component's state and returns reactive data\n * @property {(function(ComponentContext): string|Promise<string>)} template\n * Required function that defines the component's HTML structure\n * @property {(function(ComponentContext): string)|string} [style]\n * Optional function or string that provides component-scoped CSS styles\n * @property {Record<string, ComponentDefinition>} [children]\n * Optional object defining nested child components\n */\n\n/**\n * @typedef {Object} ComponentContext\n * @property {Record<string, unknown>} props\n * Component properties passed during mounting\n * @property {Emitter} emitter\n * Event emitter instance for component event handling\n * @property {function<T>(value: T): Signal<T>} signal\n * Factory function to create reactive Signal instances\n * @property {function(LifecycleHookContext): Promise<void>} [onBeforeMount]\n * Hook called before component mounting\n * @property {function(LifecycleHookContext): Promise<void>} [onMount]\n * Hook called after component mounting\n * @property {function(LifecycleHookContext): Promise<void>} [onBeforeUpdate]\n * Hook called before component update\n * @property {function(LifecycleHookContext): Promise<void>} [onUpdate]\n * Hook called after component update\n * @property {function(UnmountHookContext): Promise<void>} [onUnmount]\n * Hook called during component unmounting\n */\n\n/**\n * @typedef {Object} LifecycleHookContext\n * @property {HTMLElement} container\n * The DOM element where the component is mounted\n * @property {ComponentContext} context\n * The component's reactive state and context data\n */\n\n/**\n * @typedef {Object} UnmountHookContext\n * @property {HTMLElement} container\n * The DOM element where the component is mounted\n * @property {ComponentContext} context\n * The component's reactive state and context data\n * @property {{\n * watchers: Array<() => void>, // Signal watcher cleanup functions\n * listeners: Array<() => void>, // Event listener cleanup functions\n * children: Array<MountResult> // Child component instances\n * }} cleanup\n * Object containing cleanup functions and instances\n */\n\n/**\n * @typedef {Object} MountResult\n * @property {HTMLElement} container\n * The DOM element where the component is mounted\n * @property {ComponentContext} data\n * The component's reactive state and context data\n * @property {function(): Promise<void>} unmount\n * Function to clean up and unmount the component\n */\n\n/**\n * @typedef {Object} ElevaPlugin\n * @property {function(Eleva, Record<string, unknown>): void} install\n * Function that installs the plugin into the Eleva instance\n * @property {string} name\n * Unique identifier name for the plugin\n */\n\n/**\n * @class 🧩 Eleva\n * @classdesc A modern, signal-based component runtime framework that provides lifecycle hooks,\n * scoped styles, and plugin support. Eleva manages component registration, plugin integration,\n * event handling, and DOM rendering with a focus on performance and developer experience.\n *\n * @example\n * // Basic component creation and mounting\n * const app = new Eleva(\"myApp\");\n * app.component(\"myComponent\", {\n * setup: (ctx) => ({ count: ctx.signal(0) }),\n * template: (ctx) => `<div>Hello ${ctx.props.name}</div>`\n * });\n * app.mount(document.getElementById(\"app\"), \"myComponent\", { name: \"World\" });\n *\n * @example\n * // Using lifecycle hooks\n * app.component(\"lifecycleDemo\", {\n * setup: () => {\n * return {\n * onMount: ({ container, context }) => {\n * console.log('Component mounted!');\n * }\n * };\n * },\n * template: `<div>Lifecycle Demo</div>`\n * });\n */\nexport class Eleva {\n /**\n * Creates a new Eleva instance with the specified name and configuration.\n *\n * @public\n * @param {string} name - The unique identifier name for this Eleva instance.\n * @param {Record<string, unknown>} [config={}] - Optional configuration object for the instance.\n * May include framework-wide settings and default behaviors.\n * @throws {Error} If the name is not provided or is not a string.\n * @returns {Eleva} A new Eleva instance.\n *\n * @example\n * const app = new Eleva(\"myApp\");\n * app.component(\"myComponent\", {\n * setup: (ctx) => ({ count: ctx.signal(0) }),\n * template: (ctx) => `<div>Hello ${ctx.props.name}!</div>`\n * });\n * app.mount(document.getElementById(\"app\"), \"myComponent\", { name: \"World\" });\n *\n */\n constructor(name, config = {}) {\n /** @public {string} The unique identifier name for this Eleva instance */\n this.name = name;\n /** @public {Object<string, unknown>} Optional configuration object for the Eleva instance */\n this.config = config;\n /** @public {Emitter} Instance of the event emitter for handling component events */\n this.emitter = new Emitter();\n /** @public {typeof Signal} Static reference to the Signal class for creating reactive state */\n this.signal = Signal;\n /** @public {Renderer} Instance of the renderer for handling DOM updates and patching */\n this.renderer = new Renderer();\n\n /** @private {Map<string, ComponentDefinition>} Registry of all component definitions by name */\n this._components = new Map();\n /** @private {Map<string, ElevaPlugin>} Collection of installed plugin instances by name */\n this._plugins = new Map();\n /** @private {boolean} Flag indicating if the root component is currently mounted */\n this._isMounted = false;\n }\n\n /**\n * Integrates a plugin with the Eleva framework.\n * The plugin's install function will be called with the Eleva instance and provided options.\n * After installation, the plugin will be available for use by components.\n *\n * @public\n * @param {ElevaPlugin} plugin - The plugin object which must have an `install` function.\n * @param {Object<string, unknown>} [options={}] - Optional configuration options for the plugin.\n * @returns {Eleva} The Eleva instance (for method chaining).\n * @example\n * app.use(myPlugin, { option1: \"value1\" });\n */\n use(plugin, options = {}) {\n plugin.install(this, options);\n this._plugins.set(plugin.name, plugin);\n\n return this;\n }\n\n /**\n * Registers a new component with the Eleva instance.\n * The component will be available for mounting using its registered name.\n *\n * @public\n * @param {string} name - The unique name of the component to register.\n * @param {ComponentDefinition} definition - The component definition including setup, template, style, and children.\n * @returns {Eleva} The Eleva instance (for method chaining).\n * @throws {Error} If the component name is already registered.\n * @example\n * app.component(\"myButton\", {\n * template: (ctx) => `<button>${ctx.props.text}</button>`,\n * style: `button { color: blue; }`\n * });\n */\n component(name, definition) {\n /** @type {Map<string, ComponentDefinition>} */\n this._components.set(name, definition);\n return this;\n }\n\n /**\n * Mounts a registered component to a DOM element.\n * This will initialize the component, set up its reactive state, and render it to the DOM.\n *\n * @public\n * @param {HTMLElement} container - The DOM element where the component will be mounted.\n * @param {string|ComponentDefinition} compName - The name of the registered component or a direct component definition.\n * @param {Object<string, unknown>} [props={}] - Optional properties to pass to the component.\n * @returns {Promise<MountResult>}\n * A Promise that resolves to an object containing:\n * - container: The mounted component's container element\n * - data: The component's reactive state and context\n * - unmount: Function to clean up and unmount the component\n * @throws {Error} If the container is not found, or component is not registered.\n * @example\n * const instance = await app.mount(document.getElementById(\"app\"), \"myComponent\", { text: \"Click me\" });\n * // Later...\n * instance.unmount();\n */\n async mount(container, compName, props = {}) {\n if (!container) throw new Error(`Container not found: ${container}`);\n\n if (container._eleva_instance) return container._eleva_instance;\n\n /** @type {ComponentDefinition} */\n const definition =\n typeof compName === \"string\" ? this._components.get(compName) : compName;\n if (!definition) throw new Error(`Component \"${compName}\" not registered.`);\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 or string that returns the component's HTML structure\n * - style: Optional function or string for component-scoped CSS styles\n * - children: Optional object defining nested child components\n */\n const { setup, template, style, children } = definition;\n\n /** @type {ComponentContext} */\n const context = {\n props,\n emitter: this.emitter,\n /** @type {(v: unknown) => Signal<unknown>} */\n signal: (v) => new this.signal(v),\n };\n\n /**\n * Processes the mounting of the component.\n * This function handles:\n * 1. Merging setup data with the component context\n * 2. Setting up reactive watchers\n * 3. Rendering the component\n * 4. Managing component lifecycle\n *\n * @param {Object<string, unknown>} data - Data returned from the component's setup function\n * @returns {Promise<MountResult>} An object containing:\n * - container: The mounted component's container element\n * - data: The component's reactive state and context\n * - unmount: Function to clean up and unmount the component\n */\n const processMount = async (data) => {\n /** @type {ComponentContext} */\n const mergedContext = { ...context, ...data };\n /** @type {Array<() => void>} */\n const watchers = [];\n /** @type {Array<MountResult>} */\n const childInstances = [];\n /** @type {Array<() => void>} */\n const listeners = [];\n\n // Execute before hooks\n if (!this._isMounted) {\n /** @type {LifecycleHookContext} */\n await mergedContext.onBeforeMount?.({\n container,\n context: mergedContext,\n });\n } else {\n /** @type {LifecycleHookContext} */\n await mergedContext.onBeforeUpdate?.({\n container,\n context: mergedContext,\n });\n }\n\n /**\n * Renders the component by:\n * 1. Processing the template\n * 2. Updating the DOM\n * 3. Processing events, injecting styles, and mounting child components.\n */\n const render = async () => {\n const templateResult =\n typeof template === \"function\"\n ? await template(mergedContext)\n : template;\n const newHtml = TemplateEngine.parse(templateResult, mergedContext);\n this.renderer.patchDOM(container, newHtml);\n this._processEvents(container, mergedContext, listeners);\n if (style)\n this._injectStyles(container, compName, style, mergedContext);\n if (children)\n await this._mountComponents(container, children, childInstances);\n\n if (!this._isMounted) {\n /** @type {LifecycleHookContext} */\n await mergedContext.onMount?.({\n container,\n context: mergedContext,\n });\n this._isMounted = true;\n } else {\n /** @type {LifecycleHookContext} */\n await mergedContext.onUpdate?.({\n container,\n context: mergedContext,\n });\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 for (const val of Object.values(data)) {\n if (val instanceof Signal) watchers.push(val.watch(render));\n }\n\n await render();\n\n const instance = {\n container,\n data: mergedContext,\n /**\n * Unmounts the component, cleaning up watchers and listeners, child components, and clearing the container.\n *\n * @returns {void}\n */\n unmount: async () => {\n /** @type {UnmountHookContext} */\n await mergedContext.onUnmount?.({\n container,\n context: mergedContext,\n cleanup: {\n watchers: watchers,\n listeners: listeners,\n children: childInstances,\n },\n });\n for (const fn of watchers) fn();\n for (const fn of listeners) fn();\n for (const child of childInstances) await child.unmount();\n container.innerHTML = \"\";\n delete container._eleva_instance;\n },\n };\n\n container._eleva_instance = instance;\n return instance;\n };\n\n // Handle asynchronous setup.\n const setupResult = typeof setup === \"function\" ? await setup(context) : {};\n return await processMount(setupResult);\n }\n\n /**\n * Processes DOM elements for event binding based on attributes starting with \"@\".\n * This method handles the event delegation system and ensures proper cleanup of event listeners.\n *\n * @private\n * @param {HTMLElement} container - The container element in which to search for event attributes.\n * @param {ComponentContext} context - The current component context containing event handler definitions.\n * @param {Array<() => void>} listeners - Array to collect cleanup functions for each event listener.\n * @returns {void}\n */\n _processEvents(container, context, listeners) {\n /** @type {NodeListOf<Element>} */\n const elements = container.querySelectorAll(\"*\");\n for (const el of elements) {\n /** @type {NamedNodeMap} */\n const attrs = el.attributes;\n for (let i = 0; i < attrs.length; i++) {\n /** @type {Attr} */\n const attr = attrs[i];\n\n if (!attr.name.startsWith(\"@\")) continue;\n\n /** @type {keyof HTMLElementEventMap} */\n const event = attr.name.slice(1);\n /** @type {string} */\n const handlerName = attr.value;\n /** @type {(event: Event) => void} */\n const handler =\n context[handlerName] || TemplateEngine.evaluate(handlerName, context);\n if (typeof handler === \"function\") {\n el.addEventListener(event, handler);\n el.removeAttribute(attr.name);\n listeners.push(() => el.removeEventListener(event, handler));\n }\n }\n }\n }\n\n /**\n * Injects scoped styles into the component's container.\n * The styles are automatically prefixed to prevent style leakage to other components.\n *\n * @private\n * @param {HTMLElement} container - The container element where styles should be injected.\n * @param {string} compName - The component name used to identify the style element.\n * @param {(function(ComponentContext): string)|string} styleDef - The component's style definition (function or string).\n * @param {ComponentContext} context - The current component context for style interpolation.\n * @returns {void}\n */\n _injectStyles(container, compName, styleDef, context) {\n /** @type {string} */\n const newStyle =\n typeof styleDef === \"function\"\n ? TemplateEngine.parse(styleDef(context), context)\n : styleDef;\n /** @type {HTMLStyleElement|null} */\n let styleEl = container.querySelector(`style[data-e-style=\"${compName}\"]`);\n\n if (styleEl && styleEl.textContent === newStyle) return;\n if (!styleEl) {\n styleEl = document.createElement(\"style\");\n styleEl.setAttribute(\"data-e-style\", compName);\n container.appendChild(styleEl);\n }\n\n styleEl.textContent = newStyle;\n }\n\n /**\n * Extracts props from an element's attributes that start with the specified prefix.\n * This method is used to collect component properties from DOM elements.\n *\n * @private\n * @param {HTMLElement} element - The DOM element to extract props from\n * @param {string} prefix - The prefix to look for in attributes\n * @returns {Record<string, string>} An object containing the extracted props\n * @example\n * // For an element with attributes:\n * // <div :name=\"John\" :age=\"25\">\n * // Returns: { name: \"John\", age: \"25\" }\n */\n _extractProps(element, prefix) {\n /** @type {Record<string, string>} */\n const props = {};\n for (const { name, value } of element.attributes) {\n if (name.startsWith(prefix)) {\n props[name.replace(prefix, \"\")] = value;\n }\n }\n return props;\n }\n\n /**\n * Mounts all components within the parent component's container.\n * This method handles mounting of explicitly defined children components.\n *\n * The mounting process follows these steps:\n * 1. Cleans up any existing component instances\n * 2. Mounts explicitly defined children components\n *\n * @private\n * @param {HTMLElement} container - The container element to mount components in\n * @param {Object<string, ComponentDefinition>} children - Map of selectors to component definitions for explicit children\n * @param {Array<MountResult>} childInstances - Array to store all mounted component instances\n * @returns {Promise<void>}\n *\n * @example\n * // Explicit children mounting:\n * const children = {\n * 'UserProfile': UserProfileComponent,\n * '#settings-panel': \"settings-panel\"\n * };\n */\n async _mountComponents(container, children, childInstances) {\n for (const [selector, component] of Object.entries(children)) {\n if (!selector) continue;\n for (const el of container.querySelectorAll(selector)) {\n if (!(el instanceof HTMLElement)) continue;\n /** @type {Record<string, string>} */\n const props = this._extractProps(el, \":\");\n /** @type {MountResult} */\n const instance = await this.mount(el, component, props);\n if (instance && !childInstances.includes(instance)) {\n childInstances.push(instance);\n }\n }\n }\n }\n}\n"],"names":["TemplateEngine","expressionPattern","parse","template","data","replace","_","expression","evaluate","Function","Signal","constructor","value","_value","_watchers","Set","_pending","newVal","_notify","watch","fn","add","delete","queueMicrotask","forEach","Emitter","_events","Map","on","event","handler","has","set","get","off","handlers","size","emit","args","CAMEL_RE","Renderer","_tempContainer","document","createElement","patchDOM","container","newHtml","HTMLElement","TypeError","innerHTML","_diff","error","Error","message","oldParent","newParent","isEqualNode","oldChildren","Array","from","childNodes","newChildren","oldStartIdx","newStartIdx","oldEndIdx","length","newEndIdx","oldKeyMap","oldStartNode","newStartNode","_keysMatch","_patchNode","_createKeyMap","newKey","nodeType","Node","ELEMENT_NODE","getAttribute","moveIndex","undefined","oldNodeToMove","insertBefore","cloneNode","refNode","i","node","nodeName","hasAttribute","removeChild","oldNode","newNode","oldKey","_eleva_instance","replaceWith","oldEl","newEl","_updateAttributes","TEXT_NODE","nodeValue","oldAttrs","attributes","newAttrs","name","setAttribute","s","slice","l","toUpperCase","dataset","prop","includes","descriptor","Object","getOwnPropertyDescriptor","getPrototypeOf","isBoolean","call","removeAttribute","children","start","end","map","child","key","Eleva","config","emitter","signal","renderer","_components","_plugins","_isMounted","use","plugin","options","install","component","definition","mount","compName","props","setup","style","context","v","processMount","mergedContext","watchers","childInstances","listeners","onBeforeMount","onBeforeUpdate","render","templateResult","_processEvents","_injectStyles","_mountComponents","onMount","onUpdate","val","values","push","instance","unmount","onUnmount","cleanup","setupResult","elements","querySelectorAll","el","attrs","attr","startsWith","handlerName","addEventListener","removeEventListener","styleDef","newStyle","styleEl","querySelector","textContent","appendChild","_extractProps","element","prefix","selector","entries"],"mappings":";;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,cAAc,CAAC;AAC1B;AACF;AACA;AACA;EACE,OAAOC,iBAAiB,GAAG,sBAAsB;;AAEjD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,OAAOC,KAAKA,CAACC,QAAQ,EAAEC,IAAI,EAAE;AAC3B,IAAA,IAAI,OAAOD,QAAQ,KAAK,QAAQ,EAAE,OAAOA,QAAQ;IACjD,OAAOA,QAAQ,CAACE,OAAO,CAAC,IAAI,CAACJ,iBAAiB,EAAE,CAACK,CAAC,EAAEC,UAAU,KAC5D,IAAI,CAACC,QAAQ,CAACD,UAAU,EAAEH,IAAI,CAChC,CAAC;AACH;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,OAAOI,QAAQA,CAACD,UAAU,EAAEH,IAAI,EAAE;AAChC,IAAA,IAAI,OAAOG,UAAU,KAAK,QAAQ,EAAE,OAAOA,UAAU;IACrD,IAAI;MACF,OAAO,IAAIE,QAAQ,CAAC,MAAM,EAAE,CAAuBF,oBAAAA,EAAAA,UAAU,CAAK,GAAA,CAAA,CAAC,CAACH,IAAI,CAAC;AAC3E,KAAC,CAAC,MAAM;AACN,MAAA,OAAO,EAAE;AACX;AACF;AACF;;AC9DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMM,MAAM,CAAC;AAClB;AACF;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAACC,KAAK,EAAE;AACjB;IACA,IAAI,CAACC,MAAM,GAAGD,KAAK;AACnB;AACA,IAAA,IAAI,CAACE,SAAS,GAA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AAGJ,QAAQ,CAAClC,CAAC,CAAC;AACzB,MAAA,IAAIsC,KAAK,EAAEhD,QAAQ,KAAKC,IAAI,CAACC,YAAY,EAAE;AACzC,QAAA,MAAM+C,GAAG,GAAGD,KAAK,CAAC7C,YAAY,CAAC,KAAK,CAAC;QACrC,IAAI8C,GAAG,EAAEF,GAAG,CAACzF,GAAG,CAAC2F,GAAG,EAAEvC,CAAC,CAAC;AAC1B;AACF;AACA,IAAA,OAAOqC,GAAG;AACZ;AACF;;AC7QA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,KAAK,CAAC;AACjB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACEjH,EAAAA,WAAWA,CAAC2F,IAAI,EAAEuB,MAAM,GAAG,EAAE,EAAE;AAC7B;IACA,IAAI,CAACvB,IAAI,GAAGA,IAAI;AAChB;IACA,IAAI,CAACuB,MAAM,GAAGA,MAAM;AACpB;AACA,IAAA,IAAI,CAACC,OAAO,GAAG,IAAIrG,OAAO,EAAE;AAC5B;IACA,IAAI,CAACsG,MAAM,GAAGrH,MAAM;AACpB;AACA,IAAA,IAAI,CAACsH,QAAQ,GAAG,IAAIxF,QAAQ,EAAE;;AAE9B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AQ,IAAI,CAACd,cAAc,CAACtC,QAAQ,CAACoD,QAAQ,CAAC,EAAE;AAClDd,UAAAA,cAAc,CAACa,IAAI,CAACC,QAAQ,CAAC;AAC/B;AACF;AACF;AACF;AACF;;;;"}
1
+ {"version":3,"file":"eleva.cjs.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 A secure template engine that handles interpolation and dynamic attribute parsing.\n * Provides a safe way to evaluate expressions in templates while preventing XSS attacks.\n * All methods are static and can be called directly on the class.\n *\n * @example\n * const template = \"Hello, {{name}}!\";\n * const data = { name: \"World\" };\n * const result = TemplateEngine.parse(template, data); // Returns: \"Hello, World!\"\n */\nexport class TemplateEngine {\n /**\n * @private {RegExp} Regular expression for matching template expressions in the format {{ expression }}\n * @type {RegExp}\n */\n static expressionPattern = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n\n /**\n * Parses a template string, replacing expressions with their evaluated values.\n * Expressions are evaluated in the provided data context.\n *\n * @public\n * @static\n * @param {string} template - The template string to parse.\n * @param {Record<string, unknown>} data - The data context for evaluating expressions.\n * @returns {string} The parsed template with expressions replaced by their values.\n * @example\n * const result = TemplateEngine.parse(\"{{user.name}} is {{user.age}} years old\", {\n * user: { name: \"John\", age: 30 }\n * }); // Returns: \"John is 30 years old\"\n */\n static parse(template, data) {\n if (typeof template !== \"string\") return template;\n return template.replace(this.expressionPattern, (_, expression) =>\n this.evaluate(expression, data)\n );\n }\n\n /**\n * Evaluates an expression in the context of the provided data object.\n * Note: This does not provide a true sandbox and evaluated expressions may access global scope.\n * The use of the `with` statement is necessary for expression evaluation but has security implications.\n * Expressions should be carefully validated before evaluation.\n *\n * @public\n * @static\n * @param {string} expression - The expression to evaluate.\n * @param {Record<string, unknown>} data - The data context for evaluation.\n * @returns {unknown} The result of the evaluation, or an empty string if evaluation fails.\n * @example\n * const result = TemplateEngine.evaluate(\"user.name\", { user: { name: \"John\" } }); // Returns: \"John\"\n * const age = TemplateEngine.evaluate(\"user.age\", { user: { age: 30 } }); // Returns: 30\n */\n static evaluate(expression, data) {\n if (typeof expression !== \"string\") return expression;\n try {\n return new Function(\"data\", `with(data) { return ${expression}; }`)(data);\n } catch {\n return \"\";\n }\n }\n}\n","\"use strict\";\n\n/**\n * @class ⚡ Signal\n * @classdesc A reactive data holder that enables fine-grained reactivity in the Eleva framework.\n * Signals notify registered watchers when their value changes, enabling efficient DOM updates\n * through targeted patching rather than full re-renders.\n * Updates are batched using microtasks to prevent multiple synchronous notifications.\n * The class is generic, allowing type-safe handling of any value type T.\n *\n * @example\n * const count = new Signal(0);\n * count.watch((value) => console.log(`Count changed to: ${value}`));\n * count.value = 1; // Logs: \"Count changed to: 1\"\n * @template T\n */\nexport class Signal {\n /**\n * Creates a new Signal instance with the specified initial value.\n *\n * @public\n * @param {T} value - The initial value of the signal.\n */\n constructor(value) {\n /** @private {T} Internal storage for the signal's current value */\n this._value = value;\n /** @private {Set<(value: T) => void>} Collection of callback functions to be notified when value changes */\n this._watchers = new Set();\n /** @private {boolean} Flag to prevent multiple synchronous watcher notifications and batch updates into microtasks */\n this._pending = false;\n }\n\n /**\n * Gets the current value of the signal.\n *\n * @public\n * @returns {T} 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 * The notification is batched using microtasks to prevent multiple synchronous updates.\n *\n * @public\n * @param {T} newVal - The new value to set.\n * @returns {void}\n */\n set value(newVal) {\n if (this._value === newVal) return;\n\n this._value = newVal;\n this._notify();\n }\n\n /**\n * Registers a watcher function that will be called whenever the signal's value changes.\n * The watcher will receive the new value as its argument.\n *\n * @public\n * @param {(value: T) => void} fn - The callback function to invoke on value change.\n * @returns {() => boolean} A function to unsubscribe the watcher.\n * @example\n * const unsubscribe = signal.watch((value) => console.log(value));\n * // Later...\n * unsubscribe(); // Stops watching for changes\n */\n watch(fn) {\n this._watchers.add(fn);\n return () => this._watchers.delete(fn);\n }\n\n /**\n * Notifies all registered watchers of a value change using microtask scheduling.\n * Uses a pending flag to batch multiple synchronous updates into a single notification.\n * All watcher callbacks receive the current value when executed.\n *\n * @private\n * @returns {void}\n */\n _notify() {\n if (this._pending) return;\n\n this._pending = true;\n queueMicrotask(() => {\n /** @type {(fn: (value: T) => void) => void} */\n this._watchers.forEach((fn) => fn(this._value));\n this._pending = false;\n });\n }\n}\n","\"use strict\";\n\n/**\n * @class 📡 Emitter\n * @classdesc A robust event emitter that enables inter-component communication through a publish-subscribe pattern.\n * Components can emit events and listen for events from other components, facilitating loose coupling\n * and reactive updates across the application.\n * Events are handled synchronously in the order they were registered, with proper cleanup\n * of unsubscribed handlers.\n * Event names should follow the format 'namespace:action' (e.g., 'user:login', 'cart:update').\n *\n * @example\n * const emitter = new Emitter();\n * emitter.on('user:login', (user) => console.log(`User logged in: ${user.name}`));\n * emitter.emit('user:login', { name: 'John' }); // Logs: \"User logged in: John\"\n */\nexport class Emitter {\n /**\n * Creates a new Emitter instance.\n *\n * @public\n */\n constructor() {\n /** @private {Map<string, Set<(data: unknown) => void>>} Map of event names to their registered handler functions */\n this._events = new Map();\n }\n\n /**\n * Registers an event handler for the specified event name.\n * The handler will be called with the event data when the event is emitted.\n * Event names should follow the format 'namespace:action' for consistency.\n *\n * @public\n * @param {string} event - The name of the event to listen for (e.g., 'user:login').\n * @param {(data: unknown) => void} handler - The callback function to invoke when the event occurs.\n * @returns {() => void} A function to unsubscribe the event handler.\n * @example\n * const unsubscribe = emitter.on('user:login', (user) => console.log(user));\n * // Later...\n * unsubscribe(); // Stops listening for the event\n */\n on(event, handler) {\n if (!this._events.has(event)) this._events.set(event, new Set());\n\n this._events.get(event).add(handler);\n return () => this.off(event, handler);\n }\n\n /**\n * Removes an event handler for the specified event name.\n * If no handler is provided, all handlers for the event are removed.\n * Automatically cleans up empty event sets to prevent memory leaks.\n *\n * @public\n * @param {string} event - The name of the event to remove handlers from.\n * @param {(data: unknown) => void} [handler] - The specific handler function to remove.\n * @returns {void}\n * @example\n * // Remove a specific handler\n * emitter.off('user:login', loginHandler);\n * // Remove all handlers for an event\n * emitter.off('user:login');\n */\n off(event, handler) {\n if (!this._events.has(event)) return;\n if (handler) {\n const handlers = this._events.get(event);\n handlers.delete(handler);\n // Remove the event if there are no handlers left\n if (handlers.size === 0) this._events.delete(event);\n } else {\n this._events.delete(event);\n }\n }\n\n /**\n * Emits an event with the specified data to all registered handlers.\n * Handlers are called synchronously in the order they were registered.\n * If no handlers are registered for the event, the emission is silently ignored.\n *\n * @public\n * @param {string} event - The name of the event to emit.\n * @param {...unknown} args - Optional arguments to pass to the event handlers.\n * @returns {void}\n * @example\n * // Emit an event with data\n * emitter.emit('user:login', { name: 'John', role: 'admin' });\n * // Emit an event with multiple arguments\n * emitter.emit('cart:update', { items: [] }, { total: 0 });\n */\n emit(event, ...args) {\n if (!this._events.has(event)) return;\n this._events.get(event).forEach((handler) => handler(...args));\n }\n}\n","\"use strict\";\n\n/**\n * A regular expression to match hyphenated lowercase letters.\n * @private\n * @type {RegExp}\n */\nconst CAMEL_RE = /-([a-z])/g;\n\n/**\n * @class 🎨 Renderer\n * @classdesc A high-performance DOM renderer that implements an optimized direct DOM diffing algorithm.\n *\n * Key features:\n * - Single-pass diffing algorithm for efficient DOM updates\n * - Key-based node reconciliation for optimal performance\n * - Intelligent attribute handling for ARIA, data attributes, and boolean properties\n * - Preservation of special Eleva-managed instances and style elements\n * - Memory-efficient with reusable temporary containers\n *\n * The renderer is designed to minimize DOM operations while maintaining\n * exact attribute synchronization and proper node identity preservation.\n * It's particularly optimized for frequent updates and complex DOM structures.\n *\n * @example\n * const renderer = new Renderer();\n * const container = document.getElementById(\"app\");\n * const newHtml = \"<div>Updated content</div>\";\n * renderer.patchDOM(container, newHtml);\n */\nexport class Renderer {\n /**\n * Creates a new Renderer instance.\n * @public\n */\n constructor() {\n /**\n * A temporary container to hold the new HTML content while diffing.\n * @private\n * @type {HTMLElement}\n */\n this._tempContainer = document.createElement(\"div\");\n }\n\n /**\n * Patches the DOM of the given container with the provided HTML string.\n *\n * @public\n * @param {HTMLElement} container - The container element to patch.\n * @param {string} newHtml - The new HTML string.\n * @returns {void}\n * @throws {TypeError} If container is not an HTMLElement or newHtml is not a string.\n * @throws {Error} If DOM patching fails.\n */\n patchDOM(container, newHtml) {\n if (!(container instanceof HTMLElement)) {\n throw new TypeError(\"Container must be an HTMLElement\");\n }\n if (typeof newHtml !== \"string\") {\n throw new TypeError(\"newHtml must be a string\");\n }\n\n try {\n this._tempContainer.innerHTML = newHtml;\n this._diff(container, this._tempContainer);\n } catch (error) {\n throw new Error(`Failed to patch DOM: ${error.message}`);\n }\n }\n\n /**\n * Performs a diff between two DOM nodes and patches the old node to match the new node.\n *\n * @private\n * @param {HTMLElement} oldParent - The original DOM element.\n * @param {HTMLElement} newParent - The new DOM element.\n * @returns {void}\n */\n _diff(oldParent, newParent) {\n if (oldParent === newParent || oldParent.isEqualNode?.(newParent)) return;\n\n const oldChildren = Array.from(oldParent.childNodes);\n const newChildren = Array.from(newParent.childNodes);\n let oldStartIdx = 0,\n newStartIdx = 0;\n let oldEndIdx = oldChildren.length - 1;\n let newEndIdx = newChildren.length - 1;\n let oldKeyMap = null;\n\n while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {\n let oldStartNode = oldChildren[oldStartIdx];\n let newStartNode = newChildren[newStartIdx];\n\n if (!oldStartNode) {\n oldStartNode = oldChildren[++oldStartIdx];\n } else if (this._isSameNode(oldStartNode, newStartNode)) {\n this._patchNode(oldStartNode, newStartNode);\n oldStartIdx++;\n newStartIdx++;\n } else {\n if (!oldKeyMap) {\n oldKeyMap = this._createKeyMap(oldChildren, oldStartIdx, oldEndIdx);\n }\n const key = this._getNodeKey(newStartNode);\n const oldNodeToMove = key ? oldKeyMap.get(key) : null;\n\n if (oldNodeToMove) {\n this._patchNode(oldNodeToMove, newStartNode);\n oldParent.insertBefore(oldNodeToMove, oldStartNode);\n oldChildren[oldChildren.indexOf(oldNodeToMove)] = null;\n } else {\n oldParent.insertBefore(newStartNode.cloneNode(true), oldStartNode);\n }\n newStartIdx++;\n }\n }\n\n if (oldStartIdx > oldEndIdx) {\n const refNode = newChildren[newEndIdx + 1]\n ? oldChildren[oldStartIdx]\n : null;\n for (let i = newStartIdx; i <= newEndIdx; i++) {\n if (newChildren[i])\n oldParent.insertBefore(newChildren[i].cloneNode(true), refNode);\n }\n } else if (newStartIdx > newEndIdx) {\n for (let i = oldStartIdx; i <= oldEndIdx; i++) {\n if (oldChildren[i]) this._removeNode(oldParent, oldChildren[i]);\n }\n }\n }\n\n /**\n * Patches a single node.\n *\n * @private\n * @param {Node} oldNode - The original DOM node.\n * @param {Node} newNode - The new DOM node.\n * @returns {void}\n */\n _patchNode(oldNode, newNode) {\n if (oldNode?._eleva_instance) return;\n\n if (!this._isSameNode(oldNode, newNode)) {\n oldNode.replaceWith(newNode.cloneNode(true));\n return;\n }\n\n if (oldNode.nodeType === Node.ELEMENT_NODE) {\n this._updateAttributes(oldNode, newNode);\n this._diff(oldNode, newNode);\n } else if (\n oldNode.nodeType === Node.TEXT_NODE &&\n oldNode.nodeValue !== newNode.nodeValue\n ) {\n oldNode.nodeValue = newNode.nodeValue;\n }\n }\n\n /**\n * Removes a node from its parent.\n *\n * @private\n * @param {HTMLElement} parent - The parent element containing the node to remove.\n * @param {Node} node - The node to remove.\n * @returns {void}\n */\n _removeNode(parent, node) {\n if (node.nodeName === \"STYLE\" && node.hasAttribute(\"data-e-style\")) return;\n\n parent.removeChild(node);\n }\n\n /**\n * Updates the attributes of an element to match a new element's attributes.\n *\n * @private\n * @param {HTMLElement} oldEl - The original element to update.\n * @param {HTMLElement} newEl - The new element to update.\n * @returns {void}\n */\n _updateAttributes(oldEl, newEl) {\n const oldAttrs = oldEl.attributes;\n const newAttrs = newEl.attributes;\n\n // Single pass for new/updated attributes\n for (let i = 0; i < newAttrs.length; i++) {\n const { name, value } = newAttrs[i];\n if (name.startsWith(\"@\")) continue;\n if (oldEl.getAttribute(name) === value) continue;\n oldEl.setAttribute(name, value);\n\n if (name.startsWith(\"aria-\")) {\n const prop =\n \"aria\" + name.slice(5).replace(CAMEL_RE, (_, l) => l.toUpperCase());\n oldEl[prop] = value;\n } else if (name.startsWith(\"data-\")) {\n oldEl.dataset[name.slice(5)] = value;\n } else {\n const prop = name.replace(CAMEL_RE, (_, l) => l.toUpperCase());\n if (prop in oldEl) {\n const descriptor = Object.getOwnPropertyDescriptor(\n Object.getPrototypeOf(oldEl),\n prop\n );\n const isBoolean =\n typeof oldEl[prop] === \"boolean\" ||\n (descriptor?.get &&\n typeof descriptor.get.call(oldEl) === \"boolean\");\n if (isBoolean) {\n oldEl[prop] =\n value !== \"false\" &&\n (value === \"\" || value === prop || value === \"true\");\n } else {\n oldEl[prop] = value;\n }\n }\n }\n }\n\n // Remove any attributes no longer present\n for (let i = oldAttrs.length - 1; i >= 0; i--) {\n const name = oldAttrs[i].name;\n if (!newEl.hasAttribute(name)) {\n oldEl.removeAttribute(name);\n }\n }\n }\n\n /**\n * Determines if two nodes are the same based on their type, name, and key attributes.\n *\n * @private\n * @param {Node} oldNode - The first node to compare.\n * @param {Node} newNode - The second node to compare.\n * @returns {boolean} True if the nodes are considered the same, false otherwise.\n */\n _isSameNode(oldNode, newNode) {\n if (!oldNode || !newNode) return false;\n\n const oldKey =\n oldNode.nodeType === Node.ELEMENT_NODE\n ? oldNode.getAttribute(\"key\")\n : null;\n const newKey =\n newNode.nodeType === Node.ELEMENT_NODE\n ? newNode.getAttribute(\"key\")\n : null;\n\n if (oldKey && newKey) return oldKey === newKey;\n\n return (\n !oldKey &&\n !newKey &&\n oldNode.nodeType === newNode.nodeType &&\n oldNode.nodeName === newNode.nodeName\n );\n }\n\n /**\n * Creates a key map for the children of a parent node.\n *\n * @private\n * @param {Array<Node>} children - The children of the parent node.\n * @param {number} start - The start index of the children.\n * @param {number} end - The end index of the children.\n * @returns {Map<string, Node>} A key map for the children.\n */\n _createKeyMap(children, start, end) {\n const map = new Map();\n for (let i = start; i <= end; i++) {\n const child = children[i];\n const key = this._getNodeKey(child);\n if (key) map.set(key, child);\n }\n return map;\n }\n\n /**\n * Extracts the key attribute from a node if it exists.\n *\n * @private\n * @param {Node} node - The node to extract the key from.\n * @returns {string|null} The key attribute value or null if not found.\n */\n _getNodeKey(node) {\n return node?.nodeType === Node.ELEMENT_NODE\n ? node.getAttribute(\"key\")\n : null;\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(ComponentContext): (Record<string, unknown>|Promise<Record<string, unknown>>)} [setup]\n * Optional setup function that initializes the component's state and returns reactive data\n * @property {(function(ComponentContext): string|Promise<string>)} template\n * Required function that defines the component's HTML structure\n * @property {(function(ComponentContext): string)|string} [style]\n * Optional function or string that provides component-scoped CSS styles\n * @property {Record<string, ComponentDefinition>} [children]\n * Optional object defining nested child components\n */\n\n/**\n * @typedef {Object} ComponentContext\n * @property {Record<string, unknown>} props\n * Component properties passed during mounting\n * @property {Emitter} emitter\n * Event emitter instance for component event handling\n * @property {function<T>(value: T): Signal<T>} signal\n * Factory function to create reactive Signal instances\n * @property {function(LifecycleHookContext): Promise<void>} [onBeforeMount]\n * Hook called before component mounting\n * @property {function(LifecycleHookContext): Promise<void>} [onMount]\n * Hook called after component mounting\n * @property {function(LifecycleHookContext): Promise<void>} [onBeforeUpdate]\n * Hook called before component update\n * @property {function(LifecycleHookContext): Promise<void>} [onUpdate]\n * Hook called after component update\n * @property {function(UnmountHookContext): Promise<void>} [onUnmount]\n * Hook called during component unmounting\n */\n\n/**\n * @typedef {Object} LifecycleHookContext\n * @property {HTMLElement} container\n * The DOM element where the component is mounted\n * @property {ComponentContext} context\n * The component's reactive state and context data\n */\n\n/**\n * @typedef {Object} UnmountHookContext\n * @property {HTMLElement} container\n * The DOM element where the component is mounted\n * @property {ComponentContext} context\n * The component's reactive state and context data\n * @property {{\n * watchers: Array<() => void>, // Signal watcher cleanup functions\n * listeners: Array<() => void>, // Event listener cleanup functions\n * children: Array<MountResult> // Child component instances\n * }} cleanup\n * Object containing cleanup functions and instances\n */\n\n/**\n * @typedef {Object} MountResult\n * @property {HTMLElement} container\n * The DOM element where the component is mounted\n * @property {ComponentContext} data\n * The component's reactive state and context data\n * @property {function(): Promise<void>} unmount\n * Function to clean up and unmount the component\n */\n\n/**\n * @typedef {Object} ElevaPlugin\n * @property {function(Eleva, Record<string, unknown>): void} install\n * Function that installs the plugin into the Eleva instance\n * @property {string} name\n * Unique identifier name for the plugin\n */\n\n/**\n * @class 🧩 Eleva\n * @classdesc A modern, signal-based component runtime framework that provides lifecycle hooks,\n * scoped styles, and plugin support. Eleva manages component registration, plugin integration,\n * event handling, and DOM rendering with a focus on performance and developer experience.\n *\n * @example\n * // Basic component creation and mounting\n * const app = new Eleva(\"myApp\");\n * app.component(\"myComponent\", {\n * setup: (ctx) => ({ count: ctx.signal(0) }),\n * template: (ctx) => `<div>Hello ${ctx.props.name}</div>`\n * });\n * app.mount(document.getElementById(\"app\"), \"myComponent\", { name: \"World\" });\n *\n * @example\n * // Using lifecycle hooks\n * app.component(\"lifecycleDemo\", {\n * setup: () => {\n * return {\n * onMount: ({ container, context }) => {\n * console.log('Component mounted!');\n * }\n * };\n * },\n * template: `<div>Lifecycle Demo</div>`\n * });\n */\nexport class Eleva {\n /**\n * Creates a new Eleva instance with the specified name and configuration.\n *\n * @public\n * @param {string} name - The unique identifier name for this Eleva instance.\n * @param {Record<string, unknown>} [config={}] - Optional configuration object for the instance.\n * May include framework-wide settings and default behaviors.\n * @throws {Error} If the name is not provided or is not a string.\n * @returns {Eleva} A new Eleva instance.\n *\n * @example\n * const app = new Eleva(\"myApp\");\n * app.component(\"myComponent\", {\n * setup: (ctx) => ({ count: ctx.signal(0) }),\n * template: (ctx) => `<div>Hello ${ctx.props.name}!</div>`\n * });\n * app.mount(document.getElementById(\"app\"), \"myComponent\", { name: \"World\" });\n *\n */\n constructor(name, config = {}) {\n /** @public {string} The unique identifier name for this Eleva instance */\n this.name = name;\n /** @public {Object<string, unknown>} Optional configuration object for the Eleva instance */\n this.config = config;\n /** @public {Emitter} Instance of the event emitter for handling component events */\n this.emitter = new Emitter();\n /** @public {typeof Signal} Static reference to the Signal class for creating reactive state */\n this.signal = Signal;\n /** @public {Renderer} Instance of the renderer for handling DOM updates and patching */\n this.renderer = new Renderer();\n\n /** @private {Map<string, ComponentDefinition>} Registry of all component definitions by name */\n this._components = new Map();\n /** @private {Map<string, ElevaPlugin>} Collection of installed plugin instances by name */\n this._plugins = new Map();\n /** @private {boolean} Flag indicating if the root component is currently mounted */\n this._isMounted = false;\n }\n\n /**\n * Integrates a plugin with the Eleva framework.\n * The plugin's install function will be called with the Eleva instance and provided options.\n * After installation, the plugin will be available for use by components.\n *\n * @public\n * @param {ElevaPlugin} plugin - The plugin object which must have an `install` function.\n * @param {Object<string, unknown>} [options={}] - Optional configuration options for the plugin.\n * @returns {Eleva} The Eleva instance (for method chaining).\n * @example\n * app.use(myPlugin, { option1: \"value1\" });\n */\n use(plugin, options = {}) {\n plugin.install(this, options);\n this._plugins.set(plugin.name, plugin);\n\n return this;\n }\n\n /**\n * Registers a new component with the Eleva instance.\n * The component will be available for mounting using its registered name.\n *\n * @public\n * @param {string} name - The unique name of the component to register.\n * @param {ComponentDefinition} definition - The component definition including setup, template, style, and children.\n * @returns {Eleva} The Eleva instance (for method chaining).\n * @throws {Error} If the component name is already registered.\n * @example\n * app.component(\"myButton\", {\n * template: (ctx) => `<button>${ctx.props.text}</button>`,\n * style: `button { color: blue; }`\n * });\n */\n component(name, definition) {\n /** @type {Map<string, ComponentDefinition>} */\n this._components.set(name, definition);\n return this;\n }\n\n /**\n * Mounts a registered component to a DOM element.\n * This will initialize the component, set up its reactive state, and render it to the DOM.\n *\n * @public\n * @param {HTMLElement} container - The DOM element where the component will be mounted.\n * @param {string|ComponentDefinition} compName - The name of the registered component or a direct component definition.\n * @param {Object<string, unknown>} [props={}] - Optional properties to pass to the component.\n * @returns {Promise<MountResult>}\n * A Promise that resolves to an object containing:\n * - container: The mounted component's container element\n * - data: The component's reactive state and context\n * - unmount: Function to clean up and unmount the component\n * @throws {Error} If the container is not found, or component is not registered.\n * @example\n * const instance = await app.mount(document.getElementById(\"app\"), \"myComponent\", { text: \"Click me\" });\n * // Later...\n * instance.unmount();\n */\n async mount(container, compName, props = {}) {\n if (!container) throw new Error(`Container not found: ${container}`);\n\n if (container._eleva_instance) return container._eleva_instance;\n\n /** @type {ComponentDefinition} */\n const definition =\n typeof compName === \"string\" ? this._components.get(compName) : compName;\n if (!definition) throw new Error(`Component \"${compName}\" not registered.`);\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 or string that returns the component's HTML structure\n * - style: Optional function or string for component-scoped CSS styles\n * - children: Optional object defining nested child components\n */\n const { setup, template, style, children } = definition;\n\n /** @type {ComponentContext} */\n const context = {\n props,\n emitter: this.emitter,\n /** @type {(v: unknown) => Signal<unknown>} */\n signal: (v) => new this.signal(v),\n };\n\n /**\n * Processes the mounting of the component.\n * This function handles:\n * 1. Merging setup data with the component context\n * 2. Setting up reactive watchers\n * 3. Rendering the component\n * 4. Managing component lifecycle\n *\n * @param {Object<string, unknown>} data - Data returned from the component's setup function\n * @returns {Promise<MountResult>} An object containing:\n * - container: The mounted component's container element\n * - data: The component's reactive state and context\n * - unmount: Function to clean up and unmount the component\n */\n const processMount = async (data) => {\n /** @type {ComponentContext} */\n const mergedContext = { ...context, ...data };\n /** @type {Array<() => void>} */\n const watchers = [];\n /** @type {Array<MountResult>} */\n const childInstances = [];\n /** @type {Array<() => void>} */\n const listeners = [];\n\n // Execute before hooks\n if (!this._isMounted) {\n /** @type {LifecycleHookContext} */\n await mergedContext.onBeforeMount?.({\n container,\n context: mergedContext,\n });\n } else {\n /** @type {LifecycleHookContext} */\n await mergedContext.onBeforeUpdate?.({\n container,\n context: mergedContext,\n });\n }\n\n /**\n * Renders the component by:\n * 1. Processing the template\n * 2. Updating the DOM\n * 3. Processing events, injecting styles, and mounting child components.\n */\n const render = async () => {\n const templateResult =\n typeof template === \"function\"\n ? await template(mergedContext)\n : template;\n const newHtml = TemplateEngine.parse(templateResult, mergedContext);\n this.renderer.patchDOM(container, newHtml);\n this._processEvents(container, mergedContext, listeners);\n if (style)\n this._injectStyles(container, compName, style, mergedContext);\n if (children)\n await this._mountComponents(container, children, childInstances);\n\n if (!this._isMounted) {\n /** @type {LifecycleHookContext} */\n await mergedContext.onMount?.({\n container,\n context: mergedContext,\n });\n this._isMounted = true;\n } else {\n /** @type {LifecycleHookContext} */\n await mergedContext.onUpdate?.({\n container,\n context: mergedContext,\n });\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 for (const val of Object.values(data)) {\n if (val instanceof Signal) watchers.push(val.watch(render));\n }\n\n await render();\n\n const instance = {\n container,\n data: mergedContext,\n /**\n * Unmounts the component, cleaning up watchers and listeners, child components, and clearing the container.\n *\n * @returns {void}\n */\n unmount: async () => {\n /** @type {UnmountHookContext} */\n await mergedContext.onUnmount?.({\n container,\n context: mergedContext,\n cleanup: {\n watchers: watchers,\n listeners: listeners,\n children: childInstances,\n },\n });\n for (const fn of watchers) fn();\n for (const fn of listeners) fn();\n for (const child of childInstances) await child.unmount();\n container.innerHTML = \"\";\n delete container._eleva_instance;\n },\n };\n\n container._eleva_instance = instance;\n return instance;\n };\n\n // Handle asynchronous setup.\n const setupResult = typeof setup === \"function\" ? await setup(context) : {};\n return await processMount(setupResult);\n }\n\n /**\n * Processes DOM elements for event binding based on attributes starting with \"@\".\n * This method handles the event delegation system and ensures proper cleanup of event listeners.\n *\n * @private\n * @param {HTMLElement} container - The container element in which to search for event attributes.\n * @param {ComponentContext} context - The current component context containing event handler definitions.\n * @param {Array<() => void>} listeners - Array to collect cleanup functions for each event listener.\n * @returns {void}\n */\n _processEvents(container, context, listeners) {\n /** @type {NodeListOf<Element>} */\n const elements = container.querySelectorAll(\"*\");\n for (const el of elements) {\n /** @type {NamedNodeMap} */\n const attrs = el.attributes;\n for (let i = 0; i < attrs.length; i++) {\n /** @type {Attr} */\n const attr = attrs[i];\n\n if (!attr.name.startsWith(\"@\")) continue;\n\n /** @type {keyof HTMLElementEventMap} */\n const event = attr.name.slice(1);\n /** @type {string} */\n const handlerName = attr.value;\n /** @type {(event: Event) => void} */\n const handler =\n context[handlerName] || TemplateEngine.evaluate(handlerName, context);\n if (typeof handler === \"function\") {\n el.addEventListener(event, handler);\n el.removeAttribute(attr.name);\n listeners.push(() => el.removeEventListener(event, handler));\n }\n }\n }\n }\n\n /**\n * Injects scoped styles into the component's container.\n * The styles are automatically prefixed to prevent style leakage to other components.\n *\n * @private\n * @param {HTMLElement} container - The container element where styles should be injected.\n * @param {string} compName - The component name used to identify the style element.\n * @param {(function(ComponentContext): string)|string} styleDef - The component's style definition (function or string).\n * @param {ComponentContext} context - The current component context for style interpolation.\n * @returns {void}\n */\n _injectStyles(container, compName, styleDef, context) {\n /** @type {string} */\n const newStyle =\n typeof styleDef === \"function\"\n ? TemplateEngine.parse(styleDef(context), context)\n : styleDef;\n /** @type {HTMLStyleElement|null} */\n let styleEl = container.querySelector(`style[data-e-style=\"${compName}\"]`);\n\n if (styleEl && styleEl.textContent === newStyle) return;\n if (!styleEl) {\n styleEl = document.createElement(\"style\");\n styleEl.setAttribute(\"data-e-style\", compName);\n container.appendChild(styleEl);\n }\n\n styleEl.textContent = newStyle;\n }\n\n /**\n * Extracts props from an element's attributes that start with the specified prefix.\n * This method is used to collect component properties from DOM elements.\n *\n * @private\n * @param {HTMLElement} element - The DOM element to extract props from\n * @param {string} prefix - The prefix to look for in attributes\n * @returns {Record<string, string>} An object containing the extracted props\n * @example\n * // For an element with attributes:\n * // <div :name=\"John\" :age=\"25\">\n * // Returns: { name: \"John\", age: \"25\" }\n */\n _extractProps(element, prefix) {\n /** @type {Record<string, string>} */\n const props = {};\n for (const { name, value } of element.attributes) {\n if (name.startsWith(prefix)) {\n props[name.replace(prefix, \"\")] = value;\n }\n }\n return props;\n }\n\n /**\n * Mounts all components within the parent component's container.\n * This method handles mounting of explicitly defined children components.\n *\n * The mounting process follows these steps:\n * 1. Cleans up any existing component instances\n * 2. Mounts explicitly defined children components\n *\n * @private\n * @param {HTMLElement} container - The container element to mount components in\n * @param {Object<string, ComponentDefinition>} children - Map of selectors to component definitions for explicit children\n * @param {Array<MountResult>} childInstances - Array to store all mounted component instances\n * @returns {Promise<void>}\n *\n * @example\n * // Explicit children mounting:\n * const children = {\n * 'UserProfile': UserProfileComponent,\n * '#settings-panel': \"settings-panel\"\n * };\n */\n async _mountComponents(container, children, childInstances) {\n for (const [selector, component] of Object.entries(children)) {\n if (!selector) continue;\n for (const el of container.querySelectorAll(selector)) {\n if (!(el instanceof HTMLElement)) continue;\n /** @type {Record<string, string>} */\n const props = this._extractProps(el, \":\");\n /** @type {MountResult} */\n const instance = await this.mount(el, component, props);\n if (instance && !childInstances.includes(instance)) {\n childInstances.push(instance);\n }\n }\n }\n }\n}\n"],"names":["TemplateEngine","expressionPattern","parse","template","data","replace","_","expression","evaluate","Function","Signal","constructor","value","_value","_watchers","Set","_pending","newVal","_notify","watch","fn","add","delete","queueMicrotask","forEach","Emitter","_events","Map","on","event","handler","has","set","get","off","handlers","size","emit","args","CAMEL_RE","Renderer","_tempContainer","document","createElement","patchDOM","container","newHtml","HTMLElement","TypeError","innerHTML","_diff","error","Error","message","oldParent","newParent","isEqualNode","oldChildren","Array","from","childNodes","newChildren","oldStartIdx","newStartIdx","oldEndIdx","length","newEndIdx","oldKeyMap","oldStartNode","newStartNode","_isSameNode","_patchNode","_createKeyMap","key","_getNodeKey","oldNodeToMove","insertBefore","indexOf","cloneNode","refNode","i","_removeNode","oldNode","newNode","_eleva_instance","replaceWith","nodeType","Node","ELEMENT_NODE","_updateAttributes","TEXT_NODE","nodeValue","parent","node","nodeName","hasAttribute","removeChild","oldEl","newEl","oldAttrs","attributes","newAttrs","name","startsWith","getAttribute","setAttribute","prop","slice","l","toUpperCase","dataset","descriptor","Object","getOwnPropertyDescriptor","getPrototypeOf","isBoolean","call","removeAttribute","oldKey","newKey","children","start","end","map","child","Eleva","config","emitter","signal","renderer","_components","_plugins","_isMounted","use","plugin","options","install","component","definition","mount","compName","props","setup","style","context","v","processMount","mergedContext","watchers","childInstances","listeners","onBeforeMount","onBeforeUpdate","render","templateResult","_processEvents","_injectStyles","_mountComponents","onMount","onUpdate","val","values","push","instance","unmount","onUnmount","cleanup","setupResult","elements","querySelectorAll","el","attrs","attr","handlerName","addEventListener","removeEventListener","styleDef","newStyle","styleEl","querySelector","textContent","appendChild","_extractProps","element","prefix","selector","entries","includes"],"mappings":";;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,cAAc,CAAC;AAC1B;AACF;AACA;AACA;EACE,OAAOC,iBAAiB,GAAG,sBAAsB;;AAEjD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,OAAOC,KAAKA,CAACC,QAAQ,EAAEC,IAAI,EAAE;AAC3B,IAAA,IAAI,OAAOD,QAAQ,KAAK,QAAQ,EAAE,OAAOA,QAAQ;IACjD,OAAOA,QAAQ,CAACE,OAAO,CAAC,IAAI,CAACJ,iBAAiB,EAAE,CAACK,CAAC,EAAEC,UAAU,KAC5D,IAAI,CAACC,QAAQ,CAACD,UAAU,EAAEH,IAAI,CAChC,CAAC;AACH;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,OAAOI,QAAQ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;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMqB,KAAK,CAAC;AACjB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACElH,EAAAA,WAAWA,CAAC2F,IAAI,EAAEwB,MAAM,GAAG,EAAE,EAAE;AAC7B;IACA,IAAI,CAACxB,IAAI,GAAGA,IAAI;AAChB;IACA,IAAI,CAACwB,MAAM,GAAGA,MAAM;AACpB;AACA,IAAA,IAAI,CAACC,OAAO,GAAG,IAAItG,OAAO,EAAE;AAC5B;IACA,IAAI,CAACuG,MAAM,GAAGtH,MAAM;AACpB;AACA,IAAA,IAAI,CAACuH,QAAQ,GAAG,IAAIzF,QAAQ,EAAE;;AAE9B;AACA,IAAA,IAAI,CAAC0F,WAAW,GAAG,IAAIvG,GAAG,EAAE;AAC5B;AACA,IAAA,IAAI,CAACwG,QAAQ,GAAG,IAAIxG,GAAG,EAAE;AACzB;IACA,IAAI,CAACyG,UAAU,GAAG,KAAK;AACzB;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACEC,EAAAA,GAAGA,CAACC,MAAM,EAAEC,OAAO,GAAG,EAAE,EAAE;AACxBD,IAAAA,MAAM,CAACE,OAAO,CAAC,IAAI,EAAED,OAAO,CAAC;IAC7B,IAAI,CAACJ,QAAQ,CAACnG,GAAG,CAACsG,MAAM,CAAChC,IAAI,EAAEgC,MAAM,CAAC;AAEtC,IAAA,OAAO,IAAI;AACb;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACEG,EAAAA,SAASA,CAACnC,IAAI,EAAEoC,UAAU,EAAE;AAC1B;IAC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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,MAAMgB,gBAAgBA,CAAChH,SAAS,EAAE2E,QAAQ,EAAE6B,cAAc,EAAE;AAC1D,IAAA,KAAK,MAAM,CAACoC,QAAQ,EAAEhD,SAAS,CAAC,IAAIzB,MAAM,CAAC0E,OAAO,CAAClE,QAAQ,CAAC,EAAE;MAC5D,IAAI,CAACiE,QAAQ,EAAE;MACf,KAAK,MAAMf,EAAE,IAAI7H,SAAS,CAAC4H,gBAAgB,CAACgB,QAAQ,CAAC,EAAE;AACrD,QAAA,IAAI,EAAEf,EAAE,YAAY3H,WAAW,CAAC,EAAE;AAClC;QACA,MAAM8F,KAAK,GAAG,IAAI,CAACyC,aAAa,CAACZ,EAAE,EAAE,GAAG,CAAC;AACzC;AACA,QAAA,MAAMP,QAAQ,GAAG,MAAM,IAAI,CAACxB,KAAK,CAAC+B,EAAE,EAAEjC,SAAS,EAAEI,KAAK,CAAC;QACvD,IAAIsB,QAAQ,IAAI,CAACd,cAAc,CAACsC,QAAQ,CAACxB,QAAQ,CAAC,EAAE;AAClDd,UAAAA,cAAc,CAACa,IAAI,CAACC,QAAQ,CAAC;AAC/B;AACF;AACF;AACF;AACF;;;;"}
package/dist/eleva.d.ts CHANGED
@@ -164,49 +164,58 @@ declare class Renderer {
164
164
  * Patches the DOM of the given container with the provided HTML string.
165
165
  *
166
166
  * @public
167
- * @param {HTMLElement} container - The container whose DOM will be patched.
167
+ * @param {HTMLElement} container - The container element to patch.
168
168
  * @param {string} newHtml - The new HTML string.
169
- * @throws {TypeError} If the container is not an HTMLElement or newHtml is not a string.
170
- * @throws {Error} If the DOM patching fails.
171
169
  * @returns {void}
170
+ * @throws {TypeError} If container is not an HTMLElement or newHtml is not a string.
171
+ * @throws {Error} If DOM patching fails.
172
172
  */
173
173
  public patchDOM(container: HTMLElement, newHtml: string): void;
174
174
  /**
175
175
  * Performs a diff between two DOM nodes and patches the old node to match the new node.
176
176
  *
177
177
  * @private
178
- * @param {Node} oldParent - The old parent node to be patched.
179
- * @param {Node} newParent - The new parent node to compare.
178
+ * @param {HTMLElement} oldParent - The original DOM element.
179
+ * @param {HTMLElement} newParent - The new DOM element.
180
180
  * @returns {void}
181
181
  */
182
182
  private _diff;
183
183
  /**
184
- * Checks if the node types match.
184
+ * Patches a single node.
185
185
  *
186
186
  * @private
187
- * @param {Node} oldNode - The old node.
188
- * @param {Node} newNode - The new node.
189
- * @returns {boolean} True if the nodes match, false otherwise.
187
+ * @param {Node} oldNode - The original DOM node.
188
+ * @param {Node} newNode - The new DOM node.
189
+ * @returns {void}
190
190
  */
191
- private _keysMatch;
191
+ private _patchNode;
192
192
  /**
193
- * Patches a node.
193
+ * Removes a node from its parent.
194
194
  *
195
195
  * @private
196
- * @param {Node} oldNode - The old node to patch.
197
- * @param {Node} newNode - The new node to patch.
196
+ * @param {HTMLElement} parent - The parent element containing the node to remove.
197
+ * @param {Node} node - The node to remove.
198
198
  * @returns {void}
199
199
  */
200
- private _patchNode;
200
+ private _removeNode;
201
201
  /**
202
- * Updates the attributes of an element.
202
+ * Updates the attributes of an element to match a new element's attributes.
203
203
  *
204
204
  * @private
205
- * @param {HTMLElement} oldEl - The old element to update.
205
+ * @param {HTMLElement} oldEl - The original element to update.
206
206
  * @param {HTMLElement} newEl - The new element to update.
207
207
  * @returns {void}
208
208
  */
209
209
  private _updateAttributes;
210
+ /**
211
+ * Determines if two nodes are the same based on their type, name, and key attributes.
212
+ *
213
+ * @private
214
+ * @param {Node} oldNode - The first node to compare.
215
+ * @param {Node} newNode - The second node to compare.
216
+ * @returns {boolean} True if the nodes are considered the same, false otherwise.
217
+ */
218
+ private _isSameNode;
210
219
  /**
211
220
  * Creates a key map for the children of a parent node.
212
221
  *
@@ -214,9 +223,17 @@ declare class Renderer {
214
223
  * @param {Array<Node>} children - The children of the parent node.
215
224
  * @param {number} start - The start index of the children.
216
225
  * @param {number} end - The end index of the children.
217
- * @returns {Map<string, number>} A map of key to child index.
226
+ * @returns {Map<string, Node>} A key map for the children.
218
227
  */
219
228
  private _createKeyMap;
229
+ /**
230
+ * Extracts the key attribute from a node if it exists.
231
+ *
232
+ * @private
233
+ * @param {Node} node - The node to extract the key from.
234
+ * @returns {string|null} The key attribute value or null if not found.
235
+ */
236
+ private _getNodeKey;
220
237
  }
221
238
 
222
239
  /**