eleva 1.2.7-alpha → 1.2.8-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/eleva.cjs.js +730 -0
- package/dist/eleva.cjs.js.map +1 -0
- package/dist/eleva.d.ts +305 -80
- package/dist/eleva.esm.js +278 -142
- package/dist/eleva.esm.js.map +1 -1
- package/dist/eleva.min.js +2 -1
- package/dist/eleva.min.js.map +1 -1
- package/dist/eleva.umd.js +278 -142
- package/dist/eleva.umd.js.map +1 -1
- package/package.json +10 -13
- package/src/core/Eleva.js +148 -84
- package/src/modules/Emitter.js +48 -18
- package/src/modules/Renderer.js +23 -6
- package/src/modules/Signal.js +25 -9
- package/src/modules/TemplateEngine.js +42 -27
- package/types/core/Eleva.d.ts +143 -80
- package/types/core/Eleva.d.ts.map +1 -1
- package/types/modules/Emitter.d.ts +35 -19
- package/types/modules/Emitter.d.ts.map +1 -1
- package/types/modules/Renderer.d.ts +26 -9
- package/types/modules/Renderer.d.ts.map +1 -1
- package/types/modules/Signal.d.ts +28 -12
- package/types/modules/Signal.d.ts.map +1 -1
- package/types/modules/TemplateEngine.d.ts +35 -17
- package/types/modules/TemplateEngine.d.ts.map +1 -1
package/dist/eleva.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eleva.esm.js","sources":["../src/modules/TemplateEngine.js","../src/modules/Signal.js","../src/modules/Emitter.js","../src/modules/Renderer.js","../src/core/Eleva.js"],"sourcesContent":["\"use strict\";\n\n/**\n * @class 🔒 TemplateEngine\n * @classdesc Secure interpolation & dynamic attribute parsing.\n * Provides methods to parse template strings by replacing interpolation expressions\n * with dynamic data values and to evaluate expressions within a given data context.\n */\nexport class TemplateEngine {\n /**\n * Parses a template string and replaces interpolation expressions with corresponding values.\n *\n * @param {string} template - The template string containing expressions in the format `{{ expression }}`.\n * @param {Object<string, any>} data - The data object to use for evaluating expressions.\n * @returns {string} The resulting string with evaluated values.\n */\n static parse(template, data) {\n if (!template || typeof template !== \"string\") return template;\n\n return template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, expr) => {\n return this.evaluate(expr, data);\n });\n }\n\n /**\n * Evaluates a JavaScript expression using the provided data context.\n *\n * @param {string} expr - The JavaScript expression to evaluate.\n * @param {Object<string, any>} data - The data context for evaluating the expression.\n * @returns {any} The result of the evaluated expression, or an empty string if undefined or on error.\n */\n static evaluate(expr, data) {\n if (!expr || typeof expr !== \"string\") return expr;\n\n try {\n const compiledFn = new Function(\"data\", `with(data) { return ${expr} }`);\n return compiledFn(data);\n } catch (error) {\n console.error(`Template evaluation error:`, {\n expression: expr,\n data,\n error: error.message,\n });\n return \"\";\n }\n }\n}\n","\"use strict\";\n\n/**\n * @class ⚡ Signal\n * @classdesc Fine-grained reactivity.\n * A reactive data holder that notifies registered watchers when its value changes,\n * enabling fine-grained DOM patching rather than full re-renders.\n */\nexport class Signal {\n /**\n * Creates a new Signal instance.\n *\n * @param {*} value - The initial value of the signal.\n */\n constructor(value) {\n /** @private {*} Internal storage for the signal's current value */\n this._value = value;\n /** @private {Set<function>} Collection of callback functions to be notified when value changes */\n this._watchers = new Set();\n /** @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 * @returns {*} The current value.\n */\n get value() {\n return this._value;\n }\n\n /**\n * Sets a new value for the signal and notifies all registered watchers if the value has changed.\n *\n * @param {*} newVal - The new value to set.\n */\n set value(newVal) {\n if (newVal !== this._value) {\n this._value = newVal;\n this._notifyWatchers();\n }\n }\n\n /**\n * Registers a watcher function that will be called whenever the signal's value changes.\n *\n * @param {function(any): void} fn - The callback function to invoke on value change.\n * @returns {function(): boolean} A function to unsubscribe the watcher.\n */\n watch(fn) {\n this._watchers.add(fn);\n return () => this._watchers.delete(fn);\n }\n\n /**\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 Robust inter-component communication with event bubbling.\n * Implements a basic publish-subscribe pattern for event handling, allowing components\n * to communicate through custom events.\n */\nexport class Emitter {\n /**\n * Creates a new Emitter instance.\n */\n constructor() {\n /** @type {Object.<string, Function[]>} Storage for event handlers mapped by event name */\n this.events = {};\n }\n\n /**\n * Registers an event handler for the specified event.\n *\n * @param {string} event - The name of the event.\n * @param {function(...any): void} handler - The function to call when the event is emitted.\n */\n on(event, handler) {\n (this.events[event] || (this.events[event] = [])).push(handler);\n }\n\n /**\n * Removes a previously registered event handler.\n *\n * @param {string} event - The name of the event.\n * @param {function(...any): void} handler - The handler function to remove.\n */\n off(event, handler) {\n if (this.events[event]) {\n this.events[event] = this.events[event].filter((h) => h !== handler);\n }\n }\n\n /**\n * Emits an event, invoking all handlers registered for that event.\n *\n * @param {string} event - The event name.\n * @param {...any} args - Additional arguments to pass to the event handlers.\n */\n emit(event, ...args) {\n (this.events[event] || []).forEach((handler) => handler(...args));\n }\n}\n","\"use strict\";\n\n/**\n * @class 🎨 Renderer\n * @classdesc Handles DOM patching, diffing, and attribute updates.\n * Provides methods for efficient DOM updates by diffing the new and old DOM structures\n * and applying only the necessary changes.\n */\nexport class Renderer {\n /**\n * Patches the DOM of a container element with new HTML content.\n *\n * @param {HTMLElement} container - The container element to patch.\n * @param {string} newHtml - The new HTML content to apply.\n * @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 *\n * @param {HTMLElement} oldParent - The original DOM element.\n * @param {HTMLElement} newParent - The new DOM element.\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 *\n * @param {HTMLElement} oldEl - The element to update.\n * @param {HTMLElement} newEl - The element providing the updated attributes.\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 * Defines the structure and behavior of a component.\n * @typedef {Object} ComponentDefinition\n * @property {function(Object<string, any>): (Object<string, any>|Promise<Object<string, any>>)} [setup]\n * Optional setup function that initializes the component's reactive state and lifecycle.\n * Receives props and context as an argument and should return an object containing the component's state.\n * Can return either a synchronous object or a Promise that resolves to an object for async initialization.\n *\n * @property {function(Object<string, any>): string} template\n * Required function that defines the component's HTML structure.\n * Receives the merged context (props + setup data) and must return an HTML template string.\n * Supports dynamic expressions using {{ }} syntax for reactive data binding.\n *\n * @property {function(Object<string, any>): string} [style]\n * Optional function that defines component-scoped CSS styles.\n * Receives the merged context and returns a CSS string that will be automatically scoped to the component.\n * Styles are injected into the component's container and only affect elements within it.\n *\n * @property {Object<string, ComponentDefinition>} [children]\n * Optional object that defines nested child components.\n * Keys are CSS selectors that match elements in the template where child components should be mounted.\n * Values are ComponentDefinition objects that define the structure and behavior of each child component.\n */\n\n/**\n * @class 🧩 Eleva\n * @classdesc Signal-based component runtime framework with lifecycle hooks, scoped styles, and plugin support.\n * Manages component registration, plugin integration, event handling, and DOM rendering.\n */\nexport class Eleva {\n /**\n * Creates a new Eleva instance.\n *\n * @param {string} name - The name of the Eleva instance.\n * @param {Object<string, any>} [config={}] - Optional configuration for the instance.\n */\n constructor(name, config = {}) {\n /** @type {string} The unique identifier name for this Eleva instance */\n this.name = name;\n /** @type {Object<string, any>} Optional configuration object for the Eleva instance */\n this.config = config;\n /** @type {Object<string, ComponentDefinition>} Object storing registered component definitions by name */\n this._components = {};\n /** @private {Array<Object>} Collection of installed plugin instances */\n this._plugins = [];\n /** @private {string[]} Array of lifecycle hook names supported by the component */\n this._lifecycleHooks = [\n \"onBeforeMount\",\n \"onMount\",\n \"onBeforeUpdate\",\n \"onUpdate\",\n \"onUnmount\",\n ];\n /** @private {boolean} Flag indicating if component is currently mounted */\n this._isMounted = false;\n /** @private {Emitter} Instance of the event emitter for handling component events */\n this.emitter = new Emitter();\n /** @private {Signal} Instance of the signal for handling plugin and component signals */\n this.signal = Signal;\n /** @private {Renderer} Instance of the renderer for handling DOM updates and patching */\n this.renderer = new Renderer();\n }\n\n /**\n * Integrates a plugin with the Eleva framework.\n *\n * @param {Object} plugin - The plugin object which should have an `install` function.\n * @param {Object<string, any>} [options={}] - Optional options to pass to the plugin.\n * @returns {Eleva} The Eleva instance (for chaining).\n */\n use(plugin, options = {}) {\n if (typeof plugin.install === \"function\") {\n plugin.install(this, options);\n }\n this._plugins.push(plugin);\n return this;\n }\n\n /**\n * Registers a component with the Eleva instance.\n *\n * @param {string} name - The name of the component.\n * @param {ComponentDefinition} definition - The component definition including setup, template, style, and children.\n * @returns {Eleva} The Eleva instance (for chaining).\n */\n component(name, definition) {\n this._components[name] = definition;\n return this;\n }\n\n /**\n * Mounts a registered component to a DOM element.\n *\n * @param {HTMLElement} container - A DOM element where the component will be mounted.\n * @param {string|ComponentDefinition} compName - The name of the component to mount or a component definition.\n * @param {Object<string, any>} [props={}] - Optional properties to pass to the component.\n * @returns {object|Promise<object>} An object representing the mounted component instance, or a Promise that resolves to it for asynchronous setups.\n * @throws {Error} If the container is not found or if the component is not registered.\n */\n mount(container, compName, props = {}) {\n if (!container) throw new Error(`Container not found: ${container}`);\n\n const definition =\n typeof compName === \"string\" ? this._components[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 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 {object} An object with the container, merged context data, and an unmount function.\n */\n const processMount = (data) => {\n const mergedContext = { ...context, ...data };\n const watcherUnsubscribers = [];\n const childInstances = [];\n 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 Object.values(data).forEach((val) => {\n if (val instanceof Signal) watcherUnsubscribers.push(val.watch(render));\n });\n\n render();\n\n return {\n container,\n data: mergedContext,\n /**\n * Unmounts the component, cleaning up watchers and listeners, child components, and clearing the container.\n *\n * @returns {void}\n */\n unmount: () => {\n watcherUnsubscribers.forEach((fn) => fn());\n cleanupListeners.forEach((fn) => fn());\n childInstances.forEach((child) => child.unmount());\n mergedContext.onUnmount && mergedContext.onUnmount();\n container.innerHTML = \"\";\n },\n };\n };\n\n // Handle asynchronous setup.\n return Promise.resolve(\n typeof setup === \"function\" ? setup(context) : {}\n ).then(processMount);\n }\n\n /**\n * Prepares default no-operation lifecycle hook functions.\n *\n * @returns {Object<string, function(): void>} An object with keys for lifecycle hooks mapped to empty functions.\n * @private\n */\n _prepareLifecycleHooks() {\n return this._lifecycleHooks.reduce((acc, hook) => {\n acc[hook] = () => {};\n return acc;\n }, {});\n }\n\n /**\n * Processes DOM elements for event binding based on attributes starting with \"@\".\n * Tracks listeners for cleanup during unmount.\n *\n * @param {HTMLElement} container - The container element in which to search for events.\n * @param {Object<string, any>} context - The current context containing event handler definitions.\n * @param {Array<Function>} cleanupListeners - Array to collect cleanup functions for each event listener.\n * @private\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 *\n * @param {HTMLElement} container - The container element.\n * @param {string} compName - The component name used to identify the style element.\n * @param {function(Object<string, any>): string} [styleFn] - A function that returns CSS styles as a string.\n * @param {Object<string, any>} context - The current context for style interpolation.\n * @private\n */\n _injectStyles(container, compName, styleFn, context) {\n if (!styleFn) 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 *\n * @param {HTMLElement} container - The parent container element.\n * @param {Object<string, ComponentDefinition>} [children] - An object mapping child component selectors to their definitions.\n * @param {Array<object>} childInstances - An array to store the mounted child component instances.\n * @private\n */\n _mountChildren(container, children, childInstances) {\n childInstances.forEach((child) => child.unmount());\n childInstances.length = 0;\n\n Object.keys(children || {}).forEach((childSelector) => {\n container.querySelectorAll(childSelector).forEach((childEl) => {\n const props = {};\n [...childEl.attributes].forEach(({ name, value }) => {\n if (name.startsWith(\"eleva-prop-\")) {\n props[name.replace(\"eleva-prop-\", \"\")] = value;\n }\n });\n const instance = this.mount(childEl, children[childSelector], props);\n childInstances.push(instance);\n });\n });\n }\n}\n"],"names":["TemplateEngine","parse","template","data","replace","_","expr","evaluate","compiledFn","Function","error","console","expression","message","Signal","constructor","value","_value","_watchers","Set","_pending","newVal","_notifyWatchers","watch","fn","add","delete","queueMicrotask","forEach","Emitter","events","on","event","handler","push","off","filter","h","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","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","get","call","Eleva","config","_components","_plugins","_lifecycleHooks","_isMounted","emitter","signal","renderer","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","values","val","unmount","child","onUnmount","Promise","resolve","then","reduce","acc","hook","elements","querySelectorAll","el","attrs","addEventListener","removeEventListener","styleFn","styleEl","querySelector","textContent","keys","childSelector","childEl","instance"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,cAAc,CAAC;AAC1B;AACF;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,OAAOC,KAAKA,CAACC,QAAQ,EAAEC,IAAI,EAAE;IAC3B,IAAI,CAACD,QAAQ,IAAI,OAAOA,QAAQ,KAAK,QAAQ,EAAE,OAAOA,QAAQ;IAE9D,OAAOA,QAAQ,CAACE,OAAO,CAAC,sBAAsB,EAAE,CAACC,CA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AK;AAChD;AACF,SAAC,CAAC;AACF,QAAA,MAAMqJ,QAAQ,GAAG,IAAI,CAAC9C,KAAK,CAAC6C,OAAO,EAAExC,QAAQ,CAACuC,aAAa,CAAC,EAAE1C,KAAK,CAAC;AACpEU,QAAAA,cAAc,CAACjG,IAAI,CAACmI,QAAQ,CAAC;AAC/B,OAAC,CAAC;AACJ,KAAC,CAAC;AACJ;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"eleva.esm.js","sources":["../src/modules/TemplateEngine.js","../src/modules/Signal.js","../src/modules/Emitter.js","../src/modules/Renderer.js","../src/core/Eleva.js"],"sourcesContent":["\"use strict\";\n\n/**\n * @class 🔒 TemplateEngine\n * @classdesc 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":";AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,cAAc,CAAC;AAC1B;AACF;AACA;EACE,OAAOC,iBAAiB,GAAG,sBAAsB;;AAEjD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,OAAOC,KAAKA,CAACC,QAAQ,EAAEC,IAAI,EAAE;AAC3B,IAAA,IAAI,OAAOD,QAAQ,KAAK,QAAQ,EAAE,OAAOA,QAAQ;IACjD,OAAOA,QAAQ,CAACE,OAAO,CAAC,IAAI,CAACJ,iBAAiB,EAAE,CAACK,CAAC,EAAEC,UAAU,KAC5D,IAAI,CAACC,QAAQ,CAACD,UAAU,EAAEH,IAAI,CAChC,CAAC;AACH;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,OAAOI,QAAQA,CAACD,UAAU,EAAEH,IAAI,EAAE;AAChC,IAAA,IAAI,OAAOG,UAAU,KAAK,QAAQ,EAAE,OAAOA,UAAU;IACrD,IAAI;MACF,OAAO,IAAIE,QAAQ,CAAC,MAAM,EAAE,CAAuBF,oBAAAA,EAAAA,UAAU,CAAK,GAAA,CAAA,CAAC,CAACH,IAAI,CAAC;AAC3E,KAAC,CAAC,MAA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AAE;MAEpB,KAAK,MAAME,OAAO,IAAIzH,SAAS,CAAC8G,gBAAgB,CAACS,aAAa,CAAC,EAAE;AAC/D,QAAA,IAAI,EAAEE,OAAO,YAAYvH,WAAW,CAAC,EAAE;QACvC,MAAM6E,KAAK,GAAG,EAAE;AAChB,QAAA,KAAK,MAAM;UAAElC,IAAI;AAAE1E,UAAAA;AAAM,SAAC,IAAI,CAAC,GAAGsJ,OAAO,CAAC9E,UAAU,CAAC,EAAE;AACrD,UAAA,IAAIE,IAAI,CAACC,UAAU,CAAC,aAAa,CAAC,EAAE;YAClCiC,KAAK,CAAClC,IAAI,CAACjF,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,GAAGO,KAAK;AAChD;AACF;AACA,QAAA,MAAMuJ,QAAQ,GAAG,MAAM,IAAI,CAAC7C,KAAK,CAC/B4C,OAAO,EACPvC,QAAQ,CAACqC,aAAa,CAAC,EACvBxC,KACF,CAAC;AACDU,QAAAA,cAAc,CAAClE,IAAI,CAACmG,QAAQ,CAAC;AAC/B;AACF;AACF;AACF;;;;"}
|
package/dist/eleva.min.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
/*! Eleva v1.2.8-alpha | MIT License | https://elevajs.com */
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Eleva=t()}(this,(function(){"use strict";class e{static expressionPattern=/\{\{\s*(.*?)\s*\}\}/g;static parse(e,t){return"string"!=typeof e?e:e.replace(this.expressionPattern,((e,n)=>this.evaluate(n,t)))}static evaluate(e,t){if("string"!=typeof e)return e;try{return new Function("data",`with(data) { return ${e}; }`)(t)}catch{return""}}}class t{constructor(e){this._value=e,this._watchers=new Set,this._pending=!1}get value(){return this._value}set value(e){e!==this._value&&(this._value=e,this._notifyWatchers())}watch(e){return this._watchers.add(e),()=>this._watchers.delete(e)}_notifyWatchers(){this._pending||(this._pending=!0,queueMicrotask((()=>{this._pending=!1,this._watchers.forEach((e=>e(this._value)))})))}}class n{constructor(){this._events=new Map}on(e,t){return this._events.has(e)||this._events.set(e,new Set),this._events.get(e).add(t),()=>this.off(e,t)}off(e,t){if(this._events.has(e))if(t){const n=this._events.get(e);n.delete(t),0===n.size&&this._events.delete(e)}else this._events.delete(e)}emit(e,...t){this._events.has(e)&&this._events.get(e).forEach((e=>e(...t)))}}class s{patchDOM(e,t){if(!(e instanceof HTMLElement))throw new Error("Container must be an HTMLElement");if("string"!=typeof t)throw new Error("newHtml must be a string");const n=document.createElement("div");n.innerHTML=t,this.diff(e,n),n.innerHTML=""}diff(e,t){if(!(e instanceof HTMLElement&&t instanceof HTMLElement))throw new Error("Both parents must be HTMLElements");if(e.isEqualNode(t))return;const n=e.childNodes,s=t.childNodes,o=Math.max(n.length,s.length),i=[];for(let t=0;t<o;t++){const o=n[t],r=s[t];if(!o&&r){i.push((()=>e.appendChild(r.cloneNode(!0))));continue}if(o&&!r){i.push((()=>e.removeChild(o)));continue}if(o.nodeType===r.nodeType&&o.nodeName===r.nodeName)if(o.nodeType===Node.ELEMENT_NODE){const t=o.getAttribute("key"),n=r.getAttribute("key");if(t!==n&&(t||n)){i.push((()=>e.replaceChild(r.cloneNode(!0),o)));continue}this.updateAttributes(o,r),this.diff(o,r)}else o.nodeType===Node.TEXT_NODE&&o.nodeValue!==r.nodeValue&&(o.nodeValue=r.nodeValue);else i.push((()=>e.replaceChild(r.cloneNode(!0),o)))}i.length&&i.forEach((e=>e()))}updateAttributes(e,t){if(!(e instanceof HTMLElement&&t instanceof HTMLElement))throw new Error("Both elements must be HTMLElements");const n=e.attributes,s=t.attributes,o=[];for(const{name:s}of n)s.startsWith("@")||t.hasAttribute(s)||o.push((()=>e.removeAttribute(s)));for(const t of s){const{name:n,value:s}=t;n.startsWith("@")||e.getAttribute(n)!==s&&o.push((()=>{if(e.setAttribute(n,s),n.startsWith("aria-")){const t="aria"+n.slice(5).replace(/-([a-z])/g,((e,t)=>t.toUpperCase()));e[t]=s}else if(n.startsWith("data-"))e.dataset[n.slice(5)]=s;else{const t=n.replace(/-([a-z])/g,((e,t)=>t.toUpperCase()));if(t in e){const n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),t),o="boolean"==typeof e[t]||n?.get&&"boolean"==typeof n.get.call(e);e[t]=o?"false"!==s&&(""===s||s===t||"true"===s):s}}}))}o.length&&o.forEach((e=>e()))}}return class{constructor(e,o={}){this.name=e,this.config=o,this.emitter=new n,this.signal=t,this.renderer=new s,this._components=new Map,this._plugins=new Map,this._lifecycleHooks=["onBeforeMount","onMount","onBeforeUpdate","onUpdate","onUnmount"],this._isMounted=!1}use(e,t={}){return e.install(this,t),this._plugins.set(e.name,e),this}component(e,t){return this._components.set(e,t),this}async mount(n,s,o={}){if(!n)throw new Error(`Container not found: ${n}`);const i="string"==typeof s?this._components.get(s):s;if(!i)throw new Error(`Component "${s}" not registered.`);if("function"!=typeof i.template)throw new Error("Component template must be a function");const{setup:r,template:a,style:c,children:l}=i,h={props:o,emitter:this.emitter,signal:e=>new this.signal(e),...this._prepareLifecycleHooks()};return Promise.resolve("function"==typeof r?r(h):{}).then((o=>{const i={...h,...o},r=[],u=[],f=[];this._isMounted?i.onBeforeUpdate&&i.onBeforeUpdate():i.onBeforeMount&&i.onBeforeMount();const p=()=>{const t=e.parse(a(i),i);this.renderer.patchDOM(n,t),this._processEvents(n,i,f),this._injectStyles(n,s,c,i),this._mountChildren(n,l,u),this._isMounted?i.onUpdate&&i.onUpdate():(i.onMount&&i.onMount(),this._isMounted=!0)};for(const e of Object.values(o))e instanceof t&&r.push(e.watch(p));return p(),{container:n,data:i,unmount:()=>{for(const e of r)e();for(const e of f)e();for(const e of u)e.unmount();i.onUnmount&&i.onUnmount(),n.innerHTML=""}}}))}_prepareLifecycleHooks(){const e={};for(const t of this._lifecycleHooks)e[t]=()=>{};return e}_processEvents(t,n,s){const o=t.querySelectorAll("*");for(const t of o){const o=t.attributes;for(let i=0;i<o.length;i++){const r=o[i];if(r.name.startsWith("@")){const o=r.name.slice(1),i=e.evaluate(r.value,n);"function"==typeof i&&(t.addEventListener(o,i),t.removeAttribute(r.name),s.push((()=>t.removeEventListener(o,i))))}}}}_injectStyles(t,n,s,o){if(!s)return;let i=t.querySelector(`style[data-eleva-style="${n}"]`);i||(i=document.createElement("style"),i.setAttribute("data-eleva-style",n),t.appendChild(i)),i.textContent=e.parse(s(o),o)}async _mountChildren(e,t,n){for(const e of n)e.unmount();if(n.length=0,t)for(const s of Object.keys(t))if(s)for(const o of e.querySelectorAll(s)){if(!(o instanceof HTMLElement))continue;const e={};for(const{name:t,value:n}of[...o.attributes])t.startsWith("eleva-prop-")&&(e[t.replace("eleva-prop-","")]=n);const i=await this.mount(o,t[s],e);n.push(i)}}}}));
|
|
2
3
|
//# sourceMappingURL=eleva.min.js.map
|
package/dist/eleva.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eleva.min.js","sources":["../src/modules/TemplateEngine.js","../src/modules/Signal.js","../src/modules/Emitter.js","../src/modules/Renderer.js","../src/core/Eleva.js"],"sourcesContent":["\"use strict\";\n\n/**\n * @class 🔒 TemplateEngine\n * @classdesc Secure interpolation & dynamic attribute parsing.\n * Provides methods to parse template strings by replacing interpolation expressions\n * with dynamic data values and to evaluate expressions within a given data context.\n */\nexport class TemplateEngine {\n /**\n * Parses a template string and replaces interpolation expressions with corresponding values.\n *\n * @param {string} template - The template string containing expressions in the format `{{ expression }}`.\n * @param {Object<string, any>} data - The data object to use for evaluating expressions.\n * @returns {string} The resulting string with evaluated values.\n */\n static parse(template, data) {\n if (!template || typeof template !== \"string\") return template;\n\n return template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, expr) => {\n return this.evaluate(expr, data);\n });\n }\n\n /**\n * Evaluates a JavaScript expression using the provided data context.\n *\n * @param {string} expr - The JavaScript expression to evaluate.\n * @param {Object<string, any>} data - The data context for evaluating the expression.\n * @returns {any} The result of the evaluated expression, or an empty string if undefined or on error.\n */\n static evaluate(expr, data) {\n if (!expr || typeof expr !== \"string\") return expr;\n\n try {\n const compiledFn = new Function(\"data\", `with(data) { return ${expr} }`);\n return compiledFn(data);\n } catch (error) {\n console.error(`Template evaluation error:`, {\n expression: expr,\n data,\n error: error.message,\n });\n return \"\";\n }\n }\n}\n","\"use strict\";\n\n/**\n * @class ⚡ Signal\n * @classdesc Fine-grained reactivity.\n * A reactive data holder that notifies registered watchers when its value changes,\n * enabling fine-grained DOM patching rather than full re-renders.\n */\nexport class Signal {\n /**\n * Creates a new Signal instance.\n *\n * @param {*} value - The initial value of the signal.\n */\n constructor(value) {\n /** @private {*} Internal storage for the signal's current value */\n this._value = value;\n /** @private {Set<function>} Collection of callback functions to be notified when value changes */\n this._watchers = new Set();\n /** @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 * @returns {*} The current value.\n */\n get value() {\n return this._value;\n }\n\n /**\n * Sets a new value for the signal and notifies all registered watchers if the value has changed.\n *\n * @param {*} newVal - The new value to set.\n */\n set value(newVal) {\n if (newVal !== this._value) {\n this._value = newVal;\n this._notifyWatchers();\n }\n }\n\n /**\n * Registers a watcher function that will be called whenever the signal's value changes.\n *\n * @param {function(any): void} fn - The callback function to invoke on value change.\n * @returns {function(): boolean} A function to unsubscribe the watcher.\n */\n watch(fn) {\n this._watchers.add(fn);\n return () => this._watchers.delete(fn);\n }\n\n /**\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 Robust inter-component communication with event bubbling.\n * Implements a basic publish-subscribe pattern for event handling, allowing components\n * to communicate through custom events.\n */\nexport class Emitter {\n /**\n * Creates a new Emitter instance.\n */\n constructor() {\n /** @type {Object.<string, Function[]>} Storage for event handlers mapped by event name */\n this.events = {};\n }\n\n /**\n * Registers an event handler for the specified event.\n *\n * @param {string} event - The name of the event.\n * @param {function(...any): void} handler - The function to call when the event is emitted.\n */\n on(event, handler) {\n (this.events[event] || (this.events[event] = [])).push(handler);\n }\n\n /**\n * Removes a previously registered event handler.\n *\n * @param {string} event - The name of the event.\n * @param {function(...any): void} handler - The handler function to remove.\n */\n off(event, handler) {\n if (this.events[event]) {\n this.events[event] = this.events[event].filter((h) => h !== handler);\n }\n }\n\n /**\n * Emits an event, invoking all handlers registered for that event.\n *\n * @param {string} event - The event name.\n * @param {...any} args - Additional arguments to pass to the event handlers.\n */\n emit(event, ...args) {\n (this.events[event] || []).forEach((handler) => handler(...args));\n }\n}\n","\"use strict\";\n\n/**\n * @class 🎨 Renderer\n * @classdesc Handles DOM patching, diffing, and attribute updates.\n * Provides methods for efficient DOM updates by diffing the new and old DOM structures\n * and applying only the necessary changes.\n */\nexport class Renderer {\n /**\n * Patches the DOM of a container element with new HTML content.\n *\n * @param {HTMLElement} container - The container element to patch.\n * @param {string} newHtml - The new HTML content to apply.\n * @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 *\n * @param {HTMLElement} oldParent - The original DOM element.\n * @param {HTMLElement} newParent - The new DOM element.\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 *\n * @param {HTMLElement} oldEl - The element to update.\n * @param {HTMLElement} newEl - The element providing the updated attributes.\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 * Defines the structure and behavior of a component.\n * @typedef {Object} ComponentDefinition\n * @property {function(Object<string, any>): (Object<string, any>|Promise<Object<string, any>>)} [setup]\n * Optional setup function that initializes the component's reactive state and lifecycle.\n * Receives props and context as an argument and should return an object containing the component's state.\n * Can return either a synchronous object or a Promise that resolves to an object for async initialization.\n *\n * @property {function(Object<string, any>): string} template\n * Required function that defines the component's HTML structure.\n * Receives the merged context (props + setup data) and must return an HTML template string.\n * Supports dynamic expressions using {{ }} syntax for reactive data binding.\n *\n * @property {function(Object<string, any>): string} [style]\n * Optional function that defines component-scoped CSS styles.\n * Receives the merged context and returns a CSS string that will be automatically scoped to the component.\n * Styles are injected into the component's container and only affect elements within it.\n *\n * @property {Object<string, ComponentDefinition>} [children]\n * Optional object that defines nested child components.\n * Keys are CSS selectors that match elements in the template where child components should be mounted.\n * Values are ComponentDefinition objects that define the structure and behavior of each child component.\n */\n\n/**\n * @class 🧩 Eleva\n * @classdesc Signal-based component runtime framework with lifecycle hooks, scoped styles, and plugin support.\n * Manages component registration, plugin integration, event handling, and DOM rendering.\n */\nexport class Eleva {\n /**\n * Creates a new Eleva instance.\n *\n * @param {string} name - The name of the Eleva instance.\n * @param {Object<string, any>} [config={}] - Optional configuration for the instance.\n */\n constructor(name, config = {}) {\n /** @type {string} The unique identifier name for this Eleva instance */\n this.name = name;\n /** @type {Object<string, any>} Optional configuration object for the Eleva instance */\n this.config = config;\n /** @type {Object<string, ComponentDefinition>} Object storing registered component definitions by name */\n this._components = {};\n /** @private {Array<Object>} Collection of installed plugin instances */\n this._plugins = [];\n /** @private {string[]} Array of lifecycle hook names supported by the component */\n this._lifecycleHooks = [\n \"onBeforeMount\",\n \"onMount\",\n \"onBeforeUpdate\",\n \"onUpdate\",\n \"onUnmount\",\n ];\n /** @private {boolean} Flag indicating if component is currently mounted */\n this._isMounted = false;\n /** @private {Emitter} Instance of the event emitter for handling component events */\n this.emitter = new Emitter();\n /** @private {Signal} Instance of the signal for handling plugin and component signals */\n this.signal = Signal;\n /** @private {Renderer} Instance of the renderer for handling DOM updates and patching */\n this.renderer = new Renderer();\n }\n\n /**\n * Integrates a plugin with the Eleva framework.\n *\n * @param {Object} plugin - The plugin object which should have an `install` function.\n * @param {Object<string, any>} [options={}] - Optional options to pass to the plugin.\n * @returns {Eleva} The Eleva instance (for chaining).\n */\n use(plugin, options = {}) {\n if (typeof plugin.install === \"function\") {\n plugin.install(this, options);\n }\n this._plugins.push(plugin);\n return this;\n }\n\n /**\n * Registers a component with the Eleva instance.\n *\n * @param {string} name - The name of the component.\n * @param {ComponentDefinition} definition - The component definition including setup, template, style, and children.\n * @returns {Eleva} The Eleva instance (for chaining).\n */\n component(name, definition) {\n this._components[name] = definition;\n return this;\n }\n\n /**\n * Mounts a registered component to a DOM element.\n *\n * @param {HTMLElement} container - A DOM element where the component will be mounted.\n * @param {string|ComponentDefinition} compName - The name of the component to mount or a component definition.\n * @param {Object<string, any>} [props={}] - Optional properties to pass to the component.\n * @returns {object|Promise<object>} An object representing the mounted component instance, or a Promise that resolves to it for asynchronous setups.\n * @throws {Error} If the container is not found or if the component is not registered.\n */\n mount(container, compName, props = {}) {\n if (!container) throw new Error(`Container not found: ${container}`);\n\n const definition =\n typeof compName === \"string\" ? this._components[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 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 {object} An object with the container, merged context data, and an unmount function.\n */\n const processMount = (data) => {\n const mergedContext = { ...context, ...data };\n const watcherUnsubscribers = [];\n const childInstances = [];\n 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 Object.values(data).forEach((val) => {\n if (val instanceof Signal) watcherUnsubscribers.push(val.watch(render));\n });\n\n render();\n\n return {\n container,\n data: mergedContext,\n /**\n * Unmounts the component, cleaning up watchers and listeners, child components, and clearing the container.\n *\n * @returns {void}\n */\n unmount: () => {\n watcherUnsubscribers.forEach((fn) => fn());\n cleanupListeners.forEach((fn) => fn());\n childInstances.forEach((child) => child.unmount());\n mergedContext.onUnmount && mergedContext.onUnmount();\n container.innerHTML = \"\";\n },\n };\n };\n\n // Handle asynchronous setup.\n return Promise.resolve(\n typeof setup === \"function\" ? setup(context) : {}\n ).then(processMount);\n }\n\n /**\n * Prepares default no-operation lifecycle hook functions.\n *\n * @returns {Object<string, function(): void>} An object with keys for lifecycle hooks mapped to empty functions.\n * @private\n */\n _prepareLifecycleHooks() {\n return this._lifecycleHooks.reduce((acc, hook) => {\n acc[hook] = () => {};\n return acc;\n }, {});\n }\n\n /**\n * Processes DOM elements for event binding based on attributes starting with \"@\".\n * Tracks listeners for cleanup during unmount.\n *\n * @param {HTMLElement} container - The container element in which to search for events.\n * @param {Object<string, any>} context - The current context containing event handler definitions.\n * @param {Array<Function>} cleanupListeners - Array to collect cleanup functions for each event listener.\n * @private\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 *\n * @param {HTMLElement} container - The container element.\n * @param {string} compName - The component name used to identify the style element.\n * @param {function(Object<string, any>): string} [styleFn] - A function that returns CSS styles as a string.\n * @param {Object<string, any>} context - The current context for style interpolation.\n * @private\n */\n _injectStyles(container, compName, styleFn, context) {\n if (!styleFn) 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 *\n * @param {HTMLElement} container - The parent container element.\n * @param {Object<string, ComponentDefinition>} [children] - An object mapping child component selectors to their definitions.\n * @param {Array<object>} childInstances - An array to store the mounted child component instances.\n * @private\n */\n _mountChildren(container, children, childInstances) {\n childInstances.forEach((child) => child.unmount());\n childInstances.length = 0;\n\n Object.keys(children || {}).forEach((childSelector) => {\n container.querySelectorAll(childSelector).forEach((childEl) => {\n const props = {};\n [...childEl.attributes].forEach(({ name, value }) => {\n if (name.startsWith(\"eleva-prop-\")) {\n props[name.replace(\"eleva-prop-\", \"\")] = value;\n }\n });\n const instance = this.mount(childEl, children[childSelector], props);\n childInstances.push(instance);\n });\n });\n }\n}\n"],"names":["TemplateEngine","parse","template","data","replace","_","expr","this","evaluate","Function","compiledFn","error","console","expression","message","Signal","constructor","value","_value","_watchers","Set","_pending","newVal","_notifyWatchers","watch","fn","add","delete","queueMicrotask","forEach","Emitter","events","on","event","handler","push","off","filter","h","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","appendChild","cloneNode","removeChild","nodeType","nodeName","Node","ELEMENT_NODE","oldKey","getAttribute","newKey","replaceChild","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","get","call","config","_components","_plugins","_lifecycleHooks","_isMounted","emitter","signal","renderer","use","plugin","options","install","component","definition","mount","compName","props","setup","style","children","context","v","_prepareLifecycleHooks","Promise","resolve","then","mergedContext","watcherUnsubscribers","childInstances","cleanupListeners","onBeforeUpdate","onBeforeMount","render","_processEvents","_injectStyles","_mountChildren","onUpdate","onMount","values","val","unmount","child","onUnmount","reduce","acc","hook","elements","querySelectorAll","el","attrs","addEventListener","removeEventListener","styleFn","styleEl","querySelector","textContent","keys","childSelector","childEl","instance"],"mappings":"sOAQO,MAAMA,EAQX,YAAOC,CAAMC,EAAUC,GACrB,OAAKD,GAAgC,iBAAbA,EAEjBA,EAASE,QAAQ,wBAAwB,CAACC,EAAGC,IAC3CC,KAAKC,SAASF,EAAMH,KAHyBD,CAKxD,CASA,eAAOM,CAASF,EAAMH,GACpB,IAAKG,GAAwB,iBAATA,EAAmB,OAAOA,EAE9C,IAEE,OADuBG,SAAS,OAAQ,uBAAuBH,MACxDI,CAAWP,EACnB,CAAC,MAAOQ,GAMP,OALAC,QAAQD,MAAM,6BAA8B,CAC1CE,WAAYP,EACZH,OACAQ,MAAOA,EAAMG,UAER,EACT,CACF,ECrCK,MAAMC,EAMXC,WAAAA,CAAYC,GAEVV,KAAKW,EAASD,EAEdV,KAAKY,EAAY,IAAIC,IAErBb,KAAKc,GAAW,CAClB,CAOA,SAAIJ,GACF,OAAOV,K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iBAAiBU,GAAepI,SAASqI,IACjD,MAAM1C,EAAQ,CAAE,EAChB,IAAI0C,EAAQ9E,YAAYvD,SAAQ,EAAGyD,OAAMrE,YACnCqE,EAAKC,WAAW,iBAClBiC,EAAMlC,EAAKlF,QAAQ,cAAe,KAAOa,EAC3C,IAEF,MAAMkJ,EAAW5J,KAAK+G,MAAM4C,EAASvC,EAASsC,GAAgBzC,GAC9DY,EAAejG,KAAKgI,EAAS,GAC7B,GAEN"}
|
|
1
|
+
{"version":3,"file":"eleva.min.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","static","parse","template","data","replace","this","expressionPattern","_","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","nodeType","nodeName","Node","ELEMENT_NODE","oldKey","getAttribute","newKey","replaceChild","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","config","emitter","signal","renderer","_components","_plugins","_lifecycleHooks","_isMounted","use","plugin","options","install","component","definition","mount","compName","props","setup","style","children","context","v","_prepareLifecycleHooks","Promise","resolve","then","mergedContext","watcherUnsubscribers","childInstances","cleanupListeners","onBeforeUpdate","onBeforeMount","render","_processEvents","_injectStyles","_mountChildren","onUpdate","onMount","val","values","unmount","child","onUnmount","hooks","hook","elements","querySelectorAll","el","attrs","addEventListener","removeEventListener","styleFn","styleEl","querySelector","textContent","childSelector","keys","childEl","instance"],"mappings":";sOAaO,MAAMA,EAIXC,yBAA2B,uBAgB3B,YAAOC,CAAMC,EAAUC,GACrB,MAAwB,iBAAbD,EAA8BA,EAClCA,EAASE,QAAQC,KAAKC,mBAAmB,CAACC,EAAGC,IAClDH,KAAKI,SAASD,EAAYL,IAE9B,CAeA,eAAOM,CAASD,EAAYL,GAC1B,GAA0B,iBAAfK,EAAyB,OAAOA,EAC3C,IACE,OAAO,IAAIE,SAAS,OAAQ,uBAAuBF,OAA5C,CAA6DL,EACtE,CAAE,MACA,MAAO,EACT,CACF,EC/CK,MAAMQ,EAOXC,WAAAA,CAAYC,GAEVR,KAAKS,OAASD,EAEdR,KAAKU,UAAY,IAAIC,IAErBX,KAAKY,UAAW,CAClB,CAQA,SAAIJ,GACF,OAAOR,KAAKS,MACd,CAUA,SAAID,CAAMK,GACJA,IAAWb,KAAKS,SAClBT,KAAKS,OAASI,EACdb,KAAKc,kBAET,CAcAC,KAAAA,CAAMC,GAEJ,OADAhB,KAAKU,UAAUO,IAAID,GACZ,IAAMhB,KAAKU,UAAUQ,OAAOF,EACrC,CAUAF,eAAAA,GACOd,KAAKY,WACRZ,KAAKY,UAAW,EAChBO,gBAAe,KACbnB,KAAKY,UAAW,EAChBZ,KAAKU,UAAUU,SAASJ,GAAOA,EAAGhB,KAAK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