Read the root AGENTS.md first. This file adds data-specific rules.
System data providers and reactive hooks: CPU, memory, disk, processes, network, plus useFetch, useHttpHealth. Raw providers live in their own files (cpu.ts, memory.ts). Hooks live in src/hooks.ts.
- Add the hook to
src/hooks.ts. - Export the hook and its types from
src/index.ts. - Reactive hooks use
useState,useEffect,useRef,useCallbackfrom@termuijs/jsx.
- Do not import from
bun. NoTimertype. UseReturnType<typeof setTimeout>for timer refs. Published code runs on Node 18+. - Use Web-standard globals (
WebSocket,fetch,setTimeout) directly. They exist on both Bun and Node 18+. No import needed. - Clean up in the
useEffectreturn: close sockets, clear timers, abort controllers. Guard async callbacks with anisMountedflag. - A hook test file is
.test.tsxand needs/** @jsxImportSource @termuijs/jsx */at the top, plus@termuijs/testingin devDependencies. Render withrender(<Component />)from@termuijs/testing.
bun vitest run packages/data