eleva 1.2.8-alpha → 1.2.10-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 */\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 {Object} 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 *\n * @public\n * @static\n * @param {string} expression - The expression to evaluate.\n * @param {Object} data - The data context for evaluation.\n * @returns {*} 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 *\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 */\nexport class Signal {\n /**\n * Creates a new Signal instance with the specified initial value.\n *\n * @public\n * @param {*} value - The initial value of the signal.\n */\n constructor(value) {\n /** @private {T} Internal storage for the signal's current value, where T is the type of the initial value */\n this._value = value;\n /** @private {Set<function(T): void>} Collection of callback functions to be notified when value changes, where T is the value type */\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, where T is the type of the initial 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, where T is the type of the initial value.\n * @returns {void}\n */\n set value(newVal) {\n if (newVal !== this._value) {\n this._value = newVal;\n this._notifyWatchers();\n }\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 {function(T): void} fn - The callback function to invoke on value change, where T is the value type.\n * @returns {function(): 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 _notifyWatchers() {\n if (!this._pending) {\n this._pending = true;\n queueMicrotask(() => {\n this._pending = false;\n this._watchers.forEach((fn) => fn(this._value));\n });\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 *\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<function(any): 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 *\n * @public\n * @param {string} event - The name of the event to listen for.\n * @param {function(any): void} handler - The callback function to invoke when the event occurs.\n * @returns {function(): boolean} 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 *\n * @public\n * @param {string} event - The name of the event.\n * @param {function(any): void} [handler] - The specific handler function to remove.\n * @returns {void}\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 *\n * @public\n * @param {string} event - The name of the event to emit.\n * @param {...any} args - Optional arguments to pass to the event handlers.\n * @returns {void}\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 DOM renderer that handles efficient DOM updates through patching and diffing.\n * Provides methods for updating the DOM by comparing new and old structures and applying\n * only the necessary changes, minimizing layout thrashing and improving performance.\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 * Patches the DOM of a container element with new HTML content.\n * This method efficiently updates the DOM by comparing the new content with the existing\n * content and applying only the necessary changes.\n *\n * @public\n * @param {HTMLElement} container - The container element to patch.\n * @param {string} newHtml - The new HTML content to apply.\n * @returns {void}\n * @throws {Error} If container is not an HTMLElement or newHtml is not a string.\n */\n patchDOM(container, newHtml) {\n if (!(container instanceof HTMLElement)) {\n throw new Error(\"Container must be an HTMLElement\");\n }\n if (typeof newHtml !== \"string\") {\n throw new Error(\"newHtml must be a string\");\n }\n\n const temp = document.createElement(\"div\");\n temp.innerHTML = newHtml;\n this.diff(container, temp);\n temp.innerHTML = \"\";\n }\n\n /**\n * Diffs two DOM trees (old and new) and applies updates to the old DOM.\n * This method recursively compares nodes and their attributes, applying only\n * the necessary changes to minimize DOM operations.\n *\n * @private\n * @param {HTMLElement} oldParent - The original DOM element.\n * @param {HTMLElement} newParent - The new DOM element.\n * @returns {void}\n * @throws {Error} If either parent is not an HTMLElement.\n */\n diff(oldParent, newParent) {\n if (\n !(oldParent instanceof HTMLElement) ||\n !(newParent instanceof HTMLElement)\n ) {\n throw new Error(\"Both parents must be HTMLElements\");\n }\n\n if (oldParent.isEqualNode(newParent)) return;\n\n const oldC = oldParent.childNodes;\n const newC = newParent.childNodes;\n const len = Math.max(oldC.length, newC.length);\n const operations = [];\n\n for (let i = 0; i < len; i++) {\n const oldNode = oldC[i];\n const newNode = newC[i];\n\n if (!oldNode && newNode) {\n operations.push(() => oldParent.appendChild(newNode.cloneNode(true)));\n continue;\n }\n if (oldNode && !newNode) {\n operations.push(() => oldParent.removeChild(oldNode));\n continue;\n }\n\n const isSameType =\n oldNode.nodeType === newNode.nodeType &&\n oldNode.nodeName === newNode.nodeName;\n\n if (!isSameType) {\n operations.push(() =>\n oldParent.replaceChild(newNode.cloneNode(true), oldNode)\n );\n continue;\n }\n\n if (oldNode.nodeType === Node.ELEMENT_NODE) {\n const oldKey = oldNode.getAttribute(\"key\");\n const newKey = newNode.getAttribute(\"key\");\n\n if (oldKey !== newKey && (oldKey || newKey)) {\n operations.push(() =>\n oldParent.replaceChild(newNode.cloneNode(true), oldNode)\n );\n continue;\n }\n\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 if (operations.length) {\n operations.forEach((op) => op());\n }\n }\n\n /**\n * Updates the attributes of an element to match those of a new element.\n * Handles special cases for ARIA attributes, data attributes, and boolean properties.\n *\n * @private\n * @param {HTMLElement} oldEl - The element to update.\n * @param {HTMLElement} newEl - The element providing the updated attributes.\n * @returns {void}\n * @throws {Error} If either element is not an HTMLElement.\n */\n updateAttributes(oldEl, newEl) {\n if (!(oldEl instanceof HTMLElement) || !(newEl instanceof HTMLElement)) {\n throw new Error(\"Both elements must be HTMLElements\");\n }\n\n const oldAttrs = oldEl.attributes;\n const newAttrs = newEl.attributes;\n const operations = [];\n\n // Remove old attributes\n for (const { name } of oldAttrs) {\n if (!name.startsWith(\"@\") && !newEl.hasAttribute(name)) {\n operations.push(() => oldEl.removeAttribute(name));\n }\n }\n\n // Update/add new attributes\n for (const attr of newAttrs) {\n const { name, value } = attr;\n if (name.startsWith(\"@\")) continue;\n\n if (oldEl.getAttribute(name) === value) continue;\n\n operations.push(() => {\n oldEl.setAttribute(name, value);\n\n if (name.startsWith(\"aria-\")) {\n const prop =\n \"aria\" +\n name.slice(5).replace(/-([a-z])/g, (_, 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(/-([a-z])/g, (_, 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\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\n if (operations.length) {\n operations.forEach((op) => op());\n }\n }\n}\n","\"use strict\";\n\nimport { TemplateEngine } from \"../modules/TemplateEngine.js\";\nimport { Signal } from \"../modules/Signal.js\";\nimport { Emitter } from \"../modules/Emitter.js\";\nimport { Renderer } from \"../modules/Renderer.js\";\n\n/**\n * @typedef {Object} ComponentDefinition\n * @property {function(Object<string, any>): (Object<string, any>|Promise<Object<string, any>>)} [setup]\n * Optional setup function that initializes the component's state and returns reactive data\n * @property {function(Object<string, any>): string} template\n * Required function that defines the component's HTML structure\n * @property {function(Object<string, any>): string} [style]\n * Optional function that provides component-scoped CSS styles\n * @property {Object<string, ComponentDefinition>} [children]\n * Optional object defining nested child components\n */\n\n/**\n * @typedef {Object} ElevaPlugin\n * @property {function(Eleva, Object<string, any>): 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 * @typedef {Object} MountResult\n * @property {HTMLElement} container\n * The DOM element where the component is mounted\n * @property {Object<string, any>} data\n * The component's reactive state and context data\n * @property {function(): void} unmount\n * Function to clean up and unmount the component\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 * const app = new Eleva(\"myApp\");\n * app.component(\"myComponent\", {\n * template: (ctx) => `<div>Hello ${ctx.props.name}</div>`,\n * setup: (ctx) => ({ count: new Signal(0) })\n * });\n * app.mount(document.getElementById(\"app\"), \"myComponent\", { name: \"World\" });\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 {Object<string, any>} [config={}] - Optional configuration object for the instance.\n * May include framework-wide settings and default behaviors.\n */\n constructor(name, config = {}) {\n /** @public {string} The unique identifier name for this Eleva instance */\n this.name = name;\n /** @public {Object<string, any>} 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 {string[]} Array of lifecycle hook names supported by components */\n this._lifecycleHooks = [\n \"onBeforeMount\",\n \"onMount\",\n \"onBeforeUpdate\",\n \"onUpdate\",\n \"onUnmount\",\n ];\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, any>} [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, any>} [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 /** @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 if (typeof definition.template !== \"function\")\n throw new Error(\"Component template must be a function\");\n\n /**\n * Destructure the component definition to access core functionality.\n * - setup: Optional function for component initialization and state management\n * - template: Required function that returns the component's HTML structure\n * - style: Optional function for component-scoped CSS styles\n * - children: Optional object defining nested child components\n */\n const { setup, template, style, children } = definition;\n\n /**\n * Creates the initial context object for the component instance.\n * This context provides core functionality and will be merged with setup data.\n * @type {Object<string, any>}\n * @property {Object<string, any>} props - Component properties passed during mounting\n * @property {Emitter} emitter - Event emitter instance for component event handling\n * @property {function(any): Signal} signal - Factory function to create reactive Signal instances\n * @property {Object<string, function(): void>} ...lifecycleHooks - Prepared lifecycle hook functions\n */\n const context = {\n props,\n emitter: this.emitter,\n /** @type {(v: any) => Signal} */\n signal: (v) => new this.signal(v),\n ...this._prepareLifecycleHooks(),\n };\n\n /**\n * Processes the mounting of the component.\n *\n * @param {Object<string, any>} data - Data returned from the component's setup function.\n * @returns {MountResult} An object with the container, merged context data, and an unmount function.\n */\n const processMount = (data) => {\n const mergedContext = { ...context, ...data };\n /** @type {Array<() => void>} */\n const watcherUnsubscribers = [];\n /** @type {Array<MountResult>} */\n const childInstances = [];\n /** @type {Array<() => void>} */\n const cleanupListeners = [];\n\n // Execute before hooks\n if (!this._isMounted) {\n mergedContext.onBeforeMount && mergedContext.onBeforeMount();\n } else {\n mergedContext.onBeforeUpdate && mergedContext.onBeforeUpdate();\n }\n\n /**\n * Renders the component by parsing the template, patching the DOM,\n * processing events, injecting styles, and mounting child components.\n */\n const render = () => {\n const newHtml = TemplateEngine.parse(\n template(mergedContext),\n mergedContext\n );\n this.renderer.patchDOM(container, newHtml);\n this._processEvents(container, mergedContext, cleanupListeners);\n this._injectStyles(container, compName, style, mergedContext);\n this._mountChildren(container, children, childInstances);\n\n if (!this._isMounted) {\n mergedContext.onMount && mergedContext.onMount();\n this._isMounted = true;\n } else {\n mergedContext.onUpdate && mergedContext.onUpdate();\n }\n };\n\n /**\n * Sets up reactive watchers for all Signal instances in the component's data.\n * When a Signal's value changes, the component will re-render to reflect the updates.\n * Stores unsubscribe functions to clean up watchers when component unmounts.\n */\n for (const val of Object.values(data)) {\n if (val instanceof Signal) watcherUnsubscribers.push(val.watch(render));\n }\n\n render();\n\n return {\n container,\n data: mergedContext,\n /**\n * Unmounts the component, cleaning up watchers and listeners, child components, and clearing the container.\n *\n * @returns {void}\n */\n unmount: () => {\n for (const fn of watcherUnsubscribers) fn();\n for (const fn of cleanupListeners) fn();\n for (const child of childInstances) child.unmount();\n mergedContext.onUnmount && mergedContext.onUnmount();\n container.innerHTML = \"\";\n },\n };\n };\n\n // Handle asynchronous setup.\n return Promise.resolve(\n typeof setup === \"function\" ? setup(context) : {}\n ).then(processMount);\n }\n\n /**\n * Prepares default no-operation lifecycle hook functions for a component.\n * These hooks will be called at various stages of the component's lifecycle.\n *\n * @private\n * @returns {Object<string, function(): void>} An object mapping lifecycle hook names to empty functions.\n * The returned object will be merged with the component's context.\n */\n _prepareLifecycleHooks() {\n /** @type {Object<string, () => void>} */\n const hooks = {};\n for (const hook of this._lifecycleHooks) {\n hooks[hook] = () => {};\n }\n return hooks;\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 {Object<string, any>} context - The current component context containing event handler definitions.\n * @param {Array<Function>} cleanupListeners - Array to collect cleanup functions for each event listener.\n * @returns {void}\n */\n _processEvents(container, context, cleanupListeners) {\n const elements = container.querySelectorAll(\"*\");\n for (const el of elements) {\n const attrs = el.attributes;\n for (let i = 0; i < attrs.length; i++) {\n const attr = attrs[i];\n if (attr.name.startsWith(\"@\")) {\n const event = attr.name.slice(1);\n const handler = TemplateEngine.evaluate(attr.value, context);\n if (typeof handler === \"function\") {\n el.addEventListener(event, handler);\n el.removeAttribute(attr.name);\n cleanupListeners.push(() => el.removeEventListener(event, handler));\n }\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(Object<string, any>): string} [styleFn] - Optional function that returns CSS styles as a string.\n * @param {Object<string, any>} context - The current component context for style interpolation.\n * @returns {void}\n */\n _injectStyles(container, compName, styleFn, context) {\n if (!styleFn) return;\n\n let styleEl = container.querySelector(\n `style[data-eleva-style=\"${compName}\"]`\n );\n if (!styleEl) {\n styleEl = document.createElement(\"style\");\n styleEl.setAttribute(\"data-eleva-style\", compName);\n container.appendChild(styleEl);\n }\n styleEl.textContent = TemplateEngine.parse(styleFn(context), context);\n }\n\n /**\n * Mounts child components within the parent component's container.\n * This method handles the recursive mounting of nested components.\n *\n * @private\n * @param {HTMLElement} container - The parent container element.\n * @param {Object<string, ComponentDefinition>} [children] - Object mapping of child component selectors to their definitions.\n * @param {Array<MountResult>} childInstances - Array to store the mounted child component instances.\n * @returns {void}\n */\n async _mountChildren(container, children, childInstances) {\n for (const child of childInstances) child.unmount();\n childInstances.length = 0;\n\n if (!children) return;\n\n for (const childSelector of Object.keys(children)) {\n if (!childSelector) continue;\n\n for (const childEl of container.querySelectorAll(childSelector)) {\n if (!(childEl instanceof HTMLElement)) continue;\n const props = {};\n for (const { name, value } of [...childEl.attributes]) {\n if (name.startsWith(\"eleva-prop-\")) {\n props[name.replace(\"eleva-prop-\", \"\")] = value;\n }\n }\n const instance = await this.mount(\n childEl,\n children[childSelector],\n props\n );\n childInstances.push(instance);\n }\n }\n }\n}\n"],"names":["TemplateEngine","expressionPattern","parse","template","data","replace","_","expression","evaluate","Function","Signal","constructor","value","_value","_watchers","Set","_pending","newVal","_notifyWatchers","watch","fn","add","delete","queueMicrotask","forEach","Emitter","_events","Map","on","event","handler","has","set","get","off","handlers","size","emit","args","Renderer","patchDOM","container","newHtml","HTMLElement","Error","temp","document","createElement","innerHTML","diff","oldParent","newParent","isEqualNode","oldC","childNodes","newC","len","Math","max","length","operations","i","oldNode","newNode","push","appendChild","cloneNode","removeChild","isSameType","nodeType","nodeName","replaceChild","Node","ELEMENT_NODE","oldKey","getAttribute","newKey","updateAttributes","TEXT_NODE","nodeValue","op","oldEl","newEl","oldAttrs","attributes","newAttrs","name","startsWith","hasAttribute","removeAttribute","attr","setAttribute","prop","slice","l","toUpperCase","dataset","descriptor","Object","getOwnPropertyDescriptor","getPrototypeOf","isBoolean","call","Eleva","config","emitter","signal","renderer","_components","_plugins","_lifecycleHooks","_isMounted","use","plugin","options","install","component","definition","mount","compName","props","setup","style","children","context","v","_prepareLifecycleHooks","processMount","mergedContext","watcherUnsubscribers","childInstances","cleanupListeners","onBeforeMount","onBeforeUpdate","render","_processEvents","_injectStyles","_mountChildren","onMount","onUpdate","val","values","unmount","child","onUnmount","Promise","resolve","then","hooks","hook","elements","querySelectorAll","el","attrs","addEventListener","removeEventListener","styleFn","styleEl","querySelector","textContent","childSelector","keys","childEl","instance"],"mappings":";;;;;;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACO,MAAMA,cAAc,CAAC;EAC1B;EACF;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;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;;EC3DA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACO,MAAMM,MAAM,CAAC;EAClB;EACF;E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CAAC,EAAE;UACvC,MAAM6E,KAAK,GAAG,EAAE;EAChB,QAAA,KAAK,MAAM;YAAElC,IAAI;EAAE1E,UAAAA;EAAM,SAAC,IAAI,CAAC,GAAGsJ,OAAO,CAAC9E,UAAU,CAAC,EAAE;EACrD,UAAA,IAAIE,IAAI,CAACC,UAAU,CAAC,aAAa,CAAC,EAAE;cAClCiC,KAAK,CAAClC,IAAI,CAACjF,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,GAAGO,KAAK;EAChD;EACF;EACA,QAAA,MAAMuJ,QAAQ,GAAG,MAAM,IAAI,CAAC7C,KAAK,CAC/B4C,OAAO,EACPvC,QAAQ,CAACqC,aAAa,CAAC,EACvBxC,KACF,CAAC;EACDU,QAAAA,cAAc,CAAClE,IAAI,CAACmG,QAAQ,CAAC;EAC/B;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 */\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 {Object} 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 *\n * @public\n * @static\n * @param {string} expression - The expression to evaluate.\n * @param {Object} data - The data context for evaluation.\n * @returns {*} 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 *\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 */\nexport class Signal {\n /**\n * Creates a new Signal instance with the specified initial value.\n *\n * @public\n * @param {*} value - The initial value of the signal.\n */\n constructor(value) {\n /** @private {T} Internal storage for the signal's current value, where T is the type of the initial value */\n this._value = value;\n /** @private {Set<function(T): void>} Collection of callback functions to be notified when value changes, where T is the value type */\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, where T is the type of the initial 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, where T is the type of the initial value.\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 {function(T): void} fn - The callback function to invoke on value change, where T is the value type.\n * @returns {function(): 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 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 *\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<function(any): 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 *\n * @public\n * @param {string} event - The name of the event to listen for.\n * @param {function(any): void} handler - The callback function to invoke when the event occurs.\n * @returns {function(): boolean} 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 *\n * @public\n * @param {string} event - The name of the event.\n * @param {function(any): void} [handler] - The specific handler function to remove.\n * @returns {void}\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 *\n * @public\n * @param {string} event - The name of the event to emit.\n * @param {...any} args - Optional arguments to pass to the event handlers.\n * @returns {void}\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 DOM renderer that handles efficient DOM updates through patching and diffing.\n * Provides methods for updating the DOM by comparing new and old structures and applying\n * only the necessary changes, minimizing layout thrashing and improving performance.\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 * Patches the DOM of a container element with new HTML content.\n * This method efficiently updates the DOM by comparing the new content with the existing\n * content and applying only the necessary changes.\n *\n * @public\n * @param {HTMLElement} container - The container element to patch.\n * @param {string} newHtml - The new HTML content to apply.\n * @returns {void}\n * @throws {Error} If container is not an HTMLElement or newHtml is not a string.\n */\n patchDOM(container, newHtml) {\n if (!(container instanceof HTMLElement)) {\n throw new Error(\"Container must be an HTMLElement\");\n }\n if (typeof newHtml !== \"string\") {\n throw new Error(\"newHtml must be a string\");\n }\n\n const temp = document.createElement(\"div\");\n temp.innerHTML = newHtml;\n this.diff(container, temp);\n temp.innerHTML = \"\";\n }\n\n /**\n * Diffs two DOM trees (old and new) and applies updates to the old DOM.\n * This method recursively compares nodes and their attributes, applying only\n * the necessary changes to minimize DOM operations.\n *\n * @private\n * @param {HTMLElement} oldParent - The original DOM element.\n * @param {HTMLElement} newParent - The new DOM element.\n * @returns {void}\n * @throws {Error} If either parent is not an HTMLElement.\n */\n diff(oldParent, newParent) {\n if (\n !(oldParent instanceof HTMLElement) ||\n !(newParent instanceof HTMLElement)\n ) {\n throw new Error(\"Both parents must be HTMLElements\");\n }\n\n if (oldParent.isEqualNode(newParent)) return;\n\n const oldC = oldParent.childNodes;\n const newC = newParent.childNodes;\n const len = Math.max(oldC.length, newC.length);\n const operations = [];\n\n for (let i = 0; i < len; i++) {\n const oldNode = oldC[i];\n const newNode = newC[i];\n\n if (!oldNode && newNode) {\n operations.push(() => oldParent.appendChild(newNode.cloneNode(true)));\n continue;\n }\n if (oldNode && !newNode) {\n operations.push(() => oldParent.removeChild(oldNode));\n continue;\n }\n\n const isSameType =\n oldNode.nodeType === newNode.nodeType &&\n oldNode.nodeName === newNode.nodeName;\n\n if (!isSameType) {\n operations.push(() =>\n oldParent.replaceChild(newNode.cloneNode(true), oldNode)\n );\n continue;\n }\n\n if (oldNode.nodeType === Node.ELEMENT_NODE) {\n const oldKey = oldNode.getAttribute(\"key\");\n const newKey = newNode.getAttribute(\"key\");\n\n if (oldKey !== newKey && (oldKey || newKey)) {\n operations.push(() =>\n oldParent.replaceChild(newNode.cloneNode(true), oldNode)\n );\n continue;\n }\n\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 if (operations.length) {\n operations.forEach((op) => op());\n }\n }\n\n /**\n * Updates the attributes of an element to match those of a new element.\n * Handles special cases for ARIA attributes, data attributes, and boolean properties.\n *\n * @private\n * @param {HTMLElement} oldEl - The element to update.\n * @param {HTMLElement} newEl - The element providing the updated attributes.\n * @returns {void}\n * @throws {Error} If either element is not an HTMLElement.\n */\n updateAttributes(oldEl, newEl) {\n if (!(oldEl instanceof HTMLElement) || !(newEl instanceof HTMLElement)) {\n throw new Error(\"Both elements must be HTMLElements\");\n }\n\n const oldAttrs = oldEl.attributes;\n const newAttrs = newEl.attributes;\n const operations = [];\n\n // Remove old attributes\n for (const { name } of oldAttrs) {\n if (!name.startsWith(\"@\") && !newEl.hasAttribute(name)) {\n operations.push(() => oldEl.removeAttribute(name));\n }\n }\n\n // Update/add new attributes\n for (const attr of newAttrs) {\n const { name, value } = attr;\n if (name.startsWith(\"@\")) continue;\n\n if (oldEl.getAttribute(name) === value) continue;\n\n operations.push(() => {\n oldEl.setAttribute(name, value);\n\n if (name.startsWith(\"aria-\")) {\n const prop =\n \"aria\" +\n name.slice(5).replace(/-([a-z])/g, (_, 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(/-([a-z])/g, (_, 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\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\n if (operations.length) {\n operations.forEach((op) => op());\n }\n }\n}\n","\"use strict\";\n\nimport { TemplateEngine } from \"../modules/TemplateEngine.js\";\nimport { Signal } from \"../modules/Signal.js\";\nimport { Emitter } from \"../modules/Emitter.js\";\nimport { Renderer } from \"../modules/Renderer.js\";\n\n/**\n * @typedef {Object} ComponentDefinition\n * @property {function(Object<string, any>): (Object<string, any>|Promise<Object<string, any>>)} [setup]\n * Optional setup function that initializes the component's state and returns reactive data\n * @property {function(Object<string, any>): string} template\n * Required function that defines the component's HTML structure\n * @property {function(Object<string, any>): string} [style]\n * Optional function that provides component-scoped CSS styles\n * @property {Object<string, ComponentDefinition>} [children]\n * Optional object defining nested child components\n */\n\n/**\n * @typedef {Object} ElevaPlugin\n * @property {function(Eleva, Object<string, any>): 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 * @typedef {Object} MountResult\n * @property {HTMLElement} container\n * The DOM element where the component is mounted\n * @property {Object<string, any>} data\n * The component's reactive state and context data\n * @property {function(): void} unmount\n * Function to clean up and unmount the component\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 * const app = new Eleva(\"myApp\");\n * app.component(\"myComponent\", {\n * template: (ctx) => `<div>Hello ${ctx.props.name}</div>`,\n * setup: (ctx) => ({ count: new Signal(0) })\n * });\n * app.mount(document.getElementById(\"app\"), \"myComponent\", { name: \"World\" });\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 {Object<string, any>} [config={}] - Optional configuration object for the instance.\n * May include framework-wide settings and default behaviors.\n */\n constructor(name, config = {}) {\n /** @public {string} The unique identifier name for this Eleva instance */\n this.name = name;\n /** @public {Object<string, any>} 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 {string[]} Array of lifecycle hook names supported by components */\n this._lifecycleHooks = [\n \"onBeforeMount\",\n \"onMount\",\n \"onBeforeUpdate\",\n \"onUpdate\",\n \"onUnmount\",\n ];\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, any>} [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, any>} [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 /** @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 if (typeof definition.template !== \"function\")\n throw new Error(\"Component template must be a function\");\n\n /**\n * Destructure the component definition to access core functionality.\n * - setup: Optional function for component initialization and state management\n * - template: Required function that returns the component's HTML structure\n * - style: Optional function for component-scoped CSS styles\n * - children: Optional object defining nested child components\n */\n const { setup, template, style, children } = definition;\n\n /**\n * Creates the initial context object for the component instance.\n * This context provides core functionality and will be merged with setup data.\n * @type {Object<string, any>}\n * @property {Object<string, any>} props - Component properties passed during mounting\n * @property {Emitter} emitter - Event emitter instance for component event handling\n * @property {function(any): Signal} signal - Factory function to create reactive Signal instances\n * @property {Object<string, function(): void>} ...lifecycleHooks - Prepared lifecycle hook functions\n */\n const context = {\n props,\n emitter: this.emitter,\n /** @type {(v: any) => Signal} */\n signal: (v) => new this.signal(v),\n ...this._prepareLifecycleHooks(),\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, any>} data - Data returned from the component's setup function\n * @returns {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 const mergedContext = { ...context, ...data };\n /** @type {Array<() => void>} */\n const watcherUnsubscribers = [];\n /** @type {Array<MountResult>} */\n const childInstances = [];\n /** @type {Array<() => void>} */\n const cleanupListeners = [];\n\n // Execute before hooks\n if (!this._isMounted) {\n mergedContext.onBeforeMount && mergedContext.onBeforeMount();\n } else {\n mergedContext.onBeforeUpdate && mergedContext.onBeforeUpdate();\n }\n\n /**\n * Renders the component by parsing the template, patching the DOM,\n * processing events, injecting styles, and mounting child components.\n */\n const render = async () => {\n const newHtml = TemplateEngine.parse(\n template(mergedContext),\n mergedContext\n );\n this.renderer.patchDOM(container, newHtml);\n this._processEvents(container, mergedContext, cleanupListeners);\n this._injectStyles(container, compName, style, mergedContext);\n await this._mountComponents(container, children, childInstances);\n\n if (!this._isMounted) {\n mergedContext.onMount && mergedContext.onMount();\n this._isMounted = true;\n } else {\n mergedContext.onUpdate && mergedContext.onUpdate();\n }\n };\n\n /**\n * Sets up reactive watchers for all Signal instances in the component's data.\n * When a Signal's value changes, the component will re-render to reflect the updates.\n * Stores unsubscribe functions to clean up watchers when component unmounts.\n */\n for (const val of Object.values(data)) {\n if (val instanceof Signal) watcherUnsubscribers.push(val.watch(render));\n }\n\n await render();\n\n return {\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: () => {\n for (const fn of watcherUnsubscribers) fn();\n for (const fn of cleanupListeners) fn();\n for (const child of childInstances) child.unmount();\n mergedContext.onUnmount && mergedContext.onUnmount();\n container.innerHTML = \"\";\n },\n };\n };\n\n // Handle asynchronous setup.\n const setupResult = typeof setup === \"function\" ? await setup(context) : {};\n return await processMount(setupResult);\n }\n\n /**\n * Prepares default no-operation lifecycle hook functions for a component.\n * These hooks will be called at various stages of the component's lifecycle.\n *\n * @private\n * @returns {Object<string, function(): void>} An object mapping lifecycle hook names to empty functions.\n * The returned object will be merged with the component's context.\n */\n _prepareLifecycleHooks() {\n /** @type {Object<string, () => void>} */\n const hooks = {};\n for (const hook of this._lifecycleHooks) {\n hooks[hook] = () => {};\n }\n return hooks;\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 {Object<string, any>} context - The current component context containing event handler definitions.\n * @param {Array<Function>} cleanupListeners - Array to collect cleanup functions for each event listener.\n * @returns {void}\n */\n _processEvents(container, context, cleanupListeners) {\n const elements = container.querySelectorAll(\"*\");\n for (const el of elements) {\n const attrs = el.attributes;\n for (let i = 0; i < attrs.length; i++) {\n const attr = attrs[i];\n if (attr.name.startsWith(\"@\")) {\n const event = attr.name.slice(1);\n const handler = TemplateEngine.evaluate(attr.value, context);\n if (typeof handler === \"function\") {\n el.addEventListener(event, handler);\n el.removeAttribute(attr.name);\n cleanupListeners.push(() => el.removeEventListener(event, handler));\n }\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(Object<string, any>): string} [styleFn] - Optional function that returns CSS styles as a string.\n * @param {Object<string, any>} context - The current component context for style interpolation.\n * @returns {void}\n */\n _injectStyles(container, compName, styleFn, context) {\n if (!styleFn) return;\n\n let styleEl = container.querySelector(\n `style[data-eleva-style=\"${compName}\"]`\n );\n if (!styleEl) {\n styleEl = document.createElement(\"style\");\n styleEl.setAttribute(\"data-eleva-style\", compName);\n container.appendChild(styleEl);\n }\n styleEl.textContent = TemplateEngine.parse(styleFn(context), context);\n }\n\n /**\n * Extracts props from an element's attributes that start with 'eleva-prop-'.\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 {Object<string, any>} An object containing the extracted props\n * @example\n * // For an element with attributes:\n * // <div eleva-prop-name=\"John\" eleva-prop-age=\"25\">\n * // Returns: { name: \"John\", age: \"25\" }\n */\n _extractProps(element) {\n const props = {};\n for (const { name, value } of [...element.attributes]) {\n if (name.startsWith(\"eleva-prop-\")) {\n props[name.replace(\"eleva-prop-\", \"\")] = value;\n }\n }\n return props;\n }\n\n /**\n * Mounts a single component instance to a container element.\n * This method handles the actual mounting of a component with its props.\n *\n * @private\n * @param {HTMLElement} container - The container element to mount the component to\n * @param {string|ComponentDefinition} component - The component to mount, either as a name or definition\n * @param {Object<string, any>} props - The props to pass to the component\n * @returns {Promise<MountResult>} A promise that resolves to the mounted component instance\n * @throws {Error} If the container is not a valid HTMLElement\n */\n async _mountComponentInstance(container, component, props) {\n if (!(container instanceof HTMLElement)) return null;\n return await this.mount(container, component, props);\n }\n\n /**\n * Mounts components found by a selector in the container.\n * This method handles mounting multiple instances of the same component type.\n *\n * @private\n * @param {HTMLElement} container - The container to search for components\n * @param {string} selector - The CSS selector to find components\n * @param {string|ComponentDefinition} component - The component to mount\n * @param {Array<MountResult>} instances - Array to store the mounted component instances\n * @returns {Promise<void>}\n */\n async _mountComponentsBySelector(container, selector, component, instances) {\n for (const el of container.querySelectorAll(selector)) {\n const props = this._extractProps(el);\n const instance = await this._mountComponentInstance(el, component, props);\n if (instance) instances.push(instance);\n }\n }\n\n /**\n * Mounts all components within the parent component's container.\n * This method implements a dual mounting system that handles both:\n * 1. Explicitly defined children components (passed through the children parameter)\n * 2. Template-referenced components (found in the template using component names)\n *\n * The mounting process follows these steps:\n * 1. Cleans up any existing component instances\n * 2. Mounts explicitly defined children components\n * 3. Mounts template-referenced 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 * '.user-profile': UserProfileComponent,\n * '.settings-panel': SettingsComponent\n * };\n *\n * // Template-referenced components:\n * // <div>\n * // <user-profile eleva-prop-name=\"John\"></user-profile>\n * // <settings-panel eleva-prop-theme=\"dark\"></settings-panel>\n * // </div>\n */\n async _mountComponents(container, children, childInstances) {\n // Clean up existing instances\n for (const child of childInstances) child.unmount();\n childInstances.length = 0;\n\n // Mount explicitly defined children components\n if (children) {\n for (const [selector, component] of Object.entries(children)) {\n if (!selector) continue;\n await this._mountComponentsBySelector(\n container,\n selector,\n component,\n childInstances\n );\n }\n }\n\n // Mount components referenced in the template\n for (const [compName] of this._components) {\n await this._mountComponentsBySelector(\n container,\n compName,\n compName,\n childInstances\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","patchDOM","container","newHtml","HTMLElement","Error","temp","document","createElement","innerHTML","diff","oldParent","newParent","isEqualNode","oldC","childNodes","newC","len","Math","max","length","operations","i","oldNode","newNode","push","appendChild","cloneNode","removeChild","isSameType","nodeType","nodeName","replaceChild","Node","ELEMENT_NODE","oldKey","getAttribute","newKey","updateAttributes","TEXT_NODE","nodeValue","op","oldEl","newEl","oldAttrs","attributes","newAttrs","name","startsWith","hasAttribute","removeAttribute","attr","setAttribute","prop","slice","l","toUpperCase","dataset","descriptor","Object","getOwnPropertyDescriptor","getPrototypeOf","isBoolean","call","Eleva","config","emitter","signal","renderer","_components","_plugins","_lifecycleHooks","_isMounted","use","plugin","options","install","component","definition","mount","compName","props","setup","style","children","context","v","_prepareLifecycleHooks","processMount","mergedContext","watcherUnsubscribers","childInstances","cleanupListeners","onBeforeMount","onBeforeUpdate","render","_processEvents","_injectStyles","_mountComponents","onMount","onUpdate","val","values","unmount","child","onUnmount","setupResult","hooks","hook","elements","querySelectorAll","el","attrs","addEventListener","removeEventListener","styleFn","styleEl","querySelector","textContent","_extractProps","element","_mountComponentInstance","_mountComponentsBySelector","selector","instances","instance","entries"],"mappings":";;;;;;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACO,MAAMA,cAAc,CAAC;EAC1B;EACF;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,EAA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AEI,KAAK,CAAC;EACzE,MAAA,IAAI4C,QAAQ,EAAED,SAAS,CAACnG,IAAI,CAACoG,QAAQ,CAAC;EACxC;EACF;;EAEA;EACF;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;EACA;EACE,EAAA,MAAM3B,gBAAgBA,CAAChG,SAAS,EAAEkF,QAAQ,EAAEO,cAAc,EAAE;EAC1D;MACA,KAAK,MAAMa,KAAK,IAAIb,cAAc,EAAEa,KAAK,CAACD,OAAO,EAAE;MACnDZ,cAAc,CAACvE,MAAM,GAAG,CAAC;;EAEzB;EACA,IAAA,IAAIgE,QAAQ,EAAE;EACZ,MAAA,KAAK,MAAM,CAACuC,QAAQ,EAAE9C,SAAS,CAAC,IAAIlB,MAAM,CAACmE,OAAO,CAAC1C,QAAQ,CAAC,EAAE;UAC5D,IAAI,CAACuC,QAAQ,EAAE;UACf,MAAM,IAAI,CAACD,0BAA0B,CACnCxH,SAAS,EACTyH,QAAQ,EACR9C,SAAS,EACTc,cACF,CAAC;EACH;EACF;;EAEA;MACA,KAAK,MAAM,CAACX,QAAQ,CAAC,IAAI,IAAI,CAACX,WAAW,EAAE;QACzC,MAAM,IAAI,CAACqD,0BAA0B,CACnCxH,SAAS,EACT8E,QAAQ,EACRA,QAAQ,EACRW,cACF,CAAC;EACH;EACF;EACF;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eleva",
3
- "version": "1.2.8-alpha",
3
+ "version": "1.2.10-alpha",
4
4
  "description": "A minimalist and lightweight, pure vanilla JavaScript frontend runtime framework.",
5
5
  "type": "module",
6
6
  "main": "dist/eleva.cjs.js",
package/src/core/Eleva.js CHANGED
@@ -184,11 +184,19 @@ export class Eleva {
184
184
 
185
185
  /**
186
186
  * Processes the mounting of the component.
187
+ * This function handles:
188
+ * 1. Merging setup data with the component context
189
+ * 2. Setting up reactive watchers
190
+ * 3. Rendering the component
191
+ * 4. Managing component lifecycle
187
192
  *
188
- * @param {Object<string, any>} data - Data returned from the component's setup function.
189
- * @returns {MountResult} An object with the container, merged context data, and an unmount function.
193
+ * @param {Object<string, any>} data - Data returned from the component's setup function
194
+ * @returns {MountResult} An object containing:
195
+ * - container: The mounted component's container element
196
+ * - data: The component's reactive state and context
197
+ * - unmount: Function to clean up and unmount the component
190
198
  */
191
- const processMount = (data) => {
199
+ const processMount = async (data) => {
192
200
  const mergedContext = { ...context, ...data };
193
201
  /** @type {Array<() => void>} */
194
202
  const watcherUnsubscribers = [];
@@ -208,7 +216,7 @@ export class Eleva {
208
216
  * Renders the component by parsing the template, patching the DOM,
209
217
  * processing events, injecting styles, and mounting child components.
210
218
  */
211
- const render = () => {
219
+ const render = async () => {
212
220
  const newHtml = TemplateEngine.parse(
213
221
  template(mergedContext),
214
222
  mergedContext
@@ -216,7 +224,7 @@ export class Eleva {
216
224
  this.renderer.patchDOM(container, newHtml);
217
225
  this._processEvents(container, mergedContext, cleanupListeners);
218
226
  this._injectStyles(container, compName, style, mergedContext);
219
- this._mountChildren(container, children, childInstances);
227
+ await this._mountComponents(container, children, childInstances);
220
228
 
221
229
  if (!this._isMounted) {
222
230
  mergedContext.onMount && mergedContext.onMount();
@@ -235,7 +243,7 @@ export class Eleva {
235
243
  if (val instanceof Signal) watcherUnsubscribers.push(val.watch(render));
236
244
  }
237
245
 
238
- render();
246
+ await render();
239
247
 
240
248
  return {
241
249
  container,
@@ -256,9 +264,8 @@ export class Eleva {
256
264
  };
257
265
 
258
266
  // Handle asynchronous setup.
259
- return Promise.resolve(
260
- typeof setup === "function" ? setup(context) : {}
261
- ).then(processMount);
267
+ const setupResult = typeof setup === "function" ? await setup(context) : {};
268
+ return await processMount(setupResult);
262
269
  }
263
270
 
264
271
  /**
@@ -333,39 +340,118 @@ export class Eleva {
333
340
  }
334
341
 
335
342
  /**
336
- * Mounts child components within the parent component's container.
337
- * This method handles the recursive mounting of nested components.
343
+ * Extracts props from an element's attributes that start with 'eleva-prop-'.
344
+ * This method is used to collect component properties from DOM elements.
338
345
  *
339
346
  * @private
340
- * @param {HTMLElement} container - The parent container element.
341
- * @param {Object<string, ComponentDefinition>} [children] - Object mapping of child component selectors to their definitions.
342
- * @param {Array<MountResult>} childInstances - Array to store the mounted child component instances.
343
- * @returns {void}
347
+ * @param {HTMLElement} element - The DOM element to extract props from
348
+ * @returns {Object<string, any>} An object containing the extracted props
349
+ * @example
350
+ * // For an element with attributes:
351
+ * // <div eleva-prop-name="John" eleva-prop-age="25">
352
+ * // Returns: { name: "John", age: "25" }
344
353
  */
345
- async _mountChildren(container, children, childInstances) {
346
- for (const child of childInstances) child.unmount();
347
- childInstances.length = 0;
354
+ _extractProps(element) {
355
+ const props = {};
356
+ for (const { name, value } of [...element.attributes]) {
357
+ if (name.startsWith("eleva-prop-")) {
358
+ props[name.replace("eleva-prop-", "")] = value;
359
+ }
360
+ }
361
+ return props;
362
+ }
348
363
 
349
- if (!children) return;
364
+ /**
365
+ * Mounts a single component instance to a container element.
366
+ * This method handles the actual mounting of a component with its props.
367
+ *
368
+ * @private
369
+ * @param {HTMLElement} container - The container element to mount the component to
370
+ * @param {string|ComponentDefinition} component - The component to mount, either as a name or definition
371
+ * @param {Object<string, any>} props - The props to pass to the component
372
+ * @returns {Promise<MountResult>} A promise that resolves to the mounted component instance
373
+ * @throws {Error} If the container is not a valid HTMLElement
374
+ */
375
+ async _mountComponentInstance(container, component, props) {
376
+ if (!(container instanceof HTMLElement)) return null;
377
+ return await this.mount(container, component, props);
378
+ }
379
+
380
+ /**
381
+ * Mounts components found by a selector in the container.
382
+ * This method handles mounting multiple instances of the same component type.
383
+ *
384
+ * @private
385
+ * @param {HTMLElement} container - The container to search for components
386
+ * @param {string} selector - The CSS selector to find components
387
+ * @param {string|ComponentDefinition} component - The component to mount
388
+ * @param {Array<MountResult>} instances - Array to store the mounted component instances
389
+ * @returns {Promise<void>}
390
+ */
391
+ async _mountComponentsBySelector(container, selector, component, instances) {
392
+ for (const el of container.querySelectorAll(selector)) {
393
+ const props = this._extractProps(el);
394
+ const instance = await this._mountComponentInstance(el, component, props);
395
+ if (instance) instances.push(instance);
396
+ }
397
+ }
350
398
 
351
- for (const childSelector of Object.keys(children)) {
352
- if (!childSelector) continue;
399
+ /**
400
+ * Mounts all components within the parent component's container.
401
+ * This method implements a dual mounting system that handles both:
402
+ * 1. Explicitly defined children components (passed through the children parameter)
403
+ * 2. Template-referenced components (found in the template using component names)
404
+ *
405
+ * The mounting process follows these steps:
406
+ * 1. Cleans up any existing component instances
407
+ * 2. Mounts explicitly defined children components
408
+ * 3. Mounts template-referenced components
409
+ *
410
+ * @private
411
+ * @param {HTMLElement} container - The container element to mount components in
412
+ * @param {Object<string, ComponentDefinition>} children - Map of selectors to component definitions for explicit children
413
+ * @param {Array<MountResult>} childInstances - Array to store all mounted component instances
414
+ * @returns {Promise<void>}
415
+ *
416
+ * @example
417
+ * // Explicit children mounting:
418
+ * const children = {
419
+ * '.user-profile': UserProfileComponent,
420
+ * '.settings-panel': SettingsComponent
421
+ * };
422
+ *
423
+ * // Template-referenced components:
424
+ * // <div>
425
+ * // <user-profile eleva-prop-name="John"></user-profile>
426
+ * // <settings-panel eleva-prop-theme="dark"></settings-panel>
427
+ * // </div>
428
+ */
429
+ async _mountComponents(container, children, childInstances) {
430
+ // Clean up existing instances
431
+ for (const child of childInstances) child.unmount();
432
+ childInstances.length = 0;
353
433
 
354
- for (const childEl of container.querySelectorAll(childSelector)) {
355
- if (!(childEl instanceof HTMLElement)) continue;
356
- const props = {};
357
- for (const { name, value } of [...childEl.attributes]) {
358
- if (name.startsWith("eleva-prop-")) {
359
- props[name.replace("eleva-prop-", "")] = value;
360
- }
361
- }
362
- const instance = await this.mount(
363
- childEl,
364
- children[childSelector],
365
- props
434
+ // Mount explicitly defined children components
435
+ if (children) {
436
+ for (const [selector, component] of Object.entries(children)) {
437
+ if (!selector) continue;
438
+ await this._mountComponentsBySelector(
439
+ container,
440
+ selector,
441
+ component,
442
+ childInstances
366
443
  );
367
- childInstances.push(instance);
368
444
  }
369
445
  }
446
+
447
+ // Mount components referenced in the template
448
+ for (const [compName] of this._components) {
449
+ await this._mountComponentsBySelector(
450
+ container,
451
+ compName,
452
+ compName,
453
+ childInstances
454
+ );
455
+ }
370
456
  }
371
457
  }
@@ -46,10 +46,10 @@ export class Signal {
46
46
  * @returns {void}
47
47
  */
48
48
  set value(newVal) {
49
- if (newVal !== this._value) {
50
- this._value = newVal;
51
- this._notifyWatchers();
52
- }
49
+ if (this._value === newVal) return;
50
+
51
+ this._value = newVal;
52
+ this._notify();
53
53
  }
54
54
 
55
55
  /**
@@ -77,13 +77,13 @@ export class Signal {
77
77
  * @private
78
78
  * @returns {void}
79
79
  */
80
- _notifyWatchers() {
81
- if (!this._pending) {
82
- this._pending = true;
83
- queueMicrotask(() => {
84
- this._pending = false;
85
- this._watchers.forEach((fn) => fn(this._value));
86
- });
87
- }
80
+ _notify() {
81
+ if (this._pending) return;
82
+
83
+ this._pending = true;
84
+ queueMicrotask(() => {
85
+ this._watchers.forEach((fn) => fn(this._value));
86
+ this._pending = false;
87
+ });
88
88
  }
89
89
  }
@@ -157,16 +157,73 @@ export class Eleva {
157
157
  */
158
158
  private _injectStyles;
159
159
  /**
160
- * Mounts child components within the parent component's container.
161
- * This method handles the recursive mounting of nested components.
160
+ * Extracts props from an element's attributes that start with 'eleva-prop-'.
161
+ * This method is used to collect component properties from DOM elements.
162
162
  *
163
163
  * @private
164
- * @param {HTMLElement} container - The parent container element.
165
- * @param {Object<string, ComponentDefinition>} [children] - Object mapping of child component selectors to their definitions.
166
- * @param {Array<MountResult>} childInstances - Array to store the mounted child component instances.
167
- * @returns {void}
164
+ * @param {HTMLElement} element - The DOM element to extract props from
165
+ * @returns {Object<string, any>} An object containing the extracted props
166
+ * @example
167
+ * // For an element with attributes:
168
+ * // <div eleva-prop-name="John" eleva-prop-age="25">
169
+ * // Returns: { name: "John", age: "25" }
170
+ */
171
+ private _extractProps;
172
+ /**
173
+ * Mounts a single component instance to a container element.
174
+ * This method handles the actual mounting of a component with its props.
175
+ *
176
+ * @private
177
+ * @param {HTMLElement} container - The container element to mount the component to
178
+ * @param {string|ComponentDefinition} component - The component to mount, either as a name or definition
179
+ * @param {Object<string, any>} props - The props to pass to the component
180
+ * @returns {Promise<MountResult>} A promise that resolves to the mounted component instance
181
+ * @throws {Error} If the container is not a valid HTMLElement
182
+ */
183
+ private _mountComponentInstance;
184
+ /**
185
+ * Mounts components found by a selector in the container.
186
+ * This method handles mounting multiple instances of the same component type.
187
+ *
188
+ * @private
189
+ * @param {HTMLElement} container - The container to search for components
190
+ * @param {string} selector - The CSS selector to find components
191
+ * @param {string|ComponentDefinition} component - The component to mount
192
+ * @param {Array<MountResult>} instances - Array to store the mounted component instances
193
+ * @returns {Promise<void>}
194
+ */
195
+ private _mountComponentsBySelector;
196
+ /**
197
+ * Mounts all components within the parent component's container.
198
+ * This method implements a dual mounting system that handles both:
199
+ * 1. Explicitly defined children components (passed through the children parameter)
200
+ * 2. Template-referenced components (found in the template using component names)
201
+ *
202
+ * The mounting process follows these steps:
203
+ * 1. Cleans up any existing component instances
204
+ * 2. Mounts explicitly defined children components
205
+ * 3. Mounts template-referenced components
206
+ *
207
+ * @private
208
+ * @param {HTMLElement} container - The container element to mount components in
209
+ * @param {Object<string, ComponentDefinition>} children - Map of selectors to component definitions for explicit children
210
+ * @param {Array<MountResult>} childInstances - Array to store all mounted component instances
211
+ * @returns {Promise<void>}
212
+ *
213
+ * @example
214
+ * // Explicit children mounting:
215
+ * const children = {
216
+ * '.user-profile': UserProfileComponent,
217
+ * '.settings-panel': SettingsComponent
218
+ * };
219
+ *
220
+ * // Template-referenced components:
221
+ * // <div>
222
+ * // <user-profile eleva-prop-name="John"></user-profile>
223
+ * // <settings-panel eleva-prop-theme="dark"></settings-panel>
224
+ * // </div>
168
225
  */
169
- private _mountChildren;
226
+ private _mountComponents;
170
227
  }
171
228
  export type ComponentDefinition = {
172
229
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Eleva.d.ts","sourceRoot":"","sources":["../../src/core/Eleva.js"],"names":[],"mappings":"AAOA;;;;;;;;;;GAUG;AAEH;;;;;;GAMG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;GAaG;AACH;IACE;;;;;;;OAOG;IACH,kBAJW,MAAM;;OA8BhB;IAzBC,0EAA0E;IAC1E,oBAAgB;IAChB,yFAAyF;IACzF;;MAAoB;IACpB,oFAAoF;IACpF,wBAA4B;IAC5B,+FAA+F;IAC/F,6BAAoB;IACpB,wFAAwF;IACxF,0BAA8B;IAE9B,gGAAgG;IAChG,oBAA4B;IAC5B,2FAA2F;IAC3F,iBAAyB;IACzB,gFAAgF;IAChF,wBAMC;IACD,oFAAoF;IACpF,mBAAuB;IAGzB;;;;;;;;;;;OAWG;IACH,mBANW,WAAW;;QAET,KAAK,CASjB;IAED;;;;;;;;;;;;;;OAcG;IACH,uBAVW,MAAM,cACN,mBAAmB,GACjB,KAAK,CAYjB;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,wBAdW,WAAW,YACX,MAAM,GAAC,mBAAmB;;QAExB,OAAO,CAAC,WAAW,CAAC,CA6HhC;IAED;;;;;;;OAOG;IACH,+BAOC;IAED;;;;;;;;;OASG;IACH,uBAiBC;IAED;;;;;;;;;;OAUG;IACH,sBAYC;IAED;;;;;;;;;OASG;IACH,uBAyBC;CACF;;;;;;;UAzW4C,CAAC;YAAO,MAAM,GAAE,GAAG;KAAC,GAAC,OAAO,CAAC;YAAO,MAAM,GAAE,GAAG;KAAC,CAAC,CAAC;;;;cAEjF,CAAS,IAAmB,EAAnB;YAAO,MAAM,GAAE,GAAG;KAAC,KAAG,MAAM;;;;;;UAEN,MAAM;;;;;;;;;;;;aAQrC,CAAS,IAAK,EAAL,KAAK,EAAE,IAAmB,EAAnB;YAAO,MAAM,GAAE,GAAG;KAAC,K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;;;;cAEjF,CAAS,IAAmB,EAAnB;YAAO,MAAM,GAAE,GAAG;KAAC,KAAG,MAAM;;;;;;UAEN,MAAM;;;;;;;;;;;;aAQrC,CAAS,IAAK,EAAL,KAAK,EAAE,IAAmB,EAAnB;YAAO,MAAM,GAAE,GAAG;KAAC,KAAG,IAAI;;;;UAE1C,MAAM;;;;;;eAMN,WAAW;;;;;;;;;;aAIX,MAAY,IAAI;;wBA7BN,uBAAuB;uBADxB,sBAAsB;yBAEpB,wBAAwB"}
@@ -60,6 +60,6 @@ export class Signal {
60
60
  * @private
61
61
  * @returns {void}
62
62
  */
63
- private _notifyWatchers;
63
+ private _notify;
64
64
  }
65
65
  //# sourceMappingURL=Signal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Signal.d.ts","sourceRoot":"","sources":["../../src/modules/Signal.js"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH;IACE;;;;;OAKG;IACH,mBAFW,GAAC,EASX;IANC,6GAA6G;IAC7G,eAAmB;IACnB,sIAAsI;IACtI,kBAA0B;IAC1B,sHAAsH;IACtH,iBAAqB;IAavB;;;;;;;OAOG;IACH,yBAHW,CAAC,EAQX;IAvBD;;;;;OAKG;IACH,oBAFa,CAAC,CAIb;IAiBD;;;;;;;;;;;OAWG;IACH,iBAPW,CAAS,IAAC,EAAD,CAAC,KAAG,IAAI,GACf,MAAY,OAAO,CAS/B;IAED;;;;;;;OAOG;IACH,wBAQC;CACF"}
1
+ {"version":3,"file":"Signal.d.ts","sourceRoot":"","sources":["../../src/modules/Signal.js"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH;IACE;;;;;OAKG;IACH,mBAFW,GAAC,EASX;IANC,6GAA6G;IAC7G,eAAmB;IACnB,sIAAsI;IACtI,kBAA0B;IAC1B,sHAAsH;IACtH,iBAAqB;IAavB;;;;;;;OAOG;IACH,yBAHW,CAAC,EAQX;IAvBD;;;;;OAKG;IACH,oBAFa,CAAC,CAIb;IAiBD;;;;;;;;;;;OAWG;IACH,iBAPW,CAAS,IAAC,EAAD,CAAC,KAAG,IAAI,GACf,MAAY,OAAO,CAS/B;IAED;;;;;;;OAOG;IACH,gBAQC;CACF"}