📄️ xnew
xnew is the core function of the library. It creates a unit — a self-contained component instance that owns its DOM element, its event listeners, and its lifecycle.
📄️ xnew.nest
xnew.nest creates a child element and shifts unit.element to point to it. Any elements created after the call are placed inside the new element automatically — no manual parent references needed.
📄️ xnew.extend
xnew.extend runs another component function in the current unit's context and merges its returned API onto the unit. No new element is created — you're just mixing behavior in.
📄️ xnew.timeout
xnew.timeout is setTimeout with two improvements: the callback runs in the correct xnew scope, and it's automatically cancelled when the owning unit is finalized. You can also chain timeouts and transitions to build multi-step sequences without nesting callbacks.
📄️ xnew.interval
xnew.interval is setInterval with automatic cleanup. The interval stops on its own when the owning unit is finalized — no need to stash the ID and call clearInterval manually.
📄️ xnew.transition
xnew.transition drives a value from 0 to 1 over a set duration, calling your callback every frame. Feed that value into any property — opacity, position, scale, color — and you get smooth animation with one function call.
📄️ xnew.promise
xnew.promise wraps a standard Promise so its .then() / .catch() handlers run inside the current xnew component scope. If the component is finalized before the Promise resolves, the handlers are silently discarded — no stale callbacks, no crashes.
📄️ xnew.scope
xnew.scope captures the current component context and returns a wrapper that restores it when called. Use this when you need to call xnew APIs inside a raw setTimeout, setInterval, or a native addEventListener — places where the xnew scope would otherwise be lost.
📄️ xnew.context
xnew.context lets descendant components read shared data from an ancestor without passing it through every layer. It's the xnew answer to prop-drilling.
📄️ xnew.find
xnew.find returns every currently active unit created with a given component function. It's the quickest way to broadcast to all enemies, sync all counters, or run collision detection against every moving object — without maintaining manual arrays.
📄️ xnew.audio
synthesizer