Menu

Configuration System

Relevant source files

The Configuration System is an annotation-driven metadata registry that automatically generates a component catalog (config.lua) by scanning source files for special comment annotations. This registry serves as the single source of truth for component metadata, dependencies, and categorization, powering both the build pipeline and the custom installation system.

For information about the build and bundling process, see Build Pipeline. For installation modes and deployment, see Installation.

Purpose and Scope

The Configuration System provides:

  • Annotation-based metadata - Component information is declared inline with source code using @config* annotations
  • Automatic registry generation - The generate-config.lua tool scans source files and produces config.lua
  • Component categorization - Automatically categorizes files into core, libraries, elements, and plugins
  • Dependency tracking - Extracts and validates component dependencies from @requires and @class annotations
  • Installation driver - Powers the Custom installation mode by providing component metadata to install.lua

System Architecture

The Configuration System operates as a build-time code analysis pipeline:

Sources: tools/generate-config.lua1-153 config.lua1-510 install.lua8-21

Source Code Annotations

Component metadata is declared using special comment annotations that are parsed during configuration generation:

Annotation Reference

AnnotationPurposeExampleDefault Value
@configDescriptionHuman-readable component description@configDescription A button element"" (empty string)
@configDefaultWhether component is included by default@configDefault falsetrue
@requiresComponent dependency (can be repeated)@requires VisualElement{} (no dependencies)
@classClass inheritance (parsed for dependencies)@class Button : VisualElementN/A

Annotation Examples

Elements use annotations to declare metadata:

Elements can specify non-default inclusion:

Components can declare multiple dependencies:

Sources: tools/generate-config.lua26-63 config.lua107-444

Configuration Generation Process

The generate-config.lua tool implements a four-stage pipeline:

Stage 1: File Discovery

The scanner uses find to recursively locate all .lua files in the source directory, excluding LuaLS.lua.

Sources: tools/generate-config.lua78-100

Stage 2: Annotation Parsing

For each file, parseFile() extracts metadata:

The function uses Lua pattern matching to extract annotation values:

  • @configDescription: content:match("%-%-%-@configDescription%s*(.-)%s*\n")
  • @configDefault: content:match("%-%-%-@configDefault%s*(%w+)")
  • @requires: content:gmatch("%-%-%-@requires%s*(%w+)")
  • @class: content:match("%-%-%-@class%s*([^%s:]+)%s*:%s*([^%s\n]+)")

Sources: tools/generate-config.lua26-63

Stage 3: Categorization

Files are automatically categorized based on path patterns:

Sources: tools/generate-config.lua65-76

Stage 4: Dependency Validation

After categorization, the system validates all dependencies:

This ensures that every @requires annotation references an actual component in the system.

Sources: tools/generate-config.lua123-138

Config.lua Structure

The generated config.lua file is a Lua table with two top-level keys:

Category Structure

Each category follows this schema:

Example: Button Component Entry

From config.lua:

Sources: config.lua1-510

Integration with Installation System

The install.lua script consumes config.lua to implement three installation modes:

Dev Installation Mode

Downloads all components from all categories:

Sources: install.lua52-83

Custom Installation Mode

Uses config.lua to populate selectable component lists:

The UI presents components with their metadata:

Sources: install.lua343-398 install.lua485-638

Dependency Resolution

The Configuration System tracks two types of dependencies:

Explicit Dependencies (@requires)

Components explicitly declare dependencies:

This generates:

Implicit Dependencies (@class inheritance)

Class inheritance automatically adds the parent as a dependency:

The parser extracts the parent class:

The special case parent ~= "PropertySystem" prevents adding PropertySystem as a dependency since it's mixed in rather than inherited.

Sources: tools/generate-config.lua57-60

Dependency Graph Example

When a user selects ComboBox in Custom installation, the system automatically includes: ComboBoxDropDownListCollectionVisualElementBaseElement.

Sources: config.lua204-212 config.lua356-364 config.lua426-434

Component Default States

The @configDefault annotation controls whether a component is included by default in installations:

Default Components (default: true)

Most core elements are included by default:

ComponentCategoryReason
ButtonelementsCommon UI element
LabelelementsCommon UI element
ContainerelementsEssential container
FrameelementsEssential container
ListelementsCommon data display

Optional Components (default: false)

Large or specialized components are opt-in:

ComponentCategorySize (bytes)Reason
TextBoxelements43,530Large, specialized editor
Imageelements15,117Image format dependency
Displayelements4,668CC Window API wrapper
BigFontelements21,551Large font renderer
Graphelements6,933Specialized visualization
ComboBoxelements13,613Extends DropDown
DropDownelements7,667Extends List
LineChartelements3,171Extends Graph

Sources: config.lua240-248 config.lua356-372 config.lua400-416

File Size Tracking

The Configuration System records file sizes for progress indication during installation:

This enables accurate progress bars:

Size Statistics by Category

From the generated config:

CategoryTotal FilesTotal Size (KB)
core7~83 KB
libraries4~7 KB
elements39~395 KB
plugins7~77 KB
Total57~562 KB

Sources: tools/generate-config.lua32-34 install.lua58-69

Configuration Serialization

The serialize() function converts the configuration table to valid Lua source code:

This produces human-readable output:

Sources: tools/generate-config.lua4-24

Remote Configuration Fetching

The installer fetches config.lua from the repository:

This enables the installer to work without bundling the full configuration, and ensures it always uses the latest component metadata.

Sources: install.lua4-21

Usage Example: Adding a New Component

To add a new component to the system:

  1. Create the component file with annotations:
  1. Run the configuration generator:
  1. The component is automatically:

    • Categorized into elements (based on path src/elements/DataWidget.lua)
    • Added to config.lua with metadata
    • Dependency on VisualElement validated
    • Marked as non-default (won't be included in standard installations)
  2. Users can now:

    • See DataWidget in the Custom installation UI
    • Read its description: "A specialized visualization widget for real-time data"
    • Install it along with its dependency VisualElement

Sources: tools/generate-config.lua102-147

Summary

The Configuration System provides a centralized, annotation-driven approach to component metadata management:

  • Single source of truth - All component metadata lives in source code annotations
  • Automated generation - No manual maintenance of component registries
  • Dependency validation - Build-time checks ensure all dependencies exist
  • Installation flexibility - Powers Dev, Release, and Custom installation modes
  • Progress tracking - File sizes enable accurate installation progress indicators

The system bridges the gap between development-time organization and deployment-time needs, enabling users to install exactly the components they need while maintaining dependency integrity.

Sources: tools/generate-config.lua1-153 config.lua1-510 install.lua1-689