ITADN

feat(plotterext): implement charts API in FSK

#453Closedjoelkoz 创建于 2026-07-02
J
joelkozcommented
Implement the **`charts`** capability of the Plotter Extensions API in the Freeboard reference host. The host-agnostic contract is already merged and published; this is the FSK-side implementation. ## Contract (already shipped) - **Spec:** [`docs/api/plotter-extensions-api.md`](https://github.com/SignalK/freeboard-sk/blob/master/docs/api/plotter-extensions-api.md) → "Chart layers" section (merged in #452). - **Wire vocabulary:** `signalk-plotterext-bus@^0.8.0` (published; `BUS_ID` unchanged — additive). Add it as a registry range — **never** `file:`/`npm link` (poisons the lockfile → CI `npm ci` fails). ## What to build A lightweight facade over the charts FSK **already manages** — enumerate + batch-toggle visibility/opacity/stacking order. **Not** a chart provider: no create/add/delete of sources. Methods (all batch): - `chart.list` → `{ charts }` in display order (topmost first); each `{ id, name, visible, opacity, type?, bounds?, minZoom?, maxZoom? }`. - `chart.setVisibility` `{ ids, visible }` - `chart.setOpacity` `{ ids, opacity }` - `chart.setOrder` `{ order }` (topmost first; omitted ids keep relative position; host-clamped) Events (fine-grained, **origin-transparent** — emit for the user's own chart-panel toggles too, one per *changed* chart for the batch calls): - `chart.visibility` `{ id, visible }` · `chart.opacity` `{ id, opacity }` · `chart.order` `{ order }` Errors: `charts.unknownId` / `charts.badRequest` / `charts.notSupported`. ## Where it lands (recon map) - New `chartsMethods()` in `src/app/modules/plotterext/plotterext.service.ts`, merged into the method tables at the three attach points (widget ~L1353, panel ~L1408, background ~L1453) — mirror `routeMethods()`. - Add `'charts'` to `HOST_CAPABILITIES` in `src/app/modules/plotterext/types.ts`. - New `bridgeChartEvents()` alongside `bridgeRouteEvents()` (~L685) — an `effect()` on `skres.charts()` emitting the fine-grained events via `broadcastMessage()`. - Delegate to existing `src/app/modules/skresources/resources.service.ts`: `chartSelected(ids)` (visibility), `chartSetOpacity(id, value)`, `chartOrder` + `arrangeChartLayers()` / `chartReorder()` (order). Chart id = `FBChart[0]`; metadata on `SKChart` (`name/type/bounds/minZoom/maxZoom/defaultOpacity`). ## Also in scope - Sync `dev-tools/fsk-mcp/src/tools.js`: add curated `chart.*` tools (generic `fsk_call` reaches them already, but the typed tools earn their place for discoverability). - Tests (`*.spec.ts`) for the new method handlers + event bridge. - Update `docs/freeboard/freeboard-plotter-ext-support.md` (reference-host implementation notes) — the agnostic spec already covers the contract.
关闭于 2026-07-02 0 条评论