ElementManager
This class manages elements and plugins. It loads elements and plugins from the elements and plugins directoriesand then applies the plugins to the elements. It also provides a way to get elements and APIs.
Functions
| Method | Returns | Description |
|---|---|---|
| ElementManager.configure | - | Configures the ElementManager |
| ElementManager.registerDiskMount | - | Registers a disk mount point for loading elements |
| ElementManager.registerRemoteSource | - | Registers a remote source for an element |
| ElementManager.tryAutoLoad | boolean | Tries to load an element from any available source |
| ElementManager.loadElement | - | Loads an element by name. This will load the element and apply any plugins to it. |
| ElementManager.getElement | table | Gets an element by name. If the element is not loaded, it will try to load it first. |
| ElementManager.getElementList | table | Gets a list of all elements |
| ElementManager.getAPI | table | Gets an Plugin API by name |
| ElementManager.hasElement | boolean | Checks if an element exists (is registered) |
| ElementManager.isElementLoaded | boolean | Checks if an element is loaded |
| ElementManager.clearGlobalCache | - | Clears the global cache (_G) |
| ElementManager.getCacheStats | table | Gets cache statistics |
| ElementManager.preloadElements | - | Preloads elements into the global cache |
ElementManager.configure(config)
Configures the ElementManager
Parameters
configtableConfiguration options
ElementManager.registerDiskMount(mountPath)
Registers a disk mount point for loading elements
Parameters
mountPathstringThe path to the disk mount
ElementManager.registerRemoteSource(elementName, url)
Registers a remote source for an element
Parameters
elementNamestringThe name of the elementurlstringThe URL to load the element from
ElementManager.tryAutoLoad(name)
Tries to load an element from any available source
Parameters
namestringThe element name
Returns
booleansuccessWhether the element was loaded
ElementManager.loadElement(name)
Loads an element by name. This will load the element and apply any plugins to it.
Parameters
namestringThe name of the element to load
Usage
ElementManager.loadElement("Button")ElementManager.getElement(name)
Gets an element by name. If the element is not loaded, it will try to load it first.
Parameters
namestringThe name of the element to get
Returns
tableElementThe element class
ElementManager.getElementList()
Gets a list of all elements
Returns
tableElementListA list of all elements
ElementManager.getAPI(name)
Gets an Plugin API by name
Parameters
namestringThe name of the API to get
Returns
tableAPIThe API
ElementManager.hasElement(name)
Checks if an element exists (is registered)
Parameters
namestringThe element name
Returns
booleanexistsWhether the element exists
ElementManager.isElementLoaded(name)
Checks if an element is loaded
Parameters
namestringThe element name
Returns
booleanloadedWhether the element is loaded
ElementManager.clearGlobalCache()
Clears the global cache (_G)
Usage
ElementManager.clearGlobalCache()ElementManager.getCacheStats()
Gets cache statistics
Returns
tablestatsCache statistics with size and element names
ElementManager.preloadElements(elementNames)
Preloads elements into the global cache
Parameters
elementNamestableList of element names to preload