eleva 1.0.0-rc.6 → 1.0.0-rc.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +139 -10
- package/dist/eleva-plugins.cjs.js +675 -1
- package/dist/eleva-plugins.cjs.js.map +1 -1
- package/dist/eleva-plugins.esm.js +675 -2
- package/dist/eleva-plugins.esm.js.map +1 -1
- package/dist/eleva-plugins.umd.js +675 -1
- package/dist/eleva-plugins.umd.js.map +1 -1
- package/dist/eleva-plugins.umd.min.js +2 -2
- package/dist/eleva-plugins.umd.min.js.map +1 -1
- package/dist/eleva.cjs.js +39 -28
- package/dist/eleva.cjs.js.map +1 -1
- package/dist/eleva.d.ts +63 -2
- package/dist/eleva.esm.js +39 -28
- package/dist/eleva.esm.js.map +1 -1
- package/dist/eleva.umd.js +39 -28
- package/dist/eleva.umd.js.map +1 -1
- package/dist/eleva.umd.min.js +2 -2
- package/dist/eleva.umd.min.js.map +1 -1
- package/dist/plugins/store.umd.js +684 -0
- package/dist/plugins/store.umd.js.map +1 -0
- package/dist/plugins/store.umd.min.js +3 -0
- package/dist/plugins/store.umd.min.js.map +1 -0
- package/package.json +17 -16
- package/src/core/Eleva.js +42 -27
- package/src/plugins/Store.js +741 -0
- package/src/plugins/index.js +6 -1
- package/types/core/Eleva.d.ts +14 -2
- package/types/core/Eleva.d.ts.map +1 -1
- package/types/plugins/Store.d.ts +86 -0
- package/types/plugins/Store.d.ts.map +1 -0
- package/types/plugins/index.d.ts +1 -0
package/dist/eleva.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Eleva v1.0.0-rc.
|
|
1
|
+
/*! Eleva v1.0.0-rc.9 | MIT License | https://elevajs.com */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -609,6 +609,8 @@ class Eleva {
|
|
|
609
609
|
this.emitter = new Emitter();
|
|
610
610
|
/** @public {typeof Signal} Static reference to the Signal class for creating reactive state */
|
|
611
611
|
this.signal = Signal;
|
|
612
|
+
/** @public {typeof TemplateEngine} Static reference to the TemplateEngine class for template parsing */
|
|
613
|
+
this.templateEngine = TemplateEngine;
|
|
612
614
|
/** @public {Renderer} Instance of the renderer for handling DOM updates and patching */
|
|
613
615
|
this.renderer = new Renderer();
|
|
614
616
|
|
|
@@ -616,8 +618,6 @@ class Eleva {
|
|
|
616
618
|
this._components = new Map();
|
|
617
619
|
/** @private {Map<string, ElevaPlugin>} Collection of installed plugin instances by name */
|
|
618
620
|
this._plugins = new Map();
|
|
619
|
-
/** @private {boolean} Flag indicating if the root component is currently mounted */
|
|
620
|
-
this._isMounted = false;
|
|
621
621
|
/** @private {number} Counter for generating unique component IDs */
|
|
622
622
|
this._componentCounter = 0;
|
|
623
623
|
}
|
|
@@ -627,12 +627,23 @@ class Eleva {
|
|
|
627
627
|
* The plugin's install function will be called with the Eleva instance and provided options.
|
|
628
628
|
* After installation, the plugin will be available for use by components.
|
|
629
629
|
*
|
|
630
|
+
* Note: Plugins that wrap core methods (e.g., mount) must be uninstalled in reverse order
|
|
631
|
+
* of installation (LIFO - Last In, First Out) to avoid conflicts.
|
|
632
|
+
*
|
|
630
633
|
* @public
|
|
631
634
|
* @param {ElevaPlugin} plugin - The plugin object which must have an `install` function.
|
|
632
635
|
* @param {Object<string, unknown>} [options={}] - Optional configuration options for the plugin.
|
|
633
636
|
* @returns {Eleva} The Eleva instance (for method chaining).
|
|
634
637
|
* @example
|
|
635
638
|
* app.use(myPlugin, { option1: "value1" });
|
|
639
|
+
*
|
|
640
|
+
* @example
|
|
641
|
+
* // Correct uninstall order (LIFO)
|
|
642
|
+
* app.use(PluginA);
|
|
643
|
+
* app.use(PluginB);
|
|
644
|
+
* // Uninstall in reverse order:
|
|
645
|
+
* PluginB.uninstall(app);
|
|
646
|
+
* PluginA.uninstall(app);
|
|
636
647
|
*/
|
|
637
648
|
use(plugin, options = {}) {
|
|
638
649
|
this._plugins.set(plugin.name, plugin);
|
|
@@ -739,44 +750,44 @@ class Eleva {
|
|
|
739
750
|
const childInstances = [];
|
|
740
751
|
/** @type {Array<() => void>} */
|
|
741
752
|
const listeners = [];
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
if (!this._isMounted) {
|
|
745
|
-
/** @type {LifecycleHookContext} */
|
|
746
|
-
await mergedContext.onBeforeMount?.({
|
|
747
|
-
container,
|
|
748
|
-
context: mergedContext
|
|
749
|
-
});
|
|
750
|
-
} else {
|
|
751
|
-
/** @type {LifecycleHookContext} */
|
|
752
|
-
await mergedContext.onBeforeUpdate?.({
|
|
753
|
-
container,
|
|
754
|
-
context: mergedContext
|
|
755
|
-
});
|
|
756
|
-
}
|
|
753
|
+
/** @private {boolean} Local mounted state for this component instance */
|
|
754
|
+
let isMounted = false;
|
|
757
755
|
|
|
758
756
|
/**
|
|
759
757
|
* Renders the component by:
|
|
760
|
-
* 1.
|
|
761
|
-
* 2.
|
|
762
|
-
* 3.
|
|
758
|
+
* 1. Executing lifecycle hooks
|
|
759
|
+
* 2. Processing the template
|
|
760
|
+
* 3. Updating the DOM
|
|
761
|
+
* 4. Processing events, injecting styles, and mounting child components.
|
|
763
762
|
*/
|
|
764
763
|
const render = async () => {
|
|
764
|
+
// Execute before hooks
|
|
765
|
+
if (!isMounted) {
|
|
766
|
+
await mergedContext.onBeforeMount?.({
|
|
767
|
+
container,
|
|
768
|
+
context: mergedContext
|
|
769
|
+
});
|
|
770
|
+
} else {
|
|
771
|
+
await mergedContext.onBeforeUpdate?.({
|
|
772
|
+
container,
|
|
773
|
+
context: mergedContext
|
|
774
|
+
});
|
|
775
|
+
}
|
|
765
776
|
const templateResult = typeof template === "function" ? await template(mergedContext) : template;
|
|
766
|
-
const newHtml =
|
|
777
|
+
const newHtml = this.templateEngine.parse(templateResult, mergedContext);
|
|
767
778
|
this.renderer.patchDOM(container, newHtml);
|
|
768
779
|
this._processEvents(container, mergedContext, listeners);
|
|
769
780
|
if (style) this._injectStyles(container, compId, style, mergedContext);
|
|
770
781
|
if (children) await this._mountComponents(container, children, childInstances);
|
|
771
|
-
|
|
772
|
-
|
|
782
|
+
|
|
783
|
+
// Execute after hooks
|
|
784
|
+
if (!isMounted) {
|
|
773
785
|
await mergedContext.onMount?.({
|
|
774
786
|
container,
|
|
775
787
|
context: mergedContext
|
|
776
788
|
});
|
|
777
|
-
|
|
789
|
+
isMounted = true;
|
|
778
790
|
} else {
|
|
779
|
-
/** @type {LifecycleHookContext} */
|
|
780
791
|
await mergedContext.onUpdate?.({
|
|
781
792
|
container,
|
|
782
793
|
context: mergedContext
|
|
@@ -854,7 +865,7 @@ class Eleva {
|
|
|
854
865
|
/** @type {string} */
|
|
855
866
|
const handlerName = attr.value;
|
|
856
867
|
/** @type {(event: Event) => void} */
|
|
857
|
-
const handler = context[handlerName] ||
|
|
868
|
+
const handler = context[handlerName] || this.templateEngine.evaluate(handlerName, context);
|
|
858
869
|
if (typeof handler === "function") {
|
|
859
870
|
el.addEventListener(event, handler);
|
|
860
871
|
el.removeAttribute(attr.name);
|
|
@@ -877,7 +888,7 @@ class Eleva {
|
|
|
877
888
|
*/
|
|
878
889
|
_injectStyles(container, compId, styleDef, context) {
|
|
879
890
|
/** @type {string} */
|
|
880
|
-
const newStyle = typeof styleDef === "function" ?
|
|
891
|
+
const newStyle = typeof styleDef === "function" ? this.templateEngine.parse(styleDef(context), context) : styleDef;
|
|
881
892
|
|
|
882
893
|
/** @type {HTMLStyleElement|null} */
|
|
883
894
|
let styleEl = container.querySelector(`style[data-e-style="${compId}"]`);
|
package/dist/eleva.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eleva.cjs.js","sources":["../src/modules/TemplateEngine.js","../src/modules/Signal.js","../src/modules/Emitter.js","../src/modules/Renderer.js","../src/core/Eleva.js"],"sourcesContent":["\"use strict\";\n\n/**\n * @class 🔒 TemplateEngine\n * @classdesc A secure template engine that handles interpolation and dynamic attribute parsing.\n * Provides a safe way to evaluate expressions in templates while preventing XSS attacks.\n * All methods are static and can be called directly on the class.\n *\n * @example\n * const template = \"Hello, {{name}}!\";\n * const data = { name: \"World\" };\n * const result = TemplateEngine.parse(template, data); // Returns: \"Hello, World!\"\n */\nexport class TemplateEngine {\n /**\n * @private {RegExp} Regular expression for matching template expressions in the format {{ expression }}\n * @type {RegExp}\n */\n static expressionPattern = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n\n /**\n * Parses a template string, replacing expressions with their evaluated values.\n * Expressions are evaluated in the provided data context.\n *\n * @public\n * @static\n * @param {string} template - The template string to parse.\n * @param {Record<string, unknown>} data - The data context for evaluating expressions.\n * @returns {string} The parsed template with expressions replaced by their values.\n * @example\n * const result = TemplateEngine.parse(\"{{user.name}} is {{user.age}} years old\", {\n * user: { name: \"John\", age: 30 }\n * }); // Returns: \"John is 30 years old\"\n */\n static parse(template, data) {\n if (typeof template !== \"string\") return template;\n return template.replace(this.expressionPattern, (_, expression) =>\n this.evaluate(expression, data)\n );\n }\n\n /**\n * Evaluates an expression in the context of the provided data object.\n * Note: This does not provide a true sandbox and evaluated expressions may access global scope.\n * The use of the `with` statement is necessary for expression evaluation but has security implications.\n * Expressions should be carefully validated before evaluation.\n *\n * @public\n * @static\n * @param {string} expression - The expression to evaluate.\n * @param {Record<string, unknown>} data - The data context for evaluation.\n * @returns {unknown} The result of the evaluation, or an empty string if evaluation fails.\n * @example\n * const result = TemplateEngine.evaluate(\"user.name\", { user: { name: \"John\" } }); // Returns: \"John\"\n * const age = TemplateEngine.evaluate(\"user.age\", { user: { age: 30 } }); // Returns: 30\n */\n static evaluate(expression, data) {\n if (typeof expression !== \"string\") return expression;\n try {\n return new Function(\"data\", `with(data) { return ${expression}; }`)(data);\n } catch {\n return \"\";\n }\n }\n}\n","\"use strict\";\n\n/**\n * @class ⚡ Signal\n * @classdesc A reactive data holder that enables fine-grained reactivity in the Eleva framework.\n * Signals notify registered watchers when their value changes, enabling efficient DOM updates\n * through targeted patching rather than full re-renders.\n * Updates are batched using microtasks to prevent multiple synchronous notifications.\n * The class is generic, allowing type-safe handling of any value type T.\n *\n * @example\n * const count = new Signal(0);\n * count.watch((value) => console.log(`Count changed to: ${value}`));\n * count.value = 1; // Logs: \"Count changed to: 1\"\n * @template T\n */\nexport class Signal {\n /**\n * Creates a new Signal instance with the specified initial value.\n *\n * @public\n * @param {T} value - The initial value of the signal.\n */\n constructor(value) {\n /** @private {T} Internal storage for the signal's current value */\n this._value = value;\n /** @private {Set<(value: T) => void>} Collection of callback functions to be notified when value changes */\n this._watchers = new Set();\n /** @private {boolean} Flag to prevent multiple synchronous watcher notifications and batch updates into microtasks */\n this._pending = false;\n }\n\n /**\n * Gets the current value of the signal.\n *\n * @public\n * @returns {T} The current value.\n */\n get value() {\n return this._value;\n }\n\n /**\n * Sets a new value for the signal and notifies all registered watchers if the value has changed.\n * The notification is batched using microtasks to prevent multiple synchronous updates.\n *\n * @public\n * @param {T} newVal - The new value to set.\n * @returns {void}\n */\n set value(newVal) {\n if (this._value === newVal) return;\n\n this._value = newVal;\n this._notify();\n }\n\n /**\n * Registers a watcher function that will be called whenever the signal's value changes.\n * The watcher will receive the new value as its argument.\n *\n * @public\n * @param {(value: T) => void} fn - The callback function to invoke on value change.\n * @returns {() => boolean} A function to unsubscribe the watcher.\n * @example\n * const unsubscribe = signal.watch((value) => console.log(value));\n * // Later...\n * unsubscribe(); // Stops watching for changes\n */\n watch(fn) {\n this._watchers.add(fn);\n return () => this._watchers.delete(fn);\n }\n\n /**\n * Notifies all registered watchers of a value change using microtask scheduling.\n * Uses a pending flag to batch multiple synchronous updates into a single notification.\n * All watcher callbacks receive the current value when executed.\n *\n * @private\n * @returns {void}\n */\n _notify() {\n if (this._pending) return;\n\n this._pending = true;\n queueMicrotask(() => {\n /** @type {(fn: (value: T) => void) => void} */\n this._watchers.forEach((fn) => fn(this._value));\n this._pending = false;\n });\n }\n}\n","\"use strict\";\n\n/**\n * @class 📡 Emitter\n * @classdesc A robust event emitter that enables inter-component communication through a publish-subscribe pattern.\n * Components can emit events and listen for events from other components, facilitating loose coupling\n * and reactive updates across the application.\n * Events are handled synchronously in the order they were registered, with proper cleanup\n * of unsubscribed handlers.\n * Event names should follow the format 'namespace:action' (e.g., 'user:login', 'cart:update').\n *\n * @example\n * const emitter = new Emitter();\n * emitter.on('user:login', (user) => console.log(`User logged in: ${user.name}`));\n * emitter.emit('user:login', { name: 'John' }); // Logs: \"User logged in: John\"\n */\nexport class Emitter {\n /**\n * Creates a new Emitter instance.\n *\n * @public\n */\n constructor() {\n /** @private {Map<string, Set<(data: unknown) => void>>} Map of event names to their registered handler functions */\n this._events = new Map();\n }\n\n /**\n * Registers an event handler for the specified event name.\n * The handler will be called with the event data when the event is emitted.\n * Event names should follow the format 'namespace:action' for consistency.\n *\n * @public\n * @param {string} event - The name of the event to listen for (e.g., 'user:login').\n * @param {(data: unknown) => void} handler - The callback function to invoke when the event occurs.\n * @returns {() => void} A function to unsubscribe the event handler.\n * @example\n * const unsubscribe = emitter.on('user:login', (user) => console.log(user));\n * // Later...\n * unsubscribe(); // Stops listening for the event\n */\n on(event, handler) {\n if (!this._events.has(event)) this._events.set(event, new Set());\n\n this._events.get(event).add(handler);\n return () => this.off(event, handler);\n }\n\n /**\n * Removes an event handler for the specified event name.\n * If no handler is provided, all handlers for the event are removed.\n * Automatically cleans up empty event sets to prevent memory leaks.\n *\n * @public\n * @param {string} event - The name of the event to remove handlers from.\n * @param {(data: unknown) => void} [handler] - The specific handler function to remove.\n * @returns {void}\n * @example\n * // Remove a specific handler\n * emitter.off('user:login', loginHandler);\n * // Remove all handlers for an event\n * emitter.off('user:login');\n */\n off(event, handler) {\n if (!this._events.has(event)) return;\n if (handler) {\n const handlers = this._events.get(event);\n handlers.delete(handler);\n // Remove the event if there are no handlers left\n if (handlers.size === 0) this._events.delete(event);\n } else {\n this._events.delete(event);\n }\n }\n\n /**\n * Emits an event with the specified data to all registered handlers.\n * Handlers are called synchronously in the order they were registered.\n * If no handlers are registered for the event, the emission is silently ignored.\n *\n * @public\n * @param {string} event - The name of the event to emit.\n * @param {...unknown} args - Optional arguments to pass to the event handlers.\n * @returns {void}\n * @example\n * // Emit an event with data\n * emitter.emit('user:login', { name: 'John', role: 'admin' });\n * // Emit an event with multiple arguments\n * emitter.emit('cart:update', { items: [] }, { total: 0 });\n */\n emit(event, ...args) {\n if (!this._events.has(event)) return;\n this._events.get(event).forEach((handler) => handler(...args));\n }\n}\n","\"use strict\";\n\n/**\n * @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 // Process new attributes\n for (let i = 0; i < newAttrs.length; i++) {\n const { name, value } = newAttrs[i];\n\n // Skip event attributes (handled by event system)\n if (name.startsWith(\"@\")) continue;\n\n // Skip if attribute hasn't changed\n if (oldEl.getAttribute(name) === value) continue;\n\n // Basic attribute setting\n oldEl.setAttribute(name, value);\n }\n\n // Remove old attributes that are 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 /** @private {number} Counter for generating unique component IDs */\n this._componentCounter = 0;\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 this._plugins.set(plugin.name, plugin);\n const result = plugin.install(this, options);\n\n return result !== undefined ? result : 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 /** @type {string} */\n const compId = `c${++this._componentCounter}`;\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) this._injectStyles(container, compId, 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} compId - The component ID 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, compId, styleDef, context) {\n /** @type {string} */\n const newStyle =\n typeof styleDef === \"function\"\n ? TemplateEngine.parse(styleDef(context), context)\n : styleDef;\n\n /** @type {HTMLStyleElement|null} */\n let styleEl = container.querySelector(`style[data-e-style=\"${compId}\"]`);\n\n if (styleEl && styleEl.textContent === newStyle) return;\n if (!styleEl) {\n styleEl = document.createElement(\"style\");\n styleEl.setAttribute(\"data-e-style\", compId);\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 * @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) {\n if (!element.attributes) return {};\n\n const props = {};\n const attrs = element.attributes;\n\n for (let i = attrs.length - 1; i >= 0; i--) {\n const attr = attrs[i];\n if (attr.name.startsWith(\":\")) {\n const propName = attr.name.slice(1);\n props[propName] = attr.value;\n element.removeAttribute(attr.name);\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","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","removeAttribute","oldKey","newKey","children","start","end","map","child","Eleva","config","emitter","signal","renderer","_components","_plugins","_isMounted","_componentCounter","use","plugin","options","result","install","undefined","component","definition","mount","compName","props","compId","setup","style","context","v","processMount","mergedContext","watchers","childInstances","listeners","onBeforeMount","onBeforeUpdate","render","templateResult","_processEvents","_injectStyles","_mountComponents","onMount","onUpdate","val","Object","values","push","instance","unmount","onUnmount","cleanup","setupResult","elements","querySelectorAll","el","attrs","attr","slice","handlerName","addEventListener","removeEventListener","styleDef","newStyle","styleEl","querySelector","textContent","appendChild","_extractProps","element","propName","selector","entries","includes"],"mappings":";;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,cAAc,CAAC;AAC1B;AACF;AACA;AACA;EACE,OAAOC,iBAAiB,GAAG,sBAAsB;;AAEjD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B,CAAC,CAAC;AACzB,MAAA,MAAMP,GAAG,GAAG,IAAI,CAACC,WAAW,CAACuC,KAAK,CAAC;MACnC,IAAIxC,GAAG,EAAEuC,GAAG,CAAC/E,GAAG,CAACwC,GAAG,EAAEwC,KAAK,CAAC;AAC9B,IAAA;AACA,IAAA,OAAOD,GAAG;AACZ,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEtC,WAAWA,CAACmB,IAAI,EAAE;AAChB,IAAA,OAAOA,IAAI,EAAEP,QAAQ,KAAKC,IAAI,CAACC,YAAY,GACvCK,IAAI,CAACW,YAAY,CAAC,KAAK,CAAC,GACxB,IAAI;AACV,EAAA;AACF;;AC/PA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMU,KAAK,CAAC;AACjB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACEtG,EAAAA,WAAWA,CAAC0F,IAAI,EAAEa,MAAM,GAAG,EAAE,EAAE;AAC7B;IACA,IAAI,CAACb,IAAI,GAAGA,IAAI;AAChB;IACA,IAAI,CAACa,MAAM,GAAGA,MAAM;AACpB;AACA,IAAA,IAAI,CAACC,OAAO,GAAG,IAAI1F,OAAO,EAAE;AAC5B;IAC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AACA,IAAA,OAAO+B,KAAK;AACd,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,MAAMiB,gBAAgBA,CAACzG,SAAS,EAAEgE,QAAQ,EAAEiC,cAAc,EAAE;AAC1D,IAAA,KAAK,MAAM,CAACsC,QAAQ,EAAEnD,SAAS,CAAC,IAAIyB,MAAM,CAAC2B,OAAO,CAACxE,QAAQ,CAAC,EAAE;MAC5D,IAAI,CAACuE,QAAQ,EAAE;MACf,KAAK,MAAMhB,EAAE,IAAIvH,SAAS,CAACsH,gBAAgB,CAACiB,QAAQ,CAAC,EAAE;AACrD,QAAA,IAAI,EAAEhB,EAAE,YAAYrH,WAAW,CAAC,EAAE;AAClC;AACA,QAAA,MAAMsF,KAAK,GAAG,IAAI,CAAC4C,aAAa,CAACb,EAAE,CAAC;AACpC;AACA,QAAA,MAAMP,QAAQ,GAAG,MAAM,IAAI,CAAC1B,KAAK,CAACiC,EAAE,EAAEnC,SAAS,EAAEI,KAAK,CAAC;QACvD,IAAIwB,QAAQ,IAAI,CAACf,cAAc,CAACwC,QAAQ,CAACzB,QAAQ,CAAC,EAAE;AAClDf,UAAAA,cAAc,CAACc,IAAI,CAACC,QAAQ,CAAC;AAC/B,QAAA;AACF,MAAA;AACF,IAAA;AACF,EAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"eleva.cjs.js","sources":["../src/modules/TemplateEngine.js","../src/modules/Signal.js","../src/modules/Emitter.js","../src/modules/Renderer.js","../src/core/Eleva.js"],"sourcesContent":["\"use strict\";\n\n/**\n * @class 🔒 TemplateEngine\n * @classdesc A secure template engine that handles interpolation and dynamic attribute parsing.\n * Provides a safe way to evaluate expressions in templates while preventing XSS attacks.\n * All methods are static and can be called directly on the class.\n *\n * @example\n * const template = \"Hello, {{name}}!\";\n * const data = { name: \"World\" };\n * const result = TemplateEngine.parse(template, data); // Returns: \"Hello, World!\"\n */\nexport class TemplateEngine {\n /**\n * @private {RegExp} Regular expression for matching template expressions in the format {{ expression }}\n * @type {RegExp}\n */\n static expressionPattern = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n\n /**\n * Parses a template string, replacing expressions with their evaluated values.\n * Expressions are evaluated in the provided data context.\n *\n * @public\n * @static\n * @param {string} template - The template string to parse.\n * @param {Record<string, unknown>} data - The data context for evaluating expressions.\n * @returns {string} The parsed template with expressions replaced by their values.\n * @example\n * const result = TemplateEngine.parse(\"{{user.name}} is {{user.age}} years old\", {\n * user: { name: \"John\", age: 30 }\n * }); // Returns: \"John is 30 years old\"\n */\n static parse(template, data) {\n if (typeof template !== \"string\") return template;\n return template.replace(this.expressionPattern, (_, expression) =>\n this.evaluate(expression, data)\n );\n }\n\n /**\n * Evaluates an expression in the context of the provided data object.\n * Note: This does not provide a true sandbox and evaluated expressions may access global scope.\n * The use of the `with` statement is necessary for expression evaluation but has security implications.\n * Expressions should be carefully validated before evaluation.\n *\n * @public\n * @static\n * @param {string} expression - The expression to evaluate.\n * @param {Record<string, unknown>} data - The data context for evaluation.\n * @returns {unknown} The result of the evaluation, or an empty string if evaluation fails.\n * @example\n * const result = TemplateEngine.evaluate(\"user.name\", { user: { name: \"John\" } }); // Returns: \"John\"\n * const age = TemplateEngine.evaluate(\"user.age\", { user: { age: 30 } }); // Returns: 30\n */\n static evaluate(expression, data) {\n if (typeof expression !== \"string\") return expression;\n try {\n return new Function(\"data\", `with(data) { return ${expression}; }`)(data);\n } catch {\n return \"\";\n }\n }\n}\n","\"use strict\";\n\n/**\n * @class ⚡ Signal\n * @classdesc A reactive data holder that enables fine-grained reactivity in the Eleva framework.\n * Signals notify registered watchers when their value changes, enabling efficient DOM updates\n * through targeted patching rather than full re-renders.\n * Updates are batched using microtasks to prevent multiple synchronous notifications.\n * The class is generic, allowing type-safe handling of any value type T.\n *\n * @example\n * const count = new Signal(0);\n * count.watch((value) => console.log(`Count changed to: ${value}`));\n * count.value = 1; // Logs: \"Count changed to: 1\"\n * @template T\n */\nexport class Signal {\n /**\n * Creates a new Signal instance with the specified initial value.\n *\n * @public\n * @param {T} value - The initial value of the signal.\n */\n constructor(value) {\n /** @private {T} Internal storage for the signal's current value */\n this._value = value;\n /** @private {Set<(value: T) => void>} Collection of callback functions to be notified when value changes */\n this._watchers = new Set();\n /** @private {boolean} Flag to prevent multiple synchronous watcher notifications and batch updates into microtasks */\n this._pending = false;\n }\n\n /**\n * Gets the current value of the signal.\n *\n * @public\n * @returns {T} The current value.\n */\n get value() {\n return this._value;\n }\n\n /**\n * Sets a new value for the signal and notifies all registered watchers if the value has changed.\n * The notification is batched using microtasks to prevent multiple synchronous updates.\n *\n * @public\n * @param {T} newVal - The new value to set.\n * @returns {void}\n */\n set value(newVal) {\n if (this._value === newVal) return;\n\n this._value = newVal;\n this._notify();\n }\n\n /**\n * Registers a watcher function that will be called whenever the signal's value changes.\n * The watcher will receive the new value as its argument.\n *\n * @public\n * @param {(value: T) => void} fn - The callback function to invoke on value change.\n * @returns {() => boolean} A function to unsubscribe the watcher.\n * @example\n * const unsubscribe = signal.watch((value) => console.log(value));\n * // Later...\n * unsubscribe(); // Stops watching for changes\n */\n watch(fn) {\n this._watchers.add(fn);\n return () => this._watchers.delete(fn);\n }\n\n /**\n * Notifies all registered watchers of a value change using microtask scheduling.\n * Uses a pending flag to batch multiple synchronous updates into a single notification.\n * All watcher callbacks receive the current value when executed.\n *\n * @private\n * @returns {void}\n */\n _notify() {\n if (this._pending) return;\n\n this._pending = true;\n queueMicrotask(() => {\n /** @type {(fn: (value: T) => void) => void} */\n this._watchers.forEach((fn) => fn(this._value));\n this._pending = false;\n });\n }\n}\n","\"use strict\";\n\n/**\n * @class 📡 Emitter\n * @classdesc A robust event emitter that enables inter-component communication through a publish-subscribe pattern.\n * Components can emit events and listen for events from other components, facilitating loose coupling\n * and reactive updates across the application.\n * Events are handled synchronously in the order they were registered, with proper cleanup\n * of unsubscribed handlers.\n * Event names should follow the format 'namespace:action' (e.g., 'user:login', 'cart:update').\n *\n * @example\n * const emitter = new Emitter();\n * emitter.on('user:login', (user) => console.log(`User logged in: ${user.name}`));\n * emitter.emit('user:login', { name: 'John' }); // Logs: \"User logged in: John\"\n */\nexport class Emitter {\n /**\n * Creates a new Emitter instance.\n *\n * @public\n */\n constructor() {\n /** @private {Map<string, Set<(data: unknown) => void>>} Map of event names to their registered handler functions */\n this._events = new Map();\n }\n\n /**\n * Registers an event handler for the specified event name.\n * The handler will be called with the event data when the event is emitted.\n * Event names should follow the format 'namespace:action' for consistency.\n *\n * @public\n * @param {string} event - The name of the event to listen for (e.g., 'user:login').\n * @param {(data: unknown) => void} handler - The callback function to invoke when the event occurs.\n * @returns {() => void} A function to unsubscribe the event handler.\n * @example\n * const unsubscribe = emitter.on('user:login', (user) => console.log(user));\n * // Later...\n * unsubscribe(); // Stops listening for the event\n */\n on(event, handler) {\n if (!this._events.has(event)) this._events.set(event, new Set());\n\n this._events.get(event).add(handler);\n return () => this.off(event, handler);\n }\n\n /**\n * Removes an event handler for the specified event name.\n * If no handler is provided, all handlers for the event are removed.\n * Automatically cleans up empty event sets to prevent memory leaks.\n *\n * @public\n * @param {string} event - The name of the event to remove handlers from.\n * @param {(data: unknown) => void} [handler] - The specific handler function to remove.\n * @returns {void}\n * @example\n * // Remove a specific handler\n * emitter.off('user:login', loginHandler);\n * // Remove all handlers for an event\n * emitter.off('user:login');\n */\n off(event, handler) {\n if (!this._events.has(event)) return;\n if (handler) {\n const handlers = this._events.get(event);\n handlers.delete(handler);\n // Remove the event if there are no handlers left\n if (handlers.size === 0) this._events.delete(event);\n } else {\n this._events.delete(event);\n }\n }\n\n /**\n * Emits an event with the specified data to all registered handlers.\n * Handlers are called synchronously in the order they were registered.\n * If no handlers are registered for the event, the emission is silently ignored.\n *\n * @public\n * @param {string} event - The name of the event to emit.\n * @param {...unknown} args - Optional arguments to pass to the event handlers.\n * @returns {void}\n * @example\n * // Emit an event with data\n * emitter.emit('user:login', { name: 'John', role: 'admin' });\n * // Emit an event with multiple arguments\n * emitter.emit('cart:update', { items: [] }, { total: 0 });\n */\n emit(event, ...args) {\n if (!this._events.has(event)) return;\n this._events.get(event).forEach((handler) => handler(...args));\n }\n}\n","\"use strict\";\n\n/**\n * @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 // Process new attributes\n for (let i = 0; i < newAttrs.length; i++) {\n const { name, value } = newAttrs[i];\n\n // Skip event attributes (handled by event system)\n if (name.startsWith(\"@\")) continue;\n\n // Skip if attribute hasn't changed\n if (oldEl.getAttribute(name) === value) continue;\n\n // Basic attribute setting\n oldEl.setAttribute(name, value);\n }\n\n // Remove old attributes that are 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 {typeof TemplateEngine} Static reference to the TemplateEngine class for template parsing */\n this.templateEngine = TemplateEngine;\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 {number} Counter for generating unique component IDs */\n this._componentCounter = 0;\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 * Note: Plugins that wrap core methods (e.g., mount) must be uninstalled in reverse order\n * of installation (LIFO - Last In, First Out) to avoid conflicts.\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 * @example\n * // Correct uninstall order (LIFO)\n * app.use(PluginA);\n * app.use(PluginB);\n * // Uninstall in reverse order:\n * PluginB.uninstall(app);\n * PluginA.uninstall(app);\n */\n use(plugin, options = {}) {\n this._plugins.set(plugin.name, plugin);\n const result = plugin.install(this, options);\n\n return result !== undefined ? result : 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 /** @type {string} */\n const compId = `c${++this._componentCounter}`;\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 /** @private {boolean} Local mounted state for this component instance */\n let isMounted = false;\n\n /**\n * Renders the component by:\n * 1. Executing lifecycle hooks\n * 2. Processing the template\n * 3. Updating the DOM\n * 4. Processing events, injecting styles, and mounting child components.\n */\n const render = async () => {\n // Execute before hooks\n if (!isMounted) {\n await mergedContext.onBeforeMount?.({\n container,\n context: mergedContext,\n });\n } else {\n await mergedContext.onBeforeUpdate?.({\n container,\n context: mergedContext,\n });\n }\n\n const templateResult =\n typeof template === \"function\"\n ? await template(mergedContext)\n : template;\n const newHtml = this.templateEngine.parse(\n templateResult,\n mergedContext\n );\n this.renderer.patchDOM(container, newHtml);\n this._processEvents(container, mergedContext, listeners);\n if (style) this._injectStyles(container, compId, style, mergedContext);\n if (children)\n await this._mountComponents(container, children, childInstances);\n\n // Execute after hooks\n if (!isMounted) {\n await mergedContext.onMount?.({\n container,\n context: mergedContext,\n });\n isMounted = true;\n } else {\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] ||\n this.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} compId - The component ID 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, compId, styleDef, context) {\n /** @type {string} */\n const newStyle =\n typeof styleDef === \"function\"\n ? this.templateEngine.parse(styleDef(context), context)\n : styleDef;\n\n /** @type {HTMLStyleElement|null} */\n let styleEl = container.querySelector(`style[data-e-style=\"${compId}\"]`);\n\n if (styleEl && styleEl.textContent === newStyle) return;\n if (!styleEl) {\n styleEl = document.createElement(\"style\");\n styleEl.setAttribute(\"data-e-style\", compId);\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 * @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) {\n if (!element.attributes) return {};\n\n const props = {};\n const attrs = element.attributes;\n\n for (let i = attrs.length - 1; i >= 0; i--) {\n const attr = attrs[i];\n if (attr.name.startsWith(\":\")) {\n const propName = attr.name.slice(1);\n props[propName] = attr.value;\n element.removeAttribute(attr.name);\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","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","removeAttribute","oldKey","newKey","children","start","end","map","child","Eleva","config","emitter","signal","templateEngine","renderer","_components","_plugins","_componentCounter","use","plugin","options","result","install","undefined","component","definition","mount","compName","props","compId","setup","style","context","v","processMount","mergedContext","watchers","childInstances","listeners","isMounted","render","onBeforeMount","onBeforeUpdate","templateResult","_processEvents","_injectStyles","_mountComponents","onMount","onUpdate","val","Object","values","push","instance","unmount","onUnmount","cleanup","setupResult","elements","querySelectorAll","el","attrs","attr","slice","handlerName","addEventListener","removeEventListener","styleDef","newStyle","styleEl","querySelector","textContent","appendChild","_extractProps","element","propName","selector","entries","includes"],"mappings":";;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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,CAAC,IAAI+B,GAAG,EAAE/B,CAAC,EAAE,EAAE;AACjC,MAAA,MAAMiC,KAAK,GAAGJ,QAAQ,CAAC7B,CAAC,CAAC;AACzB,MAAA,MAAMP,GAAG,GAAG,IAAI,CAACC,WAAW,CAACuC,KAAK,CAAC;MACnC,IAAIxC,GAAG,EAAEuC,GAAG,CAAC/E,GAAG,CAACwC,GAAG,EAAEwC,KAAK,CAAC;AAC9B,IAAA;AACA,IAAA,OAAOD,GAAG;AACZ,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEtC,WAAWA,CAACmB,IAAI,EAAE;AAChB,IAAA,OAAOA,IAAI,EAAEP,QAAQ,KAAKC,IAAI,CAACC,YAAY,GACvCK,IAAI,CAACW,YAAY,CAAC,KAAK,CAAC,GACxB,IAAI;AACV,EAAA;AACF;;AC/PA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMU,KAAK,CAAC;AACjB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACEtG,EAAAA,WAAWA,CAAC0F,IAAI,EAAEa,MAAM,GAAG,EAAE,EAAE;AAC7B;IACA,IAAI,CAACb,IAAI,GAAGA,IAAI;AAChB;IACA,IAAI,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AC;AACnCnC,QAAAA,KAAK,CAAC+C,QAAQ,CAAC,GAAGb,IAAI,CAAC1J,KAAK;AAC5BsK,QAAAA,OAAO,CAACzE,eAAe,CAAC6D,IAAI,CAACjE,IAAI,CAAC;AACpC,MAAA;AACF,IAAA;AACA,IAAA,OAAO+B,KAAK;AACd,EAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,MAAMkB,gBAAgBA,CAAC1G,SAAS,EAAEgE,QAAQ,EAAEiC,cAAc,EAAE;AAC1D,IAAA,KAAK,MAAM,CAACuC,QAAQ,EAAEpD,SAAS,CAAC,IAAI0B,MAAM,CAAC2B,OAAO,CAACzE,QAAQ,CAAC,EAAE;MAC5D,IAAI,CAACwE,QAAQ,EAAE;MACf,KAAK,MAAMhB,EAAE,IAAIxH,SAAS,CAACuH,gBAAgB,CAACiB,QAAQ,CAAC,EAAE;AACrD,QAAA,IAAI,EAAEhB,EAAE,YAAYtH,WAAW,CAAC,EAAE;AAClC;AACA,QAAA,MAAMsF,KAAK,GAAG,IAAI,CAAC6C,aAAa,CAACb,EAAE,CAAC;AACpC;AACA,QAAA,MAAMP,QAAQ,GAAG,MAAM,IAAI,CAAC3B,KAAK,CAACkC,EAAE,EAAEpC,SAAS,EAAEI,KAAK,CAAC;QACvD,IAAIyB,QAAQ,IAAI,CAAChB,cAAc,CAACyC,QAAQ,CAACzB,QAAQ,CAAC,EAAE;AAClDhB,UAAAA,cAAc,CAACe,IAAI,CAACC,QAAQ,CAAC;AAC/B,QAAA;AACF,MAAA;AACF,IAAA;AACF,EAAA;AACF;;;;"}
|
package/dist/eleva.d.ts
CHANGED
|
@@ -132,6 +132,56 @@ declare class Signal<T> {
|
|
|
132
132
|
private _notify;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
/**
|
|
136
|
+
* @class 🔒 TemplateEngine
|
|
137
|
+
* @classdesc A secure template engine that handles interpolation and dynamic attribute parsing.
|
|
138
|
+
* Provides a safe way to evaluate expressions in templates while preventing XSS attacks.
|
|
139
|
+
* All methods are static and can be called directly on the class.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* const template = "Hello, {{name}}!";
|
|
143
|
+
* const data = { name: "World" };
|
|
144
|
+
* const result = TemplateEngine.parse(template, data); // Returns: "Hello, World!"
|
|
145
|
+
*/
|
|
146
|
+
declare class TemplateEngine {
|
|
147
|
+
/**
|
|
148
|
+
* @private {RegExp} Regular expression for matching template expressions in the format {{ expression }}
|
|
149
|
+
* @type {RegExp}
|
|
150
|
+
*/
|
|
151
|
+
private static expressionPattern;
|
|
152
|
+
/**
|
|
153
|
+
* Parses a template string, replacing expressions with their evaluated values.
|
|
154
|
+
* Expressions are evaluated in the provided data context.
|
|
155
|
+
*
|
|
156
|
+
* @public
|
|
157
|
+
* @static
|
|
158
|
+
* @param {string} template - The template string to parse.
|
|
159
|
+
* @param {Record<string, unknown>} data - The data context for evaluating expressions.
|
|
160
|
+
* @returns {string} The parsed template with expressions replaced by their values.
|
|
161
|
+
* @example
|
|
162
|
+
* const result = TemplateEngine.parse("{{user.name}} is {{user.age}} years old", {
|
|
163
|
+
* user: { name: "John", age: 30 }
|
|
164
|
+
* }); // Returns: "John is 30 years old"
|
|
165
|
+
*/
|
|
166
|
+
public static parse(template: string, data: Record<string, unknown>): string;
|
|
167
|
+
/**
|
|
168
|
+
* Evaluates an expression in the context of the provided data object.
|
|
169
|
+
* Note: This does not provide a true sandbox and evaluated expressions may access global scope.
|
|
170
|
+
* The use of the `with` statement is necessary for expression evaluation but has security implications.
|
|
171
|
+
* Expressions should be carefully validated before evaluation.
|
|
172
|
+
*
|
|
173
|
+
* @public
|
|
174
|
+
* @static
|
|
175
|
+
* @param {string} expression - The expression to evaluate.
|
|
176
|
+
* @param {Record<string, unknown>} data - The data context for evaluation.
|
|
177
|
+
* @returns {unknown} The result of the evaluation, or an empty string if evaluation fails.
|
|
178
|
+
* @example
|
|
179
|
+
* const result = TemplateEngine.evaluate("user.name", { user: { name: "John" } }); // Returns: "John"
|
|
180
|
+
* const age = TemplateEngine.evaluate("user.age", { user: { age: 30 } }); // Returns: 30
|
|
181
|
+
*/
|
|
182
|
+
public static evaluate(expression: string, data: Record<string, unknown>): unknown;
|
|
183
|
+
}
|
|
184
|
+
|
|
135
185
|
/**
|
|
136
186
|
* @class 🎨 Renderer
|
|
137
187
|
* @classdesc A high-performance DOM renderer that implements an optimized direct DOM diffing algorithm.
|
|
@@ -359,14 +409,14 @@ declare class Eleva {
|
|
|
359
409
|
public emitter: Emitter;
|
|
360
410
|
/** @public {typeof Signal} Static reference to the Signal class for creating reactive state */
|
|
361
411
|
public signal: typeof Signal;
|
|
412
|
+
/** @public {typeof TemplateEngine} Static reference to the TemplateEngine class for template parsing */
|
|
413
|
+
public templateEngine: typeof TemplateEngine;
|
|
362
414
|
/** @public {Renderer} Instance of the renderer for handling DOM updates and patching */
|
|
363
415
|
public renderer: Renderer;
|
|
364
416
|
/** @private {Map<string, ComponentDefinition>} Registry of all component definitions by name */
|
|
365
417
|
private _components;
|
|
366
418
|
/** @private {Map<string, ElevaPlugin>} Collection of installed plugin instances by name */
|
|
367
419
|
private _plugins;
|
|
368
|
-
/** @private {boolean} Flag indicating if the root component is currently mounted */
|
|
369
|
-
private _isMounted;
|
|
370
420
|
/** @private {number} Counter for generating unique component IDs */
|
|
371
421
|
private _componentCounter;
|
|
372
422
|
/**
|
|
@@ -374,12 +424,23 @@ declare class Eleva {
|
|
|
374
424
|
* The plugin's install function will be called with the Eleva instance and provided options.
|
|
375
425
|
* After installation, the plugin will be available for use by components.
|
|
376
426
|
*
|
|
427
|
+
* Note: Plugins that wrap core methods (e.g., mount) must be uninstalled in reverse order
|
|
428
|
+
* of installation (LIFO - Last In, First Out) to avoid conflicts.
|
|
429
|
+
*
|
|
377
430
|
* @public
|
|
378
431
|
* @param {ElevaPlugin} plugin - The plugin object which must have an `install` function.
|
|
379
432
|
* @param {Object<string, unknown>} [options={}] - Optional configuration options for the plugin.
|
|
380
433
|
* @returns {Eleva} The Eleva instance (for method chaining).
|
|
381
434
|
* @example
|
|
382
435
|
* app.use(myPlugin, { option1: "value1" });
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* // Correct uninstall order (LIFO)
|
|
439
|
+
* app.use(PluginA);
|
|
440
|
+
* app.use(PluginB);
|
|
441
|
+
* // Uninstall in reverse order:
|
|
442
|
+
* PluginB.uninstall(app);
|
|
443
|
+
* PluginA.uninstall(app);
|
|
383
444
|
*/
|
|
384
445
|
public use(plugin: ElevaPlugin, options?: {
|
|
385
446
|
[x: string]: unknown;
|