ilokesto

Proxy registry internals

Proxy components are created by combining a base renderer, all known HTML tags, and a Proxy lookup. Reads check existing target properties first, then known HTML tags, then the requested category and finally base in PluginManager. Whatever is resolved is cached on the target and returned directly afterwards.

This means Show.div is available immediately, while Show.Link appears after PluginManager.register({ show: { Link } }).

Lazy tag wrappers

Tag wrappers are created on first access, not when the proxy is created. Reading Show.div resolves and caches the wrapper once; every later read returns the same instance.

Importing the package evaluates five polymorphic proxies (Show, For, Mount, Repeat, Switch). Previously each proxy allocated a wrapper for every known tag at module evaluation — 85 tags × 5 proxies = 425 forwardRef wrappers. Now none are created until a tag variant is first read. These are measured creation counts from the package's counting-factory tests; per-wrapper heap savings were not measured.

Reflection keeps the same shape as before:

  • "span" in Show reports true without creating the wrapper.
  • Object.keys(Show) and for...in still list every tag. Enumeration reads each property descriptor, which materializes the still-virtual wrappers, so prefer direct access (Show.span) when you want to avoid allocating unused tags.
  • Object.getOwnPropertyDescriptor(Show, "div") also materializes the wrapper, so its value always matches property access.

Caching

When a plugin-backed property is resolved, utilinent stores the specialized component on the current proxy target. Register plugins before rendering code that reads the property. A cached wrapper stays on the proxy even after the plugin is unregistered; build a new proxy to pick up registry changes.

On this page