meowerse_
docs menu

utilities

Everything @meowerse/ui exports besides components, read from the TypeScript source at build time.

functions and hooks

namesignaturenotes
applyTheme(theme: Theme): void src/lib/theme.ts
attachAllCat3D(doc?: ParentNode): () => voidAttaches every `.mw-cat3d` in `doc` except `.mw-cat3d--static` ones (the documented still fallback). src/cat3d/attach.ts
attachCat3D(root: HTMLElement): () => voidStarts the lazy renderer for one `.mw-cat3d` root (poster <img> + hidden <canvas>). Returns a cleanup. src/cat3d/attach.ts
clearSessionCache(): voidDrop the cached session — call after login, signup, or sign out. src/lib/useSession.ts
contrast(a: string, b: string): numberWCAG 2.x contrast ratio between two #rrggbb colours (1 to 21). src/lib/contrast.ts
cx(...parts: (string | false | null | undefined)[]): string src/lib/cx.ts
describeError(e: RequestError, copy?: Readonly<Record<string, string>> | undefined): stringOne plain-language sentence for any request failure (lowercase voice, B14 applies to our copy only). Apps pass their own code→copy map for backend-specific errors. src/lib/request.ts
getTheme(): Theme src/lib/theme.ts
request<T>(url: string, init?: RequestInit & { timeoutMs?: number | undefined; }): Promise<RequestResult<T>>fetch with a timeout, credentials, `res.ok` checks and a typed result — never throws. src/lib/request.ts
resolvedTheme(): "light" | "dark" src/lib/theme.ts
toggleTheme(): void src/lib/theme.ts
useSession(base: string): Session & { retry: () => void; }Session for the header + guards. Reads a short-lived sessionStorage cache synchronously (instant, no spinner on repeat navigations) and dedupes the network call across every island on the page (one fetch, not one per island). Every mounted instance subscribes to the shared load, so a retry triggered by one island (e.g. AuthGate) heals every other island sharing the page (e.g. a header) too, instead of leaving them stuck on the stale error. src/lib/useSession.ts
useToast(): (t: ToastInput) => voidreturns a function that shows one toast; call it inside a ToastProvider. src/components/Toast.tsx

constants

nametype
CONTRAST_PAIRSreadonly ContrastPair[]
DEFAULT_CONTACTSContact[]
DEFAULT_TIMEOUT_MS10000
ICON_NAMESreadonly string[]
SESSION_TIMEOUT_MS8000
STATUS_TAGSRecord<StatusState, string>
THEME_INIT_SCRIPT"(function(){try{var t=localStorage.getItem('mw-theme');var r=document.documentElement;r.classList.add('mw-no-transitions');if(t==='light'||t==='dark'){r.setAttribute('data-theme',t);}requestAnimationFrame(function(){r.classList.remove('mw-no-transitions');});}catch(e){}})();"

types

ButtonProps, CheckboxProps, ConfirmResult, Contact, ContrastPair, FieldProps, PromptProps, RadioOption, RequestError, RequestResult, Session, StatusState, Theme