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/dist/eleva.umd.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
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -296,11 +296,11 @@
296
296
  * Patches the DOM of the given container with the provided HTML string.
297
297
  *
298
298
  * @public
299
- * @param {HTMLElement} container - The container whose DOM will be patched.
299
+ * @param {HTMLElement} container - The container element to patch.
300
300
  * @param {string} newHtml - The new HTML string.
301
- * @throws {TypeError} If the container is not an HTMLElement or newHtml is not a string.
302
- * @throws {Error} If the DOM patching fails.
303
301
  * @returns {void}
302
+ * @throws {TypeError} If container is not an HTMLElement or newHtml is not a string.
303
+ * @throws {Error} If DOM patching fails.
304
304
  */
305
305
  patchDOM(container, newHtml) {
306
306
  if (!(container instanceof HTMLElement)) {
@@ -321,8 +321,8 @@
321
321
  * Performs a diff between two DOM nodes and patches the old node to match the new node.
322
322
  *
323
323
  * @private
324
- * @param {Node} oldParent - The old parent node to be patched.
325
- * @param {Node} newParent - The new parent node to compare.
324
+ * @param {HTMLElement} oldParent - The original DOM element.
325
+ * @param {HTMLElement} newParent - The new DOM element.
326
326
  * @returns {void}
327
327
  */
328
328
  _diff(oldParent, newParent) {
@@ -338,34 +338,27 @@
338
338
  let oldStartNode = oldChildren[oldStartIdx];
339
339
  let newStartNode = newChildren[newStartIdx];
340
340
  if (!oldStartNode) {
341
- oldStartIdx++;
342
- continue;
343
- }
344
- if (!newStartNode) {
345
- newStartIdx++;
346
- continue;
347
- }
348
- if (this._keysMatch(oldStartNode, newStartNode)) {
341
+ oldStartNode = oldChildren[++oldStartIdx];
342
+ } else if (this._isSameNode(oldStartNode, newStartNode)) {
349
343
  this._patchNode(oldStartNode, newStartNode);
350
344
  oldStartIdx++;
351
345
  newStartIdx++;
352
346
  } else {
353
- oldKeyMap ??= this._createKeyMap(oldChildren, oldStartIdx, oldEndIdx);
354
- const newKey = newStartNode.nodeType === Node.ELEMENT_NODE ? newStartNode.getAttribute("key") : null;
355
- const moveIndex = newKey ? oldKeyMap.get(newKey) : undefined;
356
- const oldNodeToMove = moveIndex !== undefined ? oldChildren[moveIndex] : null;
347
+ if (!oldKeyMap) {
348
+ oldKeyMap = this._createKeyMap(oldChildren, oldStartIdx, oldEndIdx);
349
+ }
350
+ const key = this._getNodeKey(newStartNode);
351
+ const oldNodeToMove = key ? oldKeyMap.get(key) : null;
357
352
  if (oldNodeToMove) {
358
353
  this._patchNode(oldNodeToMove, newStartNode);
359
354
  oldParent.insertBefore(oldNodeToMove, oldStartNode);
360
- if (moveIndex !== undefined) oldChildren[moveIndex] = null;
355
+ oldChildren[oldChildren.indexOf(oldNodeToMove)] = null;
361
356
  } else {
362
357
  oldParent.insertBefore(newStartNode.cloneNode(true), oldStartNode);
363
358
  }
364
359
  newStartIdx++;
365
360
  }
366
361
  }
367
-
368
- // Cleanup
369
362
  if (oldStartIdx > oldEndIdx) {
370
363
  const refNode = newChildren[newEndIdx + 1] ? oldChildren[oldStartIdx] : null;
371
364
  for (let i = newStartIdx; i <= newEndIdx; i++) {
@@ -373,58 +366,51 @@
373
366
  }
374
367
  } else if (newStartIdx > newEndIdx) {
375
368
  for (let i = oldStartIdx; i <= oldEndIdx; i++) {
376
- const node = oldChildren[i];
377
- if (node && !(node.nodeName === "STYLE" && node.hasAttribute("data-e-style"))) {
378
- oldParent.removeChild(node);
379
- }
369
+ if (oldChildren[i]) this._removeNode(oldParent, oldChildren[i]);
380
370
  }
381
371
  }
382
372
  }
383
373
 
384
374
  /**
385
- * Checks if the node types match.
375
+ * Patches a single node.
386
376
  *
387
377
  * @private
388
- * @param {Node} oldNode - The old node.
389
- * @param {Node} newNode - The new node.
390
- * @returns {boolean} True if the nodes match, false otherwise.
391
- */
392
- _keysMatch(oldNode, newNode) {
393
- if (oldNode.nodeType !== Node.ELEMENT_NODE) return true;
394
- const oldKey = oldNode.getAttribute("key");
395
- const newKey = newNode.getAttribute("key");
396
- return oldKey === newKey;
397
- }
398
-
399
- /**
400
- * Patches a node.
401
- *
402
- * @private
403
- * @param {Node} oldNode - The old node to patch.
404
- * @param {Node} newNode - The new node to patch.
378
+ * @param {Node} oldNode - The original DOM node.
379
+ * @param {Node} newNode - The new DOM node.
405
380
  * @returns {void}
406
381
  */
407
382
  _patchNode(oldNode, newNode) {
408
383
  if (oldNode?._eleva_instance) return;
409
- if (oldNode.nodeType !== newNode.nodeType || oldNode.nodeName !== newNode.nodeName) {
384
+ if (!this._isSameNode(oldNode, newNode)) {
410
385
  oldNode.replaceWith(newNode.cloneNode(true));
411
386
  return;
412
387
  }
413
388
  if (oldNode.nodeType === Node.ELEMENT_NODE) {
414
- const oldEl = oldNode;
415
- const newEl = newNode;
416
- this._updateAttributes(oldEl, newEl);
417
- this._diff(oldEl, newEl);
389
+ this._updateAttributes(oldNode, newNode);
390
+ this._diff(oldNode, newNode);
418
391
  } else if (oldNode.nodeType === Node.TEXT_NODE && oldNode.nodeValue !== newNode.nodeValue) {
419
392
  oldNode.nodeValue = newNode.nodeValue;
420
393
  }
421
394
  }
422
395
 
423
396
  /**
424
- * Updates the attributes of an element.
397
+ * Removes a node from its parent.
425
398
  *
426
399
  * @private
427
- * @param {HTMLElement} oldEl - The old element to update.
400
+ * @param {HTMLElement} parent - The parent element containing the node to remove.
401
+ * @param {Node} node - The node to remove.
402
+ * @returns {void}
403
+ */
404
+ _removeNode(parent, node) {
405
+ if (node.nodeName === "STYLE" && node.hasAttribute("data-e-style")) return;
406
+ parent.removeChild(node);
407
+ }
408
+
409
+ /**
410
+ * Updates the attributes of an element to match a new element's attributes.
411
+ *
412
+ * @private
413
+ * @param {HTMLElement} oldEl - The original element to update.
428
414
  * @param {HTMLElement} newEl - The new element to update.
429
415
  * @returns {void}
430
416
  */
@@ -438,15 +424,16 @@
438
424
  name,
439
425
  value
440
426
  } = newAttrs[i];
441
- if (name[0] === "@" || oldEl.getAttribute(name) === value) continue;
427
+ if (name.startsWith("@")) continue;
428
+ if (oldEl.getAttribute(name) === value) continue;
442
429
  oldEl.setAttribute(name, value);
443
- if (name[0] === "a" && name[4] === "-") {
444
- const s = name.slice(5);
445
- oldEl["aria" + s.replace(CAMEL_RE, (_, l) => l.toUpperCase())] = value;
446
- } else if (name[0] === "d" && name[3] === "-") {
430
+ if (name.startsWith("aria-")) {
431
+ const prop = "aria" + name.slice(5).replace(CAMEL_RE, (_, l) => l.toUpperCase());
432
+ oldEl[prop] = value;
433
+ } else if (name.startsWith("data-")) {
447
434
  oldEl.dataset[name.slice(5)] = value;
448
435
  } else {
449
- const prop = name.includes("-") ? name.replace(CAMEL_RE, (_, l) => l.toUpperCase()) : name;
436
+ const prop = name.replace(CAMEL_RE, (_, l) => l.toUpperCase());
450
437
  if (prop in oldEl) {
451
438
  const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(oldEl), prop);
452
439
  const isBoolean = typeof oldEl[prop] === "boolean" || descriptor?.get && typeof descriptor.get.call(oldEl) === "boolean";
@@ -468,6 +455,22 @@
468
455
  }
469
456
  }
470
457
 
458
+ /**
459
+ * Determines if two nodes are the same based on their type, name, and key attributes.
460
+ *
461
+ * @private
462
+ * @param {Node} oldNode - The first node to compare.
463
+ * @param {Node} newNode - The second node to compare.
464
+ * @returns {boolean} True if the nodes are considered the same, false otherwise.
465
+ */
466
+ _isSameNode(oldNode, newNode) {
467
+ if (!oldNode || !newNode) return false;
468
+ const oldKey = oldNode.nodeType === Node.ELEMENT_NODE ? oldNode.getAttribute("key") : null;
469
+ const newKey = newNode.nodeType === Node.ELEMENT_NODE ? newNode.getAttribute("key") : null;
470
+ if (oldKey && newKey) return oldKey === newKey;
471
+ return !oldKey && !newKey && oldNode.nodeType === newNode.nodeType && oldNode.nodeName === newNode.nodeName;
472
+ }
473
+
471
474
  /**
472
475
  * Creates a key map for the children of a parent node.
473
476
  *
@@ -475,19 +478,28 @@
475
478
  * @param {Array<Node>} children - The children of the parent node.
476
479
  * @param {number} start - The start index of the children.
477
480
  * @param {number} end - The end index of the children.
478
- * @returns {Map<string, number>} A map of key to child index.
481
+ * @returns {Map<string, Node>} A key map for the children.
479
482
  */
480
483
  _createKeyMap(children, start, end) {
481
484
  const map = new Map();
482
485
  for (let i = start; i <= end; i++) {
483
486
  const child = children[i];
484
- if (child?.nodeType === Node.ELEMENT_NODE) {
485
- const key = child.getAttribute("key");
486
- if (key) map.set(key, i);
487
- }
487
+ const key = this._getNodeKey(child);
488
+ if (key) map.set(key, child);
488
489
  }
489
490
  return map;
490
491
  }
492
+
493
+ /**
494
+ * Extracts the key attribute from a node if it exists.
495
+ *
496
+ * @private
497
+ * @param {Node} node - The node to extract the key from.
498
+ * @returns {string|null} The key attribute value or null if not found.
499
+ */
500
+ _getNodeKey(node) {
501
+ return node?.nodeType === Node.ELEMENT_NODE ? node.getAttribute("key") : null;
502
+ }
491
503
  }
492
504
 
493
505
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"eleva.umd.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":";;;;;;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACO,MAAMA,cAAc,CAAC;EAC1B;EACF;EACA;EACA;IACE,OAAOC,iBAAiB,GAAG,sBAAsB;;EAEjD;EACF;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACE,EAAA,OAAOC,KAAKA,CAACC,QAAQ,EAA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EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACO,MAAMG,KAAK,CAAC;EACjB;EACF;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACEjH,EAAAA,WAAWA,CAAC2F,IAAI,EAAEuB,MAAM,GAAG,EAAE,EAAE;EAC7B;MACA,IAAI,CAACvB,IAAI,GAAGA,IAAI;EAChB;MACA,IAAI,CAACuB,MAAM,GAAGA,MAAM;EACpB;EACA,IAAA,IAAI,CAACC,OAAO,GAAG,IAAIrG,OAAO,EAAE;EAC5B;MACA,IAAI,CAACsG,MAAM,GAAGrH,MAAM;EACpB;EACA,IAAA,IAAI,CAACsH,QAAQ,GAAG,IAAIxF,QAAQ,EAAE;;EAE9B;EACA,IAAA,IAAI,CAACyF,WAAW,GAAG,IAAItG,GAAG,EAAE;EAC5B;EACA,IAAA,IAAI,CAACuG,QAAQ,GAAG,IAAIvG,GAAG,EAAE;EACzB;MACA,IAAI,CAACwG,UAAU,GAAG,KAAK;EACzB;;EAEA;EACF;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACEC,EAAAA,GAAGA,CAACC,MAAM,EAAEC,OAAO,GAAG,EAAE,EAAE;EACxBD,IAAAA,MAAM,CAACE,OAAO,CAAC,IAAI,EAAED,OAAO,CAAC;MAC7B,IAA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IE,IAAI,CAACsE,UAAU,CAACY,MAAM,CAAC,EAAE;UAC3B5C,KAAK,CAACtC,IAAI,CAACjG,OAAO,CAACmL,MAAM,EAAE,EAAE,CAAC,CAAC,GAAG5K,KAAK;EACzC;EACF;EACA,IAAA,OAAOgI,KAAK;EACd;;EAEA;EACF;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACE,EAAA,MAAMgB,gBAAgBA,CAAC/G,SAAS,EAAEyE,QAAQ,EAAE8B,cAAc,EAAE;EAC1D,IAAA,KAAK,MAAM,CAACqC,QAAQ,EAAEjD,SAAS,CAAC,IAAIxB,MAAM,CAAC0E,OAAO,CAACpE,QAAQ,CAAC,EAAE;QAC5D,IAAI,CAACmE,QAAQ,EAAE;QACf,KAAK,MAAMhB,EAAE,IAAI5H,SAAS,CAAC2H,gBAAgB,CAACiB,QAAQ,CAAC,EAAE;EACrD,QAAA,IAAI,EAAEhB,EAAE,YAAY1H,WAAW,CAAC,EAAE;EAClC;UACA,MAAM6F,KAAK,GAAG,IAAI,CAAC0C,aAAa,CAACb,EAAE,EAAE,GAAG,CAAC;EACzC;EACA,QAAA,MAAMP,QAAQ,GAAG,MAAM,IAAI,CAACxB,KAAK,CAAC+B,EAAE,EAAEjC,SAAS,EAAEI,KAAK,CAAC;UACvD,IAAIsB,QAAQ,IAAI,CAACd,cAAc,CAACtC,QAAQ,CAACoD,QAAQ,CAAC,EAAE;EAClDd,UAAAA,cAAc,CAACa,IAAI,CAACC,QAAQ,CAAC;EAC/B;EACF;EACF;EACF;EACF;;;;;;;;"}
1
+ {"version":3,"file":"eleva.umd.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":";;;;;;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACO,MAAMA,cAAc,CAAC;EAC1B;EACF;EACA;EACA;IACE,OAAOC,iBAAiB,GAAG,sBAAsB;;EAEjD;EACF;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACE,EAAA,OAAOC,KAAKA,CAACC,QAAQ,EAAEC,IAAI,EAAE;EAC3B,IAAA,IAAI,OAAOD,QAAQ,KAAK,QAAQ,EAAE,OAAOA,QAAQ;MACjD,OAAOA,QAAQ,CAACE,OAAO,CAAC,IAAI,CAACJ,iBAAiB,EAAE,CAACK,CAAC,EAAEC,UAAU,KAC5D,IAAI,CAACC,QAAQ,CAACD,UAAU,EAAEH,IAAI,CAChC,CAAC;EACH;;EAEA;EACF;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACE,EAAA,OAAOI,QAAQA,CAACD,UAAU,EAAEH,IAAI,EAAE;EAChC,IAAA,IAAI,OAAOG,UAAU,KAAK,QAAQ,EAAE,OAAOA,UAAU;MACrD,IAAI;QACF,OAAO,IAAIE,QAAQ,CAAC,MAAM,EAAE,CAAuBF,oBAAAA,EAAAA,UAAU,CAAK,GAAA,CAAA,CAAC,CAACH,IAAI,CAAC;EAC3E,KAAC,CAAC,MAAM;EACN,MAAA,OAAO,EAAE;EACX;EACF;EACF;;EC9DA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;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AAG,IAAIhG,GAAG,EAAE;MACrB,KAAK,IAAIqD,CAAC,GAAGyC,KAAK,EAAEzC,CAAC,IAAI0C,GAAG,EAAE1C,CAAC,EAAE,EAAE;EACjC,MAAA,MAAM4C,KAAK,GAAGJ,QAAQ,CAACxC,CAAC,CAAC;EACzB,MAAA,MAAMP,GAAG,GAAG,IAAI,CAACC,WAAW,CAACkD,KAAK,CAAC;QACnC,IAAInD,GAAG,EAAEkD,GAAG,CAAC3F,GAAG,CAACyC,GAAG,EAAEmD,KAAK,CAAC;EAC9B;EACA,IAAA,OAAOD,GAAG;EACZ;;EAEA;EACF;EACA;EACA;EACA;EACA;EACA;IACEjD,WAAWA,CAACmB,IAAI,EAAE;EAChB,IAAA,OAAOA,IAAI,EAAEP,QAAQ,KAAKC,IAAI,CAACC,YAAY,GACvCK,IAAI,CAACW,YAAY,CAAC,KAAK,CAAC,GACxB,IAAI;EACV;EACF;;EC3RA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACO,MAAMqB,KAAK,CAAC;EACjB;EACF;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACElH,EAAAA,WAAWA,CAAC2F,IAAI,EAAEwB,MAAM,GAAG,EAAE,EAAE;EAC7B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,EAAEf,EAAE,YAAY3H,WAAW,CAAC,EAAE;EAClC;UACA,MAAM8F,KAAK,GAAG,IAAI,CAACyC,aAAa,CAACZ,EAAE,EAAE,GAAG,CAAC;EACzC;EACA,QAAA,MAAMP,QAAQ,GAAG,MAAM,IAAI,CAACxB,KAAK,CAAC+B,EAAE,EAAEjC,SAAS,EAAEI,KAAK,CAAC;UACvD,IAAIsB,QAAQ,IAAI,CAACd,cAAc,CAACsC,QAAQ,CAACxB,QAAQ,CAAC,EAAE;EAClDd,UAAAA,cAAc,CAACa,IAAI,CAACC,QAAQ,CAAC;EAC/B;EACF;EACF;EACF;EACF;;;;;;;;"}
@@ -1,3 +1,3 @@
1
- /*! Eleva v1.2.18-beta | MIT License | https://elevajs.com */
2
- var e,t;e=this,t=function(){"use strict";class e{static expressionPattern=/\{\{\s*(.*?)\s*\}\}/g;static parse(e,t){return"string"!=typeof e?e:e.replace(this.expressionPattern,((e,n)=>this.evaluate(n,t)))}static evaluate(e,t){if("string"!=typeof e)return e;try{return new Function("data",`with(data) { return ${e}; }`)(t)}catch{return""}}}class t{constructor(e){this._value=e,this._watchers=new Set,this._pending=!1}get value(){return this._value}set value(e){this._value!==e&&(this._value=e,this._notify())}watch(e){return this._watchers.add(e),()=>this._watchers.delete(e)}_notify(){this._pending||(this._pending=!0,queueMicrotask((()=>{this._watchers.forEach((e=>e(this._value))),this._pending=!1})))}}class n{constructor(){this._events=new Map}on(e,t){return this._events.has(e)||this._events.set(e,new Set),this._events.get(e).add(t),()=>this.off(e,t)}off(e,t){if(this._events.has(e))if(t){const n=this._events.get(e);n.delete(t),0===n.size&&this._events.delete(e)}else this._events.delete(e)}emit(e,...t){this._events.has(e)&&this._events.get(e).forEach((e=>e(...t)))}}const s=/-([a-z])/g;class o{constructor(){this._tempContainer=document.createElement("div")}patchDOM(e,t){if(!(e instanceof HTMLElement))throw new TypeError("Container must be an HTMLElement");if("string"!=typeof t)throw new TypeError("newHtml must be a string");try{this._tempContainer.innerHTML=t,this._diff(e,this._tempContainer)}catch(e){throw new Error(`Failed to patch DOM: ${e.message}`)}}_diff(e,t){if(e===t||e.isEqualNode?.(t))return;const n=Array.from(e.childNodes),s=Array.from(t.childNodes);let o=0,i=0,r=n.length-1,a=s.length-1,c=null;for(;o<=r&&i<=a;){let t=n[o],a=s[i];if(t)if(a)if(this._keysMatch(t,a))this._patchNode(t,a),o++,i++;else{c??=this._createKeyMap(n,o,r);const s=a.nodeType===Node.ELEMENT_NODE?a.getAttribute("key"):null,l=s?c.get(s):void 0,u=void 0!==l?n[l]:null;u?(this._patchNode(u,a),e.insertBefore(u,t),void 0!==l&&(n[l]=null)):e.insertBefore(a.cloneNode(!0),t),i++}else i++;else o++}if(o>r){const t=s[a+1]?n[o]:null;for(let n=i;n<=a;n++)s[n]&&e.insertBefore(s[n].cloneNode(!0),t)}else if(i>a)for(let t=o;t<=r;t++){const s=n[t];!s||"STYLE"===s.nodeName&&s.hasAttribute("data-e-style")||e.removeChild(s)}}_keysMatch(e,t){return e.nodeType!==Node.ELEMENT_NODE||e.getAttribute("key")===t.getAttribute("key")}_patchNode(e,t){if(!e?._eleva_instance)if(e.nodeType===t.nodeType&&e.nodeName===t.nodeName)if(e.nodeType===Node.ELEMENT_NODE){const n=e,s=t;this._updateAttributes(n,s),this._diff(n,s)}else e.nodeType===Node.TEXT_NODE&&e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue);else e.replaceWith(t.cloneNode(!0))}_updateAttributes(e,t){const n=e.attributes,o=t.attributes;for(let t=0;t<o.length;t++){const{name:n,value:i}=o[t];if("@"!==n[0]&&e.getAttribute(n)!==i)if(e.setAttribute(n,i),"a"===n[0]&&"-"===n[4])e["aria"+n.slice(5).replace(s,((e,t)=>t.toUpperCase()))]=i;else if("d"===n[0]&&"-"===n[3])e.dataset[n.slice(5)]=i;else{const t=n.includes("-")?n.replace(s,((e,t)=>t.toUpperCase())):n;if(t in e){const n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),t),s="boolean"==typeof e[t]||n?.get&&"boolean"==typeof n.get.call(e);e[t]=s?"false"!==i&&(""===i||i===t||"true"===i):i}}}for(let s=n.length-1;s>=0;s--){const o=n[s].name;t.hasAttribute(o)||e.removeAttribute(o)}}_createKeyMap(e,t,n){const s=new Map;for(let o=t;o<=n;o++){const t=e[o];if(t?.nodeType===Node.ELEMENT_NODE){const e=t.getAttribute("key");e&&s.set(e,o)}}return s}}return class{constructor(e,s={}){this.name=e,this.config=s,this.emitter=new n,this.signal=t,this.renderer=new o,this._components=new Map,this._plugins=new Map,this._isMounted=!1}use(e,t={}){return e.install(this,t),this._plugins.set(e.name,e),this}component(e,t){return this._components.set(e,t),this}async mount(n,s,o={}){if(!n)throw new Error(`Container not found: ${n}`);if(n._eleva_instance)return n._eleva_instance;const i="string"==typeof s?this._components.get(s):s;if(!i)throw new Error(`Component "${s}" not registered.`);const{setup:r,template:a,style:c,children:l}=i,u={props:o,emitter:this.emitter,signal:e=>new this.signal(e)},h="function"==typeof r?await r(u):{};return await(async o=>{const i={...u,...o},r=[],h=[],f=[];this._isMounted?await(i.onBeforeUpdate?.({container:n,context:i})):await(i.onBeforeMount?.({container:n,context:i}));const d=async()=>{const t="function"==typeof a?await a(i):a,o=e.parse(t,i);this.renderer.patchDOM(n,o),this._processEvents(n,i,f),c&&this._injectStyles(n,s,c,i),l&&await this._mountComponents(n,l,h),this._isMounted?await(i.onUpdate?.({container:n,context:i})):(await(i.onMount?.({container:n,context:i})),this._isMounted=!0)};for(const e of Object.values(o))e instanceof t&&r.push(e.watch(d));await d();const p={container:n,data:i,unmount:async()=>{await(i.onUnmount?.({container:n,context:i,cleanup:{watchers:r,listeners:f,children:h}}));for(const e of r)e();for(const e of f)e();for(const e of h)await e.unmount();n.innerHTML="",delete n._eleva_instance}};return n._eleva_instance=p,p})(h)}_processEvents(t,n,s){const o=t.querySelectorAll("*");for(const t of o){const o=t.attributes;for(let i=0;i<o.length;i++){const r=o[i];if(!r.name.startsWith("@"))continue;const a=r.name.slice(1),c=r.value,l=n[c]||e.evaluate(c,n);"function"==typeof l&&(t.addEventListener(a,l),t.removeAttribute(r.name),s.push((()=>t.removeEventListener(a,l))))}}}_injectStyles(t,n,s,o){const i="function"==typeof s?e.parse(s(o),o):s;let r=t.querySelector(`style[data-e-style="${n}"]`);r&&r.textContent===i||(r||(r=document.createElement("style"),r.setAttribute("data-e-style",n),t.appendChild(r)),r.textContent=i)}_extractProps(e,t){const n={};for(const{name:s,value:o}of e.attributes)s.startsWith(t)&&(n[s.replace(t,"")]=o);return n}async _mountComponents(e,t,n){for(const[s,o]of Object.entries(t))if(s)for(const t of e.querySelectorAll(s)){if(!(t instanceof HTMLElement))continue;const e=this._extractProps(t,":"),s=await this.mount(t,o,e);s&&!n.includes(s)&&n.push(s)}}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Eleva=t();
1
+ /*! Eleva v1.2.19-beta | MIT License | https://elevajs.com */
2
+ var e,t;e=this,t=function(){"use strict";class e{static expressionPattern=/\{\{\s*(.*?)\s*\}\}/g;static parse(e,t){return"string"!=typeof e?e:e.replace(this.expressionPattern,((e,n)=>this.evaluate(n,t)))}static evaluate(e,t){if("string"!=typeof e)return e;try{return new Function("data",`with(data) { return ${e}; }`)(t)}catch{return""}}}class t{constructor(e){this._value=e,this._watchers=new Set,this._pending=!1}get value(){return this._value}set value(e){this._value!==e&&(this._value=e,this._notify())}watch(e){return this._watchers.add(e),()=>this._watchers.delete(e)}_notify(){this._pending||(this._pending=!0,queueMicrotask((()=>{this._watchers.forEach((e=>e(this._value))),this._pending=!1})))}}class n{constructor(){this._events=new Map}on(e,t){return this._events.has(e)||this._events.set(e,new Set),this._events.get(e).add(t),()=>this.off(e,t)}off(e,t){if(this._events.has(e))if(t){const n=this._events.get(e);n.delete(t),0===n.size&&this._events.delete(e)}else this._events.delete(e)}emit(e,...t){this._events.has(e)&&this._events.get(e).forEach((e=>e(...t)))}}const s=/-([a-z])/g;class o{constructor(){this._tempContainer=document.createElement("div")}patchDOM(e,t){if(!(e instanceof HTMLElement))throw new TypeError("Container must be an HTMLElement");if("string"!=typeof t)throw new TypeError("newHtml must be a string");try{this._tempContainer.innerHTML=t,this._diff(e,this._tempContainer)}catch(e){throw new Error(`Failed to patch DOM: ${e.message}`)}}_diff(e,t){if(e===t||e.isEqualNode?.(t))return;const n=Array.from(e.childNodes),s=Array.from(t.childNodes);let o=0,i=0,r=n.length-1,a=s.length-1,c=null;for(;o<=r&&i<=a;){let t=n[o],a=s[i];if(t)if(this._isSameNode(t,a))this._patchNode(t,a),o++,i++;else{c||(c=this._createKeyMap(n,o,r));const s=this._getNodeKey(a),l=s?c.get(s):null;l?(this._patchNode(l,a),e.insertBefore(l,t),n[n.indexOf(l)]=null):e.insertBefore(a.cloneNode(!0),t),i++}else t=n[++o]}if(o>r){const t=s[a+1]?n[o]:null;for(let n=i;n<=a;n++)s[n]&&e.insertBefore(s[n].cloneNode(!0),t)}else if(i>a)for(let t=o;t<=r;t++)n[t]&&this._removeNode(e,n[t])}_patchNode(e,t){e?._eleva_instance||(this._isSameNode(e,t)?e.nodeType===Node.ELEMENT_NODE?(this._updateAttributes(e,t),this._diff(e,t)):e.nodeType===Node.TEXT_NODE&&e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue):e.replaceWith(t.cloneNode(!0)))}_removeNode(e,t){"STYLE"===t.nodeName&&t.hasAttribute("data-e-style")||e.removeChild(t)}_updateAttributes(e,t){const n=e.attributes,o=t.attributes;for(let t=0;t<o.length;t++){const{name:n,value:i}=o[t];if(!n.startsWith("@")&&e.getAttribute(n)!==i)if(e.setAttribute(n,i),n.startsWith("aria-"))e["aria"+n.slice(5).replace(s,((e,t)=>t.toUpperCase()))]=i;else if(n.startsWith("data-"))e.dataset[n.slice(5)]=i;else{const t=n.replace(s,((e,t)=>t.toUpperCase()));if(t in e){const n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),t),s="boolean"==typeof e[t]||n?.get&&"boolean"==typeof n.get.call(e);e[t]=s?"false"!==i&&(""===i||i===t||"true"===i):i}}}for(let s=n.length-1;s>=0;s--){const o=n[s].name;t.hasAttribute(o)||e.removeAttribute(o)}}_isSameNode(e,t){if(!e||!t)return!1;const n=e.nodeType===Node.ELEMENT_NODE?e.getAttribute("key"):null,s=t.nodeType===Node.ELEMENT_NODE?t.getAttribute("key"):null;return n&&s?n===s:!n&&!s&&e.nodeType===t.nodeType&&e.nodeName===t.nodeName}_createKeyMap(e,t,n){const s=new Map;for(let o=t;o<=n;o++){const t=e[o],n=this._getNodeKey(t);n&&s.set(n,t)}return s}_getNodeKey(e){return e?.nodeType===Node.ELEMENT_NODE?e.getAttribute("key"):null}}return class{constructor(e,s={}){this.name=e,this.config=s,this.emitter=new n,this.signal=t,this.renderer=new o,this._components=new Map,this._plugins=new Map,this._isMounted=!1}use(e,t={}){return e.install(this,t),this._plugins.set(e.name,e),this}component(e,t){return this._components.set(e,t),this}async mount(n,s,o={}){if(!n)throw new Error(`Container not found: ${n}`);if(n._eleva_instance)return n._eleva_instance;const i="string"==typeof s?this._components.get(s):s;if(!i)throw new Error(`Component "${s}" not registered.`);const{setup:r,template:a,style:c,children:l}=i,h={props:o,emitter:this.emitter,signal:e=>new this.signal(e)},u="function"==typeof r?await r(h):{};return await(async o=>{const i={...h,...o},r=[],u=[],f=[];this._isMounted?await(i.onBeforeUpdate?.({container:n,context:i})):await(i.onBeforeMount?.({container:n,context:i}));const d=async()=>{const t="function"==typeof a?await a(i):a,o=e.parse(t,i);this.renderer.patchDOM(n,o),this._processEvents(n,i,f),c&&this._injectStyles(n,s,c,i),l&&await this._mountComponents(n,l,u),this._isMounted?await(i.onUpdate?.({container:n,context:i})):(await(i.onMount?.({container:n,context:i})),this._isMounted=!0)};for(const e of Object.values(o))e instanceof t&&r.push(e.watch(d));await d();const p={container:n,data:i,unmount:async()=>{await(i.onUnmount?.({container:n,context:i,cleanup:{watchers:r,listeners:f,children:u}}));for(const e of r)e();for(const e of f)e();for(const e of u)await e.unmount();n.innerHTML="",delete n._eleva_instance}};return n._eleva_instance=p,p})(u)}_processEvents(t,n,s){const o=t.querySelectorAll("*");for(const t of o){const o=t.attributes;for(let i=0;i<o.length;i++){const r=o[i];if(!r.name.startsWith("@"))continue;const a=r.name.slice(1),c=r.value,l=n[c]||e.evaluate(c,n);"function"==typeof l&&(t.addEventListener(a,l),t.removeAttribute(r.name),s.push((()=>t.removeEventListener(a,l))))}}}_injectStyles(t,n,s,o){const i="function"==typeof s?e.parse(s(o),o):s;let r=t.querySelector(`style[data-e-style="${n}"]`);r&&r.textContent===i||(r||(r=document.createElement("style"),r.setAttribute("data-e-style",n),t.appendChild(r)),r.textContent=i)}_extractProps(e,t){const n={};for(const{name:s,value:o}of e.attributes)s.startsWith(t)&&(n[s.replace(t,"")]=o);return n}async _mountComponents(e,t,n){for(const[s,o]of Object.entries(t))if(s)for(const t of e.querySelectorAll(s)){if(!(t instanceof HTMLElement))continue;const e=this._extractProps(t,":"),s=await this.mount(t,o,e);s&&!n.includes(s)&&n.push(s)}}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Eleva=t();
3
3
  //# sourceMappingURL=eleva.umd.min.js.map