mirror of
https://github.com/meshtastic/web.git
synced 2026-07-30 22:46:30 -04:00
Sweep covering several unrelated cohorts: - Delete dead `NewDeviceDialog.tsx` (commented-out in App.tsx, imports point at non-existent `@components/PageComponents/Connect/*`). - Add `better-result` to sdk-react deps so `useChat`/`useDirectChat`/ `useFavoriteNode`/`useIgnoreNode` resolve. - Fix `test-utils.tsx`: route at `routeTree.gen.ts` was never generated; re-export the existing `routeTree` constant from `routes.tsx` and pass the missing router context + DeviceWrapper deviceId. - Pre-existing `noUncheckedIndexedAccess` violations in `pskSchema.test.ts`, `x25519.ts`, `Table/index.tsx` + test, `useCopyToClipboard` (Timeout vs number) — non-null asserts where the index is guaranteed by the surrounding code, plus a defensive `if (!cell) return 0` in the table sort. - Immer `WritableDraft<T>` mismatches against SDK's `MeshDevice`/`Device` classes — cast through `Draft<X>` where the inferred recursive draft type can't represent SDK class internals. - `deviceStore.mock` updated for the `connectionPhase`/`connectionId` + setters added when the connection lifecycle was extracted. - `HeatmapLayer` accepts the `isVisible` prop everyone else's layer accepts. - `SNRTooltipProps.to` widened to `string | undefined` (single-node hover has no `to`). - Zod resolver returns `Record<string, never>` for the error-path values shape that react-hook-form expects. - Mock `NodeInfo` in `useFilterNode.test.ts` gains the `isMuted` proto field that landed upstream.
@meshtastic/sdk-react
React hooks and provider for @meshtastic/sdk.
Install
pnpm add @meshtastic/sdk @meshtastic/sdk-react @meshtastic/transport-web-serial
Quickstart
import { MeshClient } from "@meshtastic/sdk";
import { MeshProvider, useDevice, useChat } from "@meshtastic/sdk-react";
import { TransportWebSerial } from "@meshtastic/transport-web-serial";
import { ChannelNumber } from "@meshtastic/sdk";
const transport = await TransportWebSerial.create({ baudRate: 115200 });
const client = new MeshClient({ transport });
await client.connect();
function App() {
return (
<MeshProvider client={client}>
<Status />
</MeshProvider>
);
}
function Status() {
const { status, myNodeNum } = useDevice();
const { messages, send } = useChat(ChannelNumber.Primary);
return <div>{status} / {myNodeNum} / {messages.length} msgs</div>;
}
All hooks are read-only against a single MeshClient instance supplied through context. Commands are returned as stable functions.
License
GPL-3.0-only.