eleva 1.0.0-alpha → 1.2.0-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 +108 -105
- package/dist/eleva.d.ts +106 -89
- package/dist/eleva.esm.js +125 -68
- 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 +125 -68
- package/dist/eleva.umd.js.map +1 -1
- package/package.json +2 -1
- package/src/core/Eleva.js +93 -40
- package/src/modules/Emitter.js +8 -8
- package/src/modules/Renderer.js +8 -8
- package/src/modules/Signal.js +7 -5
- package/src/modules/TemplateEngine.js +10 -11
- package/types/core/Eleva.d.ts +109 -30
- package/types/core/Eleva.d.ts.map +1 -1
- package/types/modules/Emitter.d.ts +10 -10
- package/types/modules/Emitter.d.ts.map +1 -1
- package/types/modules/Renderer.d.ts +2 -2
- package/types/modules/Signal.d.ts +10 -8
- package/types/modules/Signal.d.ts.map +1 -1
- package/types/modules/TemplateEngine.d.ts +15 -12
- package/types/modules/TemplateEngine.d.ts.map +1 -1
package/dist/eleva.d.ts
CHANGED
|
@@ -1,119 +1,95 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Defines the structure and behavior of a component.
|
|
3
|
+
* @typedef {Object} ComponentDefinition
|
|
4
|
+
* @property {function(Object<string, any>): (Object<string, any>|Promise<Object<string, any>>)} [setup]
|
|
5
|
+
* Optional setup function that initializes the component's reactive state and lifecycle.
|
|
6
|
+
* Receives props and context as an argument and should return an object containing the component's state.
|
|
7
|
+
* Can return either a synchronous object or a Promise that resolves to an object for async initialization.
|
|
3
8
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* Registers an event handler for the specified event.
|
|
14
|
-
*
|
|
15
|
-
* @param {string} event - The name of the event.
|
|
16
|
-
* @param {Function} handler - The function to call when the event is emitted.
|
|
17
|
-
*/
|
|
18
|
-
on(event: string, handler: Function): void;
|
|
19
|
-
/**
|
|
20
|
-
* Removes a previously registered event handler.
|
|
21
|
-
*
|
|
22
|
-
* @param {string} event - The name of the event.
|
|
23
|
-
* @param {Function} handler - The handler function to remove.
|
|
24
|
-
*/
|
|
25
|
-
off(event: string, handler: Function): void;
|
|
26
|
-
/**
|
|
27
|
-
* Emits an event, invoking all handlers registered for that event.
|
|
28
|
-
*
|
|
29
|
-
* @param {string} event - The event name.
|
|
30
|
-
* @param {...*} args - Additional arguments to pass to the event handlers.
|
|
31
|
-
*/
|
|
32
|
-
emit(event: string, ...args: any[]): void;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* 🎨 Renderer: Handles DOM patching, diffing, and attribute updates.
|
|
9
|
+
* @property {function(Object<string, any>): string} template
|
|
10
|
+
* Required function that defines the component's HTML structure.
|
|
11
|
+
* Receives the merged context (props + setup data) and must return an HTML template string.
|
|
12
|
+
* Supports dynamic expressions using {{ }} syntax for reactive data binding.
|
|
13
|
+
*
|
|
14
|
+
* @property {function(Object<string, any>): string} [style]
|
|
15
|
+
* Optional function that defines component-scoped CSS styles.
|
|
16
|
+
* Receives the merged context and returns a CSS string that will be automatically scoped to the component.
|
|
17
|
+
* Styles are injected into the component's container and only affect elements within it.
|
|
37
18
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
19
|
+
* @property {Object<string, ComponentDefinition>} [children]
|
|
20
|
+
* Optional object that defines nested child components.
|
|
21
|
+
* Keys are CSS selectors that match elements in the template where child components should be mounted.
|
|
22
|
+
* Values are ComponentDefinition objects that define the structure and behavior of each child component.
|
|
40
23
|
*/
|
|
41
|
-
declare class Renderer {
|
|
42
|
-
/**
|
|
43
|
-
* Patches the DOM of a container element with new HTML content.
|
|
44
|
-
*
|
|
45
|
-
* @param {HTMLElement} container - The container element to patch.
|
|
46
|
-
* @param {string} newHtml - The new HTML content to apply.
|
|
47
|
-
*/
|
|
48
|
-
patchDOM(container: HTMLElement, newHtml: string): void;
|
|
49
|
-
/**
|
|
50
|
-
* Diffs two DOM trees (old and new) and applies updates to the old DOM.
|
|
51
|
-
*
|
|
52
|
-
* @param {HTMLElement} oldParent - The original DOM element.
|
|
53
|
-
* @param {HTMLElement} newParent - The new DOM element.
|
|
54
|
-
*/
|
|
55
|
-
diff(oldParent: HTMLElement, newParent: HTMLElement): void;
|
|
56
|
-
/**
|
|
57
|
-
* Updates the attributes of an element to match those of a new element.
|
|
58
|
-
*
|
|
59
|
-
* @param {HTMLElement} oldEl - The element to update.
|
|
60
|
-
* @param {HTMLElement} newEl - The element providing the updated attributes.
|
|
61
|
-
*/
|
|
62
|
-
updateAttributes(oldEl: HTMLElement, newEl: HTMLElement): void;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
24
|
/**
|
|
66
|
-
* 🧩 Eleva
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* plugin integration, lifecycle hooks, event handling, and DOM rendering.
|
|
25
|
+
* @class 🧩 Eleva
|
|
26
|
+
* @classdesc Signal-based component runtime framework with lifecycle hooks, scoped styles, and plugin support.
|
|
27
|
+
* Manages component registration, plugin integration, event handling, and DOM rendering.
|
|
70
28
|
*/
|
|
71
29
|
declare class Eleva {
|
|
72
30
|
/**
|
|
73
31
|
* Creates a new Eleva instance.
|
|
74
32
|
*
|
|
75
33
|
* @param {string} name - The name of the Eleva instance.
|
|
76
|
-
* @param {
|
|
34
|
+
* @param {Object<string, any>} [config={}] - Optional configuration for the instance.
|
|
77
35
|
*/
|
|
78
|
-
constructor(name: string, config?:
|
|
36
|
+
constructor(name: string, config?: {
|
|
37
|
+
[x: string]: any;
|
|
38
|
+
});
|
|
39
|
+
/** @type {string} The unique identifier name for this Eleva instance */
|
|
79
40
|
name: string;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
41
|
+
/** @type {Object<string, any>} Optional configuration object for the Eleva instance */
|
|
42
|
+
config: {
|
|
43
|
+
[x: string]: any;
|
|
44
|
+
};
|
|
45
|
+
/** @type {Object<string, ComponentDefinition>} Object storing registered component definitions by name */
|
|
46
|
+
_components: {
|
|
47
|
+
[x: string]: ComponentDefinition;
|
|
48
|
+
};
|
|
49
|
+
/** @private {Array<Object>} Collection of installed plugin instances */
|
|
50
|
+
private _plugins;
|
|
51
|
+
/** @private {string[]} Array of lifecycle hook names supported by the component */
|
|
52
|
+
private _lifecycleHooks;
|
|
53
|
+
/** @private {boolean} Flag indicating if component is currently mounted */
|
|
54
|
+
private _isMounted;
|
|
55
|
+
/** @private {Emitter} Instance of the event emitter for handling component events */
|
|
56
|
+
private emitter;
|
|
57
|
+
/** @private {Renderer} Instance of the renderer for handling DOM updates and patching */
|
|
58
|
+
private renderer;
|
|
87
59
|
/**
|
|
88
60
|
* Integrates a plugin with the Eleva framework.
|
|
89
61
|
*
|
|
90
|
-
* @param {
|
|
91
|
-
* @param {
|
|
62
|
+
* @param {Object} plugin - The plugin object which should have an `install` function.
|
|
63
|
+
* @param {Object<string, any>} [options={}] - Optional options to pass to the plugin.
|
|
92
64
|
* @returns {Eleva} The Eleva instance (for chaining).
|
|
93
65
|
*/
|
|
94
|
-
use(plugin
|
|
66
|
+
use(plugin: Object, options?: {
|
|
67
|
+
[x: string]: any;
|
|
68
|
+
}): Eleva;
|
|
95
69
|
/**
|
|
96
70
|
* Registers a component with the Eleva instance.
|
|
97
71
|
*
|
|
98
72
|
* @param {string} name - The name of the component.
|
|
99
|
-
* @param {
|
|
73
|
+
* @param {ComponentDefinition} definition - The component definition including setup, template, style, and children.
|
|
100
74
|
* @returns {Eleva} The Eleva instance (for chaining).
|
|
101
75
|
*/
|
|
102
|
-
component(name: string, definition:
|
|
76
|
+
component(name: string, definition: ComponentDefinition): Eleva;
|
|
103
77
|
/**
|
|
104
78
|
* Mounts a registered component to a DOM element.
|
|
105
79
|
*
|
|
106
|
-
* @param {
|
|
107
|
-
* @param {string} compName - The name of the component to mount.
|
|
108
|
-
* @param {
|
|
80
|
+
* @param {HTMLElement} container - A DOM element where the component will be mounted.
|
|
81
|
+
* @param {string|ComponentDefinition} compName - The name of the component to mount or a component definition.
|
|
82
|
+
* @param {Object<string, any>} [props={}] - Optional properties to pass to the component.
|
|
109
83
|
* @returns {object|Promise<object>} An object representing the mounted component instance, or a Promise that resolves to it for asynchronous setups.
|
|
110
|
-
* @throws
|
|
84
|
+
* @throws {Error} If the container is not found or if the component is not registered.
|
|
111
85
|
*/
|
|
112
|
-
mount(
|
|
86
|
+
mount(container: HTMLElement, compName: string | ComponentDefinition, props?: {
|
|
87
|
+
[x: string]: any;
|
|
88
|
+
}): object | Promise<object>;
|
|
113
89
|
/**
|
|
114
90
|
* Prepares default no-operation lifecycle hook functions.
|
|
115
91
|
*
|
|
116
|
-
* @returns {
|
|
92
|
+
* @returns {Object<string, function(): void>} An object with keys for lifecycle hooks mapped to empty functions.
|
|
117
93
|
* @private
|
|
118
94
|
*/
|
|
119
95
|
private _prepareLifecycleHooks;
|
|
@@ -121,7 +97,7 @@ declare class Eleva {
|
|
|
121
97
|
* Processes DOM elements for event binding based on attributes starting with "@".
|
|
122
98
|
*
|
|
123
99
|
* @param {HTMLElement} container - The container element in which to search for events.
|
|
124
|
-
* @param {
|
|
100
|
+
* @param {Object<string, any>} context - The current context containing event handler definitions.
|
|
125
101
|
* @private
|
|
126
102
|
*/
|
|
127
103
|
private _processEvents;
|
|
@@ -130,8 +106,8 @@ declare class Eleva {
|
|
|
130
106
|
*
|
|
131
107
|
* @param {HTMLElement} container - The container element.
|
|
132
108
|
* @param {string} compName - The component name used to identify the style element.
|
|
133
|
-
* @param {
|
|
134
|
-
* @param {
|
|
109
|
+
* @param {function(Object<string, any>): string} [styleFn] - A function that returns CSS styles as a string.
|
|
110
|
+
* @param {Object<string, any>} context - The current context for style interpolation.
|
|
135
111
|
* @private
|
|
136
112
|
*/
|
|
137
113
|
private _injectStyles;
|
|
@@ -139,12 +115,53 @@ declare class Eleva {
|
|
|
139
115
|
* Mounts child components within the parent component's container.
|
|
140
116
|
*
|
|
141
117
|
* @param {HTMLElement} container - The parent container element.
|
|
142
|
-
* @param {
|
|
143
|
-
* @param {Array} childInstances - An array to store the mounted child component instances.
|
|
118
|
+
* @param {Object<string, ComponentDefinition>} [children] - An object mapping child component selectors to their definitions.
|
|
119
|
+
* @param {Array<object>} childInstances - An array to store the mounted child component instances.
|
|
144
120
|
* @private
|
|
145
121
|
*/
|
|
146
122
|
private _mountChildren;
|
|
147
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Defines the structure and behavior of a component.
|
|
126
|
+
*/
|
|
127
|
+
type ComponentDefinition = {
|
|
128
|
+
/**
|
|
129
|
+
* Optional setup function that initializes the component's reactive state and lifecycle.
|
|
130
|
+
* Receives props and context as an argument and should return an object containing the component's state.
|
|
131
|
+
* Can return either a synchronous object or a Promise that resolves to an object for async initialization.
|
|
132
|
+
*/
|
|
133
|
+
setup?: ((arg0: {
|
|
134
|
+
[x: string]: any;
|
|
135
|
+
}) => ({
|
|
136
|
+
[x: string]: any;
|
|
137
|
+
} | Promise<{
|
|
138
|
+
[x: string]: any;
|
|
139
|
+
}>)) | undefined;
|
|
140
|
+
/**
|
|
141
|
+
* Required function that defines the component's HTML structure.
|
|
142
|
+
* Receives the merged context (props + setup data) and must return an HTML template string.
|
|
143
|
+
* Supports dynamic expressions using {{ }} syntax for reactive data binding.
|
|
144
|
+
*/
|
|
145
|
+
template: (arg0: {
|
|
146
|
+
[x: string]: any;
|
|
147
|
+
}) => string;
|
|
148
|
+
/**
|
|
149
|
+
* Optional function that defines component-scoped CSS styles.
|
|
150
|
+
* Receives the merged context and returns a CSS string that will be automatically scoped to the component.
|
|
151
|
+
* Styles are injected into the component's container and only affect elements within it.
|
|
152
|
+
*/
|
|
153
|
+
style?: ((arg0: {
|
|
154
|
+
[x: string]: any;
|
|
155
|
+
}) => string) | undefined;
|
|
156
|
+
/**
|
|
157
|
+
* Optional object that defines nested child components.
|
|
158
|
+
* Keys are CSS selectors that match elements in the template where child components should be mounted.
|
|
159
|
+
* Values are ComponentDefinition objects that define the structure and behavior of each child component.
|
|
160
|
+
*/
|
|
161
|
+
children?: {
|
|
162
|
+
[x: string]: ComponentDefinition;
|
|
163
|
+
} | undefined;
|
|
164
|
+
};
|
|
148
165
|
|
|
149
166
|
//# sourceMappingURL=index.d.ts.map
|
|
150
167
|
|