Files
web/packages/sdk-react/mod.ts
Dan Ditomaso 5a5755fb2b feat(sdk,sdk-react): scaffold ConfigEditor for the radio/module/channels edit flow
Replaces the (broken) web changeRegistry with a section-grain editor that
lives on the SDK. Per-connection state, signal-backed, exposed via
client.config.editor.

ConfigEditor (domain):
- baseline   = what the device most recently sent. Updated automatically
  from onConfigPacket / onModuleConfigPacket / onChannelPacket.
- working    = UI edits. setRadioSection / setModuleSection / setChannel.
- dirtyRadioSections / dirtyModuleSections / dirtyChannels signals plus
  an aggregate isDirty signal.
- Inbound baseline updates do NOT discard pending working changes — if a
  section is already dirty, the new baseline is recorded but working stays
  put; dirty bookkeeping recomputes against the updated baseline.
- reset() restores working = baseline.
- commit() wraps beginEditSettings → setConfig per dirty radio variant +
  setModuleConfig per dirty module variant + setChannel per dirty channel
  → commitEditSettings, then optimistically promotes working to baseline.
- Disconnect clears both baseline and working so a stale working copy can
  never leak across reconnects.

Domain types:
- RadioConfig and ModuleConfig are now derived directly from the proto
  Config / ModuleConfig payloadVariant union (Extract<{case: V}> shape) so
  new variants stay typed without manual list maintenance. This adds
  deviceUi (radio) and statusmessage (module) automatically.

sdk-react:
- New useConfigEditor() hook returns the editor for the active client, or
  undefined when no client is active. Components subscribe to the editor's
  signals via the existing useSignal helper.

Tests:
- 5 new ConfigEditor tests covering: clean start, dirty tracking, multi-
  section dirty, reset, mid-edit baseline update preservation, and
  disconnect-clears-state. SDK suite 49 passing.

This commit is scaffolding only — no web settings page rewires yet. The
~25 settings pages move to editor.set* / editor.commit() in follow-up
commits, replacing setChange / commitEditSettings call sites and unblocking
deletion of changeRegistry from the device store.
2026-04-25 22:47:17 -04:00

38 lines
2.3 KiB
TypeScript

export { MeshProvider } from "./src/provider/MeshProvider.tsx";
export type { MeshProviderProps } from "./src/provider/MeshProvider.tsx";
export { MeshContext } from "./src/provider/MeshContext.ts";
export { MeshRegistryProvider } from "./src/provider/MeshRegistryProvider.tsx";
export type { MeshRegistryProviderProps } from "./src/provider/MeshRegistryProvider.tsx";
export { MeshRegistryContext } from "./src/provider/MeshRegistryContext.ts";
export { useClient } from "./src/adapters/useClient.ts";
export { useClientById } from "./src/adapters/useClientById.ts";
export { useActiveClient } from "./src/adapters/useActiveClient.ts";
export { useMeshRegistry, useOptionalMeshRegistry } from "./src/adapters/useMeshRegistry.ts";
export { useSignal } from "./src/adapters/useSignal.ts";
export { useSignalValue } from "./src/adapters/useSignalValue.ts";
export { useMeshDevice } from "./src/hooks/useMeshDevice.ts";
export type { UseMeshDeviceResult } from "./src/hooks/useMeshDevice.ts";
export { useConnection } from "./src/hooks/useConnection.ts";
export type { UseConnectionResult } from "./src/hooks/useConnection.ts";
export { useChat } from "./src/hooks/useChat.ts";
export type { UseChatResult } from "./src/hooks/useChat.ts";
export { useDirectChat } from "./src/hooks/useDirectChat.ts";
export type { UseDirectChatResult } from "./src/hooks/useDirectChat.ts";
export { useDraft } from "./src/hooks/useDraft.ts";
export type { UseDraftResult } from "./src/hooks/useDraft.ts";
export { useHasNodeError, useNodeError, useNodeErrors } from "./src/hooks/useNodeError.ts";
export { useNodes } from "./src/hooks/useNodes.ts";
export { useNode } from "./src/hooks/useNode.ts";
export { useChannels, useChannel } from "./src/hooks/useChannels.ts";
export { useConfig, useModuleConfig } from "./src/hooks/useConfig.ts";
export { useConfigEditor } from "./src/hooks/useConfigEditor.ts";
export { useTelemetry } from "./src/hooks/useTelemetry.ts";
export type { UseTelemetryResult } from "./src/hooks/useTelemetry.ts";
export { usePosition } from "./src/hooks/usePosition.ts";
export { useTraceroute } from "./src/hooks/useTraceroute.ts";
export { useFileTransfer } from "./src/hooks/useFileTransfer.ts";
export { useFavoriteNode } from "./src/hooks/useFavoriteNode.ts";
export { useIgnoreNode } from "./src/hooks/useIgnoreNode.ts";