From 453867591d32e3734c9411e501dfb1870ed4a7d6 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 7 Sep 2026 06:52:20 +0000 Subject: [PATCH] docs(plugin-map): compile the README's snippets against the shipped surface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Part of objectui#5174 (batch 35): burn down the `packages/plugin-map/README.md` row in `UNGATED_DOCS` so `check-doc-snippet-types` compiles the page instead of ledgering it. - Fences 53/71: `const schema: ObjectMapSchema` with the type import from `@object-ui/types`. They parsed and "passed" before only because nothing bound them — measured with a length-preserving decimal-literal negative control on both an outer member and a nested `map` key. - Fence 135 (the three shapes `locationField` reads): the three bare record literals were the page's one parse failure (TS1005). They document three runtime-accepted INPUT shapes rather than one authorable value, so they become a table citing `extractCoordinates()` — the parser that decides the shape per record. - Fence 161: `declare const dataSource: ObjectMapProps['dataSource']` retires the live TS2304. `ObjectMapProps` is a real export of this package. The row's `TS2322x1` claim was stale for a fourth consecutive measurement. The page now reads zero, so the row is deleted rather than rewritten. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr --- packages/plugin-map/README.md | 33 ++++++++++++++++++++--------- scripts/check-doc-snippet-types.mjs | 2 -- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/packages/plugin-map/README.md b/packages/plugin-map/README.md index 3fcfe77afe..00f02c24f0 100644 --- a/packages/plugin-map/README.md +++ b/packages/plugin-map/README.md @@ -52,9 +52,10 @@ export to iterate over — the import *is* the registration. ```ts import '@object-ui/plugin-map'; +import type { ObjectMapSchema } from '@object-ui/types'; // Object-bound: the markers are the records the query returns. -const schema = { +const schema: ObjectMapSchema = { type: 'object-map', objectName: 'stores', map: { @@ -69,7 +70,9 @@ const schema = { A literal record array instead of a query, with the same `map` block: ```ts -const schema = { +import type { ObjectMapSchema } from '@object-ui/types'; + +const schema: ObjectMapSchema = { type: 'object-map', staticData: [ { id: 1, name: 'San Francisco HQ', lat: 37.7749, lng: -122.4194 }, @@ -130,17 +133,25 @@ and it does not cost the view its fit. ## Coordinate formats -`locationField` reads any of: +`locationField` names one record field, and the value in it is read at RUNTIME: +`extractCoordinates()` in `packages/plugin-map/src/ObjectMap.tsx` tests the value's +shape per record and takes the first of these three that answers. So this is a +reference read of what that parser accepts, not a value you author — which is why +it is a table rather than a snippet: -```ts -{ location: { lat: 37.7749, lng: -122.4194 } } // also latitude/longitude, lon -{ location: '37.7749,-122.4194' } // "lat,lng" -{ location: [37.7749, -122.4194] } // [lat, lng] -``` +| Shape of `record[locationField]` | Example value | What the parser accepts | +| --- | --- | --- | +| Object | `{ lat: 37.7749, lng: -122.4194 }` | `lat` or `latitude` for the latitude; `lng`, `lon` or `longitude` for the longitude. Both must already be numbers — an object form is not string-parsed. | +| String | `'37.7749,-122.4194'` | `"lat,lng"`: split on the comma, each half trimmed and `parseFloat`-ed. | +| Array | `[37.7749, -122.4194]` | `[lat, lng]`, exactly two elements, each `parseFloat`-ed. | + +The lat/lng PAIR (`latitudeField` + `longitudeField`) is tried first and is +stricter: both values must already be numbers, with no parsing step at all. A record whose coordinates are missing, unparseable, or out of range (latitude beyond ±90, longitude beyond ±180) is left off the map and counted in a notice -above it, rather than being silently dropped or rescued. +above it, rather than being silently dropped or rescued. The range test and the +notice live in that same file, alongside the parser. ## What this component does not read @@ -159,7 +170,9 @@ host that registers types itself) and the `ObjectMapProps` type are the package' exports: ```tsx -import { ObjectMap } from '@object-ui/plugin-map'; +import { ObjectMap, type ObjectMapProps } from '@object-ui/plugin-map'; + +declare const dataSource: ObjectMapProps['dataSource'];