docs menu
utilities
Everything @meowerse/ui exports besides components, read from the TypeScript source at build time.
functions and hooks
| name | signature | notes |
|---|---|---|
applyTheme | (theme: Theme): void | src/lib/theme.ts |
attachAllCat3D | (doc?: ParentNode): () => void | Attaches every `.mw-cat3d` in `doc` except `.mw-cat3d--static` ones (the documented still fallback). src/cat3d/attach.ts |
attachCat3D | (root: HTMLElement): () => void | Starts the lazy renderer for one `.mw-cat3d` root (poster <img> + hidden <canvas>). Returns a cleanup. src/cat3d/attach.ts |
clearSessionCache | (): void | Drop the cached session — call after login, signup, or sign out. src/lib/useSession.ts |
contrast | (a: string, b: string): number | WCAG 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): string | One 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) => void | returns a function that shows one toast; call it inside a ToastProvider. src/components/Toast.tsx |
constants
| name | type |
|---|---|
CONTRAST_PAIRS | readonly ContrastPair[] |
DEFAULT_CONTACTS | Contact[] |
DEFAULT_TIMEOUT_MS | 10000 |
ICON_NAMES | readonly string[] |
SESSION_TIMEOUT_MS | 8000 |
STATUS_TAGS | Record<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