eleva 0.1.0-alpha → 1.1.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 +409 -1
- package/dist/eleva.d.ts +207 -0
- package/dist/eleva.esm.js +508 -0
- package/dist/eleva.esm.js.map +1 -0
- package/dist/eleva.min.js +2 -0
- package/dist/eleva.min.js.map +1 -0
- package/dist/eleva.umd.js +516 -0
- package/dist/eleva.umd.js.map +1 -0
- package/package.json +55 -14
- package/src/core/Eleva.js +264 -0
- package/src/index.js +5 -0
- package/src/modules/Emitter.js +49 -0
- package/src/modules/Renderer.js +119 -0
- package/src/modules/Signal.js +51 -0
- package/src/modules/TemplateEngine.js +46 -0
- package/types/core/Eleva.d.ts +142 -0
- package/types/core/Eleva.d.ts.map +1 -0
- package/types/index.d.ts +3 -0
- package/types/index.d.ts.map +1 -0
- package/types/modules/Emitter.d.ts +34 -0
- package/types/modules/Emitter.d.ts.map +1 -0
- package/types/modules/Renderer.d.ts +30 -0
- package/types/modules/Renderer.d.ts.map +1 -0
- package/types/modules/Signal.d.ts +36 -0
- package/types/modules/Signal.d.ts.map +1 -0
- package/types/modules/TemplateEngine.d.ts +29 -0
- package/types/modules/TemplateEngine.d.ts.map +1 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class 🎙️ Emitter
|
|
3
|
+
* @classdesc Robust inter-component communication with event bubbling.
|
|
4
|
+
* Implements a basic publish-subscribe pattern for event handling, allowing components
|
|
5
|
+
* to communicate through custom events.
|
|
6
|
+
*/
|
|
7
|
+
export class Emitter {
|
|
8
|
+
/** @type {Object.<string, Function[]>} */
|
|
9
|
+
events: {
|
|
10
|
+
[x: string]: Function[];
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Registers an event handler for the specified event.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} event - The name of the event.
|
|
16
|
+
* @param {function(...any): void} handler - The function to call when the event is emitted.
|
|
17
|
+
*/
|
|
18
|
+
on(event: string, handler: (...args: any[]) => void): void;
|
|
19
|
+
/**
|
|
20
|
+
* Removes a previously registered event handler.
|
|
21
|
+
*
|
|
22
|
+
* @param {string} event - The name of the event.
|
|
23
|
+
* @param {function(...any): void} handler - The handler function to remove.
|
|
24
|
+
*/
|
|
25
|
+
off(event: string, handler: (...args: any[]) => void): void;
|
|
26
|
+
/**
|
|
27
|
+
* Emits an event, invoking all handlers registered for that event.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} event - The event name.
|
|
30
|
+
* @param {...any} args - Additional arguments to pass to the event handlers.
|
|
31
|
+
*/
|
|
32
|
+
emit(event: string, ...args: any[]): void;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=Emitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Emitter.d.ts","sourceRoot":"","sources":["../../src/modules/Emitter.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH;IAKI,0CAA0C;IAC1C;;MAAgB;IAGlB;;;;;OAKG;IACH,UAHW,MAAM,WACN,IAAS,IAAM,EAAH,GAAG,EAAA,KAAG,IAAI,QAIhC;IAED;;;;;OAKG;IACH,WAHW,MAAM,WACN,IAAS,IAAM,EAAH,GAAG,EAAA,KAAG,IAAI,QAMhC;IAED;;;;;OAKG;IACH,YAHW,MAAM,WACH,GAAG,EAAA,QAIhB;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class 🎨 Renderer
|
|
3
|
+
* @classdesc Handles DOM patching, diffing, and attribute updates.
|
|
4
|
+
* Provides methods for efficient DOM updates by diffing the new and old DOM structures
|
|
5
|
+
* and applying only the necessary changes.
|
|
6
|
+
*/
|
|
7
|
+
export class Renderer {
|
|
8
|
+
/**
|
|
9
|
+
* Patches the DOM of a container element with new HTML content.
|
|
10
|
+
*
|
|
11
|
+
* @param {HTMLElement} container - The container element to patch.
|
|
12
|
+
* @param {string} newHtml - The new HTML content to apply.
|
|
13
|
+
*/
|
|
14
|
+
patchDOM(container: HTMLElement, newHtml: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Diffs two DOM trees (old and new) and applies updates to the old DOM.
|
|
17
|
+
*
|
|
18
|
+
* @param {HTMLElement} oldParent - The original DOM element.
|
|
19
|
+
* @param {HTMLElement} newParent - The new DOM element.
|
|
20
|
+
*/
|
|
21
|
+
diff(oldParent: HTMLElement, newParent: HTMLElement): void;
|
|
22
|
+
/**
|
|
23
|
+
* Updates the attributes of an element to match those of a new element.
|
|
24
|
+
*
|
|
25
|
+
* @param {HTMLElement} oldEl - The element to update.
|
|
26
|
+
* @param {HTMLElement} newEl - The element providing the updated attributes.
|
|
27
|
+
*/
|
|
28
|
+
updateAttributes(oldEl: HTMLElement, newEl: HTMLElement): void;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=Renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Renderer.d.ts","sourceRoot":"","sources":["../../src/modules/Renderer.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH;IACE;;;;;OAKG;IACH,oBAHW,WAAW,WACX,MAAM,QAMhB;IAED;;;;;OAKG;IACH,gBAHW,WAAW,aACX,WAAW,QAyDrB;IAED;;;;;OAKG;IACH,wBAHW,WAAW,SACX,WAAW,QA6BrB;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class ⚡ Signal
|
|
3
|
+
* @classdesc Fine-grained reactivity.
|
|
4
|
+
* A reactive data holder that notifies registered watchers when its value changes,
|
|
5
|
+
* enabling fine-grained DOM patching rather than full re-renders.
|
|
6
|
+
*/
|
|
7
|
+
export class Signal {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new Signal instance.
|
|
10
|
+
*
|
|
11
|
+
* @param {*} value - The initial value of the signal.
|
|
12
|
+
*/
|
|
13
|
+
constructor(value: any);
|
|
14
|
+
_value: any;
|
|
15
|
+
_watchers: Set<any>;
|
|
16
|
+
/**
|
|
17
|
+
* Sets a new value for the signal and notifies all registered watchers if the value has changed.
|
|
18
|
+
*
|
|
19
|
+
* @param {*} newVal - The new value to set.
|
|
20
|
+
*/
|
|
21
|
+
set value(newVal: any);
|
|
22
|
+
/**
|
|
23
|
+
* Gets the current value of the signal.
|
|
24
|
+
*
|
|
25
|
+
* @returns {*} The current value.
|
|
26
|
+
*/
|
|
27
|
+
get value(): any;
|
|
28
|
+
/**
|
|
29
|
+
* Registers a watcher function that will be called whenever the signal's value changes.
|
|
30
|
+
*
|
|
31
|
+
* @param {function(any): void} fn - The callback function to invoke on value change.
|
|
32
|
+
* @returns {function(): boolean} A function to unsubscribe the watcher.
|
|
33
|
+
*/
|
|
34
|
+
watch(fn: (arg0: any) => void): () => boolean;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=Signal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Signal.d.ts","sourceRoot":"","sources":["../../src/modules/Signal.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH;IACE;;;;OAIG;IACH,mBAFW,GAAC,EAKX;IAFC,YAAmB;IACnB,oBAA0B;IAY5B;;;;OAIG;IACH,kBAFW,GAAC,EAOX;IAnBD;;;;OAIG;IACH,aAFa,GAAC,CAIb;IAcD;;;;;OAKG;IACH,UAHW,CAAS,IAAG,EAAH,GAAG,KAAG,IAAI,GACjB,MAAY,OAAO,CAK/B;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class 🔒 TemplateEngine
|
|
3
|
+
* @classdesc Secure interpolation & dynamic attribute parsing.
|
|
4
|
+
* Provides methods to parse template strings by replacing interpolation expressions
|
|
5
|
+
* with dynamic data values and to evaluate expressions within a given data context.
|
|
6
|
+
*/
|
|
7
|
+
export class TemplateEngine {
|
|
8
|
+
/**
|
|
9
|
+
* Parses a template string and replaces interpolation expressions with corresponding values.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} template - The template string containing expressions in the format `{{ expression }}`.
|
|
12
|
+
* @param {Object<string, any>} data - The data object to use for evaluating expressions.
|
|
13
|
+
* @returns {string} The resulting string with evaluated values.
|
|
14
|
+
*/
|
|
15
|
+
static parse(template: string, data: {
|
|
16
|
+
[x: string]: any;
|
|
17
|
+
}): string;
|
|
18
|
+
/**
|
|
19
|
+
* Evaluates a JavaScript expression using the provided data context.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} expr - The JavaScript expression to evaluate.
|
|
22
|
+
* @param {Object<string, any>} data - The data context for evaluating the expression.
|
|
23
|
+
* @returns {any} The result of the evaluated expression, or an empty string if undefined or on error.
|
|
24
|
+
*/
|
|
25
|
+
static evaluate(expr: string, data: {
|
|
26
|
+
[x: string]: any;
|
|
27
|
+
}): any;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=TemplateEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateEngine.d.ts","sourceRoot":"","sources":["../../src/modules/TemplateEngine.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH;IACE;;;;;;OAMG;IACH,uBAJW,MAAM;;QAEJ,MAAM,CAOlB;IAED;;;;;;OAMG;IACH,sBAJW,MAAM;;QAEJ,GAAG,CAgBf;CACF"}
|