eleva 1.2.17-beta → 1.2.19-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/eleva.d.ts CHANGED
@@ -3,6 +3,9 @@
3
3
  * @classdesc A robust event emitter that enables inter-component communication through a publish-subscribe pattern.
4
4
  * Components can emit events and listen for events from other components, facilitating loose coupling
5
5
  * and reactive updates across the application.
6
+ * Events are handled synchronously in the order they were registered, with proper cleanup
7
+ * of unsubscribed handlers.
8
+ * Event names should follow the format 'namespace:action' (e.g., 'user:login', 'cart:update').
6
9
  *
7
10
  * @example
8
11
  * const emitter = new Emitter();
@@ -10,42 +13,55 @@
10
13
  * emitter.emit('user:login', { name: 'John' }); // Logs: "User logged in: John"
11
14
  */
12
15
  declare class Emitter {
13
- /** @private {Map<string, Set<function(any): void>>} Map of event names to their registered handler functions */
16
+ /** @private {Map<string, Set<(data: unknown) => void>>} Map of event names to their registered handler functions */
14
17
  private _events;
15
18
  /**
16
19
  * Registers an event handler for the specified event name.
17
20
  * The handler will be called with the event data when the event is emitted.
21
+ * Event names should follow the format 'namespace:action' for consistency.
18
22
  *
19
23
  * @public
20
- * @param {string} event - The name of the event to listen for.
21
- * @param {function(any): void} handler - The callback function to invoke when the event occurs.
22
- * @returns {function(): void} A function to unsubscribe the event handler.
24
+ * @param {string} event - The name of the event to listen for (e.g., 'user:login').
25
+ * @param {(data: unknown) => void} handler - The callback function to invoke when the event occurs.
26
+ * @returns {() => void} A function to unsubscribe the event handler.
23
27
  * @example
24
28
  * const unsubscribe = emitter.on('user:login', (user) => console.log(user));
25
29
  * // Later...
26
30
  * unsubscribe(); // Stops listening for the event
27
31
  */
28
- public on(event: string, handler: (arg0: any) => void): () => void;
32
+ public on(event: string, handler: (data: unknown) => void): () => void;
29
33
  /**
30
34
  * Removes an event handler for the specified event name.
31
35
  * If no handler is provided, all handlers for the event are removed.
36
+ * Automatically cleans up empty event sets to prevent memory leaks.
32
37
  *
33
38
  * @public
34
- * @param {string} event - The name of the event.
35
- * @param {function(any): void} [handler] - The specific handler function to remove.
39
+ * @param {string} event - The name of the event to remove handlers from.
40
+ * @param {(data: unknown) => void} [handler] - The specific handler function to remove.
36
41
  * @returns {void}
42
+ * @example
43
+ * // Remove a specific handler
44
+ * emitter.off('user:login', loginHandler);
45
+ * // Remove all handlers for an event
46
+ * emitter.off('user:login');
37
47
  */
38
- public off(event: string, handler?: (arg0: any) => void): void;
48
+ public off(event: string, handler?: (data: unknown) => void): void;
39
49
  /**
40
50
  * Emits an event with the specified data to all registered handlers.
41
51
  * Handlers are called synchronously in the order they were registered.
52
+ * If no handlers are registered for the event, the emission is silently ignored.
42
53
  *
43
54
  * @public
44
55
  * @param {string} event - The name of the event to emit.
45
- * @param {...any} args - Optional arguments to pass to the event handlers.
56
+ * @param {...unknown} args - Optional arguments to pass to the event handlers.
46
57
  * @returns {void}
58
+ * @example
59
+ * // Emit an event with data
60
+ * emitter.emit('user:login', { name: 'John', role: 'admin' });
61
+ * // Emit an event with multiple arguments
62
+ * emitter.emit('cart:update', { items: [] }, { total: 0 });
47
63
  */
48
- public emit(event: string, ...args: any[]): void;
64
+ public emit(event: string, ...args: unknown[]): void;
49
65
  }
50
66
 
51
67
  /**
@@ -53,6 +69,8 @@ declare class Emitter {
53
69
  * @classdesc A reactive data holder that enables fine-grained reactivity in the Eleva framework.
54
70
  * Signals notify registered watchers when their value changes, enabling efficient DOM updates
55
71
  * through targeted patching rather than full re-renders.
72
+ * Updates are batched using microtasks to prevent multiple synchronous notifications.
73
+ * The class is generic, allowing type-safe handling of any value type T.
56
74
  *
57
75
  * @example
58
76
  * const count = new Signal(0);
@@ -65,12 +83,12 @@ declare class Signal<T> {
65
83
  * Creates a new Signal instance with the specified initial value.
66
84
  *
67
85
  * @public
68
- * @param {*} value - The initial value of the signal.
86
+ * @param {T} value - The initial value of the signal.
69
87
  */
70
- constructor(value: any);
71
- /** @private {T} Internal storage for the signal's current value, where T is the type of the initial value */
88
+ constructor(value: T);
89
+ /** @private {T} Internal storage for the signal's current value */
72
90
  private _value;
73
- /** @private {Set<function(T): void>} Collection of callback functions to be notified when value changes, where T is the value type */
91
+ /** @private {Set<(value: T) => void>} Collection of callback functions to be notified when value changes */
74
92
  private _watchers;
75
93
  /** @private {boolean} Flag to prevent multiple synchronous watcher notifications and batch updates into microtasks */
76
94
  private _pending;
@@ -79,7 +97,7 @@ declare class Signal<T> {
79
97
  * The notification is batched using microtasks to prevent multiple synchronous updates.
80
98
  *
81
99
  * @public
82
- * @param {T} newVal - The new value to set, where T is the type of the initial value.
100
+ * @param {T} newVal - The new value to set.
83
101
  * @returns {void}
84
102
  */
85
103
  public set value(newVal: T);
@@ -87,7 +105,7 @@ declare class Signal<T> {
87
105
  * Gets the current value of the signal.
88
106
  *
89
107
  * @public
90
- * @returns {T} The current value, where T is the type of the initial value.
108
+ * @returns {T} The current value.
91
109
  */
92
110
  public get value(): T;
93
111
  /**
@@ -95,14 +113,14 @@ declare class Signal<T> {
95
113
  * The watcher will receive the new value as its argument.
96
114
  *
97
115
  * @public
98
- * @param {function(T): void} fn - The callback function to invoke on value change, where T is the value type.
99
- * @returns {function(): boolean} A function to unsubscribe the watcher.
116
+ * @param {(value: T) => void} fn - The callback function to invoke on value change.
117
+ * @returns {() => boolean} A function to unsubscribe the watcher.
100
118
  * @example
101
119
  * const unsubscribe = signal.watch((value) => console.log(value));
102
120
  * // Later...
103
121
  * unsubscribe(); // Stops watching for changes
104
122
  */
105
- public watch(fn: (arg0: T) => void): () => boolean;
123
+ public watch(fn: (value: T) => void): () => boolean;
106
124
  /**
107
125
  * Notifies all registered watchers of a value change using microtask scheduling.
108
126
  * Uses a pending flag to batch multiple synchronous updates into a single notification.
@@ -116,9 +134,18 @@ declare class Signal<T> {
116
134
 
117
135
  /**
118
136
  * @class 🎨 Renderer
119
- * @classdesc A DOM renderer that handles efficient DOM updates through patching and diffing.
120
- * Provides methods for updating the DOM by comparing new and old structures and applying
121
- * only the necessary changes, minimizing layout thrashing and improving performance.
137
+ * @classdesc A high-performance DOM renderer that implements an optimized direct DOM diffing algorithm.
138
+ *
139
+ * Key features:
140
+ * - Single-pass diffing algorithm for efficient DOM updates
141
+ * - Key-based node reconciliation for optimal performance
142
+ * - Intelligent attribute handling for ARIA, data attributes, and boolean properties
143
+ * - Preservation of special Eleva-managed instances and style elements
144
+ * - Memory-efficient with reusable temporary containers
145
+ *
146
+ * The renderer is designed to minimize DOM operations while maintaining
147
+ * exact attribute synchronization and proper node identity preservation.
148
+ * It's particularly optimized for frequent updates and complex DOM structures.
122
149
  *
123
150
  * @example
124
151
  * const renderer = new Renderer();
@@ -127,24 +154,25 @@ declare class Signal<T> {
127
154
  * renderer.patchDOM(container, newHtml);
128
155
  */
129
156
  declare class Renderer {
130
- /** @private {HTMLElement} Reusable temporary container for parsing new HTML */
157
+ /**
158
+ * A temporary container to hold the new HTML content while diffing.
159
+ * @private
160
+ * @type {HTMLElement}
161
+ */
131
162
  private _tempContainer;
132
163
  /**
133
- * Patches the DOM of a container element with new HTML content.
134
- * Efficiently updates the DOM by parsing new HTML into a reusable container
135
- * and applying only the necessary changes.
164
+ * Patches the DOM of the given container with the provided HTML string.
136
165
  *
137
166
  * @public
138
167
  * @param {HTMLElement} container - The container element to patch.
139
- * @param {string} newHtml - The new HTML content to apply.
168
+ * @param {string} newHtml - The new HTML string.
140
169
  * @returns {void}
141
- * @throws {Error} If container is not an HTMLElement, newHtml is not a string, or patching fails.
170
+ * @throws {TypeError} If container is not an HTMLElement or newHtml is not a string.
171
+ * @throws {Error} If DOM patching fails.
142
172
  */
143
173
  public patchDOM(container: HTMLElement, newHtml: string): void;
144
174
  /**
145
- * Diffs two DOM trees (old and new) and applies updates to the old DOM.
146
- * This method recursively compares nodes and their attributes, applying only
147
- * the necessary changes to minimize DOM operations.
175
+ * Performs a diff between two DOM nodes and patches the old node to match the new node.
148
176
  *
149
177
  * @private
150
178
  * @param {HTMLElement} oldParent - The original DOM element.
@@ -153,44 +181,127 @@ declare class Renderer {
153
181
  */
154
182
  private _diff;
155
183
  /**
156
- * Updates the attributes of an element to match those of a new element.
157
- * Handles special cases for ARIA attributes, data attributes, and boolean properties.
184
+ * Patches a single node.
158
185
  *
159
186
  * @private
160
- * @param {HTMLElement} oldEl - The element to update.
161
- * @param {HTMLElement} newEl - The element providing the updated attributes.
187
+ * @param {Node} oldNode - The original DOM node.
188
+ * @param {Node} newNode - The new DOM node.
189
+ * @returns {void}
190
+ */
191
+ private _patchNode;
192
+ /**
193
+ * Removes a node from its parent.
194
+ *
195
+ * @private
196
+ * @param {HTMLElement} parent - The parent element containing the node to remove.
197
+ * @param {Node} node - The node to remove.
198
+ * @returns {void}
199
+ */
200
+ private _removeNode;
201
+ /**
202
+ * Updates the attributes of an element to match a new element's attributes.
203
+ *
204
+ * @private
205
+ * @param {HTMLElement} oldEl - The original element to update.
206
+ * @param {HTMLElement} newEl - The new element to update.
162
207
  * @returns {void}
163
208
  */
164
209
  private _updateAttributes;
210
+ /**
211
+ * Determines if two nodes are the same based on their type, name, and key attributes.
212
+ *
213
+ * @private
214
+ * @param {Node} oldNode - The first node to compare.
215
+ * @param {Node} newNode - The second node to compare.
216
+ * @returns {boolean} True if the nodes are considered the same, false otherwise.
217
+ */
218
+ private _isSameNode;
219
+ /**
220
+ * Creates a key map for the children of a parent node.
221
+ *
222
+ * @private
223
+ * @param {Array<Node>} children - The children of the parent node.
224
+ * @param {number} start - The start index of the children.
225
+ * @param {number} end - The end index of the children.
226
+ * @returns {Map<string, Node>} A key map for the children.
227
+ */
228
+ private _createKeyMap;
229
+ /**
230
+ * Extracts the key attribute from a node if it exists.
231
+ *
232
+ * @private
233
+ * @param {Node} node - The node to extract the key from.
234
+ * @returns {string|null} The key attribute value or null if not found.
235
+ */
236
+ private _getNodeKey;
165
237
  }
166
238
 
167
239
  /**
168
240
  * @typedef {Object} ComponentDefinition
169
- * @property {function(Object<string, any>): (Object<string, any>|Promise<Object<string, any>>)} [setup]
241
+ * @property {function(ComponentContext): (Record<string, unknown>|Promise<Record<string, unknown>>)} [setup]
170
242
  * Optional setup function that initializes the component's state and returns reactive data
171
- * @property {(function(Object<string, any>): string|Promise<string>|string)} template
243
+ * @property {(function(ComponentContext): string|Promise<string>)} template
172
244
  * Required function that defines the component's HTML structure
173
- * @property {(function(Object<string, any>): string)|string} [style]
245
+ * @property {(function(ComponentContext): string)|string} [style]
174
246
  * Optional function or string that provides component-scoped CSS styles
175
- * @property {Object<string, ComponentDefinition>} [children]
247
+ * @property {Record<string, ComponentDefinition>} [children]
176
248
  * Optional object defining nested child components
177
249
  */
178
250
  /**
179
- * @typedef {Object} ElevaPlugin
180
- * @property {function(Eleva, Object<string, any>): void} install
181
- * Function that installs the plugin into the Eleva instance
182
- * @property {string} name
183
- * Unique identifier name for the plugin
251
+ * @typedef {Object} ComponentContext
252
+ * @property {Record<string, unknown>} props
253
+ * Component properties passed during mounting
254
+ * @property {Emitter} emitter
255
+ * Event emitter instance for component event handling
256
+ * @property {function<T>(value: T): Signal<T>} signal
257
+ * Factory function to create reactive Signal instances
258
+ * @property {function(LifecycleHookContext): Promise<void>} [onBeforeMount]
259
+ * Hook called before component mounting
260
+ * @property {function(LifecycleHookContext): Promise<void>} [onMount]
261
+ * Hook called after component mounting
262
+ * @property {function(LifecycleHookContext): Promise<void>} [onBeforeUpdate]
263
+ * Hook called before component update
264
+ * @property {function(LifecycleHookContext): Promise<void>} [onUpdate]
265
+ * Hook called after component update
266
+ * @property {function(UnmountHookContext): Promise<void>} [onUnmount]
267
+ * Hook called during component unmounting
268
+ */
269
+ /**
270
+ * @typedef {Object} LifecycleHookContext
271
+ * @property {HTMLElement} container
272
+ * The DOM element where the component is mounted
273
+ * @property {ComponentContext} context
274
+ * The component's reactive state and context data
275
+ */
276
+ /**
277
+ * @typedef {Object} UnmountHookContext
278
+ * @property {HTMLElement} container
279
+ * The DOM element where the component is mounted
280
+ * @property {ComponentContext} context
281
+ * The component's reactive state and context data
282
+ * @property {{
283
+ * watchers: Array<() => void>, // Signal watcher cleanup functions
284
+ * listeners: Array<() => void>, // Event listener cleanup functions
285
+ * children: Array<MountResult> // Child component instances
286
+ * }} cleanup
287
+ * Object containing cleanup functions and instances
184
288
  */
185
289
  /**
186
290
  * @typedef {Object} MountResult
187
291
  * @property {HTMLElement} container
188
292
  * The DOM element where the component is mounted
189
- * @property {Object<string, any>} data
293
+ * @property {ComponentContext} data
190
294
  * The component's reactive state and context data
191
- * @property {function(): void} unmount
295
+ * @property {function(): Promise<void>} unmount
192
296
  * Function to clean up and unmount the component
193
297
  */
298
+ /**
299
+ * @typedef {Object} ElevaPlugin
300
+ * @property {function(Eleva, Record<string, unknown>): void} install
301
+ * Function that installs the plugin into the Eleva instance
302
+ * @property {string} name
303
+ * Unique identifier name for the plugin
304
+ */
194
305
  /**
195
306
  * @class 🧩 Eleva
196
307
  * @classdesc A modern, signal-based component runtime framework that provides lifecycle hooks,
@@ -198,12 +309,26 @@ declare class Renderer {
198
309
  * event handling, and DOM rendering with a focus on performance and developer experience.
199
310
  *
200
311
  * @example
312
+ * // Basic component creation and mounting
201
313
  * const app = new Eleva("myApp");
202
314
  * app.component("myComponent", {
203
- * template: (ctx) => `<div>Hello ${ctx.props.name}</div>`,
204
- * setup: (ctx) => ({ count: new Signal(0) })
315
+ * setup: (ctx) => ({ count: ctx.signal(0) }),
316
+ * template: (ctx) => `<div>Hello ${ctx.props.name}</div>`
205
317
  * });
206
318
  * app.mount(document.getElementById("app"), "myComponent", { name: "World" });
319
+ *
320
+ * @example
321
+ * // Using lifecycle hooks
322
+ * app.component("lifecycleDemo", {
323
+ * setup: () => {
324
+ * return {
325
+ * onMount: ({ container, context }) => {
326
+ * console.log('Component mounted!');
327
+ * }
328
+ * };
329
+ * },
330
+ * template: `<div>Lifecycle Demo</div>`
331
+ * });
207
332
  */
208
333
  declare class Eleva {
209
334
  /**
@@ -211,18 +336,25 @@ declare class Eleva {
211
336
  *
212
337
  * @public
213
338
  * @param {string} name - The unique identifier name for this Eleva instance.
214
- * @param {Object<string, any>} [config={}] - Optional configuration object for the instance.
339
+ * @param {Record<string, unknown>} [config={}] - Optional configuration object for the instance.
215
340
  * May include framework-wide settings and default behaviors.
341
+ * @throws {Error} If the name is not provided or is not a string.
342
+ * @returns {Eleva} A new Eleva instance.
343
+ *
344
+ * @example
345
+ * const app = new Eleva("myApp");
346
+ * app.component("myComponent", {
347
+ * setup: (ctx) => ({ count: ctx.signal(0) }),
348
+ * template: (ctx) => `<div>Hello ${ctx.props.name}!</div>`
349
+ * });
350
+ * app.mount(document.getElementById("app"), "myComponent", { name: "World" });
351
+ *
216
352
  */
217
- constructor(name: string, config?: {
218
- [x: string]: any;
219
- });
353
+ constructor(name: string, config?: Record<string, unknown>);
220
354
  /** @public {string} The unique identifier name for this Eleva instance */
221
355
  public name: string;
222
- /** @public {Object<string, any>} Optional configuration object for the Eleva instance */
223
- public config: {
224
- [x: string]: any;
225
- };
356
+ /** @public {Object<string, unknown>} Optional configuration object for the Eleva instance */
357
+ public config: Record<string, unknown>;
226
358
  /** @public {Emitter} Instance of the event emitter for handling component events */
227
359
  public emitter: Emitter;
228
360
  /** @public {typeof Signal} Static reference to the Signal class for creating reactive state */
@@ -233,8 +365,6 @@ declare class Eleva {
233
365
  private _components;
234
366
  /** @private {Map<string, ElevaPlugin>} Collection of installed plugin instances by name */
235
367
  private _plugins;
236
- /** @private {string[]} Array of lifecycle hook names supported by components */
237
- private _lifecycleHooks;
238
368
  /** @private {boolean} Flag indicating if the root component is currently mounted */
239
369
  private _isMounted;
240
370
  /**
@@ -244,13 +374,13 @@ declare class Eleva {
244
374
  *
245
375
  * @public
246
376
  * @param {ElevaPlugin} plugin - The plugin object which must have an `install` function.
247
- * @param {Object<string, any>} [options={}] - Optional configuration options for the plugin.
377
+ * @param {Object<string, unknown>} [options={}] - Optional configuration options for the plugin.
248
378
  * @returns {Eleva} The Eleva instance (for method chaining).
249
379
  * @example
250
380
  * app.use(myPlugin, { option1: "value1" });
251
381
  */
252
382
  public use(plugin: ElevaPlugin, options?: {
253
- [x: string]: any;
383
+ [x: string]: unknown;
254
384
  }): Eleva;
255
385
  /**
256
386
  * Registers a new component with the Eleva instance.
@@ -275,7 +405,7 @@ declare class Eleva {
275
405
  * @public
276
406
  * @param {HTMLElement} container - The DOM element where the component will be mounted.
277
407
  * @param {string|ComponentDefinition} compName - The name of the registered component or a direct component definition.
278
- * @param {Object<string, any>} [props={}] - Optional properties to pass to the component.
408
+ * @param {Object<string, unknown>} [props={}] - Optional properties to pass to the component.
279
409
  * @returns {Promise<MountResult>}
280
410
  * A Promise that resolves to an object containing:
281
411
  * - container: The mounted component's container element
@@ -288,25 +418,16 @@ declare class Eleva {
288
418
  * instance.unmount();
289
419
  */
290
420
  public mount(container: HTMLElement, compName: string | ComponentDefinition, props?: {
291
- [x: string]: any;
421
+ [x: string]: unknown;
292
422
  }): Promise<MountResult>;
293
- /**
294
- * Prepares default no-operation lifecycle hook functions for a component.
295
- * These hooks will be called at various stages of the component's lifecycle.
296
- *
297
- * @private
298
- * @returns {Object<string, function(): void>} An object mapping lifecycle hook names to empty functions.
299
- * The returned object will be merged with the component's context.
300
- */
301
- private _prepareLifecycleHooks;
302
423
  /**
303
424
  * Processes DOM elements for event binding based on attributes starting with "@".
304
425
  * This method handles the event delegation system and ensures proper cleanup of event listeners.
305
426
  *
306
427
  * @private
307
428
  * @param {HTMLElement} container - The container element in which to search for event attributes.
308
- * @param {Object<string, any>} context - The current component context containing event handler definitions.
309
- * @param {Array<Function>} cleanupListeners - Array to collect cleanup functions for each event listener.
429
+ * @param {ComponentContext} context - The current component context containing event handler definitions.
430
+ * @param {Array<() => void>} listeners - Array to collect cleanup functions for each event listener.
310
431
  * @returns {void}
311
432
  */
312
433
  private _processEvents;
@@ -317,8 +438,8 @@ declare class Eleva {
317
438
  * @private
318
439
  * @param {HTMLElement} container - The container element where styles should be injected.
319
440
  * @param {string} compName - The component name used to identify the style element.
320
- * @param {(function(Object<string, any>): string)|string} styleDef - The component's style definition (function or string).
321
- * @param {Object<string, any>} context - The current component context for style interpolation.
441
+ * @param {(function(ComponentContext): string)|string} styleDef - The component's style definition (function or string).
442
+ * @param {ComponentContext} context - The current component context for style interpolation.
322
443
  * @returns {void}
323
444
  */
324
445
  private _injectStyles;
@@ -329,7 +450,7 @@ declare class Eleva {
329
450
  * @private
330
451
  * @param {HTMLElement} element - The DOM element to extract props from
331
452
  * @param {string} prefix - The prefix to look for in attributes
332
- * @returns {Object<string, any>} An object containing the extracted props
453
+ * @returns {Record<string, string>} An object containing the extracted props
333
454
  * @example
334
455
  * // For an element with attributes:
335
456
  * // <div :name="John" :age="25">
@@ -363,45 +484,56 @@ type ComponentDefinition = {
363
484
  /**
364
485
  * Optional setup function that initializes the component's state and returns reactive data
365
486
  */
366
- setup?: ((arg0: {
367
- [x: string]: any;
368
- }) => ({
369
- [x: string]: any;
370
- } | Promise<{
371
- [x: string]: any;
372
- }>)) | undefined;
487
+ setup?: ((arg0: ComponentContext) => (Record<string, unknown> | Promise<Record<string, unknown>>)) | undefined;
373
488
  /**
374
489
  * Required function that defines the component's HTML structure
375
490
  */
376
- template: ((arg0: {
377
- [x: string]: any;
378
- }) => string | Promise<string> | string);
491
+ template: ((arg0: ComponentContext) => string | Promise<string>);
379
492
  /**
380
493
  * Optional function or string that provides component-scoped CSS styles
381
494
  */
382
- style?: string | ((arg0: {
383
- [x: string]: any;
384
- }) => string) | undefined;
495
+ style?: string | ((arg0: ComponentContext) => string) | undefined;
385
496
  /**
386
497
  * Optional object defining nested child components
387
498
  */
388
- children?: {
389
- [x: string]: ComponentDefinition;
390
- } | undefined;
499
+ children?: Record<string, ComponentDefinition> | undefined;
391
500
  };
392
- type ElevaPlugin = {
501
+ type ComponentContext = {
393
502
  /**
394
- * Function that installs the plugin into the Eleva instance
503
+ * Component properties passed during mounting
395
504
  */
396
- install: (arg0: Eleva, arg1: {
397
- [x: string]: any;
398
- }) => void;
505
+ props: Record<string, unknown>;
399
506
  /**
400
- * Unique identifier name for the plugin
507
+ * Event emitter instance for component event handling
401
508
  */
402
- name: string;
509
+ emitter: Emitter;
510
+ /**
511
+ * <T>(value: T): Signal<T>} signal
512
+ * Factory function to create reactive Signal instances
513
+ */
514
+ "": Function;
515
+ /**
516
+ * Hook called before component mounting
517
+ */
518
+ onBeforeMount?: ((arg0: LifecycleHookContext) => Promise<void>) | undefined;
519
+ /**
520
+ * Hook called after component mounting
521
+ */
522
+ onMount?: ((arg0: LifecycleHookContext) => Promise<void>) | undefined;
523
+ /**
524
+ * Hook called before component update
525
+ */
526
+ onBeforeUpdate?: ((arg0: LifecycleHookContext) => Promise<void>) | undefined;
527
+ /**
528
+ * Hook called after component update
529
+ */
530
+ onUpdate?: ((arg0: LifecycleHookContext) => Promise<void>) | undefined;
531
+ /**
532
+ * Hook called during component unmounting
533
+ */
534
+ onUnmount?: ((arg0: UnmountHookContext) => Promise<void>) | undefined;
403
535
  };
404
- type MountResult = {
536
+ type LifecycleHookContext = {
405
537
  /**
406
538
  * The DOM element where the component is mounted
407
539
  */
@@ -409,13 +541,49 @@ type MountResult = {
409
541
  /**
410
542
  * The component's reactive state and context data
411
543
  */
412
- data: {
413
- [x: string]: any;
544
+ context: ComponentContext;
545
+ };
546
+ type UnmountHookContext = {
547
+ /**
548
+ * The DOM element where the component is mounted
549
+ */
550
+ container: HTMLElement;
551
+ /**
552
+ * The component's reactive state and context data
553
+ */
554
+ context: ComponentContext;
555
+ /**
556
+ * Object containing cleanup functions and instances
557
+ */
558
+ cleanup: {
559
+ watchers: Array<() => void>;
560
+ listeners: Array<() => void>;
561
+ children: Array<MountResult>;
414
562
  };
563
+ };
564
+ type MountResult = {
565
+ /**
566
+ * The DOM element where the component is mounted
567
+ */
568
+ container: HTMLElement;
569
+ /**
570
+ * The component's reactive state and context data
571
+ */
572
+ data: ComponentContext;
415
573
  /**
416
574
  * Function to clean up and unmount the component
417
575
  */
418
- unmount: () => void;
576
+ unmount: () => Promise<void>;
577
+ };
578
+ type ElevaPlugin = {
579
+ /**
580
+ * Function that installs the plugin into the Eleva instance
581
+ */
582
+ install: (arg0: Eleva, arg1: Record<string, unknown>) => void;
583
+ /**
584
+ * Unique identifier name for the plugin
585
+ */
586
+ name: string;
419
587
  };
420
588
 
421
589
  //# sourceMappingURL=index.d.ts.map