eleva 1.0.0-alpha → 1.0.0-rc.10

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.
Files changed (68) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +554 -137
  3. package/dist/eleva-plugins.cjs.js +3397 -0
  4. package/dist/eleva-plugins.cjs.js.map +1 -0
  5. package/dist/eleva-plugins.esm.js +3392 -0
  6. package/dist/eleva-plugins.esm.js.map +1 -0
  7. package/dist/eleva-plugins.umd.js +3403 -0
  8. package/dist/eleva-plugins.umd.js.map +1 -0
  9. package/dist/eleva-plugins.umd.min.js +3 -0
  10. package/dist/eleva-plugins.umd.min.js.map +1 -0
  11. package/dist/eleva.cjs.js +1448 -0
  12. package/dist/eleva.cjs.js.map +1 -0
  13. package/dist/eleva.d.ts +1057 -80
  14. package/dist/eleva.esm.js +1230 -274
  15. package/dist/eleva.esm.js.map +1 -1
  16. package/dist/eleva.umd.js +1230 -274
  17. package/dist/eleva.umd.js.map +1 -1
  18. package/dist/eleva.umd.min.js +3 -0
  19. package/dist/eleva.umd.min.js.map +1 -0
  20. package/dist/plugins/attr.umd.js +231 -0
  21. package/dist/plugins/attr.umd.js.map +1 -0
  22. package/dist/plugins/attr.umd.min.js +3 -0
  23. package/dist/plugins/attr.umd.min.js.map +1 -0
  24. package/dist/plugins/props.umd.js +711 -0
  25. package/dist/plugins/props.umd.js.map +1 -0
  26. package/dist/plugins/props.umd.min.js +3 -0
  27. package/dist/plugins/props.umd.min.js.map +1 -0
  28. package/dist/plugins/router.umd.js +1807 -0
  29. package/dist/plugins/router.umd.js.map +1 -0
  30. package/dist/plugins/router.umd.min.js +3 -0
  31. package/dist/plugins/router.umd.min.js.map +1 -0
  32. package/dist/plugins/store.umd.js +684 -0
  33. package/dist/plugins/store.umd.js.map +1 -0
  34. package/dist/plugins/store.umd.min.js +3 -0
  35. package/dist/plugins/store.umd.min.js.map +1 -0
  36. package/package.json +240 -62
  37. package/src/core/Eleva.js +552 -145
  38. package/src/modules/Emitter.js +154 -18
  39. package/src/modules/Renderer.js +288 -86
  40. package/src/modules/Signal.js +132 -13
  41. package/src/modules/TemplateEngine.js +153 -27
  42. package/src/plugins/Attr.js +252 -0
  43. package/src/plugins/Props.js +590 -0
  44. package/src/plugins/Router.js +1919 -0
  45. package/src/plugins/Store.js +741 -0
  46. package/src/plugins/index.js +40 -0
  47. package/types/core/Eleva.d.ts +482 -48
  48. package/types/core/Eleva.d.ts.map +1 -1
  49. package/types/modules/Emitter.d.ts +151 -20
  50. package/types/modules/Emitter.d.ts.map +1 -1
  51. package/types/modules/Renderer.d.ts +151 -12
  52. package/types/modules/Renderer.d.ts.map +1 -1
  53. package/types/modules/Signal.d.ts +130 -16
  54. package/types/modules/Signal.d.ts.map +1 -1
  55. package/types/modules/TemplateEngine.d.ts +154 -14
  56. package/types/modules/TemplateEngine.d.ts.map +1 -1
  57. package/types/plugins/Attr.d.ts +28 -0
  58. package/types/plugins/Attr.d.ts.map +1 -0
  59. package/types/plugins/Props.d.ts +48 -0
  60. package/types/plugins/Props.d.ts.map +1 -0
  61. package/types/plugins/Router.d.ts +1000 -0
  62. package/types/plugins/Router.d.ts.map +1 -0
  63. package/types/plugins/Store.d.ts +86 -0
  64. package/types/plugins/Store.d.ts.map +1 -0
  65. package/types/plugins/index.d.ts +5 -0
  66. package/types/plugins/index.d.ts.map +1 -0
  67. package/dist/eleva.min.js +0 -2
  68. package/dist/eleva.min.js.map +0 -1
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * @fileoverview Eleva Plugin System
5
+ *
6
+ * This module exports all official Eleva plugins. Plugins provide optional
7
+ * functionality that can be added to Eleva applications as needed.
8
+ *
9
+ * Tree-shaking is supported - only imported plugins will be included in your bundle.
10
+ *
11
+ * @example
12
+ * // Import specific plugins (recommended for optimal tree-shaking)
13
+ * import { Attr } from 'eleva/plugins';
14
+ *
15
+ * const app = new Eleva("myApp");
16
+ * app.use(Attr, {
17
+ * enableAria: true,
18
+ * enableData: true,
19
+ * enableBoolean: true,
20
+ * enableDynamic: true
21
+ * });
22
+ *
23
+ * @example
24
+ * // Import multiple plugins
25
+ * import { Attr, Router, Store } from 'eleva/plugins';
26
+ *
27
+ * const app = new Eleva("myApp");
28
+ * app.use(Attr);
29
+ * app.use(Router);
30
+ * app.use(Store, {
31
+ * state: { counter: 0 },
32
+ * actions: { increment: (state) => state.counter.value++ }
33
+ * });
34
+ */
35
+
36
+ // Export plugins with clean names
37
+ export { AttrPlugin as Attr } from "./Attr.js";
38
+ export { RouterPlugin as Router } from "./Router.js";
39
+ export { PropsPlugin as Props } from "./Props.js";
40
+ export { StorePlugin as Store } from "./Store.js";
@@ -1,86 +1,520 @@
1
1
  /**
2
- * 🧩 Eleva Core: Signal-based component runtime framework with lifecycle, scoped styles, and plugins.
2
+ * @typedef {Object} ElevaConfig
3
+ * @property {boolean} [debug=false]
4
+ * Enable debug mode for verbose logging
5
+ * @property {string} [prefix='e']
6
+ * Prefix for component style scoping
7
+ * @property {boolean} [async=true]
8
+ * Enable async component setup
9
+ */
10
+ /**
11
+ * @typedef {Object} ComponentDefinition
12
+ * @property {SetupFunction} [setup]
13
+ * Optional setup function that initializes the component's state and returns reactive data
14
+ * @property {TemplateFunction|string} template
15
+ * Required function or string that defines the component's HTML structure
16
+ * @property {StyleFunction|string} [style]
17
+ * Optional function or string that provides component-scoped CSS styles
18
+ * @property {ChildrenMap} [children]
19
+ * Optional object defining nested child components
20
+ */
21
+ /**
22
+ * @callback SetupFunction
23
+ * @param {ComponentContext} ctx - The component context with props, emitter, and signal factory
24
+ * @returns {SetupResult|Promise<SetupResult>} Reactive data and lifecycle hooks
25
+ */
26
+ /**
27
+ * @typedef {Record<string, unknown> & LifecycleHooks} SetupResult
28
+ * Data returned from setup function, may include lifecycle hooks
29
+ */
30
+ /**
31
+ * @callback TemplateFunction
32
+ * @param {ComponentContext} ctx - The component context
33
+ * @returns {string|Promise<string>} HTML template string
34
+ */
35
+ /**
36
+ * @callback StyleFunction
37
+ * @param {ComponentContext} ctx - The component context
38
+ * @returns {string} CSS styles string
39
+ */
40
+ /**
41
+ * @typedef {Record<string, ComponentDefinition|string>} ChildrenMap
42
+ * Map of CSS selectors to component definitions or registered component names
43
+ */
44
+ /**
45
+ * @typedef {Object} ComponentContext
46
+ * @property {ComponentProps} props
47
+ * Component properties passed during mounting
48
+ * @property {Emitter} emitter
49
+ * Event emitter instance for component event handling
50
+ * @property {SignalFactory} signal
51
+ * Factory function to create reactive Signal instances
52
+ */
53
+ /**
54
+ * @typedef {Record<string, unknown>} ComponentProps
55
+ * Properties passed to a component during mounting
56
+ */
57
+ /**
58
+ * @callback SignalFactory
59
+ * @template T
60
+ * @param {T} initialValue - The initial value for the signal
61
+ * @returns {Signal<T>} A new Signal instance
62
+ */
63
+ /**
64
+ * @typedef {Object} LifecycleHooks
65
+ * @property {LifecycleHook} [onBeforeMount]
66
+ * Hook called before component mounting
67
+ * @property {LifecycleHook} [onMount]
68
+ * Hook called after component mounting
69
+ * @property {LifecycleHook} [onBeforeUpdate]
70
+ * Hook called before component update
71
+ * @property {LifecycleHook} [onUpdate]
72
+ * Hook called after component update
73
+ * @property {UnmountHook} [onUnmount]
74
+ * Hook called during component unmounting
75
+ */
76
+ /**
77
+ * @callback LifecycleHook
78
+ * @param {LifecycleHookContext} ctx - Context with container and component data
79
+ * @returns {void|Promise<void>}
80
+ */
81
+ /**
82
+ * @callback UnmountHook
83
+ * @param {UnmountHookContext} ctx - Context with cleanup resources
84
+ * @returns {void|Promise<void>}
85
+ */
86
+ /**
87
+ * @typedef {Object} LifecycleHookContext
88
+ * @property {HTMLElement} container
89
+ * The DOM element where the component is mounted
90
+ * @property {ComponentContext & SetupResult} context
91
+ * The component's reactive state and context data
92
+ */
93
+ /**
94
+ * @typedef {Object} UnmountHookContext
95
+ * @property {HTMLElement} container
96
+ * The DOM element where the component is mounted
97
+ * @property {ComponentContext & SetupResult} context
98
+ * The component's reactive state and context data
99
+ * @property {CleanupResources} cleanup
100
+ * Object containing cleanup functions and instances
101
+ */
102
+ /**
103
+ * @typedef {Object} CleanupResources
104
+ * @property {Array<UnsubscribeFunction>} watchers
105
+ * Signal watcher cleanup functions
106
+ * @property {Array<UnsubscribeFunction>} listeners
107
+ * Event listener cleanup functions
108
+ * @property {Array<MountResult>} children
109
+ * Child component instances
110
+ */
111
+ /**
112
+ * @typedef {Object} MountResult
113
+ * @property {HTMLElement} container
114
+ * The DOM element where the component is mounted
115
+ * @property {ComponentContext & SetupResult} data
116
+ * The component's reactive state and context data
117
+ * @property {UnmountFunction} unmount
118
+ * Function to clean up and unmount the component
119
+ */
120
+ /**
121
+ * @callback UnmountFunction
122
+ * @returns {Promise<void>}
123
+ */
124
+ /**
125
+ * @callback UnsubscribeFunction
126
+ * @returns {void|boolean}
127
+ */
128
+ /**
129
+ * @typedef {Object} ElevaPlugin
130
+ * @property {PluginInstallFunction} install
131
+ * Function that installs the plugin into the Eleva instance
132
+ * @property {string} name
133
+ * Unique identifier name for the plugin
134
+ * @property {PluginUninstallFunction} [uninstall]
135
+ * Optional function to uninstall the plugin
136
+ */
137
+ /**
138
+ * @callback PluginInstallFunction
139
+ * @param {Eleva} eleva - The Eleva instance
140
+ * @param {PluginOptions} options - Plugin configuration options
141
+ * @returns {void|Eleva|unknown} Optionally returns the Eleva instance or plugin result
142
+ */
143
+ /**
144
+ * @callback PluginUninstallFunction
145
+ * @param {Eleva} eleva - The Eleva instance
146
+ * @returns {void}
147
+ */
148
+ /**
149
+ * @typedef {Record<string, unknown>} PluginOptions
150
+ * Configuration options passed to a plugin during installation
151
+ */
152
+ /**
153
+ * @callback EventHandler
154
+ * @param {Event} event - The DOM event object
155
+ * @returns {void}
156
+ */
157
+ /**
158
+ * @typedef {'click'|'submit'|'input'|'change'|'focus'|'blur'|'keydown'|'keyup'|'keypress'|'mouseenter'|'mouseleave'|'mouseover'|'mouseout'|'mousedown'|'mouseup'|'touchstart'|'touchend'|'touchmove'|'scroll'|'resize'|'load'|'error'|string} DOMEventName
159
+ * Common DOM event names (prefixed with @ in templates)
160
+ */
161
+ /**
162
+ * @class 🧩 Eleva
163
+ * @classdesc A modern, signal-based component runtime framework that provides lifecycle hooks,
164
+ * scoped styles, and plugin support. Eleva manages component registration, plugin integration,
165
+ * event handling, and DOM rendering with a focus on performance and developer experience.
3
166
  *
4
- * The Eleva class is the core of the framework. It manages component registration,
5
- * plugin integration, lifecycle hooks, event handling, and DOM rendering.
167
+ * @example
168
+ * // Basic component creation and mounting
169
+ * const app = new Eleva("myApp");
170
+ * app.component("myComponent", {
171
+ * setup: (ctx) => ({ count: ctx.signal(0) }),
172
+ * template: (ctx) => `<div>Hello ${ctx.props.name}</div>`
173
+ * });
174
+ * app.mount(document.getElementById("app"), "myComponent", { name: "World" });
175
+ *
176
+ * @example
177
+ * // Using lifecycle hooks
178
+ * app.component("lifecycleDemo", {
179
+ * setup: () => {
180
+ * return {
181
+ * onMount: ({ container, context }) => {
182
+ * console.log('Component mounted!');
183
+ * }
184
+ * };
185
+ * },
186
+ * template: `<div>Lifecycle Demo</div>`
187
+ * });
6
188
  */
7
189
  export class Eleva {
8
190
  /**
9
- * Creates a new Eleva instance.
191
+ * Creates a new Eleva instance with the specified name and configuration.
192
+ *
193
+ * @public
194
+ * @param {string} name - The unique identifier name for this Eleva instance.
195
+ * @param {Record<string, unknown>} [config={}] - Optional configuration object for the instance.
196
+ * May include framework-wide settings and default behaviors.
197
+ * @throws {Error} If the name is not provided or is not a string.
198
+ * @returns {Eleva} A new Eleva instance.
199
+ *
200
+ * @example
201
+ * const app = new Eleva("myApp");
202
+ * app.component("myComponent", {
203
+ * setup: (ctx) => ({ count: ctx.signal(0) }),
204
+ * template: (ctx) => `<div>Hello ${ctx.props.name}!</div>`
205
+ * });
206
+ * app.mount(document.getElementById("app"), "myComponent", { name: "World" });
10
207
  *
11
- * @param {string} name - The name of the Eleva instance.
12
- * @param {object} [config={}] - Optional configuration for the instance.
13
208
  */
14
- constructor(name: string, config?: object);
15
- name: string;
16
- config: object;
17
- _components: {};
18
- _plugins: any[];
19
- _lifecycleHooks: string[];
20
- _isMounted: boolean;
21
- emitter: Emitter;
22
- renderer: Renderer;
209
+ constructor(name: string, config?: Record<string, unknown>);
210
+ /** @public {string} The unique identifier name for this Eleva instance */
211
+ public name: string;
212
+ /** @public {Object<string, unknown>} Optional configuration object for the Eleva instance */
213
+ public config: Record<string, unknown>;
214
+ /** @public {Emitter} Instance of the event emitter for handling component events */
215
+ public emitter: Emitter;
216
+ /** @public {typeof Signal} Static reference to the Signal class for creating reactive state */
217
+ public signal: typeof Signal;
218
+ /** @public {typeof TemplateEngine} Static reference to the TemplateEngine class for template parsing */
219
+ public templateEngine: typeof TemplateEngine;
220
+ /** @public {Renderer} Instance of the renderer for handling DOM updates and patching */
221
+ public renderer: Renderer;
222
+ /** @private {Map<string, ComponentDefinition>} Registry of all component definitions by name */
223
+ private _components;
224
+ /** @private {Map<string, ElevaPlugin>} Collection of installed plugin instances by name */
225
+ private _plugins;
226
+ /** @private {number} Counter for generating unique component IDs */
227
+ private _componentCounter;
23
228
  /**
24
229
  * Integrates a plugin with the Eleva framework.
230
+ * The plugin's install function will be called with the Eleva instance and provided options.
231
+ * After installation, the plugin will be available for use by components.
25
232
  *
26
- * @param {object} [plugin] - The plugin object which should have an install function.
27
- * @param {object} [options={}] - Optional options to pass to the plugin.
28
- * @returns {Eleva} The Eleva instance (for chaining).
29
- */
30
- use(plugin?: object, options?: object): Eleva;
31
- /**
32
- * Registers a component with the Eleva instance.
233
+ * Note: Plugins that wrap core methods (e.g., mount) must be uninstalled in reverse order
234
+ * of installation (LIFO - Last In, First Out) to avoid conflicts.
33
235
  *
34
- * @param {string} name - The name of the component.
35
- * @param {object} definition - The component definition including setup, template, style, and children.
36
- * @returns {Eleva} The Eleva instance (for chaining).
236
+ * @public
237
+ * @param {ElevaPlugin} plugin - The plugin object which must have an `install` function.
238
+ * @param {Object<string, unknown>} [options={}] - Optional configuration options for the plugin.
239
+ * @returns {Eleva} The Eleva instance (for method chaining).
240
+ * @example
241
+ * app.use(myPlugin, { option1: "value1" });
242
+ *
243
+ * @example
244
+ * // Correct uninstall order (LIFO)
245
+ * app.use(PluginA);
246
+ * app.use(PluginB);
247
+ * // Uninstall in reverse order:
248
+ * PluginB.uninstall(app);
249
+ * PluginA.uninstall(app);
37
250
  */
38
- component(name: string, definition: object): Eleva;
251
+ public use(plugin: ElevaPlugin, options?: {
252
+ [x: string]: unknown;
253
+ }): Eleva;
39
254
  /**
40
- * Mounts a registered component to a DOM element.
255
+ * Registers a new component with the Eleva instance.
256
+ * The component will be available for mounting using its registered name.
41
257
  *
42
- * @param {string|HTMLElement} selectorOrElement - A CSS selector string or DOM element where the component will be mounted.
43
- * @param {string} compName - The name of the component to mount.
44
- * @param {object} [props={}] - Optional properties to pass to the component.
45
- * @returns {object|Promise<object>} An object representing the mounted component instance, or a Promise that resolves to it for asynchronous setups.
46
- * @throws Will throw an error if the container or component is not found.
258
+ * @public
259
+ * @param {string} name - The unique name of the component to register.
260
+ * @param {ComponentDefinition} definition - The component definition including setup, template, style, and children.
261
+ * @returns {Eleva} The Eleva instance (for method chaining).
262
+ * @throws {Error} If the component name is already registered.
263
+ * @example
264
+ * app.component("myButton", {
265
+ * template: (ctx) => `<button>${ctx.props.text}</button>`,
266
+ * style: `button { color: blue; }`
267
+ * });
47
268
  */
48
- mount(selectorOrElement: string | HTMLElement, compName: string, props?: object): object | Promise<object>;
269
+ public component(name: string, definition: ComponentDefinition): Eleva;
49
270
  /**
50
- * Prepares default no-operation lifecycle hook functions.
271
+ * Mounts a registered component to a DOM element.
272
+ * This will initialize the component, set up its reactive state, and render it to the DOM.
51
273
  *
52
- * @returns {object} An object with keys for lifecycle hooks mapped to empty functions.
53
- * @private
274
+ * @public
275
+ * @param {HTMLElement} container - The DOM element where the component will be mounted.
276
+ * @param {string|ComponentDefinition} compName - The name of the registered component or a direct component definition.
277
+ * @param {Object<string, unknown>} [props={}] - Optional properties to pass to the component.
278
+ * @returns {Promise<MountResult>}
279
+ * A Promise that resolves to an object containing:
280
+ * - container: The mounted component's container element
281
+ * - data: The component's reactive state and context
282
+ * - unmount: Function to clean up and unmount the component
283
+ * @throws {Error} If the container is not found, or component is not registered.
284
+ * @example
285
+ * const instance = await app.mount(document.getElementById("app"), "myComponent", { text: "Click me" });
286
+ * // Later...
287
+ * instance.unmount();
54
288
  */
55
- private _prepareLifecycleHooks;
289
+ public mount(container: HTMLElement, compName: string | ComponentDefinition, props?: {
290
+ [x: string]: unknown;
291
+ }): Promise<MountResult>;
56
292
  /**
57
293
  * Processes DOM elements for event binding based on attributes starting with "@".
294
+ * This method handles the event delegation system and ensures proper cleanup of event listeners.
58
295
  *
59
- * @param {HTMLElement} container - The container element in which to search for events.
60
- * @param {object} context - The current context containing event handler definitions.
61
296
  * @private
297
+ * @param {HTMLElement} container - The container element in which to search for event attributes.
298
+ * @param {ComponentContext} context - The current component context containing event handler definitions.
299
+ * @param {Array<() => void>} listeners - Array to collect cleanup functions for each event listener.
300
+ * @returns {void}
62
301
  */
63
302
  private _processEvents;
64
303
  /**
65
304
  * Injects scoped styles into the component's container.
305
+ * The styles are automatically prefixed to prevent style leakage to other components.
66
306
  *
67
- * @param {HTMLElement} container - The container element.
68
- * @param {string} compName - The component name used to identify the style element.
69
- * @param {Function} styleFn - A function that returns CSS styles as a string.
70
- * @param {object} context - The current context for style interpolation.
71
307
  * @private
308
+ * @param {HTMLElement} container - The container element where styles should be injected.
309
+ * @param {string} compId - The component ID used to identify the style element.
310
+ * @param {(function(ComponentContext): string)|string} styleDef - The component's style definition (function or string).
311
+ * @param {ComponentContext} context - The current component context for style interpolation.
312
+ * @returns {void}
72
313
  */
73
314
  private _injectStyles;
74
315
  /**
75
- * Mounts child components within the parent component's container.
316
+ * Extracts props from an element's attributes that start with the specified prefix.
317
+ * This method is used to collect component properties from DOM elements.
76
318
  *
77
- * @param {HTMLElement} container - The parent container element.
78
- * @param {object} children - An object mapping child component selectors to their definitions.
79
- * @param {Array} childInstances - An array to store the mounted child component instances.
80
319
  * @private
320
+ * @param {HTMLElement} element - The DOM element to extract props from
321
+ * @returns {Record<string, string>} An object containing the extracted props
322
+ * @example
323
+ * // For an element with attributes:
324
+ * // <div :name="John" :age="25">
325
+ * // Returns: { name: "John", age: "25" }
81
326
  */
82
- private _mountChildren;
327
+ private _extractProps;
328
+ /**
329
+ * Mounts all components within the parent component's container.
330
+ * This method handles mounting of explicitly defined children components.
331
+ *
332
+ * The mounting process follows these steps:
333
+ * 1. Cleans up any existing component instances
334
+ * 2. Mounts explicitly defined children components
335
+ *
336
+ * @private
337
+ * @param {HTMLElement} container - The container element to mount components in
338
+ * @param {Object<string, ComponentDefinition>} children - Map of selectors to component definitions for explicit children
339
+ * @param {Array<MountResult>} childInstances - Array to store all mounted component instances
340
+ * @returns {Promise<void>}
341
+ *
342
+ * @example
343
+ * // Explicit children mounting:
344
+ * const children = {
345
+ * 'UserProfile': UserProfileComponent,
346
+ * '#settings-panel': "settings-panel"
347
+ * };
348
+ */
349
+ private _mountComponents;
83
350
  }
351
+ export type ElevaConfig = {
352
+ /**
353
+ * Enable debug mode for verbose logging
354
+ */
355
+ debug?: boolean | undefined;
356
+ /**
357
+ * Prefix for component style scoping
358
+ */
359
+ prefix?: string | undefined;
360
+ /**
361
+ * Enable async component setup
362
+ */
363
+ async?: boolean | undefined;
364
+ };
365
+ export type ComponentDefinition = {
366
+ /**
367
+ * Optional setup function that initializes the component's state and returns reactive data
368
+ */
369
+ setup?: SetupFunction | undefined;
370
+ /**
371
+ * Required function or string that defines the component's HTML structure
372
+ */
373
+ template: TemplateFunction | string;
374
+ /**
375
+ * Optional function or string that provides component-scoped CSS styles
376
+ */
377
+ style?: string | StyleFunction | undefined;
378
+ /**
379
+ * Optional object defining nested child components
380
+ */
381
+ children?: ChildrenMap | undefined;
382
+ };
383
+ export type SetupFunction = (ctx: ComponentContext) => SetupResult | Promise<SetupResult>;
384
+ /**
385
+ * Data returned from setup function, may include lifecycle hooks
386
+ */
387
+ export type SetupResult = Record<string, unknown> & LifecycleHooks;
388
+ export type TemplateFunction = (ctx: ComponentContext) => string | Promise<string>;
389
+ export type StyleFunction = (ctx: ComponentContext) => string;
390
+ /**
391
+ * Map of CSS selectors to component definitions or registered component names
392
+ */
393
+ export type ChildrenMap = Record<string, ComponentDefinition | string>;
394
+ export type ComponentContext = {
395
+ /**
396
+ * Component properties passed during mounting
397
+ */
398
+ props: ComponentProps;
399
+ /**
400
+ * Event emitter instance for component event handling
401
+ */
402
+ emitter: Emitter;
403
+ /**
404
+ * Factory function to create reactive Signal instances
405
+ */
406
+ signal: SignalFactory;
407
+ };
408
+ /**
409
+ * Properties passed to a component during mounting
410
+ */
411
+ export type ComponentProps = Record<string, unknown>;
412
+ export type SignalFactory = () => any;
413
+ export type LifecycleHooks = {
414
+ /**
415
+ * Hook called before component mounting
416
+ */
417
+ onBeforeMount?: LifecycleHook | undefined;
418
+ /**
419
+ * Hook called after component mounting
420
+ */
421
+ onMount?: LifecycleHook | undefined;
422
+ /**
423
+ * Hook called before component update
424
+ */
425
+ onBeforeUpdate?: LifecycleHook | undefined;
426
+ /**
427
+ * Hook called after component update
428
+ */
429
+ onUpdate?: LifecycleHook | undefined;
430
+ /**
431
+ * Hook called during component unmounting
432
+ */
433
+ onUnmount?: UnmountHook | undefined;
434
+ };
435
+ export type LifecycleHook = (ctx: LifecycleHookContext) => void | Promise<void>;
436
+ export type UnmountHook = (ctx: UnmountHookContext) => void | Promise<void>;
437
+ export type LifecycleHookContext = {
438
+ /**
439
+ * The DOM element where the component is mounted
440
+ */
441
+ container: HTMLElement;
442
+ /**
443
+ * The component's reactive state and context data
444
+ */
445
+ context: ComponentContext & SetupResult;
446
+ };
447
+ export type UnmountHookContext = {
448
+ /**
449
+ * The DOM element where the component is mounted
450
+ */
451
+ container: HTMLElement;
452
+ /**
453
+ * The component's reactive state and context data
454
+ */
455
+ context: ComponentContext & SetupResult;
456
+ /**
457
+ * Object containing cleanup functions and instances
458
+ */
459
+ cleanup: CleanupResources;
460
+ };
461
+ export type CleanupResources = {
462
+ /**
463
+ * Signal watcher cleanup functions
464
+ */
465
+ watchers: Array<UnsubscribeFunction>;
466
+ /**
467
+ * Event listener cleanup functions
468
+ */
469
+ listeners: Array<UnsubscribeFunction>;
470
+ /**
471
+ * Child component instances
472
+ */
473
+ children: Array<MountResult>;
474
+ };
475
+ export type MountResult = {
476
+ /**
477
+ * The DOM element where the component is mounted
478
+ */
479
+ container: HTMLElement;
480
+ /**
481
+ * The component's reactive state and context data
482
+ */
483
+ data: ComponentContext & SetupResult;
484
+ /**
485
+ * Function to clean up and unmount the component
486
+ */
487
+ unmount: UnmountFunction;
488
+ };
489
+ export type UnmountFunction = () => Promise<void>;
490
+ export type UnsubscribeFunction = () => void | boolean;
491
+ export type ElevaPlugin = {
492
+ /**
493
+ * Function that installs the plugin into the Eleva instance
494
+ */
495
+ install: PluginInstallFunction;
496
+ /**
497
+ * Unique identifier name for the plugin
498
+ */
499
+ name: string;
500
+ /**
501
+ * Optional function to uninstall the plugin
502
+ */
503
+ uninstall?: PluginUninstallFunction | undefined;
504
+ };
505
+ export type PluginInstallFunction = (eleva: Eleva, options: PluginOptions) => void | Eleva | unknown;
506
+ export type PluginUninstallFunction = (eleva: Eleva) => void;
507
+ /**
508
+ * Configuration options passed to a plugin during installation
509
+ */
510
+ export type PluginOptions = Record<string, unknown>;
511
+ export type EventHandler = (event: Event) => void;
512
+ /**
513
+ * Common DOM event names (prefixed with @ in templates)
514
+ */
515
+ export type DOMEventName = "click" | "submit" | "input" | "change" | "focus" | "blur" | "keydown" | "keyup" | "keypress" | "mouseenter" | "mouseleave" | "mouseover" | "mouseout" | "mousedown" | "mouseup" | "touchstart" | "touchend" | "touchmove" | "scroll" | "resize" | "load" | "error" | string;
84
516
  import { Emitter } from "../modules/Emitter.js";
517
+ import { Signal } from "../modules/Signal.js";
518
+ import { TemplateEngine } from "../modules/TemplateEngine.js";
85
519
  import { Renderer } from "../modules/Renderer.js";
86
520
  //# sourceMappingURL=Eleva.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Eleva.d.ts","sourceRoot":"","sources":["../../src/core/Eleva.js"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH;IACE;;;;;OAKG;IACH,kBAHW,MAAM,WACN,MAAM,EAiBhB;IAdC,aAAgB;IAChB,eAAoB;IACpB,gBAAqB;IACrB,gBAAkB;IAClB,0BAMC;IACD,oBAAuB;IACvB,iBAA4B;IAC5B,mBAA8B;IAGhC;;;;;;OAMG;IACH,aAJW,MAAM,YACN,MAAM,GACJ,KAAK,CAQjB;IAED;;;;;;OAMG;IACH,gBAJW,MAAM,cACN,MAAM,GACJ,KAAK,CAKjB;IAED;;;;;;;;OAQG;IACH,yBANW,MAAM,GAAC,WAAW,YAClB,MAAM,UACN,MAAM,GACJ,MAAM,GAAC,OAAO,CAAC,MAAM,CAAC,CA0FlC;IAED;;;;;OAKG;IACH,+BAKC;IAED;;;;;;OAMG;IACH,uBAaC;IAED;;;;;;;;OAQG;IACH,sBAYC;IAED;;;;;;;OAOG;IACH,uBAgBC;CACF;wBAjPuB,uBAAuB;yBACtB,wBAAwB"}
1
+ {"version":3,"file":"Eleva.d.ts","sourceRoot":"","sources":["../../src/core/Eleva.js"],"names":[],"mappings":"AAeA;;;;;;;;GAQG;AAMH;;;;;;;;;;GAUG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;GAGG;AAMH;;;;;;;;GAQG;AAEH;;;GAGG;AAEH;;;;;GAKG;AAMH;;;;;;;;;;;;GAYG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;;;GAMG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;;GAQG;AAMH;;;;;;;;GAQG;AAEH;;;GAGG;AAEH;;;GAGG;AAMH;;;;;;;;GAQG;AAEH;;;;;GAKG;AAEH;;;;GAIG;AAEH;;;GAGG;AAMH;;;;GAIG;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