ilokesto

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:

  1. existing properties on the target
  2. category-specific plugins
  3. base plugins

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:

  • UtilinentRegister
  • BaseTypeHelperFn
  • ProxyType

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 the base category
  • PluginManager is global singleton state, so registrations affect later lookups from proxy-backed components

On this page