CodeVetter · Repo Unpack · Extension points
preactjs/preact
Preact's main extension mechanism is the shared options object, rather than an application plugin registry. Renderer callbacks let addons intercept VNode creation, rendering, commits, errors, events, and teardown. Components, context providers, memo comparators, lazy loaders, and external-store subscribers supply narrower behavior contracts. Packaging and demo routes have explicit lists that must be updated when adding a new surface.
- Public Options declares vnode, unmount, diffed, event, requestAnimationFrame, debounceRendering, debug-value, hook-name, and attribute-serialization hooks.
- Internal Options adds _root, _diff, _commit, _render, _hook, _skipEffects, _catchError, and _hydrationMismatch contracts.
- Hooks demonstrates callback composition by capturing old options handlers and delegating to them; extensions should follow this existing chaining contract.
- options.debounceRendering overrides component queue scheduling, and options.requestAnimationFrame overrides passive-effect flushing.
- Component classes extend lifecycle and error-boundary behavior through render, shouldComponentUpdate, getChildContext, getDerivedStateFromError, and componentDidCatch.
- memo accepts a custom equality comparator; lazy accepts an asynchronous loader resolving to a default export or component.
- useSyncExternalStore integrates external state through subscribe/getSnapshot/getServerSnapshot callbacks and uses the subscription return value as effect cleanup.
- options.attr can customize compiler-generated attribute serialization, and addHookName forwards labels through options._addHookName.
- A new shipped addon must join PACKAGES and supply source/module manifest metadata; the root exports and files lists determine consumer resolution and tarball inclusion.
- New demo surfaces plug into imports, navigation links, and Router children in demo/index.jsx; the People router additionally accepts Route component or render callbacks.
- Type extensions operate through exported VNode/component/attribute interfaces and SignalLike/Signalish contracts; declaration fixtures exercise custom typed DOM attributes.