Vanilla JS / Web Components
@vhyxseal/vanilla provides Web Components custom elements and a contract registry for framework-free JavaScript environments. Use it to add semantic contracts to any HTML page, Astro site, plain JavaScript app, or as a progressive enhancement layer on existing markup.
What the Adapter Provides
- SealButton, SealInput, SealForm, SealNav, SealDisplay, SealConfirmation β Web Components custom elements with contract registration lifecycle
- defineVhyxSealElements() β registers all six custom elements with the browser
- createSealRegistry() β creates an isolated contract registry for non-browser environments
- All elements auto-register with the internal module-level registry on DOM connect and unregister on disconnect
Installation
Browser-only. Custom elements require a browser environment with customElements support (all modern browsers).
Full Setup
createSealRegistry()
For server-side or testing use cases where the browser registry is not available. Creates an isolated, non-global registry.
Custom Elements Usage
SealButton
Adds role=βbuttonβ and tabindex=β0β on connect. Registers contract with globalRegistry.
SealConfirmation
Custom confirmation lifecycle with typed custom events. Events bubble to parent elements.
All Elements Reference
| Element | HTML Tag | ARIA setup on connect | Notes |
|---|---|---|---|
| SealButton | <seal-button> | role="button", tabindex="0" | Keyboard accessible by default |
| SealInput | <seal-input> | role="textbox" | Wraps any input element |
| SealForm | <seal-form> | β | Form container with contract registration |
| SealNav | <seal-nav> | role="navigation" | Navigation landmark |
| SealDisplay | <seal-display> | aria-live="polite" | Configurable via aria-live attribute |
| SealConfirmation | <seal-confirmation> | β | Fires confirmationrequested, confirmationconfirmed, confirmationcancelled custom events |
TypeScript Types
Common Patterns
Progressive enhancement of an existing form
Generating a manifest server-side
Known Limitations
- Browser-only β custom elements require a DOM environment. Use createSealRegistry() for server-side or test environments
- The internal globalRegistry is not exported from the public API β use createSealRegistry() for isolated registries
- Private class fields (#contract, #confirmed, #isPending) compile to WeakMap-based implementation targeting ES2020 β true runtime privacy, small performance overhead
- defineVhyxSealElements() is idempotent β safe to call multiple times, guards with customElements.get() before each define()
- No built-in manifest serving β use your server framework to serve the registry contents at /__agent__/manifest.json (see example 2)