Config Registry API
API Reference: Engine · Types · Storage · Events · Security · Servers · Placement · Lightbox · Lens · Embeds · Coordinators · This Page
Global registry that connects configs to web components. Register a config once, and every <alap-link>, <alap-lightbox>, and <alap-lens> on the page can use it.
Quick start
import { registerConfig, defineAlapLink } from 'alap';
registerConfig(myConfig);
defineAlapLink();<!-- Uses the default config automatically -->
<alap-link query=".coffee">coffee spots</alap-link>Functions
registerConfig(config, name?)
Registers a config object and creates a corresponding AlapEngine instance. Both are stored in the global registry.
function registerConfig(config: AlapConfig, name?: string): void| Parameter | Type | Default | Description |
|---|---|---|---|
config | AlapConfig | required | The config object |
name | string | '_default' | Registry key for this config |
// Single config (most common)
registerConfig(myConfig);
// Multiple configs on one page
registerConfig(docsConfig, 'docs');
registerConfig(blogConfig, 'blog');updateRegisteredConfig(config, name?)
Updates a previously registered config and its engine. If the config doesn't exist yet, falls back to registerConfig.
function updateRegisteredConfig(config: AlapConfig, name?: string): voidUse this for runtime config changes — the engine updates in place, and all web components using that config see the new data immediately.
getEngine(name?)
Retrieves the engine instance for a registered config.
function getEngine(name?: string): AlapEngine | undefinedReturns undefined if no config is registered under that name.
getConfig(name?)
Retrieves the raw config object.
function getConfig(name?: string): AlapConfig | undefinedNamed configs
By default, all functions use '_default' as the config name. You can register multiple configs and select them per-element with the config HTML attribute:
registerConfig(docsConfig, 'docs');
registerConfig(blogConfig, 'blog');<!-- Uses 'docs' config -->
<alap-link config="docs" query=".guide">guides</alap-link>
<!-- Uses 'blog' config -->
<alap-lightbox config="blog" query=".post">posts</alap-lightbox>
<!-- Uses '_default' config (attribute omitted) -->
<alap-lens query=".bridge">bridges</alap-lens>All web components (<alap-link>, <alap-lightbox>, <alap-lens>) share the same global registry. A single config registration feeds every renderer and instance on the page.
How web components use the registry
When a web component opens (click or programmatic), it:
- Reads its
configattribute (defaults to'_default') - Calls
getEngine(configName)to get the engine - Calls
engine.resolve(query)to get links - Renders the result
If no engine is found, a warning is logged:
<alap-link>: no config registered for "myconfig". Call registerConfig() first.Example: runtime config update
import { registerConfig, updateRegisteredConfig } from 'alap';
// Initial registration
registerConfig(baseConfig);
// Later — add new links at runtime
const extended = mergeConfigs(baseConfig, {
allLinks: {
newItem: { label: 'New', url: '/new', tags: ['recent'] },
},
});
updateRegisteredConfig(extended);
// All <alap-link> elements now see the new item