# ranuts API (Generated) Auto-generated by `bin/generate-api-docs.ts` (`npm run doc:api`). Per-entry-point reference of every exported symbol with its signature and one-line description, extracted from source + JSDoc. For orientation (which entry to import, runtime constraints, conventions) read [../CLAUDE.md](../CLAUDE.md) first. Import from the **subpath** that owns the symbol, e.g. `import { debounce } from 'ranuts/utils'`. The root `ranuts` barrel re-exports the utils + visual surface. **437 exports** across 7 entry points. ## Entry points - [`ranuts/utils`](#ranuts-utils) — Browser and general-purpose utilities · _browser + node_ · 348 exports - [`ranuts/sw`](#ranuts-sw) — Service Worker caching strategies and the precache protocol · _service worker only_ · 9 exports - [`ranuts/visual`](#ranuts-visual) — 2D rendering engine (Canvas / WebGL / WebGPU) · _browser only_ · 16 exports - [`ranuts/i18n`](#ranuts-i18n) — Framework-agnostic i18n engine (also re-exported from ranuts/utils) · _browser + node_ · 9 exports - [`ranuts/vnode`](#ranuts-vnode) — Snabbdom-style virtual DOM · _browser_ · 26 exports - [`ranuts/stream`](#ranuts-stream) — SSE parsing, a provider-neutral model-stream fold, and the token budget that decides when a history stops fitting · _browser + node_ · 20 exports - [`ranuts/conversation`](#ranuts-conversation) — Project an append-only event log into renderable conversation nodes · _browser + node_ · 9 exports ## `ranuts/utils` Browser and general-purpose utilities · runtime: **browser + node** · source: `src/utils/index.ts` ```ts import { /* … */ } from 'ranuts/utils'; ``` ### Functions - `acceptPortBridge({ targetOrigin, name, }?: AcceptPortBridgeOptions) => Promise` — Acceptor: wait for the port the initiator hands over and return the bridge once the - `addClassToElement(element: Element, addClass: string) => void` — Add a class to an element - `addNumSym(value: string | number, flag?: string | number) => string` - `adoptSheetText(shadowRoot: ShadowRoot, cssText: string, marker?: string) => void` — Inject dynamic styles supplied at runtime (a component's `sheet` property, say). - `adoptStyles(shadowRoot: ShadowRoot, cssText: string, marker?: string) => void` — Inject a component's static styles into a shadow root. - `alignCrossAxis(align: PlacementAlign, anchorStart: number, anchorSize: number, floatingSize: number) => number` — Where a floating panel starts along the cross axis, given how - `appendUrl(url: string, params?: Record) => string` — Turn an object into a query string and append it to a URL - `arrayBufferToString(buffer: ArrayBuffer | Uint8Array) => string` — Decode bytes into a string using the sniffed encoding. Required when reading - `autosizeTextarea(element: HTMLTextAreaElement) => (() => void)` — Make a `