Named registries mapping a node's type string to its component module.
A host app almost always ends up with more than one palette. A page builder and, say, a broadcast-overlay editor both want Athanor components, but neither wants the other's modules showing up in its palette or resolvable from its trees. So a registry is always named, and every lookup says which one it means.
Configuration
config :athanor, :registries,
page_builder: [
components: [MyApp.Components.Hero, MyApp.Components.Card],
fallback_resolver: {MyApp.LegacyResolver, :resolve_type}
],
channel_overlays: [
components: [MyApp.Overlays.Text, MyApp.Overlays.MarqueeText]
]:components is a list of modules implementing Athanor.Component. Lookup
matches node["type"] against each module's metadata().type.
:fallback_resolver is an optional {module, function} tuple, scoped to its
registry. When a type is not found in that registry's :components, the
resolver is called as module.function(type_string) and may return a module
or nil — how a consumer keeps existing dispatch wired in during a gradual
migration.
Config is read at call time via Application.get_env/2, so test setup can
swap registries per scenario.
Naming a registry at each call site
Rendering reads the name off Athanor.Ctx (ctx.registry), which
Athanor.Renderer threads through dispatch. Editor consumers declare it once
as the required registry: option of use Athanor.Editor.Live.
Errors are loud
An unknown registry name raises rather than resolving to an empty list: a typo that silently turned every component into "Unknown component type" would be far harder to diagnose than a crash naming the registries that do exist.
Summary
Functions
Return registry's configured component modules.
Return a flat list of metadata/0 maps for every component in registry.
Convenient for editor palettes and similar UI surfaces that iterate components
by display info.
Return the module registered for type in registry, or nil.
Return the metadata for the module registered for type in registry, or
nil.
Return the names of every configured registry.
Functions
Return registry's configured component modules.
Return a flat list of metadata/0 maps for every component in registry.
Convenient for editor palettes and similar UI surfaces that iterate components
by display info.
Return the module registered for type in registry, or nil.
Return the metadata for the module registered for type in registry, or
nil.
Return the names of every configured registry.