eleva 1.2.6-alpha → 1.2.7-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.d.ts +2 -0
- package/dist/eleva.esm.js +3 -1
- package/dist/eleva.esm.js.map +1 -1
- package/dist/eleva.min.js +1 -1
- package/dist/eleva.min.js.map +1 -1
- package/dist/eleva.umd.js +3 -1
- package/dist/eleva.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/core/Eleva.js +3 -1
- package/types/core/Eleva.d.ts +2 -0
- package/types/core/Eleva.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -29,10 +29,10 @@ Pure JavaScript, Pure Performance, Simply Elegant.
|
|
|
29
29
|
**A minimalist, lightweight, pure vanilla JavaScript frontend runtime framework.**
|
|
30
30
|
_Built with love for native JavaScript—because sometimes, less really is more!_ 😊
|
|
31
31
|
|
|
32
|
-
> **Stability Notice**: This is `v1.2.
|
|
32
|
+
> **Stability Notice**: This is `v1.2.7-alpha` - The core functionality is stable, but I'm seeking community feedback before the final v1.0.0 release.
|
|
33
33
|
> While suitable for production use, please be aware of the [known limitations](docs/known-limitations.md).
|
|
34
34
|
|
|
35
|
-
**Version:** `1.2.
|
|
35
|
+
**Version:** `1.2.7-alpha`
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
|
package/dist/eleva.d.ts
CHANGED
|
@@ -54,6 +54,8 @@ declare class Eleva {
|
|
|
54
54
|
private _isMounted;
|
|
55
55
|
/** @private {Emitter} Instance of the event emitter for handling component events */
|
|
56
56
|
private emitter;
|
|
57
|
+
/** @private {Signal} Instance of the signal for handling plugin and component signals */
|
|
58
|
+
private signal;
|
|
57
59
|
/** @private {Renderer} Instance of the renderer for handling DOM updates and patching */
|
|
58
60
|
private renderer;
|
|
59
61
|
/**
|
package/dist/eleva.esm.js
CHANGED
|
@@ -349,6 +349,8 @@ class Eleva {
|
|
|
349
349
|
this._isMounted = false;
|
|
350
350
|
/** @private {Emitter} Instance of the event emitter for handling component events */
|
|
351
351
|
this.emitter = new Emitter();
|
|
352
|
+
/** @private {Signal} Instance of the signal for handling plugin and component signals */
|
|
353
|
+
this.signal = Signal;
|
|
352
354
|
/** @private {Renderer} Instance of the renderer for handling DOM updates and patching */
|
|
353
355
|
this.renderer = new Renderer();
|
|
354
356
|
}
|
|
@@ -421,7 +423,7 @@ class Eleva {
|
|
|
421
423
|
const context = {
|
|
422
424
|
props,
|
|
423
425
|
emitter: this.emitter,
|
|
424
|
-
signal: v => new
|
|
426
|
+
signal: v => new this.signal(v),
|
|
425
427
|
...this._prepareLifecycleHooks()
|
|
426
428
|
};
|
|
427
429
|
|
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 {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 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","renderer","use","plugin","options","install","component","definition","mount","compName","props","setup","style","children","context","signal","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,CAAC,EAAEC,IAAI,KAAK;AAC3D,MAAA,OAAO,IAAI,CAACC,QAAQ,CAACD,IAAI,EAAEH,IAAI,CAAC;AAClC,KAAC,CAAC;AACJ;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACE,EAAA,OAAOI,QAAQA,CAACD,IAAI,EAAEH,IAAI,EAAE;IAC1B,IAAI,CAACG,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE,OAAOA,IAAI;IAElD,IAAI;MACF,MAAME,UAAU,GAAG,IAAIC,QAAQ,CAAC,MAAM,EAAE,CAAA,oBAAA,EAAuBH,IAAI,CAAA,EAAA,CAAI,C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c,CAACC,KAAK,CAAC6J,OAAO,CAAClC,OAAO,CAAC,EAAEA,OAAO,CAAC;AACvE;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACEc,EAAAA,cAAcA,CAAChG,SAAS,EAAEiF,QAAQ,EAAEQ,cAAc,EAAE;IAClDA,cAAc,CAACvG,OAAO,CAAEoH,KAAK,IAAKA,KAAK,CAACD,OAAO,EAAE,CAAC;IAClDZ,cAAc,CAACvE,MAAM,GAAG,CAAC;AAEzBsC,IAAAA,MAAM,CAACgE,IAAI,CAACvC,QAAQ,IAAI,EAAE,CAAC,CAAC/F,OAAO,CAAEuI,aAAa,IAAK;MACrDzH,SAAS,CAAC+G,gBAAgB,CAACU,aAAa,CAAC,CAACvI,OAAO,CAAEwI,OAAO,IAAK;QAC7D,MAAM5C,KAAK,GAAG,EAAE;QAChB,CAAC,GAAG4C,OAAO,CAAChF,UAAU,CAAC,CAACxD,OAAO,CAAC,CAAC;UAAE0D,IAAI;AAAEtE,UAAAA;AAAM,SAAC,KAAK;AACnD,UAAA,IAAIsE,IAAI,CAACC,UAAU,CAAC,aAAa,CAAC,EAAE;YAClCiC,KAAK,CAAClC,IAAI,CAAClF,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,GAAGY,KAAK;AAChD;AACF,SAAC,CAAC;AACF,QAAA,MAAMqJ,QAAQ,GAAG,IAAI,CAAC/C,KAAK,CAAC8C,OAAO,EAAEzC,QAAQ,CAACwC,aAAa,CAAC,EAAE3C,KAAK,CAAC;AACpEW,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 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;A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,CAACxD,OAAO,CAAC,CAAC;UAAE0D,IAAI;AAAEtE,UAAAA;AAAM,SAAC,KAAK;AACnD,UAAA,IAAIsE,IAAI,CAACC,UAAU,CAAC,aAAa,CAAC,EAAE;YAClCkC,KAAK,CAACnC,IAAI,CAAClF,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,GAAGY,KAAK;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;;;;"}
|
package/dist/eleva.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Eleva=e()}(this,(function(){"use strict";class t{static parse(t,e){return t&&"string"==typeof t?t.replace(/\{\{\s*(.*?)\s*\}\}/g,((t,n)=>this.evaluate(n,e))):t}static evaluate(t,e){if(!t||"string"!=typeof t)return t;try{return Function("data",`with(data) { return ${t} }`)(e)}catch(n){return console.error("Template evaluation error:",{expression:t,data:e,error:n.message}),""}}}class e{constructor(t){this.t=t,this.o=new Set,this.i=!1}get value(){return this.t}set value(t){t!==this.t&&(this.t=t,this.h())}watch(t){return this.o.add(t),()=>this.o.delete(t)}h(){this.i||(this.i=!0,queueMicrotask((()=>{this.i=!1,this.o.forEach((t=>t(this.t)))})))}}class n{constructor(){this.events={}}on(t,e){(this.events[t]||(this.events[t]=[])).push(e)}off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter((t=>t!==e)))}emit(t,...e){(this.events[t]||[]).forEach((t=>t(...e)))}}class s{patchDOM(t,e){if(!(t instanceof HTMLElement))throw Error("Container must be an HTMLElement");if("string"!=typeof e)throw Error("newHtml must be a string");const n=document.createElement("div");n.innerHTML=e,this.diff(t,n),n.innerHTML=""}diff(t,e){if(!(t instanceof HTMLElement&&e instanceof HTMLElement))throw Error("Both parents must be HTMLElements");if(t.isEqualNode(e))return;const n=t.childNodes,s=e.childNodes,o=Math.max(n.length,s.length),i=[];for(let e=0;o>e;e++){const o=n[e],r=s[e];if(!o&&r){i.push((()=>t.appendChild(r.cloneNode(!0))));continue}if(o&&!r){i.push((()=>t.removeChild(o)));continue}if(o.nodeType===r.nodeType&&o.nodeName===r.nodeName)if(o.nodeType===Node.ELEMENT_NODE){const e=o.getAttribute("key"),n=r.getAttribute("key");if(e!==n&&(e||n)){i.push((()=>t.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((()=>t.replaceChild(r.cloneNode(!0),o)))}i.length&&i.forEach((t=>t()))}updateAttributes(t,e){if(!(t instanceof HTMLElement&&e instanceof HTMLElement))throw Error("Both elements must be HTMLElements");const n=t.attributes,s=e.attributes,o=[];for(const{name:s}of n)s.startsWith("@")||e.hasAttribute(s)||o.push((()=>t.removeAttribute(s)));for(const e of s){const{name:n,value:s}=e;n.startsWith("@")||t.getAttribute(n)!==s&&o.push((()=>{if(t.setAttribute(n,s),n.startsWith("aria-")){const e="aria"+n.slice(5).replace(/-([a-z])/g,((t,e)=>e.toUpperCase()));t[e]=s}else if(n.startsWith("data-"))t.dataset[n.slice(5)]=s;else{const e=n.replace(/-([a-z])/g,((t,e)=>e.toUpperCase()));if(e in t){const n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(t),e),o="boolean"==typeof t[e]||n?.get&&"boolean"==typeof n.get.call(t);t[e]=o?"false"!==s&&(""===s||s===e||"true"===s):s}}}))}o.length&&o.forEach((t=>t()))}}return class{constructor(t,
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Eleva=e()}(this,(function(){"use strict";class t{static parse(t,e){return t&&"string"==typeof t?t.replace(/\{\{\s*(.*?)\s*\}\}/g,((t,n)=>this.evaluate(n,e))):t}static evaluate(t,e){if(!t||"string"!=typeof t)return t;try{return Function("data",`with(data) { return ${t} }`)(e)}catch(n){return console.error("Template evaluation error:",{expression:t,data:e,error:n.message}),""}}}class e{constructor(t){this.t=t,this.o=new Set,this.i=!1}get value(){return this.t}set value(t){t!==this.t&&(this.t=t,this.h())}watch(t){return this.o.add(t),()=>this.o.delete(t)}h(){this.i||(this.i=!0,queueMicrotask((()=>{this.i=!1,this.o.forEach((t=>t(this.t)))})))}}class n{constructor(){this.events={}}on(t,e){(this.events[t]||(this.events[t]=[])).push(e)}off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter((t=>t!==e)))}emit(t,...e){(this.events[t]||[]).forEach((t=>t(...e)))}}class s{patchDOM(t,e){if(!(t instanceof HTMLElement))throw Error("Container must be an HTMLElement");if("string"!=typeof e)throw Error("newHtml must be a string");const n=document.createElement("div");n.innerHTML=e,this.diff(t,n),n.innerHTML=""}diff(t,e){if(!(t instanceof HTMLElement&&e instanceof HTMLElement))throw Error("Both parents must be HTMLElements");if(t.isEqualNode(e))return;const n=t.childNodes,s=e.childNodes,o=Math.max(n.length,s.length),i=[];for(let e=0;o>e;e++){const o=n[e],r=s[e];if(!o&&r){i.push((()=>t.appendChild(r.cloneNode(!0))));continue}if(o&&!r){i.push((()=>t.removeChild(o)));continue}if(o.nodeType===r.nodeType&&o.nodeName===r.nodeName)if(o.nodeType===Node.ELEMENT_NODE){const e=o.getAttribute("key"),n=r.getAttribute("key");if(e!==n&&(e||n)){i.push((()=>t.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((()=>t.replaceChild(r.cloneNode(!0),o)))}i.length&&i.forEach((t=>t()))}updateAttributes(t,e){if(!(t instanceof HTMLElement&&e instanceof HTMLElement))throw Error("Both elements must be HTMLElements");const n=t.attributes,s=e.attributes,o=[];for(const{name:s}of n)s.startsWith("@")||e.hasAttribute(s)||o.push((()=>t.removeAttribute(s)));for(const e of s){const{name:n,value:s}=e;n.startsWith("@")||t.getAttribute(n)!==s&&o.push((()=>{if(t.setAttribute(n,s),n.startsWith("aria-")){const e="aria"+n.slice(5).replace(/-([a-z])/g,((t,e)=>e.toUpperCase()));t[e]=s}else if(n.startsWith("data-"))t.dataset[n.slice(5)]=s;else{const e=n.replace(/-([a-z])/g,((t,e)=>e.toUpperCase()));if(e in t){const n=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(t),e),o="boolean"==typeof t[e]||n?.get&&"boolean"==typeof n.get.call(t);t[e]=o?"false"!==s&&(""===s||s===e||"true"===s):s}}}))}o.length&&o.forEach((t=>t()))}}return class{constructor(t,o={}){this.name=t,this.config=o,this.u={},this.l=[],this.p=["onBeforeMount","onMount","onBeforeUpdate","onUpdate","onUnmount"],this.m=!1,this.emitter=new n,this.signal=e,this.renderer=new s}use(t,e={}){return"function"==typeof t.install&&t.install(this,e),this.l.push(t),this}component(t,e){return this.u[t]=e,this}mount(n,s,o={}){if(!n)throw Error("Container not found: "+n);const i="string"==typeof s?this.u[s]:s;if(!i)throw Error(`Component "${s}" not registered.`);if("function"!=typeof i.template)throw Error("Component template must be a function");const{setup:r,template:c,style:a,children:h}=i,f={props:o,emitter:this.emitter,signal:t=>new this.signal(t),...this.M()};return Promise.resolve("function"==typeof r?r(f):{}).then((o=>{const i={...f,...o},r=[],u=[],l=[];this.m?i.onBeforeUpdate&&i.onBeforeUpdate():i.onBeforeMount&&i.onBeforeMount();const p=()=>{const e=t.parse(c(i),i);this.renderer.patchDOM(n,e),this.v(n,i,l),this.T(n,s,a,i),this.H(n,h,u),this.m?i.onUpdate&&i.onUpdate():(i.onMount&&i.onMount(),this.m=!0)};return Object.values(o).forEach((t=>{t instanceof e&&r.push(t.watch(p))})),p(),{container:n,data:i,unmount:()=>{r.forEach((t=>t())),l.forEach((t=>t())),u.forEach((t=>t.unmount())),i.onUnmount&&i.onUnmount(),n.innerHTML=""}}}))}M(){return this.p.reduce(((t,e)=>(t[e]=()=>{},t)),{})}v(e,n,s){const o=e.querySelectorAll("*");for(const e of o){const o=e.attributes;for(let i=0;o.length>i;i++){const r=o[i];if(r.name.startsWith("@")){const o=r.name.slice(1),i=t.evaluate(r.value,n);"function"==typeof i&&(e.addEventListener(o,i),e.removeAttribute(r.name),s.push((()=>e.removeEventListener(o,i))))}}}}T(e,n,s,o){if(!s)return;let i=e.querySelector(`style[data-eleva-style="${n}"]`);i||(i=document.createElement("style"),i.setAttribute("data-eleva-style",n),e.appendChild(i)),i.textContent=t.parse(s(o),o)}H(t,e,n){n.forEach((t=>t.unmount())),n.length=0,Object.keys(e||{}).forEach((s=>{t.querySelectorAll(s).forEach((t=>{const o={};[...t.attributes].forEach((({name:t,value:e})=>{t.startsWith("eleva-prop-")&&(o[t.replace("eleva-prop-","")]=e)}));const i=this.mount(t,e[s],o);n.push(i)}))}))}}}));
|
|
2
2
|
//# 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 {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 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","renderer","use","plugin","options","install","component","definition","mount","compName","props","setup","style","children","context","signal","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,MAA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EAC/D,CAUAgB,CAAAA,CAAehG,EAAW+E,EAAUU,GAClCA,EAAevG,SAASoH,GAAUA,EAAMD,YACxCZ,EAAevE,OAAS,EAExBqC,OAAO8D,KAAKtC,GAAY,CAAE,GAAE7F,SAASoI,IACnCtH,EAAU4G,iBAAiBU,GAAepI,SAASqI,IACjD,MAAM3C,EAAQ,CAAE,EAChB,IAAI2C,EAAQ9E,YAAYvD,SAAQ,EAAGyD,OAAMrE,YACnCqE,EAAKC,WAAW,iBAClBgC,EAAMjC,EAAKlF,QAAQ,cAAe,KAAOa,EAC3C,IAEF,MAAMkJ,EAAW5J,KAAK8G,MAAM6C,EAASxC,EAASuC,GAAgB1C,GAC9Da,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 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,KAAKW,CACd,CAOA,SAAID,CAAMK,GACJA,IAAWf,KAAKW,IAClBX,KAAKW,EAASI,EACdf,KAAKgB,IAET,CAQAC,KAAAA,CAAMC,GAEJ,OADAlB,KAAK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BAClBiC,EAAMlC,EAAKlF,QAAQ,cAAe,KAAOa,EAC3C,IAEF,MAAMkJ,EAAW5J,KAAK+G,MAAM4C,EAASvC,EAASsC,GAAgBzC,GAC9DY,EAAejG,KAAKgI,EAAS,GAC7B,GAEN"}
|
package/dist/eleva.umd.js
CHANGED
|
@@ -355,6 +355,8 @@
|
|
|
355
355
|
this._isMounted = false;
|
|
356
356
|
/** @private {Emitter} Instance of the event emitter for handling component events */
|
|
357
357
|
this.emitter = new Emitter();
|
|
358
|
+
/** @private {Signal} Instance of the signal for handling plugin and component signals */
|
|
359
|
+
this.signal = Signal;
|
|
358
360
|
/** @private {Renderer} Instance of the renderer for handling DOM updates and patching */
|
|
359
361
|
this.renderer = new Renderer();
|
|
360
362
|
}
|
|
@@ -427,7 +429,7 @@
|
|
|
427
429
|
const context = {
|
|
428
430
|
props,
|
|
429
431
|
emitter: this.emitter,
|
|
430
|
-
signal: v => new
|
|
432
|
+
signal: v => new this.signal(v),
|
|
431
433
|
...this._prepareLifecycleHooks()
|
|
432
434
|
};
|
|
433
435
|
|
package/dist/eleva.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eleva.umd.js","sources":["../src/modules/TemplateEngine.js","../src/modules/Signal.js","../src/modules/Emitter.js","../src/modules/Renderer.js","../src/core/Eleva.js"],"sourcesContent":["\"use strict\";\n\n/**\n * @class 🔒 TemplateEngine\n * @classdesc 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 {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 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","renderer","use","plugin","options","install","component","definition","mount","compName","props","setup","style","children","context","signal","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":";;;;;;EAEA;EACA;EACA;EACA;EACA;EACA;EACO,MAAMA,cAAc,CAAC;EAC1B;EACF;EACA;EACA;EACA;EACA;EACA;EACE,EAAA,OAAOC,KAAKA,CAACC,QAAQ,EAAEC,IAAI,EAAE;MAC3B,IAAI,CAACD,QAAQ,IAAI,OAAOA,QAAQ,KAAK,QAAQ,EAAE,OAAOA,QAAQ;MAE9D,OAAOA,QAAQ,CAACE,OAAO,CAAC,sBAAsB,EAAE,CAACC,CAAC,EAAEC,IAAI,KAAK;EAC3D,MAAA,OAAO,IAAI,CAACC,QAAQ,CAACD,IAAI,EAAEH,IAAI,CAAC;EAClC,KAAC,CAAC;EACJ;;EAEA;EACF;EACA;EACA;EACA;EACA;EACA;EACE,E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AAC;EAC/B,OAAC,CAAC;EACJ,KAAC,CAAC;EACJ;EACF;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"eleva.umd.js","sources":["../src/modules/TemplateEngine.js","../src/modules/Signal.js","../src/modules/Emitter.js","../src/modules/Renderer.js","../src/core/Eleva.js"],"sourcesContent":["\"use strict\";\n\n/**\n * @class 🔒 TemplateEngine\n * @classdesc 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":";;;;;;EAEA;EACA;EACA;EACA;EACA;EACA;EACO,MAAMA,cAAc,CAAC;EAC1B;EACF;EACA;EACA;EACA;EACA;EACA;EACE,EAAA,OAAOC,KAAKA,CAACC,QAAQ,EAAEC,IAAI,EAAE;MAC3B,IAAI,CAACD,QAAQ,IAAI,OAAOA,QAAQ,KAAK,QAAQ,EAAE,OAAOA,QAAQ;MAE9D,OAAOA,QAAQ,CAACE,OAAO,CAAC,sBAAsB,EAAE,CAACC,CAAC,EAAEC,IAAI,KAAK;EAC3D,MAAA,OAAO,IAAI,CAACC,QAAQ,CAACD,IAAI,EAAEH,IAAI,CAAC;EAClC,KAAC,CAAC;EACJ;;EAEA;EACF;EACA;EACA;EACA;EACA;EACA;EACE,EAAA,OAAOI,QAAQA,CAACD,IAAI,EAAEH,IAAI,EAAE;MAC1B,IAAI,CAACG,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE,OAAOA,IAAI;MAElD,IAAI;QACF,MAAME,UAAU,GAAG,IAAIC,QAAQ,CAAC,MAAM,EAAE,CAAA,oBAAA,EAAuBH,IAAI,CAAA,EAAA,CAAI,CAAC;QACxE,OAAOE,UAAU,CAACL,IAAI,CAAC;OACxB,CAAC,OAAOO,KAAK,EAAE;EACdC,MAAAA,OAAO,CAACD,KAAK,CAAC,CAAA,0BAAA,CAA4B,EAAE;EAC1CE,QAAAA,UAAU,EAAEN,IAAI;UAChBH,IAAI;UACJO,KAAK,EAAEA,KAAK,CAACG;EACf,OAAC,CAAC;EACF,MAAA,OAAO,EAAE;EACX;EACF;EACF;;EC5CA;EACA;EACA;EACA;EACA;EACA;EACO,MAAMC,MAAM,CAAC;EAClB;EACF;EACA;EACA;EACA;IAC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AAAA,MAAM,CAACgE,IAAI,CAACtC,QAAQ,IAAI,EAAE,CAAC,CAAChG,OAAO,CAAEuI,aAAa,IAAK;QACrDzH,SAAS,CAAC+G,gBAAgB,CAACU,aAAa,CAAC,CAACvI,OAAO,CAAEwI,OAAO,IAAK;UAC7D,MAAM3C,KAAK,GAAG,EAAE;UAChB,CAAC,GAAG2C,OAAO,CAAChF,UAAU,CAAC,CAACxD,OAAO,CAAC,CAAC;YAAE0D,IAAI;EAAEtE,UAAAA;EAAM,SAAC,KAAK;EACnD,UAAA,IAAIsE,IAAI,CAACC,UAAU,CAAC,aAAa,CAAC,EAAE;cAClCkC,KAAK,CAACnC,IAAI,CAAClF,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,GAAGY,KAAK;EAChD;EACF,SAAC,CAAC;EACF,QAAA,MAAMqJ,QAAQ,GAAG,IAAI,CAAC9C,KAAK,CAAC6C,OAAO,EAAExC,QAAQ,CAACuC,aAAa,CAAC,EAAE1C,KAAK,CAAC;EACpEU,QAAAA,cAAc,CAACjG,IAAI,CAACmI,QAAQ,CAAC;EAC/B,OAAC,CAAC;EACJ,KAAC,CAAC;EACJ;EACF;;;;;;;;"}
|
package/package.json
CHANGED
package/src/core/Eleva.js
CHANGED
|
@@ -62,6 +62,8 @@ export class Eleva {
|
|
|
62
62
|
this._isMounted = false;
|
|
63
63
|
/** @private {Emitter} Instance of the event emitter for handling component events */
|
|
64
64
|
this.emitter = new Emitter();
|
|
65
|
+
/** @private {Signal} Instance of the signal for handling plugin and component signals */
|
|
66
|
+
this.signal = Signal;
|
|
65
67
|
/** @private {Renderer} Instance of the renderer for handling DOM updates and patching */
|
|
66
68
|
this.renderer = new Renderer();
|
|
67
69
|
}
|
|
@@ -133,7 +135,7 @@ export class Eleva {
|
|
|
133
135
|
const context = {
|
|
134
136
|
props,
|
|
135
137
|
emitter: this.emitter,
|
|
136
|
-
signal: (v) => new
|
|
138
|
+
signal: (v) => new this.signal(v),
|
|
137
139
|
...this._prepareLifecycleHooks(),
|
|
138
140
|
};
|
|
139
141
|
|
package/types/core/Eleva.d.ts
CHANGED
|
@@ -54,6 +54,8 @@ export class Eleva {
|
|
|
54
54
|
private _isMounted;
|
|
55
55
|
/** @private {Emitter} Instance of the event emitter for handling component events */
|
|
56
56
|
private emitter;
|
|
57
|
+
/** @private {Signal} Instance of the signal for handling plugin and component signals */
|
|
58
|
+
private signal;
|
|
57
59
|
/** @private {Renderer} Instance of the renderer for handling DOM updates and patching */
|
|
58
60
|
private renderer;
|
|
59
61
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Eleva.d.ts","sourceRoot":"","sources":["../../src/core/Eleva.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;GAIG;AACH;IACE;;;;;OAKG;IACH,kBAHW,MAAM;;
|
|
1
|
+
{"version":3,"file":"Eleva.d.ts","sourceRoot":"","sources":["../../src/core/Eleva.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;GAIG;AACH;IACE;;;;;OAKG;IACH,kBAHW,MAAM;;OA4BhB;IAxBC,wEAAwE;IACxE,MADW,MAAM,CACD;IAChB,uFAAuF;IACvF;;MAAoB;IACpB,0GAA0G;IAC1G;;MAAqB;IACrB,wEAAwE;IACxE,iBAAkB;IAClB,mFAAmF;IACnF,wBAMC;IACD,2EAA2E;IAC3E,mBAAuB;IACvB,qFAAqF;IACrF,gBAA4B;IAC5B,yFAAyF;IACzF,eAAoB;IACpB,yFAAyF;IACzF,iBAA8B;IAGhC;;;;;;OAMG;IACH,YAJW,MAAM;;QAEJ,KAAK,CAQjB;IAED;;;;;;OAMG;IACH,gBAJW,MAAM,cACN,mBAAmB,GACjB,KAAK,CAKjB;IAED;;;;;;;;OAQG;IACH,iBANW,WAAW,YACX,MAAM,GAAC,mBAAmB;;QAExB,MAAM,GAAC,OAAO,CAAC,MAAM,CAAC,CAgHlC;IAED;;;;;OAKG;IACH,+BAKC;IAED;;;;;;;;OAQG;IACH,uBAiBC;IAED;;;;;;;;OAQG;IACH,sBAYC;IAED;;;;;;;OAOG;IACH,uBAgBC;CACF;;;;;;;;;;;;UAxS4C,CAAC;YAAO,MAAM,GAAE,GAAG;KAAC,GAAC,OAAO,CAAC;YAAO,MAAM,GAAE,GAAG;KAAC,CAAC,CAAC;;;;;;cAKjF,CAAS,IAAmB,EAAnB;YAAO,MAAM,GAAE,GAAG;KAAC,KAAG,MAAM;;;;;;;;UAKN,MAAM"}
|