The Element Manager is the core component responsible for discovering, loading, caching, and registering UI elements and plugins in Basalt2. It handles element lifecycle management, plugin integration, and supports multiple loading sources including local files, disk mounts, and remote HTTP sources.
For information about the plugin architecture and extension points, see Plugin Architecture. For details on individual element classes, see Element Hierarchy.
The Element Manager provides a centralized registry and loading system for all UI elements in Basalt2. It discovers elements from multiple sources, applies plugins through a hook system, and maintains both in-memory and optional global caches to optimize performance.
Key Responsibilities:
_G cache)Sources: src/elementManager.lua1-451
Sources: src/elementManager.lua14-28
The Element Manager discovers elements during initialization by scanning multiple sources in a specific order.
Local Element Discovery: src/elementManager.lua33-48
Minified Bundle Discovery: src/elementManager.lua73-85
Sources: src/elementManager.lua30-105
Local Loading: src/elementManager.lua295-298
Disk Loading: src/elementManager.lua222-236
Remote Loading: src/elementManager.lua194-220
Sources: src/elementManager.lua194-364
Hook Wrapping Logic: src/elementManager.lua327-362
Plugin Discovery and Registration: src/elementManager.lua50-71
Sources: src/elementManager.lua50-71 src/elementManager.lua327-362
| Property | Type | Default | Description |
|---|---|---|---|
autoLoadMissing | boolean | false | Automatically try to load elements from available sources when not found |
allowRemoteLoading | boolean | false | Enable loading elements from HTTP URLs |
allowDiskLoading | boolean | true | Enable loading elements from disk mounts |
remoteSources | table | {} | Map of element names to remote URLs |
diskMounts | table | {} | List of disk mount paths to scan for elements |
useGlobalCache | boolean | false | Enable caching elements in _G[globalCacheName] |
globalCacheName | string | "_BASALT_ELEMENT_CACHE" | Name of the global cache variable |
Configuration Structure: src/elementManager.lua20-28
Sources: src/elementManager.lua20-28
Save to Cache: src/elementManager.lua107-116
Load from Cache: src/elementManager.lua118-128
Cache Management Functions: src/elementManager.lua414-449
Sources: src/elementManager.lua107-128 src/elementManager.lua414-449
Auto-Load Implementation: src/elementManager.lua238-268
Sources: src/elementManager.lua238-268
ElementManager.loadElement(name)
name (string) - Element nameElementManager.getElement(name)
name (string) - Element nameElementManager.configure(config)
config (table) - Configuration options to updateElementManager.registerDiskMount(mountPath)
mountPath (string) - Path to disk mountElementManager.registerRemoteSource(elementName, url)
elementName (string), url (string)allowRemoteLoading = trueElementManager.hasElement(name)
ElementManager.isElementLoaded(name)
ElementManager.getElementList()
ElementManager.getAPI(name)
name (string) - Plugin nameElementManager.clearGlobalCache()
ElementManager.getCacheStats()
{size: number, elements: string[]}ElementManager.preloadElements(elementNames)
elementNames (table) - Array of element namesSources: src/elementManager.lua130-449
Each element in _elements registry has the following structure:
Example Registry Entry:
Sources: src/elementManager.lua39-45 src/elementManager.lua315-321
In the minified release/basalt.lua, the Element Manager integrates with the bundler's custom require() system.
Minified Bundle Structure: release/basalt.lua1-52
The Element Manager detects minified == true and registers elements from minified_elementDirectory: src/elementManager.lua73-85
Sources: release/basalt.lua1-52 src/elementManager.lua73-105
Refresh this wiki
This wiki was recently refreshed. Please wait 6 days to refresh again.