Extensibility
createProxy(), PluginManager, and exported type helpers
Extensibility
@ilokesto/utilinent is not limited to the built-in components. The package also exposes the machinery used to build proxy-based variants and plugin-backed extensions.
createProxy
createProxy(base, renderForTag, category) builds a proxy object that combines:
- the base component
- generated HTML-tag variants from
htmlTags - plugin-backed variants for the given category
Resolution order matters. The current implementation checks:
- existing properties on the target
- category-specific plugins
baseplugins
That means built-ins win before plugin lookups happen.
PluginManager
A singleton registry for plugin-backed components.
Available static methods include:
register()get()getAll()has()unregister()
You register components by category name.
import { PluginManager } from '@ilokesto/utilinent';
PluginManager.register({
show: {
FancyCard: FancyCard,
},
});useIntersectionObserver
This hook is also part of the public extensibility surface because higher-level visibility components build on it.
import { useIntersectionObserver } from '@ilokesto/utilinent';
function MyComponent() {
const { ref, isIntersecting } = useIntersectionObserver({ threshold: 0.5 });
return <div ref={ref}>{isIntersecting ? "I'm visible!" : 'Keep scrolling...'}</div>;
}Exported types
The root package also exports:
UtilinentRegisterBaseTypeHelperFnProxyType
These are intended for type-safe extension patterns such as module augmentation and proxy typing.
Caveats
- plugin-backed variants do not override existing built-in properties
createProxy()only looks through the configured category and then thebasecategoryPluginManageris global singleton state, so registrations affect later lookups from proxy-backed components