How tarekraafat/eleva works
Main Components
• Core Library (Eleva Core): Represented by files like src/core/Eleva.js and its TypeScript declarations in types/core/Eleva.d.ts. This is the heart of the framework.
• Modules: These include specialized functionalities to support the framework’s features:
• Emitter (src/modules/Emitter.js / types/modules/Emitter.d.ts): Provides event handling and inter-component communication.
• Renderer (src/modules/Renderer.js / types/modules/Renderer.d.ts): Handles the high-performance DOM diffing and patching.
• Signal (src/modules/Signal.js / types/modules/Signal.d.ts): Implements the reactive data holder that supports signal-based reactivity.
• TemplateEngine (src/modules/TemplateEngine.js / types/modules/TemplateEngine.d.ts): Manages template parsing and safe expression evaluations.
• Build & Distribution System: Indicate build configurations and outputs:
• Configuration files like .babelrc, eslint.config.js, rollup.config.js, and tsconfig.json.
• The dist folder contains the final UMD and ES module builds along with their source maps.
• Documentation & Examples:
• The docs folder (with assets like docs/imgs and docs/index.md) helps in visualizing the library’s API and usage.
• The examples folder provides usage examples (e.g., counter, custom plugin, todo-app) that show how the components integrate in practice.
• Testing Infrastructure: The test folder using Jest (test/ElevaCore.test.js, etc.) ensures reliability and correctness.
• Development Tools & Type Definitions:
• Configuration for development (Jest, Babel, Prettier, ESLint).
• A dedicated types folder for TS support to improve developer experience.
Their Relationships and Interactions
• Eleva Core acts as the orchestrator that brings together all modules. It provides the public API (such as app.component and app.mount) which internally leverages:
• Signal for state management and reactivity.
• Renderer for efficient DOM updates.
• Emitter for event handling between components.
• TemplateEngine for dynamic HTML template interpolation.
• The build system (using Rollup for bundling) takes the source in the src folder and compiles it along with type definitions which are then output in the dist and types directories.
• Testing is connected to each module to ensure every unit (core and modules) behaves as expected.
• The documentation and examples serve as an external guide, showing how the core and modules are integrated in real-world applications.
Architectural Patterns and Design Principles
• Modular Architecture: Each module (Emitter, Renderer, Signal, TemplateEngine) is a separate component that can be reused or replaced by plugins.
• Unopinionated & Flexible Design: Eleva does not enforce a strict structure on applications. Instead, it gives developers free rein to compose components.
• Minimalism and Performance Focus: The design strictly uses vanilla JavaScript with no external dependencies, keeping the footprint extremely low (around ~4 KB minified) while ensuring performance (efficient reactivity and DOM diffing).
• Separation of Concerns: Building different roles (state management, event handling, rendering, templating) into discrete subcomponents facilitates clear responsibilities and easier maintenance.